From 29f048708e4b6bb36c2af42b01cfdbbb5c9581c2 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 8 Jan 2022 02:13:00 +0000 Subject: [PATCH] Pico and Fumi check --- notebooks/picofumi.ipynb | 252 ++++++++++++++++++++++++--------------- 1 file changed, 154 insertions(+), 98 deletions(-) diff --git a/notebooks/picofumi.ipynb b/notebooks/picofumi.ipynb index 9e46b62..3da5137 100644 --- a/notebooks/picofumi.ipynb +++ b/notebooks/picofumi.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "e1d4d9e8-1781-4d55-9a57-d7c505009a04", + "id": "571ac5d7", "metadata": {}, "source": [ "# Pico Fumi" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d8f95dd9-11ad-455d-854a-86a12d84fbda", + "id": "72ae05ab", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ }, { "cell_type": "markdown", - "id": "f97654b6-de87-4a5a-9dfb-e32eac6b62cd", + "id": "7760dfcf", "metadata": {}, "source": [ "## Printing" @@ -28,19 +28,27 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "0046af84-de64-4023-bdf5-335177caf22a", + "execution_count": 1, + "id": "1eabbdcf", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pico Fumi\n" + ] + } + ], "source": [ "print(\"Pico Fumi\")" ] }, { "cell_type": "markdown", - "id": "ce8f228c-dbb3-4b49-87ea-2234d283f49d", + "id": "c4d898da", "metadata": {}, "source": [ "## Variables" @@ -48,10 +56,18 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "781cbd75-5b16-4740-ac88-fda9672bcdbd", + "execution_count": 2, + "id": "c9aa132b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "123\n" + ] + } + ], "source": [ "#string\n", "guess = \"123\"\n", @@ -60,10 +76,18 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "b41186fa-ff8a-4e5e-ba55-1c9450a5c9af", + "execution_count": 3, + "id": "64ae1dc1", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n" + ] + } + ], "source": [ "#integer \n", "guesses = 0\n", @@ -72,7 +96,7 @@ }, { "cell_type": "markdown", - "id": "4304923b-cbc9-48ca-9ee8-766487115c2f", + "id": "0cd9ab76", "metadata": {}, "source": [ "## Get User Input" @@ -80,15 +104,15 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "3adeee26-8a18-4bad-946b-3d06920ef82f", + "execution_count": 4, + "id": "4524a662", "metadata": {}, "outputs": [ { - "name": "stdin", + "name": "stdout", "output_type": "stream", "text": [ - "Enter a three digit number: 1\n" + "Enter a three digit number:123\n" ] } ], @@ -98,15 +122,15 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "ec055f06-6fdd-4ab9-bce2-d56c82093c4b", + "execution_count": 5, + "id": "cbaea031", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1\n" + "123\n" ] } ], @@ -116,7 +140,7 @@ }, { "cell_type": "markdown", - "id": "8999ef19-6a3c-41ea-bf2b-11dcbbe64070", + "id": "402a7d7c", "metadata": {}, "source": [ "## Check that the guess a 3 digit number" @@ -124,17 +148,17 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "f7bcf18f-4e98-453f-bc1f-ef61b0aa55e4", + "execution_count": 6, + "id": "de4d4fbb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1" + "3" ] }, - "execution_count": 18, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -145,17 +169,17 @@ }, { "cell_type": "code", - "execution_count": 22, - "id": "53fca278-f55e-43f1-ab5f-f6df4fb7c163", + "execution_count": 7, + "id": "f747159b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "False" + "True" ] }, - "execution_count": 22, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -166,18 +190,10 @@ }, { "cell_type": "code", - "execution_count": 23, - "id": "bd9b231e-53c5-4b05-8f55-86ccf289b1e1", + "execution_count": 8, + "id": "b82b11f8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Guess is not 3 digits\n" - ] - } - ], + "outputs": [], "source": [ "if len(guess) != 3:\n", " print(\"Guess is not 3 digits\")" @@ -185,7 +201,7 @@ }, { "cell_type": "markdown", - "id": "2f806636-3296-42ce-914f-356e34e066a7", + "id": "9cf640e2", "metadata": {}, "source": [ "## Re-prompt the user until they enter a 3 digit number" @@ -193,15 +209,15 @@ }, { "cell_type": "code", - "execution_count": 28, - "id": "d427210a-75be-4a47-83e2-fbdffa2b2644", + "execution_count": 9, + "id": "3e42feef", "metadata": {}, "outputs": [ { - "name": "stdin", + "name": "stdout", "output_type": "stream", "text": [ - "Enter a three digit number: 123\n" + "Enter a three digit number:123\n" ] } ], @@ -213,7 +229,7 @@ }, { "cell_type": "markdown", - "id": "6e3fa703-3f5f-4622-b8f5-349f61371282", + "id": "5871ca62", "metadata": {}, "source": [ "## Break guess into 3 parts" @@ -221,8 +237,8 @@ }, { "cell_type": "code", - "execution_count": 56, - "id": "7e1a2228-3316-4652-9051-70c355de94bb", + "execution_count": 10, + "id": "f0823ff9", "metadata": {}, "outputs": [ { @@ -244,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "ccd7b9d1-c266-498e-9f46-63c522c4d332", + "id": "8b32aac0", "metadata": {}, "source": [ "## Itterate over the guess" @@ -252,8 +268,8 @@ }, { "cell_type": "code", - "execution_count": 57, - "id": "ddca84c9-2fff-4302-afd0-7096649bcdc7", + "execution_count": 11, + "id": "d2c97cb7", "metadata": {}, "outputs": [ { @@ -273,8 +289,8 @@ }, { "cell_type": "code", - "execution_count": 58, - "id": "f631cc60-92e9-4c16-a5ab-4f50dfd10cc2", + "execution_count": 12, + "id": "cdb0cd32", "metadata": {}, "outputs": [ { @@ -294,7 +310,7 @@ }, { "cell_type": "markdown", - "id": "201cae7a-2cc5-4ff0-ac16-730091e24b72", + "id": "f43efa21", "metadata": {}, "source": [ "## Functions" @@ -302,8 +318,8 @@ }, { "cell_type": "code", - "execution_count": 33, - "id": "3aebea62-fa40-4e87-8229-3aafb051a006", + "execution_count": 10, + "id": "4fdded17", "metadata": {}, "outputs": [], "source": [ @@ -316,18 +332,15 @@ }, { "cell_type": "code", - "execution_count": 34, - "id": "a2430233-5753-433d-bada-d8ee086f2bb2", + "execution_count": 14, + "id": "886517d8", "metadata": {}, "outputs": [ { - "name": "stdin", + "name": "stdout", "output_type": "stream", "text": [ - "Enter a three digit number: 12\n", - "Enter a three digit number: 12\n", - "Enter a three digit number: 34\n", - "Enter a three digit number: 123\n" + "Enter a three digit number:123\n" ] }, { @@ -336,7 +349,7 @@ "['1', '2', '3']" ] }, - "execution_count": 34, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -347,7 +360,7 @@ }, { "cell_type": "markdown", - "id": "77ab1ca2-0ea0-43b3-b6bd-d4438fa8141d", + "id": "b18f748b", "metadata": {}, "source": [ "## Random Numbers" @@ -355,8 +368,8 @@ }, { "cell_type": "code", - "execution_count": 35, - "id": "f4412eef-6b79-4329-b8e7-85f916d3dfbf", + "execution_count": 2, + "id": "785a2c42", "metadata": {}, "outputs": [], "source": [ @@ -366,15 +379,15 @@ }, { "cell_type": "code", - "execution_count": 44, - "id": "c9324728-63c2-4023-92fc-3e1e80dff03a", + "execution_count": 6, + "id": "d1778d13", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "536\n" + "437\n" ] } ], @@ -385,8 +398,8 @@ }, { "cell_type": "code", - "execution_count": 47, - "id": "183e5444-2b79-4366-84cf-4da91c2547cf", + "execution_count": 7, + "id": "cd137952", "metadata": {}, "outputs": [ { @@ -395,7 +408,7 @@ "int" ] }, - "execution_count": 47, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -406,18 +419,20 @@ }, { "cell_type": "code", - "execution_count": 48, - "id": "afe9d668-aefd-4021-9028-a21b04e931cd", + "execution_count": 8, + "id": "a270063a", "metadata": {}, "outputs": [], "source": [ + "#covert to a string\n", "number = str(number)\n", + "#split into 3 parts\n", "number = list(number)" ] }, { "cell_type": "markdown", - "id": "a5f6f56b-0678-4f82-9539-ae7c798d6c63", + "id": "727a1c33", "metadata": {}, "source": [ "## Check if number guessed is correct" @@ -425,22 +440,17 @@ }, { "cell_type": "code", - "execution_count": 51, - "id": "6194de2b-2dbe-4c49-bc00-e5bed3c35f1f", - "metadata": {}, + "execution_count": 11, + "id": "dc005fde", + "metadata": { + "scrolled": true + }, "outputs": [ - { - "name": "stdin", - "output_type": "stream", - "text": [ - "Enter a three digit number: \n", - "Enter a three digit number: 123\n" - ] - }, { "name": "stdout", "output_type": "stream", "text": [ + "Enter a three digit number:472\n", "You guessed wrong\n" ] } @@ -455,7 +465,40 @@ }, { "cell_type": "markdown", - "id": "0496040d-4d2c-4580-9993-d1832568cd6b", + "id": "f0aef1a9", + "metadata": {}, + "source": [ + "## Check Pico" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "c3752fcd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['4', '7', '2']\n", + "['P', 'P', '']\n" + ] + } + ], + "source": [ + "hint = [\"\", \"\", \"\"]\n", + "for index, value in enumerate(guess):\n", + " if value in number:\n", + " #if value in number and value != number[index]:\n", + " hint[index] = \"P\"\n", + "print(guess)\n", + "print(hint)" + ] + }, + { + "cell_type": "markdown", + "id": "8ffb6ece", "metadata": {}, "source": [ "## Check Fumi" @@ -463,29 +506,39 @@ }, { "cell_type": "code", - "execution_count": 55, - "id": "ab9145db-4662-41ae-ba38-6c66c7402d80", + "execution_count": 16, + "id": "6591943b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "index 0 value 1\n", - "index 1 value 2\n", - "index 2 value 3\n" + "['4', '7', '2']\n", + "['F', 'P', '']\n" ] } ], "source": [ "for index, value in enumerate(guess):\n", - " print(f'index {index} value {value}')" + " if value == number[index]:\n", + " hint[index] = \"F\"\n", + "print(guess)\n", + "print(hint)" + ] + }, + { + "cell_type": "markdown", + "id": "f19d453f", + "metadata": {}, + "source": [ + "## Putting it together" ] }, { "cell_type": "code", "execution_count": null, - "id": "f647c557-d247-48b9-8c31-5623dea46336", + "id": "fa759ece", "metadata": {}, "outputs": [], "source": [ @@ -528,7 +581,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1abd05b8-dfca-4fcc-8bb0-57dd77329086", + "id": "39b1ea60", "metadata": {}, "outputs": [], "source": [ @@ -552,7 +605,10 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.9.7" + }, + "nteract": { + "version": "nteract-on-jupyter@2.1.3" } }, "nbformat": 4,