Skip to main content
-1 is your friend
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 39 3838 35 bytes

Includes +1 for -p

Give sequence on STDIN:

antsy.pl <<< "2 1 3 0" 

antsy.pl:

#!/usr/bin/perl -p s%\d+%$a[$&]=1;"@a"=~s%\d+%--$a[$&]x"@a"=~/1 /%eg;$_=!/1/%eg;$_++ 

Perl, 39 38 bytes

Includes +1 for -p

Give sequence on STDIN:

antsy.pl <<< "2 1 3 0" 

antsy.pl:

#!/usr/bin/perl -p s%\d+%$a[$&]=1;"@a"=~/1 /%eg;$_=!/1/ 

Perl, 39 38 35 bytes

Includes +1 for -p

Give sequence on STDIN:

antsy.pl <<< "2 1 3 0" 

antsy.pl:

#!/usr/bin/perl -p s%\d+%--$a[$&]x"@a"=~/1 /%eg;$_++ 
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 39 38 bytes

Includes +1 for -p

Give sequence on STDIN:

antsy.pl <<< "2 1 3 0" 

antsy.pl:

#!/usr/bin/perl -p s%\d+%$a[$&]=1;"@a"=~/1 /%eg;$_=!/1/