Giter VIP home page Giter VIP logo

demand-supply's Introduction

Clover Ventures

Demand Supply Problem

Running the solution

Ensure g++ is installed. Code is shipped with Makefile to handle compiling and linking

mkdir build/
mkdir bin/
make clean
make
./bin/runner < sample/input.txt

Note: Any input file should have an empty line in the end for the code to work

Also: The program is accepting input from stdin; empty line terminates input

Generating random test files

cd sample
python gen.py > filename.txt

Note: The test files generated are only for the demand supply logic; produce and time are fixed

Navigating through the code

src

  • main.cpp/h: The program execution start here
  • domain.cpp/h: This contains the domain logic (brain) for the application
  • order.cpp/h: The order struct class for the orders (supply/demand) and necessary functions
  • transaction.cpp/h: The transaction struct class to contains the mapping between a supply and demand order
  • string_utils.cpp/h: General string processing/helper functions

bin

This directory contains the executable binary for code execution

sample

This directory contains the sample input files

Explaining the logic

We use greedy approach compute which transactions we must undertake.

This is based on the requirement of priority based on "lower supply price - higher demand price".

demand-supply's People

Contributors

mayankmtg avatar

Watchers

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