Advertisement
svetlai

Untitled

Mar 1st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace NineGagNumbers
  6. {
  7.     public class NineGagNumbers
  8.     {
  9.         private static readonly List<String> NumeralSystemDigits = new List<string> { "-!", "**", "!!!", "&&", "&-", "!-", "*!!!", "&*!", "!!**!-" };
  10.         private const int NumeralSystemBase = 9;
  11.  
  12.         public static void Main()
  13.         {
  14.             string input = Console.ReadLine();
  15.             var in9th = Convert9GagTo9th(input);
  16.         }
  17.  
  18.         /// <summary>
  19.         /// Converts a number from 9Gag numeral system to 9th numeral system
  20.         /// </summary>
  21.         /// <param name="nineGagNumber">A string in 9Gag numeral system</param>
  22.         /// <returns>Returns a list of digits in numeral system with base 9</returns>
  23.         private static List<int> Convert9GagTo9th(string nineGagNumber)
  24.         {
  25.             var result = new List<int>();
  26.             StringBuilder currentDigit = new StringBuilder();
  27.  
  28.             for (int i = 0; i < nineGagNumber.Length; i++)
  29.             {
  30.                 currentDigit.Append(nineGagNumber[i]);
  31.  
  32.                 if (NumeralSystemDigits.Contains(currentDigit.ToString()))
  33.                 {
  34.                     int index = NumeralSystemDigits.IndexOf(currentDigit.ToString());
  35.                     result.Add(index);
  36.                     currentDigit.Clear();
  37.                 }
  38.             }
  39.  
  40.             return result;
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement