Bibi's DevLog ๐Ÿค“๐ŸŽ

[2021 ๋งˆ์Šคํ„ฐ์ฆˆ ์ฝ”์Šค ํ…Œ์ŠคํŠธ] 3๋‹จ๊ณ„ : ๋ฃจ๋น…์Šค ํ๋ธŒ ๊ตฌํ˜„ํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ–ฅ BE ๋ฐฑ์—”๋“œ/Java ์ž๋ฐ”

[2021 ๋งˆ์Šคํ„ฐ์ฆˆ ์ฝ”์Šค ํ…Œ์ŠคํŠธ] 3๋‹จ๊ณ„ : ๋ฃจ๋น…์Šค ํ๋ธŒ ๊ตฌํ˜„ํ•˜๊ธฐ

๋น„๋น„ bibi 2020. 12. 14. 17:36
2021 ์ฝ”๋“œ์Šค์ฟผ๋“œ ๋งˆ์Šคํ„ฐ์ฆˆ ์ฝ”์Šค ํ…Œ์ŠคํŠธ ๋ฌธ์ œ์™€ ์ €์˜ ํ’€์ด๋ฅผ ๊ณต์œ ํ•˜๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.

 

3๋‹จ๊ณ„: ๋ฃจ๋น…์Šค ํ๋ธŒ ๊ตฌํ˜„ํ•˜๊ธฐ

  • ์ฐธ๊ณ  ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๋ฃจ๋น…์Šค ํ๋ธŒ๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค.
  • ํ๋ธŒ๋Š” W, B, G, Y, O, R์˜ 6๊ฐ€์ง€ ์ƒ‰๊น”์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
  • ์ž…๋ ฅ: ๊ฐ ์กฐ์ž‘๋ฒ•์„ ํ•œ ์ค„๋กœ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
  • ์ถœ๋ ฅ: ํ๋ธŒ์˜ 6๋ฉด์„ ํŽผ์นœ ์ƒํƒœ๋กœ ์ถœ๋ ฅํ•œ๋‹ค.
  • Q๋ฅผ ์ž…๋ ฅ๋ฐ›์œผ๋ฉด ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•˜๊ณ , ์กฐ์ž‘ ๋ฐ›์€ ๋ช…๋ น์˜ ๊ฐฏ์ˆ˜๋ฅผ ์ถœ๋ ฅ์‹œํ‚จ๋‹ค.

ํ๋ธŒ์˜ ์ดˆ๊ธฐ ์ƒํƒœ

     	B B B
        B B B
      	B B B
        
W W W 	O O O 	G G G 	Y Y Y
W W W 	O O O 	G G G 	Y Y Y
W W W 	O O O 	G G G 	Y Y Y

      	R R R
      	R R R 
      	R R R

ํ”„๋กœ๊ทธ๋žจ ์˜ˆ์‹œ

(์ดˆ๊ธฐ ์ƒํƒœ ์ถœ๋ ฅ)

CUBE> FRR'U2R 

F
(ํ๋ธŒ์ƒํƒœ) 

R 
(ํ๋ธŒ์ƒํƒœ)

...

R
(ํ๋ธŒ์ƒํƒœ)

CUBE> Q 
๊ฒฝ๊ณผ์‹œ๊ฐ„: 00:31 //์ถ”๊ฐ€ ๊ตฌํ˜„ ํ•ญ๋ชฉ 
์กฐ์ž‘๊ฐฏ์ˆ˜: 6
์ด์šฉํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋šœ๋šœ๋šœ. 

์ถ”๊ฐ€ ๊ตฌํ˜„ ๊ธฐ๋Šฅ

  • ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ ์‹œ ๊ฒฝ๊ณผ ์‹œ๊ฐ„ ์ถœ๋ ฅ
  • ํ๋ธŒ์˜ ๋ฌด์ž‘์œ„ ์„ž๊ธฐ ๊ธฐ๋Šฅ
  • ๋ชจ๋“  ๋ฉด์„ ๋งž์ถ”๋ฉด ์ถ•ํ•˜ ๋ฉ”์‹œ์ง€์™€ ํ•จ๊ป˜ ํ”„๋กœ๊ทธ๋žจ์„ ์ž๋™ ์ข…๋ฃŒ

3๋‹จ๊ณ„ ์ฝ”๋”ฉ ์š”๊ตฌ์‚ฌํ•ญ

  • ๊ฐ€๋Šฅํ•œ ํ•œ ์ปค๋ฐ‹์„ ์ž์ฃผ ํ•˜๊ณ  ๊ตฌํ˜„์˜ ์˜๋ฏธ๊ฐ€ ๋ช…ํ™•ํ•˜๊ฒŒ ์ „๋‹ฌ๋˜๋„๋ก ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•  ๊ฒƒ
  • ํ•จ์ˆ˜๋‚˜ ๋ฉ”์†Œ๋“œ๋Š” ํ•œ ๋ฒˆ์— ํ•œ ๊ฐ€์ง€ ์ผ์„ ํ•˜๊ณ  ๊ฐ€๋Šฅํ•˜๋ฉด 20์ค„์ด ๋„˜์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.
  • ํ•จ์ˆ˜๋‚˜ ๋ฉ”์†Œ๋“œ์˜ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ๊ฐ€๋Šฅํ•˜๋ฉด ์ ๊ฒŒ(3๋‹จ๊ณ„๊นŒ์ง€๋งŒ) ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋…ธ๋ ฅํ•ด ๋ณธ๋‹ค.
function main() {
    for() {// ๋“ค์—ฌ์“ฐ๊ธฐ 1๋‹จ๊ณ„
        if() { // ๋“ค์—ฌ์“ฐ๊ธฐ 2๋‹จ๊ณ„
        	return; // ๋“ค์—ฌ์“ฐ๊ธฐ 3๋‹จ๊ณ„
        } 
    }
}

 

 


์†Œ์Šค์ฝ”๋“œ

์•„๋ž˜๋Š” ์ œ๊ฐ€ ์ œ์ถœํ•œ ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.

package Step3;

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
import java.util.Objects;

public class Step3 { // ๋ฃจ๋น…์Šค ํ๋ธŒ ๊ตฌํ˜„ํ•˜๊ธฐ
    Scanner sc = new Scanner(System.in);

