Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
String extend [
|
||||
lookAndSay [ |anElement nextElement counter coll newColl|
|
||||
coll := (self asOrderedCollection).
|
||||
newColl := OrderedCollection new.
|
||||
counter := 0.
|
||||
anElement := (coll first).
|
||||
[ coll size > 0 ]
|
||||
whileTrue: [
|
||||
nextElement := coll removeFirst.
|
||||
( anElement == nextElement ) ifTrue: [
|
||||
counter := counter + 1.
|
||||
] ifFalse: [
|
||||
newColl add: (counter displayString).
|
||||
newColl add: (anElement asString).
|
||||
anElement := nextElement.
|
||||
counter := 1.
|
||||
]
|
||||
].
|
||||
newColl add: (counter displayString).
|
||||
newColl add: (anElement asString).
|
||||
^(newColl join)
|
||||
]
|
||||
].
|
||||
|
||||
|r|
|
||||
r := '1'.
|
||||
10 timesRepeat: [
|
||||
r displayNl.
|
||||
r := r lookAndSay.
|
||||
]
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
String compile:
|
||||
'lookAndSay |anElement nextElement counter coll newColl|
|
||||
coll := (self asOrderedCollection).
|
||||
newColl := OrderedCollection new.
|
||||
counter := 0.
|
||||
anElement := (coll first).
|
||||
[ coll size > 0 ]
|
||||
whileTrue: [
|
||||
nextElement := coll removeFirst.
|
||||
( anElement == nextElement ) ifTrue: [
|
||||
counter := counter + 1.
|
||||
] ifFalse: [
|
||||
newColl add: (counter displayString).
|
||||
newColl add: (anElement asString).
|
||||
anElement := nextElement.
|
||||
counter := 1.
|
||||
]
|
||||
].
|
||||
newColl add: (counter displayString).
|
||||
newColl add: (anElement asString).
|
||||
^('''' join: newColl)'
|
||||
classified: 'toys'.
|
||||
|
||||
result := OrderedCollection new.
|
||||
r := '1'.
|
||||
result add: r.
|
||||
result addAll: ((1 to: 10) collect: [ :i |
|
||||
r := r lookAndSay.
|
||||
]).
|
||||
result.
|
||||
Loading…
Add table
Add a link
Reference in a new issue