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

Commonmark migration
Source Link

#Cubix , 38 bytes

Cubix , 38 bytes

/..?%?(O;0I:^.<.>;rrw+s;rUO?-<...O0L.@

Try it here

 / . .
 ? % ?
 ( O ;
0 I : ^ . < . > ; r r w
+ s ; r U O ? - < . . .
O 0 L . @ . . . . . . .
 . . .
 . . .
 . . .

0I: - sets up the stack with 0, n, n (s, n, d)
^ - start of the loop )? - decrement d and test for 0. 0 exits loop
%? - mod against n and test. 0 causes ;rrw+s;rU which rotates s to top and adds d, rotates s to bottom and rejoins loop
;< - Cleanup and rejoin the loop.
On exiting loop
;< - Remove d from stack and redirect
-? - Remove n from s and test, 0 LOU@ turns left, outputs and exits, negatives 0O@ push zero, output and exits. positives ;O remove difference and outputs n. The path then goes through to the left turn which redirects to the @ exit

#Cubix , 38 bytes

/..?%?(O;0I:^.<.>;rrw+s;rUO?-<...O0L.@

Try it here

 / . .
 ? % ?
 ( O ;
0 I : ^ . < . > ; r r w
+ s ; r U O ? - < . . .
O 0 L . @ . . . . . . .
 . . .
 . . .
 . . .

0I: - sets up the stack with 0, n, n (s, n, d)
^ - start of the loop )? - decrement d and test for 0. 0 exits loop
%? - mod against n and test. 0 causes ;rrw+s;rU which rotates s to top and adds d, rotates s to bottom and rejoins loop
;< - Cleanup and rejoin the loop.
On exiting loop
;< - Remove d from stack and redirect
-? - Remove n from s and test, 0 LOU@ turns left, outputs and exits, negatives 0O@ push zero, output and exits. positives ;O remove difference and outputs n. The path then goes through to the left turn which redirects to the @ exit

Cubix , 38 bytes

/..?%?(O;0I:^.<.>;rrw+s;rUO?-<...O0L.@

Try it here

 / . .
 ? % ?
 ( O ;
0 I : ^ . < . > ; r r w
+ s ; r U O ? - < . . .
O 0 L . @ . . . . . . .
 . . .
 . . .
 . . .

0I: - sets up the stack with 0, n, n (s, n, d)
^ - start of the loop )? - decrement d and test for 0. 0 exits loop
%? - mod against n and test. 0 causes ;rrw+s;rU which rotates s to top and adds d, rotates s to bottom and rejoins loop
;< - Cleanup and rejoin the loop.
On exiting loop
;< - Remove d from stack and redirect
-? - Remove n from s and test, 0 LOU@ turns left, outputs and exits, negatives 0O@ push zero, output and exits. positives ;O remove difference and outputs n. The path then goes through to the left turn which redirects to the @ exit

Source Link
MickyT
  • 12.3k
  • 2
  • 27
  • 49

#Cubix, 38 bytes

/..?%?(O;0I:^.<.>;rrw+s;rUO?-<...O0L.@

Try it here

 / . .
 ? % ?
 ( O ;
0 I : ^ . < . > ; r r w
+ s ; r U O ? - < . . .
O 0 L . @ . . . . . . .
 . . .
 . . .
 . . .

0I: - sets up the stack with 0, n, n (s, n, d)
^ - start of the loop )? - decrement d and test for 0. 0 exits loop
%? - mod against n and test. 0 causes ;rrw+s;rU which rotates s to top and adds d, rotates s to bottom and rejoins loop
;< - Cleanup and rejoin the loop.
On exiting loop
;< - Remove d from stack and redirect
-? - Remove n from s and test, 0 LOU@ turns left, outputs and exits, negatives 0O@ push zero, output and exits. positives ;O remove difference and outputs n. The path then goes through to the left turn which redirects to the @ exit

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