Bottom part of the Hourglass
Clean, 305 289 bytes
import StdEnv
@[h:t]|all((==)9)h|t>[]=[h: @t]=[h]
#s=length h/2
#m=hd(sort h)+1
=[updateAt(hd[e\\e<-flatten[[s+i,s-i]\\i<-[0..s]]|h!!e<m])m h:t]
$a b c=flatlines(map(cjustify(a+1))[fromString(fromInt(b-c)),['-']:reverse(map(map(toChar o(+)48))((iterate@[repeatn(a-r)0\\r<-[0,2..a]])!!c))])
Try it online!
05AB1E, 68 63 59 57 56 bytes
IÅÉÅ9[DOO²Q#ćD_Piˆëć<¸«¸ì]ćā<ΣÉ}2äćR¸ì˜è¸ì¯ìJDSOIα'-‚ì.C
Try it online!
Explanation
IÅÉÅ9
We initialize the stack with a list of list of 9's.
Each list represents a row so the length of each list is odd and the length of the last list is equal to the first input.
An input of 5 would result in [[9], [9, 9, 9], [9, 9, 9, 9, 9]]
[DOO²Q#ćD_Piˆëć<¸«¸ì]
We then iterate over these lists decrementing elements in a list until the list consists only of zeroes, then moving on to the next. We stop when the total sum equals the second input.
[ # ] # loop until
DOO # the sum of the list of lists
²Q # equals the second input
ć # extract the first list
D_Pi # if the product of the logical negation of all elements is true
ˆ # add the list to the global list
ë # else
ć< # extract the head and decrement it
¸« # append it to the list
¸ì # and prepend the list to the list of lists
Now we need to unsort the final list simulating removing elements from alternating sides instead of left-to-right as we have been doing.
ć # extract the row we need to sort
ā< # push a list of indices of the elements [0 ... len(list)-1]
ΣÉ} # sort it by even-ness
2äćR¸ì˜ # reverse the run of even numbers
# the resulting list will have 0 in the middle,
odd number increasing to the right and
even numbers increasing to the left
è # index into our final row with this
¸ì¯ì # reattach all the rows to eachother
Now we format the output correctly
J # join list of lists to list of strings
DSOIα # calculate the absolute difference of sum of our triangle and the 3rd input
'-‚ì # pair it with the string "-" and append to the list of rows
.C # join by newlines and center each row