XKCD-CS/Golf

From XKCD Wiki
Jump to: navigation, search

You are in the middle of a parabolic dish. Somebody has filled it with sand. Numerous barely identifiable objects are strewn across the surface, partly buried.

There is a sign:

Code Golf Rules
A sequence of consecutive identical non-whitespace symbols has a value equal to its length, multiplied by the fraction of the program composed of symbols identical to them.
A sequence of consecutive whitespace characters has a value equal to the Euclidean norm of the lengths of all distinct sequences of whitespace (with newline and carriage return considered to have a length of zero each, and tabs considered to have a length of two), divided by the Euclidean norm of the lengths of all distinct sequences of non-whitespace.
otherwise, ignoring whitespace
Each punctuation symbol has a value equal to the fraction of the program not composed of punctuation. ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
Each decimal digit has a value equal to the square of one-tenth its literal value, multiplied by the fraction of the program composed of digits. 0 1 2 3 4 5 6 7 8 9
All other symbols are considered identical to each other, and individually have a value equal to the fraction of the program that is neither punctuation nor digits.
Low scores are better than high scores.
Please, no g— statements! Keep our sand trap safe!

At the bottom of the sign is a warning diagram.

You see a complete set of fairly dusty programming tools. Some are quite exotic.

Exits: Up...? Maybe you can compile your way out.

[edit] Hole 0

  • Implement the scoring rules.