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

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

PHP, 69 37 bytes <?=($y=sqrt($x=fgets(STDIN)))*$y==$x; Try it online! Golfed 32 bytes thanks to @Shaggy's advice.

posted 3y ago by General Sebast1an‭  ·  edited 3y ago by General Sebast1an‭

Answer
#4: Post edited by user avatar General Sebast1an‭ · 2021-09-14T11:37:37Z (over 3 years ago)
  • # [PHP], 69 bytes
  • <!-- language-all: lang-php -->
  • <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}
  • [Try it online!][TIO-ktfq3wel]
  • [PHP]: https://php.net/
  • [TIO-ktfq3wel]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNf@/29mDAA "PHP – Try It Online"
  • # [PHP], <s>69</s> 37 bytes
  • <!-- language-all: lang-php -->
  • <?=($y=sqrt($x=fgets(STDIN)))*$y==$x;
  • [Try it online!][TIO-ktk01a0x]
  • Golfed 32 bytes thanks to [**@Shaggy**](https://codegolf.codidact.com/users/53588)'s [advice](https://codegolf.codidact.com/comments/thread/4491#comment-13584).
  • [PHP]: https://php.net/
  • [TIO-ktk01a0x]: https://tio.run/##K8go@P/fxt5WQ6XStriwqERDpcI2LT21pFgjOMTF009TU1MLKGOrUmH9/78lAA "PHP – Try It Online"
#3: Post edited by user avatar General Sebast1an‭ · 2021-09-11T11:52:02Z (over 3 years ago)
  • # [PHP], <s>69</s> 56 bytes
  • <!-- language-all: lang-php -->
  • <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}
  • [Try it online!][TIO-ktfq3wel]
  • Golfed 13 bytes because it was specified that nothing can be printed on one end of the condition, as long as the other has output. I know, I know. Abuse, hehe.
  • [PHP]: https://php.net/
  • [TIO-ktfq3wel]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNf@/29mDAA "PHP – Try It Online"
  • # [PHP], 69 bytes
  • <!-- language-all: lang-php -->
  • <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}
  • [Try it online!][TIO-ktfq3wel]
  • [PHP]: https://php.net/
  • [TIO-ktfq3wel]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNf@/29mDAA "PHP – Try It Online"
#2: Post edited by user avatar General Sebast1an‭ · 2021-09-11T11:48:34Z (over 3 years ago)
  • # [PHP], 69 bytes
  • <!-- language-all: lang-php -->
  • <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}else{echo 1;}
  • [Try it online!][TIO-ktfhlo4g]
  • [PHP]: https://php.net/
  • [TIO-ktfhlo4g]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNem5hSnQjiG1rX//5sZAwA "PHP – Try It Online"
  • # [PHP], <s>69</s> 56 bytes
  • <!-- language-all: lang-php -->
  • <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}
  • [Try it online!][TIO-ktfq3wel]
  • Golfed 13 bytes because it was specified that nothing can be printed on one end of the condition, as long as the other has output. I know, I know. Abuse, hehe.
  • [PHP]: https://php.net/
  • [TIO-ktfq3wel]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNf@/29mDAA "PHP – Try It Online"
#1: Initial revision by user avatar General Sebast1an‭ · 2021-09-11T07:49:18Z (over 3 years ago)
# [PHP], 69 bytes

<!-- language-all: lang-php -->

    <?php $x=fgets(STDIN);$y=sqrt($x);if($y*$y==$x){echo 0;}else{echo 1;}

[Try it online!][TIO-ktfhlo4g]

[PHP]: https://php.net/
[TIO-ktfhlo4g]: https://tio.run/##K8go@P/fxr4go0BBpcI2LT21pFgjOMTF00/TWqXStriwqERDpULTOjNNQ6VSCyhiC@RVpyZn5CsYWNem5hSnQjiG1rX//5sZAwA "PHP – Try It Online"