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

added 7 characters in body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

MATL, 2321 bytes

-8:8|Q"l4Y29YS109Zv"l4Y29YS10:q@*Q(c

Try it online! Try it online!

Explanation:

-8:8|Q9Zv % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q9Zv  --> 1built-in, byteinstead shorterof than-8:8|Q or even 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I have attempted to get rid of the 9YS by doing the circular shift in the indexing, but this increased the byte count (10t:qwX\q@*Q instead of 9YS10:q@*Q). However, some interesting patterns were obtained in the process: Try it online!, Try it online!.

MATL, 23 bytes

-8:8|Q"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-8:8|Q % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q --> 1 byte shorter than 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I have attempted to get rid of the 9YS by doing the circular shift in the indexing, but this increased the byte count (10t:qwX\q@*Q instead of 9YS10:q@*Q). However, some interesting patterns were obtained in the process: Try it online!, Try it online!.

MATL, 21 bytes

-9Zv"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-9Zv % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-9Zv  --> built-in, instead of -8:8|Q or even 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I have attempted to get rid of the 9YS by doing the circular shift in the indexing, but this increased the byte count (10t:qwX\q@*Q instead of 9YS10:q@*Q). However, some interesting patterns were obtained in the process: Try it online!, Try it online!.

added 244 characters in body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

MATL, 23 bytes

-8:8|Q"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-8:8|Q % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q --> 1 byte shorter than 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I'm still exploring if I can dohave attempted to get rid of the whole indexing smarter - e.g., modular9YS by doing the circular shift in the indexing, since bothbut this increased the expressionsbyte count (9YS10t:qwX\q@*Q andinstead of 109YS10:q@*Q are rather bulky). So farHowever, this hasn't reduced my bytecountsome interesting patterns were obtained in the process: Try it online! , Try it online!.

MATL, 23 bytes

-8:8|Q"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-8:8|Q % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q --> 1 byte shorter than 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I'm still exploring if I can do the whole indexing smarter - e.g., modular indexing, since both the expressions 9YS and 10:q@*Q are rather bulky. So far, this hasn't reduced my bytecount.

MATL, 23 bytes

-8:8|Q"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-8:8|Q % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q --> 1 byte shorter than 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I have attempted to get rid of the 9YS by doing the circular shift in the indexing, but this increased the byte count (10t:qwX\q@*Q instead of 9YS10:q@*Q). However, some interesting patterns were obtained in the process: Try it online! , Try it online!.

Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

MATL, 23 bytes

-8:8|Q"l4Y29YS10:q@*Q(c

Try it online!

Explanation:

-8:8|Q % Generates [9 ... 2, 1, 2, ... 9]. 
 " % Iterate over this vector.
 ( % Assignment indexing. Places elements B at positions C in existing vector A.
 l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'.
 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0'
 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @.
 c % Convert to char, because A was numeric.

Golfing done:

-8:8|Q --> 1 byte shorter than 8:PQ9:h|
10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c --> 1 byte shorter than 'x' (char dummy vector A)

I'm still exploring if I can do the whole indexing smarter - e.g., modular indexing, since both the expressions 9YS and 10:q@*Q are rather bulky. So far, this hasn't reduced my bytecount.

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