Day 6: Let's Review | 30 Days of Code | Hackerrank Solution

Today we will be solving Day 6: Let's Review Problem which is the sixth day topic of Hackerrank 30 Days of Code. After reading thi post you will . .

Day 6: Let's Review | 30 Days of Code | Hackerrank Solution 

Hello coders,

Today we will be solving Day 6: Let's Review Problem which is the sixth day topic of Hackerrank 30 Days of Code.

After reading this post you will get to know how to solve this problem in python.

So, Without Further Ado let's start the solution.

Day 6: Let's Review | 30 Days of Code | Hackerrank Solution


Objective 

Today we're expanding our knowledge of strings and combining it with what we've already learned about loops.

Task 

Given a string, S, of length N that is indexed from 0 to N - 1, print its even-indexed and odd-indexed as 2 space-separated strings on a single line.

Note: 0 is considered to be an index.

Input Format 

The first line contains an integer, T (the number of test cases).

Each line i of the T subsequent lines contains a String, S.

Constraints 

  • 1 ≤ T ≤ 10
  • 2 ≤ length of S ≤ 10000

Output Format 

For each String Sj (where 0 ≤ jT - 1), print Sj's even-indexed characters, followed by a space, followed by Sj's odd-indexed characters.

Sample Input 

2
Hacker 
Rank 

Sample Output 

Hce akr 
Rn ak 

Explanation 

Test Case 0: S = "Hacker"

S[0] = "H"

S[1] = "a" 

S[2] = "c"

S[3] = "k"

S[4] = "e"

S[5] = "r"

The even indices are 0,2 and 4, and the old indices are 1,3 and 5. We then print a single line of 2 space-separated strings; the first string contains the ordered characters from S's even indices (Hce), and the second string contains the ordered characters from S's odd indices (akr).

Test Case 1: S = "Rank"

S[0] = "R" 

S[1] = "a"

S[2] = "n"

S[3] = "k"

The even indices are 0 and 2, and the odd indices are 1 and 3. We then print a single line of 2 space-separated strings; the first string contains the ordered characters from S's even indices (Rn), and the second string contains the ordered characters from S's odd indices (ak).

Solution - Day 6: Let's Review

Python 3 

# Enter your code here. Read input from STDIN. Print output to STDOUT
T = int(input())
for i in range (0 , T):
    S = input()
    print(S[0::2] + " " + S[1::2])
Day 6: Let's Review | 30 Days of Code | Hackerrank Solution
Day 6: Let's Review - Solution
Day 6: Let's Review | 30 Days of Code | Hackerrank Solution
Day 6: Let's Review - Result


Conclusion 

This was the solution of Day 6: Let's Review problem. If you have any doubt regarding the problem (Day 6: Let's Review), feel free to contact in the Comment Section.

We will be delighted to help you.

Don't forget to Share it with your friends and Subscribe our Blog to receive the latest updates related to coding.

Disclaimer: The above problem is generated by Hacker Rank but the solution is provided by Sloth Coders.

Happy Coding!!

A Sloth Who loves to Code.

Sloth Coders is a Learning Platform for Coders, Programmers and Developers to learn from the basics to advance of Coding of different langauges(python, Java, Javascript and many more).

Post a Comment