basic 3x3 scrambler
Dec 29, 2019 at 6:50pm UTC
So i want to make an app that gives me a scramble for a 3x3 rubiks cube. The thing is i cant have it show me the same or similar moves one after the other(such as ...U U'...).
any ideas? here is what i have made
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int x;
int y;// equal to x
int main(){
srand(time(0));
for (int i = 0; i < 19;i++){
x = rand()%19;
switch (x){
case 1:
cout << "R" ;
break ;
case 2:
cout << "R'" ;
break ;
case 3:
cout << "R2" ;
break ;
case 4:
cout << "U" ;
break ;
case 5:
cout << "U'" ;
break ;
case 6:
cout << "U2" ;
break ;
case 7:
cout << "F" ;
break ;
case 8:
cout << "F'" ;
break ;
case 9:
cout << "F2" ;
break ;
case 10:
cout << "D" ;
break ;
case 11:
cout << "D'" ;
break ;
case 12:
cout << "D2" ;
break ;
case 13:
cout << "B" ;
break ;
case 14:
cout << "B'" ;
break ;
case 15:
cout << "B2" ;
break ;
case 16:
cout << "L" ;
break ;
case 17:
cout << "L'" ;
break ;
case 18:
cout << "L2" ;
break ;
}
cout << " " ;
y=x;
}
}
Dec 29, 2019 at 7:23pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
srand(time(0));
for (int i = 0, prev = 99; i < 10; ) {
int r = rand() % 18;
int side = r / 3;
int amount = r % 3 + 1;
if (prev / 3 != side) {
cout << "RUFDBL" [side] << amount << ' ' ;
++i;
prev = r;
}
}
cout << '\n' ;
}
Dec 30, 2019 at 7:31am UTC
Or for lol's :)
cout << side["RUFDBL" ] << amount << ' ' ;
Jan 1, 2020 at 1:59pm UTC
thanks ill try it
Topic archived. No new replies allowed.