This is how to make commands for **finding the minimum and maximum number** from a set of numbers.

## Setup

First, one will need to create some variables and a list:

(i) (min) (max) (numbers::list)

Then, to separate each number into its own item in the list, use the following custom block code:

define Initialize List (numbers) delete all of [numbers v] set [string v] to [] set [i v] to [1] repeat (length of (numbers)) if <(letter (i) of (numbers)) = ( )> then // Make sure there's a space in the right-hand side of the boolean add (string) to [numbers v] set [string v] to () // Make sure there's nothing in this input else set [string v] to (join(string) (letter (i) of (numbers))) end change [i v] by (1) end add (string) to [numbers v] // This block adds whatever's left to the list

## Find Maximum Number Command

This command has to be called like this: *1 2 3*. Typing *1 2 3* finds the maximum number out of 1, 2, and 3. It's possible to add as many numbers in the string.

### Creating the Command

The first step for creating the command is to make a block called *Find Biggest Number*, then add a number input called *Number string*, and finally check the "Run without screen refresh" box. Make this code under the *define* block:

define Find Biggest Number (numbers) Initialize List (numbers)::custom set [i v] to [1] set [max v] to [-Infinity] repeat (length of [numbers v]) if <(item (i) of [numbers v]) > (max)> then set [max v] to (item (i) of [numbers v]) end change [i v] by (1) end

### Using the Command

Now make a script like this one to test the command:

Find Biggest Number [1 2 3]::custom say (max)

If the program is correct, the sprite should say the number 3. If the sprite says no number or another number, check the *define* block's script.

## Find Minimum Number Command

This command uses a similar approach to the find maximum number command. The command is called the same way as the maximum number command.

### Creating the Command

The first step for creating this command is to make a block called *Find Smallest Number*, then add a number input called *Number string*, and finally check the "Run without screen refresh" box. Make this code under the *define* block:

define Find Smallest Number (numbers) Initialize List (numbers)::custom set [i v] to [1] set [min v] to [Infinity] repeat (length of [numbers v]) if <(item (i) of [numbers v]) < (min)> then set [min v] to (item (i) of [numbers v]) end change [i v] by (1) end

### Using the Command

Now make a script like this one to test the command:

Find Smallest Number [1 2 3]::custom say (min)

If the program is correct, the sprite should say the number 1. If the sprite says no number or another number, check the *define* block's script.

## Uses for These Commands

They are used for some reasons, like:

- Finding the maximum or minimum number of a number string.
- Quizzes where someone guesses the highest or lowest number.
- Doing advanced calculations.