Skip to content

Instantly share code, notes, and snippets.

@go-ive
Last active December 23, 2015 06:29
Show Gist options
  • Save go-ive/6594490 to your computer and use it in GitHub Desktop.
Save go-ive/6594490 to your computer and use it in GitHub Desktop.
Reddit DailyProgrammer Challenge #137 - String Transposition
package main
import (
"fmt"
)
func main() {
var numLines int
fmt.Scanf("%d", &numLines)
var lines []string = make([]string, 0)
var tempLine string
var longest int
for i := 0; i < numLines; i++ {
fmt.Scanf("%s\n", &tempLine)
if len(tempLine) > longest {
longest = len(tempLine)
}
lines = append(lines, tempLine)
}
for i := 0; i < longest; i++ {
for _, jv := range lines {
if i > len(jv)-1 {
fmt.Print(" ")
} else {
fmt.Printf("%c", jv[i])
}
}
fmt.Println("")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment