Numbers
These puzzles provide means for various operations with numbers in your scenario.
Contents
Puzzles Reference
number
This universally used puzzle provides the means to supply some number to your Puzzles scenario.
Numbers can be written without decimals (integers) or with decimals (floating-point numbers). Extra large or extra small numbers can be written with scientific (exponent) notation.
angle
This puzzle allows you to visually define angle (in degrees).
arithmetic operation (with two inputs)
This puzzle allows you to perform elementary arithmetic operations: addition (+), subtraction (-), multiplication (×) and division (÷), as well as exponentiation (^).
Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.
arithmetic operation (with single input)
This puzzle allows you to perform the following mathematical operations: square root (√), absolute value aka modulus (|x|), sign change aka negation (-), natural logarithm (ln), decimal logarithm (log10), natural exponential function (e^), and power of ten (10^).
Examples:
Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.
round (to integer)
This puzzle rounds a specified number. The round variant rounds a number to the nearest integer: 2.49 will be rounded down (producing 2), and 2.5 will be rounded up (producing 3). The round up variant rounds a number upward to the nearest integer: 2.1 will be rounded up (producing 3). The round down variant rounds a number downward to the nearest integer: 2.9 will be rounded down (producing 2).
Examples:
round with precision
This puzzle rounds a given number using the specified precision.
Examples:
Floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision as follows:
check
This puzzle checks whether a specified number is even, odd, prime, whole, positive, negative, or divisible by some other number. The result is true if this is the case and false if not. For using with Logic puzzles.
Examples:
clamp
This puzzle constraints a number to be between the specified limits (inclusive).
Examples:
map range
This puzzle maps a given value from one range to another.
Example: converting position of the slider that moves from -10 to 10 units along axis X to percentage value from 0% to 100%.
random integer
This puzzle returns a random integer number between specified numbers (inclusive both limits).
Note: supplying non-integer limits is possible, although this extends the range as this puzzle performs some additional rounding under the hood.
Examples:
random fraction
This puzzle returns a random floating-point number between 0 (inclusive) and 1 (exclusive).
In the following example this puzzle is used to generate a random color for a material:
remainder
This puzzle finds the remainder after division of one number by another (aka the modulo operation).
Examples:
operations on list
Performs an operation on the numbers of a specified list.
- sum - calculates the sum of all numbers in the list.
- min - finds the smallest number.
- max - finds the largest number.
- average - finds the arithmetic mean (as the sum of all numbers divided by the length of the list).
- median - finds the median (as the middle number when all numbers are sorted from smallest to largest).
- modes - finds the modes (as a list of numbers that appear the most frequently in the list).
- standard deviation - calculates the standard deviation (as the square root of the average of the squared deviations from the arithmetic mean).
- random item - returns a randomly chosen item.
Examples:
trigonometric functions
This puzzle allows you to calculate the values of the trigonometric functions sine (sin), cosine (cos), and tangent (tan), as well as the values of their inverse counterparts arcsine (asin), arccosine (acos), and arctangent (atan). The puzzle expects (or returns) values expressed in degrees.
Examples:
Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.
constants
This puzzle returns the following mathematical constants: pi (π), Euler's number e, the golden ratio (φ), square root of 2, square root of ½, and infinity value (∞).
Examples:
create vector
This puzzle returns a new three-dimensional vector which consists of the given X, Y, Z coordinates.
set vector value
This puzzle set the given value (x, y, z coordinate or length) for the given vector.
get vector value
This puzzle returns the given value taken from the given vector.
Returned values:
- x - X coordinate.
- y - Y coordinate.
- z - Z coordinate.
- is zero - true if the vector has zero length, false otherwise.
- length - vector length.
- negated - a new vector which points in the reverse direction.
- normalized - a new vector with length 1.
vector math
This puzzle performs a math operation between two vectors and returns a new vector.
Operations:
- + - add vectors.
- - - subtract vectors.
- × - multiply vectors (per-component).
- / - divide vectors (per-component).
- dot - calculate and return a dot product between vectors.
- cross - calculate and return a cross product between vectors.
- rotate - rotate a vector by Euler angles given as the second parameter. Euler angles are specified in degrees.
Having Troubles with Puzzles?
Seek help on the forums!