Remainder Challenge

63%4
60 goes into 4 = 20 times which leaves 3 as the remainder

Hello!
So I made mine in Unity in C# and made a little action clicker so that it would mod an RNG with a random player limited by 1-4. But I also put in a variable for the communityNumber I was given.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using static UnityEngine.Debug;

public class Remainders : MonoBehaviour
{
	public float communityNumber;
    
    void Start() {
	    communityNumber = 63;
    }

    // Update is called once per frame
    void Update()
    {
	    if (Input.GetMouseButtonDown(0))
	    {
		    ReadyPlayer();
	    }
    }
    
	void ReadyPlayer()
	{
		float playerCount = UnityEngine.Random.Range(1, 4);;
		float rngIfYouNasty = UnityEngine.Random.Range(1, 1025);
		communityNumber = rngIfYouNasty;
		float remainder = communityNumber % playerCount;
		
		Log("Your Random number is: " + rngIfYouNasty);
		
		if (remainder == 0){
			Log("Ready Player One");
		}
		if (remainder == 1) {
			Log("Ender's Game");
		}  
		if (remainder == 2) { 
			Log("Charlie and the Chocolate Factory");
		} 
		if (remainder == 3) {
			Log("Wishmaster 1 for no reason at all.");
		}
	}
}

The result with the community number would be Player 4 or as I’ve named them “Wishmaster 1 for no reason at all.”

The RNG will spit out a random number for the next person. I got 711 using a range of 1-1025.
So the number for the next person is 711.

1 Like

Privacy & Terms