Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Write a code to display "I Love You". Without using any built-in tools or functions like echo, System.out.println, printf, ...

You are not allowed to directly call any function throughout the program execution, but the system environment or the compiler-generated code might do. This way, you can put your code in a main function or method that is called by the running environment, but your program should not further call any functions.

By the way, a function is not an instruction, nor a command nor an operator. So calling sum(a, b) is not valid, but making a = b + c is, even if the compiler reduces this to internal function calls.

This is a , so the valid answer with the most upvotes wins.

share|improve this question
2  
So you are excluding c and many other languages. –  user689 Feb 22 at 14:32
6  
People here tend not to accept answers so early, since usually accepting an answer means that the contest is over. –  ace Feb 22 at 14:44
1  
What is so bad about this challenge? Most languages won't be able to compete, but some are free to do so. For example, GolfScript works fine. PHP also works fine (paste text into blank text file). There are many other languages that can do this challenge, so why are there so many downvotes and close votes? –  Quincunx Feb 22 at 22:48
1  
@Quincunx This got 2 close votes as "too broad" and 2 as "primary opinion based". I do not think that this is particularly a great challenge (it is boring for me, but I really liked the brainfuck answer). However, I do not think that it should be closed (and I will vote for a reopen if it get closed). Being not much interesting and/or boring is not a close reason, and frankly, I am seeing people closing questions just for the sake of being closed using some lame excuse just because they find them boring or impossible to do in their favorite language. –  Victor Feb 23 at 2:19
1  
@tohecz, it is not me who are asking this. But anyway, if people think that the question has problems and should be closed, normally it is adequate to drop a comment explaining why (like you and Cruncher, but none of the closers, did). Otherwise, there would be no real point in closing the question as no one would be saying to the OP what should be improved to make the question be reopened. Further, if the question has a minor problem or unclear point, people should ask or inform the OP first. In most questions, the OP fixes or clarifies the minor point quickly and no close-voting is needed. –  Victor Feb 24 at 18:57
show 11 more comments

10 Answers

up vote 8 down vote accepted

Html-asp- xhtml-tex-php.....

I didn't use any functions

I Love You
share|improve this answer
5  
That is a polyglot. It's valid in php, html, xhtml, asp ... –  Ismael Miguel Feb 22 at 20:24
1  
valid in plain TeX as well, btw. And certainly doesn't use any functions, since there're no functions in the language at all. –  tohecz Feb 24 at 12:15
2  
This shouldn't be the accepted answer......... –  Ismael Miguel Feb 24 at 20:18
 
@IsmaelMiguel I agree but I'm not the one you should say that to. You should tell the OP. –  user689 Feb 25 at 5:22
1  
@IsmaelMiguel There! I fixed it. –  Quincunx Mar 1 at 4:43
add comment

Brainfuck

    ++++     ++++
  ++[>+++   ++++>++
 +>+++++++ ++++<<<-]
>+++.>++.<+++.>>+.+++
 ++++.--------------
   ---.<.<++++++++
     +++++.>>+++
      +++++++.+
        +++++
          .

The heart looks horribly thin here, but it is a lot better on a text editor / terminal

enter image description here

Here's a nicely indented version:

+++++ +++++ [
    > +++++ ++
    > +++
    > +++++ +++++ +
    <<< -
]
> +++ .
> ++ .
< +++ .
>> + .
+++++ ++ .
----- ----- ----- -- .
< .
< +++++ +++++ +++ .
>> +++++ +++++ .
+++++ + .
share|improve this answer
1  
There's a much shorter one –  mniip Feb 22 at 14:30
2  
@mniip Length is not a concern in this question since it is not code golf. So I'd go for a slightly longer one, which makes it easier to make it look like a heart. –  ace Feb 22 at 14:37
 
nicely indented version:) LOL –  V-X Feb 23 at 11:38
 
aren't "." equivalent to putchar, which is in terms of brainfuck like echo? –  V-X Feb 24 at 10:34
 
@V-X the OP said "no functions", and I'm quite certain there aren't any functions in brainfuck –  ace Feb 24 at 11:14
show 2 more comments

Javascript:

var l='I love you.';
if(window)window.status=l;
if(document)if(document.readyState=='complete')document.innerHTML=document.title=l;
else document.onload=function(){document.innerHTML=document.title=l;};
throw new l;

The part where it says 'function' is as ASSIGNMENT!

There is nothing in the question saying I can't assign functions and trigger events.

And the 'throw new l;' will say "I love you" in the error message.

This will show 'I love you' in the console, document, title and in the status bar.

share|improve this answer
add comment

C

void main( )
{
  char *string="I Love You";
    volatile char *video = (volatile char*)0xB8000;
    while( *string != 0 )
    {
        *video++ = *string++;
        *video++;
    }
}
share|improve this answer
1  
you are using the main function. –  user689 Feb 22 at 14:34
1  
We are not allowed to call any function, Without main() how will you write a pgm ? –  vengets Feb 22 at 14:34
11  
I don't know you wrote the question not me. –  user689 Feb 22 at 14:36
2  
Nope, Read the question once again.. In this code no function call has been made. That's it.. –  vengets Feb 22 at 19:34
1  
@vengets int main(){ printf("I love you"); } I don't do any function call, that's the processor who does. (Almost like: "It's not my fault, it's the knive who killed that guy!") –  tohecz Feb 24 at 19:50
show 2 more comments

Mathematica, GolfScript, Python Interpreter, bc

This outputs the sentence:

"I love you"
share|improve this answer
1  
Polyglot; works in GolfScript and Python Interpreter too. Works in PHP but outputs with the quotes. –  Quincunx Feb 23 at 0:16
 
Also works in bc. –  manatwork Feb 24 at 9:04
 
@Quincunx, manatwork, I included the languages you mentioned in the title. –  David Carraher Feb 24 at 10:01
add comment

PHP

Quite rule bending maybe...

<? ?>I Love You
share|improve this answer
add comment

Shell Script

mkdir "I Love You"
cd I\ Love\ You/
pwd | grep -o '/I Love You' | cut -c2-
share|improve this answer
add comment

Smalltalk

as there is a read-eval-print-loop, and strings are self evaluating, this is trivial. From the command line, type this:

stx -P "'I love you'

A workspace, which is a basically a graphical wrapper for the eval, type in a string and select the "printIt" menu function.

share|improve this answer
add comment

DOS Command Prompt

C:> prompt I Love You
I Love You
share|improve this answer
 
I am wondering why my bold text is not as big and bold as others'. –  microbian Feb 24 at 20:26
 
Because they are not using a bold text,they are using headers. Try adding a # before the title. (remove the *) –  user689 Feb 25 at 12:57
 
Or put ======== under the title. Only one is enough, but I usually put the same number of = as the length of the title –  Ismael Miguel Feb 26 at 9:44
 
is prompt not an external function? –  B1KMusic Feb 28 at 20:09
 
Prompt is a command, but it's purpose is NOT to print strings. –  microbian Feb 28 at 20:30
add comment

HTA - HyperText Application

I Love You

Microsoft says any plain text is valid HTA. They even mention in their official documentation that their "Hello, World." can be as simple as:

Hello, World.

Although most examples that you see on the web go the "official" route.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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