Created
February 28, 2021 14:40
-
-
Save MinSomai/1d0f38ec78ad633c255e0ccb994cd65d to your computer and use it in GitHub Desktop.
Day 6 : Golang | Let's Review - Hackerrank.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bufio" | |
"os" | |
"strings" | |
) | |
func main() { | |
//Enter your code here. Read input from STDIN. Print output to STDOUT | |
allInput := bufio.NewScanner(os.Stdin) | |
// ignore first input | |
allInput.Scan() | |
for allInput.Scan(){ | |
inputValue := allInput.Text() | |
charSplice := strings.Split(inputValue, "") | |
var odd, even string | |
for index, eachChar := range charSplice{ | |
if(index%2==0){ | |
odd += eachChar | |
}else{ | |
even += eachChar | |
} | |
} | |
fmt.Println(odd + " " + even) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment