Posts by celtschk
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...
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...
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!
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!
Python 3, 59 bytes lambda n,m:sum(choices(range(m),k=n))+n from random import* Try it online!
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...
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,...
Looping counter Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. ...
SOS, 76 bytes +>+>?<+>?<+>?<+>?<+>?<+>?<+>?<+>?<<)<<-(>{>!<{>!<{>!<{>!<{>!<{>!<{>!<{>!&l...
SOS, 155 Bytes !+!-!!+!-!!!!+!!-!!+!-!+!-!+!!-!+!!-!!!+!!-!+!!-!!!+!!-!+!!!!-!!+!-!+!!-!!!!+!-!!!!!!+!-!+!-!+!!!-!+!!-!+!!!!-!+!!!-!!+!-!!+!!-!+!!-!!!+!!-!!+!-!!+!-!!!!+! Explanation: Each ! o...
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your...
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!
C (gcc), 133 131 bytes f(p,s){char*t="Hole in one\0Albatross\0Eagle\0Birdie\0Par\0Bogey\0Double bogey\0Triple bogey";for(--s?s+=5-p:0;s-=!*t++;);puts(t);} Saved two bytes thanks to m90 in the...
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)...
A while ago I wrote an answer in C (gcc) to the FizzBuzz challenge. Now I've found a shorter solution for the same compiler, which however uses a completely different strategy. Now I wonder if I s...
[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 symbol...
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...
Python 3, 106 91 bytes Saved 15 bytes thanks to Moshi in the comments lambda a,b,c:[p for p in"+ - * // % **".split()if(p in'+-**'or b)and eval(f"{a}{p}{b}")==c] Try it online!
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...
As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, mo...