Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

71%
+3 −0
Challenges Single letter HTML

C (gcc), 31 30 bytes #define f(a) strchr("abipq",a) Try it online! f(a){return strchr("abipq",a);} The most obvious (and non-creative) solution. This under default rules that a tr...

posted 6mo ago by Lundin‭  ·  edited 6mo ago by Lundin‭

Answer
#3: Post edited by user avatar Lundin‭ · 2026-03-18T08:54:15Z (6 months ago)
Swapped function for function-like macro
  • # [C (gcc)], 30 <strike>31</strike> bytes
  • <!-- language-all: lang-c -->
  • #define f(a) strchr("abipq",a)
  • [Try it online!][TIO-mmvsur7k]
  • <strike>
  • <!-- language-all: lang-c -->
  • f(a){return strchr("abipq",a);}
  • </strike>
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-mmvsur7k]: https://tio.run/##Hc0xDsIwDIXhPaewgqrYargApTdhcd2GZCAU0wnUs6eG6f3DJz0530VaO81LKnWBhEzw3lSyoueprC8fmdqDS0VyXweQnoqSWUHyGDgMttcxfP7R92TipwBWLXVL6DuBC3TzrfpoItqDZKLBzO72dgA "C (gcc) – Try It Online"
  • ---
  • The most obvious (and non-creative) solution. This under default rules that a truthy value in the language is anything non-zero. To display explicitly 1 or 0 would require two `!!` before the `strchr` call.
  • (Passing `a` as pointer and returning value through it gives me worse golf results.)
  • EDIT: function-like macros are generally less ideal than functions for golf but in this case it shaves one character.
  • # [C (gcc)], <strike>31</strike> 30 bytes
  • <!-- language-all: lang-c -->
  • #define f(a) strchr("abipq",a)
  • [Try it online!][TIO-mmvsur7k]
  • <strike>
  • <!-- language-all: lang-c -->
  • f(a){return strchr("abipq",a);}
  • </strike>
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-mmvsur7k]: https://tio.run/##Hc0xDsIwDIXhPaewgqrYargApTdhcd2GZCAU0wnUs6eG6f3DJz0530VaO81LKnWBhEzw3lSyoueprC8fmdqDS0VyXweQnoqSWUHyGDgMttcxfP7R92TipwBWLXVL6DuBC3TzrfpoItqDZKLBzO72dgA "C (gcc) – Try It Online"
  • ---
  • The most obvious (and non-creative) solution. This under default rules that a truthy value in the language is anything non-zero. To display explicitly 1 or 0 would require two `!!` before the `strchr` call.
  • (Passing `a` as pointer and returning value through it gives me worse golf results.)
  • EDIT: function-like macros are generally less ideal than functions for golf but in this case it shaves one character.
#2: Post edited by user avatar Lundin‭ · 2026-03-18T08:51:46Z (6 months ago)
Swapped function for function-like macro
  • # [C (gcc)], 31 bytes
  • <!-- language-all: lang-c -->
  • f(a){return strchr("abipq",a);}
  • [Try it online!][TIO-mmnmgv55]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-mmnmgv55]: https://tio.run/##HctBDsIgEIXhPaeYkDTMpHgBsTdxM44iLMQ60o0NZ0d09f7F9@RwF@k9ItOut7ppgXdVSYqWL3l9Wc8UWn9wLkhmNwDxqSiJFSQtjl0Ye1rc5x/zTEP8FMCqudSIdhI4wnQ9F@uH8BDHmygM00zrXw "C (gcc) – Try It Online"
  • ---
  • The most obvious (and non-creative) solution. This under default rules that a truthy value in the language is anything non-zero. To display explicitly 1 or 0 would require two `!!` before the `strchr` call.
  • (Passing `a` as pointer and returning value through it gives me worse golf results.)
  • # [C (gcc)], 30 <strike>31</strike> bytes
  • <!-- language-all: lang-c -->
  • #define f(a) strchr("abipq",a)
  • [Try it online!][TIO-mmvsur7k]
  • <strike>
  • <!-- language-all: lang-c -->
  • f(a){return strchr("abipq",a);}
  • </strike>
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-mmvsur7k]: https://tio.run/##Hc0xDsIwDIXhPaewgqrYargApTdhcd2GZCAU0wnUs6eG6f3DJz0530VaO81LKnWBhEzw3lSyoueprC8fmdqDS0VyXweQnoqSWUHyGDgMttcxfP7R92TipwBWLXVL6DuBC3TzrfpoItqDZKLBzO72dgA "C (gcc) – Try It Online"
  • ---
  • The most obvious (and non-creative) solution. This under default rules that a truthy value in the language is anything non-zero. To display explicitly 1 or 0 would require two `!!` before the `strchr` call.
  • (Passing `a` as pointer and returning value through it gives me worse golf results.)
  • EDIT: function-like macros are generally less ideal than functions for golf but in this case it shaves one character.
#1: Initial revision by user avatar Lundin‭ · 2026-03-12T15:33:47Z (6 months ago)
# [C (gcc)], 31 bytes

<!-- language-all: lang-c -->

    f(a){return strchr("abipq",a);}

[Try it online!][TIO-mmnmgv55]

[C (gcc)]: https://gcc.gnu.org/
[TIO-mmnmgv55]: https://tio.run/##HctBDsIgEIXhPaeYkDTMpHgBsTdxM44iLMQ60o0NZ0d09f7F9@RwF@k9ItOut7ppgXdVSYqWL3l9Wc8UWn9wLkhmNwDxqSiJFSQtjl0Ye1rc5x/zTEP8FMCqudSIdhI4wnQ9F@uH8BDHmygM00zrXw "C (gcc) – Try It Online"

---

The most obvious (and non-creative) solution. This under default rules that a truthy value in the language is anything non-zero. To display explicitly 1 or 0 would require two `!!` before the `strchr` call.

(Passing `a` as pointer and returning value through it gives me worse golf results.)