Posts by Lundin
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), 112 bytes Function solution. p,*a;f(char*s,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! Explanati...
C (gcc), 47 bytes i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();} Try it online!
C (gcc), 126 129 bytes N=9999;f(n){int p[N],i,j,P;memset(p,1,N);for(i=P=2;i*i<N;i++)if(p[i]){for(j=i*i;j<N;j+=i)p[j]=0;i-P>=n?j=N:(P=i);}e:return P;} Try it online! This is an integer...
If you actually use the library, sure, I guess. How you are going to get it running on online compilers, I have no idea. It's very uninteresting for others to view some code using a custom library ...
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 inclu...
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), 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...
C (gcc), 30 bytes main(){puts("Hello, World!");} Try it online! This is using GNU C extensions. GNU C allows main() over int main(), ss well as using puts without including stdio.h.
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?
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...
- ← Previous
- 1
- 2
- 3
- Next →