Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // After someone demonstrating that haskal can convert roman numerals to decimal in 1LOC
- // I thought I'd show that stupidity isn't limited to that language alone.
- // http://thedailywtf.com/Articles/Roman-Enumeration.aspx
- using System;
- using System.Linq;
- namespace RomanNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- (from fluff in " "
- let n = (from c in Console.ReadLine().ToUpper()
- where "IVXLCDM".Contains(c)
- select c == 'I' ? 1 : c == 'V' ? 5 : c == 'X' ? 10 : c == 'L' ? 50 : c == 'C' ? 100 : c == 'D' ? 500 : 1000).ToList()
- let r = from i in Enumerable.Range(0, n.Count)
- let l = i > 0 && n[i] > n[i - 1] ? -n[i - 1] * 2 : 0
- select n[i] + l
- select r.Sum()).ToList().ForEach(Console.WriteLine);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement