Timeline for The shortest code to invert bit-wise a binary string
Current License: CC BY-SA 3.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 30, 2015 at 21:27 | history | edited | Bassem | CC BY-SA 3.0 | added print since REPL cannot be assumed. |
| Aug 30, 2015 at 21:25 | comment | added | Bassem | @mbomb007 correct, added. | |
| Aug 30, 2015 at 20:37 | comment | added | mbomb007 | A print statement is required, since a REPL cannot be assumed. | |
| Jun 8, 2014 at 12:09 | comment | added | seequ | That's all I've got regarding this question. You can find more tricks from my other answers (and do check Tips for golfing in Python). :) | |
| S Jun 8, 2014 at 12:05 | history | edited | Bassem | CC BY-SA 3.0 | reduced size |
| Jun 8, 2014 at 12:03 | comment | added | seequ | Fyi, repr(x) for x < maxint is equal to str(x) | |
| Jun 8, 2014 at 12:01 | review | Suggested edits | |||
| S Jun 8, 2014 at 12:05 | |||||
| Jun 8, 2014 at 12:00 | history | edited | Bassem | CC BY-SA 3.0 | reduced size |
| Jun 8, 2014 at 11:53 | comment | added | seequ | Seems like you missed some spaces. Also, backticks can be used to replace repr(). ''.join(`1-int(x)`for x in'') | |
| Jun 8, 2014 at 11:48 | comment | added | seequ | Also, even though it can't be used in this answer, numbers can precede keywords without spaces. print 4if 1else 2 prints 4. | |
| Jun 8, 2014 at 11:46 | history | edited | Bassem | CC BY-SA 3.0 | added 277 characters in body |
| Jun 8, 2014 at 11:45 | comment | added | seequ | For the record: zero is false and nonzero is true. For any kind of sequence (list, string...) the same rule applies, but it's checked from the length of the sequence. Thus '' == False and 'hi' == True | |
| Jun 8, 2014 at 11:43 | comment | added | seequ | Python is my baby, always happy to help. :) | |
| Jun 8, 2014 at 11:42 | comment | added | Bassem | @TheRare Awesome! I'm gonna document all the steps above in the answer, as reference, cheers! | |
| Jun 8, 2014 at 11:40 | comment | added | seequ | Also, you can pass a generator to join (no need for the square brackets) and you don't need spaces around string literals and brackets. | |
| Jun 8, 2014 at 11:38 | comment | added | seequ | Because of that you can change int(not(int(x))) -> 1-int(x) | |
| Jun 8, 2014 at 11:37 | comment | added | seequ | As a truth value that is. int(x) and 1 returns int(x) if it's not zero and otherwise False. | |
| Jun 8, 2014 at 11:36 | history | edited | Bassem | CC BY-SA 3.0 | Reduced to 44 from 50 thanks to a comment from @TheRare |
| Jun 8, 2014 at 10:47 | comment | added | seequ | Ya'know, (int(x) and 1) == int(x) | |
| Jun 8, 2014 at 9:21 | history | edited | user16402 | CC BY-SA 3.0 | fix formatting |
| Jun 8, 2014 at 9:18 | review | First posts | |||
| Jun 8, 2014 at 9:21 | |||||
| Jun 8, 2014 at 9:10 | history | edited | Bassem | CC BY-SA 3.0 | added 3 characters in body |
| Jun 8, 2014 at 9:05 | history | edited | Bassem | CC BY-SA 3.0 | deleted 8 characters in body |
| Jun 8, 2014 at 8:59 | history | answered | Bassem | CC BY-SA 3.0 |