-4
\$\begingroup\$

Your mission is to write a program that prints "Hello World!". Simple?

The text must be human readable and should not be "|-| € |_ |_ 0 // 0 |? |_ |) \./" or something like that.

The program should not contain:

  • Newline character
  • Any characters in the string "Hello World!" including whitespace (whitespace outside strings is allowed)
  • Graphics (it must be run on text console (or master boot record in text mode)
  • Number constants that represent chars (Ascii-values, Hex chars)
  • Any simple tricks that create above numbers (ex. 36*2 or 176/2-1 (72, ASCII code of "H") )
  • Non-ASCII chars
  • Web request
  • User input
  • Over 1000 chars
  • Random numbers

It can contain:

  • Ascii-art
  • system calls that do not return letters (a-z and A-Z)
  • h, e, l, o, w, r, d and ! chars outside strings or equal datatypes

It is possible and allowed to change line by going over line max width (program must detect that itself). Linux command

stty size

may help.

Fewer chars are better.

Basically, write 'Hello World' in Ascii Art.

\$\endgroup\$

closed as unclear what you're asking by user80551, ProgramFOX, Timtech, Martin Ender, syb0rg Jul 5 '14 at 0:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ "Less chars is better" -> should this be tagged code-golf? And restricted-source? \$\endgroup\$ – Digital Trauma Apr 20 '14 at 21:13
  • \$\begingroup\$ Edit1: over 1000 chars and random numbers forbidden, because cat /*v/uandm and other like this \$\endgroup\$ – Hannes Karppila Apr 21 '14 at 7:26
9
\$\begingroup\$

Mathematica

n is an integer (in base 10).

IntegerDigits[n, 2] is a list of digits {0,1} that, when concatenated, represent n in base 2.

a=ArrayReshape[ IntegerDigits[n, 2], {19, 130}] is the same digit list rearranged as a grid of 0's and 1's with the dimensions {19, 130}.

a/. {1 -> Style["b", 0], 0 -> Style["*", 16]} replaces each 1 with "b" of font size 0 (hence it is invisible) and replaces each 0 with "*" of font size 16.

Grid[%, Spacings-> 0] tightly displays the array, with replacements. (% stands for the line of code just preceding.)

n = 35001712241657190367892609813472861877431771881809334927846103886350214620897333001318391750688831360911930936377842577561578307677143958805011717980866099960819297494949545473701708671861367649525697579614849813048033148938384921009819295565066663593631828895192249784580492554132824237605034894192899878952441264004931502456152233835512128208573340080592412541607535529943162874085478980356198477815840725568296012406592398594861031009108478191718964371749381682556005188569781665817649936105396104242935885784130227679335972626450197115544027612921177483696531170727698036575934297259107966503600164537149096917592511980213534973597038276657982204662616524347887277731541480128061438343931154467720012975561086600146498015257664764847849471;
Grid[ArrayReshape[ IntegerDigits[n, 2], {19, 130}] /. {1 -> " ", 0 -> Style["*", 16]}, 
   Spacings -> 0]

image

\$\endgroup\$
  • \$\begingroup\$ Is the " " legal? Wondering because of "...including whitespace..." in the character restrictions. \$\endgroup\$ – Geobits Apr 20 '14 at 21:37
  • 2
    \$\begingroup\$ Just to be safe, I replaced spaces with the letter b of font size 0. \$\endgroup\$ – DavidC Apr 20 '14 at 21:45
  • \$\begingroup\$ This contains an h, an e, an l, ... \$\endgroup\$ – Doorknob Apr 20 '14 at 21:48
  • \$\begingroup\$ @Doorknob I've found a way to eliminate the h and the l, but no solution yet for the e. \$\endgroup\$ – DavidC Apr 20 '14 at 22:34
  • 1
    \$\begingroup\$ It still contains an l and a d as well. \$\endgroup\$ – Doorknob Apr 21 '14 at 2:28
4
\$\begingroup\$

J - 59 or 84 char

Two versions, depending on how you define 'human-readable'. Any modifications to the resulting ASCII art would ultimately be based on this kind of compression scheme.

,.'#'#~"0#:86235578437 123845917517 91625269844 92707043917
,._45#&'#'"0\#:36761300340830444705259651524275206394141032533795647996053048645081x

The first version works by taking its list of numbers, expanding them into bitvectors (#:), using those to select (#~) how many '#' to take for each point ("0) in the matrix, and then running the result (a 2D matrix of strings of length at most 1) into a matrix of characters (,.).

The second does the same thing, except it's shorter—by one character, mind you!—to pack all of its bitvectors into a single extended precision number, which you then take 45 bit cuts (_45(blah)\) of.

Here's what they look like:

screenshot of jconsole running code http://i.snag.gy/XzYYa.jpg

\$\endgroup\$
1
\$\begingroup\$

Java generating the Strings only from a 0 as integer; 391 chars

class A{static int a=0,b=a++,e=a++,f=a/a;static char p(String s){return(char)Byte.parseByte(s,a);}public static void main(String[]z){long x=e,y=b;String c=((Long)x).toString(),d=((Long)y).toString();char l=p(c+c+d+c+c+d+d),m=p(c+c+d+d+c+d+c),o=(char)(l+a+f),_=p(c+d+d+d+d+d),$=_++;System.out.print(new char[]{p(c+d+d+c+d+d+d),m,l,l,o,$,p(c+d+c+d+c+c+c),o,(char)(o+a+f),l,(char)(m-f),_});}}

in that code the only literal variable is an Integer 0, the rest is made via Wizardry and other math tricks

\$\endgroup\$
1
\$\begingroup\$

Bash + tr, 82 79 bytes

a=({q..s});a=${a[@]};s=${a:1:1};t${a:2:1} "[$s-~]" "[u-~][$s-v]"<<<Tqxx{,c{~xp-

Output:

$ a=({q..s});a=${a[@]};s=${a:1:1};t${a:2:1} "[$s-~]" "[u-~][$s-v]"<<<Tqxx{,c{~xp-
Hello World!
$ 
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.