Comments on It's Hip to be Square
Parent
It's Hip to be Square
Challenge
A catalogue type challenge that simply asks: Given an integer n
(where n>=0
) as input return a truthy value if n
is a perfect square or a falsey value if not.
Rules
- You may take input by any reasonable, convenient means.
- You need not handle inputs greater than what your chosen language can natively handle nor which would lead to floating point inaccuracies.
- Output should be one of two consistent truthy/falsey values (e.g.,
true
orfalse
,1
or0
) - truthy if the input is a perfect square, falsey if it's not. - This is code-golf so lowest byte count wins.
Test Cases
Input: 0
Output: true
Input: 1
Output: true
Input: 64
Output: true
Input: 88
Output: false
Input: 2147483647
Output: false
[Python 3], 20 19 bytes …
3y ago
[Ruby], 16 bytes ```ruby - …
3y ago
[APL (Dyalog Extended)], 3 byt …
3y ago
[Haskell], 24 bytes Probabl …
3y ago
[Prolog (SWI)], 42 bytes …
3y ago
Japt, 6 3 bytes Cut in half …
3y ago
[Python 3], 46 bytes Saved …
3y ago
[Husk], 5 bytes ±£Θİ□ …
3y ago
[C (gcc)], 57 64 bytes …
3y ago
Vyxal, 2 bytes ``` ∆² ``` …
3y ago
[C (gcc)], 40 bytes …
3y ago
[PHP], 69 37 bytes …
3y ago
Sclipting, (UTF-16) 8 bytes …
3y ago
[C (clang)], 189 181 176 173 b …
3y ago
C (gcc), 37 bytes ``` C f( …
2y ago
Lua 5.4, 9 bytes ``` lua n …
2y ago
JavaScript (V8), 13 bytes ` …
2y ago
Embed ESCR, 28 characters [ …
2y ago
[dc], 9 bytes ?dvd-^p …
2y ago
J, 6 bytes ```J 0=1|%: `` …
3y ago
0 comment threads