fork(1) download
  1. @moves = qw(R U R' U' R' F R2 U' R' U' R U R' F');
  2. $state = "UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR";
  3.  
  4. sub move {
  5. my ($pos) = @_;
  6. eval "\$pos =~ y/$from/$to/";
  7. $pos;
  8. }
  9.  
  10. print "Moves: @moves\nStart: $state\n";
  11. for $move (@moves) {
  12. $move =~ s/'/3/;
  13. ($side, $angle) = split //, $move . 1;
  14. $from = $to = '';
  15. for (split ' ', $state) {
  16. if (/.../ && /$side/) {
  17. ($t, $f) = split '', "$'$`";
  18. $from .= $f;
  19. $to .= $t;
  20. }
  21. }
  22. $state =~ s/\w*$side\w*/move($&)/ge while $angle--;
  23. }
  24. print "End: $state\n";
Success #stdin #stdout 0s 3564KB
stdin
Standard input is empty
stdout
Moves: R U R' U' R' F R2 U' R' U' R U R' F'
Start: UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
End:   UF UL UB UR DF DR DB DL FR FL BR BL URB UFR UBL ULF DRF DFL DLB DBR