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

added 7 characters in body
Source Link

Haskell, 47(削除) 47 (削除ここまで) 46 bytes

fst.minimum.filter((/=[]>[]).snd).map(span(==' '))

Try it online! Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/=> []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Haskell, 47 bytes

fst.minimum.filter((/=[]).snd).map(span(==' '))

Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/= []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Haskell, (削除) 47 (削除ここまで) 46 bytes

fst.minimum.filter((>[]).snd).map(span(==' '))

Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((> []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Better TIO version.
Source Link

Haskell, 47 bytes

fst.minimum.filter((/=[]).snd).map(span(==' '))

Try it online! Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/= []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Haskell, 47 bytes

fst.minimum.filter((/=[]).snd).map(span(==' '))

Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/= []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Haskell, 47 bytes

fst.minimum.filter((/=[]).snd).map(span(==' '))

Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/= []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

Source Link

Haskell, 47 bytes

fst.minimum.filter((/=[]).snd).map(span(==' '))

Try it online!

Nothing special here, it's a very standard approach, just with less whitespace. A more presentable version:

main :: IO ()
main = interact (f . lines)
f :: [String] -> String
f = fst -- extract it from the tuple
 . minimum -- find the shortest leading whitespace (tuples are sorted by first element)
 . filter ((/= []) . snd) -- remove any tuples for which 'everything else' is empty
 . map (span (== ' ')) -- split each line into tuples of (leading whitespace, everything else)

Since minimum is a partial function, it will raise an exception if given input that consists only of whitespace. From my perusal of the rules, I'm under the impression that this is acceptable; but I'm fairly new here so please correct me if I'm wrong.

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