Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
0
01-dec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Advent Of Code
01-dec
Commits
70d1b5d7
Commit
70d1b5d7
authored
5 years ago
by
de Hond
Browse files
Options
Downloads
Plain Diff
Merge branch 'patch-5' into 'master'
Upload New File See merge request
!4
parents
f373a70b
29c45909
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Upload New File
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
day1.py
+28
-0
28 additions, 0 deletions
day1.py
with
28 additions
and
0 deletions
day1.py
0 → 100644
+
28
−
0
View file @
70d1b5d7
import
pandas
as
pd
import
numpy
as
np
import
math
# First exercise
def
fuel_func
(
modules
):
fuel
=
[]
for
module
in
modules
:
fuel
.
append
(
math
.
floor
(
module
/
3
)
-
2
)
return
fuel
modules
=
pd
.
read_csv
(
"
day1.csv
"
,
sep
=
"
;
"
,
header
=
None
)
modules
=
np
.
array
(
modules
)
print
(
"
answer1 is
"
,
sum
(
fuel_func
(
modules
)))
# Second exercise
def
fuel_func2
(
fuel
,
sum_fuel
=
0
):
if
(
math
.
floor
(
fuel
/
3
)
-
2
)
>
0
:
new_fuel
=
(
math
.
floor
(
fuel
/
3
)
-
2
)
sum_fuel
=
sum_fuel
+
new_fuel
sum_fuel
=
fuel_func2
(
new_fuel
,
sum_fuel
)
return
sum_fuel
total_fuel
=
0
for
module
in
modules
:
total_fuel
+=
fuel_func2
(
module
)
print
(
"
answer2 is
"
,
total_fuel
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment