#Husk , (削除) 18 (削除ここまで) 16 bytes
Husk , (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2∞0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
First input-argument is a list of lists of coefficients where index encodes exponent, like the third input example in the challenge description. Second argument is the coefficient integer \$k\$.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
#Husk , (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2∞0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
First input-argument is a list of lists of coefficients where index encodes exponent, like the third input example in the challenge description. Second argument is the coefficient integer \$k\$.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
Husk , (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2∞0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
First input-argument is a list of lists of coefficients where index encodes exponent, like the third input example in the challenge description. Second argument is the coefficient integer \$k\$.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
#Husk, (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2*0;02∞0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
AFirst input-argument is a list of lists of coefficients where index encodes exponent, like the third input example in the challenge description. Second argument is the coefficient integer \$k\$.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
#Husk, (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2*0;0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
A list of lists of coefficients where index encodes exponent, like the third input example in the challenge description.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
#Husk, (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2∞0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
First input-argument is a list of lists of coefficients where index encodes exponent, like the third input example in the challenge description. Second argument is the coefficient integer \$k\$.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)
#Husk, (削除) 18 (削除ここまで) 16 bytes
!→0+→G(mΣ∂Ṫ*)2*0;0
First Husk answer. This took so much longer to complete than I thought it would. I'm glad there is a tutorial with good explanation of how the input-order and super-numbers work, otherwise I had to give up. I never programmed in Haskell, and maybe I'm just too used to the left-to-right stack-based 05AB1E, but Husk isn't exactly straight-forward due to its strong-typed nature and right-to-left execution (including input-arguments) imho..
But, it works, which is what counts in the end. :)
A list of lists of coefficients where index encodes exponent, like the third input example in the challenge description.
Explanation:
2 # Use the first argument,
G( ) # and left-reduce it by:
Ṫ # Apply double-vectorized:
* # Multiply
# (This basically results in the multiplication table of the lists)
∂ # Take the diagonals of this multiplication table
m # Map over these diagonal-lists:
Σ # And sum each together
→ # Only leave the last list after the reduce-by
∞0 # Push an infinite list of 0s: [0,0,0,...]
+ # Merge the two lists together
0 # Push the second argument `k`
→ # Increase it by 1 (since Husk uses 1-based indexing instead of 0-based)
! # And use it to index into the list we created
# (after which the result is output implicitly)