shithub: rc

ref: 24deadf3d2ae91c3fe687dc6af9122aae6bd9563
dir: /bin/cex/

View raw version
#!/bin/awk -f
function q(){
	o = 1 + int(rand() * 10 % 4)
	a = 1 + int(rand() * (o==4 ? 1000 : 100))
	b = 1 + int(rand() * 100)
	r = o==1 ? a + b\
		: o==2 ? a - b\
		: o==3 ? a * b\
		: a / b	# equality works... sometimes? rounding errors?
	print a, op[o], b
}
BEGIN{
	op[1] = "+"
	op[2] = "-"
	op[3] = "*"
	op[4] = "/"
	srand()
	q()
}
{
	if($1 != r){
		print "NEIN NEIN NEIN!  " r
		system("theo")
	}
	q()
}