TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Xmas.c (1988)

559 点作者 evah超过 1 年前

17 条评论

svat超过 1 年前
The equivalent from the TeX world is `xii.tex`:<p><pre><code> \let~\catcode~`76~`A13~`F1~`j00~`P2jdefA71F~`7113jdefPALLF PA&#x27;&#x27;FwPA;;FPAZZFLaLPA&#x2F;&#x2F;71F71iPAHHFLPAzzFenPASSFthP;A$$FevP A@@FfPARR717273F737271P;ADDFRgniPAWW71FPATTFvePA**FstRsamP AGGFRruoPAqq71.72.F717271PAYY7172F727171PA??Fi*LmPA&amp;&amp;71jfi Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx :76jelse&amp;U76jfiPLAKK7172F71l7271PAXX71FVLnOSeL71SLRyadR@oL RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI I71Fo71dPA!!FRgiePBt&#x27;el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz; ;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,% s$;z zLqs&#x27;.ansZ.Ymi,&#x2F;sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G LcYlaDLbJsW,SWXJW ree @rzchLhzsW,;WERcesInW qt.&#x27;oL.Rtrul;e doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye </code></pre> Put that in a .tex file and run `pdftex` on it, then look at the resulting PDF file, which will look like this: <a href="https:&#x2F;&#x2F;shreevatsa.net&#x2F;post&#x2F;xii&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;shreevatsa.net&#x2F;post&#x2F;xii&#x2F;</a>
评论 #38753232 未加载
评论 #38748553 未加载
anonymousiam超过 1 年前
I grabbed this when it was originally published, but somehow the file name I have is different from the one in this article. Mine is called &quot;carol.c&quot; and I just compiled and ran it on a modern system. The compiler spat out the following warnings:<p>gcc -o carol carol.c<p>carol.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]<p><pre><code> 2 | main(t,_,a ) | ^~~~ </code></pre> carol.c: In function ‘main’:<p>carol.c:2:1: warning: type of ‘t’ defaults to ‘int’ [-Wimplicit-int]<p>carol.c:2:1: warning: type of ‘_’ defaults to ‘int’ [-Wimplicit-int]
评论 #38747417 未加载
评论 #38747982 未加载
评论 #38746966 未加载
fbodz超过 1 年前
This makes me think about kolmogorov complexity. The program here looks like gibberish but produces the desired output, would there be even shorter programs that don&#x27;t look like they make sense but produce the same output? How would you search for these programs?
评论 #38749472 未加载
评论 #38749842 未加载
评论 #38749172 未加载
magerleagues超过 1 年前
Great explanation! And looks like the IOCCC is still going strong in 2023: <a href="https:&#x2F;&#x2F;www.ioccc.org&#x2F;years.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.ioccc.org&#x2F;years.html</a>
评论 #38746927 未加载
IgorPartola超过 1 年前
Fun thing I learned recently about the 12 days of Christmas: every gift is a type of bird. Leaping ladies, lords, all of them.
评论 #38750937 未加载
评论 #38751250 未加载
mdnahas超过 1 年前
My own investigation, from 20+ years ago:<p><a href="http:&#x2F;&#x2F;michaeldnahas.com&#x2F;xmassong&#x2F;index.html" rel="nofollow noreferrer">http:&#x2F;&#x2F;michaeldnahas.com&#x2F;xmassong&#x2F;index.html</a>
mattgodbolt超过 1 年前
Still works on trunk (if you turn off the warning :))<p><a href="https:&#x2F;&#x2F;compiler-explorer.com&#x2F;z&#x2F;hGvs1e9jo" rel="nofollow noreferrer">https:&#x2F;&#x2F;compiler-explorer.com&#x2F;z&#x2F;hGvs1e9jo</a>
GrabbinD33ze69超过 1 年前
This resurfaced a good memory of my last two semesters of university (2022), professor showed us this code snippet right at the start of one lecture.
评论 #38751582 未加载
shimonabi超过 1 年前
Our professor in college got us this in the printed study materials about the C language, so I remember that I typed it in by hand once.
kazinator超过 1 年前
There is a similar task in Rosetta Code: a program to produce the &quot;Old Lady Swallowed a Fly&quot; iteratively growing song.<p><a href="https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;Old_lady_swallowed_a_fly" rel="nofollow noreferrer">https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;Old_lady_swallowed_a_fly</a>
评论 #38748186 未加载
nickdothutton超过 1 年前
IanP was a colleague of mine a lifetime ago. Thanks for reminding me.
willswire超过 1 年前
Wow! A University of Delaware link on Hacker News? Go Hens!
eek2121超过 1 年前
My brain hurts.
queuebert超过 1 年前
One of my favorite things about the IOCCC is that Larry Wall won it twice and then went on to design Perl, which explains a lot.
评论 #38746701 未加载
评论 #38746805 未加载
评论 #38746604 未加载
chris_wot超过 1 年前
That’s a very old version of C. The function signature of main uses the old K&amp;R style for function parameters.<p>I doubt it would compile currently!
评论 #38746919 未加载
评论 #38746657 未加载
评论 #38746688 未加载
评论 #38749196 未加载
评论 #38746690 未加载
sdkgames超过 1 年前
&gt;The program is smaller than even the &#x27;compressed&#x27; form of its output,<p>&gt;and thus represents a new departure in text compression standards.<p>7z and gzip disagree with this statement.
评论 #38747200 未加载
评论 #38747061 未加载
评论 #38746778 未加载
评论 #38747355 未加载
评论 #38746771 未加载
评论 #38751533 未加载
评论 #38748128 未加载
usremane超过 1 年前
Here&#x27;s what Chat GPT came up with:<p>#include &lt;stdio.h&gt; #define o putchar #define p main #define q(a) return a; #define r ) { #define s { #define t for #define u if #define v else #define w while<p>char <i>x=&quot;a partridge in a pear tree.\ntwo turtle doves\nand three french hens, four calling birds, five gold rings;\nsix geese a-laying, seven swans a-swimming,\neight maids a-milking, nine ladies dancing, ten lords a-leaping,\neleven pipers piping, twelve drummers drumming, &quot;; char </i>y[]={&quot;first&quot;, &quot;second&quot;, &quot;third&quot;, &quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;, &quot;seventh&quot;, &quot;eigth&quot;, &quot;ninth&quot;, &quot;tenth&quot;, &quot;eleventh&quot;, &quot;twelfth&quot;};<p>int p() s int i=0, j, k, l; t(;i&lt;12;i++) s printf(&quot;On the %s day of Christmas my true love gave to me\n&quot;, y[i]); j=0, k=0, l=0; t(;x[j];j++) s u(x[j]==&#x27; &#x27; &amp;&amp; (l==i || (l&lt;i &amp;&amp; x[j+1]==&#x27;\n&#x27;))) s u(!k)r k=1; o(&#x27;and &#x27;); } v u(x[j]!=&#x27;\n&#x27;)r o(x[j]); } v r k=0; l++; } } o(&#x27;\n&#x27;); } q(0) }