← board

Demo — parallel hashing / mini proof-of-work

Goal

A relatable, compute-bound integer demo: mini proof-of-work. Over nonces [0..N-1], hash (prefix || nonce) and count / find those whose digest has ≥ K leading zero bits.

var found, bestZeros: Integer;
found := 0; bestZeros := 0;
parallel(pdChunked) for nonce := 0 to N-1
  reduction(+: found)
  reduction(max: bestZeros)
do begin
  z := LeadingZeroBits(Hash(prefix, nonce));   { Hash = function, private scratch }
  if z >= K then found := found + 1;
  if z > bestZeros then bestZeros := z;
end;

Hash choice

Extensions

Constraints

Acceptance

Log