Smile! Just smile

16

It's well known that Brainf*ck is very bad at Kolmogorov-complexity problems, for example, it requires around 100 characters just to print "Hello world".

However, there might be texts where Brainf*ck is just very good at.

Your task is now to write a program that takes no input, and it displays the following:

That is, a smiley face (ASCII 1, if you browser does not render it).

Brainf*ck can do it in 2 characters.

+.

Try to find a language that beats it!

We assume your console can actually display that character (or your font has it, etc.).

Shortest code wins. If there are more of the same length, the first wins, but I'll upvote the others as well.

EDIT: I'm very sorry, I did not think the first post arrives this soon. A quick edit: the language has to be Turing-complete!

vsz

Posted 2012-11-08T18:52:43.717

Reputation: 7 963

7I must dispute your description of the output: While your code really outputs a character with the binary code 1, it is not ASCII-encoded, but belongs to some DOS codepage encoding like CP850 or CP437. In any modern console the smiley will not appear, because modern == UTF-8. ☺ – Sven – 2012-11-09T16:06:14.740

Answers

10

FALSE (2)

1,

All that reading about BF paid off! False is an ancestor of Brainfuck.

luser droog

Posted 2012-11-08T18:52:43.717

Reputation: 4 535

Ouch! Strange that no one thought of this until now. :) – vsz – 2012-11-09T07:20:06.370

1I had to accept this one, as the versions with plain-text and html were not actually done with programming languages. – vsz – 2012-11-17T18:12:43.113

I tried to do it with BLC, but I can't make any sense out of BLC. And even a 1-state Turing machine needs 4 or 5 elements in the tuple. – luser droog – 2012-11-17T18:49:41.800

19

HTML:

It's not a really a programming language, but the shortest possible solution.

user6696

Posted 2012-11-08T18:52:43.717

Reputation:

1While it no longer fits in the rules, I'll still give a +1 because I was rushing my question and did not think of this. – vsz – 2012-11-08T18:58:26.323

If you want to call this php instead, like this answer, it would probably be okay under the new rules.

– Matt – 2012-11-08T19:09:05.123

PHP will output gibberish if you simply try to use . – jdstankosky – 2012-11-08T19:37:56.453

Works in HTML+CSS, which is okay under the new rules.

– Adám – 2016-11-15T00:36:45.817

@Adám The rules to this challenge require Turing Completeness, which the link you posted does not prove. – pppery – 2020-01-07T00:16:06.783

12

Mathematica

Just for fun...

"\[HappySmiley]"
"\[NeutralSmiley]"
"\[SadSmiley]"
"\[FreakedSmiley]"

smileys

DavidC

Posted 2012-11-08T18:52:43.717

Reputation: 24 524

1In Mma, the one char ☺ also does it – Dr. belisarius – 2012-11-11T21:01:46.043

@belisarius How do you paste without having it converted to ASCII? – DavidC – 2012-11-11T22:52:18.750

1I just copy-pasted it :) – Dr. belisarius – 2012-11-11T23:07:24.370

@belisarius I also cut & pasted the icons, but for some reason the full format was shown. – DavidC – 2012-12-16T14:44:44.950

What the hell is the mathematical value of a freaked smiley? – tomsmeding – 2013-08-25T21:50:34.587

1The commercial value is roughly 75 cents. The mathematical value is zilch. – DavidC – 2013-08-25T22:03:37.943

This challenge requires specific ASCII text to be output, not images. Even if images were a valid output form, this would not be a serious contender because (I assume), Mathematica could output ASCII 1 characters with fewer bytes than this. – pppery – 2020-01-07T00:14:46.480

10

plain-text, 1 char

Because html is an overkill in many situations.

(yes, I know the rules have changed)

baby-rabbit

Posted 2012-11-08T18:52:43.717

Reputation: 1 623

plain-text is not turning complete, rendering this answer invalid. – pppery – 2020-01-07T00:15:19.680

8

C, 18 chars

Far from beating Brainf**k, but as good as C can get (I guess).
Only works on little-endian platforms, must run without parameters.

main(c){puts(&c);}

ugoren

Posted 2012-11-08T18:52:43.717

Reputation: 16 527

7

Micronetics System MUMPS 4.4 (7 chars)

w $c(1)

DaveShaw

Posted 2012-11-08T18:52:43.717

Reputation: 181

MUMPS? Oh, the horror... I never even imagined that I'll see it here. +1 just for the pure shock value! – vsz – 2012-11-09T12:56:31.757

