+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[['a68d97fbfdb', '987', 'Brorfelde', '451'],\n",
+ " ['627824317b47', '909', 'Giessenmestia', '532'],\n",
+ " ['be8b9d110', '984', 'Tubakuba', '485']]"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Answer if you always deduct £500\n",
+ "sorted(holidays, key=lambda h: int(h[1]) + int(h[3]) - 500)[:3]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[['d77b1148', '1396', 'Mamula', '579'],\n",
+ " ['cd1f4025', '1419', 'Mamula', '629'],\n",
+ " ['443a80bb', '1286', 'Mamula', '872'],\n",
+ " ['d4bc8ebfb', '1373', 'Mamula', '651'],\n",
+ " ['f22c113c', '1217', 'Mamula', '521']]"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[h for h in holidays if h[2] == 'Mamula']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2130"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "1682+448"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2158"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "1286+872"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2101"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "1488+613"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'627824317b47'"
+ ]
+ },
+ "execution_count": 39,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "hs = iter(holidays)\n",
+ "first_holiday = next(hs)\n",
+ "best_value = cost_of_holiday(first_holiday)\n",
+ "best_holiday = first_holiday[0]\n",
+ "\n",
+ "for h in hs:\n",
+ " if cost_of_holiday(h) < best_value:\n",
+ " best_value = cost_of_holiday(h)\n",
+ " best_holiday = h[0]\n",
+ "\n",
+ "best_holiday"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,