1+ # Calculate paint coverage and can box amounts.
2+
3+ # import packages
4+ import math
5+
6+ # params
7+ fl_coverage = 5.1 # m2 of wall
8+ # I'm using a dictionary as an array of dimensions, I mused on a list or a tuple too, but went for dict for clarity
9+ t_can_dims = { "Diameter" : 15 , "Height" : 30 } # cm
10+ t_box_dims = { "Length" : 0.60 , "Width" : 0.30 , "Height" : 0.35 } # meters (I assume).
11+ t_hall_dims = { "Length" : 40 , "Width" : 30 , "Height" : 3.4 } # meters
12+
13+ # ASSUMPTIONS
14+ # The hall has no doors
15+ # The hall has no windows
16+ # The floor and ceiling aren't being painted
17+
18+ # Calculate amount of paint required
19+ # ( 2 x length + 2 x width ) * height
20+ int_hall_wall_area = ( (( t_hall_dims ["Length" ] * 2 ) + (t_hall_dims ["Width" ] * 2 )) * t_hall_dims ["Height" ] )
21+ int_cans_required = math .ceil ( int_hall_wall_area / fl_coverage )
22+ t_cans_per_box = { "ByLength" : math .floor ( t_box_dims ["Length" ] / ( t_can_dims ["Diameter" ] / 100 ) ),
23+ "ByWidth" : math .floor ( t_box_dims ["Width" ] / ( t_can_dims ["Diameter" ] / 100 ) ),
24+ "ByHeight" : math .floor ( t_box_dims ["Height" ] / ( t_can_dims ["Height" ] / 100 ) )
25+ }
26+ int_cans_per_box = t_cans_per_box ["ByWidth" ] * t_cans_per_box ["ByLength" ] * t_cans_per_box ["ByHeight" ]
27+ int_full_boxes = math .floor ( int_cans_required / int_cans_per_box )
28+ int_loose_cans = int_cans_required % int_cans_per_box
29+
30+ print ( 'Welcome to the Shaggy Dog Paint calculator' )
31+ print ( '-' * 42 )
32+ print ( f'Using paint cans with diameter { t_can_dims ["Diameter" ]} cm and height { t_can_dims ["Height" ]} cm providing coverage of { fl_coverage } m2.' )
33+ print ( f'Painting a hall with length { t_hall_dims ["Length" ]} m, width { t_hall_dims ["Width" ]} m and height { t_hall_dims ["Height" ]} m.' )
34+ print ( f'This will require { int_cans_required } cans of paint.' )
35+ print ( f'Supplying { int_cans_per_box } cans per box this will require { int_full_boxes } boxes and { int_loose_cans } loose cans.' )
0 commit comments