Created
April 11, 2020 19:51
-
-
Save marti1125/4c5a46433a024e8d0008b23184c2f3bf to your computer and use it in GitHub Desktop.
Let's Review
This file contains 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 ( | |
"bufio" | |
"fmt" | |
"strconv" | |
"os" | |
) | |
func main() { | |
//Enter your code here. Read input from STDIN. Print output to STDOUT | |
scanner := bufio.NewScanner(os.Stdin) | |
cases := 0 | |
if scanner.Scan() { | |
n, _ := strconv.ParseInt(scanner.Text(), 10, 64) | |
cases = int(n) | |
} | |
for i := 1; i <= cases; i++ { | |
if scanner.Scan() { | |
t := scanner.Text() | |
e := "" | |
f := "" | |
for pos, char := range t { | |
//fmt.Printf("character %c starts at byte position %d\n", char, pos) | |
if even(pos) { | |
e = e + string(char) | |
} else { | |
f = f + string(char) | |
} | |
} | |
fmt.Println(e + " " + f) | |
} | |
} | |
/*if scanner.Scan() { | |
t2 := scanner.Text() | |
fmt.Println(t2) | |
}*/ | |
} | |
func even(n int) bool { | |
return n%2 == 0 | |
} | |
func odd(n int) bool { | |
return !even(n) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment