Ir al contenido principal

Guessing a lock combination

Suppose you have a lock and you don't know the combination to it.
Each field can contain any number ranging from 0 through 9. How many combinations can there possibly be? How to find the right combination?
One way to find the right combination is by trying all the possible combinations until the right one is found. Since the maximum value for each field is 9 and in this case we have 4 fields we can count from 0000 to the maximum value  which is 9999 to generate all the possible combinations.

To know how many possible combinations there are, simply take the maximum value and add 1 to it. In this case 9999 + 1 = 10000. The 1 is simply because 0000 also counts as a possible combination.

Comentarios

Entradas más populares de este blog

All Possible Color Combinations

A display can project 16,777,216 different colors . One way to generate all color combinations is by using the same method employed on this article but with Hexadecimal numbers . If we count from 0 to 16,777,215(#000000 to #FFFFFF) and convert each number to hexadecimal we will generate all of the 16,777,216 colors . See this method in action by moving the slider below. See the Pen All Colors by LiveUser ( @liveuser ) on CodePen . By using this method to generate each color and assigning them to individual pixels I was able to produce a 8192x2048(16777216) pixel image. Click/tap here to see full resolution image

How to learn how to code?

How I got Started My interest in video games(being a gamer) lead me to ask myself a couple of years ago "How do I make video games?". I ended up downloading a game engine called Unity 3d in which I found a Text editor with something called JavaScript . I Googled "What is JavaScript?" and "How to learn JavaScript?"  and ended up in a website called CodeCademy which had a very well structured interactive course. From there I started my coding journey  by reading online docs and different websites learning the basics of web development(HTML, CSS and JS) which lead me to learn how much knowledge I lacked in order to be able to develop video games. Developing video games was a lot harder and complex than I thought, I needed  to acquire 3d modeling skills, learn about texturing and animation, learn at least the basics of game engines and their specific functions for interacting with the scene and the elements using the programming language(scripting), audio r...

Finding the remainder of a number

The remainder is the integer "left over" after dividing one integer by another to produce an integer quotient -Wikipedia- In JavaScript(my favorite programming language) when you want to get the remainder of a certain operation you use the modulo (%) symbol. Some examples of this operation would be: 21 % 5 = 1 24 % 5 = 4 25 % 5 = 0 In the first(1) example 5 fits 4 times inside 21 and has a remainder of 1. In the second example 5 fits 4 times in 24 and has a remainder of 4. Finally, in the last example five fits 5 times inside 25 and has no remainder, thus the result is 0.