ref: c99c21d80ff6c16f1a1fa8ecf80b0dfea0fc2907
parent: e7ee3a33e3826a55531e7a5f33472bf2d458f99b
author: sirjofri <[email protected]>
date: Sun Jan 21 10:17:45 EST 2024
corrects number calculation, better names for variables inside script
--- a/calc.awk
+++ b/calc.awk
@@ -2,31 +2,32 @@
# meant to be executed within acme with records that look like this:
-# 5 * 3
-# 2 * 1
+# 5 , 3
+# 2 , 1
-{
- num1 = $1
- num2 = $3
- fac = num1 * num2 * 0.1
+NF == 3 && $2 == "," {
+ score = $1
+ explvl = $3
+ fac = score * explvl
- sum += fac
- pure += num1
+ weightedsum += fac
+ puresum += score
- if (num2 > 5) {
- pexp += num1
- nexp++
+ if (explvl > 5) {
+ sumexperienced += score
+ numexperienced++
} else {
- pun += num1
- nun++
+ sumunexperienced += score
+ numunexperienced++
}
- count++
+ purecount++
+ weightedcount += explvl
printf "%s\n", $0
}
END {
- printf "%.2f / %d = %f (weighted)\n", sum, count, sum/count
- printf "%.2f / %d = %f\n", pure, count, pure/count
- printf "experienced: %d → %f\n", nexp, pexp/nexp
- printf "unexperienced: %d → %f\n", nun, pun/nun
+ printf "%.2f / %d = %f (weighted)\n", weightedsum, weightedcount, weightedsum/weightedcount
+ printf "%.2f / %d = %f\n", puresum, purecount, puresum/purecount
+ printf "experienced: %d → %f\n", numexperienced, sumexperienced/numexperienced
+ printf "unexperienced: %d → %f\n", numunexperienced, sumunexperienced/numunexperienced
}
--- a/numbers
+++ b/numbers
@@ -19,7 +19,7 @@
4 , 2
5 , 7
5 , 5
-38.60 / 17 = 2.270588 (weighted)
+386.00 / 87 = 4.436782 (weighted)
70.50 / 17 = 4.147059
experienced: 8 → 4.687500
unexperienced: 9 → 3.666667
@@ -43,7 +43,7 @@
5 , 2
5 , 7
5 , 5
-29.60 / 16 = 1.850000 (weighted)
+296.00 / 81 = 3.654321 (weighted)
59.50 / 16 = 3.718750
experienced: 7 → 3.928571
unexperienced: 9 → 3.555556
@@ -67,7 +67,7 @@
3 , 2
5 , 7
4 , 5
-37.75 / 16 = 2.359375 (weighted)
+377.50 / 81 = 4.660494 (weighted)
73.00 / 16 = 4.562500
experienced: 7 → 4.714286
unexperienced: 9 → 4.444444
@@ -91,7 +91,7 @@
2 , 2
3 , 7
4 , 5
-27.15 / 16 = 1.696875 (weighted)
+271.50 / 81 = 3.351852 (weighted)
53.00 / 16 = 3.312500
experienced: 7 → 3.285714
unexperienced: 9 → 3.333333
@@ -115,7 +115,7 @@
4 , 2
4 , 7
3 , 5
-22.85 / 16 = 1.428125 (weighted)
+228.50 / 81 = 2.820988 (weighted)
46.00 / 16 = 2.875000
experienced: 7 → 2.571429
unexperienced: 9 → 3.111111