Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

-4 bytes: wrap the expression with `$i`,`$j` to a new scope.; added 10 characters in body; edited body
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23

PowerShell, (削除) 62 (削除ここまで) (削除) 71 (削除ここまで) 70(削除) 70 (削除ここまで) 66 bytes

+9 bytes when Test cases with an even number of elements added.

-1 byte with splatting.

-4 bytes: wrap the expression with $i,$j to a new scope.

for($a=$args;$a[1]-2)2;$a=&{$n++;$a=($a|?{++$j%2})+($a|?{$i++%2});rv i,j}){$n++}+$n

Try it online! Try it online!

PowerShell, (削除) 62 (削除ここまで) (削除) 71 (削除ここまで) 70 bytes

+9 bytes when Test cases with an even number of elements added.

-1 byte with splatting.

for($a=$args;$a[1]-2){$n++;$a=($a|?{++$j%2})+($a|?{$i++%2});rv i,j}+$n

Try it online!

PowerShell, (削除) 62 (削除ここまで) (削除) 71 (削除ここまで) (削除) 70 (削除ここまで) 66 bytes

+9 bytes when Test cases with an even number of elements added.

-1 byte with splatting.

-4 bytes: wrap the expression with $i,$j to a new scope.

for($a=$args;$a[1]-2;$a=&{($a|?{++$j%2})+($a|?{$i++%2})}){$n++}+$n

Try it online!

-1 byte with splatting.
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23

PowerShell, 62(削除) 62 (削除ここまで)(削除) 71 (削除ここまで) 70 bytes

param($a)for(;$a[1]-2;$a=$a[($a|%{$j++*2%$a.Count})]){$n++}+$n

Try it online! +9 bytes when Test cases with an even number of elements added.

Less golfed :)-1 byte with splatting.

paramfor($a$a=$args;$a[1]-2)for{$n++;$a=($r=$a|%$a|?{$j++*2%$a.Count++$j%2};$a[1]-2;$a=$a[$r])+($a|?{$n++$i++%2});rv i,j}+$n

Try it online!

PowerShell, 62 bytes

param($a)for(;$a[1]-2;$a=$a[($a|%{$j++*2%$a.Count})]){$n++}+$n

Try it online!

Less golfed :)

param($a)for($r=$a|%{$j++*2%$a.Count};$a[1]-2;$a=$a[$r]){$n++}+$n

PowerShell, (削除) 62 (削除ここまで)(削除) 71 (削除ここまで) 70 bytes

+9 bytes when Test cases with an even number of elements added.

-1 byte with splatting.

for($a=$args;$a[1]-2){$n++;$a=($a|?{++$j%2})+($a|?{$i++%2});rv i,j}+$n

Try it online!

added 91 characters in body
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23

PowerShell, 62 bytes

param($a)for(;$a[1]-2){$n++;$a=$a[2;$a=$a[($a|%{$j++*2%$a.Count})]){$n++}+$n

Try it online! Try it online!

Less golfed :)

param($a)for($r=$a|%{$j++*2%$a.Count};$a[1]-2;$a=$a[$r]){$n++}+$n

PowerShell, 62 bytes

param($a)for(;$a[1]-2){$n++;$a=$a[($a|%{$j++*2%$a.Count})]}+$n

Try it online!

PowerShell, 62 bytes

param($a)for(;$a[1]-2;$a=$a[($a|%{$j++*2%$a.Count})]){$n++}+$n

Try it online!

Less golfed :)

param($a)for($r=$a|%{$j++*2%$a.Count};$a[1]-2;$a=$a[$r]){$n++}+$n
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23
Loading

AltStyle によって変換されたページ (->オリジナル) /