Jelly , 7 6 byte (dễ dàng)
IAṢ⁼J$
Hãy thử trực tuyến!
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
Lấy đầu vào là các số được phân tách bằng dấu phẩy trong đối số đầu tiên. Trả về 1 nếu chuỗi là jolly và 0 nếu không!
Giải pháp 7 byte:
LRṖḟIA$
Hãy thử trực tuyến!
Lấy đầu vào là các số được phân tách bằng dấu phẩy trong đối số đầu tiên. Trả về không có gì nếu danh sách là một chuỗi jumper jolly, và một cái gì đó nếu nó không.
Thêm dòng này làm cho nó hoạt động với thông số kỹ thuật cứng:
Jelly , 27 22 byte (khó, phản hồi chào mừng!)
ɠḲVIAṢ⁼J$ị“¢⁼D“¡KṀȥƘạ»
Hãy thử trực tuyến!
ɠḲ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!
Giải pháp 27 byte (cứng):
LRṖḟIA$
ɠḲVÇ“¡KṀȥƘạ»“¢⁼D»L?
Hãy thử trực tuyến!
Bật các số được phân tách bằng dấu cách stdinvà xuất ra "Jolly" hoặc "Không jolly".
Giải trình:
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".
Bất kỳ thông tin phản hồi đánh giá cao!