48
\$\begingroup\$

Requirements

For the sake of the challenge let's define a unit:

A unit is defined as any point that compose the grid in which the face is drawn (pixels for screen, characters for ASCII art, etc..).

The minimal requirements for the face are:

A smiley face is composed of a shape that resemble a circle (not necessarily perfect) of any radius. There must be at least 1 unit for each of the two eyes and at least 2 units for the mouth. Both eyes and mouth should be within the face shape. The mouth can be oriented however you want (happy, sad, indifferent, etc..).

Here's an example of the output:

 0 0 0    . . .
0 . . 0  . o o .
0 --- 0  . \_/ .
 0 0 0    . . .

Goals

Of course the main goal is to come up with the shortest code possible, but art is also important.

Winner

The winner is chosen based on the amount of votes from the users, in, at least, the next 5 days.

\$\endgroup\$
6
  • \$\begingroup\$ Similar: codegolf.stackexchange.com/questions/8932/smile-just-smile/… \$\endgroup\$
    – DavidC
    Dec 29 '13 at 2:16
  • 5
    \$\begingroup\$ Wow, 8 questions on the hot question list. Our site should be getting more traffic. \$\endgroup\$
    – Justin
    Dec 29 '13 at 6:27
  • \$\begingroup\$ Isn't indifferent face strictly easier than happy, and sad sometimes more difficult? \$\endgroup\$
    – o0'.
    Dec 29 '13 at 13:50
  • 2
    \$\begingroup\$ Not going to make this an answer since it doesn't fit the minimum requirements, but I wanted to chime in... alt + 1 and alt + 2 will produce ☺ and ☻ respectively. For the sake of argument I'll consider the alt key press a character and call that 2 characters. \$\endgroup\$ Dec 30 '13 at 17:30
  • 1
    \$\begingroup\$ Will this thread ever end? :) \$\endgroup\$
    – avall
    Jan 13 '14 at 10:43

34 Answers 34

1
2
0
\$\begingroup\$

C 178 characters:

source (whitespace added - all can be removed except at int x

int x,y;
c(a,b,r)
{
  return  (x-a)*(x-a) + (y-b)*(y-b) < r*r;
}

main()
{
  for(x=9;x>=-9;--x)
  {
     for(y=-9;y<=9;++y)
       putchar(32<<(
         c(0,0,10)&&!(c(4,4,2)|c(4,-4,2)|c(3,0,8)&!c(7,0,10))
       ));
     putchar(10);}
 }

output:

     @@@@@@@@@
    @@@@@@@@@@@
  @@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@
 @@@   @@@@@   @@@
@@@@   @@@@@   @@@@
@@@@   @@@@@   @@@@
@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@
@@@ @@@@@@@@@@@ @@@
@@@  @@@@@@@@@  @@@
@@@@           @@@@
@@@@@@       @@@@@@
 @@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@
    @@@@@@@@@@@
     @@@@@@@@@
\$\endgroup\$
0
\$\begingroup\$

T-SQL, 628

For SQL Server 2012+

This is a query I did some time ago as a bit of fun and to show my kids.
It uses the string in @ to determine a few parameters B = base, O = offset, M = multiplier, D = divisor. These are then used to create a SQL Server Geometry (2012+).

It's not particularly golfed.

DECLARE @ varchar(30)='Don''t Worry, Be Happy';
WITH P AS(
    SELECT LEN(PARSENAME(F,1))D,
        LEN(PARSENAME(F,2))M,
        LEN(PARSENAME(F,3))B,
        LEN(PARSENAME(F,4))O
    FROM (VALUES(REPLACE(@,' ','.')))S(F)
    )
SELECT @, Geometry::Point(B*M,B*M,0).STBuffer(B*M).STDifference((
    SELECT Geometry::UnionAggregate(g)
    FROM (
        SELECT Geometry::Point(B*M-O,B*M+O,0).STBuffer(B/D*M)FROM P
        UNION ALL
        SELECT Geometry::Point(B*M+O,B*M+O,0).STBuffer(B/D*M)FROM P
        UNION ALL
        SELECT Geometry::STGeomFromText(
            CONCAT('CIRCULARSTRING(', 
                B*M-O,' ',B*M-O,',',
                B*M,' ',(B*M-O)-((B*M)/(B*M-O)),',',
                B*M+O,' ',B*M-O,')'),0).STBuffer(B/D)FROM P
            )A(G)
        )) 
FROM P

When run in SSMS it shows the following in the spatial results tab enter image description here

\$\endgroup\$
0
\$\begingroup\$

Javascript, 857 bytes

Just some idle obfuscation.

un="̤̤Ո͈̤ՇՇ̤͆F͆Ë̠̠́̈́ ՃC̠B̠͂ՁՁ̠Հ@ ̿̿Ԡ̾͜ծ̽̽>̼͂̾̾Ի̽;͂Ժͅ$Թ̹͈8՜̢77Շ̶Է̷̵554̓ͯ3oͯԲHͯ18̤̰0̰/ͣoͮͳol̮ͥլ̨ͯͧՠ̻Ծ̈́22̰ԲԲԺD2/ͯԽ̻̲̓/F1@̳̤C͈̠o̤̽Գ $̠2́3̯0ͯ?HԠ͈̠1̤̽2 ̤ ̤̠7̤̳̓9̰̤͂BFG̱?Ԥ1̱̤̽6$Ա̤̈́3Թ̸̱̀̀͂ͅՅ=DF͇B̸Հ̸@̰Ը≠̰̈́B0$Ղ0Ḧ̵̶́̽̓64/̯̤A̶=Ղ͇3/̯͈A̷̤1Խ̳͈7Ճ/ԯ͇̤̿Ա=C͇B/̰̹Է ̶$̱2̲H1Խ̈́o$1̲̤ͯ͆Dԯ̰$̳̰Ն̤̽Dͅ6$Cԯ9$A̴̴̴̠͆̽Կ͆͂7̯F7̓3G̼7̤̱́57԰ՆՈ̷H̷> ͇<D̤1̾̈́7H5FH4Ծ̳͇<̓H̱̻̠2̳͇̾̈́7̻̽7H̱C3͆17͈1̳̻́͆̽̈́Զ1ͯ́5HԱG̱3̵̺͆̈́ 5G̱̲oD7̤1̹57̺͂5͆$1oԠ̹̤?:>B4̸̾Ժ̻̰̿Ժ̻̠9̷̤̺̀ԻD̶4=͠ԩ",ㅤㅤㅤ=window;for(ㅤ in {escape:ㅤㅤ="un"})for(_=ㅤㅤㅤ[`${ㅤㅤ}${ㅤ}`](ㅤㅤㅤ[ㅤ](un).replace(/u../g,[]));__=/[/-H]/.exec(_);)with(_.split(__ ))_=join(shift());setTimeout(_,0)
\$\endgroup\$
0
\$\begingroup\$

ConTeXt/MetaPost (104 89 bytes)

This is a rather minimalistic smiley and you need at least 1000% zoom to see that poker face:

\startMPpage
let D=draw;D fullcircle scaled 5;D left;D right;D(-1,-1)--(1,-1)
\stopMPpage

enter image description here

You can compile the document here as a PDF

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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