News for hackers. Stuff that matters.
Re:Find SF parking cops by geor9e on Tuesday September 23, 2025 @05:56PM (#45353272)
"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...

Re:Find SF parking cops by Aloisius on Tuesday September 23, 2025 @07:23PM (#45354134)
It's just x % 7.

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

Re:Find SF parking cops by pertsix on Tuesday September 23, 2025 @07:26PM (#45354162)
But why?
Re:Find SF parking cops by Aloisius on Tuesday September 23, 2025 @07:30PM (#45354211)
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

Re:Find SF parking cops by dragontamer on Wednesday September 24, 2025 @05:30PM (#45366208)
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.

Re:Find SF parking cops by xvedejas on Tuesday September 23, 2025 @08:02PM (#45354473)
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.
Re:Find SF parking cops by nielsole on Tuesday September 23, 2025 @09:25PM (#45355121)
Isn't 11 the smallest divisor that gives those guarantees?
Re:Find SF parking cops by consp on Wednesday September 24, 2025 @03:44AM (#45357454)
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.

Re:Find SF parking cops by andruby on Wednesday September 24, 2025 @03:56AM (#45357535)
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

Re:Find SF parking cops by refurb on Tuesday September 23, 2025 @06:28PM (#45353617)
Nice observation!