Map a random number to pi
LabVIEW, 53 LabVIEW Primitives
I match Strings and put the number into an "empty" x.xxx string and remove the number from pi so it doesn´t show up again.
the random number and the single chars here are kinda visible, is that all right or do i have to redo the recording?
Mathematica, 105 or 147 characters
If random number "between 0 and 1" means 0 <= random <= 1
, i.e. includes 0 & 1.
StringReplace[ToString@InputForm@N@Pi,
Thread[ToString/@Complement[Range@9,RandomInteger[{0,9},15]]->"x"]]
(105 characters)
Otherwise, taking random number "between 0 and 1" to mean 0 < random < 1
.
Loop to get 15 random integers, not all zero. Select complement from 0 to 9 range, i.e. those numbers from 0 to 9 not in the random list. Convert those integers to strings and replace the matching characters in a pi string.
(147 characters)
While[True,r=RandomInteger[{0,9},15];
If[Union@r!={0},Break[]]];
StringReplace[ToString@InputForm@N@Pi,
Thread[ToString/@Complement[Range@9,r]->"x"]]
3.1x15x265358x7x3
Random digits:-
FromDigits[r]
820307536180783
Pyth, 25 bytes
u&p?}HGH\x.-GH`.n0<`O017
Try it online: Demonstration or Test showing the random number
Explanation:
u&p?}HGH\x.-GH`.n0<`O017
.n0 the constant pi
` convert it into a string
O0 random number in the range [0.0, 1.0)
` convert to string
< 17 only use the first 17 chars (zero, point and 15 digits)
u for each char H in the pi-string:
?}HGH\x if H in G (the random number string) then H else "x"
p print this char without newline
& and
.-GH remove the digit H once from G
<space> suppress the output (u returns the unused digits in G)