Giter VIP home page Giter VIP logo

farecalc's Introduction

Requirements Python (2.7, 3.2, 3.3, 3.4, 3.5) Django (1.8, 1.9, 1.10)

Installation

Install using pip...

pip install djangorestframework

Add 'rest_framework' to your INSTALLED_APPS setting.

INSTALLED_APPS = ( ... 'rest_framework', ) Example

Let's take a look at a quick example of using REST framework to build a simple model-backed API for accessing users and groups.

Startup up a new project like so...

pip install django pip install djangorestframework django-admin.py startproject example . ./manage.py migrate ./manage.py createsuperuser

fareCalc

Problem Statements for Code PROBLEM 1: Food Tripping! Aim: Make a backend, which takes input of a given address. Using this input, it finds the list of nearest 10 best restaurants (using Zomato API), and calculates the taxi fare to go to each restaurant (using Uber API). The output contains a list of the restaurants, along with the taxi fare needed to get to each of them. API endpoints needed for the user: Step 1: User will make a POST request to the API, containing the address. The address gets stored in the DB, and returns the location ID to the user Sample endpoint: /POST api/v1/location Sample input: Greater Kailash (GK) 2, New Delhi Step 2: User makes a GET request to the API, containing the location ID, and gets a list of 10 restaurants, with the rating for each restaurant, along with the taxi fare, sorted in ascending order from lowest fare to highest fare Sample endpoint: /GET /api/v1/fare/<location_id> Reference Material: Zomato API: To get the location info: https://developers.zomato.com/documentation#!/location/locations To get the best restaurants for a location: https://developers.zomato.com/documentation#!/location/location_details Uber API: To get fare: https://developer.uber.com/docs/ride-requests/references/api/v1-estimates-price-get Estimate: 4 hours

PROBLEM 2: Optimize Optimize Optimize! Aim: Find out the maximum sub-array of non negative numbers from an array, in the manner which uses the least computation and memory effort. This problem can easily be done in O(n^3), but we are looking for a O(n) implementation, or at least a O(n^2) Details: The sub-array should be continuous, i.e. a sub-array created by choosing the second and fourth element and skipping the third element is invalid. Maximum sub-array is defined in terms of the sum of the elements in the sub-array. Sub-array A is greater than Sub-array B if sum(A) > sum(B). Example: A : [1, 2, 5, -7, 2, 3] The two sub-arrays are [1, 2, 5], [2, 3] The answer is [1, 2, 5], as its sum is larger than [2, 3] NOTE #1: If there is a tie, then compare with segment's length and return segment which has maximum length NOTE #2: If there is still a tie, then return the segment with minimum starting index Estimate: 2 hour

farecalc's People

Contributors

sanjusci avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.