Problem about counting integral

Hello Users!

Using MIT App Inventor, I'm creating a program to generate lotto numbers and to show how many times each rank came out when we ran N.

Everything looks perfect, but I've been struggling with one problem.

If I put a number in the blank, it won't be implemented once, and the result comes out as it is.

In a sense, if N is 50, 5th place 35 times and 4th place 15 times, 4th place "50" and 5th place "0" in the result value.

I'll put the code on. Please give me a lot of helping me a lot.

Thank you.

Are you trying to get Lotto combinations consisting of unique numbers, with no repeats within the lotto combination?

If so, see

I am intrigued by your use of the bitwise and block. What are you trying to achieve with that?

Hello ABG. First of all, thank you for your attention.

I'm using 'bitwise and' for choosing rank.

In Lotto, The first place winner must have six numbers, excluding bonus numbers, out of six numbers and one bonus number.

So, I use 'bitwise and' for 'pick number (winning number) 1~6'

Similarly, the third-place must match five numbers. so I used 'bitwise and' because only five of the PICK NUMBERs were correct, they were ranked third.

It is a wrong way to code with?

also, I check your FAQ Section. thank you for reply.

++

My Final goal is here.
For example, If you're going to create 100 lotteries, there will be consequences for number 100.
As a result of that number 100, let's assume that 4th place came out 1 time, 5th place came out 3 times, and 6th place came out 96 times.
So, there will be displayed [0,0,0,1,3,96]

But i have a problem that there will be displayed ["0","0","0","100","0","0",]
I think That code seems to put "N" in it whenever it gets any higher rank.

Here is a trick question to see if you understand what 'bitwise' means...

What is bitwise and (5, 6) ?

P.S. It's okay to cheat and use the Do It facility on a sample block, as long as you can explain the answer.

ah. is answer 4(1000)?
1001(5) AND 1010(6) = 1000(4)

If that's what it means, I think it's right that it's clearly wrong.

1 Like

Right, it is most likely wrong for lotto ranking (unless you have invented something new.)

You might simplify your work by trying to write a value function rank(given_number_list, winning_number_list) that calculates the rank value of a given number list from that list and the winning number list.

1 Like

Thank you for opening the way to think. I will try my best.

This value procedure might be useful in calculating the rank of a lottery ticket:

If you take the Intersection of the winning ticket's number list and a given ticket's number list, the result will be a list of numbers in the given ticket that are also in the winning ticket.

The length of that intersection list can be used to calculate rank of that ticket.

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

1 Like

Thank you for your attention.

I have a question about that block!
If I applied that block, what is the variable 'ITEM' mean?

I think LIST 1 means Winning Number List, LIST 2 means Picking Number List, and the RESULT means rank.
but I can't understand what ITEM mean. is it means a temporary number?

Yes, this is a temporary variable for loops. Each time through the loop, this variable has an item from the list. The loop repeats as many times as there are items in the list. If the list has 6 items, the loop will run 6 times. The first time the loop is passed, the variable "item" will have the value of the first item in the list. On the sixth pass of the loop, the variable "item" will have the value of the sixth item in the list.

1 Like

@ABG @Patryk_F
Thank you for your help <3 i solve the problem for making function for

  1. Making Winning Number
  2. Making Given Number
  3. Comparison of 1 and 2

Here's the overall function.

Again, I'm very much appreciated your kindness and help. thank you.

You might benefit from reading chapters 19-21 in
http://www.appinventor.org/book2
from

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.