Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Better way of writing "find the missing number(s)"

by Cristoforo (Curate)
on Apr 03, 2017 at 18:15 UTC ( [id://1186867]=note: print w/replies, xml ) Need Help??


in reply to Better way of writing "find the missing number(s)"

Hi pritesh_ugrankar

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

    Hi,

    Thanks for the update. I didn't know about that module.

    Thinkpad T430 with Ubuntu 16.04.2 running perl 5.24.1 thanks to plenv!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2024-03-29 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found