In many programming languages, the floating-point value NaN
, or "not a number", in some programming languages generated by the expression 0/0
, does not compare as equal to itself. In this challenge, you have to take input as five vulgar fractions, each matching \-?\d+\/\d+
(for example, 2/3
, -1/5
, or even 4/0
).
Your program should output the size of the largest group or groups with equal numbers. For example,
1/2
2/4
4/8
1/3
2/6
will output 3, since the first three fractions form a group, and so do the last two, but three is larger so we choose it.
If every fraction is unequal and there is at least one non-0/0
value, output 1. However, if every value is 0/0
, output 0.
Here is the full algorithm to determine if two fractions are equal.
0/0
does not equal any other fraction, not even another0/0
(NaN).- All instances of (positive number)
/0
are equal (infinity). - All instances of (negative number)
/0
are equal (-infinity). - If there are no zero-denominator fractions, compare them as usual.
More examples:
1/3,4/12,2/14,3/21,4/28 -> 3
1/1,1/1,1/1,1/1,3/4 -> 4
1/1,1/1,1/1,1/1,1/1 -> 5
1/1,1/1,-1/1,-1/1,-1/1 -> 3
1/2,2/4,-3/6,-4/8,-5/10 -> 3
-1/1,-1/1,-1/1,-1/1,-1/1 -> 5
-1/2,-2/4,1/2,2/4,1/1 -> 2
-1/2,-2/4,1/2,2/4,-5/10 -> 3
1/8,2/16,3/24,5/40,10/80 -> 5
1/1,2/1,3/1,4/1,5/1 -> 1
1/2,2/4,1/0,263/0,2837/0 -> 3
0/0,0/0,0/0,0/0,0/0 -> 0
1/0,2/0,3/0,4/0,5/0 -> 5
1/0,2/0,3/0,-1/0,-2/0 -> 3
-1/2,0/0,0/0,0/0,0/0 -> 1
-1/5,-2/10,0/0,0/0,0/0 -> 2
This is code-golf, so fewest bytes wins!
/
for our division operator (e.g. our language's natural one)? \$\endgroup\$