Post History
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...
#3: Post edited
# [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
# [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
# [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.)
