TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Widest Roman Prime

104 pointsby kellysuttonover 9 years ago

10 comments

raffyover 9 years ago
Simple solution in Mathematica: <a href="http:&#x2F;&#x2F;i.imgur.com&#x2F;2iBIRwN.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;2iBIRwN.png</a>
评论 #11047532 未加载
tolmaskyover 9 years ago
Here it is in JavaScript (feel free to play around with it): <a href="https:&#x2F;&#x2F;tonicdev.com&#x2F;tolmasky&#x2F;widest-roman-prime" rel="nofollow">https:&#x2F;&#x2F;tonicdev.com&#x2F;tolmasky&#x2F;widest-roman-prime</a><p>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.
评论 #11046919 未加载
评论 #11047150 未加载
评论 #11046636 未加载
lisperover 9 years ago
Should have just done it in Common Lisp. Roman numeral formatting is built-in.<p><pre><code> ? (format nil &quot;~@r&quot; 3989) &quot;MMMCMLXXXIX&quot;</code></pre>
评论 #11046120 未加载
评论 #11046978 未加载
mgraczykover 9 years ago
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.
lziestover 9 years ago
I thought 3888 will be wider than 3889 because VIII certainly feels wider than IX but I am not font expert so I don&#x27;t know
评论 #11046592 未加载
kwhitefootover 9 years ago
Strictly speaking that&#x27;s the widest modern usage Roman prime under 4000.<p>The actual Romans were inconsistent in their use of the subtractive principle, see <a href="http:&#x2F;&#x2F;www.straightdope.com&#x2F;columns&#x2F;read&#x2F;1371&#x2F;what-is-the-proper-way-to-style-roman-numerals-for-the-1990s" rel="nofollow">http:&#x2F;&#x2F;www.straightdope.com&#x2F;columns&#x2F;read&#x2F;1371&#x2F;what-is-the-pr...</a><p>So there might be ways to construct a wider one.
agentgtover 9 years ago
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&#x27;t use let.. is it Rust.. nope not Rust.. rust does not use &quot;import&quot;.. can&#x27;t be Ocaml or F# because of no brackets... ah UIKit.
revxover 9 years ago
The next question that popped into my head is, what&#x27;s the thinnest Roman Prime?<p>Took me about sixty seconds before I realized that was a stupid question :)
评论 #11046605 未加载
melloclelloover 9 years ago
Wow, Swift is perfect for doing this kind of thing
评论 #11047158 未加载
评论 #11046138 未加载
AstroJetsonover 9 years ago
The challenge wasn&#x27;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&#x27;ll guess a recursive version would be close
评论 #11046184 未加载
评论 #11046186 未加载