Skip to main content
added 343 characters in body
Source Link
Xcali
  • 17k
  • 2
  • 17
  • 42

Perl 5, 41 + 1 (-a) = 42 bytes

push@F,shift@F for 1..$r;say"@F";$r=$F[0]

Try it online!

Rotates to the left. Takes the input as lines of space separated integers.

How?

Remove an element from the left end of the list, put it on the right end as many times as we should rotate ($r). Since $r starts at undef (equivaltent to 0 in this usage), nothing happens to the first line. Output the list. Save the first element of the list in $r so we can rotate that many times on the next line.

Perl 5, 41 + 1 (-a) = 42 bytes

push@F,shift@F for 1..$r;say"@F";$r=$F[0]

Try it online!

Rotates to the left. Takes the input as lines of space separated integers

Perl 5, 41 + 1 (-a) = 42 bytes

push@F,shift@F for 1..$r;say"@F";$r=$F[0]

Try it online!

Rotates to the left. Takes the input as lines of space separated integers.

How?

Remove an element from the left end of the list, put it on the right end as many times as we should rotate ($r). Since $r starts at undef (equivaltent to 0 in this usage), nothing happens to the first line. Output the list. Save the first element of the list in $r so we can rotate that many times on the next line.

Source Link
Xcali
  • 17k
  • 2
  • 17
  • 42

Perl 5, 41 + 1 (-a) = 42 bytes

push@F,shift@F for 1..$r;say"@F";$r=$F[0]

Try it online!

Rotates to the left. Takes the input as lines of space separated integers