Skip to main content
Commonmark migration
Source Link

#Perl, 27 +3 = 30 bytes

Perl, 27 +3 = 30 bytes

Run with -F. Older versions of Perl might require you to run with -nF instead, if -F does not imply -n.

grep$;+=$_**$#F,@F;say$_==$

Prints 1 if narcissistic, prints nothing otherwise.

(thanks to @Dada for byte-count correction, and for -2 bytes)

#Perl, 27 +3 = 30 bytes

Run with -F. Older versions of Perl might require you to run with -nF instead, if -F does not imply -n.

grep$;+=$_**$#F,@F;say$_==$

Prints 1 if narcissistic, prints nothing otherwise.

(thanks to @Dada for byte-count correction, and for -2 bytes)

Perl, 27 +3 = 30 bytes

Run with -F. Older versions of Perl might require you to run with -nF instead, if -F does not imply -n.

grep$;+=$_**$#F,@F;say$_==$

Prints 1 if narcissistic, prints nothing otherwise.

(thanks to @Dada for byte-count correction, and for -2 bytes)

-2 bytes and byte-count correction
Source Link
Gabriel Benamy
  • 2.9k
  • 12
  • 16

#Perl, 29 +227 +3 = 3130 bytes

Run with -F. Older versionversions of Perl might require you to run with -nF instead, if -F does not imply -n.

grep{$a+=$_**$#F}@F;say$a==$_grep$;+=$_**$#F,@F;say$_==$

Prints 1 if narcissistic, prints nothing otherwise.

(thanks to @Dada for byte-count correction, and for -2 bytes)

#Perl, 29 +2 = 31 bytes

Run with -F. Older version of Perl might require you to run with -nF instead, if -F does not imply -n.

grep{$a+=$_**$#F}@F;say$a==$_

Prints 1 if narcissistic, prints nothing otherwise.

#Perl, 27 +3 = 30 bytes

Run with -F. Older versions of Perl might require you to run with -nF instead, if -F does not imply -n.

grep$;+=$_**$#F,@F;say$_==$

Prints 1 if narcissistic, prints nothing otherwise.

(thanks to @Dada for byte-count correction, and for -2 bytes)

Source Link
Gabriel Benamy
  • 2.9k
  • 12
  • 16

#Perl, 29 +2 = 31 bytes

Run with -F. Older version of Perl might require you to run with -nF instead, if -F does not imply -n.

grep{$a+=$_**$#F}@F;say$a==$_

Prints 1 if narcissistic, prints nothing otherwise.