    char[][] cubeUp = new char[3][3]; // ์œ—๋ฉด
    char[][] cubeLeft = new char[3][3]; // ์™ผ์ชฝ๋ฉด
    char[][] cubeFront = new char[3][3]; // ์•ž๋ฉด
    char[][] cubeRight = new char[3][3]; // ์˜ค๋ฅธ์ชฝ๋ฉด
    char[][] cubeBack = new char[3][3]; // ๋’ท๋ฉด
    char[][] cubeDown = new char[3][3]; // ์•„๋žซ๋ฉด
    int countNum = 0; // ์กฐ์ž‘ ํšŸ์ˆ˜
    long countTime = 0; // ๊ฒฝ๊ณผ์‹œ๊ฐ„

    public static void main(String[] args) {
        Step3 step3 = new Step3();
        System.out.println("๐Ÿ— ๋ฃจ๋น…์Šค ํ๋ธŒ๋ฅผ ํ’€์–ด ๋ณด์„ธ์š”!");
        step3.initCube();
        step3.scramble(); // ์ฒ˜์Œ๋ถ€ํ„ฐ ์„ž์–ด์„œ ๋ณด์—ฌ์ฃผ๊ธฐ
        step3.ready();
    }

    public void initCube() {
        for (int i = 0; i < 3; i++) {
            cubeUp[i] = new char[]{'W', 'W', 'W'}; // ์œ—๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : White
            cubeLeft[i] = new char[]{'O', 'O', 'O'}; // ์™ผ์ชฝ๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : Orange
            cubeFront[i] = new char[]{'G', 'G', 'G'}; // ์•ž๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : Green
            cubeRight[i] = new char[]{'R', 'R', 'R'}; // ์˜ค๋ฅธ์ชฝ๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : Red
            cubeBack[i] = new char[]{'B', 'B', 'B'}; // ๋’ท๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : Blue
            cubeDown[i] = new char[]{'Y', 'Y', 'Y'}; // ์•„๋žซ๋ฉด ๊ธฐ๋ณธ ์ƒ‰ : Yellow
        }
        printCube();
    }

