4
\$\begingroup\$

Your challenge is simple: write a program or function which appears to print the first ten numbers of any integer sequence (on OEIS, the answerer may choose which sequence), but instead prints the exact text:

Happy April Fool's Day!

if and only if it is run on April 1st of any year. Run on any other day should make it output its original output. (Unfortunately, I was a little late posting this challenge). Answers should be voted up for clever hiding of the April fools part.

This is a , so the answer with the most votes on May 8th wins!

\$\endgroup\$

closed as off-topic by Dennis Apr 2 '17 at 14:48

  • This question does not appear to be about programming puzzles or code golf within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ I really liked this challenge until I got to this part if and only if it is run on April 1st of any year. Run on any other day should make it output its original output. Can I take an input for currentDate or something? \$\endgroup\$ – Albert Renshaw Apr 2 '17 at 4:00
  • 6
    \$\begingroup\$ Hiding code within other code makes this an underhanded challenge, and these are no longer welcome on the site. Moreover, "most creative" popularity contests lack an objective winning criterion and have fallen out of favor. \$\endgroup\$ – xnor Apr 2 '17 at 4:44
  • \$\begingroup\$ This challenge is underhanded, and such challenges are no longer on-topic. \$\endgroup\$ – Erik the Outgolfer Apr 2 '17 at 8:15
  • \$\begingroup\$ @EriktheOutgolfer Huh? It looks more like a decision-problem to me. \$\endgroup\$ – lol Apr 2 '17 at 8:16
  • \$\begingroup\$ @SIGSEGV Also a decision-problem, and not kolmogorov-complexity, but challenges that ask for answers which appear to do something else than what they really do are underhanded. \$\endgroup\$ – Erik the Outgolfer Apr 2 '17 at 8:19
5
\$\begingroup\$

TI-Basic (TI-84 Plus CE)

{1001,10,1}→LA
{1010,1,1}→LA
{1011,11,1}→LB
{1020,2,1}→LC
{1021,12,1}→LD
{1030,3,1}→LE
{1040,4,1}→LF
{1050,5,1}→LG
{1060,6,1}→LH
{1070,7,1}→LI

getDate→L1

IF L1(2)=LA(2) and L1(3)=LA(3):Then
"Happy October First!"
End
IF L1(2)=LB(2) and L1(3)=LB(3):Then
"Happy New Year!"
End
IF L1(2)=LC(2) and L1(3)=LC(3):Then
"Happy November First!"
End
IF L1(2)=LD(2) and L1(3)=LD(3):Then
"Happy February First!"
End
IF L1(2)=LE(2) and L1(3)=LE(3):Then
"Happy December First!"
End
IF L1(2)=LF(2) and L1(3)=LF(3):Then
"Happy March First!"
End
IF L1(2)=LG(2) and L1(3)=LG(3):Then
Disp "Happy April Fool's Day!"
Return:End
IF L1(2)=LH(2) and L1(3)=LH(3):Then
"Happy May First!"
End
IF L1(2)=LI(2) and L1(3)=LI(3):Then
"Happy June First!"
End
IF L1(2)=LJ(2) and L1(3)=LJ(3):Then
"Happy July First!"
End

ClrHome
Output(1,1,toString(10000LA(1)+100LA(2)+LA(3)))
Output(2,1,toString(10000LB(1)+100LB(2)+LB(3)))
Output(3,1,toString(10000LC(1)+100LC(2)+LC(3)))
Output(4,1,toString(10000LD(1)+100LD(2)+LD(3)))
Output(5,1,toString(10000LE(1)+100LE(2)+LE(3)))
Output(6,1,toString(10000LF(1)+100LF(2)+LF(3)))
Output(7,1,toString(10000LG(1)+100LG(2)+LG(3)))
Output(8,1,toString(10000LH(1)+100LH(2)+LH(3)))
Output(9,1,toString(10000LI(1)+100LI(2)+LI(3)))
Output(10,1,toString(10000LJ(1)+100LJ(2)+LJ(3)))

Uses OEIS A210884.

Stores the numbers as dates and converts them on-the-fly to output. It even leaves you a message in Ans if today is one of the dates!

\$\endgroup\$
  • \$\begingroup\$ Nice one! You only display April fools and use other ones as a way to hide the sequence, right? \$\endgroup\$ – lol Apr 2 '17 at 4:18
  • \$\begingroup\$ @SIGSEGV Yes, at first I was going to use Goto and have the label many many blank lines after the last Output to hide it, but that seemed a bit too obvious. \$\endgroup\$ – pizzapants184 Apr 2 '17 at 4:28
  • \$\begingroup\$ Well, I think I did corrupt too much on getting the month. See mine. \$\endgroup\$ – lol Apr 2 '17 at 4:41
  • \$\begingroup\$ You can omit ) or } at the end of a line or before , if TI didn't decide to scrap that feature from the TI-84+CE. You can also remove the small L from the variable being stored when assigning a value to a list. \$\endgroup\$ – bb94 Apr 12 at 22:35
