diff --git a/2025/AFL/Chap3_Data_Structures/Submissions/TASK1_Hirann.ipynb b/2025/AFL/Chap3_Data_Structures/Submissions/TASK1_Hirann.ipynb new file mode 100644 index 0000000..64b163f --- /dev/null +++ b/2025/AFL/Chap3_Data_Structures/Submissions/TASK1_Hirann.ipynb @@ -0,0 +1,48 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Task 1.1\n", + "list = [[6,6,8,6,7], [0,0,3,8,0], [6,6,6,8,7], [9,8,7,7,9], [4,8,8,8,3]]\n", + "\n", + "#Task 1.2\n", + "\n", + "def count_consecutive(l):\n", + " count = 0\n", + " for i in l:\n", + " for idx, n in enumerate(i): \n", + " if idx <= len(i) - 3: \n", + " if n + 1 == i[idx + 1] and n + 2 == i[idx + 2]:\n", + " count += 1\n", + " elif n - 1 == i[idx + 1] and n - 2 == i[idx + 2]:\n", + " count += 1\n", + " return count\n", + "\n", + "def transpose(l):\n", + " return [[l[j][i] for j in range(len(l))] for i in range(len(l[0]))]\n", + "\n", + "counter = 0\n", + "counter += count_consecutive(list)\n", + "counter += count_consecutive(transpose(list))\n", + "print(counter)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.12.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}