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

Jelly (fork), 16 bytes

ȷ4XỊị“ẹ?ŀɼƲṬỴȧ«

Try it online!, or rather, don't

Tested on commit 6167f95, made on March 13th. Doesn't work on the latest commit due to a bug (a.k.a I accidentally removed the functionality that makes this work)

How it works

ȷ4XỊị“ẹ?ŀɼƲṬỴȧ« - Main link. Takes no argument
ȷ4               - 10000
X              - Random integer between 1 and 10000
Ị             - Turn 1 into 1 and everything else into 0
“ẹ?ŀɼƲṬỴȧ« - Compressed dictionary string "Minceraft Minecraft", split on spaces
ị            - Index into the list of words

“...« is a new string terminator introduced in my fork that's equivalent to “...»Ḳ¤/“...»Ỵ¤ in the current version of Jelly. It decompresses the string in between the “...«, then splits on whitespace.

Minecraft, 358293277 276 bytes

Implementing Minceraft in Minecraft

Should be run as a set of commands in game. Should be run on a fresh superflat (redstone ready) world. Byte count is the amount of characters you need to type, including newlines.

/summon bat
/execute as @e[type=bat] store result score o s run data get entity @s UUID[1]
/scoreboard players set c s 2147054151
/execute if score o s < c s run tellraw @s "Minecraft"
/execute if score o s >= c s run tellraw @s "Minceraft"

The UUID of an entity is (mostly) randomly generated and stored as four signed 32 bit integers. One of the integers is compared with 2147054151 which is one ten thousandth of the way between 2^31 and -2^31.

Previous solution because it was so high effort and I'm not deleting it:

Minecraft, 293 bytes

/summon horse
/execute as @e[type=horse] store result score o s run data get entity @s Attributes[1].Base 100000
/scoreboard players set c s 11883
/execute if score o s >= c s run tellraw @s "Minecraft"
/execute if score o s < c s run tellraw @s "Minceraft"

How does it work?

In Minecraft, there are only a limited amount of sources of reliable randomness usable in commands. In Minecraft Functions you can use predicates with specific random chances, but that requires multiple files and submitting that as a zipped data pack would be at least 1 KB.

To avoid this and have it run solely from commands a player can type in, this uses horses as a random source. When a horse is spawned, it is assigned a random speed between 0.1125 and 0.3375 (the units are arbitrary). The random speed calculation is as follows:

$$0.25(0.45 + 0.3x + 0.3y + 0.3z)$$

Where x, y, and z are uniform independent random variables [0, 1). If you find the cumulative density function by convolving the distribution functions (to get the PDF) and then integrating, you will end up with the following piecewise function:

$$f(x)=\begin{cases}-\frac{9}{16}+15x-\frac{400x^{2}}{3}+\frac{32000x^{3}}{81}&\frac{9}{80}\le x<\frac{3}{16}\\ \frac{29}{4}-110x+\frac{1600x^{2}}{3}-\frac{64000x^{3}}{81}&\frac{3}{16}\le x<\frac{21}{80}\\ -\frac{227}{16}+135x-400x^{2}+\frac{32000x^{3}}{81}&\frac{21}{80}\le x<\frac{27}{80} \end{cases}$$

We need to find the horse speed where the probability of a horse with that speed or lower spawning is one in ten thousand or 0.0001. This can be done by solving the first equation:

$$-\frac{9}{16}+15x-\frac{400x^{2}}{3}+\frac{32000x^{3}}{81} = 0.0001\\ f^{-1}(0.0001)\simeq0.11882574$$

This results in the horse speed being multiplied by 100,000 (because scoreboard values must be integers) and compared with 11883 in the code.

The precision is currently 1.00202 in 10,000. Two bytes can be added or removed for approximately each order of magnitude required. Two additional bytes will make it 1.00012 in 10,000.

