Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolayIT/6db835d292835e53e435 to your computer and use it in GitHub Desktop.
Save NikolayIT/6db835d292835e53e435 to your computer and use it in GitHub Desktop.
Enigma Cat solution (Telerik Academy C# 2 Exam 2015)
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