Giter VIP home page Giter VIP logo

extents's Introduction

SPECIFICATION

Design a program to read a list of number pairs representing closed ranges from
a file called "extents.txt". It should also read a list of points from a file
called "numbers.txt".  Example files and format specifications are given below.

The required function of your code is to write, to standard output, the number
of ranges that contain each point. You should maintain the same ordering as the
input points, one result per line. A point P is contained within a closed range
[X,Y] if X <= P <= Y.

"extents.txt" contains the ranges, one per line, with each line in the format
"A <whitespace> B". The maximum size of this file is fifty million entries.
"numbers.txt" contains a list of points, one per line. The number of points is
potentially extremely large, perhaps numbering many billions. Either file may
contain a number of duplicates, and may or may not end with a <newline>.

The input can be assumed to be valid, given the above specification, and all
numbers can be represented by unsigned integers.

To make it easier for us to compile and test your code, please put all of the
source code (no matter how large) into a single file called "extents.cpp".
Ensure that, when executed without any arguments, the solution reads from
"extents.txt" and "numbers.txt" in the current directory and writes the
result to standard output.

It is your responsibility to ensure that the solution compiles and runs with
no, or very superficial, editing required.  Write your solution using only
C++ 03 Standard code, including the STL if you wish.

---

Example 1:

extents.txt
  0   11
105  121
122  123
  1   32

numbers.txt
 1
 2
 5
13
62
28
62
16
33

output
1
1
1
1
0
1
0
1
0

---

Example 2:

extents.txt
0 8
0 8

numbers.txt
4
4

output
2
2

---

Example 3:

See attachment expected.txt

extents's People

Watchers

 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.