Skip to content

Comment on Widest Roman Prime

Comments

Should have just done it in Common Lisp. Roman numeral formatting is built-in.

    ? (format nil "~@r" 3989)
    "MMMCMLXXXIX"

I'd imagine it's not easy to render the text out into Times without UIKit or equivalent? Pretty cool that it has that built in, though.

Actually, that's pretty easy too in CCL. It has a very nice ObjC bridge.

20 bits would do it.

But would the font make any difference to the answer?

It asks for the widest string in pixels in a proportional font, so the different letters matter.

Since most proportional fonts have somewhat similar widths, probably not. But if you just look at the longest string (or use a non-proportional font) there will be four roman numbers of equal length/width.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.