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 »

Activity for Lundin‭

Type On... Excerpt Status Date
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 3 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 3 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 3 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 3 years ago
Edit Post #283661 Post undeleted over 3 years ago
Edit Post #283661 Post edited:
over 3 years ago
Edit Post #283661 Post deleted over 3 years ago
Edit Post #283661 Initial revision over 3 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 3 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 3 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 3 years ago
Edit Post #283435 Initial revision over 3 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 3 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 3 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 3 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 3 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 3 years ago
Edit Post #283380 Initial revision over 3 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 3 years ago
Edit Post #283379 Post edited:
over 3 years ago
Edit Post #283379 Initial revision over 3 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 3 years ago
Edit Post #283353 Post edited:
over 3 years ago
Edit Post #283353 Post edited:
over 3 years ago
Edit Post #283353 Initial revision over 3 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 3 years ago
Comment Post #282821 Examples like the above seem like valid clever tricks that should be encouraged rather than forbidden.
(more)
over 3 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 3 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 3 years ago
Edit Post #283267 Initial revision over 3 years ago
Answer A: Tips for golfing in C
For the sake of code golf, you first need to decide if you wish to compete in strictly conforming ("real") C, in which case you can't rely on non-standard extensions, poorly-defined behavior or obsolete features. Or you can compete in non-standard extensions (gcc/GNU etc), when whatever binary the...
(more)
over 3 years ago
Edit Post #283137 Post edited:
over 3 years ago
Edit Post #283137 Post edited:
over 3 years ago
Comment Post #283137 @#53588 Oh I misunderstood it then. Means I can easily shave this down some more.
(more)
over 3 years ago
Edit Post #283138 Post edited:
over 3 years ago
Comment Post #283137 @#53588 No idea what you mean. The task is to print a string "true" or "false".
(more)
over 3 years ago
Comment Post #283138 Headers would have given it away, it was already quite easy 🙂 The answer is C or C++. Compiles with gcc default settings. C++ does not need iso646.h I believe.
(more)
over 3 years ago
Edit Post #282965 Post edited:
over 3 years ago
Suggested Edit Post #282965 Suggested edit:

(more)
helpful over 3 years ago
Edit Post #283138 Initial revision over 3 years ago
Answer A: Guess the language! (Cops' Thread)
C or C++ (gcc) 220 bytes, cracked by Razetime %: %: define cops(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) if(not false and k%:%:f%:%:d%:%:l(& (not true) )) %: main() Try it online! Output: ``` Cops and Robbers ``` Some explanation/de-obfuscation: - `%:` ...
(more)
over 3 years ago
Edit Post #283137 Initial revision over 3 years ago
Answer A: It's Hip to be Square
[C (gcc)], 57 64 bytes x,s;main(){scanf("%d",&x);s=sqrt(x);printf("%d",ss==x);} Try it online!
(more)
over 3 years ago
Comment Post #282482 @#8046 I think the most sensible implementation would be that each community can decide which categories that should use rep or not. Meta being one (perhaps set to no rep by default?), another example is sandbox categories like here on Code Golf.
(more)
over 3 years ago
Comment Post #282477 @#54114 If you post it under Code Review, there doesn't need to be a specific problem to solve. Rather you are expected to post complete & working code. If you are extra curious about for example portability or performance or style etc you can mention it in the question though, as that tells reviewer...
(more)
over 3 years ago
Comment Post #282491 @#53501 Except it is listed as C (clang). And with the new scoreboard system, it bumps away all solutions that _are_ actually C (clang).
(more)
over 3 years ago
Comment Post #282491 @#54114 In this case you should add the function/function-like macro used. Otherwise anyone can just use the "`M` library" from my example for any single challenge.
(more)
over 3 years ago
Comment Post #282239 Couldn't we have Codidact-specific challenges. Recreating the [Mathematics logo](https://codidact.com/community-assets/math/logo-large.png) sounds like fun but tricky challenge.
(more)
over 3 years ago
Comment Post #282482 @Monica Cellio Isn't the issue here rather that the various metas shouldn't count rep of the main site. The posts proposed here would sit on meta. Other than that, I don't have any problem personally with giving a lot of rep to someone who makes the effort to draft up these rules in detail per langua...
(more)
over 3 years ago
Comment Post #282477 There's a lot of issues with the library - most notably you should never define functions inside header files. I'd recommend to post it for Code Review at https://software.codidact.com/categories/44
(more)
over 3 years ago