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

rsreevishal - Completed #60

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7df19af
completed day 1
rsreevishal Dec 1, 2019
314afc7
first merge
rsreevishal Dec 4, 2019
b85cbb0
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 7, 2019
842b87c
finished till day 6
rsreevishal Dec 7, 2019
2bdccc1
completed day2
rsreevishal Dec 7, 2019
106a903
Delete d2.py
rsreevishal Dec 7, 2019
4940126
finished till day6
rsreevishal Dec 7, 2019
1351b75
Merge branch 'master' of https://github.com/rsreevishal/A-December-of…
rsreevishal Dec 7, 2019
708f8e8
finished till day 8
rsreevishal Dec 8, 2019
7458619
completed day9
rsreevishal Dec 9, 2019
12eee9c
completed till day11
rsreevishal Dec 10, 2019
ea0be52
completed till day11
rsreevishal Dec 10, 2019
5856762
merged the updates
rsreevishal Dec 14, 2019
34b823a
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 18, 2019
963f93e
completed till d16
rsreevishal Dec 21, 2019
f912500
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 22, 2019
6f4eb21
in progress
rsreevishal Dec 22, 2019
6acfffe
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 27, 2019
fd96b19
updated
rsreevishal Dec 27, 2019
4d05305
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 29, 2019
f4e2b31
Merge remote-tracking branch 'upstream/master'
rsreevishal Dec 30, 2019
b408a71
All done
rsreevishal Dec 31, 2019
68c85a8
all done
rsreevishal Dec 31, 2019
5b962cc
Delete JaSON.json
mahavisvanathan Jan 13, 2020
005d78c
Delete example.html
mahavisvanathan Jan 13, 2020
bfad0d2
Delete d11.html
mahavisvanathan Jan 13, 2020
6cae46a
Delete data.csv
mahavisvanathan Jan 13, 2020
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
18 changes: 18 additions & 0 deletions December-01/d1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def sevenis(n):
arr = []
i = 0
while(n > len(arr)):
tmp = pow(7,i)
arr.append(tmp)
for j in range(len(arr)-1):
arr.append(arr[j]+tmp)
if(len(arr) > n):
break
i += 1
return arr[n-1]

n = int(input())

print(sevenis(n))


21 changes: 21 additions & 0 deletions December-02/d2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def check(num):
s1 = 0
s2 = 0
for i in range(len(num)):
if(i%2 == 0):
s1 += int(num[i])
else:
tmp = int(num[i]) * 2
while (tmp > 9):
tmp -= 9
s2 += tmp
tot = s1 + s2
if( tot % 10 == 0):
print(num + " passes the test")
else:
print(num + " failed the test")


inp = input()

check(inp)
24 changes: 24 additions & 0 deletions December-03/d3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import math
def snap(arr,n):
if(len(arr) == 1):
return arr
elif(sorted(arr) == arr):
return arr
flag = count = 1
limit = math.ceil(n/2)
tmp = [arr[0]]
for i in range(1,len(arr)):
if(tmp[-1] < arr[i]):
tmp.append(arr[i])
count += 1
if(count == limit):
return tmp
flag = 0
if(flag == 1):
return arr[0:1]
else:
snap(arr[0:limit],limit)

n = int(input('Enter the size:'))
arr = [int(i) for i in input().split()]
print(snap(arr,n))
15 changes: 15 additions & 0 deletions December-04/d4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def h_index(n,arr):
arr.sort()
max = -1
for i in range(len(arr)):
if(len(arr) - i == arr[i]):
if(arr[i] > max):
max = arr[i]
return max



n = int(input('Enter # of papers:'))
arr = [int(e) for e in input().split()]

