2024 S2 - Heavy-Light Composition

Easyimplementation

1 Solution Available

Solution 1

PYTHON
1# By William Yang, Milliken Mills High School
2
3string_list = [int(a) for a in input().split()]
4output_list = ["F"]*int(string_list[0])
5for string_num in range(int(string_list[0])):
6    test_string = list(input())
7    heavy_light_tracker = 0
8    for string_letter in test_string:
9        # "H" = heavy, "L" = light
10        # heavy string
11        if test_string.count(string_letter) > 1:
12            if heavy_light_tracker == "H":
13                heavy_light_tracker = 0
14                break
15            heavy_light_tracker = "H"
16        # light string
17        else:
18            if heavy_light_tracker == "L":
19                heavy_light_tracker = 0
20                break
21            heavy_light_tracker = "L"
22    if heavy_light_tracker != 0:
23        output_list[string_num] = "T"
24
25for item in output_list:
26    print(item)

Test Cases

Select a test case to view input and output