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‭

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

19 answers  ·  posted 5y ago by celtschk‭  ·  last activity 1y ago by trichoplax‭

Question code-golf tips
66%
+2 −0
Sandbox Convert integer to English [FINALIZED]

Given a non-negative integer up to $999\\,999\\,999$, write it in English. The input number can be in any form other than English (though you'll typically want to use the native integer type of yo...

posted 5y ago by celtschk‭  ·  edited 3y 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 5y 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 5y ago by celtschk‭

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

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

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

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 6y ago by celtschk‭  ·  edited 6y 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 4y ago by celtschk‭  ·  last activity 4y ago by Quintec‭

Question discussion rules
60%
+1 −0
Challenges Borromean coprimes

Python, 89 Bytes import math as m def f(*n):return m.gcd(*n)==1and all(m.gcd(a,b)!=1for a in n for b in n) Note: The outdated Python interpreter at tio.run won't run this code (nor the ungolfe...

posted 1y ago by celtschk‭

Answer
60%
+1 −0
Sandbox Product of polynomials modulo 2 in integer representation

Your task is to implements the product of polynomials modulo 2 $(\mathbb F_2[x]$) in integer representation. Background The field $\mathbb F_2$ represents the integers modulo 2, or equivalently, ...

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

Article code-golf math
60%
+1 −0
Challenges Multiplicative perfection

C (gcc), 53 bytes This uses the shortcut behaviour of logical or (||) to only multiply if it is a divisor; the loop end condition then makes sure it's a proper divisor. i=1;p=1;f(n){for(;i<n...

posted 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 4y ago by celtschk‭  ·  edited 4y ago by celtschk‭

Answer
60%
+1 −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 4y ago by celtschk‭

Answer
60%
+1 −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 4y ago by celtschk‭

Answer
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 4y 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 4y ago by celtschk‭  ·  last activity 4y ago by Razetime‭

Question discussion tags
60%
+1 −0
Challenges "Hello, World!"

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

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

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

Given a string s of text and a line length l, your task is to word-wrap that text to that line length. Concretely, the given string consists of words separated by single spaces, with no leading or...

posted 4y ago by celtschk‭

Article code-golf string
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 5y ago by celtschk‭

Answer
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 5y 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 5y 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 5y ago by celtschk‭  ·  edited 5y 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 5y 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 5y ago by celtschk‭  ·  edited 5y 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 5y 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 5y ago by celtschk‭

Answer