# Coding help needed

**URL:** <https://community.thunkable.com/t/coding-help-needed/2383408>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [April 21, 2023, 5:08am UTC](https://community.thunkable.com/t/coding-help-needed/2383408 "2023-04-21T05:08:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![csprincessc6fi](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@csprincessc6fi](https://community.thunkable.com/u/csprincessc6fi)\
**Post date:** [April 21, 2023, 5:08am UTC](https://community.thunkable.com/t/coding-help-needed/2383408/1 "2023-04-21T05:08:45Z")

</div>

I’m trying to make a simple poker hand app where users can decide which hand is the winner quickly.  
This is supposed to simulate a Texas hold’em style Poker game. I only have two hands since this is my first try. Once the 5 table cards and the two cards for each player is displayed, I’m trying to get all possible hands of 5 from 7 for each player. I’m trying to create code like this using Thunkable blocks.  
List\<List\> p1Possible = new ArrayList\<\>();

```
    for (int i = 0; i < numbers.size(); i++) {
        int first = numbers.get(i);
        for (int j = i + 1; j < numbers.size(); j++) {
            int second = numbers.get(j);
            for (int k = j + 1; k < numbers.size(); k++) {
                int third = numbers.get(k);
                for (int l = k + 1; l < numbers.size(); l++) {
                    int fourth = numbers.get(l);
                    for (int m = l + 1; m < numbers.size(); m++) {
                        int fifth = numbers.get(m);
                        List<Integer> combination = new ArrayList<>();
                        combination.add(first);
                        combination.add(second);
                        combination.add(third);
                        combination.add(fourth);
                        combination.add(fifth);
                        p1Possible.add(combination);
                    }
                }
            }
        }
    }
   
    return p1Possible;

```

How can I do this?

This is what I have so far, and I only see 3 combinations.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/b/7b6bbbd270dbed063bcdc1eab159e2c28859f09d.png)  
Please help me!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 21, 2023, 12:42pm UTC](https://community.thunkable.com/t/coding-help-needed/2383408/2 "2023-04-21T12:42:40Z")

</div>

You are using the same variable (i) to all loops. You need to use a separate variable for each loop.

Use the dropdown menu to change the veriable  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/e/4eba35467e837f6a862faf1b178f32757aa96a29.png)

---

<div class="post-metadata">

**Author:** ![csprincessc6fi](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@csprincessc6fi](https://community.thunkable.com/u/csprincessc6fi)\
**Post date:** [April 26, 2023, 1:18am UTC](https://community.thunkable.com/t/coding-help-needed/2383408/3 "2023-04-26T01:18:57Z")

</div>

Thank you so much.  
When I tried renaming my variable it tried to rename all my i’s into j’s.  
So I looked at the variable I have created elsewhere and used those.  
And now I have way too many lists.  
This is my fixed list. And I feel like there is something wrong since I see more than 21 combinations of 5 elements.  
When I tried creating an app variable for each of my i’s and j’s, the code didn’t work at all.  
I know it’s difficult to help me without seeing everything.  
Can you help me a little more?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/9/49350f3d28af64cd76003e3f18fed556aaca4496.png)

---

<div class="post-metadata">

**Author:** ![csprincessc6fi](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@csprincessc6fi](https://community.thunkable.com/u/csprincessc6fi)\
**Post date:** [April 26, 2023, 3:06am UTC](https://community.thunkable.com/t/coding-help-needed/2383408/4 "2023-04-26T03:06:08Z")

</div>

I spent a little time and I was able to fix my error. Special thanks to @muneer for reminding me to change the variables.  
Here is the edited code that works for me now.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/3/8348fd90a2e646868d6f670857cc9f8a1327335c.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [July 25, 2023, 3:06am UTC](https://community.thunkable.com/t/coding-help-needed/2383408/5 "2023-07-25T03:06:53Z")

</div>

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