Imagine an infinite symmetrical triangle of pegs, where the rows have size 1, 2, 3, ... (similar to Pascal's Triangle). All the pegs are red apart from k (your input), which are blue. A ball is then dropped from the top. Each time it hits a peg it has an equal chance to bounce left or right, moving to the peg directly left or right in the row below.
The ball's value starts at 1. Every time the ball hits a blue peg, add its value to your earnings and then double its value. Every time it hits a red peg, reset the value to 1 and earn nothing.
What is the highest expected value you can achieve by placing k blue pegs? Give your answer as a ratio, a floating point number, or a numerator over 2^(k-1).
This is code-golf, so the shortest answer wins.
Test Cases:
1 -> 1 2 -> 2 1 1 0 3 -> 13/4 1 1 0 0 1 0 4 -> 5 1 1 1 0 1 0 5 -> 57/8 1 1 1 0 1 0 0 1 0 0 6 -> 151/16 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 7 -> 27/2 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 8 -> 143/8 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 9 -> 717/32 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 10 -> 31 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 11 -> 5103/128 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 12 -> 12511/256 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 13 -> 2127/32 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 14 -> 1349/16 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 15 -> 103 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0
k=18is likek=15:12122222121. \$\endgroup\$