{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "IKogHoj_hqy4" }, "source": [ "# PyData DropBlox coding competition ๐Ÿงฑ\n", "This Notebook shows you how to generate submissions. The real optimization work is up to you! โœŒ๐Ÿป \n", "\n", "> Hosted by [GoDataDriven](https://godatadriven.com/) for PyConDE & PyData Berlin 2022.\n", "\n", "\n", "The rewards are like follows:\n", "\n", "| Emoji | Color code | Points | Multiplication factor |\n", "|-------|------------|--------|-----------------------|\n", "| ๐ŸŸฆ | \"B\" | 100 | 0 |\n", "| ๐ŸŸจ | \"Y\" | 1 | 3 |\n", "| ๐ŸŸฉ | \"G\" | 1 | 1 |\n", "| ๐ŸŸช | \"P\" | 5 | 2 |\n", "| ๐ŸŸง | \"O\" | 5 | 3 |\n", "| ๐ŸŸฅ | \"R\" | 8 | 4 |\n", "\n", "Good luck! ๐Ÿ’ช๐Ÿป" ] }, { "cell_type": "markdown", "metadata": { "id": "I193GlrrPshR" }, "source": [ "Import definitions" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "5nljvNsQM-S7" }, "outputs": [], "source": [ "from typing import List\n", "\n", "# Data types\n", "from common.data_models import (\n", " Field,\n", " Block,\n", " Rewards,\n", " Solution\n", ")\n", "\n", "# Puzzle helper functions\n", "from common.score_evaluation import (\n", " parse_puzzle,\n", " write_solution,\n", " drop_block,\n", " drop_blocks,\n", " score_solution,\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "yJyvNoBPOpY-" }, "source": [ "Read puzzle specification file" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "id": "ZAimvAxqhrBy" }, "outputs": [], "source": [ "field: Field\n", "blocks: List[Block]\n", "rewards: Rewards\n", "field, blocks, rewards = parse_puzzle(\n", " \"./puzzle.txt\"\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "d4gp3zhKPXaK" }, "source": [ "## Example submission" ] }, { "cell_type": "markdown", "metadata": { "id": "CNWt46l4M5Yp" }, "source": [ "Check out the first block" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "tSPKZgB3M3-H", "outputId": "18d7daf0-a1ac-46b3-8517-0ce51e5ff481" }, "outputs": [ { "data": { "text/plain": [ "Block:\n", "๐ŸŸง๐ŸŸง๐ŸŸง\n", "๐ŸŸงโฌœ๏ธ๐ŸŸง\n", "โฌœ๏ธโฌœ๏ธ๐ŸŸง" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "first_block = blocks[0]\n", "first_block" ] }, { "cell_type": "markdown", "metadata": { "id": "TZbqsPNQM1UT" }, "source": [ "Drop it somewhere" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "id": "2f_a4iRNN22F" }, "outputs": [], "source": [ "x = 0\n", "drop_block(field, first_block, x)" ] }, { "cell_type": "markdown", "metadata": { "id": "bJ9XuS4BOLX8" }, "source": [ "Check out the field" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Csf_Vs6RODGL", "outputId": "501e1dca-626f-4e31-c75b-4bcf4b0d0174" }, "outputs": [], "source": [ "field" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Show our score ๐Ÿ“ˆ" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "score_solution(field, rewards)" ] }, { "cell_type": "markdown", "metadata": { "id": "SBLSamhqP8rq" }, "source": [ "Create a solution object:\n", "\n", "โ†’ Dropping block `0` at index `0`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "2a0_-SciP8zG" }, "outputs": [], "source": [ "block_ids = [0]\n", "block_positions = [0]\n", "solution = Solution(block_ids=block_ids, block_positions=block_positions)" ] }, { "cell_type": "markdown", "metadata": { "id": "UPZHZj6aPyAS" }, "source": [ "## Writing the solution file" ] }, { "cell_type": "markdown", "metadata": { "id": "iVlTISFZON1q" }, "source": [ "Write our solution to disk ๐Ÿ’พ" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Wis3JpFNMrl5" }, "outputs": [], "source": [ "write_solution(solution, \"solution.txt\")" ] }, { "cell_type": "markdown", "metadata": { "id": "zEl-rw9yQ10E" }, "source": [ "Submit your solution ๐ŸŽ‰  ! Upload at:\n", "\n", "[https://dropblox.azurewebsites.net/submit](https://dropblox.azurewebsites.net/submit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## About\n", "> Competition hosted by [GoDataDriven](https://godatadriven.com/) for PyConDE & PyData Berlin 2022." ] } ], "metadata": { "colab": { "name": "PyData DropBlox coding competition", "provenance": [] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 0 }