t | def input_handling(): | t | def input_handling(): |
| a = "a's not empty" | | a = "a's not empty" |
| data = [1, 1, 1, 1, 1] | | data = [1, 1, 1, 1, 1] |
| wall_y = -1 | | wall_y = -1 |
| wall_x = 0 | | wall_x = 0 |
| water_y = 0 | | water_y = 0 |
| glass_y = 0 | | glass_y = 0 |
| while True: | | while True: |
| if a != "": | | if a != "": |
| wall_x = len(a) | | wall_x = len(a) |
| a = input() | | a = input() |
| if "#" in a: | | if "#" in a: |
| glass_y += 1 | | glass_y += 1 |
| if "*" in a: | | if "*" in a: |
| water_y += 1 | | water_y += 1 |
| if "###" in a: | | if "###" in a: |
| glass_x = a.count('#') | | glass_x = a.count('#') |
| | | |
| else: | | else: |
| break | | break |
| wall_y += 1 | | wall_y += 1 |
| | | |
| data = [wall_x, wall_y, glass_y, glass_x, water_y] | | data = [wall_x, wall_y, glass_y, glass_x, water_y] |
| return data | | return data |
| | | |
| | | |
| def handle_falling(wall_x, glass_x, water_y): | | def handle_falling(wall_x, glass_x, water_y): |
| water_level = (glass_x - 2)*water_y | | water_level = (glass_x - 2)*water_y |
| water_heigth = water_level//wall_x | | water_heigth = water_level//wall_x |
| if (water_level/wall_x) != (water_level//wall_x): | | if (water_level/wall_x) != (water_level//wall_x): |
| water_heigth += 1 | | water_heigth += 1 |
| return water_heigth | | return water_heigth |
| | | |
| | | |
| def fallen_glass_draw(wall_x, wall_y, glass_x, glass_y, water_y): | | def fallen_glass_draw(wall_x, wall_y, glass_x, glass_y, water_y): |
| water_heigth = handle_falling(wall_x, glass_y, water_y) | | water_heigth = handle_falling(wall_x, glass_y, water_y) |
| wall_with_water_y = wall_y-water_heigth | | wall_with_water_y = wall_y-water_heigth |
| for i in range(0, wall_with_water_y): | | for i in range(0, wall_with_water_y): |
| if i < (wall_y-glass_y): | | if i < (wall_y-glass_y): |
| dot = "." | | dot = "." |
| else: | | else: |
| dot = "#" | | dot = "#" |
| for j in range(1, wall_x): | | for j in range(1, wall_x): |
| if (i == (wall_y - glass_y) or (water_heigth == | | if (i == (wall_y - glass_y) or (water_heigth == |
| 0 and i == wall_y-1)) and j < glass_x: | | 0 and i == wall_y-1)) and j < glass_x: |
| dot += "#" | | dot += "#" |
| else: | | else: |
| dot += "." | | dot += "." |
| print(dot) | | print(dot) |
| | | |
| for i in range(0, water_heigth): | | for i in range(0, water_heigth): |
| star = "*" | | star = "*" |
| for j in range(1, wall_x): | | for j in range(1, wall_x): |
| star += "*" | | star += "*" |
| print(star) | | print(star) |
| return | | return |
| | | |
| | | |
| data = input_handling() | | data = input_handling() |
| fallen_glass_draw(data[0], data[1], data[2], data[3], data[4]) | | fallen_glass_draw(data[0], data[1], data[2], data[3], data[4]) |
| | | |