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

fixed formula
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 26 bytes

×ばつθι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨...§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$\$ S(n, k) = S(n - 1, k - 1) + k S(n - 2, k - 1) + k^2 S(n - 3, k - 1) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

×ばつθι

Output the dot product of each row of S with the input.

Charcoal, 26 bytes

×ばつθι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨...§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

×ばつθι

Output the dot product of each row of S with the input.

Charcoal, 26 bytes

×ばつθι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨...§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k - 1) + k S(n - 2, k - 1) + k^2 S(n - 3, k - 1) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

×ばつθι

Output the dot product of each row of S with the input.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 26 bytes

×ばつθι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨...§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

×ばつθι

Output the dot product of each row of S with the input.

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