Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed by Kiran Akshay S #58

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
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
52 changes: 52 additions & 0 deletions December 01/Dec_1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.0\n",
"1.0\n"
]
}
],
"source": [
"def findsum(n,arr):\n",
" a_sum=sum(arr)\n",
" e_sum=(n*(n+1)/2)\n",
" v=e_sum-a_sum\n",
" print(v)\n",
"\n",
"\n",
"findsum(5,[1,3,4,5])\n",
"findsum(3,[2,3])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
53 changes: 53 additions & 0 deletions December 02/Dec_2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[10, 5, 6, 2, 20, 3, 100, 80]\n"
]
}
],
"source": [
"def wave(arr):\n",
" for i in range(len(arr)-1):\n",
" if i%2==0:\n",
" if arr[i]<arr[i+1]:\n",
" arr[i],arr[i+1]=arr[i+1],arr[i]\n",
"\n",
" else:\n",
" if arr[i]>arr[i+1]:\n",
" arr[i],arr[i+1]=arr[i+1],arr[i]\n",
" print(arr)\n",
"wave([10, 5, 6, 3, 2, 20, 100, 80])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
60 changes: 60 additions & 0 deletions December 03/Dec_3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RBRBR\n",
"Not possible\n"
]
}
],
"source": [
"def arrange_squares(R, B):\n",
" if abs(R - B) > 1:\n",
" return \"Not possible\"\n",
"\n",
" if R >= B:\n",
" result = \"RB\" * B + \"R\" * (R - B)\n",
" else:\n",
" result = \"BR\" * R + \"B\" * (B - R)\n",
"\n",
" return result\n",
"\n",
"R = 3\n",
"B = 2\n",
"output = arrange_squares(3, 2)\n",
"print(output)\n",
"print(arrange_squares(5, 3))\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
53 changes: 53 additions & 0 deletions December 04/Dec_4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"55\n",
"144\n"
]
}
],
"source": [
"def pgt(n):\n",
" if n==0:\n",
" return 0\n",
" elif n==1:\n",
" return 1\n",
" else:\n",
" return pgt(n-1)+pgt(n-2)\n",
"\n",
"print(pgt(10))\n",
"print(pgt(12))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
51 changes: 51 additions & 0 deletions December 05/Dec_5.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n",
"4\n"
]
}
],
"source": [
"def josephus(n, k):\n",
" if n == 1:\n",
" return 1\n",
" else:\n",
" return (josephus(n - 1, k) + k - 1) % n + 1\n",
"\n",
"print(josephus(3,2)) \n",
"print(josephus(5,3))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
55 changes: 55 additions & 0 deletions December 06/Dec_6.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Unique pairs are: [(2, 4), (1, 5)]\n"
]
}
],
"source": [
"def find_pairs(n, t):\n",
" unique_pairs = []\n",
" for i in range(len(n)):\n",
" for j in range(i + 1, len(n)):\n",
" if n[i] + n[j] == t:\n",
" pair = (n[i], n[j])\n",
" unique_pairs.append(pair)\n",
" return unique_pairs\n",
"\n",
"n = [2, 4, 3, 7, 1, 5]\n",
"t = 6\n",
"result = find_pairs(n, t)\n",
"print(\"Unique pairs are:\", result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
61 changes: 61 additions & 0 deletions December 07/Dec_7.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1]\n",
"[1, 1]\n",
"[1, 2, 1]\n",
"[1, 3, 3, 1]\n",
"[1, 4, 6, 4, 1]\n"
]
}
],
"source": [
"def generate_magical_tower(N):\n",
" tower = [[1]]\n",
" for i in range(1, N):\n",
" floor = [1]\n",
" for j in range(1, i):\n",
" floor.append(tower[i-1][j-1] + tower[i-1][j])\n",
" floor.append(1)\n",
" tower.append(floor)\n",
" return tower\n",
"\n",
"N = 5\n",
"magical_tower = generate_magical_tower(N)\n",
"\n",
"for floor in magical_tower:\n",
" print(floor)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.9.6"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading