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.


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
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


No input.


A random choice from above. Case does not matter.


Standard loopholes are not allowed.

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

  • 2
    \$\begingroup\$ I changed "no input allowed" to "no input", some languages require blank/null arguments as inputs. \$\endgroup\$ Mar 7 '18 at 21:21
  • 13
    \$\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\$ Mar 7 '18 at 21:42
  • 39
    \$\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\$ Mar 7 '18 at 22:20

33 Answers 33


VBA, 358 bytes

An anonymous VBE immediate window function that takes no input and outputs to STDOUT.

?Split("It is certain1It is decidedly so1Without a doubt1Yes definitely1You may rely on it1As I see it, yes1Most likely1Outlook good1Yep1Signs point to yes1Reply hazy try again1Ask again later1Better not tell you now1Cannot predict now1Concentrate and ask again1Don't count on it1My reply is no1My sources say no1Outlook not so good1Very doubtful",1)(19*Rnd)

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.


Excel Google Sheets, 319+21 = 342 340 Bytes


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

  • \$\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\$ 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\$ 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.