• I see no reason to run these separately over putting them all in a .mcfunction file and running that. – Egor Hans Apr 27 at 7:11
• Minecraft datapacks require a pack.mcmeta which would make it too expensive. However, I am not certain of the consensus regarding Minecraft commands. – Okx Apr 27 at 7:20
• I'd argue the pack.mcmeta doesn't count towards the size, only the .mcfunction file. After all, codegolf.stackexchange.com/a/224450/62991 doesn't count the time module's size either. – Egor Hans Apr 27 at 7:23
• This is also a "full program" (as much as you can get a full program in Minecraft) compared to a function as you cannot reliably run it multiple times in one world. – Okx Apr 27 at 16:23
• Aww, I was hoping you built a giant Redstone computer in the game to run this program, would be hard to give that a byte-count though. Maybe count in number of blocks? – Darrel Hoffman Apr 27 at 18:08

Python 3, 63 59 bytes

My idea was to use the time module as a PRNG since the challenge stated

on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft"

and taking the time mod 10000 does exactly that.

Thanks @movatica for -4

import time
print(f"Min{'ceec'[time.time()%1e4>1::2]}raft")

Try it online!

Alternative, also 59 bytes:

import time
print("Min%sraft"%"ceec"[time.time()%1e4>1::2])

Try it online!

• Right, fixed. :) – EnderShadow8 Apr 26 at 13:40
• you should add a tio link, so that it's easier for other people to test your code – MarcMush Apr 26 at 14:13
• Can't you replace time()%1e4>1 and'ec'or'ce' with ['ec','ce'][time()%1e4>1] for -1? – Command Master Apr 26 at 14:40
• 61 bytes – Command Master Apr 26 at 15:01
• Welcome to codegolf! 59 bytes – movatica Apr 26 at 17:02

Python 3, 787169 68 bytes

from random import*
f=lambda:f'Min{randint(0,1e4)and"ec"or"ce"}raft'

Try it online!

-7 bytes thanks to @Alex bries

-2 bytes thanks to @Alex bries

R, 4544 43 bytes

if(runif(1)<1e-4,"Minceraft","Minecraft")

Try it online!

Boring, but shorter than any more-interesting attempt that I've tried so far...

R, 42 bytes (p=0.000101) p=1 in 10000.5

Edit: much closer to exactly 1 in 10000 (for the same bytes) thanks to Robin Ryder

if(rexp(1)>1e-4,"Minecraft","Minceraft")

Try it online!

Outputs "Minecraft" if an exponentially-distributed random variable is greater than 1e-4.

The exponential distribution is governed by a parameter - lambda - that defaults to 1 in the R rexp() function. This gives cumulative p(up to x)=1-exp(-lambda*x), equal to 9.9995e-05 with x=1e-4 and lamda=1, which is pretty close to 1 in 10000 (actually 1 in 10000.5).

• Alternate 43 byte solution: c("Minecraft","Minceraft")[1.0001+runif(1)] – Robin Ryder Apr 27 at 16:50
• @RobinRyder - That's nice. I also realised we can also get almost to within 1% of the exact probability using a carefully-selected Poisson distribution, which would save 1 byte... – Dominic van Essen Apr 27 at 18:19
• If you want an approximation of the probability, this is also 42 bytes and is more accurate, with P("Minceraft")=0.000100005. – Robin Ryder Apr 27 at 21:10
• @RobinRyder - That's much better! Before I update the answer and credit you, can you just check my maths? Cumulative exponential distribution is 1-exp(-lambda*x), so with (default) rate=lambda=1, p(up to 1e-4)=1-exp(-0.0001)=9.9995e-05, right? In other words, pexp(1,rate=0.0001,lower.tail=T)? Or did I get something upside-down? – Dominic van Essen Apr 27 at 21:39
• Yes, you are right - the number I gave mistakenly was the value of lambda that would have led to an exact answer. Instead, the probability is indeed 0.000099995. – Robin Ryder Apr 28 at 6:20

Clojure, 42 bytes

#(str"Min"(if(<(rand)1e-4)"ce""ec")"raft")

Try it online!

Retina, 29 bytes

