# 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 – jonrandy Apr 25 at 11:10
• @jonrandy What do you mean? – A username 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 – jonrandy Apr 25 at 11:15
• Suggest edit: "on average 1 out of 10000 times", assuming this is the intention, to satisfy nitpickers... – Dominic van Essen Apr 25 at 11:16
• how precisly does it have to be 1/10000 ? multiple answers have 1/10001 for example – MarcMush Apr 26 at 14:01

# 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 – caird coinheringaahing Apr 25 at 11:46
• @cairdcoinheringaahing i have tried that way earlier but it didn't work – Wasif 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 – Manish Kundu Apr 25 at 12:09
• how about 22 bytes? – lyxal Apr 25 at 12:11
• or this for 21 bytes? – lyxal 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. – Jonah 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!

# 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 – spuck Apr 26 at 15:22
• 42 bytes Try it online! – Nahuel Fouilleul 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... – Dominic van Essen 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...? – Dominic van Essen 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. – SomethingDark Apr 26 at 16:30 • 4/32768=1/8192, or 18% better than 1/10000. – l0b0 Apr 27 at 9:22 # C# (Visual C# Interactive Compiler), 55 bytes ()=>$"Min{(new Random().Next(0,9999)>0?"ec":"ce")}raft"


Try it online!

• Exactly the same length without interpolation. (I like interpolation too. I was just surprised by the tie.) ()=>new Random().Next(0,9999)>0?"Minecraft":"Minceraft" – Merkle Groot Apr 26 at 17:57
• @MerkleGroot I didn't even consider that idea as I was sure it would be longer, but surprisingly it's exactly the same! Guess I overcomplicated it a bit haha – speyck Apr 27 at 8:27

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

# 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. – Razetime Apr 27 at 16:32 # 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"  # Zsh--cprecedences, 44 bytes x=(ce ec) <<<Min${x[RANDOM*1e4>>15?2:1]}raft


Try it online! (modified to make it happen 1 in 10 times and then test the program 500 times to build a frequency table)

Unlike the existing Bash answer, this actually has a $$\ \frac{1}{10000} \$$ chance, using (RANDOM*1e4)>>15.

• $RANDOM (henceforth $$\ R \$$) is uniformly distributed in $$\ [0, 2^{15}) \$$ • RANDOM*1e4>>15: (equivalent to $$\ R \times 10000 \div 32768 \$$) gives a uniformly distributed number in the range $$\ [0, 10000) \$$ • Intuitively: $$\ R \times 10000 \$$ changes the range to $$\ [0, 10000 \times 2^{15}) \$$, and $$\ R \times 10000 \div 32768 \$$ changes it to $$\ [0, 10000) \$$ • More formal proof • --cprecendeces changes the precedence of >> to be more normal like in C, so we don't need parentheses around RANDOM*1e4 • So (RANDOM*1e4)>>15?2:1 returns 1 if the number is 0 (i.e., 1 in 10000 times), and 2 otherwise • Then we index that into the array x=(ce ec), returning mostly ec but sometimes ce • Finally, construct the string like Min$raft and <<< print it

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. # 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  # Pari/GP, 44 bytes Str("Min",if(random%10000,"ec","ce"),"raft")  Try it online! # Julia, 41 bytes print(:Min,rand()<1e-4 ? :ce : :ec,:raft)  Try it online! # 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 – Recursive Co. 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. – Bo_Tie May 9 at 15:43 # 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) # Lua, 52 bytes print(1<math.random(1e4)and'Minecraft'or'Minceraft')  Try it online! # Dart, 71 bytes import'dart:math';f()=>"Min${Random().nextInt(10000)<1?'ce':'ec'}raft";


Try it online!

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

# Javascript 47 46 bytes

Reach 60 59 with the console.log().

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) – Recursive Co. May 12 at 5:30 • And where did you get that 47 byte figure? – Recursive Co. 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 :) – Elanis May 12 at 7:31 # 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