• + 0 comments
    for C-Sharp/ [C#]
    using System;
    using System.Collections.Generic;
    using System.IO;
    class Solution {
        static void Main(String[] args) {
            int.TryParse(Console.ReadLine(), out int n);
            
            //looping for (the number of test cases).
            for(int i = 0; i<n; i++)
            {
                //Console.ReadLine C# 8 return nullable, assigned to var for easier null check
                var line = Console.ReadLine();
                //Console.ReadLine C# 8 return nullable if no line, add null check
                string rec = line != null ? line : "";
                char[] s = rec.ToCharArray();
                
                Console.WriteLine(CheckCode(s));
            }
        }
        
        static string CheckCode(char[] data)
        {
            string evenIndex = "", oddIndex = "";
            
            for(int i = 0; i< data.Length; i++)
            {
                // 0 = even and any number Modulus by 2 == 0 is even
                if (i==0 || i % 2 == 0)
                    evenIndex += data[i];
                else
                    oddIndex += data[i];
            }
            
            // return {even and odd string}
            return $"{evenIndex} {oddIndex}"; 
        }
    }