Skip to content

Instantly share code, notes, and snippets.

@jsborjesson
Last active July 28, 2016 18:27
Show Gist options
  • Save jsborjesson/8257f416d1ebaee8f270c5e2fd63f5a9 to your computer and use it in GitHub Desktop.
Save jsborjesson/8257f416d1ebaee8f270c5e2fd63f5a9 to your computer and use it in GitHub Desktop.

Org-mode solution to this riddle.

More to learn about org-mode than to solve the riddle…

  1. The product of the 3 numbers is 36.
  2. The sum is the hallway number, which Zara knows.
  3. The largest number is unique.
  4. Zara needed the third clue.

Work out all the factors that produce 36:

product = 36
factors = []

(1..product).each {|x|
  (x..product).each {|y|
    (y..product).each {|z|
      factors << [x, y, z] if x * y * z == product
    }
  }
}

factors
1136
1218
1312
149
166
229
236
334

There are only 8 possible results, and these are the sums:

sums = factors.map { |f|
  f + ["="] << f.reduce(:+)
}
1136=38
1218=21
1312=16
149=14
166=13
229=13
236=11
334=10

Since she needed the last clue, and only 1*6*6 and 2*2*9 produce the same result, she must have gone through hallway 13 with the code 229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment