Skip to main content
added 626 characters in body
Source Link
Asone Tuhid
  • 2.4k
  • 8
  • 22

Ruby, 3131 25 bytes

$><<p [*DATA][3]?\b;a||=0;a+=1;$><<a/3*2+1;3:1
__END__

This uses Try it online!

Try it online!Try it online!

Try it online!Try it online!Try it online!

Explanation:

\b__END__ which doesn't work everywhereis not part of the code and everything that follows it is returned by the iterator (tio)DATA as lines of text, simply count those lines and check if there are enough of them to switch from 1 to 3.

Ruby, 31 bytes

$><<?\b;a||=0;a+=1;$><<a/3*2+1;

This uses \b which doesn't work everywhere (tio).

Ruby, 31 25 bytes

p [*DATA][3]?3:1
__END__

Try it online!

Try it online!Try it online!

Try it online!Try it online!Try it online!

Explanation:

__END__ is not part of the code and everything that follows it is returned by the iterator DATA as lines of text, simply count those lines and check if there are enough of them to switch from 1 to 3.

Source Link
Asone Tuhid
  • 2.4k
  • 8
  • 22

Ruby, 31 bytes

$><<?\b;a||=0;a+=1;$><<a/3*2+1;

This uses \b which doesn't work everywhere (tio).