compute all binary sequences of lenght n

lucas's icon

i'm trying to obtain all possible binary sequences of lenght n. for exemple, for a lenght of 3 i would get

0 0 0

0 0 1

0 1 0

1 0 0

1 1 0

0 1 1

1 0 1

1 1 1

does anybody have an idea for coding it in max ?

Source Audio's icon

depending on number of bits, that could become

quite a long list of sequences ...

you can try jasch bitlist external,

or build a embedded list into coll or similar,

if you know what maximum bit size you want to use.

mizu's icon

radiogroup can be a way to follow

bzz

Roman Thilenius's icon

by converting decimal to binary.

3 digits = 111 = 7, so: uzi 7 -> decimal to binary

is there an option to do with this without repeated division? no, not a chance.

zuei's icon

Here's a native solution that doesn't rely on any externals.

Max Patch
Copy patch and select New From Clipboard in Max.
lucas's icon

hey roman thank's for this handy patch , that made me understand a bit more how binary works. and thank's a lot zuei your patch is doing exactly what i'm looking for !!