// sectionSum :: (Number -> Number) -> Number const sectionSum = value => section => value * 256 ** section; // ipSum :: [Number] -> Number const ipSum = ipArray => ipArray.reduceRight((sum, value, section) => sum += sectionSum(value)(3-section)); // ipDifference :: Number -> Number -> Number const ipDifference = ipSum1 => ipSum2 => Math.abs(ipSum1 - ipSum2); // ipSections :: String -> [Number] const ipSections = address => address.split('.').map(section => parseInt(section)); // ipVal :: String -> Number const ipVal = ip => ipSum(ipSections(ip)) // ipsBetween :: (String -> String) -> Number const ipsBetweenCount = startIp => endIp => ipDifference(ipVal(startIp))(ipVal(endIp))
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Daily Challenge #31 - Count IPv4 Addresses
For further actions, you may consider blocking this person and/or reporting abuse