Posts by General Sebast1an
Forth (gforth), cracked by user, 20 bytes .( Cops and Robbers) Try it online!
There's another type of challenge named code bowling, and I've never heard of it, or even if I did, still don't know how it works. I'm willing to write challenges on code bowling and I want to know...
Python 3, 80 77 75 72 bytes def f(): yield 1;l=[*range(2,236425)] while l:yield l[0];del l[::l[0]] Try it online! Prints out the whole sequence. I did my best to get the biggest number t...
Challenge Write a program that prints its reversed self. For example, if your code is foo() Then it'll output: )(oof Make sure that the quine is a valid one, as defined here: No cheatin...
Combine conditionals Python has its fair share of comparison operators and can actually be used in a single conditional. For example: x == 2 and y == 2 can be: x==y==2 Used on Make $2 + 2 ...
Background Inspired by this challenge that is also a mathematical English translator. Challenge Write a program that translates a mathematical expression using English with the following specifi...
Lua, 32 bytes print(string.reverse(io.read())) Try it online! Noice built-in.
In this challenge, add 2 integers, but if both the integers are 2, output 5. Shortest code in each language wins! Example ungolfed program in Python 3.x def add(x, y): if x == 2 and y == 2: ...
shortC, 40 37 bytes i;f(C*s,In){O;*s;s++)Oi=n;i--;P*s));} Try it online! A shortC conversion of @Lundin's C (gcc) implementation.
shortC, 24 bytes f(C*s){*s&&f(s+1)^P*s);} Try it online! A shortC conversion of @Sisyphus's C (gcc) implementation.
Python 3, 268 250 235 233 210 197 148 bytes def a(n):e=(n>>6).bit_length();f=2**e;l=n&(f-1);N=(n>>e)&31;return((e+(n>31))<<5)+N+(2*l+N%2>f) def b(r):E=r>>5...
Replace range() if $n < 4$ If you're using a for loop, you're probably using range() for the list count. You can actually replace it if the number inside range() is less than 4. Why? Examine th...
Python 3, 53 38 bytes def f(x,y): for c in x:print(end=c*y) Try it online! I'm sure someone will find a lambda solution to this. Golfed 15 bytes thanks to @Moshi's advice.
Assign floats while leaving out zeroes Python allows such strange assignment. You can save bytes by removing the number preceding . if it's only 0: i=.5 print(i) Try it online! The same g...
Renaming functions A funny, cool, and useful trick. If you have to write a single function multiple times (usually range() on for loops), then you can simply assign a variable by the function's na...
Use lambdas instead of functions At most times, lambdas tend to make smaller code, which is helpful in golfing. Assigning a lambda is easy, just do: lambda f:whatever There are many answers th...
import* You can import some libraries and if you find yourself using: from lib import * Remove the space between import and *, because it works for whatever reason.
Replace for loops with string multiplication Let's say we have: for i in range(6):print(end="#") Try it online! This basically outputs # 6 times, which is self-explanatory in the code itsel...
Challenge Make a program that takes input of an integer that's $n > 1$ and print out a staircase using a specific character for stair basing (hashes (#) for demonstration; you can use spaces,...
Python 3, 349 261 160 bytes a="re y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu".split() def f(b):return[j for i in a for j in b if j[:len(i)]==i] T...
Lua, 126 118 bytes p=print for i=1,100 do if i%15==0 then p"FizzBuzz"elseif i%3==0 then p"Fizz"elseif i%5==0 then p"Buzz"else p(i)end end Try it online!
Python 3, 196 195 145 102 91 89 87 79 bytes x=input();x+=x[::-1];i=-1 for c in x[:-1]:print(c*(i>-1)+" "*i+c);i+=1 print(x) Try it online! Golfed 50 bytes thanks to @celtschk's advice. ...
Ruby, 24 21 18 bytes p"Hello, #{gets}!" Try it online! Golfed down 3 bytes thanks to @snail_'s advice. Golfed down 3 bytes thanks to @south's advice.
Lua, 35 32 bytes print("Hello, "..io.read().."!") Try it online! Golfed 3 bytes thanks to @Moshi's advice.