Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Look-and-say-sequence/E/look-and-say-sequence.e
Normal file
26
Task/Look-and-say-sequence/E/look-and-say-sequence.e
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
def lookAndSayNext(number :int) {
|
||||
var seen := null
|
||||
var count := 0
|
||||
var result := ""
|
||||
def put() {
|
||||
if (seen != null) {
|
||||
result += count.toString(10) + E.toString(seen)
|
||||
}
|
||||
}
|
||||
for ch in number.toString(10) {
|
||||
if (ch != seen) {
|
||||
put()
|
||||
seen := ch
|
||||
count := 0
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
put()
|
||||
return __makeInt(result, 10)
|
||||
}
|
||||
|
||||
var number := 1
|
||||
for _ in 1..20 {
|
||||
println(number)
|
||||
number := lookAndSayNext(number)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue