X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=01-ticket-prices%2Fticket-pricing-solution.ipynb;h=8ba20442b6dae95c16ff439de4d42a0c242d26c1;hb=cda3607a2ba45038b53399b0ca3ef8fe5ad2e049;hp=138088793b3fa3c59a00142ea2ba4cd9518d688e;hpb=3afec0b916cae5ebd717b3d15c71ff9205e144f1;p=ou-summer-of-code-2017.git diff --git a/01-ticket-prices/ticket-pricing-solution.ipynb b/01-ticket-prices/ticket-pricing-solution.ipynb index 1380887..8ba2044 100644 --- a/01-ticket-prices/ticket-pricing-solution.ipynb +++ b/01-ticket-prices/ticket-pricing-solution.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -61,7 +61,7 @@ " ['b261dbd1cef', '996', 'Holmegaard', '21']]" ] }, - "execution_count": 12, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -69,12 +69,36 @@ "source": [ "holidays = []\n", "with open('01-holidays.txt') as f:\n", - " for hol_line in f.readlines():\n", + " for hol_line in f:\n", " holidays.append(hol_line.split())\n", " \n", "holidays[:3]" ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[['dda7d369', '1546', 'Uzupis', '21'],\n", + " ['68022753', '1239', 'Mamula', '21'],\n", + " ['b261dbd1cef', '996', 'Holmegaard', '21']]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "holidays = [line.split() for line in open('01-holidays.txt')]\n", + " \n", + "holidays[:3]" + ] + }, { "cell_type": "code", "execution_count": 13, @@ -100,6 +124,27 @@ "len(affordable_holidays)" ] }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "59" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "affordable_holidays = [h for h in holidays if int(h[1]) <= 1200]\n", + "len(affordable_holidays)" + ] + }, { "cell_type": "code", "execution_count": 14, @@ -129,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -138,13 +183,13 @@ "59" ] }, - "execution_count": 15, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "sum(1 for h in open('01-holidays.txt').readlines() if int(h.split()[1]) <= 1200)" + "sum(1 for h in open('01-holidays.txt') if int(h.split()[1]) <= 1200)" ] }, {