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
afebddcb
Commit
afebddcb
authored
5 years ago
by
Stoop
Browse files
Options
Downloads
Patches
Plain Diff
Commit_esmee
parent
50ca0b08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dec-1.ipynb
+147
-0
147 additions, 0 deletions
dec-1.ipynb
with
147 additions
and
0 deletions
dec-1.ipynb
0 → 100644
+
147
−
0
View file @
afebddcb
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np \n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# part 1"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# read in text file\n",
"mass = np.loadtxt('dec-1-file.txt')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"total = 0\n",
"for m in mass:\n",
" total = total + int(m/3.0) - 2.0"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3210097.0"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"total"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# part 2"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"total = 0\n",
"\n",
"for m in mass:\n",
" \n",
" fuel_tot = int(m /3.0) - 2 \n",
" fuel = fuel_tot\n",
"\n",
" while fuel != 0:\n",
"\n",
" fuel = int(fuel/3.0) - 2\n",
" if fuel < 0:\n",
" break\n",
" else:\n",
" fuel_tot = fuel_tot + fuel\n",
" total = total + fuel_tot"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4812287"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"total"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:code id: tags:
```
python
import
numpy
as
np
import
pandas
as
pd
```
%% Cell type:markdown id: tags:
# part 1
%% Cell type:code id: tags:
```
python
# read in text file
mass
=
np
.
loadtxt
(
'
dec-1-file.txt
'
)
```
%% Cell type:code id: tags:
```
python
total
=
0
for
m
in
mass
:
total
=
total
+
int
(
m
/
3.0
)
-
2.0
```
%% Cell type:code id: tags:
```
python
total
```
%% Output
3210097.0
%% Cell type:markdown id: tags:
# part 2
%% Cell type:code id: tags:
```
python
total
=
0
for
m
in
mass
:
fuel_tot
=
int
(
m
/
3.0
)
-
2
fuel
=
fuel_tot
while
fuel
!=
0
:
fuel
=
int
(
fuel
/
3.0
)
-
2
if
fuel
<
0
:
break
else
:
fuel_tot
=
fuel_tot
+
fuel
total
=
total
+
fuel_tot
```
%% Cell type:code id: tags:
```
python
total
```
%% Output
4812287
%% Cell type:code id: tags:
```
python
``
`
%%
Cell
type
:
code
id
:
tags
:
```
python
```
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