Skip to content

codezork/merge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interval Merge

Abstract

A Go application to merge overlapping intervals of integers. The intervals must be of the form [1,10][22,23][6,19][2,7]...
A file or direct input can be used to supply intervals. File input is used for big interval quantities.

Usage

interval

You can pass intervals as argument using the command 'interval' followed by :
./merge interval "[1,10][22,23][6,19][2,7]"

file

You can create a file containing intervals in the same form. These intervals can be multilined for better readability. Use the command 'file' followed by the file path:
./merge file ./input.intervals.
An interval must not be ordered by lower bound to upper bound. In case of file-input, also whitespaces will be ignored during parsing.

verbose

If the -v flag (verbose) is used, the application outputs durations of execution and memory consumption.

gendata

You can generate a randomized interval list file using the command 'gendata' followed by the number of intervals to be generated. For better readability every 20 intervals comes a newline. Merge was tested with 10 Mio intervals. The resulting file is 'gen.intervals'. To test duration with generated data type:
./merge -v file ./gen.intervals

Build

There is a Makefile with the following targets:

  • run
    builds and runs directly with some test data
  • build
    builds an executable 'merge' using the version.yaml file
  • test
    builds and runs all test with coverage

make build will build an executable 'merge'

Performance

On my machine MacBook Pro 2.3 GHz 8-Core i9 SSD, merging 1 Mio intervals took less than a second. If more than 100 input intervals are given, they are displayed as count. If more than 100 resulting intervals exit, only the count is displayed.

Development duration

It took about 12h to realize and test all.

About

Coding Task 2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published