Group 4
Algorithm Group 4
Algorithm Group 4 contains five exercises focused on comparing multiple collections, generating combinations, finding shared values, selecting values by distance, and detecting common adjacent pairs.
Several tasks in this group operate on multiple slices representing independent datasets that must be compared with one another.
Tasks
Task 1 — Collection Equality
Determine whether three integer slices contain the same values even when those values appear in different orders.
Task 2 — Three-Element Average Combinations
Generate every unique combination of three different elements from an integer slice and count how many combinations have an average greater than a specified threshold.
Task 3 — Common Values
Find all integer values that appear in each of three input slices.
Task 4 — Closest Values to Target
For each input slice, identify the two values that are closest to a specified target value.
Task 5 — Common Adjacent Pairs
Find adjacent value pairs that appear in more than one input slice and report which slices contain each pair.
Objectives
The exercises in this group provide practice with:
- collection comparison
- ordering independence
- frequency and membership analysis
- combinations
- arithmetic averages
- intersection of multiple collections
- distance calculations
- nearest-value selection
- adjacent element processing
- pair comparison
- result deduplication
- deterministic output
Collection Relationships
Unlike some earlier groups, the slices in this group generally represent independent collections.
Their values may appear:
- in different orders
- only in some collections
- multiple times
- next to different neighboring values
The implementation should therefore distinguish between value membership, position, and adjacency depending on the task.
Implementation
The examples define the intended behavior for the provided data, but each implementation should solve the general problem.
Where the original specification contains an ambiguity or an inconsistent example, the individual task page provides a clarified requirement while preserving the intended exercise.