fork(1) download
  1. # http://c...content-available-to-author-only...e.com/a/90261/34718
  2.  
  3. # Test cases:
  4. #["ACDC","BBCA","BADD","ABCD"]
  5. #["BACD","BACD","BACD","BACD"]
  6. #["BCCB","DAAD","CAAC","BDDB"]
  7. #["ABDC","BACD","DCAB","CDBA"]
  8. #["BDAB","ACCD","DCCA","BADB"]
  9. #["DBCA","BDCA","ACDB","ACBD"]
  10.  
  11. from numpy import*
  12. A=array(map(list,input()))
  13. R=rot90
  14. T=transpose(A)
  15. print any([all(A==Z)for Z in(A[:,::-1],A[::-1],R(A),R(A,2),R(A,3),T,R(T,2))])
Success #stdin #stdout 0.04s 25352KB
stdin
["DBCA","BDCA","ACDB","ACBD"]
stdout
True