tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,4 @@
|
|||
isPalindrome := [:aString |
|
||||
str := (aString select: [:chr| chr isAlphaNumeric]) collect: [:chr | chr asLowercase].
|
||||
str = str reversed.
|
||||
].
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
String extend [
|
||||
palindro [ "Non-recursive"
|
||||
^ self = (self reverse)
|
||||
]
|
||||
palindroR [ "Recursive"
|
||||
(self size) <= 1 ifTrue: [ ^true ]
|
||||
ifFalse: [ |o i f| o := self asOrderedCollection.
|
||||
i := o removeFirst.
|
||||
f := o removeLast.
|
||||
i = f ifTrue: [ ^ (o asString) palindroR ]
|
||||
ifFalse: [ ^false ]
|
||||
]
|
||||
]
|
||||
].
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
('hello' palindro) printNl.
|
||||
('hello' palindroR) printNl.
|
||||
('ingirumimusnocteetconsumimurigni' palindro) printNl.
|
||||
('ingirumimusnocteetconsumimurigni' palindroR) printNl.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SequenceableCollection>>isPalindrome
|
||||
^self reverse = self
|
||||
Loading…
Add table
Add a link
Reference in a new issue