Re: [Pharo-users] mentor question 4
May 2, 2020
7:37 p.m.
Op 2-5-2020 om 21:09 schreef Roelof Wobben via Pharo-users: but this seems to work : cardNumber := '4539 1488 0343 6467'. cleanDigits := cardNumber copyWithout: Character space. preWrapDigits := (cleanDigits asArray reverse collectWithIndex: [ :char :idx | (idx even) ifTrue: [ 2 * char digitValue ] ifFalse:[char digitValue]]). wrappedDigits :=Â preWrapDigits collect: [ :d | d > 9 ifFalse: [ d ] ifTrue: [ d-9 ] ]. ^ wrappedDigits sum isDivisibleBy: 10. Can the code be more improved ? Roelof
2281
Age (days ago)
2281
Last active (days ago)
0 comments
1 participants
participants (1)
-
Roelof Wobben