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

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

This is a monadic train that expects an index origin of 0 (⎕IO←0). The equivalent non-train function is {≠⌿(⍵⍴2)⊤⍳⍵}.

Explanation:

 ⍳ List of numbers from 0 to (input-1)
 ⍴∘2 (input) copies of 2
 ⊤ Convert all the elements in ⍳ to base 2 to (input) digits
≠⌿ Reduce over the first axis by not-equal

Output is a space-separated list of 0 and 1. Try it here.

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

This is a monadic train that expects an index origin of 0 (⎕IO←0). The equivalent non-train function is {≠⌿(⍵⍴2)⊤⍳⍵}.

Explanation:

 ⍳ List of numbers from 0 to (input-1)
 ⍴∘2 (input) copies of 2
 ⊤ Convert all the elements in ⍳ to base 2 to (input) digits
≠⌿ Reduce over the first axis by not-equal

Output is a space-separated list of 0 and 1. Try it here.

Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

This is a monadic train that expects an index origin of 0 (⎕IO←0). The equivalent non-train function is {≠⌿(⍵⍴2)⊤⍳⍵}.

Explanation:

 ⍳ List of numbers from 0 to (input-1)
 ⍴∘2 (input) copies of 2
 ⊤ Convert all the elements in ⍳ to base 2 to (input) digits
≠⌿ Reduce over the first axis by not-equal

Output is a space-separated list of 0 and 1. Try it here.

Added explanation
Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

Set yourThis is a monadic train that expects an index origin toof 0 before running this(⎕IO←0). Outputs asThe equivalent non-train function is {≠⌿(⍵⍴2)⊤⍳⍵}.

Explanation:

 ⍳ List of numbers from 0 to (input-1)
 ⍴∘2 (input) copies of 2
 ⊤ Convert all the elements in ⍳ to base 2 to (input) digits
≠⌿ Reduce over the first axis by not-equal

Output is a space-separated list of 0 and 1. Try it here.

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

Set your index origin to 0 before running this. Outputs as a space-separated list of 0 and 1.

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

This is a monadic train that expects an index origin of 0 (⎕IO←0). The equivalent non-train function is {≠⌿(⍵⍴2)⊤⍳⍵}.

Explanation:

 ⍳ List of numbers from 0 to (input-1)
 ⍴∘2 (input) copies of 2
 ⊤ Convert all the elements in ⍳ to base 2 to (input) digits
≠⌿ Reduce over the first axis by not-equal

Output is a space-separated list of 0 and 1. Try it here.

added 8 characters in body
Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

##Dyalog APL, 8(削除) 8 (削除ここまで) 7 bytes

≠⌿⍳⊤⍨⍴∘2≠⌿⍴∘2⊤⍳

Set your index origin to 0 before running this. Outputs as a space-separated list of 0 and 1.

##Dyalog APL, 8 bytes

≠⌿⍳⊤⍨⍴∘2

Set your index origin to 0 before running this. Outputs as a space-separated list of 0 and 1.

##Dyalog APL, (削除) 8 (削除ここまで) 7 bytes

≠⌿⍴∘2⊤⍳

Set your index origin to 0 before running this. Outputs as a space-separated list of 0 and 1.

Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127
Loading

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