-8
\$\begingroup\$

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.

\$\endgroup\$
16
  • 2
    \$\begingroup\$ So you are excluding c and many other languages. \$\endgroup\$
    – Mohammad
    Feb 22, 2014 at 14:32
  • 6
    \$\begingroup\$ People here tend not to accept answers so early, since usually accepting an answer means that the contest is over. \$\endgroup\$
    – user12205
    Feb 22, 2014 at 14:44
  • 1
    \$\begingroup\$ 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? \$\endgroup\$
    – Justin
    Feb 22, 2014 at 22:48
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Feb 23, 2014 at 2:19
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Feb 24, 2014 at 18:57

10 Answers 10

10
\$\begingroup\$

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

I didn't use any functions

I Love You
\$\endgroup\$
4
  • 6
    \$\begingroup\$ That is a polyglot. It's valid in php, html, xhtml, asp ... \$\endgroup\$ Feb 22, 2014 at 20:24
  • 1
    \$\begingroup\$ valid in plain TeX as well, btw. And certainly doesn't use any functions, since there're no functions in the language at all. \$\endgroup\$
    – yo'
    Feb 24, 2014 at 12:15
  • \$\begingroup\$ @IsmaelMiguel I agree but I'm not the one you should say that to. You should tell the OP. \$\endgroup\$
    – Mohammad
    Feb 25, 2014 at 5:22
  • 1
    \$\begingroup\$ @IsmaelMiguel There! I fixed it. \$\endgroup\$
    – Justin
    Mar 1, 2014 at 4:43
10
\$\begingroup\$

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:

+++++ +++++ [
    > +++++ ++
    > +++
    > +++++ +++++ +
    <<< -
]
> +++ .
> ++ .
< +++ .
>> + .
+++++ ++ .
----- ----- ----- -- .
< .
< +++++ +++++ +++ .
>> +++++ +++++ .
+++++ + .
\$\endgroup\$
7
  • 1
    \$\begingroup\$ There's a much shorter one \$\endgroup\$
    – mniip
    Feb 22, 2014 at 14:30
  • 2
    \$\begingroup\$ @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. \$\endgroup\$
    – user12205
    Feb 22, 2014 at 14:37
  • \$\begingroup\$ nicely indented version:) LOL \$\endgroup\$
    – V-X
    Feb 23, 2014 at 11:38
  • \$\begingroup\$ aren't "." equivalent to putchar, which is in terms of brainfuck like echo? \$\endgroup\$
    – V-X
    Feb 24, 2014 at 10:34
  • \$\begingroup\$ @V-X the OP said "no functions", and I'm quite certain there aren't any functions in brainfuck \$\endgroup\$
    – user12205
    Feb 24, 2014 at 11:14
6
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

C

void main( )
{
  char *string="I Love You";
    volatile char *video = (volatile char*)0xB8000;
    while( *string != 0 )
    {
        *video++ = *string++;
        *video++;
    }
}
\$\endgroup\$
7
  • 1
    \$\begingroup\$ you are using the main function. \$\endgroup\$
    – Mohammad
    Feb 22, 2014 at 14:34
  • 1
    \$\begingroup\$ We are not allowed to call any function, Without main() how will you write a pgm ? \$\endgroup\$ Feb 22, 2014 at 14:34
  • 15
    \$\begingroup\$ I don't know you wrote the question not me. \$\endgroup\$
    – Mohammad
    Feb 22, 2014 at 14:36
  • 2
    \$\begingroup\$ Nope, Read the question once again.. In this code no function call has been made. That's it.. \$\endgroup\$ Feb 22, 2014 at 19:34
  • 2
    \$\begingroup\$ @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!") \$\endgroup\$
    – yo'
    Feb 24, 2014 at 19:50
4
\$\begingroup\$

Mathematica, GolfScript, Python Interpreter, bc

This outputs the sentence:

"I love you"
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Polyglot; works in GolfScript and Python Interpreter too. Works in PHP but outputs with the quotes. \$\endgroup\$
    – Justin
    Feb 23, 2014 at 0:16
  • \$\begingroup\$ Also works in bc. \$\endgroup\$
    – manatwork
    Feb 24, 2014 at 9:04
  • \$\begingroup\$ @Quincunx, manatwork, I included the languages you mentioned in the title. \$\endgroup\$
    – DavidC
    Feb 24, 2014 at 10:01
2
\$\begingroup\$

PHP

Quite rule bending maybe...

<? ?>I Love You
\$\endgroup\$
0
2
\$\begingroup\$

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.

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

Shell Script

mkdir "I Love You"
cd I\ Love\ You/
pwd | grep -o '/I Love You' | cut -c2-
\$\endgroup\$
1
\$\begingroup\$

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.

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

DOS Command Prompt

C:> prompt I Love You
I Love You
\$\endgroup\$
5
  • \$\begingroup\$ I am wondering why my bold text is not as big and bold as others'. \$\endgroup\$
    – microbian
    Feb 24, 2014 at 20:26
  • 1
    \$\begingroup\$ Because they are not using a bold text,they are using headers. Try adding a # before the title. (remove the *) \$\endgroup\$
    – Mohammad
    Feb 25, 2014 at 12:57
  • 1
    \$\begingroup\$ Or put ======== under the title. Only one is enough, but I usually put the same number of = as the length of the title \$\endgroup\$ Feb 26, 2014 at 9:44
  • \$\begingroup\$ is prompt not an external function? \$\endgroup\$ Feb 28, 2014 at 20:09
  • \$\begingroup\$ Prompt is a command, but it's purpose is NOT to print strings. \$\endgroup\$
    – microbian
    Feb 28, 2014 at 20:30

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