Skip to content

max-min-median/IntervalSet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

class IntervalSet

An IntervalSet class I wrote to assist in solving AOC 2022 #15.

And revised while solving AOC 2016 #20 😆

Installation

const IntervalSet = require ('./IntervalSet');

Interval class

Method Description
(static) parse(str, throws=true) Parses a string (e.g '(3, 4]') into an Interval
isValid() Returns true if the Interval is valid
overlap(other) Finds the intersection (A∩B) of two Intervals
merge(other) Finds the union (A∪B) of two Intervals
remove(other) Returns an array of 2 Intervals obtained by subtracting other from this
equals(other) Checks if two Intervals are identical
toArray() Returns an array representation of the Interval
toString() Returns a string representation of the Interval in interval notation
toInequality() Returns a string representation of the Interval as inequalities

IntervalSet class

Method Description
toArray() Returns an array representation of the IntervalSet
union(b) Finds the union (A∪B) of two IntervalSets
intersect(b) Finds the intersection (A∩B) of two IntervalSets
complement() Finds the real complement (A') of an IntervalSet
subtract(b) Finds the subtraction (A\B) of two IntervalSets
toString() Returns a string representation of the IntervalSet in interval notation
toInequality() Returns a string representation of the IntervalSet as inequalities

About

IntervalSet class written in JS. Performs operations on intervals of real numbers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors