Get happy and mad

5

3

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.

Blakethepatton

Posted 2015-11-19T20:50:28.010

Reputation: 191

3>

  • 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?
  • < – Peter Taylor – 2015-11-19T20:53:48.243

    1

    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: http://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 http://meta.codegolf.stackexchange.com/q/2140/15599

    – Level River St – 2015-11-19T20:59:41.890

    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. – Blakethepatton – 2015-11-19T21:02:14.110

    @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. – Level River St – 2015-11-19T21:05:11.753

    I've given you an upvote and a reopen vote, but there's a few things you could make clearer: I understand the sequence is 4 steps: smile, neutral, frown, neutral? Also, how long should each face be displayed? (if you don't specify a time, it seems like it's acceptable to display the next face immediately (in a millisecond), which would look rubbish, but in codegolf every byte counts, so you should specify a time to be fair.) – Level River St – 2015-11-19T21:32:58.563

    2Added 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 – Blakethepatton – 2015-11-19T21:40:59.490

    Answers

    2

    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

    pppery

    Posted 2015-11-19T20:50:28.010

    Reputation: 3 987

    2

    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->{}]
    

    LegionMammal978

    Posted 2015-11-19T20:50:28.010

    Reputation: 15 731

    1

    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
    )
    

    user81655

    Posted 2015-11-19T20:50:28.010

    Reputation: 10 181

    This doesn't clear the screen before printing each face. – pppery – 2015-11-25T13:18:35.497

    @ppperry Oh, I must have missed that in the question! I've fixed it now. – user81655 – 2015-11-25T14:10:33.813