[Question]
  [
What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out!
# Task
Create a triangle that looks like this:
```
          1
        1   1
       2  2  2
    3   5  5   3
  5  10  14  10  5
8  20  32  32  20  8
```
Basically, instead of each cell being the sum of the cells above it on the left and right, you also need to add the cell on the left above the cell on the left and the cell on the right above the cell on the right.
This is [A036355](https://oeis.org/A036355).
You may choose to do one of the following:
* Output the \$n\$th row (indexed as you wish)
* Output the first \$n\$ rows
* Output all rows infinitely
# Rules
* Each row may be represented as a string separated by some character that is not a digit or an ordered collection of numbers. You do not need to align the triangle like I did in the example.
* If you choose to output multiple rows, you need either an ordered list of rows, or a string that uses a different separator than the one you use within rows.
* Please specify which task you chose in your answer, along with the input (if applicable) and output format.
* You can receive input and output through any of the standard IO methods.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins!
## Bounty
As Scala is the [language of the month](https://codegolf.meta.stackexchange.com/questions/20585/language-of-the-month-for-january-2021-scala?cb=1), I will be giving a 50 rep bounty for any Scala answers to this question (not just if you're a first-time user). If multiple Scala answers are posted, I will be happy to put a bounty on a different Scala answer of yours instead.
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~73~~ ~~72~~ 69 bytes
-1 byte thanks to [dingledooper](https://codegolf.stackexchange.com/users/88546/dingledooper)!  
-3 bytes thanks to [Sisyphus](https://codegolf.stackexchange.com/users/48931/sisyphus)!
Prints the rows indefinitely.
```
c=a=[0]
b=[1]
while 1:print b;a,b=b,map(sum,zip(c*2+a,a+c*2,c+b,b+c))
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9k20TbaIJYryTbaMJarPCMzJ1XB0KqgKDOvRCHJOlEnyTZJJzexQKO4NFenKrNAI1nLSDtRJ1EbSOskayfpJGkna2r@/w8A "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~82~~ \$\cdots\$ 60 bytes
```
[]%[1]
u%v=v:v%foldl1(zipWith(+))[0:0:u,u++[0,0],0:v,v++[0]]
```
[Try it online!](https://tio.run/##FcexDoMgEADQvV/hUBINNDlWEr6jA72BWFHiaUmFG/x4r@nb3hKPdSKS5F8SUAWLt6bYs2OVPvQm25@5PHNdej0MARy4ZprWAQygAceG/0GULebdl2/e673GdeosdEmuMVGcD3mMpfwA "Haskell – Try It Online")
*-10 thanks to @user*
*-4 thanks to @ovs*
Fairly new to Haskell, and never golfed in it before. Happy to be beaten!
[Answer]
# [J](http://jsoftware.com/), 30 bytes
Returns the n'th row.
```
0{((+|.)@(+/)@,.,:{~)&0&(1,:0)
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/Dao1NLRr9DQdNLT1NR109HSsqus01QzUNAx1rAw0/2typSZn5CukKRgZcIGZanYKNg5pSgYKmXqGBv8B "J – Try It Online")
### How it works
* `f&0&(1,:0)` `(1,:0) f 0` will be executed `n` times
* `(last two rows) g@,. (0)` append a 0 to each row and execute g, f.e. `g (2 2 2 0,: 1 1 0 0)`
* `(+|.)@(+/)` sum the two rows `3 3 2 0` and add it to its reverse: `3 5 5 3`
* `,:{~` append the previous row `3 5 5 3,:2 2 2 0`
* `0{` after `n` iteration get the last row `3 5 5 3`
[Answer]
# [Scala](https://www.scala-lang.org/), ~~156..133~~ 120 bytes
*-23 bytes thanks to [user](https://codegolf.stackexchange.com/users/95792/user)!*  
*-13 bytes thanks to [Command Master](https://codegolf.stackexchange.com/users/92727)!*
```
()=>{var(a,b)=Seq(1,1)->Seq(1)
while(1>0){println(b)
val t=a
a=Seq(0+:0+:b,b:+0:+0,a:+0,0+:a).transpose.map(_.sum)
b=t}}
```
[Try it online!](https://tio.run/##PY7BCsIwEETv@Yo97tJa2mshAT/Ak3iWTQ0aSWNMYhVKvz3WHoTHMAzMMGlgx@Wh72bIcADzycZfEuxDgFkATOwgR8v@6kwPSCAVnLzNIAuSVPPEEbnWJI/miV3d0U5tjsT7Zp3BTrU0h2h9dh41iW1PsuCt0Fb9iq51X7UrNf9kTZiaHNmn8EimGTnguUmvkYSWeVkK/B8hiaV8AQ)
Output is infinite.
Explanation:
```
object M extends App {
  var (a, b) = Seq(1, 1) -> Seq(1)                                          // init (a, b) := ([1, 1], [1]])
  while (1 > 0) {                                                           // while true
    println(b)                                                              // print b
    val t = a                                                               // cache a in a local variable t
    a = Seq(0 +: 0 +: b, b :+ 0 :+ 0, a :+ 0, 0 +: a).transpose.map(_.sum)  // calculate the new triangle row with 
                                                                            // the help of the shifted lists a and b like in the example below
    b = t                                                                   // set b the cached previous value of a
  }
}
```
Example for n = 4:
```
   0  0  2  2  2
+  2  2  2  0  0
+  3  5  5  3  0
+  0  3  5  5  3
-----------------
=  5 10 14 10  5
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~25~~ ~~24~~ ~~19~~ ~~18~~ ~~13~~ 12 bytes
-6 bytes thanks to @ovs
-4 bytes thanks to @Neil, which allowed for additional -1
-2 bytes thanks to @Kevin Cruijssen
```
1‚ηλ₂0š+0šÂ+
```
[Try it online!](https://tio.run/##yy9OTMpM/f/f8FHDrHPbz@1@1NRkcHShNhAfbtL@/x8A "05AB1E – Try It Online")
A port of the python answer, basically. Outputs the rows infinitly
Explaination:
```
1 push 1
‚ pair. Since there is no input, it pairs 1 with 1, to get [1, 1]
η prefixes, get [[1], [1, 1]]
λ recursive environment
₂ push a(n-2)
0š prepend 0 to a(n-2)
+ sum with implicit a(n-1)
0š prepend a zero
Â Bifurcate - push a and reversed(a)
+ sum
```
[Answer]
# [Haskell](https://www.haskell.org/), 81 bytes
```
q=zipWith(+)
z=[0,0]
f=[]:[1]:[q(a++z)$q(z++a)$q(b++[0])$0:b|(a,b)<-zip f$tail f]
```
[Try it online!](https://tio.run/##HYyxDoMgFEV3v@INDJBnE7p0MOU7HAjDI0p8kapYJtJ/p@hwc85wchf6rnOMtSZT@Bg5LxJVV4zVvXZdMNYN9tmWJCEWJZIsiHTRI1rtlNCD/0nqvXo/2gMEkYkjBFc/xJuZdjhO3jIIyLTO8LrlCuof "Haskell – Try It Online")
Returns an infinite list of all rows, 1-indexed (hence the `tail` in TIO to dispose of element `0`).
[Answer]
# [Perl 5](https://www.perl.org/), 86 bytes
```
$,=$";@b=@c,@c=@,while say@,=map$,[$_]+($_>0)*$,[$_-1]+($_>1)*$b[$_-2]+$b[$_]||1,0..@,
```
[Try it online!](https://tio.run/##K0gtyjH9/19Fx1ZFydohydYhWcch2dZBpzwjMydVoTix0kHHNjexQEUnWiU@VltDJd7OQFMLzNM1hPANgfwkEN8oVhvMiK2pMdQx0NNz0Pn//19@QUlmfl7xf11fUz0DQwMA "Perl 5 – Try It Online")
Output is infinite.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~54~~ 39 bytes
```
≔⟦¹⟧ηＦＮ«⊞υ⁰≔Ｅυ⁺κ§ηλι≔ηυ⊞ι⁰≔Ｅ⮌ι⁺κ§ιλη»Ｉη
```
[Try it online!](https://tio.run/##RY49C8IwEIZn@ytuvIMIVXDqVJwclIJjcYi1mkCalnyIIP72mFSjww3vc8fzXie46UauQqitlTeN7erEQFBVXEcDuNOTdwc/nHuDRPAsFvmsUd7ink@4ZlASAx9nZp7BD2fWlrP0mwSDCCgiGXuyUSTHPyZH7Xb60j9QfiqOfphxjHkzMFBEqSe9/CoaI7XDLbcOBVEVwiYs7@oN "Charcoal – Try It Online") Link is to verbose version of code. Outputs the 0-indexed nᵗʰ row. Explanation: Relies on the symmetry of the triangle.
```
≔⟦¹⟧η
```
Start with the 0ᵗʰ row with just a `1` in it (using the predefined empty list for the "-1ᵗʰ" row).
```
ＦＮ«
```
Repeat `n` times.
```
⊞υ⁰
```
Append a `0` to the previous row.
```
≔Ｅυ⁺κ§ηλι
```
Sum the previous and current row to a temporary variable.
```
≔ηυ
```
Copy the current row to the previous row.
```
⊞ι⁰
```
Append a `0` to the new row.
```
≔Ｅ⮌ι⁺κ§ιλη
```
Add the new row to its reverse and save that as the current row.
```
»Ｉη
```
Print the final row.
Previous 54-byte version worked by creating the matrix formed by rotating the triangle anticlockwise by 45°:
```
Ｎθ⊞υＥθ⁼ι¹⊞υ⟦⁰⟧Ｆθ«≔⟦⁰⟧ηＦ⁻θι⊞ηΣ⁺…⮌η²Ｅ…⮌υ²§λ⊕κ⊞υη»Ｉ✂Ｅυ⊟ι²
```
[Try it online!](https://tio.run/##ZY49a8MwEIbn@FfceAIFmgxdOgWTwUOKScbQQVUukYgs2/oICaW/XT27LRR6270P74c2KuheuVIaP@T0mrt3CjiKl6rN0WCWsFMDjhK2Y1YuopWwEuIPPj698XfuA7ALPqrFJkZ78ci6BMNoMbOd9TlOOVYImL1GwiF32DrW64d2VJt@wD3dKERCIySsxXf7f5p/6CY1/kR3dBIarwN15BOd8Crm4@7fldOQz6oN1iesVUx4cFYTTulMW47mXVMmu0p5Lsub@wI "Charcoal – Try It Online") Link is to verbose version of code. Outputs the 1-indexed nᵗʰ row. Explanation:
```
Ｎθ
```
Input `n`.
```
⊞υＥθ⁼ι¹
```
Create a fictitious "-1ᵗʰ" row with a single `1` in the first column. This seeds the first row later.
```
⊞υ⟦⁰⟧
```
Create a "0ᵗʰ" row of zeros. (Because Charcoal uses cyclic indexing, I only need one zero.)
```
Ｆθ«
```
Loop over the desired output rows.
```
≔⟦⁰⟧η
```
Start with a "0ᵗʰ" column of just a zero.
```
Ｆ⁻θι
```
Loop over the additional numbers needed to complete this row of the rotated triangle.
```
⊞ηΣ⁺…⮌η²Ｅ…⮌υ²§λ⊕κ
```
Get the latest two numbers for this row plus the two numbers in the columns above and push the sum to the current row.
```
⊞υη
```
Push the completed row to the triangle.
```
»Ｉ✂Ｅυ⊟ι²
```
Print the last number in each row, excluding the two initial dummy rows.
[Answer]
# AWK, ~~117~~ 111 bytes
Prints the first `n` rows of the triangle, unformatted.
Edit: Let `l` and `c` be two integers. `l c` concatenates their values as a string. For example: in the first element, `0 0` evaluates `"00"` (str). `00` would evaluate `0` (int).
```
{print a[0 0]=1;for(;++l<$1;)for(c=0;c<=l;c++)printf a[l c]=a[l-1 c-1]+a[l-1 c]+a[l-2 c-2]+a[l-2 c](c~l?RS:FS)}
```
Step by step:
```
{
print a[0 0]=1;                  # sets the top of the triangle
for(;++l<$1;)                    # looping for the lines
  for(c=0;c<=l;c++)              # looping for the columns
    printf a[l c]=               # prints the ["l c"]th element of the array,
           a[l-1 c-1]+a[l-1 c]+  # which is the sum of these elements of the l-1 line
           a[l-2 c-2]+a[l-2 c]   # and these elements of the l-2 line.
           (c~l?RS:FS)           # if it's the last column, adds a line feed,
                                 # otherwise, a space.
}
```
[Try it online!](https://tio.run/##SyzP/v@/uqAoM69EITHaQMEg1tbQOi2/SMNaWzvHRsXQWhPESbY1sE62sc2xTtbW1gQrTgOqzlFIjrUFUrqGCsm6hrHaUCaEYQQUM4IzYzWS63Lsg4Kt3II1a///NwUA "AWK – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~17~~ 15 bytes
```
:;1mSż+oΘ↔Ẋż+Θ₀
```
[Try it online!](https://tio.run/##yygtzv7/38raMDf46B7t/HMzHrVNebirC8gGMpsa/v8HAA "Husk – Try It Online")
Answering [Razetime's challenge from the Husk chat](https://chat.stackexchange.com/transcript/message/57789339#57789339)
### Explanation
```
:;1mSż+oΘ↔Ẋż+Θ₀
:;1                Begin with [1]
              ₀    Define the sequence recursively
          Ẋż+Θ     Pairwise sums of rows (e.g. [1,1]+[2,2,2]=[3,3,2])
   m               For each of these sums
    Sż+             Sum it to
       oΘ↔          itself reversed with an extra leading 0
                    (e.g. [3,3,2]+[0,2,3,3]=[3,5,5,3])
```
All the sums between lines are performed with `ż+`, which sums elements at the same indices and keeps elements from the longer line unchanged.
---
## Previous solution, 17 bytes
```
∂ƒ(:İftS‡+T0Ẋż+ΘΘ
```
[Try it online!](https://tio.run/##ASQA2/9odXNr///iiILGkig6xLBmdFPigKErVDDhuorFvCvOmM6Y//8 "Husk – Try It Online")
Here's my previous solution using an original approach.
### Explanation
If we rotate the triangle 45° counterclockwise, we'll find out it is actually an infinite 2D matrix:
```
1  1  2  3  5 ...
1  2  5 10 20 ...
2  5 14 32 71 ...
3 10 32 84 ...
5 20 71 ...
...
```
This answer builds that matrix and then returns its antidiagonals, which will be the rows of the original triangle.
```
∂ƒ(:İftS‡+T0Ẋż+ΘΘ
∂                    Antidiagonals of
 ƒ(                  Fixpoint of the following function (defines the matrix recursively)
   :İft              Set the Fibonacci sequence as the first row
               ΘΘ    Add two empty rows before the matrix
            Ẋż+      and get the pairwise row sums
       S‡+T0         then sum this to itself transposed
```
The recursive definition computes the sums of each row with the previous one, and adds it to the sums of each column with the previous one; since the matrix is symmetric along the main diagonal, column sums are computed by transposing the row sums. Two empty rows need to be added to deal with the numbers near the sides of the triangle, where there are less than two rows/columns to sum.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 82 bytes
```
f=(a=0,b=[1])=>print(b)+f(b,[...b,0].map((x,i)=>x+(a[i]|0)+(b[i-1]|0)+(a[i-2]|0)))
```
[Try it online!](https://tio.run/##JcpBCoAgEEDR68zgKNaqjV1EXMwEwgSFWESL7m5Gu8fnr3zxsVQtp72mlkMDDp4kxCFhmEvV/QRBk0EoOueEfHIbF4CbtA@3AY6aHo8GJKodfvZmx4@ILQO2Fw "JavaScript (V8) – Try It Online")
* Missing a JavaScript answer, hoping @Arnauld is fine
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 13 12 bytes
```
1WɓŻ+Ż++µ³¡0
```
[Try it online!](https://tio.run/##y0rNyan8/98w/OTko7u1gUj70NZDmw8tNPj//78pAA "Jelly – Try It Online")
Returns the nth row, indexed from 0.
Makes use of the fact that Jelly's “repeat n times” quick `¡`, when given a dyad, behaves in [a Fibonacci-ish way](https://github.com/DennisMitchell/jellylanguage/wiki/Tutorial#65repeating-links).
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~29~~ ~~28~~ ~~23~~ 19 bytes
* Saved 1 byte thanks to caird coinheringaahing
* Saved 5 bytes thanks to Razetime!
* Saved 4 bytes thanks to Leo!
```
¡öFz+S+m↔z+ḣ´e0↔;;1
```
[Try it online!](https://tio.run/##yygtzv7//9DCw9vcqrSDtXMftU2p0n64Y/GhLakGQLa1teH//wA "Husk – Try It Online")
Outputs an infinite list, explanation coming soon. This is *really* long, so it looks like I'm not going to get the bounty anyway.
```
¡öFz+S+m↔z+ḣ´e0↔;;1
¡                     Create infinite list by repeatedly applying function
                      that list of previous result to create new result
                ;;1   Initial list of results - [[1]]
  Fz+S+m↔z+ḣ`e0↔      Function to get next row from previous rows
               ↔      Reverse previous rows (so last 2 rows are at start)
            `e0       [0, 0]
           ḣ          Prefixes ([[0], [0,0]])
         z+           Zip by concatenating ([0, 1, 1], [0, 0, 1])
     S+               Then add those lists
       m↔             To their reverse ([1, 2, 1], [1, 0, 1])
  F                   Fold over that 2-element list of lists
   z+                 By adding them together to get the new row
```
[Answer]
# [Haskell](https://www.haskell.org/), 59 bytes
```
x!y=zipWith(+)x$y++[0,0]
x#y=x:(0:0:y)!y!(0:x)!x#x
t=[1]#[]
```
[Try it online!](https://tio.run/##DcY7DoAgDADQ3VOU4ADBoa4kHMHZgTAwkEj8hGiH1sujb3pbfvZyHL2zkvDWtlbajLM8inMRJ0wDawnsDXr0YpWof2wVax4oxDnpmPqZ6wUBztwWaHe9CAzlvcCMQLZ/ "Haskell – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~60~~ 47 bytes
```
#3&@@@(#3&@@(1/(1-x(1+y+x+y^2x))+O@x^#)+O@y^#)&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X9lYzcHBQQNMaRjqaxjqVmgYaldqV2hXxhlVaGpq@ztUxCmDqEogpfY/oCgzr0TfIc3B0OA/AA "Wolfram Language (Mathematica) – Try It Online")
1-indexed. Returns the first \$n\$ rows by truncating the generating function \$\frac1{1-x(1+x+y+xy^2)}\$.
---
older, **66 bytes**
```
Sum[Multinomial[#-n-2i,n-2j,i,j],{i,0,#-n},{j,0,n}]~Table~{n,0,#}&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7P7g0N9q3NKckMy8/NzMxJ1pZN0/XKFMHSGTpZOpkxepUZ@oY6ABFa3Wqs4CsvNrYupDEpJzUuuo8kESt2v@Aosy8EgetNH2HoMS89NRoAx3L2P8A "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Julia 1.0](http://julialang.org/), 53 bytes
```
f(i=1,j=[])=@show(i),f([i;0]+[0;i]+[j;0;0]+[0;0;j],i)
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/P00j09ZQJ8s2OlbT1qE4I79cI1NTJ00jOtPaIFY72sA6E0hmWRtAeQbWWbE6mZpAXZr/AQ "Julia 1.0 – Try It Online")
call `f()` for infinite output
Only correct up to 64-bit signed integer limit, replace `i=1` with `i=big(1)` to make it work for any number
[Answer]
# [PHP](https://php.net/), ~~124~~ ~~115~~ 112 bytes
```
echo 1;for($q=[1];print"
";$p=$q,$q=$r)for($i=-1;++$i<=count($q);)echo$r[$i]=$q[$i-1]+$q[$i]+$p[$i-2]+$p[$i].~_;
```
[Try it online!](https://tio.run/##K8go@G9jXwAkU5Mz8hUMrdPyizRUCm2jDWOtC4oy80qUuJSsVQpsVQp1gKIqRZpg@UxbXUNrbW2VTBvb5PzSvBKgDk1rTZAJKkXRKpmxQOVAStcwVhvMAFIFIL4RlBGrVxdv/f8/AA "PHP – Try It Online")
Did the world want this answer? Probably not. Did it deserve it? Definetly.
straightforward PHP soup that outputs all rows forever (at least until scientific notation -quickly- makes things unreadable)
EDIT: saved 9 bytes by not initializing $p and $r. There wasn't enough warnings for my taste.
EDIT2: saved another 3 bytes with another strategy for the newline output, thanks to `print` returning a truthy value (note that I'm aware that a byte could be saved with a "assumed constant" line separator like `print A`, but I preferred a readable output)
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-s`, 22 bytes
```
Y^1LaS(l+:Py)+:RVlPE0y
```
Outputs the first `n` rows. [Try it online!](https://tio.run/##K8gs@P8/Ms7QJzFYI0fbKqBSU9sqKCwnwNWg8v///7rF/80A "Pip – Try It Online")
### Explanation
Each row of the triangle, represented as a list, can be obtained by a two-step process: first add the two previous rows; then take that result, reverse it, prepend 0, and add it to itself.
```
 [2 2 2]
+[3 5 5 3]
----------
 [5 7 7 3]
+[0 3 7 7 5]
------------
 [5 10 14 10 5]
```
Let's start with a less-golfed version of the code:
```
Y[1]La{Pyl+:yl+:RVlPE0Sly}
                            a is command-line argument; l is empty list (implicit)
Y[1]                        Yank the first row into y
    La{                  }  Loop a times:
       Py                    Print y, the current row
         l+:y                Add the two rows together, saving the result in l
                RVl          Reverse that list,
                   PE0       prepend 0,
             l+:             and add it back to l (the new row)
                      Sly    Swap l and y; y is now the new row and l the row above it
```
To get to 22 bytes:
* Using [this tip](https://codegolf.stackexchange.com/a/211993/16766), `[1]` → `^1`.
* We can print `y` while adding it to `l`: `l+:Py`.
* An assignment expression evaluates to an lvalue, so we can use it in the swap command: `S(l+:RVlPE0)y` (parentheses not necessary, added for clarity).
* But then we can take the same idea one step further and replace the `l` in *that* assignment with the first `l` assignment. We'll need parentheses because assignment operators are right-associative; but since the body of the loop is now one statement, we can drop the curly braces for a net 1-byte savings: `S(l+:Py)+:RVlPE0y`.
]