Post History
C (gcc), 47 bytes r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;} Try it online! I didn't manage to come up with anything better than the most obvious recursive im...
Answer
#3: Post edited
- # [C (gcc)], 47 bytes
- <!-- language-all: lang-c -->
- r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;}
- [Try it online!][TIO-llnk7ocv]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-llnk7ocv]: https://tio.run/##JY5BCsIwEEX3OcWnYElIKm1BEZL2HC7cSDAyC1MZ6qrm7DGpqz8z7w183z29z5mNt0GS2vixfjjCa@0ubSt5YueGL7WDKXieB6UM25QprnjdKUolNgEgLCzrjabegtx4OpfQWgGV7grAU298Ef7bm8tDkM3hOF7RYUYdbrExIIPaRe1iEin/AA "C (gcc) – Try It Online"
I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer...Or in case binary output is acceptable:# [C (gcc)], 42 bytes<!-- language-all: lang-c -->c;f(i){c++<8&&(printf("%d",i&1),f(i>>1));}[Try it online!][TIO-llnmdl5i][C (gcc)]: https://gcc.gnu.org/[TIO-llnmdl5i]: https://tio.run/##LY3NCsIwEITveYohYNglFaygCKl9F1mJ7MFaansqefY0sZ7m5xsYOb5EcpYQSXkV77ubczROOsyR7OFpG3UtN4X2fcscUi4E74cOxGY1AOJnotrp/RSg3flyLeI9A5X@JoAUuLv687fjMn/J2j0mk/IG "C (gcc) – Try It Online"
- # [C (gcc)], 47 bytes
- <!-- language-all: lang-c -->
- r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;}
- [Try it online!][TIO-llnk7ocv]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-llnk7ocv]: https://tio.run/##JY5BCsIwEEX3OcWnYElIKm1BEZL2HC7cSDAyC1MZ6qrm7DGpqz8z7w183z29z5mNt0GS2vixfjjCa@0ubSt5YueGL7WDKXieB6UM25QprnjdKUolNgEgLCzrjabegtx4OpfQWgGV7grAU298Ef7bm8tDkM3hOF7RYUYdbrExIIPaRe1iEin/AA "C (gcc) – Try It Online"
- I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer...
#2: Post edited
- # [C (gcc)], 47 bytes
- <!-- language-all: lang-c -->
- r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;}
- [Try it online!][TIO-llnk7ocv]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-llnk7ocv]: https://tio.run/##JY5BCsIwEEX3OcWnYElIKm1BEZL2HC7cSDAyC1MZ6qrm7DGpqz8z7w183z29z5mNt0GS2vixfjjCa@0ubSt5YueGL7WDKXieB6UM25QprnjdKUolNgEgLCzrjabegtx4OpfQWgGV7grAU298Ef7bm8tDkM3hOF7RYUYdbrExIIPaRe1iEin/AA "C (gcc) – Try It Online"
I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer...
- # [C (gcc)], 47 bytes
- <!-- language-all: lang-c -->
- r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;}
- [Try it online!][TIO-llnk7ocv]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-llnk7ocv]: https://tio.run/##JY5BCsIwEEX3OcWnYElIKm1BEZL2HC7cSDAyC1MZ6qrm7DGpqz8z7w183z29z5mNt0GS2vixfjjCa@0ubSt5YueGL7WDKXieB6UM25QprnjdKUolNgEgLCzrjabegtx4OpfQWgGV7grAU298Ef7bm8tDkM3hOF7RYUYdbrExIIPaRe1iEin/AA "C (gcc) – Try It Online"
- I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer...
- Or in case binary output is acceptable:
- # [C (gcc)], 42 bytes
- <!-- language-all: lang-c -->
- c;f(i){c++<8&&(printf("%d",i&1),f(i>>1));}
- [Try it online!][TIO-llnmdl5i]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-llnmdl5i]: https://tio.run/##LY3NCsIwEITveYohYNglFaygCKl9F1mJ7MFaansqefY0sZ7m5xsYOb5EcpYQSXkV77ubczROOsyR7OFpG3UtN4X2fcscUi4E74cOxGY1AOJnotrp/RSg3flyLeI9A5X@JoAUuLv687fjMn/J2j0mk/IG "C (gcc) – Try It Online"
#1: Initial revision
# [C (gcc)], 47 bytes <!-- language-all: lang-c --> r,c;f(i){return c++<8&&(r=r<<1|i&1,f(i>>1)),r;} [Try it online!][TIO-llnk7ocv] [C (gcc)]: https://gcc.gnu.org/ [TIO-llnk7ocv]: https://tio.run/##JY5BCsIwEEX3OcWnYElIKm1BEZL2HC7cSDAyC1MZ6qrm7DGpqz8z7w183z29z5mNt0GS2vixfjjCa@0ubSt5YueGL7WDKXieB6UM25QprnjdKUolNgEgLCzrjabegtx4OpfQWgGV7grAU298Ef7bm8tDkM3hOF7RYUYdbrExIIPaRe1iEin/AA "C (gcc) – Try It Online" I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer...