Skip to content

Instantly share code, notes, and snippets.

@sguzunov
Created April 20, 2016 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sguzunov/aea99e3de871e299d3dea9abdf1ac8c5 to your computer and use it in GitHub Desktop.
Save sguzunov/aea99e3de871e299d3dea9abdf1ac8c5 to your computer and use it in GitHub Desktop.
using System;
class TextToNumber
{
static void Main()
{
long result = 0;
int module = int.Parse(Console.ReadLine());
string text = Console.ReadLine();
for (int i = 0; i < text.Length; i++)
{
char sign = text[i];
if (sign == '@')
{
break;
}
else if ('0' <= sign && sign <= '9')
{
result *= (sign - '0');
}
else if ('A' <= sign && sign <= 'Z')
{
result += (sign - 'A');
}
else if ('a' <= sign && sign <= 'z')
{
result += (sign - 'a');
}
else
{
result %= module;
}
}
Console.WriteLine(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment