Skip to main content
added 1961 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 3939 30 bytes

I⌊EΦEX²⊕LθΦ⍘ι12μ⁼ΣιLθΣEι×Iλ§θμ

Try it online! Link is to verbose version of code. Explanation:

      ²                         Literal 2
     X                          Raised to power
         θ                      Input array
        L                       Length
       ⊕                        Incremented
    E                           Map over implicit range
            ι                   Current index
           ⍘                    Convert to string
             12                 Using digits `12`
          Φ    μ                Remove leading digit
    Φ                            Filter strings where
                   ι             Current string
                  Σ              Digital sum
                 ⁼               Equal to
                     θ           Input array
                    L            Length
  E                             Map over strings
                       ι        Current string
                      E         Map over characters
                          λ     Current character
                         I      Cast to integer
                        ×       Multiplied by
                            θ   Input array
                           §    Indexed by
                             μ  Current index
                     Σ          Take the sum
 ⌊                              Take the minimum
I                               Cast to string
                                Implicitly print

Previous less brute-forcey 39-byte version:

Charcoal, 39 bytes

Charcoal, 39 30 bytes

I⌊EΦEX²⊕LθΦ⍘ι12μ⁼ΣιLθΣEι×Iλ§θμ

Try it online! Link is to verbose version of code. Explanation:

      ²                         Literal 2
     X                          Raised to power
         θ                      Input array
        L                       Length
       ⊕                        Incremented
    E                           Map over implicit range
            ι                   Current index
           ⍘                    Convert to string
             12                 Using digits `12`
          Φ    μ                Remove leading digit
    Φ                            Filter strings where
                   ι             Current string
                  Σ              Digital sum
                 ⁼               Equal to
                     θ           Input array
                    L            Length
  E                             Map over strings
                       ι        Current string
                      E         Map over characters
                          λ     Current character
                         I      Cast to integer
                        ×       Multiplied by
                            θ   Input array
                           §    Indexed by
                             μ  Current index
                     Σ          Take the sum
 ⌊                              Take the minimum
I                               Cast to string
                                Implicitly print

Previous less brute-forcey 39-byte version:

Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 39 bytes

≔⟦υ⟦ω⟧⟧ηFθ⊞η⁺⁺§η±²2⁺§η±¹1I⌊E⊟ηΣEι×Iλ§θμ

Try it online! Link is to verbose version of code. Explanation:

≔⟦υ⟦ω⟧⟧η

Start with an (empty) list of ways of walking and running to get to a distance of -1 and a list of one (empty) way of walking and running to get to a distance of 0.

Fθ⊞η⁺⁺§η±²2⁺§η±¹1

Build up the ways of walking and running to get to distances of 1..N.

I⌊E⊟ηΣEι×Iλ§θμ

For each way of walking and running to get to a distance of N, calculate the amount of rain, and output the minimum.