Timeline for Replace me by the sum of my cyclic successors!
Current License: CC BY-SA 4.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 16, 2018 at 22:57 | comment | added | Jonathan Allan |
Firstly the ~ operator is a bitwise not, it's effectively shorthand for -1-v , so -~v is shorthand for -(-1-v) which is just 1+v (but avoids parentheses like (1+v)*a ). Secondly in Python one may multiply a list by an integer to repeat it (e.g. ['a','b']*3 is ['a','b','a','b','a','b'] ). The -~v*a could be replaced by a+v*a for the same byte count. Lastly the [i:i+v] is a slice indexing, keeping elements i to i+v-1 (0-indexed) only.
|
|
Jun 16, 2018 at 22:45 | comment | added | Jonah | not too familiar with python can you explain the part in parens after sum? | |
Jun 16, 2018 at 18:49 | history | answered | Jonathan Allan | CC BY-SA 4.0 |