1
0
Fork 0

Day 1: Replaced comment box with block comment.

This commit is contained in:
Jonathan Chan 2019-11-30 21:43:52 -08:00
parent 0bcab1f340
commit a14466c2c2
1 changed files with 47 additions and 712 deletions

View File

@ -1,716 +1,51 @@
#reader(lib"read.ss""wxme")WXME0108 ##
#lang racket
(require "../lib.rkt")
#|
This file uses the GRacket editor format.
Open this file in DrRacket version 7.0 or later to read it.
DAY 1: The Tyranny of the Rocket Equation (excerpt)
Most likely, it was created by saving a program in DrRacket,
and it probably contains a program with non-text elements
(such as images or comment boxes).
PART 1:
...
Fuel required to launch a given module is based on its mass.
Specifically, to find the fuel required for a module, take its mass,
divide by three, round down, and subtract 2.
...
What is the sum of the fuel requirements for all of the modules
on your spacecraft?
http://racket-lang.org/
PART 2:
...
So, for each module mass, calculate its fuel and add it to the total.
Then, treat the fuel amount you just calculated as the input mass
and repeat the process, continuing until a fuel requirement is zero
or negative.
...
What is the sum of the fuel requirements for all of the modules
on your spacecraft when also taking into account the mass of the
added fuel?
|#
33 7 #"wxtext\0"
3 1 6 #"wxtab\0"
1 1 8 #"wximage\0"
2 0 8 #"wxmedia\0"
4 1 34 #"(lib \"syntax-browser.ss\" \"mrlib\")\0"
1 0 36 #"(lib \"cache-image-snip.ss\" \"mrlib\")\0"
1 0 68
(
#"((lib \"image-core.ss\" \"mrlib\") (lib \"image-core-wxme.rkt\" \"mr"
#"lib\"))\0"
) 1 0 16 #"drscheme:number\0"
3 0 44 #"(lib \"number-snip.ss\" \"drscheme\" \"private\")\0"
1 0 36 #"(lib \"comment-snip.ss\" \"framework\")\0"
1 0 93
(
#"((lib \"collapsed-snipclass.ss\" \"framework\") (lib \"collapsed-sni"
#"pclass-wxme.ss\" \"framework\"))\0"
) 0 0 43 #"(lib \"collapsed-snipclass.ss\" \"framework\")\0"
0 0 19 #"drscheme:sexp-snip\0"
0 0 29 #"drscheme:bindings-snipclass%\0"
1 0 101
(
#"((lib \"ellipsis-snip.rkt\" \"drracket\" \"private\") (lib \"ellipsi"
#"s-snip-wxme.rkt\" \"drracket\" \"private\"))\0"
) 2 0 88
(
#"((lib \"pict-snip.rkt\" \"drracket\" \"private\") (lib \"pict-snip.r"
#"kt\" \"drracket\" \"private\"))\0"
) 0 0 55
#"((lib \"snip.rkt\" \"pict\") (lib \"snip-wxme.rkt\" \"pict\"))\0"
1 0 34 #"(lib \"bullet-snip.rkt\" \"browser\")\0"
0 0 25 #"(lib \"matrix.ss\" \"htdp\")\0"
1 0 22 #"drscheme:lambda-snip%\0"
1 0 29 #"drclickable-string-snipclass\0"
0 0 26 #"drracket:spacer-snipclass\0"
0 0 57
#"(lib \"hrule-snip.rkt\" \"macro-debugger\" \"syntax-browser\")\0"
1 0 26 #"drscheme:pict-value-snip%\0"
0 0 45 #"(lib \"image-snipr.ss\" \"slideshow\" \"private\")\0"
1 0 38 #"(lib \"pict-snipclass.ss\" \"slideshow\")\0"
2 0 55 #"(lib \"vertical-separator-snip.ss\" \"stepper\" \"private\")\0"
1 0 18 #"drscheme:xml-snip\0"
1 0 31 #"(lib \"xml-snipclass.ss\" \"xml\")\0"
1 0 21 #"drscheme:scheme-snip\0"
2 0 34 #"(lib \"scheme-snipclass.ss\" \"xml\")\0"
1 0 10 #"text-box%\0"
1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0"
1 0 1 6 #"wxloc\0"
0 0 81 0 1 #"\0"
0 75 1 #"\0"
0 10 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9
#"Standard\0"
0 75 12 #"Courier New\0"
0 10 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24
#"framework:default-color\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 15
#"text:ports out\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1
-1 2 15 #"text:ports err\0"
0 -1 1 #"\0"
1 0 -1 -1 93 -1 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 17
#"text:ports value\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1
-1 2 27 #"Matching Parenthesis Style\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1
-1 2 1 #"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 37
#"framework:syntax-color:scheme:symbol\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 38
#"framework:syntax-color:scheme:keyword\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 194 116 31 0 0 0 -1 -1 2
38 #"framework:syntax-color:scheme:comment\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 194 116 31 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 37
#"framework:syntax-color:scheme:string\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 35
#"framework:syntax-color:scheme:text\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 39
#"framework:syntax-color:scheme:constant\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 49
#"framework:syntax-color:scheme:hash-colon-keyword\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 42
#"framework:syntax-color:scheme:parenthesis\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36
#"framework:syntax-color:scheme:error\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 36
#"framework:syntax-color:scheme:other\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 16
#"Misspelled Text\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2
38 #"drracket:check-syntax:lexically-bound\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 28
#"drracket:check-syntax:set!d\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 37
#"drracket:check-syntax:unused-require\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36
#"drracket:check-syntax:free-variable\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 31
#"drracket:check-syntax:imported\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 47
#"drracket:check-syntax:my-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 50
#"drracket:check-syntax:their-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 48
#"drracket:check-syntax:unk-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2
49 #"drracket:check-syntax:both-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2
26 #"plt:htdp:test-coverage-on\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 2 27
#"plt:htdp:test-coverage-off\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 4 1
#"\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 4 #"XML\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 37 #"plt:module-language:test-coverage-on\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 38
#"plt:module-language:test-coverage-off\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 4 1
#"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 0 255 0 0 0 -1
-1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 0 255 0 0 0 -1
-1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 100 0 0 0 0 -1
-1 2 1 #"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1 4 32
#"widget.rkt::browser-text% basic\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 59
#"macro-debugger/syntax-browser/properties color-text% basic\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 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 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"require"
0 0 24 3 1 #" "
0 0 19 3 12 #"\"../lib.rkt\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 1651 21 0 0 0 274 0 14 3 3 #"DAY"
0 0 24 3 1 #" "
0 0 14 3 2 #"1:"
0 0 24 3 1 #" "
0 0 14 3 3 #"The"
0 0 24 3 1 #" "
0 0 14 3 7 #"Tyranny"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 6 #"Rocket"
0 0 24 3 1 #" "
0 0 14 3 8 #"Equation"
0 0 24 3 2 #" ("
0 0 14 3 7 #"excerpt"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"PART"
0 0 24 3 1 #" "
0 0 14 3 2 #"1:"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"..."
0 0 24 29 1 #"\n"
0 0 14 3 4 #"Fuel"
0 0 24 3 1 #" "
0 0 14 3 8 #"required"
0 0 24 3 1 #" "
0 0 14 3 2 #"to"
0 0 24 3 1 #" "
0 0 14 3 6 #"launch"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 5 #"given"
0 0 24 3 1 #" "
0 0 15 3 6 #"module"
0 0 24 3 1 #" "
0 0 14 3 2 #"is"
0 0 24 3 1 #" "
0 0 14 3 5 #"based"
0 0 24 3 1 #" "
0 0 14 3 2 #"on"
0 0 24 3 1 #" "
0 0 14 3 3 #"its"
0 0 24 3 1 #" "
0 0 14 3 5 #"mass."
0 0 24 29 1 #"\n"
0 0 14 3 12 #"Specifically"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 2 #"to"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 8 #"required"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 15 3 6 #"module"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 4 #"take"
0 0 24 3 1 #" "
0 0 14 3 3 #"its"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 28 3 1 #","
0 0 24 29 1 #"\n"
0 0 14 3 6 #"divide"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 5 #"three"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 5 #"round"
0 0 24 3 1 #" "
0 0 14 3 4 #"down"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtract"
0 0 24 3 1 #" "
0 0 21 3 2 #"2."
0 0 24 29 1 #"\n"
0 0 14 3 3 #"..."
0 0 24 29 1 #"\n"
0 0 14 3 4 #"What"
0 0 24 3 1 #" "
0 0 14 3 2 #"is"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 3 #"sum"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 12 #"requirements"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 7 #"modules"
0 0 24 29 1 #"\n"
0 0 14 3 2 #"on"
0 0 24 3 1 #" "
0 0 14 3 4 #"your"
0 0 24 3 1 #" "
0 0 14 3 11 #"spacecraft?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"PART"
0 0 24 3 1 #" "
0 0 14 3 2 #"2:"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"..."
0 0 24 29 1 #"\n"
0 0 14 3 2 #"So"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"each"
0 0 24 3 1 #" "
0 0 15 3 6 #"module"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 9 #"calculate"
0 0 24 3 1 #" "
0 0 14 3 3 #"its"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 3 #"add"
0 0 24 3 1 #" "
0 0 14 3 2 #"it"
0 0 24 3 1 #" "
0 0 14 3 2 #"to"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 6 #"total."
0 0 24 29 1 #"\n"
0 0 14 3 4 #"Then"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 5 #"treat"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 6 #"amount"
0 0 24 3 1 #" "
0 0 14 3 3 #"you"
0 0 24 3 1 #" "
0 0 14 3 4 #"just"
0 0 24 3 1 #" "
0 0 14 3 10 #"calculated"
0 0 24 3 1 #" "
0 0 14 3 2 #"as"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 5 #"input"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 6 #"repeat"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 7 #"process"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 10 #"continuing"
0 0 24 3 1 #" "
0 0 14 3 5 #"until"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 11 #"requirement"
0 0 24 3 1 #" "
0 0 14 3 2 #"is"
0 0 24 3 1 #" "
0 0 14 3 4 #"zero"
0 0 24 29 1 #"\n"
0 0 14 3 2 #"or"
0 0 24 3 1 #" "
0 0 14 3 9 #"negative."
0 0 24 29 1 #"\n"
0 0 14 3 3 #"..."
0 0 24 29 1 #"\n"
0 0 14 3 4 #"What"
0 0 24 3 1 #" "
0 0 14 3 2 #"is"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 3 #"sum"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 14 3 12 #"requirements"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 7 #"modules"
0 0 24 29 1 #"\n"
0 0 14 3 2 #"on"
0 0 24 3 1 #" "
0 0 14 3 4 #"your"
0 0 24 3 1 #" "
0 0 14 3 10 #"spacecraft"
0 0 24 3 1 #" "
0 0 15 3 4 #"when"
0 0 24 3 1 #" "
0 0 14 3 4 #"also"
0 0 24 3 1 #" "
0 0 14 3 6 #"taking"
0 0 24 3 1 #" "
0 0 14 3 4 #"into"
0 0 24 3 1 #" "
0 0 14 3 7 #"account"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"added"
0 0 24 3 1 #" "
0 0 14 3 5 #"fuel?"
0 0 24 3 1 #" "
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 5 #"input"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 14 #"string->number"
0 0 24 3 2 #" ("
0 0 14 3 13 #"problem-input"
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 31 #";; calc-fuel : number -> number"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 9 #"calc-fuel"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 1 #"-"
0 0 24 3 2 #" ("
0 0 14 3 5 #"floor"
0 0 24 3 2 #" ("
0 0 14 3 1 #"/"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 3 1 #" "
0 0 21 3 1 #"3"
0 0 24 3 3 #")) "
0 0 21 3 1 #"2"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 5 #"part1"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 3 #"sum"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 9 #"calc-fuel"
0 0 24 3 1 #" "
0 0 14 3 5 #"input"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 35 #";; calc-fuel-rec : number -> number"
0 0 24 29 1 #"\n"
0 0 17 3 35 #";; Calculate the fuel given a mass,"
0 0 24 29 1 #"\n"
0 0 17 3 44 #";; then add the fuel required for THAT fuel,"
0 0 24 29 1 #"\n"
0 0 17 3 54 #";; and so on until the fuel required is 0 or negative,"
0 0 24 29 1 #"\n"
0 0 17 3 39 #";; for which the fuel should just be 0."
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 13 #"calc-fuel-rec"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 3 #"let"
0 0 24 3 3 #" (["
0 0 14 3 4 #"fuel"
0 0 24 3 2 #" ("
0 0 14 3 9 #"calc-fuel"
0 0 24 3 1 #" "
0 0 14 3 4 #"mass"
0 0 24 3 3 #")])"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 2 #"if"
0 0 24 3 2 #" ("
0 0 14 3 2 #"<="
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 1 #" "
0 0 21 3 1 #"0"
0 0 24 3 2 #") "
0 0 21 3 1 #"0"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" ("
0 0 14 3 1 #"+"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 2 #" ("
0 0 14 3 13 #"calc-fuel-rec"
0 0 24 3 1 #" "
0 0 14 3 4 #"fuel"
0 0 24 3 5 #")))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 5 #"part2"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 3 #"sum"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 13 #"calc-fuel-rec"
0 0 24 3 1 #" "
0 0 14 3 5 #"input"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 13 #"show-solution"
0 0 24 3 1 #" "
0 0 14 3 5 #"part1"
0 0 24 3 1 #" "
0 0 14 3 5 #"part2"
0 0 24 3 1 #")"
0 0
(define input (map string->number (problem-input 1)))
;; calc-fuel : number -> number
(define (calc-fuel mass)
(- (floor (/ mass 3)) 2))
(define part1
(sum (map calc-fuel input)))
;; calc-fuel-rec : number -> number
;; Calculate the fuel given a mass,
;; then add the fuel required for THAT fuel,
;; and so on until the fuel required is 0 or negative,
;; for which the fuel should just be 0.
(define (calc-fuel-rec mass)
(let ([fuel (calc-fuel mass)])
(if (<= fuel 0) 0
(+ fuel (calc-fuel-rec fuel)))))
(define part2
(sum (map calc-fuel-rec input)))
(show-solution part1 part2)