Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import bitops
import strformat
var n = 1
write(stdout, "3^x :")
for i in 0..<30:
write(stdout, fmt"{popcount(n):2} ")
n *= 3
var od: array[30, int]
var ne, no = 0
n = 0
write(stdout, "\nevil :")
while ne + no < 60:
if (popcount(n) and 1) == 0:
if ne < 30:
write(stdout, fmt"{n:2} ")
inc ne
else:
if no < 30:
od[no] = n
inc no
inc n
write(stdout, "\nodious:")
for i in 0..<30:
write(stdout, fmt"{od[i]:2} ")
write(stdout, '\n')

View file

@ -0,0 +1,12 @@
import bitops, math, sequtils, strutils
const
N = 30
popcounts = toSeq(0..<N).mapIt(popcount(3^it))
mapping = toSeq(0..<(2 * N)).mapIt((it, it.popcount))
evil = mapping.filterIt((it[1] and 1) == 0).mapIt(it[0])
odious = mapping.filterIt((it[1] and 1) != 0).mapIt(it[0])
echo "3^n: ", popcounts.mapIt(($it).align(2)).join(" ")
echo "evil: ", evil.mapIt(($it).align(2)).join(" ")
echo "odious:", odious.mapIt(($it).align(2)).join(" ")