Skip to main content
Very ugly way to save 1 byte
Source Link
Ton Hospel
  • 14.9k
  • 1
  • 22
  • 45

Perl, 3838 37 bytes

Includes +1 for -pa

Give input on STDIN:

perl -M5.010 maxmin.pl <<< "3451 29820 2983 1223 1337"

maxmin.pl:

#!/usr/bin/perl -a
\$G[99-y///c][$_]for@F;say$#{$G[-1]}

Uses memory linear in the largest number, so don't try this on too large numbers. A solution without that flaw is 38 bytes:

#!/usr/bin/perl -p
$.++until$\=(sort/\b\S{$.}\b/g)[-1]}{

This isAll of these are very awkward and doesn'tdon't feel optimal at all...

Perl, 38 bytes

Includes +1 for -p

Give input on STDIN:

maxmin.pl <<< "3451 29820 2983 1223 1337"

maxmin.pl:

#!/usr/bin/perl -p
$.++until$\=(sort/\b\S{$.}\b/g)[-1]}{

This is very awkward and doesn't feel optimal at all...

Perl, 38 37 bytes

Includes +1 for -a

Give input on STDIN:

perl -M5.010 maxmin.pl <<< "3451 29820 2983 1223 1337"

maxmin.pl:

#!/usr/bin/perl -a
\$G[99-y///c][$_]for@F;say$#{$G[-1]}

Uses memory linear in the largest number, so don't try this on too large numbers. A solution without that flaw is 38 bytes:

#!/usr/bin/perl -p
$.++until$\=(sort/\b\S{$.}\b/g)[-1]}{

All of these are very awkward and don't feel optimal at all...

Source Link
Ton Hospel
  • 14.9k
  • 1
  • 22
  • 45

Perl, 38 bytes

Includes +1 for -p

Give input on STDIN:

maxmin.pl <<< "3451 29820 2983 1223 1337"

maxmin.pl:

#!/usr/bin/perl -p
$.++until$\=(sort/\b\S{$.}\b/g)[-1]}{

This is very awkward and doesn't feel optimal at all...