Posts by Lundin
C (gcc), 42 bytes c;f(i){c++<8&&(printf("%d",i&1),f(i>>1));} Try it online! Binary output version.
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...
If restricting everyone to the same system, then can force every contestant to use https://tio.run and the on-site bench-marking found below "debug" -> "real time" as efficiency metric. Example....
^ That can be used. You can try to contact the person who posted the challenge and have them mark the answer as "React -> Invalid". Or otherwise it seems that anyone can mark an answer as inva...
C (gcc), 36 bytes f(int*p){for(;*p;putchar(32|*p++));} Try it online! Similar solutions: 36 bytes too but with new lines: f(int*p){for(;*p;*p|=32,puts(p++));} 37 bytes using recursion:...
C (gcc), 152 bytes r;e(c){r=c=='j'?5:strchr("bdfghklpqy",c)?4:c=='i'?3:c=='t'?2:1;}c;s;f(char*i,char*o){s?(e(*i),c=r,e(*o)):(qsort(i,strlen(i),s=1,f),puts(i));return r-c;} Try it online! Out...
C (gcc), 45, 42 bytes t[9999];f(s,a)int*a;{for(;s;)t[a[--s]]++;} Try it online! Assumptions: Passing the array size to a function can be used as a means to deal with empty arrays (not s...
Function parameters should not be allowed to be used in place of a return value. Reasons: Terms like return value and function result are explicitly specified as a specific, formal language i...
C (gcc), 358 bytes static inline _Noreturn float f(union u);extern _Thread_local _Complex long double*restrict B;main(void){_Atomic register enum {A};typedef _Alignas(unsigned char)struct S;_Sta...
C (gcc), 48 43 bytes s;r(n,m){s+=rand()%m+1;return--n?r(n,m):s;} Try it online! Previous 48 bytes version using loop: i,s;r(n,m){for(;i<n;i++)s+=rand()%m+1;return s;}
C (gcc), 47 bytes i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();} Try it online!
C (gcc), 8 7 unique cos(cos-cos)/(cos(cos-cos)-(-cos(cos-cos))) Try it online! -1 unique character thanks to @orthoplex
Many programming languages have the concept of keywords, special syntax items that are not just identifiers reserved by some library, but words reserved by the language itself. The challenge is to...
The task is to create a program which displays a golf score as text. It takes 2 numbers as input, separated by space or new line: The first number is the par of the specific hole. The second nu...
None of these are applicable at least not for Code Golf challenges. I think this community should "opt out" of reactions unless we can come up with more relevant ones. "Works for me". Answers ...
C (gcc), 147 151 bytes #define L(X)X(+,a+b)X(-,a-b)X(*,a*b)X(/,b&&a/b)X(%,b&&a%b)X(^,pow(a,b)) #define M(o,d)printf("%s",d==c?#o" ":z++==5?".":""); z;s[99];f(a,b,c){L(M)} Tr...
C (gcc), 56 bytes i;f(s,n)char*s,n;{for(;*s;s++)for(i=n;i--;putchar(*s));} Try it online! My attempt at recursion ended up at 61 bytes: o;f(s,n)char*s,n;{for(o=n;*s&&n--;putchar(*...
Well... maybe not in combination with a code golf challenge, but more like an artistic challenge with some theme, similar to screenshot of the month? For reference see for example Outdoors photo co...
Command-line arguments may be used as input instead of stdin Languages/systems that support reading input from command-line arguments may use those as input instead of reading from stdin.
C (gcc), 43 bytes a[99];main(){printf("Hello, %s!",gets(a));} Try it online!
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.