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

#05AB1E , (削除) 24 (削除ここまで) 21 bytes

05AB1E , (削除) 24 (削除ここまで) 21 bytes

#05AB1E , (削除) 24 (削除ここまで) 21 bytes

05AB1E , (削除) 24 (削除ここまで) 21 bytes

added 1271 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
FNDÝcεU7ÝRFNNÝcεU7ÝR.ΔmXsÖ])».c

OutputsFirst input is the amount of rows n, second input the power-base d.
Outputs [0,7] instead of the colors, and only outputs a single digit for the bricks (with spaces).

Try it online. Try it online.

TODO: Will add one in a moment.

F # Loop in the range [0, (implicit) input n):
 NN # Push the current loop-index twice
 Ý # Pop the top one, and create a list in the range [0, index]
 c # Calculate the binomial coefficient of the index and this ranged list
 # i.e. 10 choose [0,1,2,3,4,5,6,7,8,9,10]
 # → [1,9,36,84,126,126,84,36,9,1]
 ε # Map each value to:
 U # Pop and store the current value in variable `X`
 7Ý # Push a list in the range [0,7]
 R # Reverse it to make the range [7,0]
 .Δ # Find the first digit which is truthy for:
 m # Take the (implicit) input d to the power of the current digit
 Xs # Push variable `X` and swap the two values
 Ö # Check if `X` is divisible by this digit ** `d`
] # Close the find_first; map; and loop
 ) # Wrap all lists into a list
 » # Join each inner list by spaces, and then each string by newlines
 .c # Centralize the lines by padding leading spaces
 # (after which the result is output implicitly)
FNDÝcεU7ÝR.ΔmXsÖ])».c

Outputs [0,7] instead of the colors, and only outputs a single digit (with spaces).

Try it online.

TODO: Will add one in a moment.

FNNÝcεU7ÝR.ΔmXsÖ])».c

First input is the amount of rows n, second input the power-base d.
Outputs [0,7] instead of the colors, and only outputs a single digit for the bricks (with spaces).

Try it online.

F # Loop in the range [0, (implicit) input n):
 NN # Push the current loop-index twice
 Ý # Pop the top one, and create a list in the range [0, index]
 c # Calculate the binomial coefficient of the index and this ranged list
 # i.e. 10 choose [0,1,2,3,4,5,6,7,8,9,10]
 # → [1,9,36,84,126,126,84,36,9,1]
 ε # Map each value to:
 U # Pop and store the current value in variable `X`
 7Ý # Push a list in the range [0,7]
 R # Reverse it to make the range [7,0]
 .Δ # Find the first digit which is truthy for:
 m # Take the (implicit) input d to the power of the current digit
 Xs # Push variable `X` and swap the two values
 Ö # Check if `X` is divisible by this digit ** `d`
] # Close the find_first; map; and loop
 ) # Wrap all lists into a list
 » # Join each inner list by spaces, and then each string by newlines
 .c # Centralize the lines by padding leading spaces
 # (after which the result is output implicitly)
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#05AB1E, (削除) 24 (削除ここまで) 21 bytes

FNDÝcεU7ÝR.ΔmXsÖ])».c

Outputs [0,7] instead of the colors, and only outputs a single digit (with spaces).

Try it online.

Explanation:

TODO: Will add one in a moment.

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