Wednesday, August 28, 2013

IO Redirection - Swapping stdout and stderr (Advanced)

% (sh myscript.sh 3>&2 2>&1 1>&3) 2>/dev/null
I'm stderr
% (sh myscript.sh 3>&2 2>&1 1>&3) >/dev/null 
I'm stdout

Thursday, August 8, 2013

python 3 line to solve 8 queen

from itertools import *
c = range(8)
print len([v for v in permutations(c) if 8==len(set(v[i]+i for i in c))==len(set(v[i]-i for i in c))])