Post History
C (gcc), 55 bytes a;f(char*s){for(;atoi(s)&128>>a&&a<4;a++);return 65+a;} Try it online! Just call atoi and start masking with 0x80. If true, keep looping and next che...
Answer
#3: Post edited
# [C (gcc)], 50 bytes- <!-- language-all: lang-c -->
a;f(char*s){for(;atoi(s)&128>>a;a++);return 65+a;}[Try it online!][TIO-m4ctnh7n]- [C (gcc)]: https://gcc.gnu.org/
[TIO-m4ctnh7n]: https://tio.run/##hc7RCoIwFAbg@z3FUIizLJnDylj5Loe55aBmzHklPvvKrooiORz44XzwH7W9KBUjSgOqRb/u2Wg6DxJDZ6Fnq0JUdY0Ss4xJr8PgHd3vMpRTTBttrNPUPBkFPPPNnBghqXXqOjSanvrQ2C5va0KsC/SG1gEjI6H0PoS5DQwkPH9Nwpj8PBSc52/7A4jDEqgWwFH8B0KUC6D8fnKKDw "C (gcc) – Try It Online"- ---
Just call atoi and start masking with 0x80. If true, keep looping and next check with 0x40 and so on, until the mask either results in zero or is right-shifted down to 0x00, meaning all bits in the ms nibble were set.
- # [C (gcc)], 55 bytes
- <!-- language-all: lang-c -->
- a;f(char*s){for(;atoi(s)&128>>a&&a<4;a++);return 65+a;}
- [Try it online!][TIO-m4i7px0j]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-m4i7px0j]: https://tio.run/##hc3fCoMgFAbwe59CCkLXFia5P9h6l4PpEjYbZlfRs7u1qw1i8XHgg/ODTx1uSsUI0hDVgd8NdDK9JxJCb8lAs5KfmwayDOpKQp5T6XUYvcNHkYOcY9pqY53G5m0xgSvbL40ilFqn7mOrcT2E1vZF1yBkXcAPsI5QNCGMn2NYJokhCSs@SSiVv4@SseLrVgA/bQAhNsCF/wecVxtgZWKOLw "C (gcc) – Try It Online"
- ---
- Just call atoi and start masking with 0x80. If true, keep looping and next check with 0x40 and so on, until the mask either results in zero or 4 bits have been checked, meaning all bits in the ms nibble were set.
#2: Post edited
- # [C (gcc)], 50 bytes
- <!-- language-all: lang-c -->
- a;f(char*s){for(;atoi(s)&128>>a;a++);return 65+a;}
- [Try it online!][TIO-m4ctnh7n]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-m4ctnh7n]: https://tio.run/##hc7RCoIwFAbg@z3FUIizLJnDylj5Loe55aBmzHklPvvKrooiORz44XzwH7W9KBUjSgOqRb/u2Wg6DxJDZ6Fnq0JUdY0Ss4xJr8PgHd3vMpRTTBttrNPUPBkFPPPNnBghqXXqOjSanvrQ2C5va0KsC/SG1gEjI6H0PoS5DQwkPH9Nwpj8PBSc52/7A4jDEqgWwFH8B0KUC6D8fnKKDw "C (gcc) – Try It Online"
- ---
Just call atoi and start masking with 0x80. If true, keep looping and next check with 0x40 and so on, until the mask is right-shifted down to 0x00 meaning all bits in the ms nibble were set.
- # [C (gcc)], 50 bytes
- <!-- language-all: lang-c -->
- a;f(char*s){for(;atoi(s)&128>>a;a++);return 65+a;}
- [Try it online!][TIO-m4ctnh7n]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-m4ctnh7n]: https://tio.run/##hc7RCoIwFAbg@z3FUIizLJnDylj5Loe55aBmzHklPvvKrooiORz44XzwH7W9KBUjSgOqRb/u2Wg6DxJDZ6Fnq0JUdY0Ss4xJr8PgHd3vMpRTTBttrNPUPBkFPPPNnBghqXXqOjSanvrQ2C5va0KsC/SG1gEjI6H0PoS5DQwkPH9Nwpj8PBSc52/7A4jDEqgWwFH8B0KUC6D8fnKKDw "C (gcc) – Try It Online"
- ---
- Just call atoi and start masking with 0x80. If true, keep looping and next check with 0x40 and so on, until the mask either results in zero or is right-shifted down to 0x00, meaning all bits in the ms nibble were set.
#1: Initial revision
# [C (gcc)], 50 bytes <!-- language-all: lang-c --> a;f(char*s){for(;atoi(s)&128>>a;a++);return 65+a;} [Try it online!][TIO-m4ctnh7n] [C (gcc)]: https://gcc.gnu.org/ [TIO-m4ctnh7n]: https://tio.run/##hc7RCoIwFAbg@z3FUIizLJnDylj5Loe55aBmzHklPvvKrooiORz44XzwH7W9KBUjSgOqRb/u2Wg6DxJDZ6Fnq0JUdY0Ss4xJr8PgHd3vMpRTTBttrNPUPBkFPPPNnBghqXXqOjSanvrQ2C5va0KsC/SG1gEjI6H0PoS5DQwkPH9Nwpj8PBSc52/7A4jDEqgWwFH8B0KUC6D8fnKKDw "C (gcc) – Try It Online" --- Just call atoi and start masking with 0x80. If true, keep looping and next check with 0x40 and so on, until the mask is right-shifted down to 0x00 meaning all bits in the ms nibble were set.