Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"each possible ticket number follows a pattern: add 11, except add 4 if the last digit is 6…Only God knows why"

That pattern feels suspiciously like how a tacked-on modulo check-digit would act.

It seems the real citation number, x, excludes the last digit, and you only needed to +1 increment to it.

Then they tack on a last digit, a check-digit, of (x+1) mod 7. That would be the same pattern.

The contract for the system does have the clause "validate the data transcribed from handwritten Citations…a check-digit algorithm to control errors in the Citation number field" https://www.sfmta.com/sites/default/files/reports-and-docume...



In college we discovered everyone's ID number was evenly divisible by 13. Presumably it's because that's the smallest number you'd need so that you could detect any one digit being incorrect, or two adjacent digits being swapped (I think?). Or that it's just very easy to implement the increment when assigning new numbers.


Isn't 11 the smallest divisor that gives those guarantees?


It's what quite a few banks used to use as a check digit, maybe that where you remember it from. But it depends on the size of the number you want to verify and exactly what system is employed. Lots of banks used 9 or 10 digit numbers which worked with a "11 check". Nine was also often used on smaller numbers.

You can use any prime afaik for this example but your number space will be limited.


For 2 digit checks it's often mod 97 (largest prime < 100) because it can detect all single-digit errors and most adjacent digit transpositions.

Used in IBAN bank account numbers, EU VAT numbers (UK, FR, BE), etc


It's just x % 7.

They started their example pattern with an citation number 984,946,606 they earlier said wasn't valid rather than 984,946,605 given initially (and shown in the image).


But why?


Because it means that 85.7% of all mistakes will be caught by very simple software checks before getting to your system. (85.7% == 6/7).

Check digits in your userdata is an old trick and is very useful in practice. Maybe modern systems should aim for something better than %7 but it's a good starting point as a system design concept.


Just a mistake, I imagine. Probably just typed the pattern out starting with the last number they wrote, which unfortunately was invalid.

> I was looking at ticket 984,946,605. When I type in 1 higher, 984,946,606, no ticket is found. ... So the ticket after 984,946,606 is actually 984,946,610


Nice observation!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: