summaryrefslogtreecommitdiff
path: root/src/ref.c
blob: 3589b13a94c1001d267be6875741cd2c31ea2372 (plain)
1
2
3
4
5
6
7
8
9
10
11
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;
}