Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 3 characters in body
Source Link
Razetime
  • 27.6k
  • 3
  • 31
  • 77

V (vim), 3534 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online! Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input line, enter insert mode
 <C-r>= evaluate the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.

V (vim), 35 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input line, enter insert mode
 <C-r>= evaluate the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.

V (vim), 34 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input line, enter insert mode
 <C-r>= evaluate the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.
added 2 characters in body
Source Link
Razetime
  • 27.6k
  • 3
  • 31
  • 77

V (vim), 35 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input linline, enter insert mode
 <C-r>= evaluteevaluate the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.

V (vim), 35 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input lin, enter insert mode
 <C-r>= evalute the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.

V (vim), 35 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input line, enter insert mode
 <C-r>= evaluate the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.
Source Link
Razetime
  • 27.6k
  • 3
  • 31
  • 77

V (vim), 35 bytes

C<C-r>=sqrt(<C-r>")
<esc>:s/.\+\.0\n/
:s/.\+/1

Try it online!

Returns empty string for a square, 1 for non-square.

Explanation

C<C-r>=sqrt(<C-r>")
C cut the input lin, enter insert mode
 <C-r>= evalute the following math command:
 sqrt( ) square root of
 <C-r>" cut input line in register "
<esc>:s/.\+\.0\n/
<esc> exit insert mode
 :s/.\+\.0\n/ remove instance of <digits>.0 
 this removes a perfect square root.
:s/.\+/1 replace any other non-newline chars left with
 a single 1.

AltStyle によって変換されたページ (->オリジナル) /