Script creating a list of three numbers

Hi all,

I’m new here, and so on coding.

I friend of mine suggests me to learn JavaScript and Python, because I love riddles that I can’t solve (so this languages could help me).

Let me explain: I want to create a JS script starting from this real-life problem.

I have a padlock which have a code of three numbers to be unlocked (you have to turn upside down these numbers to obtain the “Open sesame”), the code goes to 000 to 999, obviously.

I need to create a script that lists all the possible numbers and, at the end, also tell me how many different numbers I have (I suppose 1000 if my math isn’t bad as my english).

I started the learning path, but I’m not able to create this script.

Can someone help me?

Thank you so much

Given that we know there a 1000 possible permutations (10 * 10 * 10), what would be the point of a list?

Yes, there are 1000 different combinations. You would use a for loop.

I need all the permutations listed: 000, 001, 002 … 222, 223, 224, and so on

Still don’t see the need for the list. What is the goal?

I need to check all the different combinations that i have done for unlock the padlock

To get a list of all possible combinations, you’d need to:

  • Create a list
  • Loop through each number 0-999
    – Add the number to the list
  • Print (log) the list to the console

To keep track of which combinations you’ve tried, you could do many things. I would create a new list and add to this each time you’ve tried the combination:

  • Create a list
  • Add the number you’ve just tried
    …rinse and repeat

Thank you jibs!

Now I will figure out how to make it

1 Like