SHARE
TWEET

Untitled

a guest Feb 21st, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sing System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp1
  6. {
  7.     class StartUp
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.            var numbers = Console.ReadLine().Split().ToList();
  12.  
  13.            var letters = Console.ReadLine().Select(x => x.ToString()).ToList();  
  14.  
  15.             var result = new List<string>();
  16.  
  17.             for (int i = 0; i < numbers.Count; i++)  
  18.             {
  19.                 var sumOfDigits = 0;
  20.  
  21.                 foreach (var symbol in numbers[i])
  22.                 {
  23.                     var digit = symbol - '0';
  24.                     sumOfDigits += digit;
  25.                 }
  26.  
  27.                 if (sumOfDigits > letters.Count)
  28.                 {
  29.                     sumOfDigits = sumOfDigits % letters.Count;
  30.                 }
  31.  
  32.                 result.Add(letters[sumOfDigits]);
  33.                 letters.RemoveAt(sumOfDigits);
  34.             }
  35.  
  36.             Console.WriteLine(string.Join("", result));
  37.  
  38.         }
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top