#range #integer #numbers #packing

range_rover

Function to pack integers into ranges

5 releases

new 0.1.4 Dec 12, 2024
0.1.3 Dec 10, 2024
0.1.2 Jul 17, 2023
0.1.1 Oct 16, 2022
0.1.0 Oct 16, 2022

#722 in Algorithms

Download history 18/week @ 2024-09-23 2/week @ 2024-09-30 1/week @ 2024-10-07 1/week @ 2024-10-28 297/week @ 2024-12-09

297 downloads per month
Used in roomor

MIT license

10KB
175 lines

Function to pack integers into ranges.

Latest version

Takes a custom sequence of integers and produces a sorted vector of ranges.

Example:

use range_rover::range_rover;

let input = vec![-1, -2, 2, 0, 7, 10, -4, 1, 3, 6, 10, -3, 4, 9, 8];
let result = range_rover(input);
assert_eq!(result, vec![-4..=4, 6..=10]);

Takes a custom sequence of integers and range, produces a sorted vector of excluded ranges in range.

Example:

use range_rover::missed_in_range;
let input = vec![-1, -2, 2, 0, 7, 10, -4, 1, 3, 6, -3, 10, 4, 9, 8, -2];
let missed = missed_in_range(input, -10..=20);
assert_eq!(missed, vec![-10..=-5, 5..=5, 11..=20]);

Dependencies

~465KB