5 kyu

Rubik's Cube Simulator

46 of 47sgerodes
Description
Loading description...
Puzzles
Algorithms
Geometry
Simulation
  • Please sign in or sign up to leave a comment.
  • Twilight_Sun Avatar

    in JS random tests output looks like

    Sequence is 'Y d2 M Y' f b' U f2': expected 'ggbggbgbbowywwywroroorooywywyrwyyroyw…' to equal 'gggggbgbbowywwywroroorooywywyrwyyroyw…'
    

    I suppose seeing all 54 letters would be helpful for debugging

  • dfhwze Avatar

    I suggest to rename this kata, as this one does not want us to solve a cube, but to simulate a list of moves on solved cube instead.

  • goldenratio161 Avatar

    hi, may i know how to delete some of my solutions?

    As pochmann said, "I keep finding improvements, so currently I'm polluting the solution space with obsolete suboptimal solutions just because I can't remove them"

  • goldenratio161 Avatar

    this should be 4kyu

  • hobovsky Avatar

    This kata got unpublished as a duplicate: https://www.codewars.com/kata/576a616359b1163437001c3b/ but maybe its JS translation could be salvaged as a translation of this kata?

  • Voile Avatar

    For X, Y and Z it's unspecified which direction they're pointing to. There are multiple conventions for this (Y can point at U, D, F or even B), so it needs to be explicitly specified.

    (I believe the standard is X -> R, Y -> U, Z -> F)

    (Also, yes, it can be deciphered from single_rotations, but it shouldn't be mandatory)

  • sgerodes Avatar

    Added a Rubiks solving Kata You are welcome.;) https://www.codewars.com/kata/5e01fbe21f177f000f4995d7

  • lechevalier Avatar

    I already saw the very same kata on codingame.com nearly a year ago. Did you copy it from there?

  • user6793616 Avatar

    I made reference to this kata in my own Rubik kata "Solve Rubik's Cube by repetition". You may want to have a look at it?

  • user6793616 Avatar

    Small detail: I would have used lowercase notation for X, Y and Z -- like listed in Wikipedia, ruwix.com, solvethecube.com, ... Lowercase is commonly used for manipulations that rotate more than 1 layer (3 in this case).

  • Blind4Basics Avatar

    Btw, seeing the name of your kata... Are you planning on doing more about rubik's cubes?

  • Blind4Basics Avatar

    Still some informations that are lacking in the description. Use that instead:

    Basic rotations

    Every face can rotate.

    • The direction of a rotation is always defined on your "axis of sight" when your looking at a face of the cube.
    • A rotation of a face is written with an uppercase letter: F, B, ...
    • Clockwise and counterclockwise rotations are distinguished by an apostroph, added to the letter for the counterclockwise rotations.

      Examples:

      • F rotates the front face clockwise.
      • F' rotates the front face conterclockwise.

        You can rotate a face twice with a 2 after the letter. E.g. F2 rotates the front face clockwise twice.

        Slice rotations

        There is a possibility to rotate only a middle layer of the cube.

    Other than that, it seems ok to me.

  • Blind4Basics Avatar

    all good now, about the implementation!

    About the description, I'm not sure you should give the preloaded dictionnary, though. Didn't read it again yet.

  • Blind4Basics Avatar

    ok, so, here we are:

    • description needs to be corrected about M (again, your implementation is correct about it, only the representation in the description is wrong)
    • description needs to be more precise about the operations: for instance, you never say what is the axis used to perform/look at the rotation you do. That's why it's hard to follow, for now.
    • you should add some basic tests about ulfrbd
    • there is a small trouble in your use of Test.describe and Test.it: you forgot or put one print("<COMPLETEIN::>") at a wrong place (you should use the new test framework, it's far easier to obtain the correct brakedown of the test suite). For now, "Single turns" hold the complete test suite.

    And now, the parts that are wrong:

    Currently, I pass all the tests until I reach scramble, where I only fail on u S.

    your implementation of `S` is correct, but the test with `u S` is expecting 
    a wrong result (up to you to see if that's u or the combination of opeartions
    that is wrong):
    
    Mine 'u'
          +-----+
          |y y y|
          |y y y|
          |y y y|
    +-----+-----+-----+-----+
    |r r r|g g g|o o o|b b b|
    |r r r|g g g|o o o|b b b|
    |b b b|r r r|g g g|o o o|
    +-----+-----+-----+-----+
          |w w w|
          |w w w|
          |w w w|
          +-----+
    
    Mine 'u S'
          +-----+
          |y y y|
          |b r r|
          |y y y|
    +-----+-----+-----+-----+
    |r w r|g g g|o y o|b b b|
    |r w r|g g g|o y o|b b b|
    |b w b|r r r|g y g|o o o|
    +-----+-----+-----+-----+
          |w w w|
          |g o o|
          |w w w|
          +-----+
    
    expected: you're rotating front instead
          +-----+
          |y y y|
          |b r r|
          |y y y|
    +-----+-----+-----+-----+
    |r w r|g g r|o y o|b b b|
    |r w r|g g r|o y o|b b b|
    |b w b|g g r|g y g|o o o|
    +-----+-----+-----+-----+
          |w w w|
          |g o o|
          |w w w|
          +-----+
    

    Other example, on the sequence U R b B.

    Mines:

    U
          +-----+
          |y y y|
          |y y y|
          |y y y|
    +-----+-----+-----+-----+
    |r r r|g g g|o o o|b b b|
    |b b b|r r r|g g g|o o o|
    |b b b|r r r|g g g|o o o|
    +-----+-----+-----+-----+
          |w w w|
          |w w w|
          |w w w|
          +-----+
    
    U R
          +-----+
          |y y g|
          |y y r|
          |y y r|
    +-----+-----+-----+-----+
    |r r r|g g w|g g o|y b b|
    |b b b|r r w|g g o|y o o|
    |b b b|r r w|g g o|y o o|
    +-----+-----+-----+-----+
          |w w o|
          |w w o|
          |w w b|
          +-----+
    
    U R b
          +-----+
          |o o o|
          |g g g|
          |y y r|
    +-----+-----+-----+-----+
    |g r r|g g w|g o b|y y y|
    |y y b|r r w|g w w|o o b|
    |y y b|r r w|g w w|o o y|
    +-----+-----+-----+-----+
          |w w o|
          |r b b|
          |r b b|
          +-----+
    
    U R b B
          +-----+
          |b w w|
          |g g g|
          |y y r|
    +-----+-----+-----+-----+
    |o r r|g g w|g o b|o o y|
    |o y b|r r w|g w b|o o y|
    |o y b|r r w|g w r|y b o|
    +-----+-----+-----+-----+
          |w w o|
          |r b b|
          |g y y|
          +-----+
    

    Yours at the end: front and back are wrong.

          +-----+
          |b w w|
          |g g g|
          |y y r|
    +-----+-----+-----+-----+
    |o r r|r r g|g o b|o o y|
    |o y b|r r g|g w b|o o y|
    |o y b|w w w|g w r|b b y|
    +-----+-----+-----+-----+
          |w w o|
          |r b b|
          |g y y|
          +-----+
    

    If you wanna know easily what operations are wrong, jus implement all the simple tests that are missing, this way it will be easier to compare.


    Cheers,

    B4B

  • Blind4Basics Avatar
    • see my last message below about the random tests
    • your description is really FAR from enough. I managed to interpret some of the undescribed operations, but when it became too much fuzzy, I went to the link you provided. And then... I realized your description isn't even consistent with what's there.

    According to that link, the transformation for M should be:

          +-----+
          |y o y|
          |y o y|
          |y o y|
    +-----+-----+-----+-----+
    |b b b|r y r|g g g|o w o|
    |b b b|r y r|g g g|o w o|
    |b b b|r y r|g g g|o w o|
    +-----+-----+-----+-----+
          |w r w|
          |w r w|
          |w r w|
          +-----+
    

    and not:

          +-----+
          |y r y|
          |y r y|
          |y r y|
    +-----+-----+-----+-----+
    |b b b|r w r|g g g|o y o|
    |b b b|r w r|g g g|o y o|
    |b b b|r w r|g g g|o y o|
    +-----+-----+-----+-----+
          |w o w|
          |w o w|
          |w o w|
          +-----+
    

    Seeing that, I'd bet on other problems of the same kind, which means your kata will be almost undebuggable/undoable. Please check your transformations, the link and your description, and update the whole thing accordingly.

  • Blind4Basics Avatar

    sounds interesting.... Though, just pushing the attempt button wihout implementing anything...:

    Test Results:
    Single Turns
    STDERR:
    
    Traceback (most recent call last):
      File "main.py", line 205, in <module>
        testing(turn)
      File "main.py", line 196, in testing
        actual = perform(sequence)
    NameError: name 'perform' is not defined
    

    :o

    And, in the description:

    implement the rotate() function. It takes a string with space separated values (turns) like rotate("F L R2 D' F2")

    but in the trainer:

    def turn(state, sequence):
        pass