Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gilberto-009199/f189ea043769a8bedd611d6ae034e031 to your computer and use it in GitHub Desktop.
Save gilberto-009199/f189ea043769a8bedd611d6ae034e031 to your computer and use it in GitHub Desktop.
phopreta_bloquear_coluna_completa.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNEfFlFZ5vpRIyEP2cw2CYq",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/gilberto-009199/f189ea043769a8bedd611d6ae034e031/phopreta_bloquear_coluna_completa.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# Phopreta Tests"
],
"metadata": {
"id": "boGchH5TugtB"
}
},
{
"cell_type": "code",
"source": [
"import os\n",
"import pandas as pd\n",
"from IPython.display import display, HTML"
],
"metadata": {
"id": "JkfIPOS819i8"
},
"execution_count": 7,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Como Testar:\n",
"\n",
" Suba o seu **dataset** no **Gist** e cole a url **Abaixo**:\n",
"\n",
"+ **Passo** 1(Copiar a tabela, Ctrl + A, Ctrl + C):\n",
" ![Copiar a Tabela](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE01.png)\n",
"\n",
"+ **Passo** 2(Criar um gist):\n",
" </br> visite o site [gist github](https://gist.github.com/)\n",
" ![Copiar a Tabela](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE02.png)\n",
" Talves seja necessario **criar** uma **conta**\n",
"\n",
"+ **Passo** 3(Criar um arquivo .txt):\n",
" </br> Escreva no campo data.txt,\n",
" ![Copiar a Tabela](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE03.gif)\n",
"\n",
"+ **Passo** 4(Criar):\n",
" </br> Crie um gist **publico**\n",
" ![Copiar a Tabela](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE04.gif)\n",
"\n",
"+ **Passo** 5(Copie a URL):\n",
" ![Copiar a Tabela](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE06.gif)\n",
"\n",
"+ **Passo** 6(Copie a URL):\n",
" ![Postar URL](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/EXAMPLE07.gif)\n"
],
"metadata": {
"id": "DgGONZXU51ES"
}
},
{
"cell_type": "markdown",
"source": [
"## Regra coluna completa(25)\n",
"Regra 25. Regra da coluna completa.\n",
" Os conjuntos:\n",
"+ {01 06 11 16 21}\n",
"+ {02 07 12 17 22}\n",
"+ {03 08 13 18 23}\n",
"+ {04 09 14 19 24}\n",
"+ {05 10 15 20 25}\n",
"\n",
"nunca ocorrem simultaneamente. Combinações que tenham dois ou mais desses conjuntos devem ser descartadas.\n",
"\n",
"![form](https://filedn.com/l3HMwWFeFPE7q4xHdixbsqH/phopreta/CONCURSOSREPETIDOS.gif)"
],
"metadata": {
"id": "EN6kuHKLum_k"
}
},
{
"cell_type": "code",
"source": [
"# @markdown ## **Coluna Completa(Impedir dois ou mais numeros)**\n",
"URL_DAS_COMBINAÇÕES=\"https://gist.github.com/gilberto-009199/04a8e07673a424000091f0b169b3354a/raw/64f8be38d055c0243f506ea8fcb5bc264aba7c6f/data_not_duplicate_old_result.txt\" # @param {type:\"string\"}\n",
"df = pd.read_csv(URL_DAS_COMBINAÇÕES, delimiter= '\\t',header= None ,names = ['combinação', '1°', '2°', '3°', '4°', '5°', '6°', '7°', '8°', '9°', '10°', '11°', '12°', '13°', '14°', '15°'])\n",
"\n",
"\n",
"\n",
"# @markdown Regra 25. Regra da coluna completa.\n",
"# @markdown Os conjuntos:\n",
"# @markdown + { 01 06 11 16 21 }\n",
"# @markdown + { 02 07 12 17 22 }\n",
"# @markdown + { 03 08 13 18 23 }\n",
"# @markdown + { 04 09 14 19 24 }\n",
"# @markdown + { 05 10 15 20 25 }\n",
"# @markdown\n",
"# @markdown nunca ocorrem simultaneamente. Combinações que tenham dois ou mais desses conjuntos devem ser\n",
"# @markdown descartadas.\n",
"\n",
"# Lista de conjuntos a serem verificados\n",
"conjuntos = [\n",
" {1, 6, 11, 16, 21},\n",
" {2, 7, 12, 17, 22},\n",
" {3, 8, 13, 18, 23},\n",
" {4, 9, 14, 19, 24},\n",
" {5, 10, 15, 20, 25}\n",
"]\n",
"listPrimos = [];\n",
"\n",
"for reg in df.values:\n",
" count = 0\n",
" comb = reg[1:];\n",
" for conjunto in conjuntos:\n",
" if all(num in comb for num in conjunto):\n",
" count += 1\n",
" listPrimos.append(count)\n",
"\n",
"df['QUANT. Conjunto'] = listPrimos;\n",
"\n",
"filtered_df = df[(df['QUANT. Conjunto'] >=2 )]\n",
"\n",
"if len(filtered_df) > 0:\n",
" print(\"\\t Linhas com 2 ou mais conjuntos de colunas:\")\n",
" display(HTML(filtered_df.head().to_html()));\n",
"else:\n",
" print(\"\\t Nenhuma Linhas com 2 ou mais conjuntos de colunas:\")\n",
" display(HTML(df.head().to_html()));\n",
"\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 225
},
"id": "zhOQNYRxz0Ay",
"outputId": "1bc80452-39d8-439f-ec52-393ff96470ed"
},
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\t Nenhuma Linhas com 2 ou mais conjuntos de colunas:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.HTML object>"
],
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>combinação</th>\n",
" <th>1°</th>\n",
" <th>2°</th>\n",
" <th>3°</th>\n",
" <th>4°</th>\n",
" <th>5°</th>\n",
" <th>6°</th>\n",
" <th>7°</th>\n",
" <th>8°</th>\n",
" <th>9°</th>\n",
" <th>10°</th>\n",
" <th>11°</th>\n",
" <th>12°</th>\n",
" <th>13°</th>\n",
" <th>14°</th>\n",
" <th>15°</th>\n",
" <th>QUANT. Conjunto</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1ª</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" <td>8</td>\n",
" <td>11</td>\n",
" <td>12</td>\n",
" <td>14</td>\n",
" <td>15</td>\n",
" <td>18</td>\n",
" <td>19</td>\n",
" <td>20</td>\n",
" <td>22</td>\n",
" <td>24</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2ª</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>6</td>\n",
" <td>8</td>\n",
" <td>9</td>\n",
" <td>10</td>\n",
" <td>11</td>\n",
" <td>12</td>\n",
" <td>14</td>\n",
" <td>15</td>\n",
" <td>18</td>\n",
" <td>19</td>\n",
" <td>23</td>\n",
" <td>25</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3ª</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" <td>8</td>\n",
" <td>10</td>\n",
" <td>11</td>\n",
" <td>14</td>\n",
" <td>17</td>\n",
" <td>19</td>\n",
" <td>20</td>\n",
" <td>21</td>\n",
" <td>22</td>\n",
" <td>23</td>\n",
" <td>24</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4ª</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" <td>8</td>\n",
" <td>9</td>\n",
" <td>11</td>\n",
" <td>15</td>\n",
" <td>16</td>\n",
" <td>18</td>\n",
" <td>19</td>\n",
" <td>20</td>\n",
" <td>22</td>\n",
" <td>24</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5ª</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" <td>8</td>\n",
" <td>11</td>\n",
" <td>13</td>\n",
" <td>15</td>\n",
" <td>16</td>\n",
" <td>18</td>\n",
" <td>20</td>\n",
" <td>22</td>\n",
" <td>24</td>\n",
" <td>25</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"# @markdown ## **Coluna Completa(Impedir dois ou mais numeros)**\n",
"URL_DAS_COMBINAÇÕES=\"https://gist.github.com/gilberto-009199/837cb2dc23f028aafd7cbceb4ca3eb9f/raw/8f82441c929fa3cec8cb495f311f0a28dc357018/data_teste_error2.txt\" # @param {type:\"string\"}\n",
"df = pd.read_csv(URL_DAS_COMBINAÇÕES, delimiter= '\\t',header= None ,names = ['combinação', '1°', '2°', '3°', '4°', '5°', '6°', '7°', '8°', '9°', '10°', '11°', '12°', '13°', '14°', '15°'])\n",
"\n",
"\n",
"\n",
"# @markdown Regra 25. Regra da coluna completa.\n",
"# @markdown Os conjuntos:\n",
"# @markdown + { 01 06 11 16 21 }\n",
"# @markdown + { 02 07 12 17 22 }\n",
"# @markdown + { 03 08 13 18 23 }\n",
"# @markdown + { 04 09 14 19 24 }\n",
"# @markdown + { 05 10 15 20 25 }\n",
"# @markdown\n",
"# @markdown nunca ocorrem simultaneamente. Combinações que tenham dois ou mais desses conjuntos devem ser\n",
"# @markdown descartadas.\n",
"\n",
"# Lista de conjuntos a serem verificados\n",
"conjuntos = [\n",
" {1, 6, 11, 16, 21},\n",
" {2, 7, 12, 17, 22},\n",
" {3, 8, 13, 18, 23},\n",
" {4, 9, 14, 19, 24},\n",
" {5, 10, 15, 20, 25}\n",
"]\n",
"listPrimos = [];\n",
"\n",
"for reg in df.values:\n",
" count = 0\n",
" comb = reg[1:];\n",
" for conjunto in conjuntos:\n",
" if all(num in comb for num in conjunto):\n",
" count += 1\n",
" listPrimos.append(count)\n",
"\n",
"df['QUANT. Conjunto'] = listPrimos;\n",
"\n",
"filtered_df = df[(df['QUANT. Conjunto'] >=2 )]\n",
"\n",
"if len(filtered_df) > 0:\n",
" print(\"\\t Linhas com 2 ou mais conjuntos de colunas:\")\n",
" display(HTML(filtered_df.head().to_html()));\n",
"else:\n",
" print(\"\\t Nenhuma Linhas com 2 ou mais conjuntos de colunas:\")\n",
" display(HTML(df.head().to_html()));\n",
"\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 99
},
"id": "OAy51ATWPB6s",
"outputId": "64a080a3-a1f0-43e2-f670-fb811174d58a"
},
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\t Linhas com 2 ou mais conjuntos de colunas:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.HTML object>"
],
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>combinação</th>\n",
" <th>1°</th>\n",
" <th>2°</th>\n",
" <th>3°</th>\n",
" <th>4°</th>\n",
" <th>5°</th>\n",
" <th>6°</th>\n",
" <th>7°</th>\n",
" <th>8°</th>\n",
" <th>9°</th>\n",
" <th>10°</th>\n",
" <th>11°</th>\n",
" <th>12°</th>\n",
" <th>13°</th>\n",
" <th>14°</th>\n",
" <th>15°</th>\n",
" <th>QUANT. Conjunto</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1ª</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" <td>11</td>\n",
" <td>12</td>\n",
" <td>13</td>\n",
" <td>16</td>\n",
" <td>17</td>\n",
" <td>18</td>\n",
" <td>21</td>\n",
" <td>22</td>\n",
" <td>24</td>\n",
" <td>25</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
]
},
"metadata": {}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment