Being new to Python, I’m having a heck of a time figuring out what these two lines do:
for i in [j for j in xrange(0, N) if [k for k in xrange(j) if now[k] == now[j]] == []]:
for j in [k for k in xrange(1, K + 1) if [l for l in xrange(i) if now[l] == k] == []]:
Is there a way to rewrite this so noobs like myself could understand it? Thanks.
I’m almost positive that this code is equivalent to:
or (which would be a bit less efficient, but nicely reflects the idea behind the code):
BUT it’s written in a convulted, inefficient way (especially the
[...] == []is nasty and pointless). Maybe by someone who feels pretty clever using complex structures where simple ones would be much better suited.