ゼリー、7 6バイト(簡単)
IAṢ⁼J$
オンラインでお試しください!
IAṢ⁼J$ jolly function on N:
IAṢ the increment list: get all the Increments, take their Absolute values, and Ṣort them
⁼ compare that to...
J$ range from 1 to len(N) -- this has an extra number, but that's fine because...
...the increment list is one shorter, and ⁼ will only compare that many values
最初の引数で入力をコンマ区切りの数値として受け取ります。シーケンスが陽気な場合は1を返し、そうでない場合は0を返します!
7バイトソリューション:
LRṖḟIA$
オンラインでお試しください!
最初の引数で入力をコンマ区切りの数値として受け取ります。リストがジョリージャンパーシーケンスの場合は何も返さず、そうでない場合は何かを返します。
この行を追加すると、ハード仕様で動作します:
Jelly、27 22バイト(ハード、フィードバック歓迎!)
ɠḲVIAṢ⁼J$ị“¢⁼D“¡KṀȥƘạ»
オンラインでお試しください!
ɠḲVIAṢ⁼J$ị“¢⁼D“¡KṀȥƘạ»
ɠḲV read a line, split on spaces and eValuate the numbers
IAṢ⁼J$ jolly function: see above!
ị ịndex the result into (remember Jelly is one-indexed, so 0 wraps around to the back):
“¢⁼D“ "Jolly" compressed if true,
¡KṀȥƘạ» or, "Not jolly" compressed if false!
27バイト(ハード)ソリューション:
LRṖḟIA$
ɠḲVÇ“¡KṀȥƘạ»“¢⁼D»L?
オンラインでお試しください!
スペースで区切られた数字を取得します stdin
を受け取り、「Jolly」または「Not jolly」を出力します。
説明:
LRṖḟIA$ jolly function:
LRP make a range (R) from 1 to the input length (L), popping off (P) the last number to make it 1 to N-1.
ḟ reverse filter: remove all the elements from that range that are members of...
IA$ the increment list: get all the increments, take their absolute values (expressed as one monad via '$').
ɠḲVÇ“¡KṀȥƘạ»“¢⁼D»L? i/o main function:
ɠḲV read a line from stdin, split it on spaces and have Python parse each number (handling negative signs)
Ç ? run the above, and use the result on the following conditional:
L? if the length of the result is truthy (non-empty):
“¡KṀȥƘạ» then, return Jelly compressed string "Not jolly",
“¢⁼D» else, return Jelly compressed string "Jolly".
フィードバックは大歓迎です!