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
71%
+3 −0
Challenges Abbreviate everything

Python 3, 142 bytes def f(s): m=1;r="" for c in s.upper(): if'@'<c<'['or'-'==c:r+=c*m;m=0 if c in":; ":r+=c*(c!=' ');m=1 if c in".?!":r+=' ';m=1 return r Try it online!

posted 5y ago by celtschk‭

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

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

Answer
71%
+3 −0
Sandbox Generate Lewis Caroll's Jabberwocky [FINALIZED]

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

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

71%
+3 −0
Sandbox Run-length encode a byte sequence [FINALIZED]

Run-length encoding is a simple compression technique which compresses sequences of repeating identical bytes. The encoding rules for this task are as follows: Any sequence of $n$ identical bytes...

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

66%
+2 −0
Q&A Ways to make a cooperative King of the Hill contest

What about the following rule: You get points, but your score is not your own points, but the points of the best player below you, or 0 if you are the worst player. Obviously if you are the worst ...

posted 11mo ago by celtschk‭

Answer
66%
+2 −0
Meta Category migration and the sandbox

Some additional cosiderations on using the sandbox: First, a migration mechanism might encourage good behaviour, for example by migration being only possible if the post has a minimal score, and/o...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges Display a Progress Bar

Python 3, 48 bytes def f(n,d):return f"[{(50*n+d//2)//d*'|':-<50}]" Try it online!

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Q&A Advice for hosting a language agnostic King of the Hill contest

Contestants should read from standard input and write to standard output. This is because almost all programming languages, including most esoteric programming languages, allow reading from standar...

posted 2y ago by celtschk‭

Answer
66%
+2 −0
Challenges How many odd digits?

C (gcc), 37 bytes This takes an integer as input. It uses the fact that the last digit is odd if and only if the number is odd, and that integer division by 10 removes the last digit. Testing if ...

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

Answer
66%
+2 −0
Challenges The 50 substrings that validate any string of Roman numerals

Bash, 205 bytes for s in C{C{CC,D,M},DC,MC} {CM,DC,D}{D,M} I{C,D,I{II,V,X},L,M,VI,X{C,I,L,V,X}} L{C,D,L,M,XC,XL} MMMM V{C,D,IV,IX,L,M,V,X} X{C{C,D,L,M,X},D,LX,M,X{C,L,XX}} do echo $1|grep -q $s...

posted 2y ago by celtschk‭

Answer
66%
+2 −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 5y ago by celtschk‭  ·  edited 4y 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 5y ago by celtschk‭

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

Rule 110 is a Turing complete cellular automaton. It is defined as follows: Take as initial value a sequence of symbols that's infinite to both sides, which consists only of two different symbols ...

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

Answer
66%
+2 −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 5y ago by celtschk‭  ·  edited 5y ago by celtschk‭

Answer
66%
+2 −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 5y 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 5y ago by celtschk‭  ·  edited 5y 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 5y ago by celtschk‭

Answer
66%
+2 −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 5y 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 5y ago by celtschk‭  ·  edited 5y ago by celtschk‭

Answer
66%
+2 −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 5y ago by celtschk‭  ·  edited 5y ago by General Sebast1an‭

Answer