Giter Site home page Giter Site logo

refrigeratorpuzzlesolver's Introduction

Refrigerator Puzzle Solver

This type of puzzle is also called a monkey puzzle [1].

Refrigerator Puzzle Solver was programmed to solve a puzzle on my refrigerator. I had a bet with my girlfriend that I could find the solution quicker by writing a program, than her trying by hand. I won (as one would expect, see 'Calculate the number of configurations to test').

The refrigerator puzzle The solver

Refrigerator Puzzle Solver was programmed at the 28th of December of 2008 in C++ using the IDE C++ Builder 6.0. It uses the STL, VCL and Boost libraries

Calculate the number of configurations to test

The nine puzzle pieces can be put in 987654321 = 9! = 362880 sequences.

One puzzle piece has four orientations.

For a certain sequence of the nine pieces, there are 4^9=262144 configurations.

Therefore, the number of possibilities to test equals 362880 * 262144 = 95126814720.

Because there four solutions of the puzzle (due to rotation) one expects to need to test 95126814720 / 4 = 23781703680 configurations. That is more then 23 billion configurations!

How the program solves the puzzle

The program starts with an ordering of the nine puzzle pieces.

First, one or more puzzle pieces are rotated in a systematic way, as systematic as adding one to a four-digit number system.

Second, these (rotated) puzzle pieces are put in a recursive function. This function takes a set of used and fitting puzzle pieces and a set of unused puzzle pieces. It tries to put an unused puzzle piece in the next place, trying all unused pieces. If successful, the function calls itself with the (new) set of used puzzle pieces and the (new) set of unused puzzle pieces. If the function fails, it returns an empty solution.

Click on 'Display current' in the program to see the computer do this. Every try is shown for about 100 milliseconds, so one can actually see what happens.

References

  1. David Harel. Computers Ltd.: What They Really Can't Do. 2000. ISBN-10: 0198505558.

refrigeratorpuzzlesolver's People

Contributors

richelbilderbeek avatar

Watchers

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