Readit News logoReadit News
nemoniac commented on Janet: Lightweight, Expressive, Modern Lisp   janet-lang.org... · Posted by u/veqq
nemoniac · a month ago
The first code example on that page claims to solve "the 3SUM problem".

According to [1], "the 3SUM problem asks if a given set of n real numbers contains three elements that sum to zero."

It's not clear to me what problem the Janet code solves but it's clearly not that 3SUM problem.

On the example input of

    @[2 4 1 3 8 7 -3 -1 12 -5 -8]
it outputs

    @[@[6 1 7] @[2 5 10] @[1 2 9] @[4 6 9] @[3 0 9] @[6 2 0]]
For what it's worth, here's some Common Lisp code that does solve the 3SUM problem in O(n^2).

    (defun 3sum (a)
      (let ((h (make-hash-table))
            (len (length a)))
        (dotimes (i len)
          (setf (gethash (aref a i) h) t))
        (dotimes (i len)
          (dotimes (j i)
            (when (gethash (- (+ (aref a i) (aref a j))) h)
              (return-from 3sum t))))))
    
    (3sum #(2 4 1 3 8 7 -3 -1 12 -5 -8))
    ;; => t

[1] https://en.wikipedia.org/wiki/3SUM

nemoniac commented on Reading NFC Passport Chips in Linux   shkspr.mobi/blog/2025/06/... · Posted by u/robin_reala
Farbklex · 2 months ago
I haven't found the docs for the Dutch version but this article shows the content of the MRZ of a French drivers license. They seem to match the Dutch ones as well.

https://trustdochub.com/en/mrz-strip-french-driving-licence/...

nemoniac · 2 months ago
Only partially. At least for my Dutch licence. It contains neither holder's last name nor end date.

It does start with D1NLD. Then a single digit which is not the checksum of the foregoing (using the passport checksum algorithm). Then the document number. Then some letters and numbers I can't make any sense of. It ends with a correct global checksum for all of the foregoing.

nemoniac commented on Reading NFC Passport Chips in Linux   shkspr.mobi/blog/2025/06/... · Posted by u/robin_reala
nemoniac · 2 months ago
Here's a tidied up version of the Python code to generate the MRZ from the passport data. It also corrects a padding error.

    https://pastebin.com/k0Tty22a
My Dutch driver's licence has a single MRZ-like line across the bottom. It seems to encode the country and licence number but I can't make any sense of the rest of the line. Anyone have any leads?

nemoniac commented on Direct TLS can speed up your connections   marc-bowes.com/postgres-d... · Posted by u/tanelpoder
nemoniac · 3 months ago
Direct TLS can speed up your postgreSQL connection

u/nemoniac

KarmaCake day4073October 25, 2008View Original