5
\$\begingroup\$

C

I use some fun CLANG properties to do tricky math and print the text sneakishly. I am printing the sequence of even numbers 0,2,4,6 etc up to 42.

This is a nice solution because I don't use any letters or hard coded strings, just pure math trickery to end up outputting the desired text even though it appears to a human brain that this should just be outputting 0,2,4,6,etc

Try it online! (Just the sneaky April Fools Day version)

#define printNumber(x) printf("%c", x)

main() {

    SYSTEMTIME st;
    GetLocalTime(&st);
    BOOL isFunDay = (st.wDay == 4 && st.wDay == 1);

    if (isFunDay) {
        printEvenNumbersTheFunWay();//fun way for a fun day!
    } else {
        printSomeEvenNumbersTheBoringWay();
    }

}

printEvenNumbersTheFunWay() {

    //print sequence: 0,2,4,6,8,10,12,14...42

    //print 0
    #define zero 72-72
    printNumber(2*zero+0);

    //print 2
    #define zero 5-5
    printNumber(20*zero+2);

    //print 4
    #define zero 108-108
    printNumber(2*zero+4);

    //print 6
    #define zero 106-106
    printNumber(2*zero+6);

    //print 8
    #define zero 113-113
    printNumber(2*zero+8);

    //print 10
    #define zero 22-22
    printNumber(2*zero+10);

    //print 12
    #define zero 53-53
    printNumber(2*zero+12);

    //print 14
    #define zero 98-98
    printNumber(2*zero+14);

    //print 16
    #define zero 98-98
    printNumber(2*zero+16);

    //print 18
    #define zero 87-87
    printNumber(2*zero+18);

    //print 20
    #define zero 88-88
    printNumber(2*zero+20);

    //print 22
    #define zero 10-10
    printNumber(2*zero+22);

    //print 24
    #define zero 46-46
    printNumber(2*zero+24);

    //print 26
    #define zero 85-85
    printNumber(2*zero+26);

    //print 28
    #define zero 83-83
    printNumber(2*zero+28);

    //print 30
    #define zero 78-78
    printNumber(2*zero+30);

    //print 32
    #define zero 7-7
    printNumber(2*zero+32);

    //print 34
    #define zero 81-81
    printNumber(2*zero+34);

    //print 36
    #define zero 2-2
    printNumber(-1*zero+36);

    //print 38
    #define zero 30-30
    printNumber(2*zero+38);

    //print 40
    #define zero 57-57
    printNumber(2*zero+40);

    //print 42
    #define zero 79-79
    printNumber(2*zero+42);

    //print 44
    #define zero 1-1
    printNumber(-10*zero+44);

}

printSomeEvenNumbersTheBoringWay() {

    //print sequence: 0,2,4,6,8,10,12,14...42

    int i = 0;
    while (i <= 42) {
        printf("%i, ", i);
        i+=2;
    }

}
\$\endgroup\$
  • \$\begingroup\$ Isn't this just the same answer as your deleted one? \$\endgroup\$ – Erik the Outgolfer Apr 2 '17 at 8:21
  • \$\begingroup\$ My deleted one used a BOOL for detecting date which was not valid for this competition so I posted this valid submission which actually checks system-time \$\endgroup\$ – Albert Renshaw Apr 2 '17 at 16:20
4
\$\begingroup\$

JS, A000027

d=new Date();
if(d.getMonth()+("")[(![]+"")[+[]]+"ontcol"+(!![]+[]["fi"+(![]+"")[!+[]+!+[]]+"l"])[10]+"r"]()[11]+("")["fon"+(!![]+"")[0]+"color"]()[11]+!+[]+!+[]*!+[]+!+[]&&d.getDate()==+!+[])alert("Happy April Fool's Day!");
else{for(i=0;i<10;)alert(++i);}

Mmm, good mixture of JS and JSF*ck. (Fun fact: The majority of the code is used to represent ==.)

Good tip for corrupting code like mine: JS to JSFuck Conversion code/list

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

Python 2, A000027

import datetime as a
if(str(a.date.today())[5:]=='04-01'):print("Happy April Fool's Day!")
else:
 for i in range(10):print(i+1)

Try it online!

\$\endgroup\$

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