Merry Christmas 2017 Challenge!

Dec 25, 2017 at 9:04am
Well it’s that day of year again. For those of you who celebrate, Merry Christmas!

This year’s challenge is to generate a holiday greeting display that has some random aspect to it. That is, it must do something different each and every time the program is run.

Oh, and it must be 50 lines or fewer of code.

Good luck!

Here’s my greeting to you.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <chrono>
#include <iostream>
#include <random>
#include <string>
using namespace std;

#define A auto
#define B bool
#define C const
#define F for
#define H char
#define I int
#define K system_clock
#define O operator
#define R return
#define S string
#define T time_since_epoch
#define U substr
#define W while
#define Z if
ranlux24 rng;S O

                   *
                  ( C
                 S&s,I
                n){S r;
              A x=rng()%s
               .size();W
              (r.size()<(
             x+n))r+=s;R r
           .U(x,n);}S Y(){ S 
            r;S p="-%*`\"~"
           ",_";S y=" ";H c=
          0;r+="\n\n"+y*19+"*"
        +y*54+"\n";I q=0;F(I n
         =1;n<18;n++){B b=!(n%4
        );I w=n-q+b;A a=p*(w+1+w
       );Z(a[w]==c)R "";c=a[w]; r
     +=y*(19-w)+a+y*(30-w)+((n==15)?             "FOR UNTO YOU A"
      :(n==16)?/*~,_-%`"~,_-%`"~*/               "SAVIOR IS BORN"
                 :y*14
)+y*10+"\n";q+=b;}r+=y*17+S(5,'|')+y*52+"\n  "+p*70+"  \n"; R r;} I main(){rng
.seed(chrono::K::now().T().count());S s;do s=Y(); W(s.empty());cout<<s<<"\n";}


                   *
                  _-%
                 _-%*`
                `"~,_-%
              "~,_-%*`"~,
               %*`"~,_-%
              %*`"~,_-%*`
             `"~,_-%*`"~,_
           -%*`"~,_-%*`"~,_-
            "~,_-%*`"~,_-%*
           _-%*`"~,_-%*`"~,_
          "~,_-%*`"~,_-%*`"~,
        "~,_-%*`"~,_-%*`"~,_-%*
         "~,_-%*`"~,_-%*`"~,_-
        -%*`"~,_-%*`"~,_-%*`"~,
       `"~,_-%*`"~,_-%*`"~,_-%*`                  FOR UNTO YOU A
     ~,_-%*`"~,_-%*`"~,_-%*`"~,_-%                SAVIOR IS BORN
      _-%*`"~,_-%*`"~,_-%*`"~,_-%
                 |||||
  ~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*`"~,_-%*  


Happy coding!

LOL, update.
Last edited on Dec 25, 2017 at 7:10pm
Dec 25, 2017 at 4:46pm
This is very nice! Merry Christmas =)
Jan 4, 2018 at 7:58pm
I did indeed try this on c++ and it works. BEAUTIFUL!
Jan 4, 2018 at 9:02pm
Thank you! I’m glad at least a couple of people enjoyed it as much as I did writing it.

I found that the ranlux generator produced the best trees, so that’s why.
/question unasked, LOL

I had originally posted the unobfuscated program code, but then I realized that I could twist it to look like the output...

I know it’s 2018 now, but it isn’t too late to make an any themed 50-line or fewer, does-something-random-each-time-it-is-run program.
Obfuscation optional.

:O)
Last edited on Jan 4, 2018 at 9:03pm
Topic archived. No new replies allowed.