vaultah
  • Member for 6 years, 4 months
  • Last seen this week
Full Width Text
26 votes

Python 3.5, 18 bytes print(*input(),'') This works because print's default separator is single space.

View answer
Orthogonal Orientation
12 votes

Python 3, 64 51 48 bytes Saved 6 bytes thanks to xnor. Saved 7 bytes thanks to Lynn. Saved 3 bytes thanks to DSM and Morgan from sopython. lambda c,s:'\n'[c<'?':].join(s[::1|-(c in'<^')]) The ...

View answer
Stack Overflowing
10 votes

C++14 (lambda function), 196 Saved 1 byte thanks to Quentin. Saved 2 bytes thanks to Adam Martin. #include<iostream> using namespace std;[](int h,int n){auto s=" \\|/( ) (-) (-)-"s;...

View answer
Reverse Array Sum
9 votes

Python 2, 32 bytes lambda l:map(sum,zip(l,l[::-1])) Alternative solution without zip (35 bytes): lambda l:map(int.__add__,l,l[::-1]) Try it online!

View answer
Draw an ASCII house
8 votes

Python 3.6 (pre-release), 221 210 203 bytes x,y=eval(input()) w=8*x+1;p='-'*w+'\n' for v in['*',*[f'/{" "*i}\\'for i in range(1,w-1,2)],p+p.join([''.join(f'{"".join([f"|{(a*3)[...

View answer
Big code... for you!
6 votes

C++11 (GCC), 298 293 bytes #include<sstream> [](int i){std::stringstream b("It would be extremely painful... for you!"),c("If I pull that off will you die? You're a big guy.");std::string s,w;...

View answer
Expand a C array
6 votes

Python 3.6 (pre-release), 133 m,p=str.split,print;y,u=m(input(),'[');t,n=m(y);i=m(u[5:-2],', ') l=len(i);p(t,n+f'[{l}];') for x in range(l):p(n+f'[{x}] = {i[x]};') Makes heavy use of f-strings. ...

View answer
Shifty Eyes Shifting I's
6 votes

Python, 142 141 134 122 121 bytes Saved 19 bytes thanks to xnor. def f(l,I=0,i=1): for a,_,b in l.split():I-=[I>0,-(i!=I+1)][a>'='];i-=[i!=I+1,-1][b>'='] return'.'*I+'I'+'.'*(i+~I)+'i'...

View answer
Decode the hidden message!
5 votes

Python 3, 98 lambda l:''.join(x*('='!=x[1:-1])for x in l).translate({'='!=x[1:-1]or ord(x[0]):x[2:]for x in l}) This lambda function receives a list of strings (input) and returns a string (the ...

View answer
I only pay with dollars
5 votes

Python 3.6 (pre-release), 87 lambda s:f"${int(s.translate({46:'',44:''})[1:])*[110,15,0,137][ord(s[0])%4]/1e4:,.2f}" Uses f-strings to evaluate the result and format it. s.translate({46:'',...

View answer
Exit code string output
4 votes

Python 3, 77 bytes p='exit(0)' for c in input()[::-1]:p='print(%r);exit(ord(%r))'%(p,c) print(p) This code takes input from STDIN and outputs the first program to STDOUT. If the input is ABCDE, the ...

View answer
Parse a 1D language
Accepted answer
3 votes

Python 3.6 (pre-release), 199 Saved 6 bytes thanks to Morgan Thrapp import re def f(s):s=s.strip('()');i,j=[m.start()if m else-1for m in(re.search(c+'(?![^(]*\))',s)for c in'21')];return i>0and f'2(...

View answer
Counting up and down while doubling the increments
2 votes

C++14, 58 bytes [](auto v,int&s){int p=s=0;for(auto x:v)s+=p=x*p<1?x:2*p;} Takes input via the v argument (std::vector, or any iterable container), outputs to the s argument (by reference). ...

View answer
Unscramble those case-(very)-sensitive strings
2 votes

C++11 (GCC), 154 149 bytes #include<algorithm> [](std::string s){int*p,u,l=u=-1;for(auto&c:s)(c|32)-97<26U?p=&(c&32?u:l),~*p?(std::swap(c,s[*p]),*p=-1):*p=&c-&s[0]:0;...

View answer
Array alignment addition
2 votes

Python 2, 119 bytes a=input() i,v,l=0,list(a),len while 1:q=l(v[0])>l(v[1]);print map(sum,zip(*v)[i:]);i=l(v[q]);v[q]+=a[q];1/(i-l(v[q^1])) Takes input from stdin as two tuples separated by comma,...

View answer
Rotate every row and column in a matrix
2 votes

Python 2, 96 bytes def f(m,v): for i,x in enumerate(v):x%=len(m);r=m[i/2];m[i/2]=r[-x:]+r[:-x];m=zip(*m) return m Tests f returns a list of tuples. Each line in the function body is indented ...

View answer
"-rot" transform
1 votes

C++14 (or newer), 81 bytes [](auto&v){for(int i=1,t;++i<v.size();v[i]=t)t=v[i-2],v[i-1]+=v[i];v.pop_back();} A lambda function that modifies the passed std::vector by reference. Tests: https://...

View answer
Columnar Transposition Cipher
1 votes

Python 3.5, 139 def f(a,b):a,s,j=a.lower(),sorted,''.join;a=s({*a},key=a.find);l=len(a);return j(map(j,[*zip(*s(zip(*zip(*[iter(a+[*b+' '*l])]*l))))][1:])) Slightly more readable version: def f(a, b)...

View answer