Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges It's Hip to be Square

Lua 5.4, 9 bytes n^.5%1==0 Try it online! The entire compressed code is 33 bytes: function f(n)return n^.5%1==0 end Try it here. It's not clear whether the rules allow the first form (i...

posted 2y ago by Zakk‭

Answer
#1: Initial revision by user avatar Zakk‭ · 2022-04-28T09:09:28Z (almost 2 years ago)
# [Lua 5.4](https://www.lua.org/versions.html#5.4), 9 bytes

``` lua
n^.5%1==0
```

[Try it online!](https://tio.run/##bY0xCgIxEEVrc4ppJBlYQ1JY5gqyJxCW3YwEZKKzk867x6DY@cv/eP/f29Kp8aqlMpBjBMnahDtf/fkYUwo982bMQwqrsxc7gX3BnIXyqrA/2yLZ4g@f/mZwQ1WgQII4QQwBtmoOX6d8Bq33Wncdzc2RK4hoxm1/Aw)

----

The entire compressed code is 33 bytes:

``` lua
function f(n)return n^.5%1==0 end
```

[Try it here.](https://tio.run/##bY1BDsIgFETXcorZGCBpCSxccgXjCUyaFgyJ@ejvZ@fdsVaXznJe3sy9Tb3nRrOUSsiGLCdpTKCrOx1DjB6Jlv7gQmL0WQ/QL1wS5zQL1mebOGmrfnj8m42rXBkFEWFA8B5LVYevU/ZB7ZzUVbbmZrIp1lr1eX0D)

It's not clear whether the rules allow the first form (i.e. only the relevant expression) or the second form (i.e. the entire piece of code that does the check). I see some use the former, some use the latter.