Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Look-and-say-sequence/Go/look-and-say-sequence.go
Normal file
31
Task/Look-and-say-sequence/Go/look-and-say-sequence.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func lss(s string) (r string) {
|
||||
c := s[0]
|
||||
nc := 1
|
||||
for i := 1; i < len(s); i++ {
|
||||
d := s[i]
|
||||
if d == c {
|
||||
nc++
|
||||
continue
|
||||
}
|
||||
r += strconv.Itoa(nc) + string(c)
|
||||
c = d
|
||||
nc = 1
|
||||
}
|
||||
return r + strconv.Itoa(nc) + string(c)
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := "1"
|
||||
fmt.Println(s)
|
||||
for i := 0; i < 8; i++ {
|
||||
s = lss(s)
|
||||
fmt.Println(s)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue