--- Begin Message ---Op 30-4-2020 om 16:16 schreef Roelof Wobben:nextIsOdd := true. aString reverseDo: [:digit | digit = Character space ifFalse: [ nextIsOdd ifTrue: [oddSum := ...] ifFalse: [evenSum := ...]. nextIsOdd := nextIsOdd not]].hmm, Still no luck with this code : cardNumber := '4539 1488 0343 6467'. oddSum := 0. evenSum := 0. nextIsOdd := true. cardNumber reverseDo: [:digit | digit = Character space ifFalse: [ nextIsOdd ifTrue: [oddSum := oddSum + digit asInteger ] ifFalse: [evenSum := ((digit asInteger * 2) > 9) ifTrue: [evenSum + ((digit asInteger * 2) - 9) ] ifFalse: [ evenSum + (digit asInteger * 2) ]]. nextIsOdd := nextIsOdd not]]. ^ oddSum + evenSum the answer schould be 57 where I get 1157 So some debugging to do
--- End Message ---
- Re: [Pharo-users] mentor question 4 Ben Coman
- Re: [Pharo-users] mentor questi... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Stéphane Ducasse
- Re: [Pharo-users] mentor question 4 Pablo Navarro
- Re: [Pharo-users] mentor question 4 Richard O'Keefe
- Re: [Pharo-users] mentor questi... Pablo Navarro
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard O'Keefe
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard Sargent
- Re: [Pharo-users] mentor questi... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard O'Keefe
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor questi... Richard Sargent
- Re: [Pharo-users] mentor questi... Ben Coman
- Re: [Pharo-users] mentor qu... Roelof Wobben via Pharo-users
- Re: [Pharo-users] ment... Roelof Wobben via Pharo-users