wnnmaw
  • Member for 7 years, 6 months
  • Last seen more than a month ago
Reverse two sections of a string around a pivot
6 votes

Python 2, 37 39 bytes lambda a,b:b.join(a.split(b,1)[::-1]) Where a is the main string and b is the pivot string. Try it online!

View answer
The Art of Word Shaping
5 votes

Python 2, 114 71 bytes Turns out I was re-inventing the wheel, a simple double replace on a multiline string works quite well. The string has the additional benefit of being able to count zeros ...

View answer
Calculate Phi (not Pi)
5 votes

Python, 137 139 n=input() print n,len([b for b in range(len([a for a in range(n)if not all(a%i for i in xrange(2,a))]))if all(b%i for i in xrange(2,b))])

View answer
Build a twisted "Hello world!"
4 votes

Python, 398 414 380 456 bytes* Managed to update so that it is compliant with the rules, but I still hesitate to call this competitive. Since the commented lines are needed for it to run, I've ...

View answer
A most excellent proof, too small to fi—!
Accepted answer
4 votes

Python 2, 334 p=open("f.txt",'r').readlines() r,S,p=p[0][7:],p[2].strip(),p[3:-1] import textwrap as t,itertools as i m,l=max([len(s[:-5].strip()) for s in p]),len(S)-2 P = i.izip_longest([&...

View answer
A Geometrical Challenge
3 votes

Python 2, 157 132 bytes def f(s): S=int(s[1:-1]) for n in([range(1,S+2,2),range(S,0,-2)]['-'in s],[S]*S)['s'in s]: print "{:^{S}}".format('*'*n,S=S) First attempt firgured that the +/- ...

View answer
Stack Exchange Vote Simulator
3 votes

Python 2.7, 79 75 88 s=input() print (0,(1,-1)[s[-1]=='v'])[len(s[s.rfind(('v^','^v')[s[-1]=='v'])+1:])%2!=0]

View answer
May the first be with you
2 votes

Python 2.7, 173 165 bytes 8 bytes saved by quintopia This one got gross: lambda S:`[(t[0],t[0].upper())[t[1]]for t in zip("".join("first".join(s.replace("first","...

View answer
Golf a string twister
2 votes

Python 2, 115 bytes lambda s:'\n'.join("".join(s)for s in zip(*[k[-i%len(k):]+k[:-i%len(k)]for i,k in enumerate(zip(*s.split('\n')))])) Thanks to the wonder of zip managed to get this down ...

View answer
Matching Adjacent Words
2 votes

Python 2, 90 bytes lambda A,B:all(ord(b)-2<ord(a)<ord(b)+2for a,b in zip(sorted(A),sorted(B)))*len(A)==len(B) Simple anonymous function, I have to have a separate check for length because zip ...

View answer
Reverse Array Sum
1 votes

Python 2 + numpy, 31 bytes I think this is kosher based on the rules, but let me know if not. Anonymous function takes a numpy array as input: import numpy lambda l:l+l[::-1] Try it online!

View answer
Fibonacci-style matrix expansion
1 votes

Python, 103 105 bytes f=lambda n,L:f(n-1,[l+[sum(l[-2:])]for l in L])if n else L lambda n,L:zip(*f(n,map(list,zip(*f(n,L))))) Anonymous function takes list of list and passes to recursive function f. ...

View answer
Printing ascending ASCII, Cops
1 votes

Python 2, 76 characters, Cracked by Adnan print __________h______________________v_____________,___)_________)_______) Outputs BKT]f Full Code

View answer