Code Monkey home page Code Monkey logo

rubik's Introduction

Rubik's cube

Travis

This program solves Rubik's cube 3x3.

Introduction

Rubik's cube will be read from file or keyboard, it's represented as plain text. The standard position for our Rubik's cube is: green side in front of you and white side up, we will need this to recognize movements.

Usage

Here <input_file> represents a Rubik's cube which we want to solve, <output_file> is the optional file to send the solution.

$ ./Rubik [option] [<input_file> [<output_file>]]

Demo Gurú

Option Description
-e explanation of valid <input_file> (same format for <output_file>)
-h print this help and exit
-i interactive mode of resolution, without extra arguments
-MX execute movement X in {U,u,D,d,L,l,R,r,F,f,B,b} to cube <input_file> (modified)
-m explain valid movements
-p print cube in human-readable format, need <input_file>
-r random Rubik's cube solution
-R generate a random Rubik's cube
-s show if a Rubik's cube is solved (y[es]/n[o]), need <input_file>

Colors

You can use three different options (simultaneously is possible, not recommended): W/w/1 for white O/o/2 for orange G/g/3 for green R/r/4 for red L/l/5 for blue Y/y/6 for yellow

The program will read 54 colors, one side each time. You will be able to change the colors if you made mistakes. The program represents Rubik's cube in two dimensions with green side in front of user (centered blue sticker represents blue side):

Colors

It would be represented in a file as

w w w w w w w w w
o o o o o o o o o
g g g g g g g g g
r r r r r r r r r
l l l l l l l l l
y y y y y y y y y

Other colors

If your rubik's cube has different patterns or colors, look at this:

-Example 1: If the center of the left side is red, in all stickers you should select orange.

-Example 2: If the center of the back side is black, in your black stickers you should select blue.

Movements

The Rubik's cube has 12 main movements and 6 double movements: F2, B2, R2, L2, U2, D2. "FBRLUD" movements in clockwise and "fbrlud" the opposite movement. As you can see here:

F(ront) B(ack) R(igth) L(eft) U(p) D(own)

Movements

Future work

Ordered by difficulty:

  • -t option to show tricks for pretty patterns

  • -l <input_file> option to show logic errors in a Rubik's cube (like invalid permutations that made the cube unresolvable) and how to solve it [self implemented]

  • Implement advanced methods as Fridrich in 3x3

  • Solve 4x4, 5x5, megamix, who knows...

For any doubt or suggestion you can contact me or create an issue respectively.

rubik's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.