Created
April 28, 2018 17:34
-
-
Save unixpickle/f73d193237f147bacab3a4cec6a3ddfc to your computer and use it in GitHub Desktop.
Scramble for locky puzzle
This file contains 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
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