Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Wretchedlout on June 04, 2012, 08:43:30 pm

Title: Easy way to:
Post by: Wretchedlout on June 04, 2012, 08:43:30 pm
Is there an easy way to create a list with dim 26 with:
Rnd integers for each dim#
Any Dim = int 1-26
Dim x =/= x
Ex
Dim 1 = X
Dim X= 1
Dim 2 = Y
Dim Y = 2

Ask if you dont understand
Title: Re: Easy way to:
Post by: blue_bear_94 on June 04, 2012, 08:45:31 pm
So you want a list of 26 random integers from 1 to 26 where each element is not equal to its index?
Title: Re: Easy way to:
Post by: Wretchedlout on June 04, 2012, 08:48:28 pm
Yes, and the index of the number is = dim(num of index num
Title: Re: Easy way to:
Post by: blue_bear_94 on June 04, 2012, 08:49:28 pm
Code: [Select]
26→dim(L1
Fill(0,L1
For(A,1,13
1+sum(not(cumSum(0=L1→B
Repeat C≠L1(B) and not(L1(C
randInt(1,26→C
End
C→L1(B
B→L1(C
End
Edit: I realized that I made a mistake.
Edit 2: != means not equal (2nd test 2)
Title: Re: Easy way to:
Post by: Wretchedlout on June 04, 2012, 09:19:12 pm
:DD thanks
Title: Re: Easy way to:
Post by: jsj795 on June 04, 2012, 09:22:45 pm
i was trying to make one using seq( and SortA but then blue_bear already got the answer :P
Title: Re: Easy way to:
Post by: blue_bear_94 on June 05, 2012, 08:49:20 am
Well, let's see yours.
Title: Re: Easy way to:
Post by: Wretchedlout on June 05, 2012, 06:13:53 pm
Herm....
well it seems that about only 1/6 of the time this works. The reason it "dosen't work" is because 5/6 of the time it makes a 0 for one of the variables. Could you please fix this so that only 1-26 are in the variables of the list?
It seems the 0's are in the 20-26th place of the list most of the time
-Thanks :)
Title: Re: Easy way to:
Post by: blue_bear_94 on June 05, 2012, 06:59:58 pm

Code: [Select]
26→dim(L1
Fill(0,L1
For(A,1,13
1+sum(not(cumSum(not(L1→B
Repeat C≠B and not(L1(C //changed
randInt(1,26→C
End
C→L1(B
B→L1(C
End
Did you type the L1 token (2nd+L1) or the individual letters 'L' '1'?
Title: Re: Easy way to:
Post by: Wretchedlout on June 05, 2012, 07:08:24 pm
2nd and 1
and it has worked every time now :)

double thanks