    public void scramble() { // ์„ž๊ธฐ ๋ฉ”์„œ๋“œ
        char[][] tempUp = new char[3][3];
        char[][] tempLeft = new char[3][3];
        char[][] tempFront = new char[3][3];
        char[][] tempRight = new char[3][3];
        char[][] tempBack = new char[3][3];
        char[][] tempDown = new char[3][3];
        Random random = new Random();
        int randomNum1 = random.nextInt(4); // 0~3๊นŒ์ง€ ๋žœ๋คํ•˜๊ฒŒ ํ˜ธ์ถœ. bound5์ด์ƒ์ด ๋˜๋ฉด 360๋„๋ฅผ ๋Œ์•„์„œ ์•ˆ ์„ž์ผ๋–„๊ฐ€ ๋งŽ์•„ ์กฐ์ •ํ•จ.
        int randomNum2 = random.nextInt(4);
        int randomNum3 = random.nextInt(4);
        for (int i = 0; i < randomNum1; i++) {
            whenU(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
            whenDDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
        }
        for (int i = 0; i < randomNum2; i++) {
            whenF(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
            whenB(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
        }
        for (int i = 0; i < randomNum3; i++) {
            whenL(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
            whenD(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
        }
        for (int i = 0; i < randomNum1; i++) {
            whenR(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
            whenFDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
        }
        System.out.println("\n\n ๐Ÿ”€ ๐Ÿ”€ ํ๋ธŒ๋ฅผ ๋ฌด์ž‘์œ„๋กœ ์„ž์—ˆ์Šต๋‹ˆ๋‹ค.");
        printCube();
        countTime = System.currentTimeMillis();
    }

    public void ready() {
        String input = start();
        ArrayList<String> inputList = trimInput(input);
        checkInput(inputList);
    }

    public void printCube() {
        for (int i = 0; i < 3; i++) {
            System.out.printf("%n %6c %1c %1c %1c %6c", ' ', cubeUp[i][0], cubeUp[i][1], cubeUp[i][2], ' ');
        }
        for (int i = 0; i < 3; i++) {
            System.out.printf("%n %1c %1c %1c  %1c %1c %1c  %1c %1c %1c  %1c %1c %1c",
                    cubeLeft[i][0], cubeLeft[i][1], cubeLeft[i][2],
                    cubeFront[i][0], cubeFront[i][1], cubeFront[i][2],
                    cubeRight[i][0], cubeRight[i][1], cubeRight[i][2],
                    cubeBack[i][0], cubeBack[i][1], cubeBack[i][2]);
        }
        System.out.printf("%n %6c %1c %1c %1c %15c %1c%1c", ' ', cubeDown[0][0], cubeDown[0][1], cubeDown[0][2], ' ', ' ', 'U');
        System.out.printf("%n %6c %1c %1c %1c %15c %1c%1c%1c%1c", ' ', cubeDown[1][0], cubeDown[1][1], cubeDown[1][2], ' ', 'L', 'F', 'R', 'B');
        System.out.printf("%n %6c %1c %1c %1c %15c %1c%1c", ' ', cubeDown[2][0], cubeDown[2][1], cubeDown[2][2], ' ', ' ', 'D');
    }

    public String start() {
        System.out.println("\nโ“ ------------------------- โ†— ใ€Œ์ „๊ฐœ๋„ ๋„์›€๋งใ€ ------------------------------");
        System.out.println(">>   U = Up = ์œ—๋ฉด,  L = Left = ์™ผ์ชฝ ๋ฉด,  F = Front = ์•ž๋ฉด, ");
        System.out.println(">>   R = Right = ์˜ค๋ฅธ์ชฝ ๋ฉด,  B = Back = ๋’ท๋ฉด,  D = Down = ์•„๋žซ๋ฉด์„ ๋œปํ•ฉ๋‹ˆ๋‹ค.");
        System.out.println("--------------------------------------------------------------------------");
        System.out.println("โคต ์•„๋ž˜ ๋ช…๋ น์–ด์— ๋”ฐ๋ผ '์‹œ๊ณ„๋ฐฉํ–ฅ'์œผ๋กœ '1/4๋ฐ”ํ€ด' ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        System.out.println(" U : ์œ—๋ฉด,  L : ์™ผ์ชฝ ๋ฉด,  F : ์•ž๋ฉด,  R : ์˜ค๋ฅธ์ชฝ ๋ฉด,  B : ๋’ท๋ฉด,  D : ์•„๋žซ๋ฉด");
        System.out.println("โคด ์•„๋ž˜ ๋ช…๋ น์–ด์— ๋”ฐ๋ผ '๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ'์œผ๋กœ '1/4๋ฐ”ํ€ด' ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        System.out.println(" U' : ์œ—๋ฉด,  L' : ์™ผ์ชฝ ๋ฉด,  F' : ์•ž๋ฉด,  R' : ์˜ค๋ฅธ์ชฝ ๋ฉด,  B' : ๋’ท๋ฉด,  D' : ์•„๋žซ๋ฉด");
        System.out.println("๐Ÿ”ƒ ์•„๋ž˜ ๋ช…๋ น์–ด์— ๋”ฐ๋ผ '์‹œ๊ณ„๋ฐฉํ–ฅ'์œผ๋กœ '1/2๋ฐ”ํ€ด' ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        System.out.println(" U2 : ์œ—๋ฉด,  L2 : ์™ผ์ชฝ ๋ฉด,  F2 : ์•ž๋ฉด,  R2 : ์˜ค๋ฅธ์ชฝ ๋ฉด,  B2 : ๋’ท๋ฉด,  D2 : ์•„๋žซ๋ฉด");
        System.out.println("โ›” Q ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.");
        System.out.print("CUBE > ");
        String input = sc.nextLine();
        System.out.println(); // ๊ฐœํ–‰
        return input;
    }

    public ArrayList<String> trimInput(String input) { // ์ž…๋ ฅ๊ฐ’ ๋‹ค๋“ฌ๊ธฐ
        String[] inputArr = input.split("");
        int inputArrLength = inputArr.length;
        ArrayList<String> inputList = new ArrayList<>();
        for (int i = 0; i < inputArrLength; i++) { // ์š”์†Œ๊ฐ€ '๋‚˜ 2์ด๋ฉด ์ง์ „ ์š”์†Œ์— '๋‚˜ 2๋ฅผ ๋ถ™์ด๊ธฐ
            String inputElement = inputArr[i];
            if (inputElement.equals("'")) {
                inputArr[i - 1] = inputArr[i - 1] + "'";
            }
            if (inputElement.equals("2")) {
                inputArr[i - 1] = inputArr[i - 1] + "2";
            }
        }
        for (int i = 0; i < inputArrLength; i++) { // ์š”์†Œ๊ฐ€ '์ด ์•„๋‹ˆ๊ณ  2๊ฐ€ ์•„๋‹ ๋•Œ inputList์— ์ถ”๊ฐ€
            String inputElement = inputArr[i];
            if (!inputElement.equals("'") && !inputElement.equals("2")) {
                inputList.add(inputElement);
            }
        }
        return inputList;
    }

    public void checkInput(ArrayList<String> inputList) {
        int inputListSize = inputList.size();
        for (int i = 0; i < inputListSize; i++) {
            String anInput = inputList.get(i);
            if (anInput.equals("U'") || anInput.equals("U") || anInput.equals("F'") || anInput.equals("F")
                    || anInput.equals("L'") || anInput.equals("L") || anInput.equals("R'") || anInput.equals("R")
                    || anInput.equals("B'") || anInput.equals("B") || anInput.equals("D'") || anInput.equals("D")
                    || anInput.equals("U2") || anInput.equals("L2") || anInput.equals("F2") || anInput.equals("R2")
                    || anInput.equals("B2") || anInput.equals("D2") || anInput.equals("Q")) {
                guideInput(anInput);
            } else {
                System.out.println("โ— ์ง€์ •๋˜์ง€ ์•Š์€ ๋ช…๋ น์–ด๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.");
                String reInput = start();
                ArrayList<String> reInputList = trimInput(reInput);
                checkInput(reInputList);
            }
        }
        isComplete();
        ready();
    }

    public void isComplete() {
        char[][] completeUp = new char[3][3];
        char[][] completeLeft = new char[3][3];
        char[][] completeFront = new char[3][3];
        char[][] completeRight = new char[3][3];
        char[][] completeBack = new char[3][3];
        char[][] completeDown = new char[3][3];
        for (int i = 0; i < 3; i++) {
            completeUp[i] = new char[]{'W', 'W', 'W'}; // completeUp : White
            completeLeft[i] = new char[]{'O', 'O', 'O'}; // completeLeft : Orange
            completeFront[i] = new char[]{'G', 'G', 'G'}; // completeFront : Green
            completeRight[i] = new char[]{'R', 'R', 'R'}; // completeRight : Red
            completeBack[i] = new char[]{'B', 'B', 'B'}; // completeBack : Blue
            completeDown[i] = new char[]{'Y', 'Y', 'Y'}; // completeDown : Yellow
        }
        if (Objects.deepEquals(cubeUp, completeUp) && Objects.deepEquals(cubeLeft, completeLeft)
                && Objects.deepEquals(cubeFront, completeFront) && Objects.deepEquals(cubeRight, completeRight)
                && Objects.deepEquals(cubeBack, completeBack) && Objects.deepEquals(cubeDown, completeDown)) {
            System.out.println("๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ ์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค! ํ๋ธŒ๋ฅผ ์™„์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰");
            terminate();
        }
    }

    public void terminate() { // ์ข…๋ฃŒ ๋ฉ”์„œ๋“œ
        sc.close();
        long timeGap = calTime();
        long timeGapMinute = (timeGap) / (1000 * 60); // ๋ฐ€๋ฆฌ์ดˆ๋ฅผ ๋ถ„ ๋‹จ์œ„๋กœ ๋‚˜๋ˆ„๊ธฐ
        long timeGapSecond = (timeGap - (timeGapMinute * 1000 * 60)) / 1000; // ๋ถ„์„ ๋‹ค์‹œ ๋ฐ€๋ฆฌ์ดˆ๋‹จ์œ„๋กœ ๋ฐ”๊ฟ”์„œ ๋ฐ€๋ฆฌ์ดˆ-๋ถ„์„ ์ดˆ ๋‹จ์œ„๋กœ ๋‚˜๋ˆ„๊ธฐ
        System.out.println("\n๐Ÿ• ๊ฒฝ๊ณผ์‹œ๊ฐ„ : " + timeGapMinute + "๋ถ„ " + timeGapSecond + "์ดˆ");
        System.out.println("๐Ÿ”„ ์กฐ์ž‘ ํšŸ์ˆ˜ : " + countNum + "ํšŒ");
        System.out.println("\n๐Ÿ˜Š ์ด์šฉํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.");
        System.exit(0);
    }

    public long calTime() {
        long startTime = countTime;
        long endTime = System.currentTimeMillis();
        long timeGap = endTime - startTime;
        return timeGap;
    }

    public void guideInput(String anInput) {
        char[][] tempUp = new char[3][3];
        char[][] tempLeft = new char[3][3];
        char[][] tempFront = new char[3][3];
        char[][] tempRight = new char[3][3];
        char[][] tempBack = new char[3][3];
        char[][] tempDown = new char[3][3];
        switch (anInput) {
            case "U":
                System.out.println("\nU : ์œ—๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenU(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "U2":
                System.out.println("\nU2 : ์œ—๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenU(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenU(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "U'":
                System.out.println("\nU' : ์œ—์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenUDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "F":
                System.out.println("\nF : ์•ž๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenF(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "F2":
                System.out.println("\nF2 : ์•ž๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenF(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenF(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "F'":
                System.out.println("\nF' : ์•ž์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenFDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "L":
                System.out.println("\nL : ์™ผ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenL(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "L2":
                System.out.println("\nL2 : ์™ผ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenL(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenL(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "L'":
                System.out.println("\nL' : ์™ผ์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenLDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "R":
                System.out.println("\nR : ์˜ค๋ฅธ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenR(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "R2":
                System.out.println("\nR2 : ์˜ค๋ฅธ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenR(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenR(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "R'":
                System.out.println("\nR' : ์˜ค๋ฅธ์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenRDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "B":
                System.out.println("\nB : ๋’ท๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenB(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "B2":
                System.out.println("\nB2 : ๋’ท๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenB(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenB(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "B'":
                System.out.println("\nB' : ๋’ท๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenBDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "D":
                System.out.println("\nD : ์•„๋žซ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenD(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "D2":
                System.out.println("\nD2 : ์•„๋žซ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/2 ํšŒ์ „");
                whenD(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                whenD(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "D'":
                System.out.println("\nD' : ์•„๋žซ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „");
                whenDDot(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);
                break;
            case "Q":
                System.out.println("โ›” ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ");
                terminate();
                break;
        }
        countNum++;
        printCube();
        System.out.println(); // ์ค„๋ฐ”๊ฟˆ
    }

    public void copyToTemp(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        for (int i = 0; i < 3; i++) { // ์ž„์‹œ๋ณ€์ˆ˜์— cube๋‚ด์šฉ ๋ณต์‚ฌ
            for (int j = 0; j < 3; j++) {
                tempUp[i][j] = cubeUp[i][j];
                tempLeft[i][j] = cubeLeft[i][j];
                tempFront[i][j] = cubeFront[i][j];
                tempRight[i][j] = cubeRight[i][j];
                tempBack[i][j] = cubeBack[i][j];
                tempDown[i][j] = cubeDown[i][j];
            }
        }
    }

    public void copyToCube(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) { //ํŒŒ๋ผ๋ฏธํ„ฐ5๊ฐœ
        for (int i = 0; i < 3; i++) { // cube์— ์ž„์‹œ๋ณ€์ˆ˜ ๋‚ด์šฉ ๋ณต์‚ฌ
            for (int j = 0; j < 3; j++) {
                cubeUp[i][j] = tempUp[i][j];
                cubeLeft[i][j] = tempLeft[i][j];
                cubeFront[i][j] = tempFront[i][j];
                cubeRight[i][j] = tempRight[i][j];
                cubeBack[i][j] = tempBack[i][j];
                cubeDown[i][j] = tempDown[i][j];
            }
        }
    }

    public void clockWise(char[][] temp, char[][] cube) { // ํ•ด๋‹น ๋ฉด cube๋ฅผ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „ํ•ด temp์— ๋Œ€์ž….
        temp[0][0] = cube[2][0];
        temp[0][1] = cube[1][0];
        temp[0][2] = cube[0][0];
        temp[1][0] = cube[2][1];
        temp[1][2] = cube[0][1];
        temp[2][0] = cube[2][2];
        temp[2][1] = cube[1][2];
        temp[2][2] = cube[0][2];
    }

    public void counterClockWise(char[][] temp, char[][] cube) { // ํ•ด๋‹น ๋ฉด cube๋ฅผ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „ํ•ด temp์— ๋Œ€์ž….
        temp[0][0] = cube[0][2];
        temp[0][1] = cube[1][2];
        temp[0][2] = cube[2][2];
        temp[1][0] = cube[0][1];
        temp[1][2] = cube[2][1];
        temp[2][0] = cube[0][0];
        temp[2][1] = cube[1][0];
        temp[2][2] = cube[2][0];
    }

    public void whenU(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // U : ์œ—์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempUp, cubeUp);// U๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempLeft[0][0] = cubeFront[0][0]; // U๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[0][1] = cubeFront[0][1];
        tempLeft[0][2] = cubeFront[0][2];
        tempBack[0][0] = cubeLeft[0][0];// U๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[0][1] = cubeLeft[0][1];
        tempBack[0][2] = cubeLeft[0][2];
        tempFront[0][0] = cubeRight[0][0];// U๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[0][1] = cubeRight[0][1];
        tempFront[0][2] = cubeRight[0][2];
        tempRight[0][0] = cubeBack[0][0];// U๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[0][1] = cubeBack[0][1];
        tempRight[0][2] = cubeBack[0][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);//๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenUDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // U' : ์œ—์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempUp, cubeUp);// U๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempLeft[0][0] = cubeBack[0][0]; // U๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[0][1] = cubeBack[0][1];
        tempLeft[0][2] = cubeBack[0][2];
        tempFront[0][0] = cubeLeft[0][0];// U๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[0][1] = cubeLeft[0][1];
        tempFront[0][2] = cubeLeft[0][2];
        tempRight[0][0] = cubeFront[0][0];// U๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[0][1] = cubeFront[0][1];
        tempRight[0][2] = cubeFront[0][2];
        tempBack[0][0] = cubeRight[0][0];// U๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[0][1] = cubeRight[0][1];
        tempBack[0][2] = cubeRight[0][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown); //๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenL(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // L : ์™ผ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempLeft, cubeLeft);// L๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][0] = cubeBack[2][2];// L๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[1][0] = cubeBack[1][2];
        tempUp[2][0] = cubeBack[0][2];
        tempFront[0][0] = cubeUp[0][0];// L๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[1][0] = cubeUp[1][0];
        tempFront[2][0] = cubeUp[2][0];
        tempDown[0][0] = cubeFront[0][0];// L๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[1][0] = cubeFront[1][0];
        tempDown[2][0] = cubeFront[2][0];
        tempBack[0][2] = cubeDown[2][0]; // L๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[1][2] = cubeDown[1][0];
        tempBack[2][2] = cubeDown[0][0];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenLDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // L' : ์™ผ์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempLeft, cubeLeft);// L๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][0] = cubeFront[0][0];// L๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[1][0] = cubeFront[1][0];
        tempUp[2][0] = cubeFront[2][0];
        tempFront[0][0] = cubeDown[0][0]; // L๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[1][0] = cubeDown[1][0];
        tempFront[2][0] = cubeDown[2][0];
        tempDown[0][0] = cubeBack[2][2];// L๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[1][0] = cubeBack[1][2];
        tempDown[2][0] = cubeBack[0][2];
        tempBack[0][2] = cubeUp[2][0];// L๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[1][2] = cubeUp[1][0];
        tempBack[2][2] = cubeUp[0][0];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenF(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // F : ์•ž์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempFront, cubeFront);// F๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[2][0] = cubeLeft[2][2];// F๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[2][1] = cubeLeft[1][2];
        tempUp[2][2] = cubeLeft[0][2];
        tempLeft[0][2] = cubeDown[0][0]; // F๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[1][2] = cubeDown[0][1];
        tempLeft[2][2] = cubeDown[0][2];
        tempRight[0][0] = cubeUp[2][0];// F๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[1][0] = cubeUp[2][1];
        tempRight[2][0] = cubeUp[2][2];
        tempDown[0][0] = cubeRight[2][0];// F๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[0][1] = cubeRight[1][0];
        tempDown[0][2] = cubeRight[0][0];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown); // ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenFDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // F' : ์•ž์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown); // ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempFront, cubeFront);// F๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[2][0] = cubeRight[0][0];// F๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[2][1] = cubeRight[1][0];
        tempUp[2][2] = cubeRight[2][0];
        tempLeft[0][2] = cubeUp[2][2]; // F๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[1][2] = cubeUp[2][1];
        tempLeft[2][2] = cubeUp[2][0];
        tempRight[0][0] = cubeDown[0][2];// F๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[1][0] = cubeDown[0][1];
        tempRight[2][0] = cubeDown[0][0];
        tempDown[0][0] = cubeLeft[0][2];// F๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[0][1] = cubeLeft[1][2];
        tempDown[0][2] = cubeLeft[2][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenR(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // R : ์˜ค๋ฅธ์ชฝ ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempRight, cubeRight);// R๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][2] = cubeFront[0][2];// R๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[1][2] = cubeFront[1][2];
        tempUp[2][2] = cubeFront[2][2];
        tempFront[0][2] = cubeDown[0][2];// R๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[1][2] = cubeDown[1][2];
        tempFront[2][2] = cubeDown[2][2];
        tempDown[0][2] = cubeBack[2][0];// R๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[1][2] = cubeBack[1][0];
        tempDown[2][2] = cubeBack[0][0];
        tempBack[0][0] = cubeUp[2][2]; // R๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[1][0] = cubeUp[1][2];
        tempBack[2][0] = cubeUp[0][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenRDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // R' : ์˜ค๋ฅธ์ชฝ ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempRight, cubeRight);// R๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][2] = cubeBack[2][0];// R๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[1][2] = cubeBack[1][0];
        tempUp[2][2] = cubeBack[0][0];
        tempFront[0][2] = cubeUp[0][2]; // R๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[1][2] = cubeUp[1][2];
        tempFront[2][2] = cubeUp[2][2];
        tempDown[0][2] = cubeFront[0][2];// R๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[1][2] = cubeFront[1][2];
        tempDown[2][2] = cubeFront[2][2];
        tempBack[0][0] = cubeDown[2][2];// R๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[1][0] = cubeDown[1][2];
        tempBack[2][0] = cubeDown[0][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenB(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // B : ๋’ท๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempBack, cubeBack);// B๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][0] = cubeRight[0][2];// B๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[0][1] = cubeRight[1][2];
        tempUp[0][2] = cubeRight[2][2];
        tempLeft[0][0] = cubeUp[0][2];// B๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[1][0] = cubeUp[0][1];
        tempLeft[2][0] = cubeUp[0][0];
        tempRight[0][2] = cubeDown[2][2]; // B๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[1][2] = cubeDown[2][1];
        tempRight[2][2] = cubeDown[2][0];
        tempDown[2][0] = cubeLeft[0][0];// B๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[2][1] = cubeLeft[1][0];
        tempDown[2][2] = cubeLeft[2][0];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenBDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // B' : ๋’ท๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempBack, cubeBack);// B๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempUp[0][0] = cubeLeft[2][0];// B๋ฉด์˜ ์˜†๋ฉด - U๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempUp[0][1] = cubeLeft[1][0];
        tempUp[0][2] = cubeLeft[0][0];
        tempLeft[0][0] = cubeDown[2][0]; // B๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[1][0] = cubeDown[2][1];
        tempLeft[2][0] = cubeDown[2][2];
        tempRight[0][2] = cubeUp[0][0];// B๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[1][2] = cubeUp[0][1];
        tempRight[2][2] = cubeUp[0][2];
        tempDown[2][0] = cubeRight[2][2];// B๋ฉด์˜ ์˜†๋ฉด - D๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempDown[2][1] = cubeRight[1][2];
        tempDown[2][2] = cubeRight[0][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenD(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // D : ์•„๋žซ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        clockWise(tempDown, cubeDown);// D๋ฉด ์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempLeft[2][0] = cubeBack[2][0];// D๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[2][1] = cubeBack[2][1];
        tempLeft[2][2] = cubeBack[2][2];
        tempFront[2][0] = cubeLeft[2][0];// D๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[2][1] = cubeLeft[2][1];
        tempFront[2][2] = cubeLeft[2][2];
        tempRight[2][0] = cubeFront[2][0]; // D๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[2][1] = cubeFront[2][1];
        tempRight[2][2] = cubeFront[2][2];
        tempBack[2][0] = cubeRight[2][0];// D๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[2][1] = cubeRight[2][1];
        tempBack[2][2] = cubeRight[2][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }

    public void whenDDot(char[][] tempUp, char[][] tempLeft, char[][] tempFront, char[][] tempRight, char[][] tempBack, char[][] tempDown) {
        // D' : ์•„๋žซ๋ฉด์„ ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „
        copyToTemp(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ์ž„์‹œ๋ณ€์ˆ˜์— cube ๋‚ด์šฉ ๋ณต์‚ฌ
        counterClockWise(tempDown, cubeDown);// D๋ฉด ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ 1/4 ํšŒ์ „
        tempLeft[2][0] = cubeFront[2][0]; // D๋ฉด์˜ ์˜†๋ฉด - L๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempLeft[2][1] = cubeFront[2][1];
        tempLeft[2][2] = cubeFront[2][2];
        tempFront[2][0] = cubeRight[2][0];// D๋ฉด์˜ ์˜†๋ฉด - F๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempFront[2][1] = cubeRight[2][1];
        tempFront[2][2] = cubeRight[2][2];
        tempRight[2][0] = cubeBack[2][0];// D๋ฉด์˜ ์˜†๋ฉด - R๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempRight[2][1] = cubeBack[2][1];
        tempRight[2][2] = cubeBack[2][2];
        tempBack[2][0] = cubeLeft[2][0];// D๋ฉด์˜ ์˜†๋ฉด - B๋ฉด ๋ณ€๊ฒฝ์‚ฌํ•ญ
        tempBack[2][1] = cubeLeft[2][1];
        tempBack[2][2] = cubeLeft[2][2];
        copyToCube(tempUp, tempLeft, tempFront, tempRight, tempBack, tempDown);// ๋ฐ”๋€ ์ž„์‹œ๋ณ€์ˆ˜๋ฅผ cube์— ๋ณต์‚ฌ
    }
} // class

 

์ถœ๋ ฅํ˜•ํƒœ 

 

 


์„ค๋ช…

Step3.java ์ฝ”๋“œ ์„ค๋ช…

  • ์ „์—ญ๋ณ€์ˆ˜

    • sc : Scanner
    • cubeUp, cubeLeft, cubeFront, cubeRight, cubeBack, cubeDown
      • ํ๋ธŒ์˜ 6๋ฉด(์œ—์ชฝ, ์™ผ์ชฝ, ์•ž์ชฝ, ์˜ค๋ฅธ์ชฝ, ๋’ท์ชฝ, ์•„๋žซ์ชฝ)์„ ๋‹ด๋‹นํ•˜๋Š” 3*3 ์ด์ฐจ์›๋ฐฐ์—ด
    • countNum : ์กฐ์ž‘ ํšŸ์ˆ˜๋ฅผ ์นด์šดํŒ…ํ•˜๋Š” ๋ณ€์ˆ˜
    • countTime : ๊ฒฝ๊ณผ์‹œ๊ฐ„์„ ์ธก์ •ํ•˜๋Š” ๋ณ€์ˆ˜
  • initCube() : ํ๋ธŒ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • ํ๋ธŒ์˜ 6๋ฉด์„ ๊ธฐ๋ณธ ์ƒ‰์œผ๋กœ ์„ค์ •
    • ์œ—๋ฉด = White, ์™ผ์ชฝ๋ฉด = Orange, ์•ž๋ฉด = Green
    • ์˜ค๋ฅธ์ชฝ๋ฉด = Red, ๋’ท๋ฉด = Blue, ์•„๋žซ๋ฉด = Yellow
  • scramble() : ํ๋ธŒ๋ฅผ ๋ฌด์ž‘์œ„๋กœ ์„ž๋Š” ๋ฉ”์„œ๋“œ.

    • ๋ฃจ๋น…์Šค ํ๋ธŒ๋ฅผ ํ‘ธ๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๊ธฐ ๋–„๋ฌธ์— ์ฒซ ํ™”๋ฉด์„ ์ œ์‹œํ•œ ๋’ค ์ž๋™์œผ๋กœ ์„ž์–ด์ค€๋‹ค.
    • random.nextInt(4)๋ฅผ ํ†ตํ•ด 0~3๊นŒ์ง€์˜ ๋ฌด์ž‘์œ„ ์ˆซ์ž๋ฅผ 3๊ฐœ ํ˜ธ์ถœ
    • ์ผ๋ถ€ ํ๋ธŒํšŒ์ „ ๋ฉ”์„œ๋“œ๋“ค์„ ํ†ตํ•ด ๋ฌด์ž‘์œ„ ์ˆซ์ž๋งŒํผ ํ๋ธŒ๋ฅผ ์„ž์€ ๋’ค ๊ทธ ๋ชจ์Šต์„ ์ถœ๋ ฅํ•œ๋‹ค.
    • ์„ž์ธ ํ๋ธŒ๊ฐ€ ์ถœ๋ ฅ๋œ ์‹œ์ ๋ถ€ํ„ฐ ์‹œ๊ฐ„์ด ๊ณ„์‚ฐ๋œ๋‹ค(countTime).
  • ready() : start()-trimInput()-checkInput()์„ ์ฐจ๋ก€๋กœ ํ˜ธ์ถœํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • ๊ฐ๊ฐ ์•ž ํ•จ์ˆ˜์˜ ๋ฆฌํ„ด๊ฐ’์„ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ฐ›๋Š”๋‹ค.
  • printCube() : ํ˜„์žฌ ํ๋ธŒ 6๋ฉด์˜ ์ƒํƒœ๋ฅผ ์ „๊ฐœ๋„ ๋ชจ์–‘์œผ๋กœ ์ถœ๋ ฅํ•˜๊ณ , ์ „๊ฐœ๋„ ๋„์›€๋ง์„ ์ œ๊ณตํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • printf()๋ฅผ ํ™œ์šฉํ•ด ํ๋ธŒ์˜ 6๋ฉด์„ ์ „๊ฐœ๋„ ๋ชจ์–‘์œผ๋กœ ์ถœ๋ ฅ
    • ํ˜„์žฌ ํ๋ธŒ์˜ ๋ชจ์–‘ ์˜ค๋ฅธ์ชฝ์—, ์ „๊ฐœ๋„์˜ ๊ฐ ๋ฉด์— ๋Œ€ํ•œ ๋ช…๋ น์–ด ๊ธฐํ˜ธ๋ฅผ ์ œ๊ณต
      • ์‹ค์ œ๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ๊ฐ ๋ฉด์— ๋Œ€ํ•œ ์„ค๋ช…์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์•„ ์ถ”๊ฐ€ํ•จ.
  • start() : ๋„์›€๋ง ๋ฐ ๋ช…๋ น์–ด ์„ค๋ช…์„ ์ œ๊ณตํ•˜๊ณ , ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฉ”์„œ๋“œ.

    • return : input (์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ž…๋ ฅ๋ฐ›์€ ๋ช…๋ น์–ด)
  • trimInput(input) : ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ž…๋ ฅ๋ฐ›์€ ๋ช…๋ น์–ด๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์ข‹์€ ํ˜•ํƒœ๋กœ ๋‹ค๋“ฌ๋Š” ๋ฉ”์„œ๋“œ.

    • ์‚ฌ์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์„ split("")๋กœ ํ•œ ๋ฌธ์ž์”ฉ ์ชผ๊ฐœ์–ด ๋ฐฐ์—ด๋กœ ๋งŒ๋“ฆ
    • ๊ฒฐ๊ณผ๊ฐ’์„ ๋‹ด์„ ArrayList์ธ inputList๋ฅผ ์„ ์–ธ.
    • ๊ฐ ์š”์†Œ๊ฐ€ ' ๋˜๋Š” 2์™€ ์ผ์น˜ํ•˜๋ฉด, ๊ทธ ์š”์†Œ์˜ ์ง์ „ ์š”์†Œ์— ' ๋˜๋Š” 2๋ฅผ ๋ถ™์ž„.
    • ๊ฐ ์š”์†Œ๊ฐ€ '๋„ ์•„๋‹ˆ๊ณ  2๋„ ์•„๋‹ ๋•Œ๋งŒ inputList์— ์ถ”๊ฐ€.
    • return : inputList
  • checkInput(inputList) : ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ž…๋ ฅ๋ฐ›์€ ๋ช…๋ น์–ด๋ฅผ ๊ฒ€์‚ฌํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • inputList์˜ ๊ฐ ์š”์†Œ(anInput)๋ฅผ ํ•˜๋‚˜์”ฉ ํ™•์ธ.
    • anInput์ด U U' L L' F F' R R' B B' D D' U2 L2 F2 R2 B2 D2 ์ค‘ ํ•˜๋‚˜์ผ ๋•Œ๋งŒ guideInput(anInput) ํ˜ธ์ถœ.
    • ๊ทธ๋ ‡์ง€ ์•Š์„ ๋•Œ๋Š” ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  start()-trimInput()-checkInput()์„ ๋‹ค์‹œ ์‹คํ–‰.
    • inputList์˜ ๋ชจ๋“  ๋ช…๋ น์–ด ์ฒ˜๋ฆฌ๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด isComplete()๋กœ ํ๋ธŒ๊ฐ€ ์™„์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ready()ํ˜ธ์ถœ.
  • isComplete() : ํ๋ธŒ๊ฐ€ ์™„์„ฑ๋˜์—ˆ๋Š”์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • (์ด ํ”„๋กœ๊ทธ๋žจ์—์„œ๋Š”) ํ๋ธŒ์˜ 6๋ฉด์˜ ๊ฐ€์šด๋ฐ ์š”์†Œ(์ด์ฐจ์›๋ฐฐ์—ด๋กœ๋Š” [1][1])๋Š” ๋ฐ˜๋“œ์‹œ ์ดˆ๊ธฐ๊ฐ’๊ณผ ๊ฐ™๋‹ค.
    • ์ฆ‰ ์œ—๋ฉด์€ ๋ชจ๋‘ W, ์™ผ์ชฝ ๋ฉด์€ ๋ชจ๋‘ L, ์•ž์ชฝ ๋ฉด์€ ๋ชจ๋‘ G, ์˜ค๋ฅธ์ชฝ ๋ฉด์€ ๋ชจ๋‘ R, ๋’ท๋ฉด์€ ๋ชจ๋‘ B, ์•„๋žซ๋ฉด์€ ๋ชจ๋‘ Y์—ฌ์•ผ ํ•œ๋‹ค.
    • ๊ฒ€์‚ฌ ๋ฐฉ๋ฒ• : ์ดˆ๊ธฐ ํ๋ธŒ์™€ ๋˜‘๊ฐ™์€ ์ž„์‹œํ๋ธŒ๋ฅผ ๋งŒ๋“ค๊ณ , ํ˜„์žฌ ํ๋ธŒ์˜ 6๋ฉด์ด ์ž„์‹œํ๋ธŒ์˜ 6๋ฉด๊ณผ ๊ฐ™์€์ง€ ๋น„๊ตํ•œ๋‹ค.
      • ๋งŒ์•ฝ ์™„์„ฑ๋˜์—ˆ๋‹ค๋ฉด ์ถ•ํ•˜ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ ๋’ค terminate()๋ฅผ ํ˜ธ์ถœ.
  • terminate() : ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ ๋ฉ”์„œ๋“œ

    • Scanner๋ฅผ ๋‹ซ๊ณ  calTime()์„ ํ˜ธ์ถœํ•ด ๊ฒฝ๊ณผ์‹œ๊ฐ„(๋ฐ€๋ฆฌ์ดˆ ๋‹จ์œ„)์„ ๋ฐ›๋Š”๋‹ค.
    • ๋ฐ›์€ ๊ฒฝ๊ณผ์‹œ๊ฐ„์„ ๋ถ„, ์ดˆ ๋‹จ์œ„๋กœ ๊ณ„์‚ฐํ•ด ์ถœ๋ ฅํ•œ๋‹ค.
    • countNum์— ์ €์žฅ๋œ ์กฐ์ž‘ํšŸ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
    • ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•œ๋‹ค.
  • calTime() : ๊ฒฝ๊ณผ์‹œ๊ฐ„์„ ๊ณ„์‚ฐํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • countTime์— ์ €์žฅ๋œ ์‹œ์ž‘์‹œ๊ฐ„์„ ๋ฐ›์•„์˜จ๋‹ค. (์‹œ์ž‘์‹œ๊ฐ„์€ scramble()์—์„œ ์ €์žฅ๋จ)
    • calTime()์ด ํ˜ธ์ถœ๋œ ์‹œ๊ฐ„์„ ์ข…๋ฃŒ์‹œ๊ฐ„์œผ๋กœ ํ•œ๋‹ค.
    • timeGap : ์ข…๋ฃŒ์‹œ๊ฐ„ - ์‹œ์ž‘์‹œ๊ฐ„ (๋ฐ€๋ฆฌ์ดˆ ๋‹จ์œ„)์„ ๊ณ„์‚ฐํ•œ ๊ฒฐ๊ณผ๊ฐ’
    • return : timeGap
  • guideInput(anInput) : ์‚ฌ์šฉ์ž์˜ ๋ช…๋ น์–ด ํ•˜๋‚˜์— ๋Œ€ํ•œ ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • ๊ฐ ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ๋“ค์— ๋„˜๊ธธ ํŒŒ๋ผ๋ฏธํ„ฐ์ธ temp์ž„์‹œํ๋ธŒ(์œ—๋ฉด,์™ผ์ชฝ๋ฉด,์•ž๋ฉด,์˜ค๋ฅธ์ชฝ๋ฉด,๋’ท๋ฉด,์•„๋žซ๋ฉด)๋ฅผ ์„ ์–ธ
    • switch-case๋ฌธ์„ ํ†ตํ•ด anInput๊ณผ ์ผ์น˜ํ•˜๋Š” ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ๋กœ ์—ฐ๊ฒฐํ•˜๊ณ , ์ž…๋ ฅ๊ฐ’์— ๋Œ€ํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅ
    • U2์ฒ˜๋Ÿผ 1/2๋ฐ”ํ€ด ํšŒ์ „ํ•˜๋Š” ๋ช…๋ น์–ด๋Š” whenU()๋ฅผ ๋‘ ๋ฒˆ ํ˜ธ์ถœ.
    • ๊ฐ ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ ์ฒ˜๋ฆฌ๊ฐ€ ๋๋‚˜๋ฉด countNum(์กฐ์ž‘ํšŸ์ˆ˜) ์— 1์„ ๋”ํ•˜๊ณ , ํ˜„์žฌ ํ๋ธŒ๋ฅผ ์ถœ๋ ฅ
  • copyToTemp(temp) / copyToCube(temp) : ์ž„์‹œํ๋ธŒ์— ํ˜„์žฌ ํ๋ธŒ๋ฅผ ๋ณต์‚ฌํ•˜๋Š” ๋ฉ”์„œ๋“œ.

    • 6๋ฉด์˜ ์ž„์‹œํ๋ธŒ ๊ฐ’์„ ๋ฐ›์•„ ํ˜„์žฌ ํ๋ธŒ์— ๋ณต์‚ฌํ•˜๊ฑฐ๋‚˜ / ํ˜„์žฌ ํ๋ธŒ 6๋ฉด์˜ ๊ฐ’์„ ์ž„์‹œํ๋ธŒ์— ๋ณต์‚ฌํ•˜๋Š” ๋ฉ”์„œ๋“œ
    • ๋ชจ๋“  ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ์— ํ•„์š”ํ•œ ๋ฉ”์„œ๋“œ
  • clockWise(temp, cube) / counterClockWise(temp, cube) :

    • ์–ด๋–ค ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ / ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „ํ•˜๋Š” ๋ฉ”์„œ๋“œ.
    • ์–ด๋–ค ๋ฉด์˜ ํ˜„์žฌ ํ๋ธŒ๋ฅผ ์‹œ๊ณ„๋ฐฉํ–ฅ / ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 1/4 ํšŒ์ „ํ•ด ์ž„์‹œํ๋ธŒ์— ๋Œ€์ž…ํ•จ.
    • ๋ชจ๋“  ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ์— ํ•„์š”ํ•œ ๋ฉ”์„œ๋“œ
  • [ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ]

    • whenU(temp), whenUDot(temp),whenL(temp), whenLDot(temp),whenF(temp), whenFDot(temp),
    • whenR(temp), whenRDot(temp),whenB(temp), whenBDot(temp),whenD(temp), whenDDot(temp),
    • ๋ช…๋ น์–ด์— ๋”ฐ๋ผ ํ๋ธŒ๋ฅผ ํšŒ์ „์‹œํ‚ค๋Š” ๋ฉ”์„œ๋“œ๋“ค.
    • ๋ชจ๋“  ๋ณ€๊ฒฝ์‚ฌํ•ญ์€ ์ž„์‹œํ๋ธŒ์— ๋จผ์ € ์ ์šฉ๋˜๊ณ , ๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ์ด ํ˜„์žฌ ํ๋ธŒ์— ๋ณต์‚ฌ๋œ๋‹ค.
    • (1) ์ž„์‹œํ๋ธŒ์— ํ˜„์žฌ ํ๋ธŒ ๋‚ด์šฉ์„ ๋ณต์‚ฌํ•ด ๋„ฃ๋Š”๋‹ค
      • why? ํ๋ธŒํšŒ์ „๋ฉ”์„œ๋“œ์—์„œ ์กฐ์ž‘๋˜๋Š” ์š”์†Œ๋ฅผ ์ œ์™ธํ•œ ์š”์†Œ๋“ค์€ ๊ทธ๋Œ€๋กœ์—ฌ์•ผ ํ•˜๊ธฐ ๋–„๋ฌธ
    • (2) ๊ฐ ํšŒ์ „๋ฉ”์„œ๋“œ์˜ ํšŒ์ „ํ•˜๋Š” ๋ฉด์„ ์‹œ๊ณ„๋ฐฉํ–ฅ/๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ ํšŒ์ „์‹œํ‚จ ๊ฒฐ๊ณผ๋ฅผ ์ž„์‹œํ๋ธŒ์— ์ €์žฅํ•œ๋‹ค.
      • ์‹œ๊ณ„๋ฐฉํ–ฅ์ด๋ฉด clockWise(temp, cube), ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ์ด๋ฉด counterClockWise(temp, cube)
    • (3) ํšŒ์ „ํ•˜๋Š” ๋ฉด์— ์ธ์ ‘ํ•œ 4๋ฉด์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์กฐ์ž‘ํ•˜์—ฌ ์ž„์‹œํ๋ธŒ์— ์ €์žฅํ•œ๋‹ค. = (4) ์ž„์‹œํ๋ธŒ์— ์ €์žฅ๋œ ๋‚ด์šฉ์ด ํ˜„์žฌ ํ๋ธŒ ์ƒํƒœ๊ฐ€ ๋˜๋„๋ก ๋ณต์‚ฌํ•ด ๋„ฃ๋Š”๋‹ค.