Giter VIP home page Giter VIP logo

grid-solver's Introduction

Grid Solver

Given an n by m grid of vertices, draw a line between the vertices starting at a vertex v and finishing at another vertex w, visiting each exactly once.

About

CLI Usage

This utility implements algorithms for the existence & construction of a Hamiltonian path in an arbitrary grid graph.

For more details, see:

Usage

Draw a Hamiltonian path between two vertices in a grid graph G(n, m)

Usage: grid-solver.exe [OPTIONS]

Options:
      --width <WIDTH>      Width of the grid
      --height <HEIGHT>    Height of the grid
      --start-x <START_X>  Start vertex x coordinate
      --start-y <START_Y>  Start vertex y coordinate
      --end-x <END_X>      End vertex x coordinate
      --end-y <END_Y>      End vertex y coordinate
  -h, --help               Print help
  -V, --version            Print version

Motivation

At a recent IBM potluck, employees were presented with the following toy problem - draw a straight line through all points in the below grid starting at the start point and ending at the end point.

blank-grid

These instructions were vague as they did not explicitly state the validity of certain moves. Solutions were found both involving moving diagonally between points, and leaving the grid. However, these were both considered "exceptions"; the ideal solution would only utilize moves contained within the graph between immediately adjacent points in the right, left, up, and down directions. However, no such solution could be found by participants.

failed-attempt

I set off to write a program that would solve any general grid problem like this one. In the process, I discovered that the problem had been formalized and thoroughly explored in Hamilton Paths in Grid Graphs. I then decided to implement the algorithms described in this paper, and to communicate the results discussed in the paper (which I think are quite interesting) in this repository.

grid-solver's People

Contributors

whatsacomputertho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.