ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1567. SMS-spam

Моё решение/My Solution C#
Posted by Toriki 16 Oct 2017 23:12
using System;

namespace SMSSpam
{
    class Program
    {
        static void Main(string[] args)
        {
            string spam = Console.ReadLine();

            Console.WriteLine(spamPrice(spam.ToLower()));
            Console.ReadKey();
        }

        static int spamPrice (string spam)
        {
            int price = 0;

            foreach (char letter in spam)
            {
                price += LetterPrice(letter);
            }

            return price;

        }

        static int LetterPrice (char letter)
        {
            string charSet = "abcdefghijklmnopqrstuvwxyz*.,! ";

            return (charSet.IndexOf(letter) % 3) + 1;
        }
    }
}