@vsz it's the only Golf suitable language I know, it often beats most common langs :) – DaveShaw – 2012-11-09T12:59:14.467

5

DC - 2 characters

1P

It doesn't require any explanation.

Fors

Posted 2012-11-08T18:52:43.717

Reputation: 3 020

5

Brainf*ck (only 2 characters)

+.

vsz

Posted 2012-11-08T18:52:43.717

Reputation: 7 963

Of course, I'll still accept a solution of length 2. – vsz – 2012-11-08T18:55:38.857

Could you explain how this works? It should output ASCII 1 which is a non-printable character. – nyuszika7h – 2014-10-27T13:58:21.627

@nyuszika7h : many consoles output a smiley for ASCII 1. – vsz – 2014-10-27T19:19:04.240

1Really? I've never seen such a console. I bet they use some obscure charset. – nyuszika7h – 2014-10-27T19:21:23.003

5

Doesn't beat 2 chars, but:

PHP 11 chars.

<?=chr(1)?>

For everyone saying you can simply place the smiley in php and it will output :

Running it with php.exe in the command line gives Γÿǁ and placing it in the browser gives ☺

It does not work.

jdstankosky

Posted 2012-11-08T18:52:43.717

Reputation: 1 474

You could also go the HTML route that m0nhawk did. – Mr. Llama – 2012-11-09T17:35:34.370

@GigaWatt You cannot. It puts out gibberish using PHP. Did you even try? I tried it in the CLI and the browser. – jdstankosky – 2012-11-09T17:48:53.970

Works fine for me. http://ideone.com/6wYzx9

– Mr. Llama – 2012-11-09T17:56:23.453

Running it with php.exe in the command line gives Γÿǁ and placing it in the browser gives ☺ – jdstankosky – 2012-11-09T18:56:20.227

2If you do a hex dump of your file, you'll see that it was saved as unicode representation of a smiley (\xE298BA), not as \x01. Try manually making a file with a single \x01 byte in it and running it from the command line with PHP. – Mr. Llama – 2012-11-09T21:04:55.080

4

Golfscript, 3 characters

"☺"

Not a golfscript expert, but I don't believe there is a way to convert an integer into the corresponding ASCII character using only 1 character, so it seems like this is the shortest it can get

Strigoides

Posted 2012-11-08T18:52:43.717

Reputation: 1 025

4

PHP (1)

Technically this is a valid PHP file (a web server will happily serve it).

Peter C

Posted 2012-11-08T18:52:43.717

Reputation: 141

3

LaTeX (51/77 characters)

Short solution

\documentclass{book}
\begin{document}
☺
\end{document}

Good solution (Compile with latex main.tex):

\documentclass{book}
\usepackage{wasysym}
\begin{document}
\smiley
\end{document}

Martin Thoma

Posted 2012-11-08T18:52:43.717

Reputation: 669

The first one does not work because pure LaTeX cannot read unicode chars. Oddly enough, this does not work neither in XeLaTeX, nor in LuaLaTeX because the default font table does not contain this symbol. Please consider this: \documentclass{book} \usepackage{fontspec} \setmainfont{DejaVu Sans} \begin{document}☺\end{document} — and please specify the rendering engine you are using (pdfLaTeX) in the “good” solution. – Andreï Kostyrka – 2016-11-14T16:57:48.773

2

J (3 chars)

'☺'

The code require appropriate font.

According to Wikipedia

In the Wingdings font, the letter "J" is rendered as a smiley face (note this is distinct from the Unicode code point U+263A, which renders as ☺).

P̲̳x͓L̳

Posted 2012-11-08T18:52:43.717

Reputation: 213

Another variation is u:1. – FireFly – 2013-10-08T21:30:45.343

2

Whitespace, 9 bytes

   	
	
  

Try it online!

ssstl   push 1 on stack
tlss    output char

Dorian

Posted 2012-11-08T18:52:43.717

Reputation: 1 521

2

Q/k (9 chars)

Can't do it in 2 unfortunately.

-1"\001";

I seem to recall a bug in an older version of the interpreter which produced the other smile symbol in less characters. I'll look it up.

Edit: found the quirk. It only appears to work on windows versions of the interpreter:

q)1(1b);
☺

skeevey

Posted 2012-11-08T18:52:43.717

Reputation: 4 139

1

Burlesque - 6 Characters

