-
Notifications
You must be signed in to change notification settings - Fork 4
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
NPinn
wants to merge
12
commits into
antsh3k:main
Choose a base branch
from
NPinn:solution_n
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
99c72ac
Commiting Jupyter Notebook file
NPinn 87c9371
Delete .ipynb_checkpoints directory
NPinn 473f8d1
Delete wrapping_calculations.ipynb
NPinn 2f751aa
Commiting Solution.py
NPinn 74ac977
Delete list_of_presents.csv
NPinn 5523484
Delete solution_n.py
NPinn cc2d7ea
Delete .ipynb_checkpoints directory
NPinn 36ca7ab
Commiting solution_n.py File
NPinn 9d31eed
Updating solution code to properly calculate the length of ribbon req…
NPinn 700b0b3
Removing line that prints list of all results, solution_n.py code now…
NPinn 15d012e
Fixing spelling mistake of list variable from list_of_presenets to li…
NPinn 15ce2f0
Commit CSV list of presents file to soluion branch
NPinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_presenets = df['Box Dimensions'].to_list() | ||
| del df | ||
|
|
||
| full_list = [] | ||
| combined_wrapping_paper_total = 0 | ||
| combined_ribbon_total = 0 | ||
|
|
||
| for present in list_of_presenets: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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") | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list_of_presents