80
9
In a language of your choice, write a program that exactly outputs the characters Hello world!
followed by a newline. The code:
- should not use any character more than twice (alphanumeric, symbol, whitespace...anything)
- should not use any external resources
- should not use any user input
- should not output anything else
An example of a valid python program:
print("He%so world!"%(2*'l'))
An example of an invalid python program (the character 'r' is used three times):
print("Hel"+chr(108)+'o world!')
Winner is whoever has the most votes after 14 days.
EDIT: A winner has been chosen! Thanks all for your work on this question!
3Is it allowed to use a letter more than twice in different case? E.g. "RRrr" – Boann – 2014-01-17T16:18:29.020
2@Boann since I did not specify in the original question, it is allowed (since they are technically different characters). – Josh – 2014-01-17T16:33:51.523
25What about the repeated letter o in the "valid" python example. There also these:- " ' ( ) – Adam Speight – 2014-01-17T16:35:26.180
15@AdamSpeight what do you mean? The letter is only used twice, as per the specs. – Josh – 2014-01-17T16:37:07.267
@josh The first condition need to be rewritten to be more clearer.
should not repeat a character more than twice. Eg alphanumeric, symbol, whitespace...anything – Adam Speight – 2014-01-17T16:40:24.057
5@AdamSpeight ... which is literally the same. – VisioN – 2014-01-17T16:42:00.423
1@VisioN It isn't literally the same. The original makes it more prominent that it reads as no repetition. Eg only one use of a character is permitted (which it is what it's asking). Whereas in my version the condition is much easier to read, as it doesn't break the condition into two halves.
comments doesn't preserve the line breaks which makes it impossible to display an example. – Adam Speight – 2014-01-17T16:53:32.480
@AdamSpeight: Then make an edit if you feel that strongly about it. – Chris Laplante – 2014-01-17T17:29:13.683
1It seems, it con not be done using java? – Prizoff – 2014-01-17T17:57:06.477
1@Prizoff I believe so. – Josh – 2014-01-17T18:15:00.983
4I think you mean a character should not appear more than twice, that is, it should not be repeated more than once. – Michael Kay – 2014-01-17T18:15:23.560
56I guess [tag:brainfuck] is out of the question... – jub0bs – 2014-01-17T18:26:44.370
1No, it's not doable in Java. I've been trying to do it for fun. Impossible to do it with less than two
s
characters. At best, you have to have aclass
word and astatic
word, which is three. – asteri – 2014-01-17T19:40:58.520Do
include <file>
s count? I can't do it in C++ unless they don't. – None – 2014-01-17T21:17:02.463includes do count. – Josh – 2014-01-17T21:23:24.063
1You know that you are dealing with ascii values too much when you see any number (in this case, the vote count of 32) and immediately translate into the appropriate character (Space). I guess Befunge just does this to people. – Justin – 2014-01-18T06:41:09.907
1in your valid example 'l' is used twice! – kBisla – 2014-01-18T17:08:31.793
1@BlueFlame reread the requirements especially the first. – Adam Speight – 2014-01-18T18:35:16.583
@BlueFlame It is ok to use a character more than once. You can use 2 of the same characters. – Dozer789 – 2014-01-18T21:54:56.600
how the first python program be valid if it uses 2
o
s, 2(
, 2)
, 2 " (quote), 2' (apostrophe), the spec only says that "should not use any character more than twice (alphanumeric, symbol, whitespace...anything)", not "should not use any character more than twice (alphanumeric) repetitively" – phuclv – 2014-01-19T06:59:22.927Should this question be protected? I've seen at least 2 answers that weren't answers. – Justin – 2014-01-19T09:51:23.373
In-browser javascript console counter:
function t(s){return [].reduce.call(s,function(n,c){n[c]=1+(n[c]|0);return n},{})}
- usaget('golfcode')
. Escape backslashes as \ to avoid getting literals. – Joel Purra – 2014-01-19T14:26:49.720VB.net (impossible?) Console.WriteLine() As just to output something uses o x 2 e x 3 ( x 1 ) x 1 l x 1 r x 1 Edit Also consider that the minimal about of required ceremony is Module z Sub Main End Sub End Module Also VB doesn't have C#'s escapes sequences \x108 . – Adam Speight – 2014-01-17T19:19:02.690
impossible in D unfortunately as to output anything you need to
import std.stdio;
(3*t) – ratchet freak – 2014-01-20T09:08:53.017The valid python also has two
r
!! – Mehdi – 2014-01-20T12:52:23.307@JeffGohlke Note that you can get a bit farther by substituting an
s
by\u0073
. You can only substitute one because then you'll run out of0
s, so you still can't have a working Java program (you also need 3t
s andi
s). – ARRG – 2014-01-20T17:03:49.680@Mehdi Read the rules again... – Thomas – 2014-01-21T00:22:22.310
1The rules are ambiguous. Your example
print("He%so world!"%(2*'l'))
uses'l'
ando
twice. It also contains multipler"'()
characters in the source, if that matters. – Barry Staes – 2014-01-21T09:55:52.7171Right. The rules say "should not use any character more than twice (alphanumeric, symbol, whitespace...anything)", so you can have TWO of each character. – Rob – 2014-01-21T16:10:59.473
@Lưu Vĩnh Phúc — What are you trying to say ? – Nicolas Barbulesco – 2014-05-15T11:15:12.690
1@NicolasBarbulesco misread. I thought it was non repetition, only one character allowed – phuclv – 2014-05-15T11:29:26.157