,1L[sh

Explanation:

, pops stdin. 1L[ pushes one and convert to char (by codepoint) sh is used to switch to pretty format. (Otherwise it would print a leading ').

mroman

Posted 2012-11-08T18:52:43.717

Reputation: 1 382

1

Tcl, 1

Displays a ☺ with some other stuff.
There are rumors that this also works with PHP or other languages.

Johannes Kuhn

Posted 2012-11-08T18:52:43.717

Reputation: 7 122

1

Arduino, 24

char a=1;Serial.print(a)

Timtech

Posted 2012-11-08T18:52:43.717

Reputation: 12 038

1

Stax, 2 bytes

1]

Run and debug it

Nanajnaiojneg

Posted 2012-11-08T18:52:43.717

Reputation: 11

The Stax ] doesn't work prefixly - it pops an item from the stack and creates a list from it. So you might alternatively need 1] for the program.

– a'_' – 2020-02-20T01:30:43.637

1

Keg, 2 characters

Push the number 1 and print it. (Surprised that 1, also works; -1 from Lyxal.)

1,

Try it online!

Keg, 1 character

Keg is actually Turing-complete, and any unrecognized command acts as a push onto the stack.

Try it online!

a'_'

Posted 2012-11-08T18:52:43.717

Reputation: 1 099

It's actually 1, making it 2 bytes. – Lyxal – 2020-02-20T06:42:43.320

1

05AB1E, 2 characters

Just a boring hard-coding. It's encoded in CP437.

"☺

Try it online!

05AB1E, 2 bytes

Try it online!

a'_'

Posted 2012-11-08T18:52:43.717

Reputation: 1 099

You may want to include the encodings. Your top answer is only 2 bytes in an encoding like CP850 or CP437, which contains both the characters and " in their codepage. But using the 05AB1E encoding, the top answer isn't even possible, and using the UTF-8 encoding it would be 4 bytes. – Kevin Cruijssen – 2020-02-20T08:44:24.453

The challenge says that characters are a valid encoding system... – a'_' – 2020-02-20T08:50:31.847

1

chevron - 4 bytes/2 runes

>☺

Superloach

Posted 2012-11-08T18:52:43.717

Reputation: 71

0

SmileBASIC, 3 characters

?"☺

​​

12Me21

Posted 2012-11-08T18:52:43.717

Reputation: 6 110

0

plain TeX (5 chars):

Other my answer, now on plain TeX:

☺\bye

user6696

Posted 2012-11-08T18:52:43.717

Reputation:

Does not work because pure TeX is ASCII-only. – Andreï Kostyrka – 2016-11-14T16:58:58.877

0

PowerShell, 5 bytes

if a program should output the smile face char.

'☺'

Try it online!


PowerShell, 7 bytes

if a program should output the char with code 1.

[char]1

Try it online!

mazzy

Posted 2012-11-08T18:52:43.717

Reputation: 4 832

1Why not just '☺' ? By the way, the face isn't rendered for me in TIO or the console – I.T Delinquent – 2020-02-17T15:32:09.190

because the code for the smile face is not 1 in the Powershell. Try it online!

– mazzy – 2020-02-17T15:39:37.607

1Should your answer be '[Char]9786' instead then? I'm really confused :-D – I.T Delinquent – 2020-02-17T15:44:46.333

1Ha! You are right. I thought I'd write a program that outputs a character with code 1. But you can interpret it as writing a program that outputs a smiley face. – mazzy – 2020-02-17T15:48:36.333

0

Gol><>, 2 bytes

1H

Try it online!

Just for completeness. Push a single 1, print all the contents as characters and halt.

Bubbler

Posted 2012-11-08T18:52:43.717

Reputation: 16 616

0

MineFriff, 5 bytes

C1,o;

Try it online!

Simply:

  • Treat the temp register as a character
  • Add one to the register and push
  • Output the top item and finish.

Lyxal

Posted 2012-11-08T18:52:43.717

Reputation: 5 253

0

C (gcc), 15 bytes

f(){puts("☺");}

Try it online!

S.S. Anne

Posted 2012-11-08T18:52:43.717

Reputation: 1 161

0

Perl 6 (7 chars)

say '☺'

I'm bending the rules a little by assuming that a \n is welcome to avoid shell prompt mess.

gfldex

Posted 2012-11-08T18:52:43.717

Reputation: 173

4Are you sure you need that space character? – J B – 2013-08-28T21:46:46.693

0

JavaScript, 10 Bytes

alert("☺")

enter image description here

Pete Arden

Posted 2012-11-08T18:52:43.717

Reputation: 1 151