+ import std.math; import std.typecons; - import std.math; /* You are given two intervals, - where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). ? ---- + where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). - The given intervals are closed which means that the interval (start, end) ? ---- + The given intervals are closed which means that the interval (start, end) - includes both start and end. ? ---- + includes both start and end. - For each given interval, it is assumed that its start is less or equal its end. ? ---- + For each given interval, it is assumed that its start is less or equal its end. - Your task is to determine whether the length of intersection of these two ? ---- + Your task is to determine whether the length of intersection of these two - intervals is a prime number. ? ---- + intervals is a prime number. - Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3) ? ---- + Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3) - which its length is 1, which not a prime number. ? ---- + which its length is 1, which not a prime number. - If the length of the intersection is a prime number, return "YES", ? ---- + If the length of the intersection is a prime number, return "YES", - otherwise, return "NO". ? ---- + otherwise, return "NO". - If the two intervals don't intersect, return "NO". ? ---- + If the two intervals don't intersect, return "NO". - - - [input/output] samples: ? ---- + [input/output] samples: - >>> intersection(tuple(1L, 2L), tuple(2L, 3L)) ? ---- + >>> intersection(tuple(1L, 2L), tuple(2L, 3L)) - "NO" + "NO" - >>> intersection(tuple(-1L, 1L), tuple(0L, 4L)) ? ---- + >>> intersection(tuple(-1L, 1L), tuple(0L, 4L)) - "NO" + "NO" - >>> intersection(tuple(-3L, -1L), tuple(-5L, 5L)) ? ---- + >>> intersection(tuple(-3L, -1L), tuple(-5L, 5L)) + "YES" - "YES" - */ string intersection(Tuple!(long, long) interval1, Tuple!(long, long) interval2)