Weekly Challenge 293
Each week Mohammad S. Anwar sends out , .
For this task, I take integers from the command line and convert them to a list of lists (arrays of arrays in Perl). If this was an actual real-world project, I'd probably use a . Sets don't store duplicate values.
False. If there is more than one value, then it's a boomerang. I'm not here to determine if it is a good boomerang :)def is_boomerang(points: list) -> bool:
if all(points[0][1] == points[i][1] for i in range(1, len(points))):
return False
if any(points[0][1] == points[i][1] for i in range(1, len(points))):
return True
degrees = set(abs((points[0][0] - points[i][0]) / (points[0][1] - points[i][1])) for i in range(1, len(points)))
return False if len(degrees) == 1 else True
Examples
$ ./ch-2.py 1 1 2 3 3 2
true
$ ./ch-2.py 1 1 2 2 3 3
false
$ ./ch-2.py 1 1 1 2 2 3
true
$ ./ch-2.py 1 1 1 2 1 3
false
$ ./ch-2.py 1 1 2 1 3 1
false
$ ./ch-2.py 0 0 2 3 4 5
true
SOCIAL SHARE CARD GENERATOR