# Random numbers 1-13 that don't repeat more than once

**URL:** https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269
**Category:** Coding Questions
**Created:** [January 22, 2020, 11:02pm UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269 "2020-01-22T23:02:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jonnystockham](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jonnystockham](https://discourse.processing.org/u/jonnystockham)
#### Post date: [January 22, 2020, 11:02pm UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269/1 "2020-01-22T23:02:32Z")

</div>

Is it possible to randomly generate an int value going 1-13 and not make the numbers repeat more than once during this sequence?

---

<div class="post-metadata">

### Author: ![jonnystockham](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jonnystockham](https://discourse.processing.org/u/jonnystockham)
#### Post date: [January 22, 2020, 11:04pm UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269/2 "2020-01-22T23:04:28Z")

</div>

I want this number to randomise the order of the quiz and be able to restart it with a different order each time @Chrisir magic?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [January 22, 2020, 11:38pm UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269/3 "2020-01-22T23:38:14Z")

</div>

Yes. There are many ways, but one easy built-in way is to make an IntList, then call shuffle().

[https://processing.org/reference/IntList\_shuffle\_.html](https://processing.org/reference/IntList_shuffle_.html)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [January 23, 2020, 8:18am UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269/4 "2020-01-23T08:18:04Z")

</div>

```auto

IntList inventory;

void setup() {
  size(200, 200);
  inventory = new IntList();
  inventory.append(1);
  inventory.append(2);
  inventory.append(3);

  inventory.append(4);
  inventory.append(5);
  inventory.append(6);

  println(inventory);
  inventory.shuffle();
  println(inventory);

  int a = inventory.get(2); 
  println(a);
}

```

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [January 23, 2020, 8:40am UTC](https://discourse.processing.org/t/random-numbers-1-13-that-dont-repeat-more-than-once/17269/5 "2020-01-23T08:40:45Z")

</div>

```auto
final IntList sequence = IntList.fromRange(1, 14);
println(sequence);//IntList size=13 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

sequence.shuffle(this);
println(sequence);

exit();

```
