Post History
Python 3.8 (pre-release), 62 bytes f=lambda x,a=[]:f(x[1:],a+[x[0]]if x[0]else a[:-1])if x else a Try it online! -11 bytes thanks to user
Answer
#3: Post edited
# [Python 3.8 (pre-release)], 73 bytes- <!-- language-all: lang-python -->
f=lambda x:0in x and f(x[0]and x[:(i:=x.index(0))-1]+x[i+1:]or x[1:])or x[Try it online!][TIO-kpbj60ok]- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
[TIO-kpbj60ok]: https://tio.run/##bYxBDsIgEEX3noIlpKMZxMZK0pMQFhgkkiglpIvx9EgbdaHmLf7Pf5PJj/k6JTXkUmsYb@5@9o6RxpgYMZc8C5wM2qWR0TzqkXYx@QtxFGIrbUcmdlLbqTTfUiyl5hLTzAM3CG96OFohNh8jYd9W9bX1DVwNwvBzr@CwmtOfTy@aqU8 "Python 3.8 (pre-release) – Try It Online"Alternatively:f=lambda x:0in x and f([x[:(i:=x.index(0))-1]+x[i+1:],x[1:]][x[0]<1])or x
- # [Python 3.8 (pre-release)], 62 bytes
- <!-- language-all: lang-python -->
- f=lambda x,a=[]:f(x[1:],a+[x[0]]if x[0]else a[:-1])if x else a
- [Try it online!][TIO-kpbjmg5n]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-kpbjmg5n]: https://tio.run/##K6gsycjPM7YoKPr/P802JzE3KSVRoUIn0TY61ipNoyLa0CpWJ1E7uiLaIDY2M00BRKfmFKcqJEZb6RrGaoKEFCAC/wuKMvNKNNI0og10YNBUxzxWU5MLLmOoYwQUNUYTMwVCA7CMgY4FhnpjHROwjCUWk6AQKPMfAA "Python 3.8 (pre-release) – Try It Online"
- -11 bytes thanks to user
#2: Post edited
- # [Python 3.8 (pre-release)], 73 bytes
- <!-- language-all: lang-python -->
- f=lambda x:0in x and f(x[0]and x[:(i:=x.index(0))-1]+x[i+1:]or x[1:])or x
- [Try it online!][TIO-kpbj60ok]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
[TIO-kpbj60ok]: https://tio.run/##bYxBDsIgEEX3noIlpKMZxMZK0pMQFhgkkiglpIvx9EgbdaHmLf7Pf5PJj/k6JTXkUmsYb@5@9o6RxpgYMZc8C5wM2qWR0TzqkXYx@QtxFGIrbUcmdlLbqTTfUiyl5hLTzAM3CG96OFohNh8jYd9W9bX1DVwNwvBzr@CwmtOfTy@aqU8 "Python 3.8 (pre-release) – Try It Online"
- # [Python 3.8 (pre-release)], 73 bytes
- <!-- language-all: lang-python -->
- f=lambda x:0in x and f(x[0]and x[:(i:=x.index(0))-1]+x[i+1:]or x[1:])or x
- [Try it online!][TIO-kpbj60ok]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-kpbj60ok]: https://tio.run/##bYxBDsIgEEX3noIlpKMZxMZK0pMQFhgkkiglpIvx9EgbdaHmLf7Pf5PJj/k6JTXkUmsYb@5@9o6RxpgYMZc8C5wM2qWR0TzqkXYx@QtxFGIrbUcmdlLbqTTfUiyl5hLTzAM3CG96OFohNh8jYd9W9bX1DVwNwvBzr@CwmtOfTy@aqU8 "Python 3.8 (pre-release) – Try It Online"
- Alternatively:
- f=lambda x:0in x and f([x[:(i:=x.index(0))-1]+x[i+1:],x[1:]][x[0]<1])or x
#1: Initial revision
# [Python 3.8 (pre-release)], 73 bytes <!-- language-all: lang-python --> f=lambda x:0in x and f(x[0]and x[:(i:=x.index(0))-1]+x[i+1:]or x[1:])or x [Try it online!][TIO-kpbj60ok] [Python 3.8 (pre-release)]: https://docs.python.org/3.8/ [TIO-kpbj60ok]: https://tio.run/##bYxBDsIgEEX3noIlpKMZxMZK0pMQFhgkkiglpIvx9EgbdaHmLf7Pf5PJj/k6JTXkUmsYb@5@9o6RxpgYMZc8C5wM2qWR0TzqkXYx@QtxFGIrbUcmdlLbqTTfUiyl5hLTzAM3CG96OFohNh8jYd9W9bX1DVwNwvBzr@CwmtOfTy@aqU8 "Python 3.8 (pre-release) – Try It Online"