summaryrefslogtreecommitdiff
path: root/src/ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ref.c')
-rw-r--r--src/ref.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ref.c b/src/ref.c
new file mode 100644
index 0000000..3589b13
--- /dev/null
+++ b/src/ref.c
@@ -0,0 +1,12 @@
+// This is the original code posted on IOTA's Discord.
+int ref1(int i, int x, int y)
+{
+ return i % y + ((((i / y) + x) % 3) + (i / (y * 3)) * 3) * y;
+}
+
+// A simplified version posted by someone on IOTA's Discord (not exactly sure
+// who posted it first).
+int ref2(int i, int x, int y)
+{
+ return i + (((i / y) + x) % 3 - ((i / y) % 3)) * y;
+} \ No newline at end of file