in reply to Better way of writing "find the missing number(s)"
Not a better way perhaps, but a solution using Set::IntSpan.
#!/usr/bin/perl use strict; use warnings; use Set::IntSpan; my @arr = (19,17,22,23,24,15,16,25..35); my $set = Set::IntSpan->new(\@arr); print join ' ', $set->holes->elements;
Prints:
18 20 21
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Better way of writing "find the missing number(s)"
by pritesh_ugrankar (Monk) on Apr 03, 2017 at 18:44 UTC |