Progress Bar
Easy · simulation
A small download tool prints a text progress bar. You are given done, the number of files finished, total, the number of files in all, and width, the number of cells the bar has.
Build the bar as a string in exactly this format:
- An opening bracket
[. - Then
widthcells, one after another. The firstfilledcells are#and the rest are-. - A closing bracket
], then one space, then the percentage, then a%sign.
Here filled is done * width / total, rounded down to a whole number, and the percentage is done * 100 / total, also rounded down and written without any decimals.
Return the finished string.
Examples
Example 1
Input: done = 3, total = 10, width = 10
Output: "[###-------] 30%"
3 out of 10 is 30%, and 3 of the 10 cells are filled.
Example 2
Input: done = 1, total = 3, width = 6
Output: "[##----] 33%"
A third of 6 cells is exactly 2 filled cells. One third is 33.33...%, rounded down to 33%.
Example 3
Input: done = 0, total = 5, width = 4
Output: "[----] 0%"
Constraints
- 1 <= width <= 5000
- 1 <= total <= 10^4
- 0 <= done <= total