Code Golf: Code Golf: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎{{header|Wren}}: Afterthought.)
(→‎{{header|Wren}}: Shorter solution for the second part.)
Line 14: Line 14:
Code Golf
Code Golf
</pre>
</pre>
To print the string "Code Golf" ''with'' the quotation marks but with no quotation marks in the script itself would require a minimum of 105 characters (109 including the \n's).
To print the string "Code Golf" ''with'' the quotation marks but with no quotation marks in the script itself would require a minimum of 90 characters (92 including the \n's).
<lang ecmascript>class Code{}
<lang ecmascript>class f{}
for(c in[-66,-33,11,0,1,-68,-29,11,8,2,-66])System.write(String.fromByte(c+100))
class Golf{}
f</lang>
var q=String.fromByte(34)
System.writeAll([q,Code,String.fromByte(32),Golf,q])
Golf</lang>


{{out}}
{{out}}

Revision as of 16:59, 9 December 2021

Code Golf: Code Golf is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Show the shortest possible program that will emit the string “Code Golf”, without the quotation marks and without anything after the final “f”.

Wren

Well, this has no quotation marks and there's nothing after the final "f" but it's a bit lengthy at 76 characters (79 if you count the implicit \n at the end of the first three lines). Note that Wren's single pass compiler allows the last line though it does nothing. <lang ecmascript>class Code{} class Golf{} System.writeAll([Code,String.fromByte(32),Golf]) Golf</lang>

Output:
Code Golf

To print the string "Code Golf" with the quotation marks but with no quotation marks in the script itself would require a minimum of 90 characters (92 including the \n's). <lang ecmascript>class f{} for(c in[-66,-33,11,0,1,-68,-29,11,8,2,-66])System.write(String.fromByte(c+100)) f</lang>

Output:
"Code Golf"