Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 185 additions & 0 deletions challenges/PIQUE challenge/PIQUE_challenge.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Challenge: PIQUE\n",
"### Team # 32\n",
"### Team Members\n",
"- Ayelen Perez | Argentina\n",
"- Jefferson Granizo | Ecuador\n",
"- Jesus Montemayor | Perú\n",
"- Rubén Guzman | México\n",
"- Andres Diaz | Puerto Rico\n",
"\n",
"\n",
"\n",
"# Quantum Investor: Exploring the Fusion of Blockchain and Quantum Computing\n",
"\n",
"**Introduction**:\n",
"\n",
"At the exciting intersection of blockchain investment and quantum computing emerges \"Quantum Investor,\" an educational game designed for high school students. This innovative game provides a unique opportunity to explore advanced concepts playfully and educationally, allowing young adventurers to delve into the intriguing world of quantum physics and blockchain investment strategies.\n",
"\n",
"**Game Description:**\n",
"\n",
"\"Quantum Investor\" invites you to take on the role of a savvy investor in the fascinating realm of quantum blockchains. Armed with financial knowledge and quantum cryptography strategies, you will face exciting challenges while optimizing your investment and safeguarding the integrity of a blockchain against quantum threats.\n",
"\n",
"**How It Works:**\n",
"\n",
"The game presents players with the ability to apply a quantum gate, in this case, the famous Hadamard gate, to strengthen the security and reliability of the blockchain. The application of this gate generates quantum properties such as superposition that enhance the blockchain's resistance to attacks. Participants also have the opportunity to simulate quantum attacks, providing a practical understanding of how threats can impact blockchain security and, ultimately, the investment.\n",
"\n",
"**Code Development:**\n",
"\n",
"The game was developed using IBM's Qiskit quantum programming language, a leading tool in quantum computing research and development.\n",
"The code is structured modularly to facilitate understanding and allow for future educational expansions. In addition, didactic explanations were incorporated into the game to help students understand why applying a quantum gate improves blockchain security and, consequently, investment performance.\n",
"\n",
"**Educational Objectives:**\n",
"\n",
"\"Quantum Investor\" aims to achieve the following educational objectives:\n",
"\n",
"* ***Basics of Quantum Physics:*** Participants will learn fundamental concepts of quantum physics, such as superposition and quantum entanglement.\n",
"\n",
"* ***Quantum Investment Strategies:*** They will experience the importance of investment strategies in the context of quantum blockchains, understanding how quantum techniques can impact investment profitability.\n",
"\n",
"* ***Quantum Programming:*** Players will become familiar with quantum programming using Qiskit, gaining practical insights into designing and executing quantum algorithms for game development.\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"**Conclusion:**\n",
"\n",
"\"Quantum Investor\" offers an educational experience to ignite students' interest in the exciting intersection of quantum physics and blockchain investment strategies. This game demonstrates that learning about emerging technologies and finance can be fun and accessible, preparing the next generation for the challenges and opportunities of the digital future.\n",
"Embark on this thrilling educational adventure and discover the fascinating intersection of finance and quantum computing.\n",
"\n",
"# Welcome to \"Quantum Investor\"!\n",
"\n",
"Supporting Tools: ChatGPT"
],
"metadata": {
"id": "crT2z7MxQhov"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a0s5Spg6cdCs"
},
"outputs": [],
"source": [
"!pip install qiskit[all]\n",
"!pip install qiskit-aer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "7SvM-F6Dcnoh"
},
"outputs": [],
"source": [
"import random\n",
"from qiskit import QuantumCircuit, Aer, execute\n",
"\n",
"# Configuración del juego\n",
"quantum_bits = 8\n",
"blockchain_security = 60\n",
"\n",
"# Crear qubits cuánticos y registro clásico\n",
"qc = QuantumCircuit(quantum_bits, quantum_bits)\n",
"\n",
"# Variables globales para seguimiento\n",
"investment = 1000\n",
"current_security_level = blockchain_security\n",
"\n",
"# Función para aplicar una puerta cuántica de seguridad\n",
"def apply_security_gate(qc, level):\n",
" for i in range(quantum_bits):\n",
" for _ in range(level):\n",
" qc.h(i)\n",
"\n",
"# Función para simular un ataque cuántico\n",
"def simulate_quantum_attack(qc):\n",
" for i in range(quantum_bits):\n",
" if random.random() < 0.2:\n",
" qc.measure(i, i)\n",
"\n",
"# Función para calcular el nivel de seguridad\n",
"def calculate_security_level(success_rate):\n",
" return int(blockchain_security * (1 - success_rate))\n",
"\n",
"# Función para mostrar el estado actual\n",
"def show_game_state():\n",
" print(f\"Inversión actual: {investment} créditos\")\n",
" print(f\"Nivel de seguridad de la blockchain: {current_security_level}\")\n",
" print(f\"Qubits cuánticos: {quantum_bits}\")\n",
"\n",
"# Función para ejecutar el juego\n",
"def run_game():\n",
" global current_security_level, investment\n",
"\n",
" while True:\n",
" show_game_state()\n",
"\n",
" # Opciones del jugador\n",
" print(\"Opciones:\")\n",
" print(\"1. Aplicar seguridad a la blockchain\")\n",
" print(\"2. Simular ataque cuántico\")\n",
" print(\"3. Salir del juego\")\n",
"\n",
" choice = input(\"Elige una opción: \")\n",
"\n",
" if choice == \"1\":\n",
" # Explicación didáctica\n",
" print(\"Al aplicar una puerta cuántica, como la compuerta Hadamard, a los qubits de la blockchain,\")\n",
" print(\"se generan propiedades cuánticas que fortalecen su seguridad.\")\n",
" print(\"La compuerta Hadamard se utiliza para crear superposiciones, lo que hace que sea más difícil para\")\n",
" print(\"los atacantes predecir la información en los qubits, mejorando así la seguridad.\")\n",
" apply_security_gate(qc, 1)\n",
" current_security_level += 10\n",
" investment -= 100\n",
" elif choice == \"2\":\n",
" if choice == \"2\":\n",
" qc.measure(range(quantum_bits), range(quantum_bits))\n",
" backend = Aer.get_backend('qasm_simulator')\n",
" job = execute(qc, backend, shots=1024)\n",
" result = job.result()\n",
"\n",
" simulate_quantum_attack(qc)\n",
" counts = result.get_counts()\n",
" success_rate = counts.get('0', 0) / 1024\n",
" new_security_level = calculate_security_level(success_rate)\n",
"\n",
" # Determinar el resultado del ataque\n",
" if current_security_level > 80:\n",
" print(\"¡La blockchain es segura!\")\n",
" else:\n",
" print(\"¡La blockchain ha sido comprometida!\")\n",
"\n",
" # Actualizar la inversión en función de los resultados del ataque\n",
" investment += 100 if new_security_level > 80 else -100\n",
" elif choice == \"3\":\n",
" break\n",
"\n",
"if __name__ == \"__main__\":\n",
" run_game()\n"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading