Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created April 11, 2020 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marti1125/4c5a46433a024e8d0008b23184c2f3bf to your computer and use it in GitHub Desktop.
Save marti1125/4c5a46433a024e8d0008b23184c2f3bf to your computer and use it in GitHub Desktop.
Let's Review
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