Last active
March 9, 2016 07:12
-
-
Save louy2/378c696fea6a1b9eaf3e to your computer and use it in GitHub Desktop.
「縞ニーソセット」ゲットチャレンジ!https://paiza.jp/poh/ando | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
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 ( | |
"fmt" | |
"os" | |
"log" | |
"strconv" | |
"bufio" | |
) | |
func parseStdin() (int, int) { | |
stdin := bufio.NewScanner(os.Stdin) | |
stdin.Scan() | |
unitLen, err := strconv.Atoi(stdin.Text()) | |
if err != nil { | |
log.Fatal("fail to convert unitLen") | |
} | |
// fmt.Println(unitLen) | |
stdin.Scan() | |
totalLen, err := strconv.Atoi(stdin.Text()) | |
if err != nil { | |
log.Fatal("fail to convert totalLen") | |
} | |
// fmt.Println(totalLen) | |
return unitLen, totalLen | |
} | |
func main(){ | |
unitLen, totalLen := parseStdin() | |
colors := []string{"R", "W"} | |
for i := 0; i < totalLen; i++ { | |
fmt.Print(colors[i / unitLen % 2]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment