Code Monkey home page Code Monkey logo

tumbler-puzzle's Introduction

This is going to be my brute-force attempt at finding the solutions to my a puzzle I acquired a number of years ago (I think I may have inherited it from a roommate). Look in the docs directory for the photos of the puzzle at a number of angles, which captures all sides of it. My first task will be to convert this to a convenient schematic, data structure for manipulating.

In short (as you can probably see), the goal is to arrange the tumblers so that all four simple arithmetic equations are true simultaneously. The tumblers can be pulled apart and re-assembled, and rotated, into many permutations. There are some restrictions and simplifying constraints:

  • it makes no sense to have two operators adjacent

  • by elimination, this means all digits must be singletons (no multi-digit numbers)

  • the equal sign should not count as a real tumbler, otherwise it will result in duplicate solutions (x4), which are only different by an offset

  • the first tumbler in any permutation should be held stationary while the others are rotated, to avoid further duplicate solutions (again, x4)

To enumerate the solutions:

  • there are 24 (4!) permutations of the operator tumblers
  • there are 120 (5!) permutations of the digit tumblers
  • there are 2880 (24*120) meaningful orderings of all tumblers
  • there are 16384 (4^7) possible arrangements of each tumbler ordering (not 4^8, since we always hold one tumbler fixed)
  • there are 47185920 (2880*16384) total solutions to try

There are probably some group-theoretic arguments that can be made to really simplify the solution space, but I'm only a group theory novice.

A Lisp, or some other language with lazy evaluation (I plan to use Clojure), is probably the best tool for working through all the permutations and trying each one in-turn. It might help reduce memory footprint (we'll see).

What remains open to interpretation is whether to treat the operations as floating-point, or to treat them strictly as operating on integers. Another is whether to enforce precedence of operators, or apply them naively from left to right.

As a first pass, I'm going to assume left-to-right (for each side of the equation), and take advantage of Clojure's default representation of numbers as rationals. I could always change it later.

tumbler-puzzle's People

Contributors

pdelong42 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

tumbler-puzzle's Issues

unfix

I have to decide what to do with the unfix dependency I've pulled-in. It's got some minor issues:

  • In v1.0, the lein repl complains that rank is not dynamic, but expects it to be based on how it's named. It looks like this is fixed in v1.5, but the author hasn't pushed that to clojars yet (and probably never will - it's been fixed for over a year).
  • I feel the equality / inequality operators should bind less tightly than addition, subtraction, multiplication, and division; but they don't

Because of these changes I'd like to make, I need to decide whether to submit a pull request when I fix them, or if I should keep it forked and push to clojars under a separate namespace (or both). I've never tried the latter, so it would be a useful learning experience.

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.