Skip to navigation

Renesys Corp


Challenge: No Zealand

The bzip2'd file no_zealand.txt.bz2 (md5sum: 6f5ef2d9f9fdd46e508b67a607dd1b98 ) contains data about 100,000 networks.

A customer is interested in a particular subset of the networks in that file. Find the networks that interest them.

  1. They only care about networks in locations having more than 10 but fewer than 100 networks (or 11-99, inclusive)
  2. A location is a distinct tuple of (country,region,city) -- parts can be empty.
  3. Exclude all locations in New Zealand (NZ), Belgium (BE), or the state of Hawaii (HI).
  4. Sort all distinct networks from these locations lexicographically (as strings, using C Locale ordering).
  5. Take the 10,000th network (1-indexed -- the 'first' element in the list is element 1)
  6. Enter the network (as a string), your email, and your code into the form below and submit it.

File format:

Each line contains these fields (tab-separated):
network source country region city score

Example

For this example file, there 13 valid prefixes:

    124.146.191.224/27
    212.176.166.0/24
    221.244.225.136/29
    64.192.124.0/24
    66.251.68.112/28
    67.172.50.0/24
    69.218.106.104/29
    75.63.165.120/29
    79.187.60.192/28
    80.120.28.60/30
    84.246.214.0/23
    86.47.186.32/27
    90.80.31.0/28
    

All of them are part of the same LOCATION: ('JP', '', ''), the only location with 11-99 networks. Since Japan isn't in Belgium, New Zealand, or Hawaii, we include it. If we wanted the third network, our answer would be 221.244.225.136/29

By contrast, suppose we had more lines like this:

58.157.236.184/29 TRUTH BE Brussels Brussels 313.18

Since this is in Belgium, it should be excluded, even if (BE,Brussels,Brussels), had 31 networks (ie., in (10,100))!

Challenge Specific Notes

  • Runtime should be nearly instant on a modern machine (one example, using cPython: 1.5 sec.).

General Notes:

  • This should be simple. Coding it should take about 30 minutes! If you're two hours in, reconsider your choice of language, and check your assumptions.
  • Use whatever langauge you like! To impress us, show more than one approach, or use your favorite novelty/Next Big Thing™ language (Haskell, Scheme, Clojure, Postscript, etc!). (We're not going to run the code, but we want to see your work.)

Submit your answer*


(plain text and pdf preferred)

*Important Legal Note: Renesys exclusively owns all rights and economic interests in any code submissions and all Intellectual Property embodied therein or related thereto. As such, the person submitting code to Renesys hereby assigns and agrees to assign, irrevocably and unconditionally, to the fullest extent permitted by law under any interpretation of the relationship between the parties, all right, title and interest (including without limitation all Intellectual Property rights embodied therein or associated therewith) in and to the submission.