News for hackers. Stuff that matters.
Re:Widest Roman Prime by raffy on Saturday February 06, 2016 @02:54AM (#11046953)
Simple solution in Mathematica: http://i.imgur.com/2iBIRwN.png
Re:Widest Roman Prime by jdiez17 on Saturday February 06, 2016 @07:39AM (#11047532)
I like this solution the most. Some questions on @wacnt (like this one) can't be answered because Wolfram Alpha's NLP fails to recognize the algorithm implicit in the question, but if it was able to translate the problem statement into a machine-readable form, this would be very close to it.

Edit: Some background on @wacnt: https://docs.google.com/document/d/17me2A-SG5Z0Mr9Xd-a1kT1HQ...

Re:Widest Roman Prime by tolmasky on Friday February 05, 2016 @09:09PM (#11046161)
Here it is in JavaScript (feel free to play around with it): https://tonicdev.com/tolmasky/widest-roman-prime

Took me only a couple of minutes since it was mainly just searching for the right npm packages to piece together. Say what you like about micro libraries, but for explorations like this it really makes JavaScript in a league of its own.

Re:Widest Roman Prime by ktRolster on Saturday February 06, 2016 @02:31AM (#11046919)
> Say what you like about micro libraries, but for explorations like this it really makes JavaScript in a league of its own.Say what you like about micro libraries, but for explorations like this it really makes JavaScript in a league of its own.

Indeed, we spend so much time arguing about programming languages, when in reality the presence or absence of libraries is much more important.

Re:Widest Roman Prime by epalmer on Saturday February 06, 2016 @07:01AM (#11047387)
> Indeed, we spend so much time arguing about programming languages, when in reality the presence or absence of libraries is much more important.

+1,+1

Re:Widest Roman Prime by omk on Saturday February 06, 2016 @04:49AM (#11047150)
That's the exact reason I believe in Javascript. Exploration and when you need something done quick and dirty.
Re:Widest Roman Prime by Illniyar on Saturday February 06, 2016 @12:05AM (#11046636)
You are missing the last step, using the "times new roman" font.
Re:Widest Roman Prime by tolmasky on Saturday February 06, 2016 @02:22AM (#11046903)
Its on line 26 (have to scroll down to see it).
Re:Widest Roman Prime by lisper on Friday February 05, 2016 @08:52PM (#11046116)
Should have just done it in Common Lisp. Roman numeral formatting is built-in.

    ? (format nil "~@r" 3989)
    "MMMCMLXXXIX"
Re:Widest Roman Prime by melloclello on Friday February 05, 2016 @08:53PM (#11046120)
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.
Re:Widest Roman Prime by lisper on Friday February 05, 2016 @09:18PM (#11046191)
Actually, that's pretty easy too in CCL. It has a very nice ObjC bridge.
Re:Widest Roman Prime by tosseraccount on Friday February 05, 2016 @10:56PM (#11046489)
20 bits would do it.
Re:Widest Roman Prime by akkartik on Friday February 05, 2016 @09:08PM (#11046158)
But would the font make any difference to the answer?
Re:Widest Roman Prime by astrange on Friday February 05, 2016 @10:12PM (#11046366)
It asks for the widest string in pixels in a proportional font, so the different letters matter.
Re:Widest Roman Prime by gpvos on Saturday February 06, 2016 @06:00AM (#11047256)
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.
Re:Widest Roman Prime by mgraczyk on Friday February 05, 2016 @10:50PM (#11046469)
The problem is underspecified because it does not define under which renderer the text should be measured. Kerning could reorder some of the close ties.
Re:Widest Roman Prime by lziest on Friday February 05, 2016 @11:42PM (#11046582)
I thought 3888 will be wider than 3889 because VIII certainly feels wider than IX but I am not font expert so I don't know
Re:Widest Roman Prime by khedoros on Friday February 05, 2016 @11:49PM (#11046592)
But it wouldn't be a prime.
Re:Widest Roman Prime by lziest on Saturday February 06, 2016 @01:28AM (#11046800)
ah missed that. Thanks!
Re:Widest Roman Prime by kwhitefoot on Saturday February 06, 2016 @02:12PM (#11049227)
Strictly speaking that's the widest modern usage Roman prime under 4000.

The actual Romans were inconsistent in their use of the subtractive principle, see http://www.straightdope.com/columns/read/1371/what-is-the-pr...

So there might be ways to construct a wider one.

Re:Widest Roman Prime by agentgt on Saturday February 06, 2016 @05:01PM (#11050150)
Its funny with all these new sort of bracket like functional programming languages with similar syntax it actually took me a minute to figure out that the code is Swift(probably lack of experience)... Looks like Scala.. no scala doesn't use let.. is it Rust.. nope not Rust.. rust does not use "import".. can't be Ocaml or F# because of no brackets... ah UIKit.
Re:Widest Roman Prime by revx on Friday February 05, 2016 @11:40PM (#11046579)
The next question that popped into my head is, what's the thinnest Roman Prime?

Took me about sixty seconds before I realized that was a stupid question :)

Re:Widest Roman Prime by dewiz on Friday February 05, 2016 @11:55PM (#11046605)
Depends, monospaced font or not? It's either 2 or 5
Re:Widest Roman Prime by melloclello on Friday February 05, 2016 @08:53PM (#11046119)
Wow, Swift is perfect for doing this kind of thing
Re:Widest Roman Prime by fishnchips on Saturday February 06, 2016 @04:54AM (#11047158)
So it seems but mostly because of the UI component where you can calculate the width of the resulting text without having to hardcode the width of individual characters.
Re:Widest Roman Prime by AstroJetson on Friday February 05, 2016 @09:03PM (#11046141)
The challenge wasn't print the largest prime under 4000, it was find the prime with the most digits. So the lisper example gave the wrong answer. Still need to generate the prime, count the digits and return the one with the most digits. No sure that the lisp version would be less lines of code, but I'll guess a recursive version would be close
Re:Widest Roman Prime by Buge on Friday February 05, 2016 @09:16PM (#11046184)
It's not to find the one with the most digits. It's to find the widest one in Times New Roman. Times New Roman is not a fixed-width font, so the widest one might have less digits than some other one. For example I is less wide than M.
Re:Widest Roman Prime by cyphar on Friday February 05, 2016 @11:15PM (#11046518)
Haha. Funny.