Skip to main content
deleted 7 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 2222 20 bytes

Saved 2 bytes thanks to Martin Ender

ri2,{(_(jAb:+\jAbjAb\jAb+:+++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online!Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
Concatenate the lists of digits
                :+     AddSum the two sumsdigits

CJam, 42 bytes

Solution using the repetition. Similar algorithm to Jonathan Allan's solution.

ri_2,1+"[2358DC7A89HHGFDA56B8A9AA]"S*~@*+=

Try it online!

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 42 bytes

Solution using the repetition. Similar algorithm to Jonathan Allan's solution.

ri_2,1+"[2358DC7A89HHGFDA56B8A9AA]"S*~@*+=

Try it online!

CJam, 22 20 bytes

Saved 2 bytes thanks to Martin Ender

ri2,{(_(jAb\jAb+:+}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                    Read an integer from input
  2,                  Push the array [0 1]
    {             }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                 Decrement (n-1)
      _(               Duplicate and decrement again (n-2)
        jAb            Get the list digits of j(n-2)
           \           Swap the top two elements
            jAb        Get the list of digits of j(n-1)
               +       Concatenate the lists of digits
                :+     Sum the digits

CJam, 42 bytes

Solution using the repetition. Similar algorithm to Jonathan Allan's solution.

ri_2,1+"[2358DC7A89HHGFDA56B8A9AA]"S*~@*+=

Try it online!

added 242 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJamCJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 42 bytes

Solution using the repetition. Similar algorithm to Jonathan Allan's solution.

ri_2,1+"[2358DC7A89HHGFDA56B8A9AA]"S*~@*+=

Try it online!

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 42 bytes

Solution using the repetition. Similar algorithm to Jonathan Allan's solution.

ri_2,1+"[2358DC7A89HHGFDA56B8A9AA]"S*~@*+=

Try it online!

deleted 19 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. Will attempt to golf further0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. Will attempt to golf further.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums

CJam, 22 bytes

ri2,{(_(jAb:+\jAb:++}j

Straightforward recursive algorithm, nothing fancy. 0-indexed.

Try it online! or test for 0-50 (actually runs pretty fast).

Explanation

ri                      Read an integer from input
  2,                    Push the array [0 1]
    {               }j  Recursive block, let's call it j(n), using the input as n and [0 1] as base cases
     (                   Decrement (n-1)
      _(                 Duplicate and decrement again (n-2)
        jAb              Get the list digits of j(n-2)
           :+            Sum them
             \           Swap the top two elements
              jAb        Get the list of digits of j(n-1)
                 :+      Sum them
                   +     Add the two sums
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37
Loading