+ 2
Ruby - Why these values for a[0] and a[1]?
a = "3 is the answer 4 is not".to_i b = a[1]*a[0]+a[1] puts b*b puts a[0] puts a[1] puts a
1 Answer
+ 11
to_i gets first number of the string. So, a = 3
3 in binary is 00000011
First position is the 1 bit at the right.
Second position is penultimate bit
So
a[0] = 1 ( 00000001)
a[1] = 1 (00000010)
a[2] = 0 (00000000)