chillitom / extents Goto Github PK
View Code? Open in Web Editor NEWsolution to an old coding challenge of forgotten origin
solution to an old coding challenge of forgotten origin
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.