Posts by Lundin
^ 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), 57 64 bytes x,s;main(){scanf("%d",&x);s=sqrt(x);printf("%d",s*s==x);} Try it online!
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 manual...
C, 534 bytes Strictly conforming program. #include <stdio.h> #include <stdlib.h> #include <string.h> char i=1,**c,**d,*t[30]={"red","yellow","green","brown","scarlet","blac...
C (gcc), 244 bytes main(){for(char*w=" 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 ar...
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...
This has probably been discussed before but I couldn't find any posts about it. I think we should re-make the sandbox category in the following way: Votes in the sandbox category should not c...
C (compliant), 19 bytes (gcc -std=c18 -pedantic-errors) int main(){main();} Godbolt
C (gcc), 41 bytes r;o(char*s){for(;*s;r+=*s++&1);return r;} Try it online! This is under the assumption that in a function solution, input has to be passed as parameter and output throug...
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...
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), 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!
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 obs...
C (gcc), 20 bytes f(a){puts("!"+a%2);} Try it online! Function solution. Prints ! in case of even numbers, otherwise just new line.
For this to work, I think we need to rule out all start-up code (the C runtime) but also the register maps. So I think answers should be a void main (void){ ... } (or equivalent) function solution ...
C (gcc), 153 bytes a,b;f(char*s){for(char*c,*o="idso";*s;s++)for(c=o;*c;c++)*s==*c&&(b=c-o,a+=!b,a-=b==1,b==2?a*=a:0,b==3&&printf("%d%c",a,s[1]?44:10),a==-1|a==256?a=0:0);} Tr...
C (compliant), 106 bytes char r,i,s[80];void f(int n){memset(s,32,79);for(;r<n;puts(s),r++)for(i=0;i++<n*2;s[n-r-1]=47,s[n+r]=92);} Try it online! Standard C compliant function solutio...
C (compliant), 197 198 bytes. Golfed version of the function in the question, using X macros: #define L Y(1000,M)Y(900,CM)Y(500,D)Y(400,CD)Y(100,C)Y(90,XC)Y(50,L)Y(40,XL)Y(10,X)Y(9,IX)Y(5,V)Y(4,I...
- ← Previous
- 1
- 2
- 3
- Next →