wrymug
  • Member for 4 years, 6 months
  • Last seen more than a month ago
  • Canada
55 answers
19 votes
3k views
The redundant boolean
11 votes

Python 3, 33 25 18 15 bytes Thanks @jurjen-bos for the __mod__ tip. '%.32d'.__mod__ Try it online!

View answer
36 answers
29 votes
6k views
Fibtraction - Fibonacci but with subtraction
10 votes

Javascript, 24 bytes f=n=>n<3?n:f(n-2)-f(n-1) f=n=>n<3?n:f(n-2)-f(n-1) for (let i = 1; i <= 20; i++) { console.log(f(i)) }

View answer
81 answers
63 votes
7k views
Is the number binary-heavy?
7 votes

Python 3,  44  (thanks @c-mcavoy) 40 bytes lambda n:bin(n).count('0')<len(bin(n))/2 Try it online!

View answer
8 answers
7 votes
796 views
Is the writer a man or woman?
5 votes

Python 3, 320 317 307 286 253 189 bytes h=S=0 for v in input().split():V=sum(map(v.count,'aeiouAEIOU'));C=sum(x.isalpha()for x in v);H=V<.4*C;C-=V;K=[1.5*V/(C+1),C/(1.5*V+1)][H];h+=K*H;S+=K-K*H ...

View answer
5 answers
7 votes
283 views
Abbreviate list of names until they fit
3 votes

Python 3, 102 bytes def f(l,n,g): while len(g.join(l))>n:i=l.index(max(l,key=len));l[i]=l[i][:-2]+'…' return g.join(l) Try it online! Alternatively if you want to see the result being ...

View answer
24 answers
22 votes
4k views
Fractal Cathedral
2 votes

Python 2, 120 118 107 bytes thanks @luismendo, @officialaimm, @halvard-hummel def f(l): for a in range(1,l+1):print(bin(a)[2:]+bin(a)[-2:1:-1]).replace(*'0 ').center(len(bin(l+1))*2-4) Try it ...

View answer
72 answers
40 votes
5k views
Am I divisible by double the sum of my digits?
2 votes

Python 3, 35 bytes lambda a:a%(sum(map(int,str(a)))*2)

View answer
151 answers
145 votes
21k views
I double the source, you double the output!
1 votes

Python 3, 74 67 57 bytes Quick and dirty... Output via text file is allowed per meta. try:f+=[2] except:f=[2] open('o','w').write(str(sum(f)))

View answer
3 answers
2 votes
262 views
Is this any number?
1 votes

Python 3, 290 136 105 bytes Python port of @dzaima's answer. All credit to @dzaima for the regex :) lambda s:re.match('^(-?\d+((\.\d+|)(L|e-?\d+(\.\d+|)|\+\d+(\.\d+|)j|)|)|[A-F\d]+|[a-f\d]+)$',s) ...

View answer
23 answers
15 votes
1k views
Have I had lunch yet?
1 votes

Python 3, 104 bytes from datetime import* n=datetime.now();print(n>=n.replace(hour=[0,n.month+12][n.month<12],minute=n.day)) Try it online! All datetime tests. I replaced Feb 29th with Feb ...

View answer
15 answers
10 votes
387 views
Create a shifter
0 votes

Python 3, 73 bytes f=lambda s,i:(f(s+1,i[1:]+i[-1])if s<0else f(s-1,i[0]+i[:-1]))if s else i Try it online!

View answer
13 answers
65 votes
4k views
Operator precedence: How wrong can I be?
0 votes

Python 3, 284 bytes Edit: seems like something's wrong with evaluating the last example. I'll look into it tomorrow. Another Python answer. Couldn't outgolf everyone else, but I spent too long on ...

View answer
23 answers
26 votes
3k views
Is it a weak prime?
0 votes

Python 3, 149 bytes f=lambda n,k=1,P=1:n*[0]and P%k*[k]+f(n-P%k,k+1,P*k*k) def a(n):p=f(n);return p.index(n)in filter(lambda i:p[i]-p[i-1]<p[i+1]-p[i],range(1,len(p)-1)) Try it online! I'm using ...

View answer
62 answers
50 votes
10k views
Am I a Fibonacci Number?
0 votes

Python 3, 59 Bytes f=5*int(input())**2 print(not((f+4)**0.5%1and(f-4)**0.5%1))

View answer