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

Replace n+1 with -~n and n-1 with ~-n For integers, n+1 and ~-n have the same value, as have n-1 and -~n. While the expressions themselves have the same lengths, the replacements often allow to s...

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

Answer
60%
+1 −0
Challenges Digit antitranspose

Python 3, 35 bytes lambda m:list(zip(*m[::-1]))[::-1] Try it online! The format is a list of tuples. The content of the tuples could be any type; in my tests I used single-digit strings bec...

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

Answer
60%
+1 −0
Sandbox Word wrap a string

posted 2y ago by celtschk‭

Article code-golf string
60%
+1 −0
Challenges Truthify an array

Python 3, 75 bytes lambda a:[[i,k]for i in r(l(a))for k in r(l(a[0]))if a[i][k]] r=range;l=len Try it online!

posted 2y ago by celtschk‭

Answer
60%
+1 −0
Challenges "Hello, World!"

Unlambda, 40 bytes `````````````.H.e.l.l.o.,. .W.o.r.l.d.!i Try it online!

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 2y ago by celtschk‭

Answer
60%
+1 −0
Q&A Tips for golfing in Python

Replace if/else expressions by array subscripts Consider the statement a=b if x<y else c You can get rid of the expensive keywords by using the implicit conversion of boolean values to inte...

posted 2y ago by celtschk‭

Answer
60%
+1 −0
Challenges Weave Strings Together

Python 3, 91 90 bytes Saved one byte thanks to Mark Giraffe in the comments lambda l:"".join(["".join(x)for x in zip_longest(*l,fillvalue='')]) from itertools import* Try it online!

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

Answer
60%
+1 −0
Challenges It's Hip to be Square

C (gcc), 40 bytes i;f(n){for(i=1;n>0;n-=i,i+=2);return!n;} Try it online!

posted 2y ago by celtschk‭

Answer
60%
+1 −0
Challenges 1, 2, Fizz, 4, Buzz!

Python 3, 64 62 bytes for i in range(1,101):print("Fizz"*(i%3<1)+"Buzz"*(i%5<1)or i) Try it online! Saved two bytes thanks to Moshi‭ in the comments.

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

Answer
60%
+1 −0
Q&A Tips for golfing in Python

Replace print loops by list unpacking If you want to print elements of a list one per line, the straightforward way to do it is a loop: for i in l:print(i) But this can be shortened using list...

posted 2y ago by celtschk‭

Answer
60%
+1 −0
Challenges A number adder, not a death adder

C (gcc), 87 bytes P1: i;main(){scanf("%d",&i);printf("i;main(){scanf(\"%%d\",&i);printf(\"%%d\",%d+i);}",i);} Try it online! Generated P2 for input 10: i;main(){scanf("%d",&i...

posted 2y ago by celtschk‭

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
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
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
50%
+0 −0
Challenges "Hello, World!"

SOS, 155 Bytes !+!-!!+!-!!!!+!!-!!+!-!+!-!+!!-!+!!-!!!+!!-!+!!-!!!+!!-!+!!!!-!!+!-!+!!-!!!!+!-!!!!!!+!-!+!-!+!!!-!+!!-!+!!!!-!+!!!-!!+!-!!+!!-!+!!-!!!+!!-!!+!-!!+!-!!!!+! Explanation: Each ! o...

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

Answer
50%
+0 −0
Challenges Reverse an ASCII string

SOS, 76 bytes +>+>?<+>?<+>?<+>?<+>?<+>?<+>?<+>?<<)<<-(>{>!<{>!<{>!<{>!<{>!<{>!<{>!<{>!&l...

posted 2y ago by celtschk‭

Answer
50%
+0 −0
Challenges Cumulative Counts

Python 3, 74 bytes def f(a): d={x:0 for x in a};r=[] for x in a:d[x]+=1;r+=[d[x]] return r Try it online!

posted 2y ago by celtschk‭

Answer
50%
+0 −0
Challenges Presumptuous base conversion

C (gcc), 117 bytes b,r;f(char*s){char*p=s;for(;*p;p++)*p-=47+7*(*p>57),b=b<*p?*p:b;if(b<2)return p-s;for(;*s;s++)r*=b,r+=*s-1;return r;} Try it online!

posted 1y ago by celtschk‭

Answer
50%
+0 −0
Challenges Encode with ROT13.5

Bash, 31 bytes tr a-zA-Z0-9 n-za-mN-ZA-M5-90-4 Try it online!

posted 1y ago by celtschk‭

Answer