Created
August 26, 2011 09:10
-
-
Save ukyo/1173023 to your computer and use it in GitHub Desktop.
sais go
This file contains hidden or 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" | |
| "io/ioutil" | |
| ) | |
| func getCounts() { | |
| } | |
| func getBuckets() { | |
| } | |
| func getLS(s string) []bool { | |
| l := len(s) | |
| t := make([]bool, len(s)) | |
| t[l - 1] = true | |
| for i := l - 1; i > 0; i-- { | |
| switch { | |
| case s[i - 1] == s[i]: | |
| t[i - 1] = t[i] | |
| default: | |
| t[i - 1] = s[i - 1] < s[i] | |
| } | |
| } | |
| return t | |
| } | |
| func main() { | |
| data, _ := ioutil.ReadAll(os.Stdin) | |
| s := string(data[:len(data) - 1]) + "$" | |
| t := getLS(s[:]) | |
| LS := map[bool]string{false: "L", true: "S"} | |
| fmt.Println(s) | |
| for _, v := range t { | |
| fmt.Printf("%v", LS[v]) | |
| } | |
| fmt.Println() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment