Good gosh, this problem is SO much more complicated than it sounds.
The description is quite unclear, honestly. No hate but there are some things other people need to know before getting started.
1) The coefficient array that is returned needs to be EXACTLY n+1 in length
2) The first coefficient cannot be zero
3) The 'only' constraint doesn't just apply to c_n & c_0, although the assert does check for that. Your coefficient array must be a pyramid (as I now see in the tags). Had to learn that one the hard way.
i.e. c_n = c_0
BUT ALSO ...
c_n+1 = c_1
c_n+2 = c_2
If you're trying to test your code in your own MATLAB console before posting it and the asserts throw errors (as they did with me) use this instead:
assert(isequal(dot(coeff, 4.^flip(0:n)), 10^n))
assert(coeff(1) > 0)
Overall, interesting problem. Slaved away at it because it got me so frustrated but knowing these things would have saved me quite a bit of time. Good luck to future participants.
Return the largest number that is adjacent to a zero
Find the two-word state names
Read a column of numbers and interpolate missing data
Whole Number Concatenator
Toads and Frogs Puzzle
Let's Make A Deal: Criminal Minds
Nodal Voltage of Resistor Ladder Network
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office