Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/Population-count/AWK/population-count.awk
Normal file
36
Task/Population-count/AWK/population-count.awk
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# syntax: GAWK -f POPULATION_COUNT.AWK
|
||||
# converted from VBSCRIPT
|
||||
BEGIN {
|
||||
nmax = 30
|
||||
b = 3
|
||||
n = 0
|
||||
bb = 1
|
||||
for (i=1; i<=nmax; i++) {
|
||||
list = list pop_count(bb) " "
|
||||
bb *= b
|
||||
}
|
||||
printf("%s^n: %s\n",b,list)
|
||||
for (j=0; j<=1; j++) {
|
||||
c = (j == 0) ? "evil" : "odious"
|
||||
i = n = 0
|
||||
list = ""
|
||||
while (n < nmax) {
|
||||
if (pop_count(i) % 2 == j) {
|
||||
n++
|
||||
list = list i " "
|
||||
}
|
||||
i++
|
||||
}
|
||||
printf("%s: %s\n",c,list)
|
||||
}
|
||||
exit(0)
|
||||
}
|
||||
function pop_count(xx, xq,xr,y) {
|
||||
while (xx > 0) {
|
||||
xq = int(xx / 2)
|
||||
xr = xx - xq * 2
|
||||
if (xr == 1) { y++ }
|
||||
xx = xq
|
||||
}
|
||||
return(y)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue