Drop some Blox! The one who drops in the most efficient way wins! 🏆
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

267 lines
5.8 KiB

{
"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"
]
},
{
"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",
")"
]
},
{
"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": {
"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
}