Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class DurankulakNumbers
- {
- static List<char> Reverse(string input)
- {
- List<char> revInput = new List<char>();
- for (int i = input.Length - 1; i >= 0; i--)
- {
- revInput.Add(input[i]);
- }
- return revInput;
- }
- static long Convert(List<char> revInput, long numSystem)
- {
- long counterTwo = 1;
- long counter = -1;
- List<long> numbersList = new List<long>();
- long temp = 0;
- long numb = 0;
- bool sign = false;
- for (int i = 0; i < revInput.Count; i++)
- {
- if ((long)revInput[i] >= 97 && (long)revInput[i] <= 102)
- {
- temp = temp + (26 * (revInput[i] - 96));
- counterTwo++;
- }
- if (sign == false)
- {
- numb = numb + temp * (long)Math.Pow(numSystem, counter);
- sign = true;
- }
- if ((long)revInput[i] >= 65 && (long)revInput[i] <= 90)
- {
- temp = ((long)revInput[i] - 65);
- counter++;
- sign = false;
- }
- }
- if (sign == false)
- {
- numb = numb + temp * (long)Math.Pow(numSystem, counter);
- }
- return numb;
- }
- static void Main()
- {
- string input = (Console.ReadLine());
- long numSystem = 168;
- List<char> revInput = Reverse(input);
- long output = Convert(revInput, numSystem);
- Console.WriteLine(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement