# I need a line with different random numbers that have been picked once

**URL:** <https://discourse.processing.org/t/i-need-a-line-with-different-random-numbers-that-have-been-picked-once/23163>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [August 10, 2020, 4:43am UTC](https://discourse.processing.org/t/i-need-a-line-with-different-random-numbers-that-have-been-picked-once/23163 "2020-08-10T04:43:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lu\_mime](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lu\_mime](https://discourse.processing.org/u/lu_mime)\
**Post date:** [August 10, 2020, 4:43am UTC](https://discourse.processing.org/t/i-need-a-line-with-different-random-numbers-that-have-been-picked-once/23163/1 "2020-08-10T04:43:28Z")

</div>

I’m trying to solve an exercise, that i have to do a line, with for cycle. I need that it looks like this

6  
8  
9  
3  
1

but the only thing that I have is multiple numbers, in the same place, multiple times. I don’t know how to pick different random numbers every time the cycle for runs only once, and not every time the void draw read the code. I understand that the random function it’s inside the void draw, but, if I put it into the void setup, it only choose all the times the same number, like this:

2  
2  
2  
2  
2

the code that I am using, is this, hope someone can help me and fix it ❤

int tam = 25;  
int valAnterior;

void setup(){  
size(600,400);  
textSize(tam);

}

void draw(){  
background(200);  
for(int i=1; i\<6; i++){  
text(valAnterior, width/5, i\*tam);  
valAnterior = round(random(0,9));  
}

}

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 10, 2020, 4:47am UTC](https://discourse.processing.org/t/i-need-a-line-with-different-random-numbers-that-have-been-picked-once/23163/2 "2020-08-10T04:47:18Z")

</div>

Not gonna lie it looks like you’ve just posted an assignment in the hope that someone solves it for you

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 10, 2020, 8:18am UTC](https://discourse.processing.org/t/i-need-a-line-with-different-random-numbers-that-have-been-picked-once/23163/3 "2020-08-10T08:18:26Z")

</div>

Hello,

Look up each function you are using (and the related ones) and a solution will be forthcoming.

One of the best tools in a programmer’s tool chest is knowing the resources available to you and learning to navigate, filter, and use them.

A short list of resources to peruse:

> **Resources \< Click here to expand !**
>
> Explore the resources available here:
> 
> - The Processing _website_ has references, examples, tutorials, links to resources, etc.  
> [https://processing.org/](https://processing.org/)
> 
> - The Processing PDE (IDE) has lots to offer!  
> An exploration of the menu bar will reveal what is available; libraries, tools, local examples, and other goodies are in there.
> 
> - The Coding Train \< Experience the unbridled enthusiasm of Daniel Shiffman  
> [https://shiffman.net/](https://shiffman.net/)  
> [https://www.youtube.com/user/shiffman](https://www.youtube.com/user/shiffman)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> 
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> 
> - The source code can give insight if you are adventurous:  
> [GitHub - processing/processing: Source code for the Processing Core and Development Environment (PDE)](https://github.com/processing/processing)
> 
> - Explore Processing on GitHub:  
> [Processing Foundation · GitHub](https://github.com/processing)  
> [processing/core/src/processing/core/PApplet.java at master · processing/processing · GitHub](https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java) \< Many of the Processing functions are here!
> 
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the menu.  
> In the education menu, there is a reference to the Coding Train.
> 
> - And the Internet. `:)`

`:)`
