5 kyu
Rubik's Cube Simulator
46 of 47sgerodes
Loading description...
Puzzles
Algorithms
Geometry
Simulation
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
in JS random tests output looks like
I suppose seeing all 54 letters would be helpful for debugging
yes
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.
agreed, call it "Rubik's Cube simulator" maybe?
Done, now we can better distinguish between the solvers and simulators.
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"
Its not possible to delete old solutions. The obsolete, suboptimal solutions stay with us forever.
ok :(
Those shouldn't be deleted, even if it were possible. Once published, your submission is part of the historical record.
this should be 4kyu
Your 2x2 kata is probably also 4, no?
ah, maybe I should change it to 4kyu. However the 3x3 solver it estimated at 3kyu only, and the my 2x2 one is much easier imo. Rank inflation is a thing to consider too... Oh well, maybe I should get more completions on my kata first, then let the community decide.
This is a selffulling propecy. Skrew this inflation :)
you make a good point, dfhwze. changed to 4kyu.
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?
For
X
,Y
andZ
it's unspecified which direction they're pointing to. There are multiple conventions for this (Y
can point atU
,D
,F
or evenB
), 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)added to description
Added a Rubiks solving Kata You are welcome.;) https://www.codewars.com/kata/5e01fbe21f177f000f4995d7
I already saw the very same kata on codingame.com nearly a year ago. Did you copy it from there?
There are numerous rubik codes on the internet. But I composed the this code on my own.
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?
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).
I agree it would have been better. But kata got approved without this suggestion.
Btw, seeing the name of your kata... Are you planning on doing more about rubik's cubes?
Yes, it is just the first step. I wanted to implement the FTOP method of solving the cube.
Do you suggest another name?
Still some informations that are lacking in the description. Use that instead:
F
,B
, ...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.
Changed
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.
Why not? Then the wariors can simply test their rotations by themself. For the weaker it wouldbe very useful. And it NOT helps to bypass the tests. Because the dict is only cased on a solved cube. Scrambles will test everything carefully.
Well, as you want. It was just a question I had for myself and that I wanted to share about, taht's all. ;)
ok, so, here we are:
M
(again, your implementation is correct about it, only the representation in the description is wrong)ulfrbd
Test.describe
andTest.it
: you forgot or put oneprint("<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
.Other example, on the sequence
U R b B
.Mines:
Yours at the end: front and back are wrong.
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
Changed the description. Added a dictionary for the basic rotations. Will take a look at the bug you mentoned tomorrow. Alredy 11 PM...) Thanks for testing !
ok, all the simple moves are good. Still failing only at the scramble parts. I don't know what you did with your code, but it seems it doesn't handle properly some combinations or complex sequences.
Could it be that
S
,f
,b
, andZ
(and their "'" and "2" variants) are still buggy?S
andb
turn the front, whilef
andZ
don't. (see this solution).As this is still in beta: Maybe you want to consider changing the initial state from
"yyyyyyyyybbbbbbbbbrrrrrrrrrgggggggggooooooooowwwwwwwww"
to"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12"
. Test failures would be so much clearer.ah right, didn't think about that. I'll check if my code is wrong or not, so.
well, mys olution seems still correct though. @siebenschlaefer: you talked about the reference solution or mine?
I'm talking about the reference solution.
If the initial state was
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12"
the visual representation would look like this:For the command
S
the reference solution would return"abcqnkghijWlmXopYruxAtwzsvyBdDEeGHfJKLMNOPQRSTUVIFCZ12"
or visuallyAs you can see, the front is turned.
Same for
b
:"DGJCFIghicflbeoadryvszwtAxuBY2EX1HWZQNKROLSPMTUVknqjmp"
or visuallyNow for
f
the front is NOT turned:"abcqnkroljWTmXUpYVstuvwxyzAgdDheGifJKLMNOPQRSHEBIFCZ12"
or visuallySame for
Z
:"pmjqnkrolZWT1XU2YVstuvwxyzAgdahebifcMPSLORKNQHEBIFCJGD"
or visuallyok, thx.
Awesome debugging idea @siebenschlaefer. Thanks
waiting for the update... :)
I am now working on it.) Its harder to find the bug than I thought. I think I rotate an array one time to much.
Ahhh, it was all the Z orientation. Glad I must not debug all the code. It is easy to overlook, because the F sticker by the Z orientation are changing its state, but by a solved cube it is not visible. And I forgot to rotate the front stickers. Thanks another time for the idea to make all stikers different. I will resfresh in some minutes. f b Z S are working now as expected
print("<COMPLETEDIN::>")
, thanks. It should be in the post. Where can I reed about the new test framework?The new test framework: Codewars-Python-Test-Framework-V2
According to that link, the transformation for
M
should be:and not:
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.
The part with the "M" slice. I double checked before constructing the Kata all different turns. I checked it now too. Compared them to the website. No Issues were found. That is what the function is returning to me:
It is correct in the enviroment of the website and also in this Kata. Could it be possible that you were confused by the fact that the cube on the website has an orientation with white to the top and the Kata with yellow to the top? Or were you making the M' (the oposite to M) turn?
wait, maybe there is another kind o problem, then. I compared using the fact that here it is said:
looking at the image, the middle column of the front face of the cube is going down, seen as clockwise rotation, viewed from the left side (since
as an L turn
). Now, using your initial cube:Central
y
is going down, same forr
andw
, which end up on the back side, ando
goes to theU
side. And this is absolutely not what you're telling in the description or your previous message.So, where is actually the problem? Seems to me you're rotating in the wrong direction.
currently at the debugging step, important info:
So far, your implementation is correct, but that's the description that is wrong, in fact.
Understood. I am working currently on the description. Debugging and making it understandable.
closing this one to make some clean up in the informations.
sounds interesting.... Though, just pushing the attempt button wihout implementing anything...:
: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:
I was experimenting with the Function name and the number of arguments.))) Sry, forgot to update the description.
no problem.
But it seems now that your random tests aren't random at all:
I cant explaind why it is so... The random generation is working correct, I checked. a random trun sequence is given to "testing()" but "testing()" receives ALWAYS "Z2". cant explain it now. Do you have any ideas?
Strings are immutable, the "perform" can not alter it, so it should not be the problem with that.
I was so stupid to use another variable in the call. Fuck. Problem solved.