commit c9ee6e9
Emilia Smólska
·
2026-11-05 19:13:24 +0000 UTC
parent c9ee6e9
import
1 files changed,
+57,
-0
A
aq.c
A
aq.c
+57,
-0
1@@ -0,0 +1,57 @@
2+/*
3+ * a utility for playing with alphanumeric qabbala (larp larp larp sahur)
4+ * public domain
5+ */
6+
7+#include <stdio.h>
8+#include <stdlib.h>
9+#include <unistd.h>
10+
11+/* octal because i can */
12+static const char _aq_table[128] = {
13+ 000, 000, 000, 000, 000, 000, 000, 000,
14+ 000, 000, 000, 000, 000, 000, 000, 000,
15+ 000, 000, 000, 000, 000, 000, 000, 000,
16+ 000, 000, 000, 000, 000, 000, 000, 000,
17+ 000, 000, 000, 000, 000, 000, 000, 000,
18+ 000, 000, 000, 000, 000, 000, 000, 000,
19+ 001, 002, 003, 004, 005, 006, 007, 010,
20+ 010, 011, 000, 000, 000, 000, 000, 000,
21+ 000, 012, 013, 014, 015, 016, 017, 020,
22+ 021, 022, 023, 024, 025, 026, 027, 030,
23+ 031, 032, 033, 034, 035, 036, 037, 040,
24+ 041, 042, 043, 000, 000, 000, 000, 000,
25+ 000, 012, 013, 014, 015, 016, 017, 020,
26+ 021, 022, 023, 024, 025, 026, 027, 030,
27+ 031, 032, 033, 034, 035, 036, 037, 040,
28+ 041, 042, 043, 000, 000, 000, 000, 000,
29+};
30+
31+/* clangoy cries about char subscripts */
32+#define aq_value(x) (_aq_table[(int)(x)])
33+
34+static int
35+aq_sum(const char *s)
36+{
37+ int r = 0;
38+
39+ while (*s != '\0') {
40+ r += aq_value(*s++);
41+ }
42+
43+ return r;
44+}
45+
46+int
47+main(int argc, char **argv)
48+{
49+ if (argv[1] == NULL) {
50+ *argv-- = "bunnies rabbits";
51+ }
52+
53+ for (argv++; *argv != NULL; argv++) {
54+ printf("%s\t%d\n", *argv, aq_sum(*argv));
55+ }
56+
57+ return EXIT_SUCCESS;
58+}