fork(3) download
  1. import string
  2.  
  3. alg = "R' D R"
  4.  
  5. state = solved = "UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR".split()
  6. for move in alg.split():
  7. perm = "FLBR FRBL FDBU FUBD URDL ULDR".split()['UDLRFB'.index(move[0])]
  8. n = len(move) + move.endswith("'")
  9. table = string.maketrans(perm, perm[n:] + perm[:n])
  10. state = [p.translate(table) if move[0] in p else p for p in state]
  11. for io in zip(solved, state):
  12. if io[0] != io[1]:
  13. print "{} moved to {}".format(*io)
Success #stdin #stdout 0.01s 7908KB
stdin
Standard input is empty
stdout
DF moved to FR
DB moved to DL
DL moved to DF
FR moved to DB
UFR moved to RFD
DRF moved to LBD
DFL moved to FRU
DLB moved to DFL