Last active
November 15, 2015 00:46
-
-
Save NikolayIT/6db835d292835e53e435 to your computer and use it in GitHub Desktop.
Enigma Cat solution (Telerik Academy C# 2 Exam 2015)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var words = Console.ReadLine().Split(' '); | |
foreach (var word in words) | |
{ | |
// 17 to decimal | |
ulong numInDec = 0; | |
for (int i = 0; i < word.Length; i++) | |
{ | |
numInDec *= 17; | |
numInDec += (ulong)(word[i] - 'a'); | |
} | |
// decimal to 26 | |
var sb = new StringBuilder(); | |
while(numInDec > 0) | |
{ | |
sb.Insert(0, (char)((numInDec % 26) + 'a')); | |
numInDec /= 26; | |
} | |
Console.Write(sb.ToString() + " "); | |
} | |
Console.WriteLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment