Skip to content

Nathan's Solution Branch Pull Request #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
101 changes: 101 additions & 0 deletions list_of_presents.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Box Dimensions
2x1x5
4x4x3
2x9x2
10x7x1
1x2x4
4x9x10
1x9x4
9x7x4
8x10x5
1x3x7
6x5x3
4x6x2
2x7x2
6x6x10
5x1x8
9x2x7
2x9x5
10x6x10
4x2x1
4x5x2
4x2x7
5x8x6
3x6x6
4x5x2
10x3x9
4x3x8
7x5x9
4x6x1
4x1x6
7x5x2
4x10x6
4x8x7
8x3x5
3x4x9
9x5x10
7x10x7
6x4x3
9x8x2
1x2x3
3x7x10
2x7x7
10x8x9
5x9x1
2x9x5
6x2x5
7x3x8
1x5x9
3x9x2
5x9x10
4x3x6
3x9x9
1x10x6
8x1x2
6x5x4
1x4x10
2x2x8
2x9x3
3x8x9
3x5x9
10x7x4
9x4x5
7x6x8
9x8x2
4x4x2
6x1x10
9x4x10
4x1x2
1x4x2
1x6x2
9x4x5
8x4x9
3x10x10
8x4x8
7x4x2
2x7x6
7x7x8
1x2x1
7x6x2
4x4x4
9x8x3
7x3x5
8x4x2
8x9x2
1x9x1
2x4x3
7x8x8
4x7x1
3x7x1
7x5x8
5x7x9
8x3x4
5x4x1
10x9x1
6x1x1
10x8x9
9x3x1
9x2x3
2x10x2
4x7x2
10x4x10
39 changes: 39 additions & 0 deletions solution_n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pandas as pd

def solution(input_data):
df = pd.read_csv(input_data)
list_of_presents = df['Box Dimensions'].to_list()
del df

full_list = []
combined_wrapping_paper_total = 0
combined_ribbon_total = 0

for present in list_of_presents:
# Split and get Int values for each boxes dimensions
dimensions = list(map(int, present.split('x')))
# Sort Dimensions so that smallest measures are always in positions 0 and 1
dimensions.sort(reverse=False)
# Get all individual dimension calculations
smallest_dimension = dimensions[0]*dimensions[1]
second_dimension = dimensions[0]*dimensions[2]
third_dimension = dimensions[2]*dimensions[1]
# Get Box Volume
box_volume = dimensions[0]*dimensions[1]*dimensions[2]
# Calculate Wrapping Paper Required for Box
wrapping_paper_total = (2*(smallest_dimension+second_dimension+third_dimension))+smallest_dimension
# Add to Wrapping Paper Catch-All Calculation
combined_wrapping_paper_total+= wrapping_paper_total
# Calculate Ribbon Needed for Box
ribbon_total = 2*(dimensions[0]+dimensions[1])+box_volume
# Add to Ribbon Catch-All Calculation
combined_ribbon_total += ribbon_total
#Append all Results to full list
full_list.append([dimensions, wrapping_paper_total, ribbon_total])

print(f'Calculated Wrapping Paper Total: {combined_wrapping_paper_total}')
print(f'Calculated Ribbon Total: {combined_ribbon_total}')


if __name__ == "__main__":
solution("list_of_presents.csv")