From c332e88f7becbcacdfb79836cc3548757187ef3c Mon Sep 17 00:00:00 2001 From: jcarlosrm98 <157207234+jcarlosrm98@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:38:39 +0100 Subject: [PATCH] Trabajo hecho --- codewars1.ipynb | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 codewars1.ipynb diff --git a/codewars1.ipynb b/codewars1.ipynb new file mode 100644 index 0000000..bea6ac6 --- /dev/null +++ b/codewars1.ipynb @@ -0,0 +1,110 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3bde88ef", + "metadata": {}, + "source": [ + "#ARRAY CODEWARS" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b290293a", + "metadata": {}, + "outputs": [], + "source": [ + "#ejercicio 1: \"https://www.codewars.com/kata/563089b9b7be03472d00002b/solutions/python\"\n", + "class List:\n", + " def remove_ (self, integer_list, values_list):\n", + " new_array = []\n", + " for num in integer_list:\n", + " if num not in values_list:\n", + " new_array.append(num)\n", + " return new_array" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "50549b92", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "#ejercicio 2: \"https://www.codewars.com/kata/56311e4fdd811616810000ce/solutions/python\"\n", + " def count_spec_digits(self, integers_list, digits_list):\n", + " \n", + " lista = []\n", + " \n", + " \n", + " for digit in digits_list:\n", + " count = 0\n", + " for num in integers_list:\n", + " count += str(num).count(str(digit))\n", + " lista.append((digit, count))\n", + " \n", + " return lista " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd7f1ac1", + "metadata": {}, + "outputs": [], + "source": [ + "# Ejercicio 3, ordered count: \"https://www.codewars.com/kata/57a6633153ba33189e000074/solutions/python\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b0b6502d", + "metadata": {}, + "outputs": [], + "source": [ + "char_count = {}\n", + " \n", + " for char in input_string:\n", + " if char in char_count:\n", + " char_count[char] += 1\n", + " else:\n", + " char_count[char] = 1\n", + "\n", + " result = [(char, count) for char, count in char_count.items()]\n", + "\n", + " return result" + ] + } + ], + "metadata": { + "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.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}