Created
March 7, 2024 21:28
-
-
Save dpiponi/0129faf8d34cb221e4328398743b7f53 to your computer and use it in GitHub Desktop.
solving that 2,3,7 puzzle efficiently
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Weird { | |
public: | |
float a0, a1, a2, a3, a4, a5, a6; | |
Weird(float b0, float b1, float b2, float b3, float b4, float b5, float b6) | |
: a0(b0), a1(b1), a2(b2), a3(b3), a4(b4), a5(b5), a6(b6) {} | |
Weird operator*(const Weird &other) const { | |
return Weird( | |
a0 * other.a0 + a6 * other.a1 + a5 * other.a2 + a4 * other.a3 + | |
a6 * other.a3 + a3 * other.a4 + a5 * other.a4 + a6 * other.a4 + | |
a2 * other.a5 + a4 * other.a5 + a5 * other.a5 + a6 * other.a5 + | |
a1 * other.a6 + a3 * other.a6 + a4 * other.a6 + a5 * other.a6 + | |
2 * a6 * other.a6, | |
a1 * other.a0 + a0 * other.a1 + a6 * other.a2 + a5 * other.a3 + | |
a4 * other.a4 + a6 * other.a4 + a3 * other.a5 + a5 * other.a5 + | |
a6 * other.a5 + a2 * other.a6 + a4 * other.a6 + a5 * other.a6 + | |
a6 * other.a6, | |
a2 * other.a0 + a1 * other.a1 + a0 * other.a2 + a6 * other.a3 + | |
a5 * other.a4 + a4 * other.a5 + a6 * other.a5 + a3 * other.a6 + | |
a5 * other.a6 + a6 * other.a6, | |
a3 * other.a0 + a2 * other.a1 + a1 * other.a2 + a0 * other.a3 + | |
a6 * other.a4 + a5 * other.a5 + a4 * other.a6 + a6 * other.a6, | |
a4 * other.a0 + a3 * other.a1 + a6 * other.a1 + a2 * other.a2 + | |
a5 * other.a2 + a1 * other.a3 + a4 * other.a3 + a6 * other.a3 + | |
a0 * other.a4 + a3 * other.a4 + a5 * other.a4 + a6 * other.a4 + | |
a2 * other.a5 + a4 * other.a5 + a5 * other.a5 + 2 * a6 * other.a5 + | |
a1 * other.a6 + a3 * other.a6 + a4 * other.a6 + 2 * a5 * other.a6 + | |
2 * a6 * other.a6, | |
a5 * other.a0 + a4 * other.a1 + a6 * other.a1 + a3 * other.a2 + | |
a5 * other.a2 + a6 * other.a2 + a2 * other.a3 + a4 * other.a3 + | |
a5 * other.a3 + a6 * other.a3 + a1 * other.a4 + a3 * other.a4 + | |
a4 * other.a4 + a5 * other.a4 + 2 * a6 * other.a4 + a0 * other.a5 + | |
a2 * other.a5 + a3 * other.a5 + a4 * other.a5 + 2 * a5 * other.a5 + | |
2 * a6 * other.a5 + a1 * other.a6 + a2 * other.a6 + a3 * other.a6 + | |
2 * a4 * other.a6 + 2 * a5 * other.a6 + 4 * a6 * other.a6, | |
a6 * other.a0 + a5 * other.a1 + a4 * other.a2 + a6 * other.a2 + | |
a3 * other.a3 + a5 * other.a3 + a6 * other.a3 + a2 * other.a4 + | |
a4 * other.a4 + a5 * other.a4 + a6 * other.a4 + a1 * other.a5 + | |
a3 * other.a5 + a4 * other.a5 + a5 * other.a5 + 2 * a6 * other.a5 + | |
a0 * other.a6 + a2 * other.a6 + a3 * other.a6 + a4 * other.a6 + | |
2 * a5 * other.a6 + 2 * a6 * other.a6); | |
} | |
}; | |
int main() { | |
Weird x(0, 1, 0, 0, 0, 0, 0); | |
Weird y = x; | |
for (int i = 0; i < 30; ++i) { | |
y = x * y; | |
std::cout << y.a0 << ' ' << y.a1 << ' ' << y.a2 << ' ' << y.a3 << ' ' | |
<< y.a4 << ' ' << y.a5 << ' ' << y.a6 << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment