5
\$\begingroup\$

Requirements

You need to make a smiley face go from smiling to frowning and back. There needs to the below faces in the code: Smiling, no expression, frowning, no expression, and then back to smiling. The new face needs to replace the old face flipbook style so that there's only one face on the screen at a time. There is no input required it will just be a loop that displays one face, pauses for 200 milliseconds, and replaces the current face with the next and so on looping forever.

Faces to use:

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOO     OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO     OOOOo
   oOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOo
    *OOOOO  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  OOOOO*
    *OOOOOO  *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*  OOOOOO*
     *OOOOOO  *OOOOOOOOOOOOOOOOOOOOOOOOOOO*  OOOOOO*
      *OOOOOOo  *OOOOOOOOOOOOOOOOOOOOOOO*  oOOOOOO*
        *OOOOOOOo  *OOOOOOOOOOOOOOOOO*  oOOOOOOO*
          *OOOOOOOOo  *OOOOOOOOOOO*  oOOOOOOOO*
             *OOOOOOOOo           oOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*    
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
     *OOOOOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOOOO*
      *OOOOOOo                             oOOOOOO*
        *OOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*    
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOO                  OOOOOOOOOOOOOOO*
     *OOOOOOOOOOO                      OOOoOOOOOOOO*
      *OOOOOO       OOOOOOOOOOOOOOOO        OOOOOO*
        *OOOOO   OOOOOOOOOOOOOOOOOOOOOO   OOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*    
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
     *OOOOOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOOOO*
      *OOOOOOo                             oOOOOOO*
        *OOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*    
                      ""ooooooooo""

Only one face shows up at a time and it should loop forever cycling between happy indifferent and sad.

Goal

Have the shortest code is always the goal but being able to tell that the output is actual a face is quite important.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ 1. Is the input one face, and the output the next in the sequence? Or is there no input, and it has to output a face, pause, clear and output the next face, etc? And if the latter, is it a single loop or does it loop forever? 2. If the goal is having the shortest code, why is the winner the post with the most upvotes rather than the post with the shortest code? \$\endgroup\$ Nov 19, 2015 at 20:53
  • 1
    \$\begingroup\$ Welcome to PPCG. Popularity contests of this type are generally not well received, as they are more of an art contest than a prgramming contest. A better way to go with this challenge would be for you to design some faces and make it a codegolf, so the winning depends on programming skill, like this: codegolf.stackexchange.com/q/49671/15599 . I think this is too simple Please stick around and answer a few challenges to get a feel for the site. Also, you can post challenges to our sandbox for feedback before they go live meta.codegolf.stackexchange.com/q/2140/15599 \$\endgroup\$ Nov 19, 2015 at 20:59
  • \$\begingroup\$ No input it just starts the sequence. It can be a single loop that lasts forever and I'll change it to the shortest code as per both pete and steveverrill suggested. \$\endgroup\$ Nov 19, 2015 at 21:02
  • \$\begingroup\$ @PeterTaylor being able to tell that the output is actall a face is quite important. I think OP's intention is that we can redesign the face, but as that isn't a good idea (because everyone will just go :) to be as short as possible), I think you've jumped ahead. I think you are right, the challenge should have faces prescribed by the OP. \$\endgroup\$ Nov 19, 2015 at 21:05
  • 2
    \$\begingroup\$ Added the neutral face back as the fourth face as it does need to cycle back in reverse order. Also defined that the pause is 200 milliseconds \$\endgroup\$ Nov 19, 2015 at 21:40

3 Answers 3

2
\$\begingroup\$

Python 2 - 461/442 bytes

461 bytes:

f='eNrtlkEOwyAMBO+8wuLoz/gJPIH/3yKVhC62AVeVKrUNR7KDceJdhchbpdRrlZLM4yreqikg8sRr\npdZH1EhE9cAgwkQ8ivROg5BphWW5Yymp5rJm50G90pHGzD2c1TVYjQJlCFvj86w91SQMlJiXLuYb\nCFAxTEOXuM4x7v1zH0CWBfYEgAChgkA+6BVircLWlTzrgCi5Lqecu81zThPRnQW/mgUfwzZmdob2\nDQqMs7qXNhJbs9Fs2HUWBAq5YRBoJsbcaXCnwZ+lgR3NTRq4zMnN0sA/WcaKOg2mP1gO8R1hcACw\nDCfh\n'.decode('base64').decode('zlib').split("\n\n");import os,time;f+=[f[1]];i=0
while 1:os.system('cls');print f[i];i=(i+1)%4;time.sleep(.2)

442 bytes requiring ansi code support:

f='eNrtlkEOwyAMBO+8wuLoz/gJPIH/3yKVhC62AVeVKrUNR7KDceJdhchbpdRrlZLM4yreqikg8sRr\npdZH1EhE9cAgwkQ8ivROg5BphWW5Yymp5rJm50G90pHGzD2c1TVYjQJlCFvj86w91SQMlJiXLuYb\nCFAxTEOXuM4x7v1zH0CWBfYEgAChgkA+6BVircLWlTzrgCi5Lqecu81zThPRnQW/mgUfwzZmdob2\nDQqMs7qXNhJbs9Fs2HUWBAq5YRBoJsbcaXCnwZ+lgR3NTRq4zMnN0sA/WcaKOg2mP1gO8R1hcACw\nDCfh\n'.decode('base64').decode('zlib').split("\n\n");import time;f+=[f[1]];i=0
while 1:print'<ESC>[f'+f[i];i=(i+1)%4;time.sleep(.2)

<ESC> is a literal escape character (code 27). This program assumes that the terminal it is running on starts out blank

\$\endgroup\$
2
\$\begingroup\$

Mathematica, 478 470 bytes

i=0;Dynamic[Uncompress["1:eJzt1rsKwjAUBuAOPkjNmEl9BHUUAnYVAg6CU4b6/nhNPLekR6hCJWcQqf/XpFp/Oj+G/WnWNE1/f9md+0u3vr1rxfE+xPH+sFiuWCI4aQLLyrlMvhwWiAYQpCWYQWXb1uIcPZIcZM/lXfGICF1gu2ZHIiQ5xSDJNiRMypA1hxzIpMu0rzMOw2fEYujYL0HGxlMnqJOCi/mQlzZ9FxbepDEuyrfBCGSJA4ISovj/iueRwTsTs48xJtWDMd221oiWQfXHNfJjOVACfGiNfA7B/6y0Qe5AjRQmMBahYrlcj+guTMe+UiSbWiRaBlUtkrHkaEXC7+AcRFK++V2xSOTzuxYdF4pEMA5/MNkeqQ8kagZV7ZGxZH0gQctNtUiuFNCEqg=="][[i=i~Mod~4+1]],UpdateInterval->.2,TrackedSymbols->{}]
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 613 bytes

setInterval(_=>(c=console).clear()||c.log((` 16__o6__
 11oO18o
 7oO26o
 4oO32o
 2oO36o
 0oO40o
  oO8*  *O11*  *O9o
 oO8 3O9 3O9o
 oO9o  oO11o  oO10o
oO46o
`+[`oO1 2O28 2O1o
oO3 O32 O3o
 *O2  O30  O2*
 *O3  *O26*  O3*
  *O3  *O24*  O3*
 0*O3o  *O20*  oO3*
 2*O4o  *O14*  oO4*
 4*O5o  *O8*  oO5*
 7*O5o 8oO5*`,n=`oO46o
oO46o
 *O44*
 *O44*
  *O5oO24oO5*
 0*O3o 26oO3*
 2*O2oO24oO2*
 4*O32*
 7*O26*`,`oO46o
oO46o
 *O44*
 *O11 15O12*
  *O8 19O9*
 0*O3 4O13 5O3*
 2*O2 0O19 0O3*
 4*O32*
 7*O26*`,n][i++%4]+`
 11*O18*
 16""o6""`).replace(/.\d+/g,r=>r[0].repeat(+r.slice(1)+3))),i=200)

Explanation

Uses a simple run-length encoding scheme to compress the string. Any character can optionally have a number directly after it which tells the decompressor to print that character n + 3 times (eg. ab4c will become abbbbbbbc).

Without this compression the code size is just over 2000 bytes.

setInterval(
  _=>(c=console).clear()||c.log(            // clear and display the face in the console
    (                                       // piece together the appropriate string
      `TOP`+                                // run-length encoded face top string
      [`HAPPY`,n=`NEUTRAL`,`SAD`,n][i++%4]+ // encoded mouth string
      `BOTTOM`                              // encoded face bottom string
    )
      .replace(/.\d+/g,                     // search for each character-number instance
        r=>r[0].repeat(+r.slice(1)+3)       // repeat the character n + 3 times
      )
  ),
  i=                                        // i = iterator
    200                                     // set interval to 200ms
)
\$\endgroup\$
2
  • \$\begingroup\$ This doesn't clear the screen before printing each face. \$\endgroup\$ Nov 25, 2015 at 13:18
  • \$\begingroup\$ @ppperry Oh, I must have missed that in the question! I've fixed it now. \$\endgroup\$
    – user81655
    Nov 25, 2015 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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