Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges The Pell Numbers

APL (Dyalog Classic), 20 18 17 16 bytes ⊢/,+.×⍣⎕⍨∘.+⍨⌽⍳2 Matrix implementation, requires ⎕IO←0. Thanks to @Razetime for the idea, -3 bytes by me Try it online! APL (Dyalog Classic), 19 18 byt...

posted 4y ago by Quintec‭  ·  edited 4y ago by Quintec‭

Answer
#6: Post edited by user avatar Quintec‭ · 2021-02-18T13:40:38Z (almost 4 years ago)
  • # [APL (Dyalog Classic)], <strike>20</strike> <strike>18</strike> 17 bytes
  • ⊢/,+.×⍣⎕⍨∘.+⍨⌽⍳2
  • Matrix implementation, requires `⎕IO←0`. _Thanks to @Razetime for the idea, -3 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=e9S1SF9HW@/w9Ee9ix/1TX3Uu@JR16JHHTP0tEHMnr2PejcbAQA&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], <strike>19</strike> 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], <strike>20</strike> <strike>18</strike> <strike>17</strike> 16 bytes
  • ⊢/,+.×⍣⎕⍨∘.+⍨⌽⍳2
  • Matrix implementation, requires `⎕IO←0`. _Thanks to @Razetime for the idea, -3 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=e9S1SF9HW@/w9Ee9ix/1TX3Uu@JRxww9bRDds/dR72YjAA&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], <strike>19</strike> 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
#5: Post edited by user avatar Quintec‭ · 2021-02-18T13:39:33Z (almost 4 years ago)
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • ⊢/,+.×⍣⎕⍨(∘.+⍨⌽⍳2)
  • Matrix implementation, requires `⎕IO←0`. _Thanks to @Razetime for the idea, -2 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=e9S1SF9HW@/w9Ee9ix/1TX3Uu0LjUccMPW0g41HP3ke9m400AQ&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], <strike>20</strike> <strike>18</strike> 17 bytes
  • ⊢/,+.×⍣⎕⍨⊢∘.+⍨⌽⍳2
  • Matrix implementation, requires `⎕IO←0`. _Thanks to @Razetime for the idea, -3 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=e9S1SF9HW@/w9Ee9ix/1TX3Uu@JR16JHHTP0tEHMnr2PejcbAQA&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], <strike>19</strike> 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
#4: Post edited by user avatar Quintec‭ · 2021-02-18T13:21:18Z (almost 4 years ago)
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • ⊢/,+.×⍣⎕⍨(∘.+⍨⌽⍳2)
  • Matrix implementation _Thanks to @Razetime for the idea, -2 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=AwA&c=M3nU1ayjrXd4@qPexY/6pj7qXWGkYPSod4uRgiEQGgAA&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • ⊢/,+.×⍣⎕⍨(∘.+⍨⌽⍳2)
  • Matrix implementation, requires `⎕IO←0`. _Thanks to @Razetime for the idea, -2 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=e9S1SF9HW@/w9Ee9ix/1TX3Uu0LjUccMPW0g41HP3ke9m400AQ&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
#3: Post edited by user avatar Quintec‭ · 2021-02-17T17:57:31Z (almost 4 years ago)
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • ⊢/,+.×⍣⎕⍨(∘.+⍨⌽⍳2)
  • Matrix implementation _Thanks to @Razetime for the idea, -2 bytes by me_
  • [Try it online!](https://razetime.github.io/APLgolf/?h=AwA&c=M3nU1ayjrXd4@qPexY/6pj7qXWGkYPSod4uRgiEQGgAA&f=AwA&i=S@My4ErjMgRiUwA&r=tio&l=apl-dyalog&m=tradfn&n=f#)
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
#2: Post edited by user avatar Quintec‭ · 2021-02-17T17:43:38Z (almost 4 years ago)
  • # [APL (Dyalog Classic)], 19 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1 1 2}
  • Generic recursive implementation part 2
  • [Try it online!][TIO-kl9kntpy]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 18 bytes
  • <!-- language-all: lang-apl -->
  • {⍵<2:⍵⋄+/∇¨⍵-1,⍳2}
  • Generic recursive implementation part 2
  • _-1 byte thanks to @Razetime_
  • [Try it online!][TIO-kl9q3svq]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9q3svq]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqHOo97NRrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8Pw2kZbOhAQA "APL (Dyalog Classic) – Try It Online"
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}
  • Random fun implementation
  • [Try it online!][TIO-kl9l43hh]
  • # [APL (Dyalog Classic)], 26 bytes
  • <!-- language-all: lang-apl -->
  • {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}
  • Random fun implementation 2
  • [Try it online!][TIO-kl9lfvbo]
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"
  • [APL (Dyalog Classic)]: https://www.dyalog.com/
  • [TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"
#1: Initial revision by user avatar Quintec‭ · 2021-02-17T15:37:34Z (almost 4 years ago)
# [APL (Dyalog Classic)], 19 bytes

<!-- language-all: lang-apl -->

    {⍵<2:⍵⋄+/∇¨⍵-1 1 2}

Generic recursive implementation part 2

[Try it online!][TIO-kl9kntpy]

# [APL (Dyalog Classic)], 26 bytes

<!-- language-all: lang-apl -->

    {×⍵:⌊0.5+(∇⍵-1)÷1-⍨2*÷2⋄1}

Random fun implementation

[Try it online!][TIO-kl9l43hh]

# [APL (Dyalog Classic)], 26 bytes

<!-- language-all: lang-apl -->

    {a←⍳⌈⍵÷2⋄(2*a)+.×⍵!⍨1+2×a}

Random fun implementation 2

[Try it online!][TIO-kl9lfvbo]

[APL (Dyalog Classic)]: https://www.dyalog.com/
[TIO-kl9lfvbo]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qn/6O2CQb/qxOB1KPezY96Oh71bj283ehRd4uGkVaiprbe4elAEcVHvSsMtY0OT0@s/Z8GVtr3qKv5Ue@aR71bDq03ftQ2EWhWcJAzkAzx8Az@n6ZgDAA "APL (Dyalog Classic) – Try It Online"

[APL (Dyalog Classic)]: https://www.dyalog.com/
[TIO-kl9l43hh]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@vD0R71brR71dBnomWprPOpoB3J1DTUPbzfUfdS7wkjr8HajR90thrX/0x61TXjU2/eoq/lR75pHvVsOrTd@1DbxUd/U4CBnIBni4Rn8P03BFAA "APL (Dyalog Classic) – Try It Online"

[APL (Dyalog Classic)]: https://www.dyalog.com/
[TIO-kl9kntpy]: https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVhsjKyD5qLtFW/9RR/uhFUCOrqGCoYJR7f@0R20THvX2PepqftS75lHvlkPrjR@1TXzUNzU4yBlIhnh4Bv9PA@nYbGgAAA "APL (Dyalog Classic) – Try It Online"