Gelatina , 7 6 byte (facile)
IAṢ⁼J$
Provalo 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
Accetta input come numeri separati da virgola nel primo argomento. Restituisce 1 se la sequenza è jolly e 0 se non lo è!
Soluzione a 7 byte:
LRṖḟIA$
Provalo online!
Accetta input come numeri separati da virgola nel primo argomento. Non restituisce nulla se l'elenco è una sequenza jolly jumper e qualcosa in caso contrario.
L'aggiunta di questa linea lo fa funzionare con le specifiche difficili:
Jelly , 27 22 byte (difficile, feedback di benvenuto!)
ɠḲVIAṢ⁼J$ị“¢⁼D“¡KṀȥƘạ»
Provalo 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!
Soluzione a 27 byte (difficile):
LRṖḟIA$
ɠḲVÇ“¡KṀȥƘạ»“¢⁼D»L?
Provalo online!
Accetta numeri separati da spazi stdin e genera "Jolly" o "Non jolly".
Spiegazione:
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".
Qualsiasi feedback molto apprezzato!