caird coinheringaahing ♦
- 50.9k
- 11
- 133
- 364
Add++, 29 bytes
D,g,@@,T2€BbB^
L,bLd1_Rþ%A$þg
I'm surprised Add++ was this short. Takes input as a list of bits
How it works
D, ; Define a helper function
g, ; called g
@@, ; that takes 2 arguments e.g. [8 [1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0]]
T ; Split into chunks; [[1 1 0 0 0 0 1 0] [0 0 0 1 0 0 1 1] [1 0 1 1 0 0 0 0] [1 1 0 0 1 0 1 1] [1 0 1 0 1 0 1 0]]
2€Bb ; Convert from binary; [67 200 13 211 85]
B^ ; Reduce by XOR; 0
L, ; Define an unnamed lambda
; Example argument: [1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0]
bL ; Length; 40
d ; Duplicate; [40 40]
1_ ; Decrement; [40 39]
R ; Range; [40 [1 2 3 ... 37 38 39]]
þ% ; Filter false Mod; [1 2 4 5 8 10 20]
A$ ; Push the argument below; [[1 1 0 ... 0 1 0] [1 2 4 5 8 10 20]]
þg ; Filter false on g; [1 2 4 8]
Add++, 29 bytes
D,g,@@,T2€BbB^
L,bLd1_Rþ%A$þg
I'm surprised Add++ was this short. Takes input as a list of bits
Add++, 29 bytes
D,g,@@,T2€BbB^
L,bLd1_Rþ%A$þg
I'm surprised Add++ was this short. Takes input as a list of bits
How it works
D, ; Define a helper function
g, ; called g
@@, ; that takes 2 arguments e.g. [8 [1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0]]
T ; Split into chunks; [[1 1 0 0 0 0 1 0] [0 0 0 1 0 0 1 1] [1 0 1 1 0 0 0 0] [1 1 0 0 1 0 1 1] [1 0 1 0 1 0 1 0]]
2€Bb ; Convert from binary; [67 200 13 211 85]
B^ ; Reduce by XOR; 0
L, ; Define an unnamed lambda
; Example argument: [1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0]
bL ; Length; 40
d ; Duplicate; [40 40]
1_ ; Decrement; [40 39]
R ; Range; [40 [1 2 3 ... 37 38 39]]
þ% ; Filter false Mod; [1 2 4 5 8 10 20]
A$ ; Push the argument below; [[1 1 0 ... 0 1 0] [1 2 4 5 8 10 20]]
þg ; Filter false on g; [1 2 4 8]
Add++, 29 bytes
D,g,@@,T2€BbB^
L,bLd1_Rþ%A$þg
I'm surprised Add++ was this short. Takes input as a list of bits