• Post Reply Bookmark Topic Watch Topic
  • New Topic

random generator or random numbers or array  RSS feed

 
rey deleon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

how do I compare an array (or maybe int?) (example: 3572) to a 4digit number from random generator? how many of the four digit match the generated numbers. please help.

reydel
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you do it if you had to solve the problem using just pencil and paper. BTW It often helps to imagine you are explaining it to a 5 year old.
 
Derek Dalek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand the problem correctly, you have 2 four digit numbers and need to determine the number of matching digits. For example, if the numbers are 1234 and 1574, the first and last digits match and the count would be 2. While I want to give you more time to solve on your own, I will say that my solution involved the use of the modulus operator.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!