fine, I'll put them on github

This commit is contained in:
Ben Charlton 2017-12-06 17:28:33 +00:00
commit c3bc233d82
9 changed files with 472 additions and 0 deletions

43
4/4.2.go Normal file
View file

@ -0,0 +1,43 @@
package main
import "os"
import "fmt"
import "strings"
import "bufio"
import "sort"
// cat input | go run 4.2.go
func main() {
failed := 0
count := 0
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
count++
s := strings.Split(scanner.Text(), " ")
fmt.Println(s)
for i := 0; i < len(s); i++ {
an := strings.Split(s[i], "")
sort.Strings(an)
san := strings.Join(an, "")
s[i] = san
}
sort.Strings(s)
for i := 1; i < len(s); i++ {
fmt.Println(i, s[i])
if s[i] == s[i-1] {
failed++
fmt.Println("Failed!", s[i], s[i-1])
break
}
}
fmt.Println("---")
}
fmt.Println(failed, count, count-failed)
}

35
4/4.go Normal file
View file

@ -0,0 +1,35 @@
package main
import "os"
import "fmt"
import "strings"
import "bufio"
import "sort"
// cat input | go run 4.go
func main() {
failed := 0
count := 0
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
count++
s := strings.Split(scanner.Text(), " ")
fmt.Println(s)
sort.Strings(s)
for i := 1; i < len(s); i++ {
fmt.Println(i, s[i])
if s[i] == s[i-1] {
failed++
fmt.Println("Failed!")
break
}
}
fmt.Println("---")
}
fmt.Println(failed, count, count-failed)
}