Giter Club home page Giter Club logo

house-of-lines's Introduction

House of Lines

You are supposed to draw a house on paper without lifting your pencil or drawing any of the lines twice. If you label the corners A through E as in figure 1, one possible solution would be: A -> B -> D -> C -> E -> D -> A -> C -> B. How many possible solutions are there?

Figures

Figure 1 Figure 1

You can make it more challenging by letting the player change the pencil's direction at the point where the diagonals intersect. In that case, we would label the corners as in figure 2 and a possible solution would be: A -> C -> B -> A -> D -> C -> E -> D -> F -> E -> B. Now how many solutions are there?

Figure 2 Figure 2

Task

Write a Node.js program consisting of one or more files that finds and lists all possible ways of drawing the figure using the above notation. Once done, enhance the program to ignore solutions that are reflections of solutions already in the result set. Make this program accessible on a web page that lets the user select from the two different options. The output page should contain the solutions set along with some information about the complexity of the algorithm and time it took to calculate the result.

My solution:

This is graph theory problem. The main objective is finding Eulerian paths/trails in a finite graph.

  • I utilized Vue.js for a front-end implementation/visual guide of the algorithm.
  • To find the eulerian paths I wrote the DFS solution in Node.js (ES6). You can find the guts of it at lib/graphHelper.js
  • The algorithm itself determines the starting vertices (which is determines there would be two, A & B, since they have the odd degree), however, when displaying the result set I only output from one vertex (A) since reflections are not wanted
  • The front-end interfaces with the graphHelper module at src/App.vue.
  • The output will state a complexity of ~O(m+n) for both graphs since it utilizes the same algo.

ENJOY!

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Demo

Demo

house-of-lines's People

Contributors

tcornell05 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.