Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 1.78 KB

41-count-ip-addresses.md

File metadata and controls

18 lines (17 loc) · 1.78 KB

Problem:

Implement a function that receives two IPv4 addresses, and returns the number of addresses between them (including the first one, excluding the last one).

All inputs will be valid IPv4 addresses in the form of strings. The last address will always be greater than the first one.


Examples

ips_between("10.0.0.0", "10.0.0.50")  ==   50 
ips_between("10.0.0.0", "10.0.1.0")   ==  256 
ips_between("20.0.0.10", "20.0.1.0")  ==  246
ipsBetween("10.0.0.0", "10.0.0.50")  ===   50 
ipsBetween("10.0.0.0", "10.0.1.0")   ===  256 
ipsBetween("20.0.0.10", "20.0.1.0")  ===  246
   first    |    last     | ips_between
------------+-------------+-------------
 '10.0.0.0' | '10.0.0.50' |      50 
 '10.0.0.0' |  '10.0.1.0' |     256 
'20.0.0.10' |  '20.0.1.0' |     246

Solution