A Silly Task
October 22, 2019
The quote mark makes the word five
a symbol, which is self-evaluating:
Chez Scheme Version 9.5 Copyright 1984-2017 Cisco Systems, Inc. > 'five five
You can run the program at https://ideone.com/4HSMdQ, but it isn’t the same, because ideone requires the display
keyword.
This time – no cheating and no real golfing…. OK – so works up to about 100K as I haven’t got the and/, rule right above that …. The critical bits are “-s $0” gives the size of the current file!, and stuff after END is ignored – added to test code for different lengths…
Here is a very naive solution in R7RS Scheme that I feel is more in
keeping with the spirit of the question, which I interpreted in the
vein of Quines.
With that interpretation (which I realize may not be the author’s
intention), the solutions so far by @programmingpraxis and James Smith
are typically considered ‘”Cheating” quines”:
https://en.wikipedia.org/wiki/Quine_(computing)#%22Cheating%22_quines
Let’s use the excellent Python num2words library to make things easier. Since num2words is multilingual, and in the interests of international solidarity, we’ll generate solutions of the form “print(…)” in a variety of languages:
Output (note that we check the encoded length, not the number of characters):
Here’s a solution in Python.
Output:
Here’s a Python meta solution (ie. run the program to make a program), no libraries, no cheating. Iterate to a fix point to find the right length (proof of termination welcome):
Now we have:
A solution in Common Lisp using the loop syntax and built-in english language number formatting (“~r”).