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
Comment Post #279797 I went ahead and proposed a [move post between different categories feature request](https://meta.codidact.com/questions/279815). It would be generally handy to have, I think.
(more)
almost 4 years ago
Comment Post #279797 Great idea. Although... is there a point in archiving old, finalized sandbox posts? Otherwise I believe that the best solution would make it possible for the poster move the post between categories, from sandbox to live challenges.
(more)
almost 4 years ago
Edit Post #279722 Post edited:
almost 4 years ago
Edit Post #279814 Post edited:
Got rid of break
almost 4 years ago
Edit Post #279814 Initial revision almost 4 years ago
Answer A: Prime Difference
C (gcc), 126 129 bytes ```c N=9999;f(n){int p[N],i,j,P;memset(p,1,N);for(i=P=2;ii=n?j=N:(P=i);}e:return P;} ``` Try it online! This is an integer input/output function solution. The upper limit of prime number supported is the square root of`N`, so currently it counts prime numbers up to 9...
(more)
almost 4 years ago
Comment Post #279755 However, chasing down a specific poorly-specified program output to a certain compiler, system + options could perhaps be an interesting and very different challenge. If you write a program that purposely does something bad, resulting in crazy results, then task people to find a system and compiler t...
(more)
almost 4 years ago
Comment Post #279755 A problem with your example is that can only be reproduced with a non-standard compiler for that language. So you would have to specify to what extent non-standard language extensions are allowed and if your program relies on them... which in turn would be a major spoiler. Running `main;` on a confor...
(more)
almost 4 years ago
Comment Post #279759 @Quintec‭ That's a l (L). And yeah the reason that l and 1 look identical on some fonts is the reason why one shouldn't name identifiers like that.
(more)
almost 4 years ago
Comment Post #279754 Isn't it a big problem that the robbers can just "brute force" it with trail & error by trying online compilers until they find a match?
(more)
almost 4 years ago
Comment Post #279759 And yeah `(int){8<88}<<8` can be rewritten as `1<<8` or `u'\xff'+!!u'\xff'` as `u'\xff'+1` but I'm saving the 1 for a rainy day.
(more)
almost 4 years ago
Edit Post #279759 Initial revision almost 4 years ago
Answer A: Output 256 in many different ways
C, 8 solutions Standard C, no extensions. 1 solution snippet per line: ```c "llll"[3]^33^333 4444 5555-555-555-555-555-555-555-555-555-555-55-55-55-55-55-5-5-5-7-7 6666/26 (int){8<88}<<8 u'\xff'+!!u'\xff' 0XFFFFFeFF LINE ``` Somewhat naive solution so far, but the nu...
(more)
almost 4 years ago
Comment Post #279743 If snippets are ok, what about necessary libs to make the snippet run? That is, to access some language features I would strictly speaking have to include/import etc a lib.
(more)
almost 4 years ago
Edit Post #279722 Initial revision almost 4 years ago
Article Integer to Roman numeral
The task is to take a decimal integer as input and print the corresponding Roman numeral with capital letters. The program must handle all positive integer numbers between 1 and 1000. Input can be assumed to be correct and no error handling is necessary. Example data: ``` Input Output 1 ...
(more)
almost 4 years ago
Comment Post #279679 Oh, and `t` actually doesn't have to be char. So with gcc implicit int abuse, this should be possible: `t;f(char*s){s[1]?f(s+1):0;for(t=*s;s[1];*++s=t)*s=s[1];}`.
(more)
about 4 years ago
Comment Post #279679 Also, switching `while` with `for` will save you lots. `for(char t=*s;s[1];*++s=t;)*s=s[1];` should work. So how about this? `f(char*s){s[1]?f(s+1):0;for(char t=*s;s[1];*++s=t)*s=s[1];}`, 59 bytes.
(more)
about 4 years ago
Comment Post #279679 I think this might be a possible improvement: `f(char*s){s[1]?f(s+1):0;while(s[1]){char t=*s;*s=s[1];*++s=t;}}}`. In case s[1] is a character, it makes the recursive call and then while loop. If not, a `0;` dummy statement. `s[1]` is zero in that case so the while loop isn't executed.
(more)
about 4 years ago
Comment Post #279657 `*p=b+strlen(gets(b))` works too but gives identical size.
(more)
about 4 years ago
Edit Post #279657 Post edited:
about 4 years ago
Edit Post #279657 Initial revision about 4 years ago
Answer A: Reverse an ASCII string
C (gcc), 62 bytes main(){char b[99],p=strchr(gets(b),0);for(;p-->b;)putch(p);} This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified. EDIT: Revisited, function-based equivalent of the above (plus I have ...
(more)
about 4 years ago
Comment Post #279639 Max length of input string?
(more)
about 4 years ago
Comment Post #279635 Probably a good idea. If the OP makes an attempt to write the non-golfed version of the challenge, then they'll realize various requirements that need to be addressed.
(more)
about 4 years ago
Comment Post #279601 What's the upper limit to number of items supported and the values themselves? Does it need to cover negative numbers?
(more)
about 4 years ago
Comment Post #279426 How can you say that it relies on non-standard extensions while lecturing me about the standard at the same time? It's either, not both at once.
(more)
about 4 years ago
Comment Post #279415 I think this is kind of cheating since that online compiler declares a main() elsewhere. Otherwise you could improve it to `m(){m();}`, 9 bytes, a recursive call that will eventually stack overflow with seg fault
(more)
about 4 years ago
Comment Post #279383 Nice solution since it's quite straight-forward, +1. I managed 108 bytes with same compiler settings (default gcc) but a much more obscure solution [here](https://codegolf.codidact.com/a/279365/279534).
(more)
about 4 years ago
Answer A: 1, 2, Fizz, 4, Buzz!
C (gcc), 108 bytes ```c h,i;main(){for(;i++<100;){char s[]="%dFizzBuzz ",b=i%5;h=s+2;printf(s+(i%3?b?h=32,0:6:b?h[1]=32,2:2),i);}} ``` Godbolt. Works on clang too. Contains some serious abuse of all that is holy: gcc extensions, misaligned writes, endianess, poorly-defined behavior... New...
(more)
about 4 years ago
Comment Post #279479 Then maybe the Q&A category needs to be "seeded" with some example questions so that people understand what it's for. The current help for categories and FAQ on this site isn't helpful.
(more)
about 4 years ago
Comment Post #279467 Seems to me like the majority of such questions should be asked on meta rather than Q&A. Otherwise this site has main site + 2 layers of meta...
(more)
about 4 years ago
Edit Post #279466 Initial revision about 4 years ago
Answer A: What is the Q&A category for?
I was thinking the same thing. Maybe instead there should be one category for code golf and leave the main Q&A is for other types of challenges and puzzles?
(more)
about 4 years ago
Comment Post #279382 But essentially they are lying just to pose and feel good about themselves. If you post an ill-formed, non-conforming program in "language X", that also relies on non-standard extensions, you are actually not programming in language X but in something else. That gives them an unfair advantage to thos...
(more)
about 4 years ago
Comment Post #279408 default-rules then?
(more)
about 4 years ago
Edit Post #279461 Post edited:
about 4 years ago
Edit Post #279461 Initial revision about 4 years ago
Answer A: Bytes to Segfault
C (compliant), 19 bytes (`gcc -std=c18 -pedantic-errors`) ```c int main(){main();} ``` Godbolt
(more)
about 4 years ago
Comment Post #279408 This sounds reasonable enough, especially if help files can get kept up to date to match community consensus on meta. Maybe "code-golf-rules" or "challenge-rules" are better tag names though? Since standards might be confused with formal language standards.
(more)
about 4 years ago
Comment Post #279426 Apart from using deprecated gcc extensions, this is non-conforming/ill-formed C++ with several constraint violations.
(more)
about 4 years ago
Comment Post #279382 Again, "it generated a binary" is a horrible rationale, particularly in C and C++ languages. [What must a C compiler do when it finds an error?](https://software.codidact.com/q/277340).
(more)
about 4 years ago
Comment Post #279382 @moony So code golf is all about abusing undefined behavior then find some crapiler that will crapile the code into a non-conforming binary in another non-standard language than the one stated?
(more)
about 4 years ago
Comment Post #279382 @Quintec‭ Nope, it's too much spyware for me. Anyway, other users might want to read these comments too.
(more)
about 4 years ago
Comment Post #279382 @dzaima Freestanding mode doesn't mean changing the system or standard lib behavior. It means running programs without the need for an OS, or run a program that is the OS. For this reason, such programs are not called by an OS, but by hardware, such as a power-on reset interrupt vector. This means th...
(more)
about 4 years ago
Comment Post #279382 "UB doesn't matter if the answer works" The very definition of UB is that you can't prove that something isn't UB with "it seems to be working just fine". [What is undefined behavior and how does it work?](https://software.codidact.com/q/277486)
(more)
about 4 years ago
Comment Post #279382 "but won't actually compete with GCC/clang" Sure, just run a freestanding port of gcc, which is not a special compiler option, but one of two modes supported: hosted and freestanding. GCC defaults to hosted on hosted systems, but not necessarily so on freestanding systems. `x(){puts("Hello, World!")...
(more)
about 4 years ago
Comment Post #279382 "it works fine on GCC and clang" No it doesn't, it produces numerous diagnostics on both compilers. See [What must a C compiler do when it finds an error?](https://software.codidact.com/q/277340). What they are executing is not C, but non-standard extensions.
(more)
about 4 years ago
Comment Post #279386 My point is - your lambda won't run as-is, you need to wrap it in some other code not present. How is that different from calling a function not present?
(more)
about 4 years ago
Comment Post #279382 And then C has also since the dawn of time allowed freestanding systems with implementation-defined forms to replace main(). So I just need to find some embedded system's compiler that uses the form `x()` instead of main() and now I will win every competition. I can't do that if programs are to be _s...
(more)
about 4 years ago