34
\$\begingroup\$

As a child, my friend had a magic 8 ball that we would ask questions to and see what the fate of that question was.

Challenge

Your challenge is to write a program (or function) that when run (or called), outputs (or returns) a random answer from the possible answers below. (Random being: each output should have a nonzero chance of occurring but they do not need to meet any other criteria)

The possible answers from the Magic 8-ball are (case-insensitive):

It is certain
It is decidedly so
Without a doubt
Yes definitely
You may rely on it
As I see it, yes
Most likely
Outlook good
Yep
Signs point to yes
Reply hazy try again
Ask again later
Better not tell you now
Cannot predict now
Concentrate and ask again
Don't count on it
My reply is no
My sources say no
Outlook not so good
Very doubtful

Input

No input.

Output

A random choice from above. Case does not matter.

Rules

Standard loopholes are not allowed.

This is , so the shortest code in bytes for each language wins!

\$\endgroup\$
  • 2
    \$\begingroup\$ I changed "no input allowed" to "no input", some languages require blank/null arguments as inputs. \$\endgroup\$ – Rɪᴋᴇʀ Mar 7 '18 at 21:21
  • 12
    \$\begingroup\$ Is it me or someone is downvoting every answers?????? \$\endgroup\$ – Dat Mar 7 '18 at 21:33
  • 1
    \$\begingroup\$ @Dat I posted something here in meta to discuss this. I have upvoted every answer, as I always do for answers that fulfil the requirements on my questions. Maybe a moderator will intervene... \$\endgroup\$ – DevelopingDeveloper Mar 7 '18 at 21:42
  • 37
    \$\begingroup\$ @Dat Signs point to yes \$\endgroup\$ – mbomb007 Mar 7 '18 at 22:10
  • 1
    \$\begingroup\$ @mbomb007 My favorite comment I have seen on PPCG thus far! \$\endgroup\$ – DevelopingDeveloper Mar 7 '18 at 22:20

32 Answers 32

-1
\$\begingroup\$

C (gcc), 408 bytes

f(s){char*p="It is certain\0It is decidedly so\0Without a doubt\0Yes definitely\0You may rely on it\0As I see it, yes\0Most likely\0Outlook good\0Yep\0Signs point to yes\0Reply hazy try again\0Ask again later\0Better not tell you now\0Cannot predict now\0Concentrate and ask again\0Don't count on it\0My reply is no\0My sources say no\0Outlook not so good\0Very doubtful";for(s=time(0)%20;s;)*p++?0:s--;s=p;}

Try it online!

Users are hard to predict, making the timing of their decision to call the function pseudo-random enough for our purposes.

\$\endgroup\$
-1
\$\begingroup\$

Excel Google Sheets, 319+21 = 342 340 Bytes

=INDEX(A:A,1+20*RAND(

Where cells A1:A19 contain the different output options. Reads from the array using a random index. Saves a whole load of bytes by avoiding a delimiter in the list

Saved 2 bytes thanks to Taylor Scott

\$\endgroup\$
  • \$\begingroup\$ I have some concerns about this answer - 1, with raw text and no delimiters, there are 319 bytes of data, and 2 I think that you should have to count have to count a single byte towards delimiting the cell data, because in its raw text represntation - that is if you were to store the data as a CSV (comma-delimited) or an ASC file - there would be a single , character separating the columns' values (or \n separating the rows) \$\endgroup\$ – Taylor Scott Mar 9 '18 at 16:01
  • \$\begingroup\$ That said, you can drop 2 bytes off of your score by switching to Google Sheets and dropping the terminal )) \$\endgroup\$ – Taylor Scott Mar 9 '18 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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