String>>
isValidBinary
^self allSatisfy: [:each | each = $0 or: [each = $1]]
binaryToDecimal
"The caller should ensure that self isValidBinary before calling this."
^self inject: 0 into: [:acc :each |
acc*2 + (each codePoint - $0 codePoint)]
On Mon, 27 Apr 2020 at 06:05, Roe
--- Begin Message ---
Thanks,
And the 5 can also be calculated by 2 * (char - $a) + 1
Roelof
Op 28-4-2020 om 18:31 schreef Richard Sargent:
Formula? Well, it's pretty straight forward.
Formula? Well, it's pretty straight forward.
Let's start with the size of the diamond (it field, actually). In the
example, there are two lines above and two lines below the "C" line.
C-A = 2. This number looks useful.
The dimension is 2+1+2 square.
How many spaces before a letter? C-letter i.e.
--- Begin Message ---
Hello,
I try now to solve this one :
ntroduction
The diamond kata takes as its input a letter, and outputs it in
a diamond
shape. Given a letter, it prints a diamond starting with 'A',
with the
supplied