Post Reply 
Randomize a List problem
09-14-2020, 04:38 PM (This post was last modified: 09-14-2020 04:52 PM by Hlib.)
Post: #1
Randomize a List problem
Over the weekend, I did a little research using a calculator. This is a program called "Randomize a List", taken from the wonderful manual <One-Minute Marvels> (a collection of short HP48/49 programs, page 8) by Wlodek Mier-Jedrzejowicz and Richard Nelson.
`RANL`
Code:

<< LIST➝ ➝ t
<< 1. t FOR n n RAND × CEIL ROLLD NEXT t ➝LIST >> >>
`RANL` shuffles the list items randomly. Theoretically, the number of different lists of N elements is N!. This program cannot output any of all possible options when it is run once.
For example, we will never get permutations {1 2 3} and {2 1 3 }
after {3 2 1} `RANL`
The number of all possible options we can get for a list of N elements in this program when it is run once:
#2 {2 1} – 2 options out of 2!=2 possible.
#3 {3 2 1} – 4 options out of 3!=6 possible.
#4 {4 3 2 1} – 10 out of 4!=24.
#5 {5 4 3 2 1} – 28 / out of 5!=120.
#6 {6 5 4 3 2 1} – 80 / out of 6!=720.
#7 {7 6 5 4 3 2 1} – 274 / out of 7!=5040.
#8 {8 7 6 5 4 3 2 1} – 898 / out of 8!=40320 and so on.
To fix this, you need to replace one letter in the text: ... FOR n t RAND × ... .
But I`m interested in a more complex problem: how to use the formula to express the number of possible combinations in the first (not corrected) version of the program, also describing the ROLLD function in the loop. I calculated this using an algorithm on a calculator, and my knowledge of mathematics is clearly not enough for an analytical solution.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Randomize a List problem - Hlib - 09-14-2020 04:38 PM
RE: Randomize a List problem - John Keith - 09-14-2020, 06:08 PM
RE: Randomize a List problem - Albert Chan - 09-14-2020, 07:32 PM
RE: Randomize a List problem - Hlib - 09-14-2020, 08:51 PM
RE: Randomize a List problem - Albert Chan - 09-14-2020, 11:41 PM
RE: Randomize a List problem - Werner - 09-15-2020, 06:41 AM
RE: Randomize a List problem - Werner - 09-15-2020, 09:47 AM
RE: Randomize a List problem - Albert Chan - 09-15-2020, 04:36 PM
RE: Randomize a List problem - ijabbott - 09-15-2020, 06:39 PM
RE: Randomize a List problem - John Keith - 09-15-2020, 08:56 PM
RE: Randomize a List problem - Albert Chan - 09-15-2020, 09:34 PM
RE: Randomize a List problem - Werner - 09-16-2020, 06:43 AM
RE: Randomize a List problem - John Keith - 09-16-2020, 11:51 AM
RE: Randomize a List problem - Albert Chan - 09-15-2020, 01:00 AM
RE: Randomize a List problem - Wes Loewer - 09-15-2020, 04:10 AM
RE: Randomize a List problem - John Keith - 09-15-2020, 01:42 PM
RE: Randomize a List problem - Hlib - 09-15-2020, 03:57 PM
RE: Randomize a List problem - Albert Chan - 09-15-2020, 07:53 PM
RE: Randomize a List problem - Albert Chan - 09-17-2020, 12:11 PM
RE: Randomize a List problem - Hlib - 09-17-2020, 09:36 AM
RE: Randomize a List problem - John Keith - 09-17-2020, 12:20 PM
RE: Randomize a List problem - Albert Chan - 09-17-2020, 01:42 PM
RE: Randomize a List problem - John Keith - 09-17-2020, 08:21 PM
RE: Randomize a List problem - John Keith - 09-18-2020, 03:31 PM
RE: Randomize a List problem - Albert Chan - 09-18-2020, 10:19 PM
RE: Randomize a List problem - Albert Chan - 09-19-2020, 12:29 AM
RE: Randomize a List problem - pier4r - 10-13-2020, 07:13 PM
RE: Randomize a List problem - DavidM - 10-14-2020, 04:12 AM
RE: Randomize a List problem - Albert Chan - 10-15-2020, 04:43 PM
RE: Randomize a List problem - DavidM - 10-15-2020, 06:24 PM
RE: Randomize a List problem - pier4r - 10-14-2020, 06:55 PM
RE: Randomize a List problem - DavidM - 04-26-2024, 03:17 PM



User(s) browsing this thread: