17
2
Your goal: to write a piece of code that will result in the classic result of "Hello, world!" being printed to STDOUT or equivalent.
Rules: Code must be entirely in printing ASCII. All code must be functional - removal of any single counting character must change the result or cause the code to not function. All variables must be used after assignment. Character and String literals must be necessary to the output - that is, replacement of any character literal or any character within a string literal with another character must be capable of changing the result (and not via the effect of escape sequence - replacing character with backslash or equivalent)
(NOTE: Final rule was edited in)
Scoring: This is where it gets interesting. Highest score wins as determined by number of characters, as per typical code-bowling rules. But repeated use of characters will result in point deductions. Specifically...
- Repeated use of any alphanumeric character (a-z, A-Z, 0-9) will result in a deduction of 3 points per repeat (first use does not result in a deduction).
- Repeated use of basic punctuation ([!?.-,":';]) - including the brackets - will result in a deduction of 2 points per repeat.
- Repeated use of other ASCII characters {`~@#$%^&*_+=|\/><} - including the curly brackets - will result in a deduction of 4 points per repeat.
- Repeated use of spaces, tabs, and newlines will result in a deduction of 1 point per repeat. That is, only the first use of a space, tab, or newline will count towards your total.
Note: comments do not count towards total, although the characters marking the start/end of a comment do. For instance, in C/C++, If you have /* This is a comment */
, then it will count two slashes and two asterisks, but nothing between them.
Some examples (note: using Julia as sample language)...
print("Hello, world!");
Total visible characters: 22
Contains Space: +1
Repeated alphanumerics: -12 for llor
Repeated punctuation: -2 for "
Final score: 22+1-12-2 = 9
print("Hel",char(108),"o, wor",0x108,"d!"); # 0x108 makes a Uint8 that prints as ASCII
Total characters: 43 (does not count any characters after #, which is the comment character)
Contains Space: +1
Repeated alphanumerics: -18 for rr1008
Repeated punctuation: -24 for ()""""",,,,,
Final score: 43+1-24-18 = 2
xy=STDOUT
m="Hello, world!"
print(xy,m);
Total visible characters: 37
Contains Newline: +1
Contains Space: +1
Repeated alphanumerics: -18 for xyllor
Repeated punctuation: -4 for ",
Repeated other ASCII: -4 for =
Final score: 37+1+1-18-4-4 = 13
A couple of invalid pieces of code...
x=2;print("Hello,world!")
Problem: x
is assigned, but not used.
print("Hello,"*" world!")
Problem: *
is unnecessary, result will be the same without it.
k=1
if k>0
print("Hello, world!")
else
print("abcghjmquvxyzABCDEFGIJKLMNOPQRSTUVWXYZ_+*-&|")
end
Problem: The second print
command will not run. Also, removing characters in quote in second print
command will not change output.
x="Hello, world!";
print(x)
Problem: removal of newline will not change result or cause error (in Julia, semicolon is only necessary if multiple commands are on the same line, otherwise just suppresses return value).
print("Hellos\b, world!")
Problem: s
character does not affect result, as it gets erased by \b
. This is acceptable if done through code ("Hello",char(100),"\b, world!"
), but cannot be done via string literals or character literals.
Convenient score-calculator - http://jsfiddle.net/4t7qG/2/ - thanks to Doorknob
Can we take input if it counts toward the score? – FantaC – 2017-12-28T19:51:39.060
I think you may just have fixed code bowling. I'm really curious how this plays out (i.e. if you'll get answers that still find loopholes to exploit), but at least this sounds like the best code bowling specification I've seen so far. – Martin Ender – 2014-06-04T17:05:17.743
1
Seems awfully close to http://codegolf.stackexchange.com/questions/19477/golf-with-a-bowling-ball-hello-world-with-high-complexity-yet-short-code?rq=1 and http://codegolf.stackexchange.com/questions/18721/hello-world-with-limited-character-repetition?rq=1
– Kyle Kanos – 2014-06-04T17:08:29.273Isn't it mostly print hello world with most distinct characters? – Howard – 2014-06-04T17:11:11.123
@KyleKanos While I agree, I think we should give this a try in the interest of attempting to save code bowling.
– Martin Ender – 2014-06-04T17:11:54.530@KyleKanos - this is more than just a character restriction or complexity challenge. It's a game where, to maximise your score, sometimes you'll take a hit along the way. Two steps forward, one step back. And the score is both objective (as opposed to that popularity-contest) and direct (as opposed to the complexity one). You're not trying to impress people with your clever code, you're not trying to obfuscate or overcomplicate it. That's what makes this different. – Glen O – 2014-06-04T17:16:40.327
@GlenO: This seems to be a combination of the two puzzles I linked to but with a new win tag, so it's not really any different than the first link is to the second. – Kyle Kanos – 2014-06-04T17:25:49.037
@KyleKanos - well obviously - they all involve Hello World. Much like this one: http://codegolf.stackexchange.com/questions/307/obfuscated-hello-world - it's the win condition that changes the whole game.
– Glen O – 2014-06-04T17:28:01.9901
This seems relevant to your discussion http://meta.codegolf.stackexchange.com/questions/777/are-two-questions-duplicates-if-they-have-different-scoring-rules
– Martin Ender – 2014-06-04T17:28:58.367@GlenO: I disagree that the win condition changes the puzzle (as suggested by m.buettner's link). Mind you, I'm only not close-voting as duplicates because m.buettner points out that this is to save code-bowling, which I'm okay with. – Kyle Kanos – 2014-06-04T17:38:47.530
@m.buettner - better? – Glen O – 2014-06-04T17:55:28.200
3
I created a JSFiddle where you can put your code and it will automatically figure out your score. Would you be okay with me editing a link to it it in to the post?
– Doorknob – 2014-06-04T18:44:22.803@Doorknob: Ha nice I had just made a python script to do just that. – Claudiu – 2014-06-04T18:46:22.923
Can/should the output contain a final newline? – Dennis – 2014-06-04T20:26:28.307
1@Dennis - if your program produces a newline because of the command, no problem (for instance, println in Julia prints and then adds a newline on the end). But it shouldn't be part of the string. – Glen O – 2014-06-05T03:41:37.367
@Doorknob - thanks, I've edited it in and credited you with it. – Glen O – 2014-06-05T03:57:43.850
Stupid question, is something like
println("Hello, World")
valid? – Knerd – 2014-06-05T08:28:24.980So the goal is to write the longest program, not the shortest, right? – ACarter – 2014-06-05T09:00:16.903
@Knerd - it's almost valid (it should be "Hello, world!" rather than "Hello, World"), but it's not particularly helpful - it has a score of just 3, which is pretty low. – Glen O – 2014-06-05T11:55:25.983
1@ACarter - basically, yes. But the restrictions and the deductions make it non-trivial. – Glen O – 2014-06-05T11:56:10.807
@GlenO, thanks for the reply, yeah thats true. I just asked because I had the idea to use a typdef, but it is probably the worst version :D – Knerd – 2014-06-05T12:18:52.953