Math - Remainders - Challenge

173%4 = 1
so Player 2’s turn

Here how I solved it in my calculator in 2 different ways:

image

And here is the solution in the unreal engine:

image
image

Next number is: 331

331 % 4 = 3

My solution

Next number is: 98

98/4= 24.5
24.5-24=0.5
0.5*4=2
thus P3 starts

Next number is : 133

133%4 = 33 r1

The second player is now playing.

Next number is: 31

31%4 = 7r3

With the remainder of 3, player 4 would start.

Next number! 137

Nice simple bit of math to start off, 137 % 4 = 3 (137/4 = 34 r 1) so Player 2 gets to go first.

C# Script

private int rngValue = 137;
private int playerCount = 4;
private int r;
public string[] players = {"One","Two","Three","Four"};


r = rngValue % playerCount;

if(r==0)
{
	System.Console.WriteLine("Player " + players[r] + ", you go first.");
}
if(r==1)
{
	System.Console.WriteLine("Player " + players[r] + ", you go first.");
}
if(r==2)
{
	System.Console.WriteLine("Player " + players[r] + ", you go first.");
}
if(r==3)
{
	System.Console.WriteLine("Player " + players[r] + ", you go first.");
}

Next Number! 649

1 Like

I wrote a simple code in Processing (Java) for this if anyone is interested. Find below:

int number = int(random(1,100));

if (number % 4 == 0) {
println(“P1 starts”);
} else if (number % 4 == 1) {
println(“P2 starts”);
} else if (number % 4 == 2) {
println(“P3 starts”);
} else {
println(“P4 starts”);
}

649/4 = 162.25, 0.25*4 = 1

The remainder is 1, so Player 2 goes first

Next Number: 38

1 Like

If (63%4=3)

else
player 4 goes first
79

1 Like

That’s how my code looks like

        int randNum = Random.Range(0, 100);
        Debug.Log(randNum);
        if (randNum % 4 == 0)
        {
            Debug.Log("FirstPlayer Starts!");
        } else if (randNum % 4 == 1){
            Debug.Log("SecondPlayer Starts!");
        } else if (randNum % 4 == 2){
            Debug.Log("ThirdPlayer Starts!");
        } else{
            Debug.Log("FourthPlayer Starts!");
        }

71 % 4 = 3
Answer - 4th player starts

Next number is 221

1 Like

63%4=3
Player four goes first.

221/4=55.25
55.25-55=0.25
0.25*4=1

so player two goes first

next number is 423

1 Like

Answer is “fourth player turn”. 63%4 = 3

Previous message asked for 423 : “fourth player turn”
423%4 = 3

A small javascript snippet to compute player turn.

function whichPlayer(number){
	const labels = ["first player turn", "second player turn", "third player turn", "fourth player turn"];
	return labels[number%4];
}

next number is 77

63 % 4 = ??

A / B = C
63 / 4 = 15.75

Remove .75
C = 15

C * B
15 * 4 = 60

A - C = R
63 - 60 = 3

R = 3

63 % 4 = 15 R 3

Player 3 Gooooooo :slight_smile:

With calculator:
63/4 = 15.75
63-(4*15) = 3
Remainder = 3
Player 3 goes first.

With code:

        int num = 63 % 4;

        switch (num)
        {
            case 1:
                // Player 1 turn
                break;
            case 2:
                // Player 2 turn
                break;
            case 3:
                // Player 3 turn
                break;
            default:
                // Player 4 turn
                break;
        }

New number for the chain is 93!

I couldn’t find the right threads for the previous assignments, so I’m just going to put them all here. Sorry moderator person:

rounding assignment:
floor(6.283) = 6
ceil(6.283) = 7
round(6.283, 1) = 6.3
round(6.283, 2) = 6.28

division assignment:
9 - (3 / 1/3) + 1
9 - 9 + 1 = 1

remainder assignment:
calculator:
63 % 4
4 * 15 = 60, so should be player 3 (zero-indexed… in the example there is player 0)
last number: 93, should be player 1 (again, zero-indexed)

new number is 2

Calculator:
63 / 4 = 15.75
0.75 * 4 = 3 (3rd player)

Code (Java):

Previous poster’s number solution: player 2 will be.

New number (drumrolls): 1357

Calculator(SymboLab with my modification):
63/4=15*(3/4) => 3/4 * 4 = 3 => Player 3 Goes First
Previous Comment => 1357 / 4 => 339 * (1/4) => 1/4 * 4 = 1=> Player 1 Goes First
Code (C#)


New Number: 546

1 Like

Challenege calculated

Challenge code:
image

Previous calculated:

Previous Code:
image

Could not tell which number to use from previous , random 1089 with 4 players .

My code in unity c#

  void Start()
    {
        WhoGoesFirst(4, 1089);
    }

    void WhoGoesFirst(int numberOfPlayers, int seedNumber) 
    {
        /* Learn to use remainders operator %
         take the number of seed number and divide by the number of players
        the remainder is the player that goes first.
             */
        int m = seedNumber % numberOfPlayers;  
        Debug.Log(m);
        Debug.Log("The seed number is " + seedNumber + " and there are " + numberOfPlayers + " players, therefore player " + (seedNumber % numberOfPlayers) + " goes first");
    }

The remainder is 1 so player 2 goes first.

New random number 863.

63/4 = 15.75
ignoring 15 and multiplying decimal remainder with 4 : 0.75 * 4 = 3
so player 4 goes first.

using 863 as random
863/4 = 215.75
remainder .75 and multiplying decimal remainder with 4 : 0.75 * 4 = 3
so player 4 goes first.

next random number : 429

Privacy & Terms