I'll post the puzzle and solution here; hopefully someone finds it fun!
No 151 from Professor Layton and the Diabolical Box: Colin's Score
Four students took a test where every question had two possible answers, A or B. Each question was worth 10 points, for a total of 100 points.
The students' test results were posted as seen below, but the teacher forgot to tally Colin's score. Colin was heading to the teacher's office when Mary called him back, saying they could figure out his score using the results from the other tests. Can you figure out Colin's score?
Mary: 70 points
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
B | B | A | B | A | B | B | A | B | B |
Dan: 50 points
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
B | A | A | A | B | A | B | A | A | A |
Lisa: 30 points
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
B | A | A | A | B | B | B | A | B | A |
Colin: ?? points
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
B | B | A | A | A | B | B | A | A | A |
-----
Below is the program I wrote to solve it. Verbose by contemporary language standards, but almost no thinking required, and the answer in an instant! Note the original version didn't have so many comments; these are to guide the curious reader. Sadly, github's gists don't know how to color Prolog syntax. Also, due to this terribly lame layout, I would suggest the 'view raw' feature at the bottom of the gist to see it in plaintext glory.
Edit: I also gist-ed my Prolog poker solver, which I wrote about in my first Prolog post. It was my very first prolog, and there are probably shorter ways of doing what I did, but hey! Give it a looksee and hope you enjoy it ^_^
No comments:
Post a Comment