print(h_index(n,arr))
29 changes: 29 additions & 0 deletions December-05/d5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
file1 = open('../src/res/csv_to_html_res.csv','r')
file2 = open('example.html','a')
open('example.html', 'w').close()
openTag = "<html>\n^<body>\n^^<table>\n"
closeTag = "^^^</table>\n^^</body>\n</html>\n"
result = ""
result += openTag
flag = 0
for line in file1:
values = line.split(',')
tmp = ""
if(flag == 0):
for e in values:
e = e.replace('\n','')
tmp += "<th>{}</th>".format(e)
flag = 1
else:
for e in values:
e = e.replace('\n','')
tmp += "<td>{}</td>".format(e)
tr = "^^^^<tr>{}</tr>\n".format(tmp)
result += tr
result += closeTag
file2.write(result.replace('^',' '))
file1.close()
file2.close()



25 changes: 25 additions & 0 deletions December-05/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<body>
<table>
<tr><th>"Name"</th><th> "Sex"</th><th> "Age"</th><th> "Height (in)"</th><th> "Weight (lbs)"</th></tr>
<tr><td>"Alex"</td><td> "M"</td><td> 41</td><td> 74</td><td> 170</td></tr>
<tr><td>"Bert"</td><td> "M"</td><td> 42</td><td> 68</td><td> 166</td></tr>
<tr><td>"Carl"</td><td> "M"</td><td> 32</td><td> 70</td><td> 155</td></tr>
<tr><td>"Dave"</td><td> "M"</td><td> 39</td><td> 72</td><td> 167</td></tr>
<tr><td>"Elly"</td><td> "F"</td><td> 30</td><td> 66</td><td> 124</td></tr>
<tr><td>"Fran"</td><td> "F"</td><td> 33</td><td> 66</td><td> 115</td></tr>
<tr><td>"Gwen"</td><td> "F"</td><td> 26</td><td> 64</td><td> 121</td></tr>
<tr><td>"Hank"</td><td> "M"</td><td> 30</td><td> 71</td><td> 158</td></tr>
<tr><td>"Ivan"</td><td> "M"</td><td> 53</td><td> 72</td><td> 175</td></tr>
<tr><td>"Jake"</td><td> "M"</td><td> 32</td><td> 69</td><td> 143</td></tr>
<tr><td>"Kate"</td><td> "F"</td><td> 47</td><td> 69</td><td> 139</td></tr>
<tr><td>"Luke"</td><td> "M"</td><td> 34</td><td> 72</td><td> 163</td></tr>
<tr><td>"Myra"</td><td> "F"</td><td> 23</td><td> 62</td><td> 98</td></tr>
<tr><td>"Neil"</td><td> "M"</td><td> 36</td><td> 75</td><td> 160</td></tr>
<tr><td>"Omar"</td><td> "M"</td><td> 38</td><td> 70</td><td> 145</td></tr>
<tr><td>"Page"</td><td> "F"</td><td> 31</td><td> 67</td><td> 135</td></tr>
<tr><td>"Quin"</td><td> "M"</td><td> 29</td><td> 71</td><td> 176</td></tr>
<tr><td>"Ruth"</td><td> "F"</td><td> 28</td><td> 65</td><td> 131</td></tr>
</table>
</body>
</html>
43 changes: 43 additions & 0 deletions December-06/d6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import math

def isSquare(n):
rt = int(math.sqrt(n))
return rt*rt == n

def isFib(n):
return isSquare(5*n*n + 4) or isSquare(5*n*n - 4)

def generate(m):
if(m>9):
print('This leads to memory error')
return
primes = [True for i in range(10**7)]
primes[0] = primes[1] = False
n = len(primes)
count = 0
for i in range(2,n):
if(primes[i]):
if(isFib(i)):
print(i)
count += 1
if(count == m):
return
ind = 2
tmp = i*ind
while(tmp < n):
primes[tmp] = False
ind += 1
tmp = i*ind





n = int(input("Enter a number between 1-9:"))
generate(n)






50 changes: 50 additions & 0 deletions December-07/d7.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include<iostream>
#include<queue>

using namespace std;

class Person {
public:
int no;
char id;
void get() {
cout<<"\nEnter the token number & id:"<<endl;
cin>>no>>id;
}
void print() {
cout<<"\n("<<no<<","<<id<<")"<<endl;
}
};

