Kata – Revolver Roulette

Here’s a little exercise with a violent setting. It might be worth remembering if you’re unfortunate enough to be in a situation like this:

A masked man puts two bullets into adjacent chambers of a six shooter revolver. The masked man aims the gun at you and pulls the trigger.

<click>…phew!

The chamber advances by one and the masked man prepares to fire once again. He offers you the opportunity to roll the barrel before firing again. Should you take the masked man up on his offer?

Assume you survive the second shot at this point.

Now suppose he is to fire two more times for a total of four shots.

Do you accept a spin of the chamber prior to third shot?

How about a spin of the chamber prior to the fourth?

What are your chances of survival after surviving the first shot?

Kata – Anagrams

I am going to use another kata from Dave Thomas’ Blog again! Anagrams!

Taken Directly:

The challenge is fairly simple: given a file containing one word per line, print out all the combinations of words that are anagrams; each line in the output contains all the words from the input that are anagrams of each other. For example, your program might include in its output:

kinship pinkish
enlist inlets listen silent
boaster boaters borates
fresher refresh
sinks skins
knits stink
rots sort

Use the word List for comparing results.