# Question
Title: Calculate the Smith normal form of an integer matrix
Given an \\$m \times n\\$ matrix of integers A, there exist a \\$m \times m\\$ matrix P, an \\$m \times n\\$ matrix D, and an \\$n \times n\\$ matrix Q such that:

* \\$A = P D Q\\$.
* P and Q are unimodular matrices (i.e. matrices which are invertible and whose inverses are also integer matrices);
* D is diagonal;
* each diagonal entry \\$d\_{ii}\\$ of D is nonnegative; and
* \\$d\_{11} \mid d\_{22} \mid \cdots \mid d\_{nn} \\$.

Furthermore, the matrix D is unique in this representation.

Depending on context, the Smith normal form of A is either just the diagonal matrix D, or a Smith normal form decomposition of A is the tuple \\$(P, D, Q)\\$. For this challenge, you only need to calculate D.

One common way to calculate D is via an algorithm that looks like a combination of the Euclidean algorithm for calculating gcd and Gaussian elimination -- applying elementary row and column operations until the matrix is in the desired format for D. Another way to calculate D is to use the fact that for each i, \\$d\_{11} d\_{22} \cdots d\_{ii}\\$ is equal to the gcd of all determinants of \\$i\times i\\$ submatrices (including non-contiguous submatrices) of A.

## The challenge

You are to write a function or program that calculates the Smith normal form of an input matrix. The output may either be in the form of the full matrix D, or in the form of a list of the diagonal entries of D. In an imperative programming language, it is also acceptable to write a function that takes a matrix by reference and mutates the matrix into its Smith normal form.

## Rules

* This is : shortest code wins.
* Standard loophole prohibitions apply.
* You do not need to worry about integer overflow, if that applies in your language.

## Examples

```
1 2 3       1 0 0
4 5 6  ->   0 3 0
7 8 9       0 0 0

6  10       1 0
10 15  ->   0 10

6 0  0        1 0  0
0 10 0   ->   0 30 0
0 0  15       0 0  30

2 2       2 0
2 -2  ->  0 4

2 2  4 6       2 0 0 0
2 -2 0 -2  ->  0 4 0 0

3 3 3      1 0 0
4 4 4  ->  0 0 0
5 5 5      0 0 0

```

Note: Mathematica already has a built-in to calculate Smith normal form. As such, you can use this to play around with test cases: Try it online!

# Answer
# Wolfram Language (Mathematica), no SNF builtin, 56 bytes

-35 from att

```
(i=0;(!i+1)/1~Max~!i++&/.!a_:>GCD@@Join@@#~Minors~a)/@#&

```

Try it online!

From Wikipedia:

> The invariant factors \\$\alpha\_i\\$ can be computed as $$\alpha\_i = \frac{d\_i(A)}{d\_{i-1}(A)}$$ where \\$d\_i(A)\\$ equals the greatest common divisor of the determinants of all \\$i\times i\\$ minors of the matrix *A* and \\$d\_0(A)=1\\$.
> 5 votes

# Answer
# PARI/GP, 20 bytes

-25 bytes thanks to @Daniel Schepler and @Parcly Taxel.

```
m->Vecrev(matsnf(m))

```

Attempt This Online!

Related.
> 4 votes

# Answer
# C++ with the Eigen3 library, 470 bytes

