Yes, provide more details so I don't have to spend twenty minutes figuring out what it does.
(Going by my three-second-look gut feeling: It's the Sieve of Eratosthenes)
Yes, provide more details so I don't have to spend twenty minutes figuring out what it does.
(Going by my three-second-look gut feeling: It's the Sieve of Eratosthenes)
> i for a[::i] in <whatever>
Mind blown. How does assigning to an array even work? I'm guessing this is way-undefined-speak for setting elements, and I am simultaneously dazzled by its brilliance and horrified by its stupidity.
Python 2.5.2 (79560, Nov 26 2010, 14:57:55)
[PyPy 1.4.0] on win32
>>> a = [1, 2 ,3]
>>> for a[:] in [[6, 7, 8]]:
... pass
>>> print(a)
[6, 7, 8] (Going by my three-second-look gut feeling: It's the Sieve of Eratosthenes)
A broken one, this seems like advertising that you hole in one'd a sand trap. list(range(n)) as opposed to range(n)
and why the double indexing of a in i in a[:][2:] if a[i] == i].
Am I missing something ? I think it would work without those.Edit: Yo La Tengo. Deviousness aside the code is quite nice. It would be fun to optimize it but without breaking its spirit.
The [:] you mentioned is indeed redundant, I removed it. Thanks.
a[:][2:] -- maybe the author doesn't know that any slice returns a new list? Maybe he just wants to be even more mysterious?
An alternative to a[:][2:] would just be range(2, n), but the author clearly doesn't want it to be readable.
The author wasn't kidding about it being nasty to read...