# Use what you know: Your take on Diceware [duplicate]

If you're not familiar, Diceware is a method for creating passwords using an ordinary die from a pair of dice as a hardware random number generator.

For the sake of fun, let's ignore anything about the security of computer's random number generators.

Write a function or program that prints or returns a single five-character string containing a random selection of the numbers 1 through 6. These should be chosen with equal probability.

Example valid outputs:

21321
14654
53552
63641


No standard loopholes! This is code-golf, so shortest code in bytes wins.

• Like this?
– x13
Jan 7, 2016 at 13:00
• @PeterTaylor - the question you marked this a duplicate of is not even close to the same. Please unmark the question as a duplicate. Jan 7, 2016 at 15:25
• It's replacing an is-zero test with a loop. That's a trivial change, and by the standards of this site qualifies as a duplicate. Jan 7, 2016 at 16:25

# Dyalog APL, 7 bytes

10⊥?5⍴6


Try it online on TryAPL.

### How it works

    5⍴6  Yield (6 6 6 6)
?     Roll; turn each 6 into a random integer between 1 and 6.
10⊥      Decode with base 10.


# Julia, 24 bytes

print(join(rand(1:6,5)))


We use rand to get an array of length five consisting of elements randomly chosen from the range 1:6. We join it into a string using join then print it to STDOUT using print.

## J, 11 bytes

a.{~49+?5$6  Explanation:  5$6    NB. repeat 6 five times      output: 6 6 6 6 6
?5$6 NB. 5 random integers < 6 output: 4 5 1 0 2 49+?5$6    NB. add 49 ('1') to them     output: 53 54 50 49 51
a.{~49+?5\$6    NB. convert them to ASCII    output: 56213


# Pyth, 9 8 bytes

jkO^S6 5


Try it online.

Get list of numbers 1 to 6, Cartesian 5th power, pick random element, join by empty string.

## CJam, 8 bytes

{6mr)}5*


Test it here.

### Explanation

{       e# Run this block 5 times.
6mr  e# Get a random integer in [0,5] with uniform distribution.
)    e# Increment.
}5*


# Mathematica, 36 bytes

""<>ToString/@{1,6}~RandomInteger~5&


cough cough string formatting cough cough

# MATLAB / Octave, 12 bytes

[49+6*rand(1,6),'']
ans = 153361


rand(x,y) creates a random array with dimensions (x-by-y) with numbers between 0 and 1. Multiply this by 6 to get values between 0 and 6. Add 49 to get a value 49 < n < 55 (the random number will never be exactly 0 or 1). [...,''] converts this to strings with the floored values of n (integers [49 54] corresponding to [1 6] in ASCII.

# TeaScript, 11 bytes

r6)ΣN6))j(u


Try it online