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
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
60%
+1 −0
Q&A Tips for golfing in Python

If you have a loop or if, you can save two or more characters (depending on the current indentation level and the number of statements in the body) by putting it right after the colon: For example...

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

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
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
66%
+2 −0
Sandbox Convert integer to English [FINALIZED]

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

75%
+4 −0
Challenges Make my value binary

C (gcc), 35 32 bytes Saved 3 bytes thanks to Lundin f(n){n&&f(n/2);putchar(n&1|48);} This solution exploits that leading zeros, while not required, are also not forbidden by the ...

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

Answer
60%
+1 −0
Challenges Reduce over the range [1..n]

C (gcc), 50 bytes f(int(*o)(i,j),int n){return n-1?o(f(o,n-1),n):1;} Try it online!

posted 2y ago by celtschk‭

Answer
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
60%
+1 −0
Challenges Make $2 + 2 = 5$

C (gcc), 33 31 bytes f(x,y){return x+y+(x==2&y==2);} Try it online! Saved two bytes thanks to Shaggy

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
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
60%
+1 −0
Challenges Evaluate a single variable polynomial equation

C++ (gcc), 61 bytes float f(int n,float*p,float x){return n?*p+x*f(n-1,p+1,x):0;} Try it online!

posted 3y ago by celtschk‭

Answer
66%
+2 −0
Sandbox Multiply two strings [FINALIZED]

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

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
75%
+4 −0
Challenges Generate Lewis Caroll's Jabberwocky

The task is to generate the text of Lewis Caroll's Jabberwocky. The text, quoted from Wikipedia, is as follows (I've replaced a non-ASCII character with ASCII, otherwise it's direct copy&paste...

4 answers  ·  posted 3y ago by celtschk‭  ·  last activity 3y ago by General Sebast1an‭

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
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
71%
+3 −0
Sandbox Run-length encode a byte sequence [FINALIZED]

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

80%
+6 −0
Challenges 1, 2, Fizz, 4, Buzz!

C (gcc), 113 Bytes i;main(){while(i++<100){char*h[]={"%d "," "},**p=h;i%3||(*p++="Fizz%2$s");i%5||(*p="Buzz ");printf(*h,i,h[1]);}} This compiles with several warnings, but no errors. Here'...

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

Answer