about summary refs log tree commit diff
path: root/THT/B/QG-2016/trigrid.py
diff options
context:
space:
mode:
Diffstat (limited to 'THT/B/QG-2016/trigrid.py')
-rwxr-xr-xTHT/B/QG-2016/trigrid.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/THT/B/QG-2016/trigrid.py b/THT/B/QG-2016/trigrid.py
index ea33d07..0911ef9 100755
--- a/THT/B/QG-2016/trigrid.py
+++ b/THT/B/QG-2016/trigrid.py
@@ -1,10 +1,11 @@
 #!/usr/bin/env python3
 
-a = (4, 3, 5, 6, 111, 222, 3333, 4444, 55555, 666666, 7777777, 88888888,
-     999999999, 123456789123456789, 1000000000000000000)
+TESTS = (4, 3, 5, 6, 111, 222, 3333, 4444, 55555, 666666, 7777777, 88888888,
+         999999999, 123456789123456789, 1000000000000000000)
 
-t = lambda n: n * (n + 2) * (n * 2 + 1) // 8 % 2016
+# Fomular from http://mathworld.wolfram.com/TriangleTiling.html
+n = lambda a: a * (a + 2) * (a * 2 + 1) // 8 % 2016
 
 with open('TRIGRID.TXT', 'w') as f:
-    for i in a:
-        f.write("{}\n".format(t(i)))
+    for a in TESTS:
+        f.write("{}\n".format(n(a)))