int main() {
int n;
cout<<"\nEnter the # of patients:";
cin>>n;
queue<Person> ppl,tmp;
for(int i = 0; i < n; i++) {
Person tmp;
tmp.get();
ppl.push(tmp);
}
char k;
cout<<"\nEnter the id of k:";
cin>>k;
while(!ppl.empty()) {
Person top = ppl.front();
if(top.id == k) {
ppl.pop();
top.print();
while(!tmp.empty()) {
tmp.front().print();
tmp.pop();
}
} else {
tmp.push(top);
ppl.pop();
}
}
while(!tmp.empty()) {
tmp.front().print();
tmp.pop();
}
}
59 changes: 59 additions & 0 deletions December-08/d8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
def hasFront(arr,r,c,i,j):
if(i-1 >= 0):
return arr[i-1][j] == arr[i][j]
return False

def hasBack(arr,r,c,i,j):
if(i+1 < r):
return arr[i+1][j] == arr[i][j]
return False

def hasLR(arr,r,c,i,j):
if(j+1 < c):
if(arr[i][j+1] == arr[i][j]):
return True
if(j-1 >= 0):
if(arr[i][j-1] == arr[i][j]):
return True
return False

def hasDiagonal(arr,r,c,i,j):
if(i-1 >=0 and j-1 >=0):
if(arr[i-1][j-1] == arr[i][j]):
return True
if(i+1 < r and j+1 < c):
if(arr[i+1][j+1] == arr[i][j]):
return True
if(i-1 >=0 and j+1 < c):
if(arr[i-1][j+1] == arr[i][j]):
return True
if(i+1 < r and j-1 >= 0):
if(arr[i+1][j-1] == arr[i][j]):
return True
return False


r = int(input('Enter # of rows:'))
c = int(input('Enter # of columns:'))
print('-Enter the student arrangement-')
arr = []
for _ in range(r):
arr.append([e for e in input().split()])

result = []
for _ in range(r):
result.append([0.0 for i in range(c)])

for i in range(r):
for j in range(c):
if(hasFront(arr,r,c,i,j)):
result[i][j] += 0.3
if(hasBack(arr,r,c,i,j)):
result[i][j] += 0.2
if(hasLR(arr,r,c,i,j)):
result[i][j] += 0.2
if(hasDiagonal(arr,r,c,i,j)):
result[i][j] += 0.025

for e in result:
print(e)
21 changes: 21 additions & 0 deletions December-09/d9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def get(setn,no):
print('Enter the elements in set {}'.format(no))
setn.update([int(e) for e in input().split()])

def check(set1,set2,function):
set3 = set()
func = function.replace('x','{}')
func = func.replace('^','**')
for e in set1:
set3.add(int(eval(func.format(e))))
if(len(set1) == len(set3) and set3.issubset(set2)):
print('It is one-to-one function')
else:
print('It is not one-to-one function')

set1 = set()
set2 = set()
get(set1,1)
get(set2,2)
function = input('Enter the function use \'x\' as placeholder:')
check(set1,set2,function)
29 changes: 29 additions & 0 deletions December-10/d10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<iostream>
using namespace std;

int cookie_count(int n,int p,int c) {
int cookies = 0,freeCookies = 0,remaining = 0;
cookies += n/p;
freeCookies = cookies/c;
remaining = cookies%c;
do {
cookies += freeCookies;
int tmp = freeCookies;
freeCookies /= c;
remaining += tmp%c;
} while(freeCookies > 0);
cookies += remaining / c;
return cookies;
}

int main() {
int n,p,c;
cout<<"\nEnter the total cost:";
cin>>n;
cout<<"\nEnter the cost of a cookie:";
cin>>p;
cout<<"\nEnter # of jar required for a cookie:";
cin>>c;
cout<<endl<<cookie_count(n,p,c);
return 0;
}
14 changes: 14 additions & 0 deletions December-11/d11.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Day 11</title>
</head>
<body>
<form>
<label for="email">Enter the email address:</label>
<!--Done using regular expression-->
<input id="email" type="text" pattern="^[a-zA-Z0-9._-]+@[a-zA-Z]+\.com$" required/>
<input type="submit" value="Verifiy"/>
</form>
</body>
</html>
Loading