Skip to main content
Commonmark migration
Source Link

#Perl 5, (33 Bytes+2) = 35

Perl 5, (33 Bytes+2) = 35

A regex-less solution.

map{print$p=$_.$"if$_>=$p||!$p}@F

Test

Note that the @F array is populated because of the -a switch.

$ echo -7 -8 -5 0 -1 4 4 3 5|perl -na -e 'map{print$p=$_.$"if$_>=$p||!$p}@F'
-7 -5 0 4 4 5

#Perl 5, (33 Bytes+2) = 35

A regex-less solution.

map{print$p=$_.$"if$_>=$p||!$p}@F

Test

Note that the @F array is populated because of the -a switch.

$ echo -7 -8 -5 0 -1 4 4 3 5|perl -na -e 'map{print$p=$_.$"if$_>=$p||!$p}@F'
-7 -5 0 4 4 5

Perl 5, (33 Bytes+2) = 35

A regex-less solution.

map{print$p=$_.$"if$_>=$p||!$p}@F

Test

Note that the @F array is populated because of the -a switch.

$ echo -7 -8 -5 0 -1 4 4 3 5|perl -na -e 'map{print$p=$_.$"if$_>=$p||!$p}@F'
-7 -5 0 4 4 5
Post Undeleted by LukStorms
added 22 characters in body
Source Link
LukStorms
  • 1.8k
  • 1
  • 12
  • 11

#Perl 5, (2933 Bytes+2) = 3135

A regex-less solution.

map{print$i=$_print$p=$_.' ',if$_>$i$"if$_>=$p||!$p}@F

Test

Note that the @F array is filled because the -a switch is used.Note that the @F array is populated because of the -a switch.

$ echo 1-7 2-8 -5 40 3-1 74 4 |perl3 5|perl -na -e 'map{print$i=$_print$p=$_.' ',if$_>$i$"if$_>=$p||!$p}@F'
1 2-7 -5 70 4 4 5

#Perl 5, (29 Bytes+2) = 31

A regex-less solution.

map{print$i=$_.' ',if$_>$i}@F

Test

Note that the @F array is filled because the -a switch is used.

$ echo 1 2 5 4 3 7  |perl -na -e 'map{print$i=$_.' ',if$_>$i}@F'
1 2 5 7

#Perl 5, (33 Bytes+2) = 35

A regex-less solution.

map{print$p=$_.$"if$_>=$p||!$p}@F

Test

Note that the @F array is populated because of the -a switch.

$ echo -7 -8 -5 0 -1 4 4 3 5|perl -na -e 'map{print$p=$_.$"if$_>=$p||!$p}@F'
-7 -5 0 4 4 5
Post Deleted by LukStorms
Source Link
LukStorms
  • 1.8k
  • 1
  • 12
  • 11

#Perl 5, (29 Bytes+2) = 31

A regex-less solution.

map{print$i=$_.' ',if$_>$i}@F

Test

Note that the @F array is filled because the -a switch is used.

$ echo 1 2 5 4 3 7  |perl -na -e 'map{print$i=$_.' ',if$_>$i}@F'
1 2 5 7