Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace _01.MultiverseCommunication
- {
- class MultiverseCommunication
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<string> digits = ConvertStrToInt(input);
- Console.WriteLine(ConvertIndecimal(digits));
- }
- static string FindDigit(string substring)
- {
- string digit = String.Empty;
- switch (substring)
- {
- case "CHU": digit= "0"; break;
- case "TEL": digit= "1"; break;
- case "OFT": digit= "2"; break;
- case "IVA": digit= "3"; break;
- case "EMY": digit= "4"; break;
- case "VNB": digit= "5"; break;
- case "POQ": digit= "6"; break;
- case "ERI": digit= "7"; break;
- case "CAD": digit= "8"; break;
- case "K-A": digit= "9"; break;
- case "IIA": digit= "10"; break;
- case "YLO": digit= "11"; break;
- case "PLA": digit= "12"; break;
- default: break;
- }
- return digit;
- }
- static List<string> ConvertStrToInt(string input)
- {
- List<string> digits = new List<string>();
- for (int i = 0; i < input.Length; i+=3)
- {
- string substring = input.Substring(i, 3);
- digits.Add(FindDigit(substring));
- }
- return digits;
- }
- static BigInteger ConvertIndecimal(List<string> digits)
- {
- BigInteger result = 0;
- BigInteger powerOf13 = 1;
- for (int i = digits.Count- 1; i >= 0; i--)
- {
- result += powerOf13 * (BigInteger.Parse(digits[i].ToString()));
- powerOf13 *= 13;
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement