Sort by

recency

|

3417 Discussions

|

  • + 0 comments
    T = int(input())  # Number of test cases
    
    for _ in range(T):
        s = input()
        even = s[0::2]
        odd = s[1::2]
        print(even,odd,sep=" ")
    
  • + 0 comments

    Java Solution

    public class Solution {
    
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       sc.nextLine();
    
       for(int i=0;i<n;i++){
        String s = sc.nextLine();
        String oddString="";
        for(int j =0 ;j<s.length();j++){
            if(j % 2 == 0)
                System.out.print(s.charAt(j));
            else
                oddString+=s.charAt(j);
        }
        System.out.println(" "+oddString);
       }
    }
    

    }

  • + 0 comments

    My js answer :

    function processData(input) {

    const lines = input.split('\n')
    const t = parseInt(lines[0])
    
    
    for(let i = 1; i<= t; i++){
        let even = "";
        let odd = "";
    
        for(let k = 0; k < lines[i].length ; k++){
            if(k % 2 === 0){
                even += lines[i][k];
            }
            if(k % 2 === 1){
                odd += lines[i][k];
            }
        }    
    
    
         console.log(even + " " + odd);
    }
    

    }

  • + 0 comments

    This is my solution with Python 3

    n = int(input())
    for i in range(n):    
        s = str(input())
        even_string = s[::2]
        odd_string = s[1::2]
        print(f"{even_string} {odd_string}")
    

    If you have any comments or improvements, please let me know!

  • + 0 comments

    t = int(input())

    for _ in range(t): s = input() even_chars = s[::2]
    odd_chars = s[1::2]
    print(even_chars, odd_chars)