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 »

Posts by Lundin‭

55 posts
60%
+1 −0
Challenges Reverse the bits in a Byte

C (gcc), 42 bytes c;f(i){c++<8&&(printf("%d",i&1),f(i>>1));} Try it online! Binary output version.

posted 8mo ago by Lundin‭

Answer
60%
+1 −0
Challenges Reverse the bits in a Byte

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...

posted 8mo ago by Lundin‭  ·  edited 8mo ago by Lundin‭

Answer
71%
+3 −0
Q&A Hosting fastest code challenges

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....

posted 11mo ago by Lundin‭

Answer
66%
+2 −0
Meta How should we handle incorrect answers?

^ 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...

posted 1y ago by Lundin‭  ·  edited 1y ago by Moshi‭

Answer
60%
+1 −0
Challenges Lowercase, but not just the letters

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:...

posted 1y ago by Lundin‭

Answer
60%
+1 −0
Challenges Sort letters by height

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...

posted 1y ago by Lundin‭  ·  edited 1y ago by trichoplax‭

Answer
50%
+0 −0
Challenges Make a frequency table (histogram)

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...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
60%
+1 −0
Sandbox Code bowling using unique characters

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

37%
+1 −3
Meta Rules for function submissions

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...

posted 2y ago by Lundin‭

Answer
50%
+0 −0
Challenges Keyword golfing

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...

posted 2y ago by Lundin‭  ·  edited 9mo ago by Lundin‭

Answer
60%
+1 −0
Challenges Roll n fair dice

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;}

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
60%
+1 −0
Challenges Looping counter

C (gcc), 47 bytes i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();} Try it online!

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
75%
+4 −0
Challenges Can you give me half?

C (gcc), 8 7 unique cos(cos-cos)/(cos(cos-cos)-(-cos(cos-cos))) Try it online! -1 unique character thanks to @orthoplex‭

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
80%
+6 −0
Challenges Keyword golfing

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...

6 answers  ·  posted 2y ago by Lundin‭  ·  last activity 9mo ago by H_H‭

Question code-golf
71%
+3 −0
Sandbox Keyword golfing [FINALIZED]

posted 2y ago by Lundin‭  ·  edited 10mo ago by trichoplax‭

80%
+6 −0
Challenges Golf golf challenge

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...

5 answers  ·  posted 2y ago by Lundin‭  ·  last activity 2y ago by radarek‭

Question code-golf
71%
+3 −0
Sandbox Golf golf challenge [FINALIZED]

posted 2y ago by Lundin‭  ·  edited 10mo ago by trichoplax‭

80%
+6 −0
Meta Reactions on Code Golf Codidact

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 ...

posted 2y ago by Lundin‭

Answer
75%
+4 −0
Challenges Operation "Find The Operator"

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...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
60%
+1 −0
Sandbox Bird is the word

posted 2y ago by Lundin‭  ·  edited 1y ago by General Sebast1an‭

66%
+2 −0
Challenges Repeat the characters

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(*...

posted 2y ago by Lundin‭

Answer
80%
+6 −0
Meta Can we have [popularity-contest]s?

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...

posted 2y ago by Lundin‭

Answer
75%
+4 −0
Meta Default Rules: Code Golf I/O

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.

posted 2y ago by Lundin‭

Answer
66%
+2 −0
Challenges "Hello, {name}!"

C (gcc), 43 bytes a[99];main(){printf("Hello, %s!",gets(a));} Try it online!

posted 2y ago by Lundin‭

Answer
77%
+5 −0
Challenges Make $2 + 2 = 5$

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.

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer