K
K
kr_ilya2021-03-01 16:35:04
go
kr_ilya, 2021-03-01 16:35:04

How to fill an array with binary CC numbers in order?

It is necessary to fill a two-dimensional array with six-bit numbers of the binary number system in order, starting from 0. Each bit of the number must be a separate element of the "internal array."
To end up with an array like this:
603ced1dd25f9636206122.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uvelichitel, 2021-03-01
@kr_ilya

Well, for example like this

var ot [64][6]int
for i := 0; i < 64; i++ {
  for j := 0; j < 6; j++ {
    ot[i][5-j] = (i >> j) % 2
  }
}

you can https://play.golang.org/p/Dg6NZOh-uUo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question