Coding Kata, 10th of May
It's time to get your laptops out as this month as this month we will be doing a coding kata at ScotRUG, Glasgow on the 10th of May at the usual SociatyM.
As usual will gather from 6:30pm and start as soon as we can.
The night is intend for people of all levels of experience with ruby with lots of pair programming going on and hopefully general discussion.
The kata we will be attempting will be the Countdown by Brian Candler
One of the longest-running quiz shows on UK TV is called Countdown, and has a "numbers round". There are some cards laid face down in front of the host - the top row contains 'large' numbers (from the set 25, 50, 75, 100), and the rest are 'small' (1 to 10). Six cards are picked and displayed: the choice is made by one of the contestants, who typically will ask for one large number and five small ones.
Next, a machine called "Cecil" picks a target number between 100 and 999 at random. The contestants then have 30 seconds to find a way of combining the source numbers using the normal arithmetic operators (+, -, *, /) to make the target number, or to get as close as possible.
Each source card can be used no more than once. The same applies to any intermediate results, although of course you don't have to explicitly show the intermediate results.
Example: source 100 5 5 2 6 8, target 522
100 * 5 = 5005 + 6 = 11
11 * 2 = 22
500 + 22 = 522or more succinctly, (5*100)+((5+6)*2) = 522Another solution is (100+6)*5-8 = 522
Normal arithmetic rules apply, and in particular you are not allowed to use integer rounding. That is, 7 divided by 3 is 2 1/3, not 2.
The quiz is to write a program which will accept one target number and a list of source numbers, and generate a solution which calculates the target or a number as close to the target as possible.
As always a massive thanks to the lovely folks at Edgecase who are kindly sponsoring the venue for us.
Hope to see you there.
Colin & Pete

About Edgecase: We are a team of talented software artisans who love solving problems. Our dedicated group of developers and artists have individual expertise in areas such as usability, security, enterprise application integration, and business analysis. Passionate about software development, we are driven by the challenge of what we do.