Skip to content

ASR134/Railway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Railway Station Planner

Plan a station’s tracks by entering train arrival and departure times. The app computes the minimum number of tracks required so that all trains can be accommodated without conflicts.

Quick start

  1. Open index.html in a modern browser.
  2. Add train rows (or set the number of trains and click "Apply Count").
  3. Enter arrival and departure times (24-hour format, supports 24:00).
  4. Click "Calculate Minimum Tracks".

Real Indian station mode

Use the "Input mode" toggle to switch to "Real station (India)". Provide:

  • Station code (e.g., NDLS)
  • Date (YYYY-MM-DD)
  • API base URL (your endpoint that returns schedule JSON)
  • API key (optional, if your API requires it)

Click "Fetch Schedule" to populate the table. The app expects an array of items or a property like trains, data, or results with arrival_time/departure_time (or similarly named) fields. If your API uses different field names, adapt the mapping in fetchStationSchedule within app.js.

Where to add your algorithm

Open app.js and implement your logic in the function:

function computeMinimumTracks(trains) {
  // trains: Array<{ arrival: number, departure: number }>
  // return a number
}

Notes:

  • arrival and departure are minutes since 00:00.
  • Input is validated so departure > arrival and within 00:0024:00.
  • If you prefer, you can export/import from another file; just ensure computeMinimumTracks is available globally or in this scope.

Visualization

Below the result there’s a simple visualization that places trains into tracks with a greedy layout for display only. It is not used to compute the answer; it’s there to help sanity‑check inputs.

Development notes

  • No build step required; it’s plain HTML/CSS/JS.
  • Tested in latest Chrome and Edge.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published