Activity for Lundin
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #283770 |
_Must_ it be a function or are function-like macros allowed (in case of C)? (more) |
— | over 2 years ago |
Edit | Post #284048 |
Post edited: |
— | over 2 years ago |
Edit | Post #284048 | Initial revision | — | over 2 years ago |
Answer | — |
A: Make $2 + 2 = 5$ [C (gcc)], 30 bytes f(x,y){return x+y|!(x^y|x^2);} Try it online! In case the "preferably on a function" requirement can be dropped, then #define f(x,y)x+y|!(x^y|x^2) is 28 bytes. (more) |
— | over 2 years ago |
Comment | Post #283917 |
@#53588 It might be worth keeping discussions archived at least for a few weeks after a new challenge is released. In case anyone has questions they might be able to go check the reasoning behind some rule in the sandbox. In the long term I agree that finalised sandbox drafts hold no value. (more) |
— | over 2 years ago |
Comment | Post #283864 |
Same solution: `f(n){n&&f(n/2);putchar(n&1|48);}` (more) |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Comment | Post #283736 |
@#54114 I'm decent at C programming but still a beginner at code golfing :) (more) |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: Oh hey, printf happens to return 3 in this case. This is some truly evil code... :) |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: Move the first print to the first condition of inner for loop. Lose && but adds a , |
— | over 2 years ago |
Comment | Post #283716 |
@#54114 I think the fastest code is an interesting idea, though for this to work out we'd have to come up with a standardized way to benchmark the code, preferably online in TIO. That probably means that challenges will be restricted to one particular language. Ideally, all answers are expected to pr... (more) |
— | over 2 years ago |
Edit | Post #283738 | Initial revision | — | over 2 years ago |
Article | — |
Pass a value through different memory sections Lets get a bit closer to the metal than usual! The task is to pass a constant value between the different data memory sections of a typical computer. For this challenge you need a system and language which allows you to allocate variables in all of the following sections (using ELF notation): ... (more) |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 |
Post edited: |
— | over 2 years ago |
Edit | Post #283736 | Initial revision | — | over 2 years ago |
Answer | — |
A: In The Jailhouse Now [C (gcc)], 119 118 116 115 bytes #define p(x,y,z) printf(i^1?i^c?#z:#y:#x) i,j;f(c){for(i=1;i<=c;p(╗\n,╝\n,╣\n),i++)for(j=p(╔,╚,╠);j++<c;)p(╦,╩,╬);} Try it online! Function solution. I started with a recursive solution but it didn't work out well... though I'm still conv... (more) |
— | over 2 years ago |
Comment | Post #283649 |
It should say "Take input of a non-negative _decimal_ integer". Also, many languages have conversion functions so this will mostly be about passing input to a conversion function and print it. Or print straight away using binary notation if the language supports it. (more) |
— | over 2 years ago |
Comment | Post #283652 |
I'm realizing that your neat `"s"+(n<2)` trick would have shaved down my own solution quite a bit, but I'll refrain from shamelessly stealing it :) I have lots of stuff like `%.*s` `i-1?8:7,w` (print 7 characters of the string w otherwise 8) which didn't turn out too compact. (more) |
— | over 2 years ago |
Comment | Post #283652 |
Seems we were working on this simultaneously in C but you beat me with 12 :) Completely different solutions, I went bananas on the printf format string instead. (more) |
— | over 2 years ago |
Edit | Post #283661 | Post undeleted | — | over 2 years ago |
Edit | Post #283661 |
Post edited: |
— | over 2 years ago |
Edit | Post #283661 | Post deleted | — | over 2 years ago |
Edit | Post #283661 | Initial revision | — | over 2 years ago |
Answer | — |
A: 99 Shortened Bottles of Beer [C (gcc)], 244 bytes main(){for(charw=" bottles of beer on the wall",i=100;--i;)printf("%d%.s%s, %d%.s%.8s.\n%s, %d%.s%s.\n\n",i,i-1?8:7,w,w+8,i,i-1?8:7,w,w+8,i^1?"Take one down and pass it around":"Go to the store and buy some more",i^1?i-1:99,i^2?8:7,w,w+8);} Try it online! Ful... (more) |
— | over 2 years ago |
Comment | Post #279159 |
Wouldn't each example have two answers? Since it's a quadratic equation and solving x^2 gives 2 roots. (more) |
— | over 2 years ago |
Comment | Post #283432 |
I think `C (gcc)` already implies gcc compiler extensions. Or that's how we have been using it until now, at least. It would be cumbersome to change that now. (more) |
— | over 2 years ago |
Edit | Post #283435 | Initial revision | — | over 2 years ago |
Answer | — |
A: Default Rules: Extensions The `C (gcc)` implies extensions - it will only work with that specific compiler under it's default setting GNU17 (equivalent to `-std=gnu17`), which is mostly a superset of standard C. This also includes a number of POSIX functions. Another option is standard C, meaning no extensions and no const... (more) |
— | over 2 years ago |
Comment | Post #283380 |
@#54114 Again, this is a strictly conforming solution. The includes need to be there or it won't compile. Similarly implicit int was removed from the language. (more) |
— | over 2 years ago |
Comment | Post #283380 |
@#53588g As for the TIO, I wished to test with the worst test case that takes some serious amount of input. I couldn't be bothered to add them one by one to TIO. (more) |
— | over 2 years ago |
Comment | Post #283380 |
@#53588 This is a strictly conforming solution, meaning it has to be fully standard compliant and with no poorly-defined behavior. It's not using gcc extensions, just standard C. (more) |
— | over 2 years ago |
Comment | Post #282238 |
`main(){printf("$");main();}` This program creates stack overflow, takes no input from the community and gives lots of dollar signs as output for a short while, until the inevitable crash happens. On a serious note, can't we come up with something more original than copy paste of existing challenges ... (more) |
— | over 2 years ago |
Edit | Post #283380 | Initial revision | — | over 2 years ago |
Answer | — |
A: Coat of Many Colours C, 534 bytes Strictly conforming program. #include #include #include char i=1,c,d,t[30]={"red","yellow","green","brown","scarlet","black","ochre","peach","ruby","olive","violet","fawn","lilac","gold","chocolate","mauve","cream","crimson","silver","rose","azure","lemon"... (more) |
— | over 2 years ago |
Edit | Post #283379 |
Post edited: |
— | over 2 years ago |
Edit | Post #283379 | Initial revision | — | over 2 years ago |
Question | — |
How to add lots of command line arguments to https://tio.run? I have a question about everyone's favourite Code Golf editor https://tio.run. After picking a language, is there a sensible way to enter command line arguments to it, other than adding them manually one by one? For one golf challenge here I need to add some 30+ arguments for testing and that quic... (more) |
— | over 2 years ago |
Edit | Post #283353 |
Post edited: |
— | over 2 years ago |
Edit | Post #283353 |
Post edited: |
— | over 2 years ago |
Edit | Post #283353 | Initial revision | — | over 2 years ago |
Answer | — |
A: Caesar shift cipher [C (gcc)], 112 bytes Function solution. p,a;f(chars,int n){a=strdup(s);for(s=a;s;s++)(p=isalpha(s)?(s&96)^96?65:97:0)&&(s=(s-p+n)%26+p);puts(a);} Try it online! Explanation: The code takes a hard copy of the passed parameter and increases each character with the value, but... (more) |
— | over 2 years ago |
Comment | Post #282821 |
Examples like the above seem like valid clever tricks that should be encouraged rather than forbidden. (more) |
— | over 2 years ago |
Comment | Post #282821 |
If there is to be such a rule, it needs to be more specific. In C and C++ you have various tricks such as [the #line directive](https://godbolt.org/z/nrxGaqP4W) which can be used to trick the program into thinking the file name is something else - might be handy in some scenarios. There's also the ar... (more) |
— | over 2 years ago |
Comment | Post #282952 |
In case of the value zero specifically, `i` is guaranteed to already be zero even in strictly conforming C, since it has static storage duration. So maybe use some other number for example :) (more) |
— | over 2 years ago |