Four ways to be the same
The first line has n, and the second line has n values separated by single spaces.
Each value is a string token that can be written as is in JavaScript code.
A token is an integer (e.g.
5, -12, -0), a string in double quotes (e.g.
"5", "", "abc"), or one of true, false, null, undefined, NaN.
Turn each token into that JavaScript value, then remove duplicates separately under four equality rules.
The rules are, in order, a == b, a === b, Object.is(a, b), and the equality a Set uses (whether two values merge into one when put in a new Set).
Look at the values one at a time from the front.
Keep a value if none of the values kept so far is equal to it under the rule; otherwise drop it.
For each rule, print on one line the number of kept values and then their positions (1-based input order) from smallest, separated by spaces.
- Input
- 1 ≤ n ≤ 2000.
Integers are between -1000 and 1000 and have no leading zeros (-0 may appear).
The string inside the quotes is empty, 1 to 4 digits (it may start with 0), or 1 to 5 lowercase English letters. - Output
- four lines (==, ===, Object.is, Set, in that order)
8 0 -0 NaN NaN "0" null undefined false
4 1 3 4 6 7 1 3 4 5 6 7 8 7 1 2 3 5 6 7 8 6 1 3 5 6 7 8
3 "" 0 "0"
2 1 3 3 1 2 3 3 1 2 3 3 1 2 3