Sabev

Space Travel

Feb 10th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Fundamentals
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             while (true)
  14.             {
  15.                 string planet = Console.ReadLine();
  16.                 string command = Console.ReadLine();
  17.                 List<int> myList = new List<int>();
  18.                 string[] split = new string[command.Length / 2 + (command.Length % 2 == 0 ? 0 : 1)];
  19.                 for (int i = 0; i < split.Length; i++)
  20.                 {
  21.                     split[i] = command.Substring(i * 2, i * 2 + 2 > command.Length ? 1 : 2);
  22.                 }
  23.                 foreach (var item in split)
  24.                 {
  25.                     int a = int.Parse(item);
  26.                     myList.Add(a);
  27.                 }
  28.                 if (myList[0] == 71 && myList[1] == 79)
  29.                 {
  30.                     Console.WriteLine("GO HOME");
  31.                     Console.WriteLine("Going home.");
  32.                     break;
  33.                 }
  34.                 else
  35.                 {
  36.                     foreach (var item in split)
  37.                     {
  38.                         int a = int.Parse(item);                        
  39.                         Console.Write((char)a);                    
  40.                     }
  41.                     Console.WriteLine();
  42.  
  43.                 }
  44.                
  45.             }
  46.            
  47.  
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment