2009-05-19: Coding Dojo Results
Thanks to everyone that came out to the coding dojo; especially anyone who did some codin’!
It was the first time doing this for everyone and I thought we did rather well. We ended up with some pretty slick C# code for parsing Roman numerals:
using System; namespace RomanNumeralsCodingDojo { public class RomanNumerals { public long Value { get; private set; } public RomanNumerals(string value) { for (var i = 0; i < value.Length-1; i++) { var charValue = Parse(value[i]); var nextCharValue = Parse(value[i+1]); if (charValue >= nextCharValue) Value += charValue; else Value -= charValue; } Value += Parse(value[value.Length-1]); } private static int Parse(char romanCharacter) { return (int) Enum.Parse(typeof (RomanCharacters), new string(new [] {romanCharacter})); } private enum RomanCharacters { I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000, } } } You can download the C# solution with unit tests here.