# Tag Info

1

Here is an alternative approach. This generates empty list most of the time since first number might be less than 15 more often. SeedRandom@134 list = TakeList[RandomChoice[Range@20, 10000], Range@100]; TakeWhile[list, Max@# >= 15 &] {{19}, {4, 18}, {10, 11, 18}} Let see next list Take[list, 4] {{19}, {4, 18}, {10, 11, 18}, {3, 6, 5, 7}} Here is ...

0

So What i ended up doing is this f[n_] := Max[RandomInteger[{1, 20}, n]] Tally[Sort[ Table[First[ Position[Map[f, Range[2, 100]], _?(# < 15 &)]], {10000}] /. First[{}] -> {100}]] because I wanted to figure out the probabilities of hitting any given stopping point.

3

Set up a test function to control the iteration: Clear[test, i] i = 1; test[i_] := Max[Sow[RandomInteger[{1, 20}, i]]] >= 15; Use Sow-Reap combo to collect the results generated during the iteration, where SeedRandom is used to make the random results appear determined for the purpose of demonstration: SeedRandom; Reap[While[test[i], i++]][[2, 1]] {{...

Top 50 recent answers are included