ce9999*$(ec L@$..
Min$&raft Try it online! Explanation: ce9999*$(ec

Insert ce and 9999 copies of ec.

L@..

Select one of the pairs of letters at random....

L$ Min$&raft

... and wrap it between Min and raft.

C (gcc), 48 bytes

f(){printf("Min%sraft",rand()%10000?"ec":"ce");}

Try it online!

Version closer to $$\\frac{1}{10000}\$$

For a pseudorandomness as close to $$\\frac{1}{10000}\$$ as possible:

C (gcc), 79 bytes

f(){long p=0,m=1e4,i;for(i=m;i--;)p+=rand();printf("Min%sraft",p%m?"ec":"ce");}

Try it online!

• Nice! Can you have 1e4 or 1e+4 in C? – A username Apr 25 at 12:29
• @Ausername float can't be %ed – l4m2 Apr 25 at 12:47
• @Ausername Yes C has that but it's a float and you need an integral type for a mod (%) expression. – Noodle9 Apr 25 at 19:20
• This will not result in a 1/10000 chance if RAND_MAX is not a multiple of 10000. – ericw31415 Apr 26 at 4:54
• @ericw31415 You might as well post this comment for every answer since they're all using PRNGs that work on scales of powers of $2$. Plus they're PRNGs not RNGs so there's no way to make them perfectly random. – Noodle9 Apr 26 at 13:25

Charcoal, 17 bytes

MinＰceraft¿‽×χφec

Try it online! Link is to verbose version of code. Explanation:

Min

Print Min.

Ｐceraft

Print ceraft without moving the cursor.

¿‽×χφ

If a random number in the range [0..10000) is nonzero, then...

ec

... correct it to ec.

"Min$(('ec','ce')[!(random 1e4)])raft" Try it online! • I don't know Powershell, but 1000 is 1e4, not 1e5. Is that a mistake? – caird coinheringaahing Apr 25 at 12:58 • thanks. The rule is "The game Minecraft has a 1 in 10000 chance". 10000 == 1e5 isn't it? – mazzy Apr 25 at 13:04 • Sorry, typo in my original comment. I meant 10000, not 1000. However 10000 == 1e4: Try it online! A helpful way to remember is that the number after the 1e counts the zeros, not the digits – caird coinheringaahing Apr 25 at 13:05 • Of course!) I'm sorry. Fixed. Thank you! – mazzy Apr 25 at 13:07 V (vim), 80 bytes iMin<Esc>:r!echo$RANDOM
C<c-r>=<c-r>"%10000
<esc>:s/^0\n/ce
:s/\d\+/ec
kgJAraft

Try it online!

Generate a random no. in 0-9999, and then replace 0 with ce and anything else with ec.

• i<C-r>=rand()%10000<cr><esc> is the random generator I came up with, doesn't work on TIO though sadly. – Citty Apr 26 at 17:34
• I think rand() needs a seed but I'm not too sure of it. – Razetime Apr 27 at 1:40

Jelly, 18 17 bytes

“ẹ?ŀɼƲṬỴȧ»ȷ4XỊịḲ

Try it online!

Full program.

-1 byte thanks to Jonathan Allan!

How it works

“ẹ?ŀɼƲṬỴȧ»ȷ4XỊịḲ - Main link. Takes no arguments
“ẹ?ŀɼƲṬỴȧ»       - Compressed string "Minceraft Minecraft"; Call that S
ȷ4     - 10000
X    - Random integer between 1 and 10000
Ị   - Is that equal to 1?
Ḳ - Split S on spaces
ị  - Index into the split S
• A 17: “ẹ?ŀɼƲṬỴȧ»ȷ4XỊịḲ. (Also, another 18: ȷ4XỊ⁾ecṙ“¡Œ!“¡^Ð»j.) – Jonathan Allan Apr 25 at 13:24
• @JonathanAllan Oh, nice, thanks! (also, got to love comment markdown ಠ_ಠ) – caird coinheringaahing Apr 25 at 13:27

J, 28 25 bytes

'Minecraft'120&A.~0=?@1e4

Try it online!

-3 thanks to Bubbler

Note: J does not allow 0-argument functions, but this function ignores it's argument, which is the J equivalent

To see this work, change 1e4 to 2 in the TIO, which will make the letter swap happen 50% of the time.

• 0=?@1e4 Does a random number between 0 and 9999 inclusive equal 0? Returns 1 one in 10000 times.
• 120&A. Transposes the requires letters.
• Conditional execution at rate according to step 1 happens as a result of the way & works when invoked dyadically.

alternative 1, 27 bytes

4|.'raftMin','ec'|.~0=?@1e4

Try it online!

Rotate |. the string 'ec' with probability 1/10k, then append it to the string 'raftMin, then rotate the result by 4.

alternative 2, 28 bytes

'Minecraft'C.~3<@,4#~0=?@1e4

Try it online!

• 25 bytes for 120&A. one. – Bubbler Apr 25 at 23:35

Python 2, 62 61 bytes

-1 byte thanks to xnor!

from random import*
print'Min%sraft'%'ceec'[random()>1e-4::2]

Try it online!

If a probability of $$\\left({92 \over 256}\right)^9 \approx 0.0000999841\$$ to print Minceraft is fine, 59 bytes is possible:

import os
print'Min%sraft'%'ceec'[max(os.urandom(9))>91::2]

Try it online!

Python 2, 63 bytes

from random import*
print'Min%xraft'%(236-30*0**randrange(1e4))

Try it online!

• The CE/EC reversal is cute but it turns out shorter to just do a generic [::2] selector: TIO – xnor Apr 26 at 5:01

_=>Min${new Date%1e4?'ec':'ce'}raft Try It Online • Welcome to Code Golf, and nice first answer! – Makonede May 5 at 22:17 • Thanks, wonder if anything can be improved here! – mmaismma May 6 at 6:22 • I'm not that fluent with JavaScript, so I can't really see any improvements you could make. But there might be a way! – Makonede May 6 at 16:16 Python 3 - 4542 41 Bytes 41 bytes with the constraint of running from a different process every run. print(f"Min{'ceec'[id(0)%4e4>1::2]}raft") 42 bytes with limited randomness unless running a different process each time [*]. print(f"Min{'ceec'[id({})%4e4>1::2]}raft") The idea was to use the same wrapper as in here, but a different RNG: Create a new object (a set dict in this case, because it takes 5 2 characters set() {}), and take the id() of that, which is its memory address. The memory address acts like a uniform hash[*], which has 1/10000 1/40000 (thanks @ovs) chance to end with zeros. Try it online! Update to 42 bytes: Instead of set(), use {} which is the dict constructor. Can't go shorter for dynamic object creation. Try it online! Update to 41 bytes: - use static object creation! Thanks to @dingledooper Works only if the program is run in a different process every run! Instead of {}, use 0. 0 is an object in Python, so it has an address in virtual memory, and that address is constant for that object during the lifetime of the program. If we were to run that in a for loop, it would not be random. However, if we run it in a new process every run, we get the desired randomness. This is the case in a stateless server. Try it online! [*] - Objects in Python are freed immediately when they are no longer referenced (reference counting). Thus, running the solution in a loop might always output the same id, as the memory is freed and allocated at the same address. This is OS dependent, and environment dependent, thus may not work as expected, or in a reproducible way. Running a new process each time solves this issue. • Welcome to CGCC, that's a very nice answer! By my experimentation it seems that memory addresses of set() are always divisible by 4, which means you would need to change 1e4 to 4e4 to get the right probability. – ovs May 4 at 21:51 • @ovs wow that's a very nice catch, thanks! – Gulzar May 4 at 21:55 • Wow. And I thought using time was nice... – EnderShadow8 May 4 at 23:09 • Does id(0) work here? – dingledooper May 5 at 9:06 • @Jakque I think this has to be OS specific. I would like to ask a question about this in SO, please add the specifications on which you tested, and the code. – Gulzar May 10 at 7:03 Swift, 55 53 bytes print(.random(in:1...1e4)<2 ?"Minceraft":"Minecraft") Try it online! This is also my first Code Golf post. Thanks to @Dingus for getting taking off 2 bytes! • Welcome to CGCC! 53 bytes with two small tweaks. – Dingus Apr 26 at 2:08 • @Dingus Had no idea you could do 1e4, thanks! Also the < is smart to remove the ==. – George_E Apr 26 at 12:04 JavaScript, 51 44 bytes _=>Min${Math.random()*1e4>1?'ec':'ce'}raft

try it online

That's a lotta bytes for such a simple task...

-7 thanks to the OP

• 44 bytes: _=>Min${Math.random()*1e5>1?'ec':'ce'}raft - Try it online! – A username Apr 25 at 10:48 • or a=>Min${+new Date%10001?'ec':'ce'}raft; but doesn't work consecutively – Alex bries Apr 25 at 10:59
• What's strange here is that someone still upvoted my answer even though I (accidentally) used 1e5 instead of the correct 1e4. – Recursive Co. Apr 25 at 11:15
• Why not >1e-4 if you use Math.random()? – l4m2 Apr 25 at 12:48
• @TimSeguine your right, then it should be 37 bytes _=>"Min${new Date%1e4?'ec':'ce'}raft" – Alex bries Apr 27 at 12:47 Bash, 59 bytes printf "%0.sMinecraft\n" {0..9999}|sed '1s/ec/ce/'|shuf -n1 Try it online! Change 9999 to 1 to see it work with 50% probability. Repeats the line "Minecraft" 10,000 times. Changes the first line only to "Minceraft". Shuffles the lines randomly and returns the first. • -1 byte: Replace \n to actual newline character. Try It Online – mmaismma May 5 at 8:39 Factor, 40 38 bytes 1e-4 [ "Minceraft"] [ "Minecraft"] ifp Try it online! -2 bytes thanks to @Bubbler! Factor has a version of if called ifp that calls either quotation depending on a probability. There is also an interpolating version that is slightly longer: 1e4 random 1 < "ce""ec"? [I Min${}raftI]
• You can omit spaces after closing " :) – Bubbler Apr 26 at 0:01
• @Bubbler Thanks. – chunes Apr 26 at 0:14

05AB1E, 19 18 bytes

„ecтnиćRªΩ”–·ÿraft

Try it online!

Run 10000 times

„ec      push string "ec"
т        push 100
n        squared, 10000
и        repeat, push ["ec"]*10000
R        reverse
ª        append
Ω        choose random element
”–·ÿraft push "Min" + tos + "raft", which is implicitly outputed

Mathematica, 484443 41 bytes

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

Here's a simple unit test which found a bug in my first version.

Table[If[Random[]<.1^4,"Minceraft","Minecraft"], {ix, 10^6}] // Counts

And the result:

<|"Minecraft" -> 999909, "Minceraft" -> 91|>
• Nice work. To save 4 bytes, note that Random[] does the same thing as RandomReal[]; it's been deprecated since v6 but it still works. – Michael Seifert Apr 27 at 13:54
• 41 bytes without the <>s. – att Apr 27 at 23:06
• @att, I thought I had tested that idea. Obviously not. It's very pleasing to me, that this version is shorter, and more readable. – John Apr 28 at 12:40

05AB1E, 252423 21 bytes

’£Ì³±’™D„ecÂ:‚тnLΩΘè™

Try it online!

I am once again grateful for Kevin's string compressor for providing me with the compressed strings.

Explained (old)

.•2žéhαP”·úεÕŸ•#тnLΩ1Qè™
.•2žéhαP”·úεÕŸ•#         # the list ["minecraft", "minceraft"]
тnLΩ1Qè  # indexed at the position (random.randint(1, 100 ** 2) == 1)
™ # title cased

Try it online!

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! JavaScript (V8), 5650 48 bytes print(Min${1e4*Math.random()<2?"ce":"ec"}raft)

Try it online!

Credit to @caird for removing 2 bytes! (Took off a semicolon and changed ==5 to <2)

05AB1E, 17 bytes

’£Ì³±’œ4°LΩΘ5!*è™

Try it online!

’£Ì³±’                -- "minecraft"
œ               -- permutations: ["minecraft", "minecratf", ...]
4°LΩ           -- random integer in the range 1..10000
Θ          -- 1 if it’s equal to 1, 0 otherwise
5!*       -- multiply by 5! (120)
è      -- index into the list of permutations
™     -- titlecase