2 ms·
Or we just update it so it evals to the same answer. :)
by jedberg 16y ago
Or we just update it so it evals to the same answer. :)
- jacquesm 16y agoInteresting sub-problem, work out how many possible combinations there are given that SOA serial numbers have to be monotonically increasing and you need the same number of '1' bits in them. Hey, there is actually a slight ambiguity in the specification there, after all you could be referring to the serial number as used in the DNS or the ascii characters representing that serial number in the record. Those would have different numbers of '1' bits. Are there two valid solutions or just one?
- tptacek 16y ago2,380,770 (ie, "enough"). Most of the wiggle room is in the less-significant bits, so the SOA serial is easy to fit to the requirement.
- deleted 16y ago[deleted]
- jacquesm 16y agoHm, I get 22,540,845. Now you have me worried :)
- tptacek 16y agoThe serial number is 31 bits long. I brute forced it, with the dumbest ruby one-liner ever (it involved 'count("1")').
- jacquesm 16y agoSerial numbers are unsigned 32 bit numbers as per http://www.ietf.org/rfc/rfc1035.txt http://www.ietf.org/rfc/rfc1035.txt aren't they?
- tptacek 16y agoNo; the RFC says the largest serial is 0x7fffffff.
- jacquesm 16y agoHm, that's confusing, the one RFC linked above says: "SERIAL The unsigned 32 bit version number of the original copy of the zone. Zone transfers preserve this value. This value wraps and should be compared using sequence space arithmetic. " Whereas the other says: "Serial numbers may be incremented by the addition of a positive integer n, where n is taken from the range of integers [0 .. (2^(SERIAL_BITS - 1) - 1)]. For a sequence number s, the result of such an addition, s', is defined as s' = (s + n) modulo (2 ^ SERIAL_BITS) " and " Addition of a value outside the range [0 .. (2^(SERIAL_BITS - 1) - 1)] is undefined." Where SERIAL_BITS apparently is the 32 from the other RFC. So you can add serial numbers as long as they're below or equal to 0x7fffffe but the result of the addition is still a valid serial number, and you can happily increment past 0x7ffffffe only you're no longer allowed to add that number to another serial number. http://tools.ietf.org/html/rfc1982 http://tools.ietf.org/html/rfc1982 Interesting.