@extends('template') @section('title') Lab 12 @stop @section('content') # Lab 12, Part 2: Gentle Starter Problem ## Checking the Turtle's ink supply (recursion and counting) Imagine your Turtle had a limited supply of ink, and it should keep drawing a given pattern *until* it runs out of ink. For example, let's say we want to draw a stair pattern and we want to draw `x` “stairs” before the “ink runs our ” ```py def drawStairs(w, ink): dashes = 0 # Calculate ink used to draw rectangle inkNeeded = 2*h + 2*w # Do not have enough ink to draw another one if ink < inkNeeded: return dashes else: # Draw single stair fd(w) pu() fd(w * .1) pd() # Count the 1 drawn rect and recurse to draw the rest of rects dashes = 1 + drawDashes(w, h, ink - inkNeeded) # How many rectangles were drawn return dashes ``` ## Write the output of these invocations of `test`: 1. ### `drawDashes(25, 30, 100)`     2. ### `drawDashes(25, 15, 100)`     3. ###`drawDashes(5, 10, 100)` ## View the `test` invocation solutions

Type password (given in lab) to see the solution.

@include('/labs/lab12/_toc') @stop