Skip to content

Instantly share code, notes, and snippets.

@tomaes

tomaes/hz.pas

Created May 4, 2020
Embed
What would you like to do?
Audio micro game. Make it through 12 rounds of approximate frequency estimation.
program Hz; {sound micro game; 2020-5-4}
uses crt;
var f,q,p,r: integer; s: string;
begin
clrscr;
writeln('Guess My Frequency (20-2000Hz)');
randomize;
r := 0; s := '';
repeat
f := random(1980)+20;
sound(f); delay(200); nosound;
write('Hz? ');
readln(q);
inc(r);
inc(p,200);
dec(p,abs(q-f));
if (q-f > 0) then s := '+' else s := '';
writeln('/\/:',f,' a-b:', s, q-f, ' $:', p);
until (r = 12) or (p < 0);
writeln(r, ' round[s]');
if (p > 400) then writeln('Well done!');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.