# Introduction

The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen.

Your challenge is to code a function or program that takes no input, and on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft".

# Scoring

This is , shortest wins!

• All solutions so far will not satisfy the challenge as stated (they might, but highly unlikely). It has in fact been misstated - it is correct in the introduction, but the challenge asks for something different Apr 25 at 11:10
• @jonrandy What do you mean? Apr 25 at 11:12
• The introduction talks about a 1 in 10000 chance, whereas the challenge asks for a function/program that returns "Minceraft" EXACTLY once and "Minecraft" the rest of the time. This would be achieved with a loop. The solutions below are doing what is stated in the introduction, which is different Apr 25 at 11:15
• Suggest edit: "on average 1 out of 10000 times", assuming this is the intention, to satisfy nitpickers... Apr 25 at 11:16
• how precisly does it have to be 1/10000 ? multiple answers have 1/10001 for example Apr 26 at 14:01

# Scratch, 71 bytes

define
say[Minecraft
if<(pick random(0)to(9999))=[0]>then
say[Minceraft


Uses scratchblocks syntax.

• but then wouldn't this say minecraft and minceraft one in 10000 times? I believe only Minceraft should be outputted in that case
– user100690
May 8 at 16:41
• @ophact The "say" block makes the sprite display the specified text in a speech bubble, overriding the previously displayed text. Only Minceraft would appear. May 9 at 15:43

# Excel, 41 40 bytes

-1 byte thanks to MarcMush

="Min"&IF(RAND()<0.1^4,"ce","ec")&"raft"


I tried typing 0.0001 as 1E-4 to save two bytes. Excel changes it to 0.0001.

# Raku, 31 bytes

{"Min{<ce ec>[rand>1e-4]}raft"}


Try it online!

# Wolfram Language, 5047 42 bytes

Thanks to MarkMush for -1 byte and Michael Seifert for -4 bytes

If[Random[]<.1^4,"Minceraft","Minecraft"]&


Try it online!

Unfortunately, joining strings doesn't help to shorten this at all; the following is one byte longer:

"Min"<>If[Random[]<.1^4,"ce","ec"]<>"raft"&


Previous solution:

RandomChoice[{9999,1}->{"Minecraft","Minceraft"}]&


Try it online!

• If you're OK with deprecated functions, Random[] does the same thing as RandomReal[] and saves you four bytes. Apr 27 at 13:57

# Julia, 39 bytes

f()="Min$(rand()<1e-4 ? :ce : :ec)raft"  Try it online! # Thue, 100 bytes A::=~Minecraft B::=~Minceraft 10::=A 10::=1 12::=A 12::=A 12::=A 12::=A 12::=1 13::=B ::= 1000022223  Try it online! NB: TIO's version of Thue requires a trailing newline. Here is one such interpreter that has no such restriction. You can replace 1000022223 with 103 to convince yourself that a 50-50 chance works (although note again TIO's Thue interpreter seems to seed the RNG with the time in seconds, making quick, successive runs often have the same output). For more convincing, feel free to read my justification below. ## Explanation (For this explanation, I shall substitute "Minecraft" with x and "Minceraft" with y for clarity.) Outputting numbers with an arbitrary random chance isn't straightforward in Thue. We need to output y with a 1 in 10000 chance, and x otherwise. Thue's source of randomness is the way it chooses replacements to make: It samples the available valid substitutions and picks one at random to perform. We can bias the selection by increasing the number of substitutions we want to inflate. The naive approach would be to include 9999 replacements mapping to x, and 1 mapping to y, but this would be an inordinate amount of bytes. Instead, we'll encode 1/10000 by simulating its prime factors: $$\2^4\cdot5^4\$$. We can pretty easily simulate a binary choice: A::=~x B::=~y 13::=B 10::=A 10::=1 ::= 103  50% of the time, we'll replace 10 with A, immediately terminating further substitutions with A. The other 50% of the time, we'll replace it with 1. When we reach 13, we'll output B. We can generalize this quite easily, as inserting $$\N\$$ 0s gives a $$\\frac{1}{2^N}\$$ chance to output B. This process can be thought of as moving the 1 forward along a strip of 0s, with a 50% chance each time to terminate and output x. The 3 acts as the end of the road, allowing us to output B. The odds of it reaching the end are quite clearly $$\\frac{1}{2^N}\$$. Observe the following examples: For 10->A, 10->1: 103 = 50% / 50% (1/2) 1003 = 75% / 25% (1/4) 10003 = 87.5% / 12.5% (1/8) 100003 = 93.75% / 6.25% (1/16)  In fact, we can simulate a $$\\frac{1}{K^N}\$$ chance by having $$\K-1\$$ copies of the replacement 10::=A, and 1 copy of the replacement 10::=1. For $$\K=5\$$, this gives an 80% chance at each step to terminate and output x, rather than the 50% chance in the previous example. Observe the following: For (12->A)x4, 12->1 123 = 80% / 20% (1/5) 1223 = 96% / 4% (1/25) 12223 = 99.2% / 0.8% (1/125) 122223 = 99.84% / 0.16% (1/625)  Concatenating both yields 1000022223, with a combined chance of $$\\frac{1}{2^4}\cdot\frac{1}{5^4}=\frac{1}{10000}\$$. We can justify this to ourselves empirically. For N=1000000 trials, we would expected to see about 1000000/10000 == 100 instances of y. And, from one such trial: x: 999892 (99.98%) y: 108 (0.01%)  We can see this is quite convincingly the case. ## Alternative version, 102 bytes A::=~Minecraft B::=~Minceraft 013::=A 013::=13 12::=A 12::=A 12::=A 12::=A 12::=01 .13::=B ::= .122223  This one generates the 0s on the fly, exploiting the symmetry between the prime factors. It's unfortunately 2 bytes longer, as the more complicated behavior requires extra symbols. ## Metagolfer For similar tasks, where one must output something with a 1/n chance, I've written a Ruby script that compiles a corresponding program. Of course, this works nicer for some numbers rather than others (a prime encoded by this approach requires lines equal to its value), so perhaps some ingenuity would be required for certain cases. if ARGV.empty? STDERR.puts "Insufficient arguments. Usage:" STDERR.puts " #$0 n"
exit 1
end
require 'prime'
$alphabet = "02456789abcdefghijklmnopqrstuvwxyz" n = ARGV[0].to_i comp = "" puts "[COMMENT]::=Inserts B with 1/n probability, A otherwise." Prime::prime_division(n).each_with_index { |(prime, count), i| (1..prime).each { |k| print "1#{$alphabet[i]}::="
puts k == prime ? "1" : "A"
}
comp << $alphabet[i] * count } puts "13::=B" puts "::=" puts "1#{comp}3"  # C# (Visual C# Interactive Compiler), 54 53 bytes -1 thanks to caird coinheringaahing _=>$"Min{(new Random().Next(10000)<1?"ce":"ec")}raft"


Try it online!

• Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in C# page for ways you can golf your program. You can assume an unused input, so can change () to _ for -1 byte Apr 27 at 20:56
• Thanks for the feedback! Those posts are super helpful Apr 27 at 21:08

# PPL 1.0.10, 108 bytes

importRandom
declarex=Random.random()*10000
ifx>1{
printLine("Minecraft")
}
ifx<=1{
printLine("Minceraft")
}


This must use v1.0.10 because imports were introduced. This reuses the "mash together tokens" that emerged as a product of my sloppy lexer writing.

# Commented

note, comments do not exist in PPL

importRandom           // import the module Random, one of three standard libraries
declarex=              // declare variable x
Random.random()        // set to pseudo-random number between 0 and 1 (random property)
*                      // ... times...
10000                  // 10000 (no 1e4)
ifx>1{                 // if x is greater than 1 then
printLine("Minecraft") // print "Minecraft" to STDOUT
}                      // closing code block
ifx<=1{                // no "else" in PPL, so use opposite condition instead
printLine("Minceraft") // print "Minceraft" to STDOUT
}                      // closing code block


# Java (JDK), 45 bytes

e->Math.random()<1e-4?"Minceraft":"Minecraft"


Try it online!

# Python, 73 71 bytes

-2 bytes thanks to @cairdcoinheringgaahing

from random import*
print("Minec%sraft"%("e"if randint(1,1e4)<1else""))


Try it online!

Explanation:

The first line imports everything from the random module. randint(1,1e4) chooses a random number from 1 to 10000 if it is 1, print Mineceraft. If not, print Minecraft

• Welcome to Code Golf, and nice first answer! You can remove the space after the ,, you can change the ==1 to <2, and be sure to check out our Tips for golfing in Python page for ways you can golf your program Sep 14 at 17:33

# Braingolf, 25 bytes

"Minec"v%*rc?:,|"raft"&@;


Try it online!

### Explanation

"Minec"                     - Push "Minec" to stack
v                    - Switch to next stack
%                   - Niladic modulus, push 100
*                  - Monadic multiplication, square top of stack (10000)
r                 - Pop top of stack and generate random integer 0 <= n < x where x is popped val
c                - Collapse stack to main stack
?: |            - Pop top of stack, if 0...
,               - ...swap top 2 items on stack ('e' and 'c')
"raft"      - Push rest of string
&@    - Print entire stack as ASCII
;   - Prevent implicit output


When and only when the generated random number is 0, this will output Minceraft, otherwise it will output Minecraft.

Braingolf's r instruction uses Python3's random.randrange function, which to my knowledge should be sufficiently uniform for this challenge, and takes an exclusive maximum, meaning calling r on 10000 is equivalent to random.randrange(10000), which generates a number x where 0 <= x < 10000.
This leads to a 1/10000 chance of generating a 0, and thus a 1/10000 chance of outputting Minceraft

# Vyxal, R, 21 bytes, Courtesy of Lyxal and ManishKundu

«ɽL3Gp↵¢¨Π°ꜝ«½k2℅1=iǐ


Try it Online!

# Vyxal, 30 bytes

Mink2ʀ℅1>[ec|ce]+raft+


Try it Online!

Well someone help me to compress these strings.... no no don't compress, compressing this yield larger strings....

• I think you can just push the strings to the stack and use the s flag to concatenate them, so you can remove the +s Apr 25 at 11:46
• @cairdcoinheringaahing i have tried that way earlier but it didn't work Apr 25 at 11:50
• I think that might be a bug then. If you remove the +s and just add a W though, you can get 29 bytes Apr 25 at 12:09
• how about 22 bytes? Apr 25 at 12:11
• or this for 21 bytes? Apr 25 at 12:20

# Japt, 25 bytes

The code snippet below seems to bug out on the compressed nonprintable chars, please see the link for the correct string.

"ec"                  // U = string constant
M  {MqL²Ä ?U:Uw}ft
{           }     // Insert
?U:Uw      // either U or U reversed depending on whether
Mq               // a random number in range
L²Ä            // [0, 10001) is truthy or not
M               ft  // into a compressed string


Try it here.

# APL (Dyalog Unicode), 25 bytes

A port of Jonah's great J answer.

{4⌽'raftMin','ce'⌽⍨×?1e4}


Try it online!

## My previous answer, 30 bytes

{'Min','raft',⍨2↑'cec'↓⍨×?1e4}


Try it online!

A dfn whose argument doesn't matter. Requires 0-indexing.

{'Min','raft',⍨2↑'cec'↓⍨×?1e4}
?1e4 ⍝ Random number in range [0, 10000)
×     ⍝ Signum (0 if 0, 1 if >0)
'cec'↓⍨      ⍝ Drop those many elements from 'cec'
⍝ 1 in 1e4 chance of not dropping the first 'c'
2↑             ⍝ Keep only the first 2 characters
'raft',⍨                ⍝ Prepend to 'raft'
'Min',                        ⍝ Append to 'Min'

• You might be able to save some bytes with one of my J approaches. The APL translations are typically shorter than the J, which is 27/28 here. Apr 25 at 19:44

# F# (.NET Core), 70 bytes

fun _->"Min"+(if System.Random().Next(9999)=1 then"ce"else"ec")+"raft"


Try it online!

# Pari/GP, 44 bytes

Str("Min",if(random%10000,"ec","ce"),"raft")


Try it online!

# CSASM v2.4.0.1, 110 bytes

func main:
push 10000
extern Random.Next(i32)
brtrue a
push "Minceraft"
br b
.lbl a
push "Minecraft"
.lbl b
print
ret
end


extern Random.Next(i32) calls Random.Next(int) on a System.Random object
Therefore, it will return a value in $$\[0, 10000)\$$
Non-zero integers are truthy in CSASM, so the brtrue instruction will be successful $$\1/10000\$$ of the time

# Bash (pure Bash, 54 bytes)

[ $[RANDOM % 10000] = 0 ]&&s=ce||s=ec;echo Min${s}raft


Since echo always returns 0, this kind of condition works.

• 53 bytes: s=ec;[ $[RANDOM % 10000] = 0 ]&&s=ce;echo Min${s}raft Apr 26 at 15:22
• 42 bytes Try it online! Apr 27 at 6:48
• $RANDOM is between 0 and 32767, so the odds are 4/32768 or 1/8192 rather than 1/10000. – l0b0 Apr 27 at 9:19 # Batch, 55 bytes @if %RANDOM% LEQ 3 (echo Mincecraft)else echo Minecraft  (No TIO link because TIO does not support batch.) %RANDOM% returns a random integer between 0 and 32767, and the if statement checks to see if it is less than or equal to 3. There are 4 integers between 0 and 3 inclusive, and a $$\4 \over 32768\$$ chance is just slightly better than 1 in 10000. # Exactly 1 in 10000 odds, 72 bytes @set/a r=%RANDOM%%%10000 @if %r%==1 (echo Mincecraft)else echo Minecraft  • It would be nice to also see how many bytes you'd need in BATCH to get exactly 1 in 10000... Apr 26 at 6:52 • Q: is r equal to a random integer between 0 and 32767, modulo 10000? If so, surely the chance of getting '1' is still 4 in 32767 (with r values of 1, 10001, 20001 and 30001)? Or don't I understand BATCH properly...? Apr 26 at 9:34 • You're right about four values returning 1, but the odds are better now because there are also four values that return 2, four values that return 3, four values that return 4, etc. Apr 26 at 16:30 • 4/32768=1/8192, or 18% better than 1/10000. – l0b0 Apr 27 at 9:22 # TI-Basic, 38 bytes "ec If rand<ᴇ-4 "ce "Min"+Ans+"raft  Ti-Basic is a tokenized language, I used what my TI-83+ says (48-10=38) # Python 3, 59 bytes import time;print(f'Min{"ecce"[time.time()%1e4<1::2]}raft')  Basically combining a few other suggestions here (although I did mostly work it out myself anyway). It took a while to realize that using from time import* actually costs a byte overall. # Julia, 35 bytes "Min$(rand()<1e-4 ? :ce : :ec)raft"


Try it online!

• this is a full program, so you have to include println in the code. Apr 27 at 16:32

# Perl -M5.010, 31 bytes

say"Min${time%1E4?\ec:\ce}raft"  Try it online! Prints "Minecraft" when run during a 2h 46m 39s window (9999 seconds), and "Minceraft" during a 1 second window. This takes advantage of the fact the challenge just stays "on average 1 in 10000 times", without mentioning a distribution. # Pxem, 0 bytes: content + 30 bytes: filename. • Content is empty. • Filename (escaped): \144\144ceraft.!.r\001.z.s.sXXec.aMin.p ## Algorithm 1. Push "ceraft". 2. Generate a random number between 0 to 9999. 3. Unless it is 1, fix the string "ceraft" with "ecraft". 4. Insert "Min" and print it. Try it online! # Python 2/3, 58 bytes from random import*;choice(["Minec"]*9999+["Mince"])+"raft"  No idea whether the result has to be printed, so... + 6 bytes in Python 2 if print necessary from random import*;print choice(["Minec"]*9999+["Mince"])+"raft"  and + 7 bytes in Python 3 from random import*;print(choice(["Minec"]*9999+["Mince"])+"raft")  # BRASCA, 21 bytes MinecHH*{?0=#$raft


Try it online!

## Explanation

Minec                 - Push "Minec"
HH*{?            - Push a random number between 0-9999 (inclusive)
0=#$- If 0, swap the top two stack items (the "e" and "c"), else skip raft - Push "raft" <implicit> - Output the string  # Javascript, 59 bytes console.log(Min${['ec','ce'][+(Math.random()<1e-4)]}raft)

One less thanks to @ophact !

• minus 1 byte by removing the zero: +(Math.random()<1e-4)
– user100690
May 12 at 5:30
• And where did you get that 47 byte figure?
– user100690
May 12 at 5:32
• @ophact The text inside the console.log is 47 bytes length. Wasn't sure of how to count there, console.log is not really part of the solution :) May 12 at 7:31

# Troll, 40 bytes

Prints Minceraft if throwing a 10000-sided die(!?) results in a 1.

if1=d10000then"Minceraft"else"Minecraft"


Try it online! (Make random rolls. produces a single output, Calculate probabilities. shows the probability of each possible output)

Sadly a lot less things are possible with strings rather than integers, otherwise this would be possible:

"Mince"U9999#"Minec"pick1||"raft"


# Silicon, 28 23 bytes

-5 bytes thanks to @ovs

"Min""ec"Ôs~={R}"raft"â


Explanation

"Min""ec"Ôs~={R}"raft"â

"Min""ec"                 - Push "Min" and "ec"
Ôs               - Push 100 and square it
~=             - Pick a random number between 0 and 10000, then
check if it's equal to the previous stack item
{R}          - If true, reverse the topmost stack item ("ec")
"raft"    - Push "raft"
â   - Join stack
<implicit>                - Implicit output


28 bytes

"Min"ÔÔ*~={"ce},{"ec}"raft"â


First code golf challenge in 5 years! It's good to be back.

Silicon uses the CP037 code page.

• I think "Min""ec"Ôs~=(R)"raft"â works for 23
– ovs
Sep 23 at 15:03
• @ovs Outgolfed in my own language! Thank you haha :)
– m654
Sep 23 at 17:21

# JavaScript (Node.js), 44 bytes

e=>Min\${Math.random()<1e-4?'ce':'ec'}raft


Try it online!

• Why's there a " near the start? It's not meant to be there, and you can save a byte by removing i. Oct 5 at 18:49
• @emanresuA : sorry for late reply(very late) , removed " and not sure about i ? Oct 25 at 13:49