Created
October 14, 2014 15:18
-
-
Save butchi/d643ffa83f760e9dfda9 to your computer and use it in GitHub Desktop.
yukicoder No.39 桁の数字を入れ替え
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/39 *) | |
maxPos[li_] := Last[Position[li, Max[li]]][[1]] | |
replace[li_] := ReplacePart[li, {maxPos[li] -> First[li], 1 -> Max[li]}] | |
f[n_] := FromDigits[replace[IntegerDigits[n]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
不正解
× f[9978] = 9978
○ f[9978] = 9987