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\$
  • \$\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\$ – Dryden Long Dec 30 '13 at 17:30
  • 1
    \$\begingroup\$ Will this thread ever end? :) \$\endgroup\$ – avall Jan 13 '14 at 10:43

35 Answers 35

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 25

document.write("☺")

You should get the Unicode smiley face! Granted, it's a little cheaty, but it satisfies all the requirements:

A smiley face is composed of a shape that resemble a circle (not necessarily perfect) of any radius. (Check! The shape resembles a circle)

There must be at least 1 unit for each of the two eyes and at least 2 units for the mouth. (Check! Given the rule for a unit also allowing for pixels, this rule is also satisfied!)

Both eyes and mouth should be within the face shape. (Check, eyes and mouth are wholly within the face shape!)

The mouth can be oriented however you want (happy, sad, indifferent, etc..). (Check! Already smiling!)

\$\endgroup\$
  • \$\begingroup\$ other fonts have that glyph too, here's a variation on yours:alert("\u263a"); \$\endgroup\$ – Jasen Dec 27 '14 at 2:35
  • \$\begingroup\$ also: document.write("\u263a") \$\endgroup\$ – Jasen Dec 27 '14 at 2:36
  • 1
    \$\begingroup\$ Your image isn't drawn with pixels, it's drawn with characters. I'm pretty sure this doesn't meet the requirements. \$\endgroup\$ – mbomb007 Jan 16 '15 at 17:45
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\$
-2
\$\begingroup\$

Plain text, 1​​​​​

It looks good and is scalable, too.

\$\endgroup\$
  • 7
    \$\begingroup\$ Looks like the squared face guy sitting in front of me (a.k.a a box). \$\endgroup\$ – Frenzy Li Dec 29 '13 at 4:25
  • 3
    \$\begingroup\$ Doesn’t seem to me to use enough “units.” \$\endgroup\$ – Christopher Creutzig Dec 29 '13 at 9:44
  • 6
    \$\begingroup\$ The whole idea in defining a "unit" was to prevent this kind of answers, that have, already, been posted here. \$\endgroup\$ – Shoe Dec 29 '13 at 12:05
  • 1
    \$\begingroup\$ @Jefffrey: I wasn’t going to add this one, but then I read that in your definition of “units” you also said “pixels”. I’ll delete it if you’d like to clarify that, though. \$\endgroup\$ – Ry- Dec 29 '13 at 19:16
  • 2
    \$\begingroup\$ I just see a box (Google Chrome Version 31.0.1650.63 m). Where are the eyes and mouth? \$\endgroup\$ – user13267 Dec 31 '13 at 8:40
-3
\$\begingroup\$

VB.net (52c)

Module P
Sub Main()
Console.Write("☺")
End Sub
End Module
\$\endgroup\$

protected by Community Dec 31 '13 at 6:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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