-
Notifications
You must be signed in to change notification settings - Fork 26
/
puddle.html
50 lines (35 loc) · 2.38 KB
/
puddle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<title>Puzzle: Twitter Puddle</title>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<p class="subtle"><a href="/">« Boston Python puzzles</a></p>
<h1>Twitter Puddle</h1>
<p>[We found this puzzle here: <a href="http://programmingpraxis.com/2013/11/15/twitter-puddle/">Twitter Puddle on programmingpraxis</a>]</p>
<p>Consider the following picture:</p>
<img src="puddle1.jpg"/>
<p>In this picture we have walls of different heights. This picture is
represented by an array of integers, where the value at each index is the
height of the wall. The picture above is represented with an array as
[2,5,1,2,3,4,7,7,6].</p>
<p>Now imagine it rains. How much water is going to be accumulated in puddles
between walls?</p>
<img src="puddle2.jpg"/>
<p>We count volume in square blocks of 1×1. So in the picture above, everything
to the left of index 1 spills out. Water to the right of index 7 also spills
out. We are left with a puddle between 1 and 6 and the volume is 10.</p>
<p>Your task is to write a program to compute the volume of water in the
puddle; you should strive for an algorithm that completes the task in a single
pass.</p>
<h2>Solutions</h2>
<ul>
<li>Brett Smith's solution is <a href="https://github.com/BostonPython/puzzles/blob/gh-pages/solutions/brettcs/puddles.py">puddles.py</a></li>
<li>Edward Stronge's solution is <a href="https://github.com/ejstronge/twitter_puddle/blob/master/twitter_puddle.py">twitter_puddle.py</a></li>
<li>Ned Batchelder's solutions are <a href="https://github.com/BostonPython/puzzles/blob/gh-pages/solutions/nedbat/puddle.py">puddle.py</a></li>
<li>Andrew Ross's solutions are <a href="https://github.com/BostonPython/puzzles/blob/gh-pages/solutions/asross/twitter_puddle.py">twitter_puddle.py</a></li>
<li>Steve Witham's solutions are <a href="http://nbviewer.ipython.org/github/switham/puzzles/blob/gh-pages/solutions/switham/twitter_puddle.ipynb">twitter_puddle.ipynb</a></li>
<li>Ankur Aggarwal's solution is <a href="http://github.com/BostonPython/puzzles/blob/gh-pages/solutions/ankur2106/TwitterPuddle.py">TwitterPuddle.py</a></li>
<li>Will Sutton's solution is <a href="http://github.com/BostonPython/puzzles/blob/gh-pages/solutions/sutt/twitterpuddle.ipynb">twitterpuddle.ipynb</a></li>
</ul>
<p>If you have a solution you'd like to share see the <a href="solutions.html">Solutions page</a> for instructions.</p>