Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Other product solution in Clear category for Three Views by amandel
from itertools import product
def three_views(front_view: str, right_view: str, top_view: str) -> int:
le = lambda x,y: chr(5*x+y+ord('A'))
return sum(le(x,y) in front_view and le(x,z) in right_view and le(4-z,y) in top_view \
for x,y,z in product(range(5), repeat=3))
print("Example:")
print(three_views("BCDGHILMNQRSVWX", "CHMRW", "LMN"))
# These "asserts" are used for self-checking
assert three_views("BCDGHILMNQRSVWX", "CHMRW", "LMN") == 15
assert three_views("GHILMNQRS", "GHILMNQRS", "GHILMNQRS") == 27
assert three_views("GIMQS", "GIMQS", "GIMQS") == 9
assert (
three_views("AFGKLMPQRSUVWXY", "AFGKLMPQRSUVWXY", "ABCDEFGHIJKLMNOPQRSTUVWXY") == 55
)
print("The mission is done! Click 'Check Solution' to earn rewards!")
May 31, 2024