5 ms·
I'm not a programmer but I love logic puzzles. I didn't read past the clues and wanted to see if I could solve this beforehand. I did so and it only took me an
by starshadowx2 8y ago
I'm not a programmer but I love logic puzzles. I didn't read past the clues and wanted to see if I could solve this beforehand. I did so and it only took me an hour but I had started over early on so the actual solution was just a bit less.
Here's my solution if anyone is interested - https://imgur.com/a/MQFDdXu https://imgur.com/a/MQFDdXu
As an aside, does anyone have any good sites/links to logic puzzles like these? I really do enjoy spending time graphing them out and solving them.
- olooney 8y agoThese are usually known as Zebra puzzles: https://en.wikipedia.org/wiki/Zebra_Puzzle https://en.wikipedia.org/wiki/Zebra_Puzzle There's a very famous one apocryphally attributed to Einstein: https://udel.edu/~os/riddle.html https://udel.edu/~os/riddle.html Searching for the term "zebra puzzle" will net many results e.g.: https://www.brainzilla.com/logic/zebra/ https://www.brainzilla.com/logic/zebra/ They can be solved by hand, as you've noted, with vanilla Prolog using the technique in the article, or with constraint logic programming for which Prolog has a very powerful library (vanilla Prolog is just doing an exhaustive search.) https://en.wikipedia.org/wiki/Constraint_logic_programming https://en.wikipedia.org/wiki/Constraint_logic_programming http://www.swi-prolog.org/man/clpfd.html http://www.swi-prolog.org/man/clpfd.html Another approach is to translate them into an exact cover problem and feed them into a solver like DLX. https://en.wikipedia.org/wiki/Exact_cover https://en.wikipedia.org/wiki/Exact_cover https://www.geeksforgeeks.org/exact-cover-problem-algorithm-x-set-2-implementation-dlx/ https://www.geeksforgeeks.org/exact-cover-problem-algorithm-... This class of problem is NP-complete so don't feel bad if larger problems are too hard to solve - no one knows how to solve them efficiently!
- starshadowx2 8y agoThis is great, thank you. I'll give the "Einstein" one a go when I have some time. With a glance it looks like the same manual solution method as I did earlier, just with more charts.
- bunny9 8y agohttps://www.interviewbit.com/puzzles/ https://www.interviewbit.com/puzzles/
- starshadowx2 8y agoThese seem cool but definitely not what I'm looking for. These all look like programming puzzles whereas I just wanted more of this kind of logic/deduction puzzle.