stoyanmkd

Numerology

Dec 19th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         string[] inputData = Console.ReadLine().Split('.', ' ');
  9.  
  10.         int dd = int.Parse(inputData[0]);
  11.         int mm = int.Parse(inputData[1]);
  12.         int yyyy = int.Parse(inputData[2]);
  13.         string userName = (inputData[3]);
  14.  
  15.         long result = dd * mm * yyyy;
  16.  
  17.         if (mm % 2 != 0 )
  18.         {
  19.             result *= result;
  20.         }
  21.  
  22.         foreach (var symbol in userName)
  23.         {
  24.             if (symbol >= '0' && symbol <='9')
  25.             {
  26.                
  27.                 result += symbol - '0';
  28.             }
  29.             else if (symbol>='a' && symbol <= 'z')
  30.             {
  31.                 result += symbol - 'a' + 1;
  32.             }
  33.             else if (symbol >= 'A' && symbol <= 'Z')
  34.             {
  35.                 result += 2*(symbol - 'A' + 1);
  36.             }
  37.  
  38.         }
  39.         while (result > 13)
  40.         {
  41.             int digitSum = 0;
  42.  
  43.             while (result > 0)
  44.             {
  45.                 digitSum += (int)(result % 10);
  46.                 result /= 10;
  47.             }
  48.             result = digitSum;
  49.         }
  50.  
  51.         Console.WriteLine(result);
  52.  
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment