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,62 @@
program populationCount(input, output, stdErr);
var
// general advice: iterator variables are _signed_
iterator: int64;
// the variable wed like to count the set bits in
number: qWord;
// how many evil numbers weve already found
evilCount: int64;
// odious numbers
odiousNumber: array[1..30] of qWord;
odiousIterator: int64;
begin
// population count for powers of three
for iterator := 0 to 29 do
begin
number := round(exp(ln(3) * iterator));
write(popCnt(number):3);
end;
writeLn();
// evil numbers
// (while preserving calculated odious numbers for next sub-task)
evilCount := 0;
odiousIterator := low(odiousNumber);
// for-loop: because we (pretend to) dont know,
// when and where weve found the first 30 numbers of each
for iterator := 0 to high(iterator) do
begin
// implicit typecast: popCnt only accepts _un_-signed integers
number := iterator;
if odd(popCnt(number)) then
begin
if odiousIterator <= high(odiousNumber) then
begin
odiousNumber[odiousIterator] := number;
inc(odiousIterator);
end;
end
else
begin
if evilCount < 30 then
begin
write(number:20);
inc(evilCount);
end;
end;
if evilCount + odiousIterator > 60 then
begin
break;
end;
end;
writeLn();
// odious numbers
for number in odiousNumber do
begin
write(number:20);
end;
writeLn();
end.