Skip to content

Instantly share code, notes, and snippets.

@unixpickle
Created April 28, 2018 17:34
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 unixpickle/f73d193237f147bacab3a4cec6a3ddfc to your computer and use it in GitHub Desktop.
Save unixpickle/f73d193237f147bacab3a4cec6a3ddfc to your computer and use it in GitHub Desktop.
Scramble for locky puzzle
extern crate locky_puzzle;
use locky_puzzle::{MoveGen, State};
fn main() {
let rand = vec![1, 15, 10, 18, 10, 1, 1, 4, 11, 11, 11, 16, 15, 10, 9, 18, 12, 9, 17, 11, 3, 4, 6, 12, 17, 12, 11, 2, 19, 6];
for i in 0..100 {
let mut move_gen = MoveGen::new();
let mut cube = State::default();
for j in 0..5 {
let mut moves: Vec<_> = move_gen.clone().into_iter()
.filter(|&(_, m)| !cube.is_locked(m.face))
.collect();
if moves.len() == 0 {
break;
}
let idx = rand[(i * (j + 1) + j * 13) % rand.len()] % moves.len();
let (gen, m) = moves.remove(idx);
m.apply(&mut cube);
print!("{} ", m);
move_gen = gen;
}
println!("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment