Global

Members

(constant) MONTHS :Array.<string>

Source:
Type:
  • Array.<string>

Methods

calculateTable(refillData, consumption, startingVolume, maxCapacity) → {Object}

Simulates monthly tank usage, calculating volume changes and deficits.
Source:
Parameters:
Name Type Description
refillData Object.<string, number> Monthly refill volumes.
consumption number Amount withdrawn every even month.
startingVolume number Volume at the start of the year.
maxCapacity number Maximum capacity of the tank.
Returns:
Type:
Object

findMinimumCapacity(refillData, consumption) → {number|null}

Uses binary search to find the minimal tank volume required to avoid any deficit.
Source:
Parameters:
Name Type Description
refillData Object.<string, number> Monthly refill volumes.
consumption number Amount withdrawn every even month.
Returns:
Type:
number | null
- Minimum sufficient volume or null if impossible.

getTableString(tableData) → {string}

Converts table data into a formatted ASCII table.
Source:
Parameters:
Name Type Description
tableData Array.<Object> Array of row objects with month info.
Returns:
Type:
string
- ASCII-formatted table string.

main()

Entry point for the script. Parses input, calculates and prints tables.
Source:

parseInputFile(filePath) → {Object}

Reads input.txt file and parses it into usable data.
Source:
Parameters:
Name Type Description
filePath string Path to the input.txt file.
Returns:
Type:
Object

parseInputText(input) → {Object}

Parses structured text input from a file into usable data.
Source:
Parameters:
Name Type Description
input string Raw text input.
Returns:
Type:
Object

printTable(title, tableData)

Prints a table with a title to the console.
Source:
Parameters:
Name Type Description
title string Table title.
tableData Array.<Object> Table rows.