Skip to content
Snippets Groups Projects
Commit afebddcb authored by Stoop's avatar Stoop
Browse files

Commit_esmee

parent 50ca0b08
No related branches found
No related tags found
No related merge requests found
%% 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
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment