Algorithm analyzer / simulator

...and the R sticker moves to the F face and the F sticker moves to the R face, right?

yes

But that's not what I said. I said:


  • URF moves to DRF
  • RFU moves to RFD (not RDF)
  • FUR moves to FDR (not FRD)

Unless I am completely daft, all of these designations are clockwise and all have the U sticker in the same relative position as the D sticker. It's the first letter in the first example, the third in the second, and the second in the third.

No?

Or am I missing something?

no you are wrong

DRF, RFD and FDR are not clockwise
 
no you are wrong

DRF, RFD and FDR are not clockwise

Quite right. My dylsexia must be acting up again. At least that's what my friends say when I tell them that life has been handing me melons.

So then these three "results" are equivalent, no?


  • URF moves to DFR
  • RFU moves to FRD
  • FUR moves to RDF

And they all convey exactly the same information. Right?
 
Quite right. My dylsexia must be acting up again. At least that's what my friends say when I tell them that life has been handing me melons.

So then these three "results" are equivalent, no?


  • URF moves to DFR
  • RFU moves to FRD
  • FUR moves to RDF

And they all convey exactly the same information. Right?

Yes they do. One is not better than another, they are all different.
 
Cynthia: Only the FIRST letter in a corner matters - the other two can be in either order. You can write either URF or UFR. And yes, if you just modify the alg in line 3 of Stefan's code and rerun the program, it should output what the pieces do.


Stefan: That's a cool little program, but how does it actually do the moves? I assume the magic is in lines 9 and 10 but I don't really get what you're doing there. More specifically, what's the function of the maketrans and translate functions? I assume those are Python specific?
 
Cynthia: Only the FIRST letter in a corner matters - the other two can be in either order. You can write either URF or UFR.

Since the WGO (white-green-orange) piece will always have those three colors in that (clockwise) order, identifying the new position of any one color uniquely determines the other two. Nevertheless, I think it makes sense to have a consistent order, so I'm good with always specifying the corner colors in clockwise order. It also has the advantage of making it easy to read where all three colors went directly from the code.

And yes, if you just modify the alg in line 3 of Stefan's code and rerun the program, it should output what the pieces do.

I tried that and couldn't get it to work. Were you able to do that? Can you tell me what you did, step by step?

Stefan: That's a cool little program, but how does it actually do the moves? I assume the magic is in lines 9 and 10 but I don't really get what you're doing there. More specifically, what's the function of the maketrans and translate functions? I assume those are Python specific?

I assumed at least one of those were subroutines that aren't shown.

Stefan,

Can I edit the string on line 3 [alg = "R' D R"] to enter a different algorithm and rerun the program?

I tried editing it and clicking the Run button, but it took me to a different page.

Thanks

Stefan,

I signed up for an Ideone account hoping to run your cool little program. I got the following error message:

Code:
Compilation error
             
stdin
Standard input is empty
             
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: IndentationError: ('unexpected indent', ('prog.py', 1, 4, '    import string\n'))

stdout
Standard output is empty

Can you help?
 
Last edited by a moderator:
If I download a Python interpreter, will I be able to generate that move list with just the code you show?

For Python 2 it should work, for Python 3 use this instead:
http://ideone.com/haMUAm
(I should have done Python 3 right away, slightly shorter)

If so, Python has to be the most compact language since APL.

Python helps, but it really is the approach that makes it short. qq could probably rewrite it to J or K and make it a third of the size. And I'd love to see that, even though it would look just like gibberish to me :D

PS: Is there any way to generate these multiple quotes other than cutting and pasting the markup?

I don't think so.

Cynthia: Only the FIRST letter in a corner matters - the other two can be in either order. You can write either URF or UFR.

That's a possible convention, but I prefer to use all-same-direction because then readers don't need to know about that convention.

Stefan: That's a cool little program, but how does it actually do the moves? I assume the magic is in lines 9 and 10 but I don't really get what you're doing there. More specifically, what's the function of the maketrans and translate functions? I assume those are Python specific?

They're like Perl's tr/.../.../, maybe you know that? Translates for example "ABC" to "xyz", meaning it replaces every "A" in the target string by "x", every "B" by "y", etc. Very similar to saying "UFR moved to RFD" actually, where the U moved to R, the F to F, and the R to D.

In variable "state", I store the current positions of cubies "UF UR ... DBR". So if at some point the first letter pair in state is "LB", that means that the "UF" cubie is at position "LB". Now let's say I want to simulate a U turn. That affects all cubies currently in the U layer, i.e., those cubies with a "U" in their current position string. And for all of these, every "F" becomes "L", every "L" becomes "B", etc. So lines 7 to 9 prepare the translation "FLBR"-to-"LBRF", and in line 10 it gets applied to all cubie positions containing "U". For example, position "FUR" becomes "LUF" while "DLF" isn't changed. I really love this way to represent and simulate the cube. Easily generalizes to for example Megaminx as well.

Can you help?

Looks like you added spaces where you shouldn't have. If this doesn't help, please post the URL.

Edit: Geez, I'm a noob. Improved the last part of the program and changed variable names while I was at it (only the Python 3 version).
 
Last edited:
Back
Top