## 30秒学会 JavaScript 片段 – union

Returns every element that exists in any of the two arrays once.

Create a `Set` with all values of `a` and `b` and convert to an array.

## 30秒学会 Golang 片段 – MaxOf

Returns the maximum value of two or more numbers.

Use `math.Inf(-1)` to set the initial maximum value to negative infinity.
Use `range` and `math.Max()` to iterate over the numbers and get the maximum value.

## 30秒学会 Golang 片段 – Median

Returns the median of a collection of numbers.

Find the midpoint and convert it to an integer, use `sort.Float64s()` to sort the given numbers.
Return the number at the midpoint if length is odd, otherwise the average of the two middle numbers.

## 30秒学会 Python 片段 – in_range

Checks if the given number falls within the given range.

Use arithmetic comparison to check if the given number is in the specified range.
If the second parameter, `end`, is not specified, the range is considered to be from `0` to `start`.

## 30秒学会 Python 片段 – max_by

Returns the maximum value of a list, after mapping each element to a value using the provided function.

Use `map()` with `fn` to map each element to a value using the provided function, use `max()` to return the maximum value.

## 30秒学会 PHP 片段 – factorial

Calculates the factorial of a number.

Use recursion.
If `\$n` is less then or equal to `1`, return `1`.
Otherwise, return the product of `\$n` and the factorial of `\$n -1`.

## 30秒学会 Dart 片段 – sumBy

Returns the sum of a list, after mapping each element to a number using the provided function.

Use `Iterable.map()` to map each element to the numeric value returned by `fn`, `Iterable.reduce()` to sum the values.

## 30秒学会 JavaScript 片段 – uniqueSymmetricDifference

Returns the unique symmetric difference between two arrays, not containing duplicate values from either array.

Use `Array.prototype.filter()` and `Array.prototype.includes()` on each array to remove values contained in the other, then create a `Set` from the results, removing duplicate values.

## 30秒学会 Python 片段 – max_n

Returns the `n` maximum elements from the provided list.
If `n` is greater than or equal to the provided list’s length, then return the original list (sorted in descending order).

Use `sorted()` to sort the list, `[:n]` to get the specified number of elements.
Omit the second argument, `n`, to get a one-element list.

## 30秒学会 JavaScript 片段 – isPrime

Checks if the provided integer is a prime number.

Check numbers from `2` to the square root of the given number.
Return `false` if any of them divides the given number, else return `true`, unless the number is less than `2`.