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).
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).
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).
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)