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 alphabetization
Source Link
guest4308
  • 1.6k
  • 6
  • 21

sed, (削除) 26 (削除ここまで) 24 bytes

-2 from @GammaFunction for swapping truthy/falsy

/[1ACFHLRSacdfgik-tx]/Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetizedalphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit with an error code of 1, otherwise it'll exit normally with your input in stdout.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q1

sed, (削除) 26 (削除ここまで) 24 bytes

-2 from @GammaFunction for swapping truthy/falsy

/[1ACFHLRSacdfgik-tx]/Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit with an error code of 1, otherwise it'll exit normally with your input in stdout.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q1

sed, (削除) 26 (削除ここまで) 24 bytes

-2 from @GammaFunction for swapping truthy/falsy

/[1ACFHLRSacdfgik-tx]/Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit with an error code of 1, otherwise it'll exit normally with your input in stdout.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q1
golf
Source Link
guest4308
  • 1.6k
  • 6
  • 21

sed, 26(削除) 26 (削除ここまで) 24 bytes

-2 from @GammaFunction for swapping truthy/falsy

/[1ACFHLRSacdfgik-tx]/Q
Q1

Try it online! Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit normally, and if it wasn't it'll givewith an error code of 1, otherwise it'll exit normally with your input in stdout.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q
Q1

sed, 26 bytes

/[1ACFHLRSacdfgik-tx]/Q
Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit normally, and if it wasn't it'll give an error code of 1.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q
Q1

sed, (削除) 26 (削除ここまで) 24 bytes

-2 from @GammaFunction for swapping truthy/falsy

/[1ACFHLRSacdfgik-tx]/Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit with an error code of 1, otherwise it'll exit normally with your input in stdout.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q1
Source Link
guest4308
  • 1.6k
  • 6
  • 21

sed, 26 bytes

/[1ACFHLRSacdfgik-tx]/Q
Q1

Try it online!

guess I can start it off with the obvious solution. I alphabetized the options so that I could abbreviate any ranges; but k-t was the only one. in sed, Q means 'immediately quit', and it takes an optional number as an error code; so if input was a good char then it'll quit normally, and if it wasn't it'll give an error code of 1.

if you need it to check if the entire string is a valid option, it'd look like

/^[1ACFHLRSacdfgik-tx]*$/Q
Q1

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