Code Monkey home page Code Monkey logo

fixed-route-suggestion-task's Introduction

New Route suggestion Problem

Fixed routes can be modeled as a sequence of connected stations on a map. This algo allow the user to submit a new fixed route suggestion, this route is a sequence of connected stations on the map. In this problem have constructed a new route using only stations from fixed routes given only one user fixed route suggestion. The route is constructed in such a way that for every suggested station and the corresponding chosen station from routes the distance is minimized. Stations are represented as points in 2D plane.

Getting Started

Clone the git repo to get started.

Prerequisites

Node.js >= v12.18

Need to create an input file first, the file format is

2
5
A 4 5
B 5 3
C 6 5
D 7 5
E 9 3
4
F 2 4
G 4 1
H 8 3
I 8 5

Input

The first line of the input consists of one integer N, the number of fixed routes in Swvl system. The next N blocks represents fixed routes in swvl system, each block consists of an integer K followed by K lines, each line consists of a string S and two integers X and Y the station name, x and y coordinates respectively. The following line consists of one integer M the number of stations in user’s suggested fixed route, each line of the M lines consists of a string S and two integers X and Y the station name, x and y coordinates respectively. Note that (each station is connected to the following one in the input)

Output

The output contains M lines, each line contains two space-separated strings S and P, the name of the suggested station and the name of the chosen station from the system respectively.

Run

In order to run the script, run

node main.js E:/Test/input.txt

End with an example of getting some data out of the system or using it for a little demo

Running the tests

You can refer the sampleTestData.txt and largeSizeDataSet.txt

sampleTestData.txt contains the sample data from the task largeSizeTestData.txt contains a larger sample test data with

  • 3960 Routes in the System
  • 197921 Stations in the System
  • 65 stations in suggested route

Stats of 20 runs (average):

Sample Data:

       fileRead: 0.514ms   
       Calculation: 0.201ms
       FileWrite: 2.849ms
       Memory usage: 2.86 MB

Large Data

        fileRead: 314.730ms
        Calculation: 955.720ms
        FileWrite: 2.503ms
        Memory usage 62 MB

Authors

  • Muhammad Waris

License

This project is licensed under the MIT License - see the LICENSE.md file for details

fixed-route-suggestion-task's People

Contributors

mwaris97 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.