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 celtschk‭

70 posts
71%
+3 −0
Challenges Length of a Sumac Sequence

C (gcc), 32 bytes f(a,b){return a>0?f(b,a-b)+1:0;} Try it online!

posted 3y ago by celtschk‭

Answer
71%
+3 −0
Meta Thoughts on hiding challenge sections with expandable details tags

I think everything strictly needed to write or judge a solution should never be hidden. If you feel it is too large, think about how to shorten it. Information that is not strictly necessary can b...

posted 1y ago by celtschk‭  ·  edited 1y ago by celtschk‭

Answer
71%
+3 −0
Q&A Tips for golfing in Python

If you print some string s without a newline character at the end, instead of print(s,end="") write print(end=s) to save two bytes. Note that this only works for strings, not for other typ...

posted 2y ago by celtschk‭  ·  edited 2y ago by General Sebast1an‭

Answer
71%
+3 −0
Challenges "Hello, {name}!"

Bash, 20 18 bytes Saved two bytes by removing the quotes; the code works well without them. echo Hello, `cat`! Try it online!

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

Answer
71%
+3 −0
Challenges Multiply two strings

Given two strings, I define their product as follows: If any of the two strings is empty, the product is the empty string. If the second string consists of a single character, the result ...

6 answers  ·  posted 2y ago by celtschk‭  ·  last activity 2y ago by Hakerh400‭

Question code-golf string
71%
+3 −0
Challenges Golf a FRACTRAN interpreter

Python 3, 76 71 bytes Saved 5 bytes thanks to user def f(p,n):l=[n*p//q for(p,q)in p if n%q<1];return f(p,l[0])if l else n Try it online! This code assumes that the fractions are given a...

posted 3y ago by celtschk‭  ·  edited 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges Reverse your quine

Python 3, 69 bytes i="))43,]1-::[i,43,73(%ci(tnirp;%c%s%c=i";print(i%(37,34,i[::-1],34)) Try it online!

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges Given the preorder and the inorder of a tree, output the postorder

C (gcc), 114 bytes f(int n,int*p,int*i,int**o){if(n){int*m=i,k;for(;*m!=*p;++m);k=m-i;f(k,p+1,i,o);f(n-k-1,p+k+1,m+1,o);*(*o)++=*p;}} Try it online! Arguments: n is the length of the arra...

posted 3y ago by celtschk‭  ·  edited 3y ago by celtschk‭

Answer
66%
+2 −0
Q&A Tips for golfing in C

Use pointer arithmetic and \0 with string literals In C, strings are just zero-terminated character arrays, which means you can play tricks with pointer arithmetic. For example, the line char*s=a...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Sandbox Implement Rule 110 [FINALIZED]

posted 2y ago by celtschk‭  ·  edited 11mo ago by trichoplax‭

66%
+2 −0
Challenges Define a mathematical expression in English

C (gcc), 774 bytes #define S strcat(o, #define I(s)if(n)S s);else{S" ");return;} #define B);break;case n,N,s;char*i,o[999],*d[]={"zero ","one ","two ","three ","four ","five ","six ","seven "...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges 99 Shortened Bottles of Beer

C (gcc), 232 bytes f(n,w,p){printf("%i bottle%s of beer%s%s",n,"s"+(n<2)," on the wall"+w,p);}main(i){for(i=99;i;){f(i,0,", ");f(i,12,".\n");printf(i>1?"Take one down and pass it around, "...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Q&A Tips for golfing in Python

Reorder expressions in order to save whitespace Consider the following code: if c=='U':c='X' The space between if and c obviously cannot be removed, as that would merge them to the identifier ...

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

Answer
66%
+2 −0
Challenges Create an Alphabet Diamond

Python 3, 99 bytes r=[*range(26)] a="ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1]) Try it online!

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

Answer
66%
+2 −0
Challenges Are All Elements Equal?

C (gcc), 46 bytes f(int*a){return *a<0|a[1]<0||*a==a[1]&f(a+1);} This takes an array that is terminated by a negative number (which is not part of the list content, just like the te...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges When The Ternary Is Balance

Python 3, 78 bytes def t(n,*l):d="0+-"[n%3];return d*(not l or n*n) if n*n<2 else t((n+1)//3,1)+d Try it online!

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

Answer
66%
+2 −0
Q&A Tips for golfing in Python

If you have any tips for golfing in Python, add them as answers to this post.

18 answers  ·  posted 2y ago by celtschk‭  ·  last activity 2y ago by General Sebast1an‭

Question code-golf tips
66%
+2 −0
Sandbox Multiply two strings [FINALIZED]

posted 2y ago by celtschk‭  ·  edited 11mo ago by trichoplax‭

66%
+2 −0
Sandbox Convert integer to English [FINALIZED]

posted 2y ago by celtschk‭  ·  edited 11mo ago by trichoplax‭

66%
+2 −0
Challenges Output 256 in many different ways

Unlambda, 1 solution Since Unlambda code that does something always contains the backtick character, there cannot be more than one solution. ```.2.5.6i

posted 2y ago by celtschk‭

Answer
62%
+3 −1
Meta Under which condition is a function that takes arguments other than those specified by the challenge by itself a valid solution to a challenge?

On my challenge Looping Counter there are several entries like this which contains a function which needs to be called with the right parameters to give the correct output. In this particular case,...

1 answer  ·  posted 2y ago by celtschk‭  ·  last activity 2y ago by Quintec‭

Question discussion rules
60%
+1 −0
Challenges 1, 2, Fizz, 4, Buzz!

C (gcc), 103 bytes Using a different approach than my previous solution, therefore posting as new answer as suggested here. i;main(){while(i++<100){char s[]="FizzBuzz",*t=s+4*!!(i%3);if(i%5)...

posted 2y ago by celtschk‭

Answer
60%
+1 −0
Challenges Find the IP address class

C (gcc), 64 62 bytes Saved 2 bytes thanks to m90 in the comments. i;f(char*s){i=atoi(s)>>4;return'A'+(i&8?i&4?i&2?i%2+3:2:1:0);} Try it online!

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

Answer
60%
+1 −0
Meta Does Looping Counter qualify as kolmogorov-complexity?

Lundin just suggested in a comment under another question that I tag the challenge Looping Counter as kolmogorov-complexity. Now I'm not sure if it actually qualifies for that tag, for the followi...

1 answer  ·  posted 2y ago by celtschk‭  ·  last activity 2y ago by Razetime‭

Question discussion tags
60%
+1 −0
Challenges Roll n fair dice

Python 3, 59 bytes lambda n,m:sum(choices(range(m),k=n))+n from random import* Try it online!

posted 2y ago by celtschk‭

Answer