Since we were not getting submissions using the Gaussian elimination style solution, I thought I would take a crack at implementing and golfing a solution myself. (I won't count a self-answer as a competitor, but if somebody wants to pick this up and run with it, that would be fine with me.)

```
#include<Eigen/Core>
#define r M.row
#define c M.col
#define G goto R;
void f(auto&M){int m=M.rows(),n=M.cols(),i,j,k,P,v;for(k=0;k<m&&k<n;++k){R:if(M(k,k)<0)r(k)*=-1;P=M(k,k);for(i=k;i<m;++i)for(j=k;j<n;++j){v=abs(M(i,j));if((v<P||!P)&&v){r(k).swap(r(i));c(k).swap(c(j));G}}if(P){for(i=k+1;i<m;++i){r(i)-=M(i,k)/P*r(k);if(M(i,k))G}for(j=k+1;j<n;++j){c(j)-=M(k,j)/P*c(k);if(M(k,j))G}for(i=k+1;i<m;++i)for(j=k+1;j<n;++j){if(M(i,j)%P){r(i)+=r(k);c(j)-=M(i,j)/P*c(k);G}}}}}

```

For some test code, append this:

```

#include <iostream>
void test(Eigen::MatrixXi M) {
    std::cout << "Input:\n" << M;
    f(M);
    std::cout << "\nOutput:\n" << M << "\n\n";
}

int main() {
    Eigen::MatrixXi M(3,3);
    M<<1,2,3,4,5,6,7,8,9;
    test(M);

    Eigen::MatrixXi M2(2,2);
    M2<<6,10,10,15;
    test(M2);

    Eigen::MatrixXi M3(3,3);
    M3<<6,0,0,0,10,0,0,0,15;
    test(M3);

    Eigen::MatrixXi M4(2,2);
    M4<<2,2,2,-2;
    test(M4);

    Eigen::MatrixXi M5(2,4);
    M5<<2,2,4,6,2,-2,0,-2;
    test(M5);

    Eigen::MatrixXi M6(3,3);
    M6<<3,3,3,4,4,4,5,5,5;
    test(M6);

    return 0;
}

```
> 3 votes

# Answer
# , ~~165~~ ~~163~~ 159 bytes

```
\(m,x,y,R=Reduce,C=combn)R(\(l,k)R(`?`<-\(x,y,z=y%%x)`if`(x&z,z?x,x)+y*!x,sort(abs(C(x,k,\(i)C(y,k,\(j)round(det(t(m[i,j]))))))))/max(1,l),1:min(x,y),1,,T)[-1]

```

Attempt This Online!

-2 bytes thanks to pajonk and further -4 thanks to Giuseppe.

Takes input as matrix `m` and its dimensions `x,y`, outputs SNF diagonal.

### Explanation

Uses the same algorithm as Parcly Taxel's answer.

For each `k` in `1:min(x,y)` compute the minors:

`combn(x,k,\(i)...)` generate all combinations `i` of `k` row indices

`combn(y,k,\(j)...)` generate all combinations `j` of `k` column indices

`round(det(m[i,j]))` calculate the determinants of submatrices and round, as otherwise floating point inaccuracies lead to problems in GCD

`sort(abs(...)` discard the signs and sort in order expected by GCD

`Reduce('?'<-..., ...)` Reduce by GCD. Overall, a lot of bytes are wasted due to no built-in GCD in R...

`Reduce(\(l,k)) .../max(1,l), init=1, accumulate=T)` Divide each term by the previous one, unless it's zero

`..[-1]` Drop the initializer `1` and return.
> 3 votes

# Answer
# Octave, ~~237~~ ~~229~~ ~~227~~ 225 bytes.

*Saved 10 bytes thanks to the comment of @ceilingcat*

---

Use the formula in Wikipedia.

> The invariant factors \\$\alpha\_i\\$ can be computed as $$\alpha\_i = \frac{d\_i(A)}{d\_{i-1}(A)} $$ where \\$d\_i(A)\\$ equals the greatest common divisor of the determinants of all \\$i\times i\\$ minors of the matrix *A* and \\$d\_0(A)=1\\$.
> \\$ \text{Note that here } d\_i(A)\geq 1 \\$

---

Golfed version. Try it online!

```
function a=z(A)[m,n]=size(a=A*0);d=1;for i=1:min(m,n);q=[];for r=combnk(1:m,i)';for c=combnk(1:n,i)';q=[q;det(A(r,c))];end;end;for j=1:numel(q);x=abs(round(q(j)));r={x gcd(r,x)}{(j>1)+1};end;if d~=0;a(i,i)=r/d;end;d=r;end;end

```

Ungolfed version. Try it online!

```
clear all;close all;clc;

function dets = minor_det(A, i)
    % Check if A is a square matrix or not
    [m, n] = size(A);

    % If i is greater than any dimension of A, return an error
    if i > m || i > n
        error('i cannot be greater than the dimensions of A');
    end

    % Get all combinations of i rows and columns
    rows = combnk(1:m, i);
    cols = combnk(1:n, i);

    % Initialize the array of determinants
    dets = [];

    % For each combination of rows and columns, compute the determinant
    for r = 1:size(rows, 1)
        for c = 1:size(cols, 1)
            minor = A(rows(r,:), cols(c,:));
            det_minor = det(minor);
            dets = [dets; det_minor];
        end
    end
end

function answer = func(A)
d=[];
for  i=1:min(size(A))
    minor_determinants = minor_det(A,i);
    res = round(abs(minor_determinants(1)));
    for index = 2:numel(minor_determinants)
        res = gcd(res, round(abs(minor_determinants(index))));
    end
    d(end+1)=res;
end
d=[1,d];
answer=zeros(size(A));
for i=1:(min(size(A)))
    if d(i)~=0
        answer(i,i)=d(i+1)/d(i);
    end
end
end

function out = map_func(matrices)
out = cellfun(@(matrix) func(matrix), matrices, 'UniformOutput', false);
end

matrices={
    [1,2,3;4,5,6;7,8,9],
    [6,10; 10,15],
    [6,0,0;0,10,0;0,0,15],
    [2,2;2,-2],
    [2 2  4 6 ;2 -2 0 -2],
    [3,3,3;4,4,4;5,5,5]
    };
disp(map_func(matrices));

```
> 2 votes

# Answer
# SageMath, ~~26~~ 24 bytes

```
lambda m:m.smith_form(0)

```

SageMath matrix as I/O.

Try it online.

**Explanation:**

Should speak for itself, but I'll add it anyway.

```
lambda m:          # Lambda function with matrix as argument:
  m.smith_form( )  #  Get the Smith Normal Form of the given matrix,
               0   #  but only return its diagonal matrix D

```

`smith_form()` will output a tuple of three matrices \\$(D,P,Q)\\$ by default. But by overriding its first argument with `False`, it'll result in just its diagonal matrix \\$D\\$, hence the need for the `0`-argument.
> 1 votes

---
Tags: code-golf, math, matrix
---


title: Cartesian product of two lists

text:
# Question
Title: Cartesian product of two lists
### Task

Given two lists of characters, output their Cartesian product, i.e. the list of pairings of each letter from the first list with each letter from the second list.

### Example

`"123456"` and `"abcd"` give:

```
[["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d"],["4","a"],["4","b"],["4","c"],["4","d"],["5","a"],["5","b"],["5","c"],["5","d"],["6","a"],["6","b"],["6","c"],["6","d"]]

```

### Input

Two lists of characters or strings. The characters used will be alphanumeric `a-z, A-Z, 0-9` and a character can occur both multiple times and in both inputs at the same time.

### Output

The Cartesian product of the input lists. That is, a list of each possible ordered pair of a character from the first list and a character from the second list. Each pair is a list or string or similar of two characters, or of two length-one strings. The output's length will be equal to the product of the lengths of the inputs.

The pairs must be listed in order; first listing the first character of the first list with the first of the second list, followed by all the pairings of the first character of the first list. The last pair consists of the last character of the first list together with the last character of the second list.

The output must be a flat list of pairs; not a 2D matrix where pairs are grouped by their first or second element.

### Test cases

```
inputs               output

"123456", "abcd"     [["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d"],["4","a"],["4","b"],["4","c"],["4","d"],["5","a"],["5","b"],["5","c"],["5","d"],["6","a"],["6","b"],["6","c"],["6","d"]]
"abc", "123"         [["a","1"],["a","2"],["a","3"],["b","1"],["b","2"],["b","3"],["c","1"],["c","2"],["c","3"]]
"aa", "aba"          [["a","a"],["a","b"],["a","a"],["a","a"],["a","b"],["a","a"]]

```

# Answer
> 6 votes
# 05AB1E, 1 byte

```
â

```

Try it online!

# Answer
> 18 votes
# Haskell, 12 bytes

```
(<*>).map(,)

```

Try it online!

# Answer
> 7 votes
# Mathematica, 12 bytes

```
Tuples@{##}&

```

Takes two lists of characters as input.

# Answer
> 5 votes
# APL (Dyalog), 4 bytes

```
,∘.,

```

Try it online!

`,` flatten

`∘.` the Cartesian

`,` concatenation

# Answer
> 4 votes
# Jelly, 1 byte

```
p

```

Try it online!

# Answer
> 4 votes
# Ruby, ~~30~~ 18 bytes

-12 bytes from Jordan reminding me of a way to use the spec to my advantage!

Takes lists of characters as input.

```
->a,b{a.product b}

```

Try it online!

# Answer
> 4 votes
# Octave, 32 bytes

```
@(a,b)[(a+~b')(:) (b'+~a)(:) '']

```

Try it online!

# Answer
> 4 votes
# Brachylog, 5 bytes

```
{∋ᵐ}ᶠ

```

Try it online!

### Explanation

Pretty self-explanatory

```
{  }ᶠ       Find all:
  ᵐ           Map:
 ∋              In

```

# Answer
> 4 votes
# Perl 6, 4 bytes

```
&[X]

```

This is just a reference to the built-in cross product operator `X`. It works on lists of any sort, not just characters.

# Answer
> 4 votes
# J, 3 bytes

```
,@{

```

This is the Catalogue verb in J. We need to Ravel (`,`) the result to make it 1 dimensional.

Try it online!

# Answer
> 3 votes
# JavaScript (ES6), ~~45~~ ~~36~~ ~~34~~ 33 bytes

Requires Firefox. Takes both inputs as strings or as arrays of individual characters.

```
a=>b=>[for(x of a)for(y of b)x+y]

```

---

## Try It

```
f=
a=>b=>[for(x of a)for(y of b)x+y]
oninput=_=>console.clear()&console.log(f(i.value)(j.value))
console.log(f(i.value="123456")(j.value="abcd"))
```

```
<input id=i><input id=j>
```

# Answer
> 3 votes
# Tcl, 60 bytes

```
proc p x\ y {lmap X $x {lmap Y $y {lappend l $X\ $Y}};set l}

```

Use:

```
% p {1 2 3} {a 2 2}
{1 a} {1 2} {1 2} {2 a} {2 2} {2 2} {3 a} {3 2} {3 2}

```

# Answer
> 3 votes
# Pyth, 3 bytes

```
*ww

```

Multiplying two strings just acts as the cartesian product.

Test it online!

# Answer
> 3 votes
# Bash, 18

This can be done with brace expansions:

```
eval echo {$1}{$2}

```

Try it online.

# Answer
> 3 votes
# Common Lisp, 63 bytes

```
(lambda(a b)(mapcan(lambda(x)(mapcar(lambda(y)(list x y))b))a))

```

Try it online!

# Answer
> 2 votes
# Python 2, 39 bytes

```
lambda x,y:[[i,j]for i in x for j in y]

```

Try it online!

## Alternate solution, ~~34~~ 30 bytes

*-4 bytes thanks to Anders Kaseorg.*

There is a built-in for this...

```
from itertools import*
product

```

# Answer
> 2 votes
# QBIC, 29 bytes

```
[_l;||[_l;||?_sA,a,1|+_sB,b,1

```

This prints 2-char strings with all combinations on one line each.

## Explanation

```
   ;      Read in string A$
 _l |     Get its length as b
[    |    and kick off a FOR-loop from 1 to that
[_l;||    Do the same for B$
          Note that, while the FOR-loop may pass this code several times, the
          'read-from cmd line' is done only once.
?_sA,a,1| PRINT the character from A$ at the position of the 'a' loop counter
+_sB,a,1   concatenated with the char from B$ at the pos of the 'b' loop counter

```

# Answer
> 2 votes
# C# 7, ~~78~~ 63 bytes

```
(a,b)=>$"({string.Join(",",a.SelectMany(x=>b,(x,y)=>(x,y)))})";

```

# Answer
> 2 votes
# MATL, 2 bytes

```
Z*

```

`*` is the general operator for products and the prefix `Z` makes it the *cartesian* product and can take two strings as arguments.

Try it online!

# Answer
> 2 votes
# Actually, 1 byte

Try it online!

is the Cartesian product command.

# Answer
> 2 votes
# 05AB1E, 10 bytes

```
v²NFÀ}¹ø)˜

```

Try it online!

This is without the built-in, and undoubtedly won't be competitive.

# Answer
> 2 votes
# Ohm, 1 byte

Try it online!

Literally only the built-in

# Answer
> 2 votes
# Japt, ~~5~~ 2 bytes

Japt now has a method for the Cartesian product.

Takes input as 2 arrays of character strings.

```
ïV

```

Try it

# Answer
> 2 votes
# Husk, 1 byte

```
*

```

Try it online! `*` does Cartesian products when given two lists.

# Answer
> 2 votes
# Rockstar, 81 bytes

```
listen to X
listen to Y
cut X
while X
roll X in C
cut Y in Z
while Z
say C+roll Z

```

Try it here (Code will need to be pasted in)

# Answer
> 1 votes
## Clojure, 21 bytes

```
#(for[i % j %2][i j])

```

# Answer
> 1 votes
# PHP, 69 bytes

```
<?foreach($_GET[0]as$x)foreach($_GET[1]as$y)$r[]=[$x,$y];print_r($r);

```

Try it online!

# Answer
> 1 votes
# Cheddar, 52 bytes

```
a->b->a.chars.map(i->b.chars.map(i&(+))).reduce((+))

```

Try it online!

# Answer
> 1 votes
# Retina, 49 bytes

```
.(?=.*¶(.+))
$1$&¶
¶¶.+
¶
.(?=.*(.)¶)
$1$&¶
¶.¶
¶

```

Try it online! Takes input on separate lines. Explanation:

```
.(?=.*¶(.+))
$1$&¶

```

Each character in the first string generates a separate line prefixed by the second string.

```
¶¶.+
¶

```

The original second string is deleted.

```
.(?=.*(.)¶)
$1$&¶

```

For each character in the first string, each character in the second string generates a separate line prefixed with the first character.

```
¶.¶
¶

```

The left-over characters from the first string are deleted.

# Answer
> 1 votes
# Charcoal, ~~8~~ 7 bytes

```
ＦθＥη⁺ικ

```

Try it online! Link is to verbose version of code. Explanation: The variables `θ` and `η` implicitly refer to the two input strings. The  command loops over each character of the first input, while the  command maps over each character of the second input concatenating the loop variable `ι` and the map variable `κ`, the result of which is implicitly printed on separate lines.

# Answer
> 1 votes
# q/kdb+, 5 bytes

**Solution:**

```
cross           / yup, there's a built-in to do exactly this

```

**Example:**

```
q)"123456"cross"abcd"
"1a"
"1b"
"1c"
"1d"
"2a"
"2b"
"2c"
"2d"
"3a"
"3b"
"3c"
"3d"
"4a"
"4b"
...etc

```

# Answer
> 1 votes
# , 29 bytes

```
function(x,y)outer(x,y,paste)

```

Try it online!

Note that R matrix are filled by column, so the result is in the order dictated by the spec.

If allowed to have `factors` for input and output, there is a built-in... but one needs to extract the resulting levels from the factor so in the end it would be more than 29 bytes.

### , 11 bytes

```
interaction

```

Try it online!

# Answer
> 1 votes
# GolfScript, 21 bytes

```
~\:a;{a{[.;1$]}%\;}%`

```

Try it online!

# Answer
> 1 votes
# Google Sheets, 101

Inputs A1, B1.

```
=ArrayFormula(REGEXEXTRACT(Flatten(MID(A1,SEQUENCE(LEN(A1)),1)&MID(B1,SEQUENCE(1,LEN(B1)),1)),"(.)(.)

```

## How it Works

* Turn string into character array. The first is vertical, the second is horizontal because of how we call `SEQUENCE`.
* Concatenate every permutation of one letter from each string. (Because one is vertical and the other is horizontal.
* Flatten into array
* Extract first and second character by Regex
* I considered delimiting by commas and splitting, but that would have required more work if the first string had a comma (or whatever delimiting character).

## Notes

* `Flatten` is an undocumented function that turns any range into a column array.

# Answer
> 1 votes
# Scala, 24 bytes

```
for(x<-_;y<-_)yield(x,y)

```

Try it online!

I love for comprehensions.

# Answer
> 1 votes
# Add++, 8 bytes

```
L*,€€+BF

```

Try it online!

## How it works

```
L*,		; Create an anonymous function that returns the entire stack
		; Example inputs: 	"abc" "123"
	€	; Over each char:	["1" "abc"]
	 €	;   Over each char:	["1" "a"]
	  +	;     Concatenate	"a1"
		;   This returns	["a1" "a2" "a3"]
		; This returns		[[["a1" "a2" "a3"] ["b1" "b2" "b3"] ["c1" "c2" "c3"]]]
	BF	; Flatten		["a1" "a2" "a3" "b1" "b2" "b3" "c1" "c2" "c3"]

```

# Answer
> 1 votes
# Vyxal, 1 byte

```
Π

```

Try it Online!

Vyxal's built ins are fun!

# Answer
> 1 votes
# TypeScript Type System, 111 bytes

```
type X<A,B>=A extends[infer F,...infer R]?[...B extends[any,...infer V]?[[F,B[0]],...X<[F],V>]:[],...X<R,B>]:[]

```

Test it at the TypeScript playground

My old, more intuitive answer is unfortunately invalid due to the challenge requiring an array of tuples rather than an array of arrays of tuples. This complicated mess, on the other hand, seems to be shorter than using the old version and defining a flatten-type.

```
type X<A, B> = A extends [ // generic type X takes tuples A and B
  infer F,                 // from A, get first (F)
  ...infer R               // and rest (R)
]
  ? [                                // push:
      ...B extends [any, ...infer V] //   get first and rest (V) from B
        ? [                          //   push:
            [F, B[0]],               //     [ F, B[0] ]
            ...X<[F], V>             //     recurse with [F], V
          ]
        : [],
      ...X<R, B>                     //   recurse with R, B
    ]
  : [];

```

## TypeScript Type System, 57 bytes

This is technically invalid for this specific challenge, but I'm leaving it here since it is more practical for other challenges where cartesian product is used.

```
type P<A,B>={[I in keyof A]:{[J in keyof B]:[A[I],B[J]]}}

```

Test it at the TypeScript playground

Pretty simple but I'll leave an explanation anyway for those who don't know any TypeScript:

```
type P<A, B> = {                 // generic type P takes tuple types A and B
  [I in keyof A]: {              //   for index i in A:
    [J in keyof B]: [A[I], B[J]] //     for index j in B: tuple [A[i], B[j]]
  }                              //   end
}                                // end

```

# Answer
> 1 votes
# JavaScript (ES6), 35 bytes

```
a=>b=>a.flatMap(x=>b.map(y=>[x,y]))

```

```
f=
a=>b=>a.flatMap(x=>b.map(y=>[x,y]))

document.write(`<pre style="font-size: 1rem">${[
  "f([1, 2, 3])(['a', 'b', 'c']) ",
  "f([2, 4, 6, 8])([1, 3, 5, 7]) ",
  "f(['A', 'B'])(['c', 'd', 'e'])",
].map(test => `${test} → ${JSON.stringify(eval(test))}`).join("\n")}</pre>`)
```

# Answer
> 1 votes
# Thunno 2, 1 byte

Built-in. Takes input in reversed order.

#### Screenshot

# Answer
> 1 votes
# Julia, 21 bytes

```
a^b=permutedims(a).*b

```

Attempt This Online!

Takes input as character arrays, returns length-2 strings. Frustratingly, one-byte `'` operator doesn't work with text, so we have to `permutedims` instead. Still a few bytes shorter than a nested `for` loop.

While this technically returns a 2D matrix, which the OP doesn't want, it **does** support 1D-indexing (as demonstrated in test cases on ATO), and so is perfectly usable as a flat list. However, this requirement probably invalidates the built-in answer, as Julia flattens the Matrix in column-major order, giving a different result sequence:

## Julia, 17 bytes

```
Iterators.product

```

Attempt This Online!

# Answer
> 1 votes
# Nekomata, 2 bytes

```
ᵐ~

```

Attempt This Online!

```
ᵐ   Map
 ~  Any of

```

A port of @Fatalize's Brachylog answer.

# Answer
> 1 votes
# \>\<\> (Fish), 92 bytes

```
fi:?v~:f(?v1-00.
-10.\i{:{:}$}$p1
1~v?gf:11~/.27oa$<v!?ge:+1$
  \:fgo$:ego$1+ $/;

```

Try it

Each list should be prefixed by it's length

# Answer
> 0 votes
# Jq 1.5, 29 bytes

```
map(split(""))|[combinations]

```

Uses combinations builtin.

Sample Run

```
$ jq -Mc  'map(split(""))|[combinations]' <<< '["123456","abcd"]'
[["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d"],["4","a"],["4","b"],["4","c"],["4","d"],["5","a"],["5","b"],["5","c"],["5","d"],["6","a"],["6","b"],["6","c"],["6","d"]]

$ echo -n 'map(split(""))|[combinations]' | wc -c
  29

```

# Answer
> 0 votes
# Axiom, 55 bytes

```
f(a,b)==concat[[[a.x,b.y]for y in 1..#b]for x in 1..#a]

```

some results

```
(15) -> f("123456","abcd")
   (15)
   [[1,a], [1,b], [1,c], [1,d], [2,a], [2,b], [2,c], [2,d], [3,a], [3,b],
    [3,c], [3,d], [4,a], [4,b], [4,c], [4,d], [5,a], [5,b], [5,c], [5,d],
    [6,a], [6,b], [6,c], [6,d]]
                                                Type: List List Character
(16) -> f("abc","123")
   (16)  [[a,1],[a,2],[a,3],[b,1],[b,2],[b,3],[c,1],[c,2],[c,3]]
                                                Type: List List Character
(17) -> f("aa","aba")
   (17)  [[a,a],[a,b],[a,a],[a,a],[a,b],[a,a]]
                                                Type: List List Character

```

# Answer
> 0 votes
# APL NARS 8 chars

```
{,⍺∘.,⍵}

```

Copy from https://codegolf.stackexchange.com/a/125115/58988 test

```
f←{,⍺∘.,⍵}
'123456' f 'abcd'
 1a 1b 1c 1d 2a 2b 2c 2d 3a 3b 3c 3d 4a 4b 4c 4d 5a 5b 5c 5d 6a 6b 6c 6d

```

# Answer
> 0 votes
# Prolog (SWI), 48 bytes

```
L-R:-findall([A,B],(member(A,L),member(B,L)),R).

```

Try it online!

# Answer
> 0 votes
# Pyt, 1 byte

```
×

```

Try it online!

Gotta love built-ins.

# Answer
> 0 votes
# Thunno, \\$ 2 \log\_{256}(96) \approx \\$ 1.65 bytes

```
Z!

```

Attempt This Online!

### Thunno, \\$ 2 \log\_{256}(96) \approx \\$ 1.65 bytes

```
zS

```

Attempt This Online!

Built-in solutions.

# Answer
> 0 votes
# awk, 101 bytes

it's verbose but doesn't involve cryptic BS

```
echo '123456 abcd' |

```

---

```
awk 'function ___(_,__) { gsub(".","\\&& ",__)gsub(".",__,_); return _
     }$++NF = ___($++_, $++_)'

```

---

```
123456 abcd 1a 1b 1c 1d 2a 2b 2c 2d 3a 3b 3c 3d 4a 4b 4c 4d 5a 5b 5c 5d 6a 6b 6c 6d

```

# Answer
> 0 votes
# Scala, 45 bytes

Golfed version. Try it online!

```
(a:String,b:String)=>for{x<-a;y<-b}yield(x,y)

```

---
Tags: code-golf, set-theory
---


# Question
Title: Transpose a 3x3 matrix across the anti-diagonal
Write a program which takes a 3x3 matrix on stdin and prints its transpose along the anti-diagonal to stdout. You may assume that all elements of the matrix will be integers. Columns are space-separated and rows are newline-separated.

### Example

Input:

```
1 2 3
3 4 5
1 2 3

```

Output:

```
3 5 3
2 4 2
1 3 1

```

Input:

```
1 2 3
4 5 6
7 8 9

```

Output:

```
9 6 3
8 5 2
7 4 1

```

# Answer
# APL - 7

```
⌽⍉⌽3 3⍴

```

Example input:

```
⌽⍉⌽3 3⍴1 2 3 3 4 5 1 2 9
> 9 5 3
  2 4 2
  1 3 1

```

ngn APL demo
> 9 votes

# Answer
## Mathematica, ~~31~~ ~~28~~ 20 bytes

```
(r=Reverse)[r@#]&

```

The  is Mathematica's transpose operator (which is displayed as a superscript T in Mathematica).
> 5 votes

# Answer
## Sage, 39

*Runs in the interactive prompt*

```
matrix(input()[::-1]).transpose()[::-1]

```

Sample input:

```
[[1,2,3],[3,4,5],[1,2,3]]

```

Sample output:

```
[3 5 3]
[2 4 2]
[1 3 1]

```
> 4 votes

# Answer
## GolfScript, 18 / 15 / 11 chars

```
~]-1%3/zip{' '*n}%

```

This is the straightforward implementation, following pretty much the exact steps given in the question. There's a clever arithmetic trick one could use instead, but it turns out to need more characters.

Sample input:

```
1 2 3
3 4 5
1 2 9

```

Sample output:

```
9 5 3
2 4 2
1 3 1

```

Ps. If I can use the same output format as in ace's answer (i.e. extra with square brackets around each row), I can save three chars for a total of **15 chars**:

```
~]-1%3/zip{`n}%

```

If a one-line output format like `[[9 5 3] [2 4 2] [1 3 1]]` is allowed, I can shrink that further to just **11 chars**:

```
~]-1%3/zip`

```
> 4 votes

# Answer
# J - 16 (?) char

Taking the 3x3 matrix as a grid from stdin, we get the 16 character:

```
|:&.|.".1!:1]3#1

```

This can be made shorter if the input is made more flexible, as in the Sage and APL answers:

```
|:&.|.".1!:1]1   NB. if stdin input form can be  1 2 3, 4 5 6,: 7 8 9
|:&.|.           NB. if used as an expression like the APL answer

```

The key is in the `|:&.|.` portion: this is what transposes the matrix. It reads *Transpose* (`|:`) *Under* (`&.`) *Reverse* (`|.`), meaning you reverse the matrix, transpose it, and then undo your initial reverse.

Demo:

```
   |:&.|.".1!:1]3#1          NB. three lines input, three output
1 2 3
4 5 6
7 8 9
9 6 3
8 5 2
7 4 1

   1 2 3,3 4 5,:1 2 9        NB. a matrix
1 2 3
3 4 5
1 2 9
  |:&.|. 1 2 3,3 4 5,:1 2 9  NB. the logic
9 5 3
2 4 2
1 3 1

```
> 3 votes

# Answer
# K, 3/7/20(?) bytes

K is similar enough to APL that a character-for-character transliteration of @mniip's solution works:

```
|+|3 3#

```

In action:

```
  |+|3 3#1 2 3 3 4 5 1 2 9
(9 5 3
 2 4 2
 1 3 1)

```

This behaves identically, modulo the way output is prettyprinted. However, I should note that neither this solution nor the solution it is based on actually operate on `stdin`/`stdout`. To implement this as per a stricter interpretation of the spec in Kona-compatible K3 it's necessary to use `0:` and jump through some hoops:

```
`0:,/'2$|+|3 3#. 0:`

```

Write to stdout (``0:`) the join over each (`,/'`) of the two-wide string format (`2$`) of the anti-diagonal transpose (`|+|`) of the 3x3 reshape (`3 3#`) of the eval (`.`) of stdin (`0:``).

In action:

```
indigo:kona je$ ./k antidiag.k
K Console - Enter \ for help

  1 2 3 3 4 5 1 2 9
 9 5 3
 2 4 2
 1 3 1

```

There's a pretty good reason that APL-family programmers tend to avoid problems that force the use of stdin/stdout. Arguably, with flexible IO requirements, this could be solved with simply `|+|`:

```
  |+|(1 2 3;3 4 5;1 2 9)
(9 5 3
 2 4 2
 1 3 1)

```
> 3 votes

# Answer
# Vyxal, 4 bytes

```
RÞTR

```

Try it Online!

```
R    # Vectorised reverse
 ÞT  # Transpose
   R # Vectorised reverse

```
> 3 votes

# Answer
# Brain-Flak `-c`, 2628 bytes

```
(()()()()){({}[()]<{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<>)<>>)}{}){{}(<(<()>)>)}{}}{}({}<>)<>>)}{}(<>({})<>){(({}))((()()()()()){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}(<>({})<>)({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<><>{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}{(({}))((()()()()()){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}{}{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<>)<>>)}{}){{}(<(<()>)>)}{}}{}<>{(({}))((()()()()()){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<>)<>>)}{}){{}(<(<()>)>)}{}}{}([(((()()())()){}{}){}]{}){(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}({}<>){(({}))((()()()()()){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>({}<>)<>(()()){({}[()]<{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<>)<>>)}{}){{}(<(<()>)>)}{}}{}({}<>)({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}<>{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>{(({}))((()()()()()){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<>)<>>)}{}){{}(<(<()>)>)}{}}{}({}<>)({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}<>([]){({}[()]<({}<>)<>>)}<>(()()()){({}[()]<{(({}))((((()()()()){}){}){})({}[{}])((){[()](<{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}){{}(<(<()>)>)}{}}{}({}<(([])<{{}({}<>)<>([])}{}<>>)<>>)<>{({}[()]<({}<>)<>>)}{}<>>)}{}

```

If it weren't for IO requirements this could have been 842 bytes but hey it was a good challenge :P I'm sure there's a lot that can be golfed here and I will see if I can find some of those spots later but right now I need to stop staring at brackets.

Try it online!
> 3 votes

# Answer
# BQN, 3 bytes

```
⌽˘⌽

```

Try it online!

### Explanation

```
⌽˘⌽
  ⌽ 1. Reverse over [leading axis][1]
⌽˘  2. Reverse over "major cells"

```
> 3 votes

# Answer
# MATLAB, 15 bytes

Rotate the matrix 180 degrees, and transpose it. This takes the input where columns are space separated and rows are newline separated. Outputs on the same format.

```
@(A)rot90(A,2)'

ans([1 2 3
4 5 6
7 8 9])

ans =

     9     6     3
     8     5     2
     7     4     1

```
> 2 votes

# Answer
### Racket, 42 bytes

```
(λ(m[r reverse])(r(apply map list(r m))))

```

Takes a list of lists of numbers as input, and outputs the same type.

Thought I might as well find a use case for some of the tips I'd written up some years ago!

Try it online!
> 2 votes

# Answer
# Thunno, \\$6\log\_{256}(96)\approx\\$ 4.94 bytes

```
.rZt.r

```

Attempt This Online!

`.r` reverses each row; `Zt` transposes; `.r` reverses each row.
> 2 votes

# Answer
# Fortran (GFortran), 87 ~~98~~ ~~101~~ bytes

```
integer A(3,3);read*,((A(i,j),j=1,3),i=1,3);print'(3i3)',((A(4-i,4-j),i=1,3),j=1,3)
end

```

Try it online! ~~98b~~ ~~101bytes~~
> 2 votes

# Answer
# JavaScript (Node.js), 83 ~~97~~ bytes

> -14 bytes thanks to @noodleman !

Input and output are the matrixes exactly in the string format specified by OP.
This surely is the shortest JS answer using this format!

```
s=>s.split(/\s/).map((e,i,a)=>a[i+(2-i%3-(i/3|0))*4]+(i%3<2?` `:i>6?``:`
`)).join``

```

Try it online!

---

Let me explain a bit:
First we split the input string on all whitespaces, which gives us a **`one-dimensional array`**.
Then, we switch each item with their corresponding targets by transforming the current value of the (one-dimensional) index this way:
**`i+(2-i%3-(i/3|0))*4`**.
And finally, we concatenate all the elements while adding the  and `\n` after the right items (but specifically not after the last item).
> 2 votes

# Answer
# R, 78

```
write.table(matrix(rev(unlist(strsplit(readLines(),' '),' ')),3),qu=F,r=F,c=F)
# Copy and paste the input
# If the prompt is not on a new line, press `enter` after the last line
# Type `Ctrl+D`

```

I discovered the `rev()` function on SO, it helped me to understand than the transformation is just reversing the input and putting it in the matrix from top to bottom, and left to right.

I also discovered that the argument `row.names=T` (T for `true`) can be shortened to `r=T`, saving 16 chars.

## Explanations:

* `readLines()` reads STDIN and return a vector with 3 elements (each one is a string)
* `strsplit()` splits the strings in the vector by using space as a separator
* `unlist()` makes a flat list from a vector
* `rev()` puts the list in reverse order
* `matrix([list], 3)` creates a matrix from the list, the argument `3` indicates that there is 3 elements per row
* `write.table([matrix], qu=F, r=F, c=F)` prints the matrix without quotes, rows and columns labels
> 1 votes

# Answer
## TI-BASIC, 50

```
Input A:rowSwap(A,1,dim(A
AnsT→A:rowSwap(A,1,dim(A

```
> 1 votes

# Answer
## CJam, 13 bytes

```
q~]W%3/zSf*N*

```

Test it here.

CJam is newer than this challenge. This solution is very similar to the GolfScript one.

### Explanation

```
q~   e# Read input and evaluate, pushing all 9 numbers on the stack.
]    e# Wrap them in an array.
W%   e# Reverse it - this performs a 180° rotation.
3/   e# Split into rows of length 3.
z    e# Transpose.
Sf*  e# Join integers in each row with spaces.
N*   e# Join the rows with linefeeds.

```

If there was no constraint on 3x3 inputs, we could either compute the line width with a square root:

```
q~]W%_,mQ/zSf*N*

```

Or we could perform the anti-diagonal transpose as vertical flip, transpose, vertical flip (like my Mathematica answer does):

```
qN/Sf/W%zW%Sf*N*

```

In either case, we'd have 16 bytes.
> 1 votes

# Answer
# , 37 bytes

```
write(scan()[rep(9:7,e=3)-3*0:2],1,3)

```

Try it online!

Simply changes the order of the elements of the input vector.

Well, actually a basic approach is shorter:

### , 35 bytes

```
write(matrix(rev(scan()),3,,T),1,3)

```

Try it online!
> 1 votes

# Answer
# 05AB1E, 7 (or 3) bytes

```
|€#øRí»

```

Try it online.

With less strict I/O rules it would be 3 bytes instead, with I/O being a 3x3 matrix of integers:

```
øRí

```

Try it online.

**Explanation:**

```
         #  e.g. input = "1 2 3\n4 5 6\n7 8 9"
|        # Take all input-lines as a list of strings
         #  STACK: ["1 2 3","4 5 6","7 8 9"]
 €#      # Split each line by spaces
         #  STACK: [["1","2","3"],["4","5","6"],["7","8","9"]]
   ø     # Zip the matrix, swapping rows with columns
         #  STACK: [["1","4","7"],["2","5","8"],["3","6","9"]]
    R    # Reverse the order of rows in the matrix
         #  STACK: [["3","6","9"],["2","5","8"],["1","4","7"]]
     í   # Reverse each row of the matrix
         #  STACK: [["9","6","3"],["8","5","2"],["7","4","1"]]
      »  # Join each row by spaces, and then everything by newlines
         #  STACK: "9 6 3\n8 5 2\n7 4 1"
         # (after which it is output implicitly)

```

Here some alternatives with different order of operations:

```
øíR
Ríø
íRø
íøí
RøR

```
> 1 votes

# Answer
# Jelly, 3 bytes

```
ṚZṚ

```

Try it online!

Uses Python list format for I/O.
> 1 votes

# Answer
# Japt, 3 bytes

```
yÔÔ

```

Try it

```
yÔÔ     :Implicit input of 2D array
y       :Transpose
 Ô      :Reverse rows
  Ô     :Reverse array

```
> 1 votes

# Answer
# Factor \+ `math.matrices`, 27 bytes

```
[ anti-flip simple-table. ]

```

`anti-flip` postdates build 1525, the one TIO uses, so here's a picture of running this in Factor's REPL:

Note that in a standard output context, `simple-table.` outputs its elements with spaces in between. In the REPL, it's a little fancier.
> 1 votes

# Answer
# flax, 2 bytes

```
Ṙ∝

```

ATO doesn't have the lastest commit of flax (because I keep discovering bugs). So here is an image of it in action:
> 1 votes

# Answer
# JavaScript, 103 bytes

Expects string input and outputs string

```
s=>(s=s.split`
`.map(x=>x.split` `))[0].map((_,c)=>s.map((_,r)=>s[2-r][2-c])).map(x=>x.join` `).join`
`

```

Try it:

```
f=s=>(s=s.split`
`.map(x=>x.split` `))[0].map((_,c)=>s.map((_,r)=>s[2-r][2-c])).map(x=>x.join` `).join`
`

;[
`1 2 3
3 4 5
1 2 3`,
`1 2 3
4 5 6
7 8 9`
].forEach(x=>console.log(f(x)))
```

# JavaScript, 45 bytes

Expects 2D array input and outputs 2D array

```
m=>m[0].map((_,c)=>m.map((_,r)=>m[2-r][2-c]))

```

Try it:

```
f=m=>m[0].map((_,c)=>m.map((_,r)=>m[2-r][2-c]))

;[
  [
    [1, 2, 3],
    [3, 4, 5],
    [1, 2, 3]
  ],
  [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
  ]
].forEach(x=>console.log(JSON.stringify(f(x))))
```
> 1 votes

---
Tags: code-golf, math
---


title: Implement Minceraft

text:
# Question
Title: Implement Minceraft
# Introduction

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

# Your challenge

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!

# Answer
# 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.
> 2 votes

# Answer
# Minecraft, ~~358~~ ~~293~~ ~~277~~ 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.

```
/scoreboard objectives add s dummy
/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

```
/scoreboard objectives add s dummy
/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.
> 61 votes

# Answer
# 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!
> 21 votes

# Answer
# Python 3, ~~78~~ ~~71~~ ~~69~~ 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
> 13 votes

# Answer
## Python 3 - ~~45~~ ~~42~~ 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.
> 13 votes

# Answer
# JavaScript, 37 bytes

```
_=>`Min${new Date%1e4?'ec':'ce'}raft`

```

Try It Online

First of all, write `Min`.

Then get the current time with `new Date`. Normally it returns something similar to "2021-10-05T10:29:58.432Z". But if you do a mathematical operation on it, this output becomes the epoch time similar to "1633429932422" (a number, basically).

Now divide the number by 10000 (1e4). If the remainder (%) is `0` i.e. `false`, add `ce` to `Min` otherwise add `ec`.

At last, add `raft` at the end.
> 11 votes

# Answer
# 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!
> 9 votes

# Answer
# Taxi, 632 bytes

```
Go to Heisenberg's:W 1 R 3 R 1 L.Pickup a passenger going to Divide and Conquer.1073741824e-4 is waiting at Starchild Numerology.Go to Starchild Numerology:N 1 L 3 L 1 L 3 L.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:W 1 R 3 R 1 R 2 R 1 R.Pickup a passenger going to Trunkers.Go to Trunkers:E 1 R 3 R 1 L.Pickup a passenger going to The Underground.Go to The Underground:E 1 R 2 L.Switch to plan A if no one is waiting.Minecraft is waiting at Writer's Depot.[A]Minceraft is waiting at Writer's Depot.Go to Writer's Depot:N 3 L 2 L.Pickup a passenger going to Post Office.Go to Post Office:N 1 R 2 R 1 L.

```

Try it online!

There are two sources of randomness in Taxi: **Heisenberg's** (which holds a random integer passenger), and **Firemouth Grill** (which can hold any number of passengers, who are picked up in a random order).

This program uses **Heisenberg's** to grab a random number, which will be used to choose one of two strings randomly.

Here is the basic control flow of the program:

* Go to **Heisenberg's** and grab a random integer, in the range of \\$\[0, 2^{31}-1\]\\$. (\\$2^{31}-1\\$ is `RAND_MAX` in C++, and Taxi uses C++'s random functions.)
* Pick up the value `1073741824e-4` (that's \\$\frac{2^{31}}{2 \times 10000}\\$) from **Starchild Numerology**.
* Drop off both passengers at **Divide and Conquer**, giving us a result of \\$\frac{n}{2^{31}} \times 2 \times 10000\\$, which is a double in the range \\$\[0, 2 \times 10000)\\$. (We use this range instead of \\$\[0, 10000)\\$ because we will output `Minceraft` when this number is either 0 or 1.)
* Bring this result to **Trunkers**, which chops off the fractional part. (The range is still \\$\[0, 2 \times 10000)\\$.)
* Bring this result to **The Underground**. One of two things will happen:
* + A passenger will be returned, which means that our number was greater than 1 (which has a \\$\frac{2 \times 10000 - 2}{2 \times 10000}\\$ chance of occurring). Do nothing.
* + No passenger will be returned, which means that our number was either 0 or 1 (which has a \\$\frac{2}{2 \times 10000}\\$ chance of occurring). Declare the value `"Minceraft"` at **Writer's Depot**.
* Declare the value `"Minecraft"` at **Writer's Depot**.
* Pick up the first passenger waiting at **Writer's Depot**. (If both `"Minecraft"` and `"Minceraft"` are waiting, `"Minceraft"` will be picked up, because it was waiting there first.)
* Drop off this passenger at the **Post Office**, outputting the string and (for purposes of Code Golf) ending the program.

# Taxi, 691 bytes

```
1e4 is waiting at Starchild Numerology.Go to Starchild Numerology:W 1 L 2 R 1 L 1 L 2 L.Pickup a passenger going to The Underground.Minceraft is waiting at Writer's Depot.Go to Writer's Depot:E 1 L 2 R.[A]Pickup a passenger going to Cyclone.Go to Cyclone:N.Pickup a passenger going to Firemouth Grill.Pickup a passenger going to Firemouth Grill.Go to Firemouth Grill:S 1 L 2 L 1 R.Go to Fueler Up:E 1 L.Go to The Underground:N.Switch to plan B if no one is waiting.Pickup a passenger going to The Underground.Minecraft is waiting at Writer's Depot.Go to Writer's Depot:N 3 L 2 L.Switch to plan A.[B]Go to Firemouth Grill:S 1 R.Pickup a passenger going to Post Office.Go to Post Office:E 1 R.

```

Try it online!

This program uses **Firemouth Grill** to hold thousands of "Minecraft" and "Minceraft" strings to choose from randomly.

Here is the basic control flow of the program:

* Pick up the value `1e4` from **Starchild Numerology** to use as a counter.
* Declare the value `"Minceraft"` at **Writer's Depot** and go there (but don't pick it up yet).
* Repeat these steps:
* + Pick up the string currently at **Writer's Depot**, and clone it at **Cyclone**. (Having two strings along for the ride will earn us extra gas money!)
* + Take both clones, and drop them off at **Firemouth Grill**.
* + Take our counter, and drop it off at **The Underground**. One of two things will happen:
* + - A passenger will be left waiting, which was 1 less than our previous counter. Pick up this new counter, and declare the value `"Minecraft"` at **Writer's Depot** and go there. At this point, repeat the previous steps.
* + - No passenger will be left waiting, which means that our counter is now 0 and we are done.
* Go to **Firemouth Grill**, and pick up a passenger. It will most likely be `"Minecraft"`, but there's a 1/10000 chance it will be `"Minceraft"`.
* Drop off this passenger at the **Post Office**, outputting the string and (for purposes of Code Golf) ending the program.

# Taxi, 849 bytes

```
Go to Fueler Up:W 1 R.Switch to plan B.[A]Go to Fueler Up:E 2 L.[B]Go to Heisenberg's:N 3 R 1 L.Pickup a passenger going to Cyclone.Go to Cyclone:N 1 L 3 L.Pickup a passenger going to Magic Eight.Pickup a passenger going to Cyclone.Go to Cyclone:N 1 R 3 R 1 R.Pickup a passenger going to Equal's Corner.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:N 1 R.2e4 is waiting at Starchild Numerology.Go to Starchild Numerology:N 1 R.Pickup a passenger going to Magic Eight.Go to Magic Eight:W 1 R 2 R 1 R.Switch to plan A if no one is waiting.Pickup a passenger going to The Underground.Go to The Underground:E 2 L.Switch to plan C if no one is waiting.Minecraft is waiting at Writer's Depot.[C]Minceraft is waiting at Writer's Depot.Go to Writer's Depot:N 3 L 2 L.Pickup a passenger going to Post Office.Go to Post Office:N 1 R 2 R 1 L.

```

Try it online!

This was my first instinct. It also uses **Heisenberg's** to generate a random integer within the range \\$\[0, 2 \times 10000)\\$, but it does so by repeatedly generating a random number until it is within this range. The taxi has to stop at **Fueler Up** to refill its gas tank, and it has to clone passengers at **Cyclone** and drop the clones off at **Equal's Corner** to make enough money to re-generate random numbers for as long as necessary, but otherwise, the functionality is the same as the 632-byte program.

It doesn't depend on the specifics of C++, but it *does* usually take longer to execute, because generating a small enough random number is rarer. If anyone can improve this one, be my guest.
> 9 votes

# Answer
# , ~~45~~ ~~44~~ 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...

---

# , 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  `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).
> 8 votes

# Answer
# Clojure, 42 bytes

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

```

Try it online!
> 8 votes

# Answer
# 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`.
> 6 votes

# Answer
# 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`.
> 6 votes

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

```
> 6 votes

# Answer
# APL, 26 bytes

```
'Min','raft',⍨'ec'⌽⍨1=?1E4

```

Saved 1 byte thanks to Adam
> 6 votes

# Answer
# Minecraft, 226 bytes.

```
/scoreboard objectives add d dummy
/scoreboard players set c d 2147054151
/execute store result score s d run seed
/execute if score s d < c d run tellraw @s "Minecraft"
/execute if score s d >= c d run tellraw @s "Minceraft"

```

(Includes a trailing newline, to run the final command)

I saw the other Minecraft answer by Okx and had some suggestions. I would've put them in the comments of the other response, but I figured I changed it enough for its own submission, and another CGSE member said it's fine so whatever.

I'm only just now noticing the only change I made was using /seed. Ah, well. The things you learn when you have five ideas for improvements and four of them don't work.
> 6 votes

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

```
> 5 votes

# Answer
# PowerShell, 38 bytes

```
"Min$(('ec','ce')[!(random 1e4)])raft"

```

Try it online!
> 5 votes

# Answer
# 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!
> 5 votes

# Answer
# 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.
> 5 votes

# Answer
# , 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!
> 5 votes

# Answer
# 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!
> 5 votes

# Answer
# 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
ć        head extract
R        reverse
ª        append
Ω        choose random element
”–·ÿraft push "Min" + tos + "raft", which is implicitly outputed

```
> 5 votes

# Answer
# Mathematica, ~~48~~ ~~44~~ ~~43~~ 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|>

```
> 4 votes

# Answer
# Befunge-93, ~~100~~ ~~97~~ 81 bytes

```
"tfarec"v
77+:v>0#<
v*2\_v
?1v0:#
^#< ^-1\$#+
+55:$<  |`-1*:*:
>:#,_@ |<
^ "Min"<

```

Try it online!

Uses rejection sampling to generate a random integer between 0 and 9999 inclusive, and then swaps the letters if that number is 0.

I abused some coincidences that arose in my code to golf it.
> 4 votes

# Answer
# Vyxal, ~~27~~ ~~20~~ 18 bytes

```
`↔ṅ`₴k2ṁċ[`ec`|`ce`]₴`r…ż`,

```

Try it Online!

Edit: this is actually 7 less bytes, at only 20:

```
k2ṁ[`↓∑ġ¬`|`↔ṅ⇩ṡ…ż`]

```

Try it Online!

Edit 2: Thanks to @emanresu A, this has been shortened to 18 bytes.

```
k2ṁ[`↓∑ġ¬`|`↔ṅ⇩ṡ…ż

```

Try it Online!
> 4 votes

# Answer
# Bash, 43 bytes

```
x=(ce ec);echo Min${x[RANDOM%9999?1:0]}raft

```

Try it online!

`RANDOM%9999` has a range of \[0,9999\], and in bash `0` evaluates to false, so the ternary works as expected. Supposedly, the `$RANDOM` function has an "approximately linear distribution", but I haven't proved that with a million iterations. Hat-tip to the Zsh solution.
> 4 votes

# Answer
# 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*
> 3 votes

# Answer
# Ruby, ~~35~~ 34 bytes

```
$><<"Min#{rand<1e-4?:ce: :ec}raft"

```

Try it online!

Thanks to Dingus for a saved byte.
> 3 votes

# Answer
# 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.
> 3 votes

# Answer
# 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]

```
> 3 votes

# Answer
# PHP, ~~40~~ ~~32~~ 29 bytes

```
<?=Min,rand()%1e4?ec:ce,raft;

```

Try it online!

Not a bad score for good ol' PHP

Or even shorter if we allow plain text ouside of the PHP tags (Thanks to Tim Seguine)

# PHP, ~~33~~ ~~29~~ 28 bytes

```
Min<?=rand()%1e4?ec:ce?>raft

```

Try it online!

EDIT: saved another number of bytes by removing all quotes, inspired by another suggestion from Tim Seguine

EDIT 2: thanks again to Tim Seguine, now using `rand()%1e4` instead of `rand(0,1e4)` which is not even shorter but more accurate, (at least in TIO, so far as `getrandmax()` has a high value), and using `,` to remove the round brackets
> 3 votes

# Answer
# 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.
> 3 votes

# Answer
# 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\\$ `0`s 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 `0`s, 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 `0`s 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"

```
> 3 votes

# Answer
# JavaScript (V8), ~~56~~ ~~50~~ 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`)
> 3 votes

# Answer
# 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!
> 3 votes

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

```
> 3 votes

# Answer
# Python 3, ~~87~~ ~~77~~ 73 bytes

Kinda noob solution. Just using random and then substituting with %s.

```
import random;print("min%sraft"%"ec"if random.randint(1,1e4)<1e4else"ce")

```
> 3 votes

# Answer
# x86-64 Machine Code, Microsoft Calling Convention, 33 bytes

Works by checking if 32 bits of the time stamp are less than `2^32/10000`. Technically, it's about 1 in 9999.994, but it should be close enough. The functions would have a signature of:

```
extern "C" void minceraft(char* out);

```

but the output is not null terminated.

```
0F 31                            rdtsc
3D B8 8D 06 00                   cmp         eax,68DB8h
48 B8 65 63 72 61 66 4D 69 6E    mov         rax,6E694D6661726365h
77 02                            ja          minecraft
86 C4                            xchg        al,ah
minecraft:
48 C1 C0 18                      rol         rax,18h
48 89 01                         mov         qword ptr [rcx],rax
C6 41 08 74                      mov         byte ptr [rcx+8],74h
C3                               ret

```

An alternative, also 33 bytes:

```
48 B8 4D 69 6E 65 63 72 61 66    mov         rax,66617263656E694Dh
48 89 01                         mov         qword ptr [rcx],rax
C6 41 08 74                      mov         byte ptr [rcx+8],74h
0F 31                            rdtsc
3D B8 8D 06 00                   cmp         eax,68DB8h
77 06                            ja          minecraft
66 C7 41 03 63 65                mov         word ptr [rcx+3],6563h
minecraft:
C3                               ret

```
> 3 votes

# Answer
# Vyxal , ~~27~~ 16 bytes

```
‛↔ṅ‛cek2ʁ℅ßṘ`r…ż

```

Try it Online!
> 3 votes

# Answer
# Bash, ~~58~~ ~~57~~ 54 bytes

```
s=ec;[ `shuf -n1 -i0-9999` = 0 ]&&s=ce;echo Min$s\raft

```

Try it online!
> 3 votes

# Answer
# Rattle, 43 bytes

```
Min&e&c&raft&1e4|I<b0=?~%~[0b2b1][^0b1b2]b3

```

Try it Online!

## Explanation

```
Min&e&c&raft&1e4|            passes ["Min", "e", "c", "raft", 10000] as hard-coded input
  I                          parse input, place into consecutive memory slots
                                 and move pointer to next free slot
   <                         move pointer left (to the slot with 10000)
    b0                       add item in slot 0 to print buffer ("Min")
      =?~                    set the top of the stack to a random integer value
                                 from 0 to the value in storage at the pointer (10000)
         %~                  set the top of the stack to the result of
                                 this random value mod 10000
           [0    ]           if the result is 0...
             b2b1            add the values in slots 2 then 1 to print buffer ("ce")
                  [^0    ]   if the value is not 0...
                     b1b2    add the values in slots 1 then 2 to print buffer ("ec")
                          b3 add "raft" to print buffer and print implicitly

```

Want to test this but don't want to run the code 10000 times? Try replacing "1e4" with "4".
> 3 votes

# Answer
# 05AB1E, ~~25~~ ~~24~~ ~~23~~ 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

```
> 2 votes

# Answer
# Wolfram Language, ~~50~~ ~~47~~ 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!
> 2 votes

# Answer
# Julia, 41 bytes

```
print(:Min,rand()<1e-4 ? :ce : :ec,:raft)

```

Try it online!
> 2 votes

# Answer
# C# (Visual C# Interactive Compiler), 55 bytes

```
()=>$"Min{(new Random().Next(0,9999)>0?"ec":"ce")}raft"

```

Try it online!
> 2 votes

# Answer
# Scratch, 71 bytes

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

```

Uses scratchblocks syntax.
> 2 votes

# Answer
# Raku, 31 bytes

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

```

Try it online!
> 2 votes

# Answer
# Julia, 39 bytes

```
f()="Min$(rand()<1e-4 ? :ce : :ec)raft"

```

Try it online!
> 2 votes

# Answer
# 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!
> 2 votes

# Answer
# 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.
> 2 votes

# Answer
# 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")

```
> 2 votes

# Answer
# Java (JDK), 45 bytes

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

```

Try it online!
> 2 votes

# Answer
# 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"

```
> 2 votes

# Answer
# 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`
> 2 votes

# Answer
# 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.
> 2 votes

# Answer
# 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`
> 2 votes

# Answer
# APOL, 39 bytes

`+("Min" +(¿(!(∿(õ)) "ce" "ec") "raft"))`
> 2 votes

# Answer
# Rust, 87 bytes

```
print!("Min{}raft",if (rand::random::<u16>()as f32/6.5535).ceil()==1.{"ce"}else{"ec"})

```

Scales the 0-65,535 to be from 1-10,000 and checks if the result is 1.

Playground link
> 2 votes

# Answer
# T-SQL, 44 bytes

```
PRINT'MIN'+IIF(RAND()<1E-4,'CE','EC')+'RAFT'

```

Notes:

* `PRINT` saves one character over `SELECT`
* To easily validate the code, replace `1E-4` (1/10,000) with `1E-1` (1/10), and run it a few dozen times; it should be quick to demonstrate it works as expected.
* `RAND()<1E-4` is one character shorter than my original version, `1E4*RAND()<1`.
> 2 votes

# Answer
# Kotlin, ~~67~~ 81 bytes

Try it online!

```
print("min${if(kotlin.random.Random.nextUInt()%10001u>9999u)"ce" else "ec"}raft")

```

or this if import's are allowed, which is 67 bytes in this context:

```
print("min${if(Random.nextUInt()%10001u>9999u)"ce" else "ec"}raft")

```

explanation for the code:

```
if(Random.nextUInt()%10001u>9999u)"ce" else "ec"

```

`Random.nextUInt()` Returns a random Kotlin `UINT` Number, the `%` (modulo operator) is to make it be within the ranges of `0, n`, 10000 in this case, i could have used `1e4` to accomplish it but it would be a `double` and it would need conversion, which just adds extra bytes, if the expression is true, "ce" would be used, which is the odd possibility, also since it starts from 0 and not 1, the possible combinations inbetween 0, 10001 is 100000, `2%2` is 0 and not 2 for example, and since `>9999u` can only be 1 smaller than 10000, which the \> compansates for, also it is the same as == 10000u, it is for saving bytes.

Proof:

```
        var count = mutableListOf<Int>()
        for(z in 0..10)
        {
            count.add(z, 0)
            for(i in 0..100000000)
            {
                if(Random.nextUInt()%10001u>9999u) count[z] += 1
            }
        }
        var avg = 0
        for(i in count.indices)
        {
            avg += count[i]
        }
        avg /= count.size
        println("ratio: ${100000000f / avg}, normal ratio: ${10000/1f}")

```

> ratio: 9995.003, normal ratio: 10000.0
> 2 votes

# Answer
# Javascript 37 bytes

```
$=>`Min${new Date%1e4?"ec":"ce"}raft`

```
> 2 votes

# Answer
# Thunno `KJ`, \\$ 27 \log\_{256}(96) \approx \\$ 22.22 bytes

```
"raft""ceec"ZlZ4RZw0>AI"Min

```

Attempt This Online!

Replace `Z4` with a small number like `4` if you want to test it.

#### Explanation

```
"raft" # Push "raft"
"ceec" # Push "ceec"
Zl     # Uninterleave to get ["ce", "ec"]
Z4R    # Push range(10**4)
Zw     # Pop and push a random element
0>     # Is it greater than 0?
AI     # Index into the list ["ce", "ec"]
"Min  "# Push the string "Min"
       # The flags join the stack
       # (which is reversed in Thunno,
       # so "Min" is actually the first item)

```
> 2 votes

# Answer
# Thunno 2, 17 bytes

```
ʋẠĿ&⁺9ṗk2ɼḅṇŒ×iJḟ

```

Port of Grimmy's 05AB1E answer.

## Thunno 2, 18 bytes

```
k2Lɼ?ʋẠĿ&⁺ḟ:ʋẠṬĠȤḟ

```

Alternatively:

```
k2ɼḅ‘ẠĿ&⁺ ẠṬĠȤ‘Oiḟ

```

Port of caird coinheringaahing's Jelly (fork) answer.

#### Explanation

```
ʋẠĿ&⁺9ṗk2ɼḅṇŒ×iJḟ   # Full program
ʋẠĿ&⁺               # Push dictionary compressed string "MineCraft"
     9ṗ             # Permutations of the above with length 9
       k2ɼ          # Push a random number in the range [1..10000]
          ḅ         # 1 if it equals 1, 0 otherwise
           ṇŒ       # Push codepage compressed integer 120
             ×      # Multiply these together
              i     # Index into the list of permutations
               J    # Join the resulting list into a string
                ḟ   # And title case this string
                    # Implicit output

```

```
k2Lɼ?ʋẠĿ&⁺ḟ:ʋẠṬĠȤḟ  # Full program
k2                  # Constant for 10000
  Lɼ                # Push a random number in the range [0..9999]
    ?               # If it's truthy (non-zero):
     ʋẠĿ&⁺          #  Push dictionary compressed string "MineCraft"
          ḟ         #  And title case it to get "Minecraft"
           :        # Otherwise:
            ʋẠṬĠȤ   #  Push dictionary compressed string "MinceRaft"
                 ḟ  #  And title case it to get "Minceraft"
                    # Implicit output

```

```
k2ɼḅ‘ẠĿ&⁺ ẠṬĠȤ‘Oiḟ  # Full program
k2ɼ                 # Push a random number in the range [1..10000]
   ḅ                # 1 if it equals 1, 0 otherwise
    ‘ẠĿ&⁺ ẠṬĠȤ‘     # Push dictionary compressed string "minecraft minceraft"
               Oi   # Split on spaces and index into the list
                 ḟ  # Title case the resulting string
                    # Implicit output

```
> 2 votes

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

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

```

Try it Online!

# Vyxal, 30 bytes

```
`Min`k2ʀ℅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....
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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'

```
> 1 votes

# Answer
# F# (.NET Core), 70 bytes

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

```

Try it online!
> 1 votes

# Answer
# Pari/GP, 44 bytes

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

```

Try it online!
> 1 votes

# Answer
# 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
> 1 votes

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

```
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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)
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# Julia, 35 bytes

```
"Min$(rand()<1e-4 ? :ce : :ec)raft"

```

Try it online!
> 1 votes

# Answer
# Lua, 52 bytes

```
print(1<math.random(1e4)and'Minecraft'or'Minceraft')

```

Try it online!
> 1 votes

# Answer
# Dart, 71 bytes

```
import'dart:math';f()=>"Min${Random().nextInt(10000)<1?'ce':'ec'}raft";

```

Try it online!
> 1 votes

# Answer
# Javascript, 59 bytes

```
console.log(`Min${['ec','ce'][+(Math.random()<1e-4)]}raft`)
```

One less thanks to @ophact !
> 1 votes

# Answer
# BRASCA, 21 bytes

```
`Minec`HH*{?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

```
> 1 votes

# Answer
# JavaScript (Node.js), 44 bytes

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

```

Try it online!

Edit : port of Java answer from : jadeFalk
> 1 votes

# Answer
# MathGolf, 16 bytes

```
ùMin♫╢♂a*├x▌w╕rß

```

Try it online or output 10,000 space-delimited results at once.

**Explanation:**

```
ùMin              # Push string "Min"
    ♫             # Push 10000
     ╢♂           # Push compressed string "ec"
       a          # Wrap it in a list: ["ec"]
    ♫   *         # Repeat it the 10000 amount of times: ["ec","ec","ec",...]
         ├        # Pop and push the first item (without popping the list): "ec"
          x       # Reverse it: "ce"
           ▌      # Prepend it back to the list: ["ce","ec","ec",...]
            w     # Pop and push a random item from this list
             ╕rß  # Push compressed string "raft"
                  # (after which the entire stack joined together is output implicitly)

```
> 1 votes

# Answer
# BQN, ~~47~~ 40 bytes SBCS

-7 bytes thanks to DLosc

```
"Min"∾"raft"∾˜⌽⍟(0=•rand.Range 10⋆4)"ec"

```

Try it!

## Explanation

```
"Min"∾"raft"∾˜⌽⍟(0=•rand.Range 10⋆4)"ec"
              ⌽⍟(0=•rand.Range 10⋆4)"ec"  - If rand(0,9999)==0, reverse "ec"
"Min"∾"raft"∾˜                            - Join it to "Min" and "raft"

```
> 1 votes

# Answer
# Rust 107 bytes#

```
use rand::Rng;fn main(){println!("Min{}raft",if rand::thread_rng().gen_range(0..10000)==0{"ce"}else{"ec"})}

```

There's unfortunately no try online option as this solution does require the use of crates.

Pretty straight forward though, it generates a random integer between 0-999 inclusively and then if it is 0 it fills in "ce" instead of "ec" into the string template.
> 1 votes

# Answer
# Snap! (scratchblocks3 syntax), 73 bytes

```
when gf clicked
if(pick random(0)to(9999
say[Minecraft
else
say[Minceraft

```

The number `0` is falsy in Snap!, and all positive numbers are truthy.
> 1 votes

# Answer
# CJam, 24 bytes

```
"Minec"e!1e3mrHG?="raft"

```

Try it online!

```
code
-------------------------|--------
"Minec"e!1e3mrHG?="raft" |
                ?        | If...
         1e3mr           | a random number 0-9999
                         | is not zero..
              H  =       | Get the index 16 in...
       e!                | all permutations of...
"Minec"                  | string literal "Minec"
                         | else...
                G        | Get index 15
                  "raft" | Push 'raft'

```

Index 16 in the permutations is "Minec", index 15 is "Mince".
> 1 votes

# Answer
# C (GCC), 48 bytes

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

```

Try It Online!

62 bytes solution where the chance is exactly 1/10000:

```
i;f(){while(i=rand(),i>9999);printf("Min%sraft",i?"ec":"ce");}

```

Try It Online!
> 1 votes

# Answer
# Scala, 70 bytes

Try it online!

```
println(if(new Random().nextDouble()<1e-4)"Mincecraft"else"Minecraft")

```
> 1 votes

# Answer
# Python 3, 71 66 bytes

-5 bytes thanks to Unrelated String

```
from random import*
print(f"Min{'ecce'[randint(1,1e4)<2::2]}raft")

```

Try it online!
> 1 votes

# Answer
# C++, 150 bytes

```
#include<iostream>#include<ctime>
int main(){srand(time(NULL));int a=rand()%10000+1;if(a==5432){std::cout<<"minceraft";}else{std::cout<<"minecraft";}}

```
> 1 votes

# Answer
# Python, 70 Bytes

```
from random import*;print(randrange(0,1e4)and'Minecraft'or'Minceraft')

```

Try it onlien!
> 1 votes

# Answer
# GolfScript, ~~38~~  ~~33~~  ~~31~~ 30 bytes

```
"Min"10000rand"ec""ce"if"raft"

```

Try it online!

```
"Min"10000rand"ec""ce"if"raft" | whole program                   | Stack:
"Min"                          | push "Min"                      | "Min"
     10000rand                 | generate a random number 0-9999 | "Min"<0-9999>
                      if       | If it is truthy.... (non-zero): | "Min"
              "ec"             | Push "ec". Else:                |
                  "ce"         | Push "ce"                       |
                        "raft" | Push "raft"                     | "Min"<ec/ce>"raft"

```
> 0 votes

# Answer
# Arturo, 46 bytes

```
$[]->~«min|(2>random 1 1e4)?->"ce"->"ec"|raft

```

Try it
> 0 votes

---
Tags: code-golf, kolmogorov-complexity, random
---