shithub: rc

Download patch

ref: 41f6839ba51cf7122044b5dd0519394317f5ab52
parent: 2219d783ad6e3f670fe8c0f06d9abed4676d9597
author: qwx <qwx@sciops.net>
date: Thu Jan 9 10:29:42 EST 2020

add drills: various silly unfinished drill programs

diff: cannot open b/drills//null: file does not exist: 'b/drills//null'
--- /dev/null
+++ b/drills/cex
@@ -1,0 +1,26 @@
+#!/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()
+}
--- /dev/null
+++ b/drills/frequenzbohrer
@@ -1,0 +1,86 @@
+#!/bin/awk -f
+# ; mkdir $home/mid
+# ; for(i in $notestringsbelow) echo 2 0^$i | mst | games/midi -c > $home/mid/^$i^.pcm
+
+function extant(v, a){
+	for(e in a)
+		if(a[e] == v)
+			return 1
+	return 0
+}
+
+function addrange(n){
+	i = length(roster) + 1
+	for(o in range){
+		m = n + range[o]
+		if(m > 0 && m <= length(note) && !extant(m, roster))
+			roster[i++] = m
+	}
+}
+
+function new(){
+	print "Find die noten, allied schweinhund!"
+	for(i in qs){
+		do
+			n = int(rand() * 10000000 % length(roster) + 1)
+		while(extant(roster[n], qs))
+		qs[i] = roster[n]
+	}
+	for(i in keys)
+		qs[int(rand() * 10000000 % length(qs) + 1)] = keys[i]
+	cmd = "cat $home/mid/^("
+	for(i=1; i<=length(qs); i++)
+		cmd = cmd note[qs[i]] ".pcm "
+	cmd = cmd ") >/dev/audio"
+	system(cmd)
+}
+
+BEGIN{
+	split("\
+c0 c♯0 d0 d♯0 e0 f0 f♯0 g0 g♯0 a0 a♯0 b0 \
+c1 c♯1 d1 d♯1 e1 f1 f♯1 g1 g♯1 a1 a♯1 b1 \
+c2 c♯2 d2 d♯2 e2 f2 f♯2 g2 g♯2 a2 a♯2 b2 \
+c3 c♯3 d3 d♯3 e3 f3 f♯3 g3 g♯3 a3 a♯3 b3 \
+c4 c♯4 d4 d♯4 e4 f4 f♯4 g4 g♯4 a4 a♯4 b4 \
+c5 c♯5 d5 d♯5 e5 f5 f♯5 g5 g♯5 a5 a♯5 b5 \
+c6 c♯6 d6 d♯6 e6 f6 f♯6 g6 g♯6 a6 a♯6 b6 \
+c7 c♯7 d7 d♯7 e7 f7 f♯7 g7 g♯7 a7 a♯7 b7 \
+c8 c♯8 d8 d♯8 e8 f8 f♯8 g8 g♯8 a8 a♯8 b8 \
+c9 c♯9 d9 d♯9 e9 f9 f♯9 g9 g♯9 a9 a♯9 b9 \
+c10 c♯10 d10 d♯10 e10 f10 f♯10 g10", note)
+	# FIXME: just have all notes from octaves -1,0,+1
+	split("-12 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 12 1 2 3 4 5 6 7 8 9 10 11", range)
+	srand()
+	print "Vich noten shall wir testen diese day, bastard?"
+}
+NR == 1{
+	n = split($0, keys)
+	if(n < 1)
+		exit("no notes to hand")
+	for(k in keys){
+		m = 0
+		for(n in note){
+			if(keys[k] == note[n]){
+				m = n
+				break
+			}
+		}
+		if(m == 0){
+			print "unknown note " keys[k]
+			exit("unknown note " keys[k])
+		}
+		keys[k] = m
+		addrange(m)
+	}
+	for(i=1; i<=6*length(keys); i++)
+		qs[i] = 0
+	new()
+}
+NR > 1{
+	# FIXME: just choose one of the notes at random; only test one note;
+	# say which one it's testing
+	for(i=1; i<=NF; i++)
+		if(!($i in qs) || !extant(qs[$i], keys))
+			print "NEIN!  Es ist " note[qs[$i]] "!"
+	new()
+}
--- /dev/null
+++ b/drills/übung
@@ -1,0 +1,53 @@
+#!/bin/rc
+
+# FIXME: alternatives/synonyms: don't fail because of those
+# FIXME: examples, phrases
+# FIXME: verb conjugation
+# FIXME: meaning alternatives
+# FIXME: noun genders, plural, derivatives/compounds
+# FIXME: shuffle list every time it's parsed completely
+# FIXME: randomly ask english or german
+
+en=0
+files=$home/p/not/ger/^(adj adv cnj exp itj nou prn prp vrb)
+score=0
+total=0
+
+fn sigint{
+	echo; echo deine Endsumme: $score/$total Punkte, pfff.
+	e
+	exit ''
+}
+
+fn chk{
+	a=$2
+	b=$1
+	if(~ $en 1){
+		a=$1
+		b=$2
+	}
+	echo -n was ist $a?'		'
+	if(! ~ `{read -n 1} $b)
+		echo NEIN! es ist $b!
+	if not
+		score=`{echo $score | awk '{print $1+1}'}
+	total=`{echo $total | awk '{print $1+1}'}
+}
+
+while(~ $1 -*){
+	switch($1){
+	case -e
+		en=1
+	}
+	shift
+}
+
+ifs='
+' l=(`{cat $files \
+	| sed '/^	/d;/^$/d;s/		*/	/g' \
+	| awk -F '	' 'BEGIN{srand()}{printf "%06d  %s\n", rand()*1000000, $0;}' \
+	| sort -n \
+	| sed 's/^[0-9]*  //'})
+while()
+	for(i in $l)
+		chk `{echo $i | awk -F '	' '{printf "%s\n%s", $1, $2}'}