Gelee , 7 6 Bytes (einfach)
IAṢ⁼J$
Probieren Sie es online!
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
Übernimmt die Eingabe als durch Kommas getrennte Zahlen im ersten Argument. Gibt 1 zurück, wenn die Sequenz lustig ist, und 0, wenn dies nicht der Fall ist!
7-Byte-Lösung:
LRṖḟIA$
Probieren Sie es online!
Übernimmt die Eingabe als durch Kommas getrennte Zahlen im ersten Argument. Returns nichts , wenn die Liste eine Jolly Jumper - Sequenz ist, und etwas wenn dies nicht der ist.
Wenn Sie diese Zeile hinzufügen, funktioniert dies mit der Hardspezifikation:
Jelly , 27 22 Bytes (hart, Feedback erwünscht!)
ɠḲVIAṢ⁼J$ị“¢⁼D“¡KṀȥƘạ»
Probieren Sie es online!
ɠḲ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 Byte (harte) Lösung:
LRṖḟIA$
ɠḲVÇ“¡KṀȥƘạ»“¢⁼D»L?
Probieren Sie es online!
Nimmt durch Leerzeichen getrennte Zahlen auf stdinund gibt "Jolly" oder "Not Jolly" aus.
Erläuterung:
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".
Jedes Feedback sehr geschätzt!