JBernardo
• Member for 10 years, 6 months
• Last seen this week

A nice way to convert an iterable to list on Python 3: imagine you have some iterable, like i = (1,2,3,4) i = range(4) i = (x**2 for x in range(5)) But you need a list: x=list(i) #the default way ...

P is for Python 2, 30 chars -> Score: 36 I did it, after 8 years I realized there is a shorter way in python 2! print bytearray(range(97,123)) Previous code that was as big as trivial print: print'...

Python, 184 That's why I love spaces. import sys x = sys.stdin.read( ).split() z = x [ 1 : : 4 ] for i , ( j , k ) in enumerate ( sorted ( zip ( [ int(i) ...

Brainf*ck [-]>++++[<+++++++++++++>-]<.----..---------------. And the output will be: 400!

Python, 70 Something crazy I just thought (using comma separated input): from cmath import* x,y=input() print round(tan(polar(y+x*1j)[1]).real) If you accept small float precision errors, the round ...

Python 2, 19 bytes This might be cheating as it can only work on a terminal, since each space added in between "A" is removed with a backspace char. while 1:print'\bA',

Python 3, 79 chars a,b,c=eval(input()) d=(b*b-4*a*c)**.5/2/a x=-b/2/a print('r1=',x+d,'\nr2=',x-d) Python's imaginary unity is j and not i. I used Python 3 because the power operator works also on ...

Python 3, 59 bytes print('rnbqkbnr','p'*8,*['.'*8]*4,'P'*8,'RNBQKBNR',sep='\n') Interesting that with better unpacking and print function, Python 3 can be much better than Python 2 for golf This ...

Python, 134 129 chars def f(x):d=[cmp(*i)for i in zip(x,x[1:])]if x>9 else[0];n=d[0]>0;return all(i<0 for i in d[n::2])&all(i>0 for i in d[n<1::2]) Ungolfed: def f(x): if ...

P is for Python 3, 32 chars -> Score: 38 print('%c'*26%(*range(97,123),)) I'm on fire. This is based in my 2011 answer which is before Python 3.5 added starred tuple unpacking, making it smaller ...

Perl, 110 sub f{$_="$_[0]000";/./;$t=$&;s/(?<=.)[HW]//g;y/A-Z/:123:12_:22455:12623:1_2:2/s;s/(?<=.)\D//g;/.(...)/;$t.$1} I'm using Howard's solution with my translate table (y/A-Z/table/s ...

Python, 274 285 241 235 225 200 190 183 179 174 166 161 - Fixed last clause (H or W as consonant separators). Ashcraft now has the right result. - Made the dict smaller - Formating is smaller (doesn'...

Python, 49 chars import re f=lambda x:'(^(?!%s$).*$)'%re.escape(x) The answer matches anything but the input. It gives an output using conditional groups so is suited for the problem: regular ...

Python 3.8, 32 bytes lambda s:((r:=s[::-1])!=s)+(r<s) Try it online! It is just one byte shorter than other Python 3.x lambda s:(s[::-1]!=s)+(s[::-1]<s)

Python My JAPH in Python class Foo: def __init__(s, t='Just another Python hacker'): def g(): return [100,101,102,32,102, 40,120,41,58,112,114, ...

Python 3 - 181 177 bytes (Ponara'bosti) a='Ku Po Bo Co Vru Fo Sti Kri zla nara qkel lopee enat ham kty cola'.split() *y,x=map(int,input()) u=x>0 v=y>[] print(a[x]+a[x+8]*u**v+"'"*(u&v)+''....

Python, 484 Ok, I did it but was pretty boring... The last sentence is always with "fly" so some chars were removed... f,s,b,c,d=o='fly spider bird cat dog'.split() x='There was an old lady who ...

Python 3, 1369 chars (not bytes) a='...