+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def running(sequence):\n",
+ " current = 0\n",
+ " floors = []\n",
+ " for i in sequence:\n",
+ " current += value(i)\n",
+ " floors += [current]\n",
+ " return floors"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(10002, 216, -6)"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "with open('02-lifts.txt') as f:\n",
+ " instructions = f.read()\n",
+ " floors = running(instructions)\n",
+ "len(floors), max(floors), min(floors)"
+ ]
+ },