[Tutor] Fwd: Re: dynamical program to create subnets CIDR

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 7 17:41:10 EDT 2019


Please use Reply All or reply List when responding to the list.
Otherwise it just goes to the author.

-------- Forwarded Message --------
Subject: 	Re: dynamical program to create subnets CIDR
Date: 	Mon, 7 Oct 2019 19:35:11 +0000 (UTC)
From: 	ose micah <osaosemwe at yahoo.com>
To: 	alan.gauld at yahoo.co.uk



Hello Alan,??

Basically, the algorithm I have in mind is one that takes the first Ip
in the list, and compares it to others in the list. It can definitely be
improved on.??
>From the list of subnets, it pick the first subnet and compares it with
others, such that if the first and second set of 3 digit are same in the
subnet, it pushes this to a temp list, so that it combines all these
subnets into one subnet, and overwrites the new subnet created (which is
the least CIDR block of the subnets in the temp list) and the rest
subnet to a file. If the number of subnets in the file is not less or
equals to four, it continues the process comparing list of subnets.??
Next if the after comparing the first and the second set of 3 digit, it
has not yielded the result needed, it compares the first set of 3 digits
in the IPs left. it create a list of those that are same, and generates
a subnet of least CIDR block to the list left until the least of CIDR is
4 or less than 4.??

Thanks and regards,

Ose Micah.

On Monday, October 7, 2019, 02:54:23 PM EDT, Alan Gauld
<alan.gauld at btinternet.com> wrote:


On 07/10/2019 19:31, ose micah wrote:


> Can anyone help with a program that could compare a list of IPs and
> create the least possible CIDR block sets from these IPs.
>
> for example.
>
> I have a list say:
>
...
>
> I want to reduce this list to:
>
> 10.32.0.0/14
> 202.238.149.0/19
> 10.224.0.0/13
> 10.54.63.0/13



Sorry but I cannot see how you get to the second list
from the first. I think you need to give us a clue what
the high level algorithm is. Don't assume we know your
problem domain. Most of us don't, we know Python.

At a basic level I'd suggest investigating functions
like str.split(), sort(), max/min(). But even that
does not appear sufficient to meet your needs.
Without understanding the criteria I can't guess the algorithm.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list