Skip to main content
2 of 4
added 569 characters in body; added 20 characters in body

Vimscript, 116 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjp4a-\ej4a \e is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this (input) times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !