Last active
December 23, 2015 06:29
-
-
Save go-ive/6594490 to your computer and use it in GitHub Desktop.
Reddit DailyProgrammer Challenge #137 - String Transposition
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" | |
) | |
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