# 8 random numbers of 167

**URL:** <https://forum.kirupa.com/t/8-random-numbers-of-167/120232>\
**Category:** Uncategorized\
**Created:** [August 22, 2004, 6:43am UTC](https://forum.kirupa.com/t/8-random-numbers-of-167/120232 "2004-08-22T06:43:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![murka390](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@murka390](https://forum.kirupa.com/u/murka390)\
**Post date:** [August 22, 2004, 6:43am UTC](https://forum.kirupa.com/t/8-random-numbers-of-167/120232/1 "2004-08-22T06:43:37Z")

</div>

how can i get 8 random (and DIFFERENT) numbers out of 167(random(167))?  
6 must be also excluded (6 - a variable)

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [August 22, 2004, 7:21am UTC](https://forum.kirupa.com/t/8-random-numbers-of-167/120232/2 "2004-08-22T07:21:59Z")

</div>

> [@murka390](#):
>
> how can i get 8 random (and DIFFERENT) numbers out of 167(random(167))?  
> 6 must be also excluded (6 - a variable)

shuffle = function () {  
return Math.round(Math.random());  
};  
myArray = ;  
for (var i = 1; i\<168; i++) {  
myArray.push(i);  
}  
myArray.splice(5, 1);  
myArray.sort(shuffle);  
for (var j = 0; j\<8; j++) {  
trace(“myArray[”+j+"] = "+myArray[j]);  
}

---

<div class="post-metadata">

**Author:** ![murka390](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@murka390](https://forum.kirupa.com/u/murka390)\
**Post date:** [August 22, 2004, 8:27am UTC](https://forum.kirupa.com/t/8-random-numbers-of-167/120232/3 "2004-08-22T08:27:05Z")

</div>

hm… before today i have never used arrays… but i should learn them quick, cause’ as i can see, they can do a lots of miracles 😉

now, about that script…

can i do this? (if i want to exclude the \_parent.\_parent.\_currentframe-1,1)  
myArray.splice(\_parent.\_parent.\_currentframe);

and if i want to get those randomly chosen numbers to different variables, then is this correct?  
vale1 = j[0] (“vale1” must equal to the first randomly picked number)  
vale2 = j[1] (etc.)  
vale3 = j[2]  
vale4 = j[3]  
vale5 = j[4]  
vale6 = j[5]  
vale7 = j[6]  
vale8 = j[7]

---

<div class="post-metadata">

**Author:** ![murka390](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@murka390](https://forum.kirupa.com/u/murka390)\
**Post date:** [August 22, 2004, 8:59am UTC](https://forum.kirupa.com/t/8-random-numbers-of-167/120232/4 "2004-08-22T08:59:49Z")

</div>

ok, i got it 🙂  
it should be like this? (if i want to exclude the \_parent.\_parent.\_currentframe and vale1,vale2, etc, must have those values)

shuffle = function () {  
return Math.round(Math.random());  
};  
myArray = [];  
for (var i = 1; i\<168; i++) {  
myArray.push(i);  
}  
myArray.splice(\_parent.\_parent.\_currentframe-1, 1);  
myArray.sort(shuffle);  
for (var j = 0; j\<8; j++) {  
trace(“myArray[”+j+"] = "+myArray[j]);  
vale1 = myArray[j-7];  
vale2 = myArray[j-6];  
vale3 = myArray[j-5];  
vale4 = MyArray[j-4]  
vale5 = MyArray[j-3]  
vale6 = MyArray[j-2]  
vale7 = MyArray[j-1]  
vale8 = MyArray[j]  
}
