Book Reviews


[Day Permalink] Tuesday, May 25, 2004

[Item Permalink] Sets in Python -- Comment()
Apparently a sets module is included with Python 2.3. This seems to be a nice implementation. I could have used sets for implementing the solution of Einstein's Riddle.


[Item Permalink] Documented Python code for solving the so-called Einstein's Riddle -- Comment()
I improved the object-oriented Python code (EDIT: updated the link/May 29, 2007) for solving the so-called Einstein's Riddle. Now the code is documented, and the input data is in English instead of Finnish. Here are the final results of a run:
Choices: 1
1         2         3         4         5         
yellow    blue      red       green     white     
norway    denmark   finland   german    sweden    
water     tea       milk      coffee    beer      
blues     opera     rock      pop       metal     
cat       horse     bird      fish      dog       
I noticed that here is a site containing Python code for solving logic puzzles like this one. This code is rather nice, and more general than mine. On the other hand, the code is also slower due to the generality of the approach.