Created
November 2, 2014 16:57
-
-
Save butchi/5d1d78fd0e22d127afb6 to your computer and use it in GitHub Desktop.
No.55 正方形を描くだけの簡単なお仕事です。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* http://yukicoder.me/problems/no/55 *) | |
| pLi = Complex[#[[1]], #[[2]]] & /@ | |
| Partition[ImportString["8 10 14 14 13 9", "Table"][[1]], 2]; | |
| dLi = Abs[RotateLeft[pLi, 1] - RotateLeft[pLi, 2]]; | |
| permLi = Permutations[pLi]; | |
| p4Li = (#[[2]] + I (#[[1]] - #[[3]])) & /@ permLi; | |
| sqLi = Table[Append[permLi[[n]], p4Li[[n]]], {n, 1, Length[permLi]}]; | |
| edgeLen[pLi_] := Abs[pLi - RotateLeft[pLi]]; | |
| judgeLi = SameQ @@ # & /@ (edgeLen /@ sqLi); | |
| pos = Position[judgeLi, True]; | |
| If[pos === {}, -1, ({Re[#], Im[#]} &@p4Li[[pos[[1]][[1]]]])] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment