Post History
Python 3, 46 bytes Saved 8 bytes thanks to Shaggy! lambda n:[n-i*i or exit(1)for i in range(1+n)] Try it online! Python 3.8 (pre-release), 50 54 52 bytes Fixed a silly mistake thanks to Sh...
Answer
#4: Post edited
- # [Python 3.8 (pre-release)], <s>50</s> <s>54</s> 52 bytes
- Fixed a silly mistake thanks to Shaggy *and* saved 2 bytes!
- <!-- language-all: lang-python -->
- for i in range(1+(x:=int(input()))):x-i*i or exit(1)
- [Try it online!][TIO-ktkpylgb]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-ktkpylgb]: https://tio.run/##K6gsycjPM7YoKPr/Py2/SCFTITNPoSgxLz1Vw1Bbo8LKNjOvRCMzr6C0REMTCKwqdDO1MhWAClMrMks0DDX//zcAAA "Python 3.8 (pre-release) – Try It Online"
- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
- # [Python 3], 46 bytes
- Saved 8 bytes thanks to [Shaggy](https://codegolf.codidact.com/users/53588)!
- <!-- language-all: lang-python -->
- lambda n:[n-i*i or exit(1)for i in range(1+n)]
- [Try it online!][TIO-ktm050z7]
- [Python 3]: https://docs.python.org/3/
- [TIO-ktm050z7]: https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPKjpPN1MrUyG/SCG1IrNEw1AzDcjMVMjMUyhKzEtP1TDUztOM/Z@mYaD5HwA "Python 3 – Try It Online"
- # [Python 3.8 (pre-release)], <s>50</s> <s>54</s> 52 bytes
- Fixed a silly mistake thanks to Shaggy *and* saved 2 bytes!
- <!-- language-all: lang-python -->
- for i in range(1+(x:=int(input()))):x-i*i or exit(1)
- [Try it online!][TIO-ktkpylgb]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-ktkpylgb]: https://tio.run/##K6gsycjPM7YoKPr/Py2/SCFTITNPoSgxLz1Vw1Bbo8LKNjOvRCMzr6C0REMTCKwqdDO1MhWAClMrMks0DDX//zcAAA "Python 3.8 (pre-release) – Try It Online"
- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
#3: Post edited
# [Python 3.8 (pre-release)], <s>50</s> 54 bytesFixed a silly mistake thanks to Shaggy- <!-- language-all: lang-python -->
for i in range(1+(x:=int(input()))):x==i*i and exit(1)[Try it online!][TIO-ktkm64vz]- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
[TIO-ktkm64vz]: https://tio.run/##DcExCoAwDAXQq2RMdbG4SKGHKVjrX9JSIsTTR98br95d9mNM96tPAkFoFmmV48qWMkQZMh7l8EuWMxZQkZOqQTkG9@0D "Python 3.8 (pre-release) – Try It Online"- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
- # [Python 3.8 (pre-release)], <s>50</s> <s>54</s> 52 bytes
- Fixed a silly mistake thanks to Shaggy *and* saved 2 bytes!
- <!-- language-all: lang-python -->
- for i in range(1+(x:=int(input()))):x-i*i or exit(1)
- [Try it online!][TIO-ktkpylgb]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-ktkpylgb]: https://tio.run/##K6gsycjPM7YoKPr/Py2/SCFTITNPoSgxLz1Vw1Bbo8LKNjOvRCMzr6C0REMTCKwqdDO1MhWAClMrMks0DDX//zcAAA "Python 3.8 (pre-release) – Try It Online"
- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
#2: Post edited
# [Python 3.8 (pre-release)], 50 bytes- <!-- language-all: lang-python -->
for i in range(x:=int(input())):x==i*i and exit(1)[Try it online!][TIO-ktfvjovl]- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
[TIO-ktfvjovl]: https://tio.run/##FcMxCoAwDAXQq2RMnFp0kEIPU7DqX9JSItTTR3zw@mt303Xvw/1sg0BQGkWvyjNlqDG0P8YikmbOWEBFD6oTxlHcYwhh@38 "Python 3.8 (pre-release) – Try It Online"- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
- # [Python 3.8 (pre-release)], <s>50</s> 54 bytes
- Fixed a silly mistake thanks to Shaggy
- <!-- language-all: lang-python -->
- for i in range(1+(x:=int(input()))):x==i*i and exit(1)
- [Try it online!][TIO-ktkm64vz]
- [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
- [TIO-ktkm64vz]: https://tio.run/##DcExCoAwDAXQq2RMdbG4SKGHKVjrX9JSIsTTR98br95d9mNM96tPAkFoFmmV48qWMkQZMh7l8EuWMxZQkZOqQTkG9@0D "Python 3.8 (pre-release) – Try It Online"
- Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).
#1: Initial revision
# [Python 3.8 (pre-release)], 50 bytes <!-- language-all: lang-python --> for i in range(x:=int(input())):x==i*i and exit(1) [Try it online!][TIO-ktfvjovl] [Python 3.8 (pre-release)]: https://docs.python.org/3.8/ [TIO-ktfvjovl]: https://tio.run/##FcMxCoAwDAXQq2RMnFp0kEIPU7DqX9JSItTTR3zw@mt303Xvw/1sg0BQGkWvyjNlqDG0P8YikmbOWEBFD6oTxlHcYwhh@38 "Python 3.8 (pre-release) – Try It Online" Here's a stupid solution that outputs using the exit code (1 if it's a perfect square, 0 otherwise).