Property | Value |
---|---|
Hex Value | $EF35 |
Categories | |
Localizations |
|
randIntNoRep(
Overview
Returns a random ordered list of integers from a lower integer to an upper integer which may include the lower integer and upper integer. If the optional argument numelements
is specified, the first numelements
are listed. The first numelements
term in the list of random integers are displayed.
Availability: Token available everywhere.
Syntax
randIntNoRep(lowerint,upperint [,numelements])
Arguments
Name | Type | Optional |
---|---|---|
lowerint | ||
upperint | ||
numelements | Yes |
Location
math, PRB
, 8:randIntNoRep(
Description
randIntNoRep( is used when you need to create a list of numbers in random order in which no integer is repeated. This command is useful for things such as simulating decks of cards. Commonly, before this command was introduced, the following code would shuffle a deck:
rand(52→L₂
seq(X,X,0,51→L₁
SortA(L₂,L₁
This result can now be achieved with the following code:
randIntNoRep(0,51→L₁
Advanced Uses
seed→rand affects the output of randIntNoRep(
What this does is quite simple. When you seed rand, then the next time you use randIntNoRep(, you will get a result that will be fairly random, but the same on all calculators. This allows several things to be possible, including password protection and encryption. For example, if you were to use the following code, you could encrypt and decrypt messages only if you use the same encryption value. In this example, Str1 contains the message:
Decode:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ .!,0123456789→Str2
Input "CODE:",A
A→rand
randIntNoRep(1,length(Str2→L1
length(Str1→B
".
For(A,1,B
Ans+sub(Str2,sum(cumSum(L1=inString(Str2,sub(Str1,A,1)))),1
End
sub(Ans,2,B
Encode:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ .!,0123456789→Str2
Input "CODE:",A
A→rand
length(Str2→C
randIntNoRep(1,Ans→L1
length(Str1→B
".
For(A,1,B
Ans+sub(Str2,L1(C+1-inString(Str2,sub(Str1,A,1))),1
End
sub(Ans,2,B
The output strings are in Ans
Related Commands
Source: parts of this page were written by the following TI|BD contributors: burr, MrTanookiMario, Timothy Foster, Xeda Elnara.
History
Calculator | OS Version | Description |
---|---|---|
TI-84+ | 2.53 | Added |