Skip to content

Instantly share code, notes, and snippets.

@jacoby
Created April 18, 2019 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacoby/0649285fc9253810c9c7c62805b4e91e to your computer and use it in GitHub Desktop.
Save jacoby/0649285fc9253810c9c7c62805b4e91e to your computer and use it in GitHub Desktop.
fn main() {
let mut this_is_mutable_motherfucker: [i32; 9] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
for i in 3..12 {
if i == i {
this_is_mutable_motherfucker[0] = i;
for j in 3..12 {
if j == j && j != i {
this_is_mutable_motherfucker[1] = j;
for k in 3..12 {
if k == k && k != i && k != j {
this_is_mutable_motherfucker[2] = k;
for l in 3..12 {
if l == l && l != i && l != j && l != k {
this_is_mutable_motherfucker[3] = l;
for m in 3..12 {
if m == m && m != i && m != j && m != k && m != l {
this_is_mutable_motherfucker[4] = m;
for n in 3..12 {
if n == n
&& n != i
&& n != j
&& n != k
&& n != l
&& n != m
{
this_is_mutable_motherfucker[5] = n;
for o in 3..12 {
if o == o
&& o != i
&& o != j
&& o != k
&& o != l
&& o != m
&& o != n
{
this_is_mutable_motherfucker[6] = o;
for p in 3..12 {
if p == p
&& p != i
&& p != j
&& p != k
&& p != l
&& p != m
&& p != n
&& p != o
{
this_is_mutable_motherfucker
[7] = p;
for q in 3..12 {
if q == q
&& q != i
&& q != j
&& q != k
&& q != l
&& q != m
&& q != n
&& q != o
&& q != p
{
this_is_mutable_motherfucker[8] = q;
check(this_is_mutable_motherfucker);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
// I am so unsure about this.
// we can only have nine elements
// we cannot have duplicate variables
// that's most of the checking.
fn check(mf: [i32; 9]) {
let mut flag = 0;
// rows
if 21 != mf[0] + mf[1] + mf[2] {
flag = 1
}
if 21 != mf[3] + mf[4] + mf[5] {
flag = 1
}
if 21 != mf[6] + mf[7] + mf[8] {
flag = 1
}
// cols
if 21 != mf[0] + mf[3] + mf[6] {
flag = 1
}
if 21 != mf[1] + mf[4] + mf[7] {
flag = 1
}
if 21 != mf[2] + mf[5] + mf[8] {
flag = 1
}
// diag
if 21 != mf[0] + mf[4] + mf[8] {
flag = 1
}
if 21 != mf[2] + mf[4] + mf[6] {
flag = 1
}
if flag == 0 {
println!("{},{},{}", mf[0], mf[1], mf[2]);
println!("{},{},{}", mf[3], mf[4], mf[5]);
println!("{},{},{}", mf[6], mf[7], mf[8]);
println!("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment