Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#05AB1E , (削除) 21 (削除ここまで) 20 bytes

05AB1E , (削除) 21 (削除ここまで) 20 bytes

#05AB1E , (削除) 21 (削除ここまで) 20 bytes

05AB1E , (削除) 21 (削除ここまで) 20 bytes

changed to gender-inclusive pronoun
Source Link
Greg Martin
  • 16.7k
  • 4
  • 23
  • 73

Port of @ngn's K (ngn/k) answer, so make sure to upvote himthem!!

Port of @ngn's K (ngn/k) answer, so make sure to upvote him!!

Port of @ngn's K (ngn/k) answer, so make sure to upvote them!!

Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#05AB1E, (削除) 21 (削除ここまで) 20 bytes

Ask¬-2%.sD€ß\s€à\+ĀP

Port of @ngn's K (ngn/k) answer, so make sure to upvote him!!

Input as a lowercase list of characters.

Try it online or verify all test cases.

Explanation:

A # Push the lowercase alphabet: "abcdefghijklmnopqrstuvwxyz"
 sk # Get the (0-based) index of each characters of the input-list in this alphabet
 # i.e. ["b","a","l","m","y"] → [1,0,11,12,24]
¬ # Push the first index (without popping)
 - # And subtract it from each index
 # i.e. [1,0,11,12,24] - 1 → [0,-1,10,11,23]
 2% # Then take modulo-26 to make the negative values positive
 # i.e [0,-1,10,11,23] → [0,25,10,11,23]
.s # Take the suffices of this list
 # i.e. [0,25,10,11,23] → [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]]
 D # Duplicate it
 ۧ # Take the minimum of each suffix
 # i.e. [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]]
 # → [23,11,10,10,0]
 \ # And take the deltas (forward differences) of those
 # i.e. [23,11,10,10,0] → [-12,-1,0,-10]
 s # Swap to get the suffices again
 ۈ # Take the maximum of each suffix this time
 # i.e. [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]]
 # → [23,23,23,25,25]
 \ # And take the deltas (forward differences) of those as well
 # i.e. [23,23,23,25,25] → [0,0,2,0]
 + # Add the values at the same indices in the two lists together
 # i.e. [-12,-1,0,-10] + [0,0,2,0] → [-12,1,2,-10]
 Ā # Python-style truthify each (0→0; everything else → 1)
 # i.e. [-12,1,2,-10] → [1,1,1,1]
 P # And take the product of that to check if all are truthy
 # i.e. [1,1,1,1] → 1
 # (after which this is output implicitly as result)

AltStyle によって変換されたページ (->オリジナル) /