CJam,48 46 42 38 36字节
P`'xf+1dmr`{1$f#:!1a/0=:)W+H<.>
这是同时打印π和随机数的版本:
P_p`'xf+1dmr`_oNo{1$f#:!1a/0=:)W+H<.>
正如OP在评论中所阐明的,我没有将随机数截断为15个小数位。
说明
这个想法是将π的字符串表示形式中的每个字符变成一对该字符和x。对于随机数中的每个字符,我们交换以该字符开头的第一对字符。最后,我们输出每对的第二个字符。
P` e# Get string representation of π.
'xf+ e# Append "x" to each character.
1dmr` e# Get string representation of random number in [0,1).
{ e# For each character in that string...
1$ e# Copy the list of pairs.
f# e# For each pair, find the index of the current character. If the character is
e# not in the pair, we get -1 (truthy). If it is the first character of the pair,
e# we get 0 (falsy). If it is the second character, we get 1 (truthy).
:! e# Logical NOT for each of the results. We get a 1 for every pair we could
e# potentially swap.
1a/ e# Split around those 1s.
0= e# Keep only the first chunk.
:) e# Turn all the 0s into that chunk into 1s.
W+ e# Append a -1.
H< e# Truncate to 17 elements (the number of pairs).
.% e# Apply % pairwise. This reverses the element at the position of the -1.
}/
1f= e# Select the second character from each pair.