svetlozar_kirkov

Numerology (100/100)

Nov 13th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Numerology
  6. {
  7.     class Numerology
  8.     {
  9.         static void Main()
  10.         {
  11.             string input = Console.ReadLine();
  12.             string[] splitInput = input.Split(' ', '.');
  13.             UInt64 dateProduct = Convert.ToUInt64(splitInput[0].ToString()) *
  14.                 Convert.ToUInt64(splitInput[1].ToString())
  15.                * Convert.ToUInt64(splitInput[2].ToString());
  16.             if (Convert.ToUInt64(splitInput[1].ToString()) % 2 != 0)
  17.             {
  18.                 dateProduct *= dateProduct;
  19.             }
  20.             UInt64 usernameWeight = 0;
  21.             Dictionary<char,int> dict = new Dictionary<char, int>();
  22.             char smallLetter = 'a';
  23.             char bigLetter = 'A';
  24.             for (int i = 1; i <= 26; i++,smallLetter++,bigLetter++)
  25.             {
  26.                 dict.Add(smallLetter,i);
  27.                 dict.Add(bigLetter,i*2);
  28.             }
  29.             for (int i = 0; i < splitInput[3].Length; i++)
  30.             {
  31.                 if (dict.ContainsKey(splitInput[3][i]))
  32.                 {
  33.                     usernameWeight += Convert.ToUInt64(dict[splitInput[3][i]]);
  34.                 }
  35.                 else
  36.                 {
  37.                     usernameWeight += Convert.ToUInt64(splitInput[3][i].ToString());
  38.                 }
  39.             }
  40.             UInt64 initialSum = usernameWeight + dateProduct;
  41.             while (initialSum > 13)
  42.             {
  43.                 int[] nums = Array.ConvertAll(initialSum.ToString().ToArray(), x => (int)x - 48);
  44.                 initialSum = Convert.ToUInt64(nums.Sum());
  45.             }
  46.             Console.WriteLine(initialSum);
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment