Go Tour Slices Exercise logic
Do I need to create a for loop in which I assign every element of my slice to a value in the range of dx?
Yes:
- an outer loop to assign a[x] with a
[]uint8
slice ofdx
size, - with an inner loop '
y
' for each elementa[x]
(which is a[]uint8
) in order to assigna[x][y]
with the asked value (ie, one of the "interesting functions" likex^y
,(x+y)/2
, andx*y
).
x
andy
are indexes in a range over a slice (a
, thena[x]
): see "For
statements".
I like (x ^ y) * (x ^ y)
:
As rwilson04 comments below:
x*x + y*y
is another good one