Solving Puzzles With Code

A few months back my wonderful wife bought me an awesome “Mensa Puzzle” daily calendar.  I love little brain teasers so I was looking forward to tackling one a day to keep the old noggin sharp.  Unfortunately, here we are approaching March and I’ve done a horrible job at finding the time to work on the puzzles.  This evening I glanced over at it and decided to tackle the entry from January 4th – yeah, I told you I’d fallen behind on it.

Here’s an image of the puzzle so you can play along at home:

Copyright belongs to the calendar publisher of course!

Since I’ve never been good at solving puzzles requiring any sort of math I decided to tackle it via code.  My first approach completely failed.  I’d share it with you, but I’ll spare you some belly laughs and just show you what I came up with after glancing at the solution on the back of the calendar.

Which got me to the solution of 199.  Here’s the answer from the calendar which explains it better than I could.

If you would have solved it differently feel free to post your solution in the comments (and feel free to use whatever language you’d like).  I think I may try to continue to solve some of these puzzles via code in the future as a way to keep my code based problem solving abilities sharp.

Todd began his journey in development with ColdFusion in 2004. Like a lot of ColdFusion developers he was the "computer guy" on his team and was assigned to a small team of developers to build intranet applications. Due to the nature of such an assignment this often led to being the sole developer on a project - responsible for everything from the server side logic, to database queries, to front end architecture and design. These responsibilities combined well with his natural desires to learn new things and soon led to him diving deep into Ajax, Flex ColdFusion frameworks and Object Oriented design patterns and methodologies. After joining Booz Allen Hamilton in 2011 he has extended his learning into many newer front end and back end frameworks and toolsets - the latest passion being Groovy/Grails and HTML5/JavaScript frameworks. Todd frequently speaks at industry conferences and has been published in numerous technical journals on various topics. When not slanging code he can be found at one of his children's various activities, hanging out with his wife or pwning n00bs on the latest edition of Call Of Duty.

Posted in Uncategorized
One comment on “Solving Puzzles With Code
  1. That was very cool practice … :-)

    Thanks for the puzzler …

    https://gist.github.com/EdwardBeckett/5046554

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>