Commit 1a2f6eea authored by chaitanyavarma's avatar chaitanyavarma

Out lab submission

parents
from functools import reduce
def Fib(n):
## write your code here
arr = range(2, n + 1)
return list(
filter(lambda k: k not in reduce(lambda t1, t2: t1 + t2, map(lambda x: list(range(2 * x, n + 1, x)), arr)),
arr))
\ No newline at end of file
from q2 import collapse
L = [["this","is"],["an","interesting","python"],["programming","exercise."]]
l=collapse(L)
print(l)
L = [["this","is","a","bad","problem"]]
l=collapse(L)
print(l)
L = [["this"],["is"],["the"],["easiest"],["problem"],["of"],["this"],["outlab"]]
l=collapse(L)
print(l)
this is an interesting python programming exercise.
this is a bad problem
this is the easiest problem of this outlab
from functools import reduce
def collapse(L):
return reduce(lambda x, y: x + " " + y, map(lambda x: reduce(lambda t1, t2: t1 + " " + t2, x), L))
rm -f tempout
rm -f dump
python3 main.py > tempout 2> dump
diff -Z tempout output > result
if [[ -s result ]];
then
echo "failed"
else
echo "passed"
fi
rm -f result dump tempout
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
import numpy as np
import matplotlib.pyplot as plt
import os
cwd = os.getcwd()
filetoread = open(cwd + "/csv_file", 'r')
lines = filetoread.readlines()
xcords = []
ycords = []
zcords = []
for line in lines:
coords = line[:-1].split(",")
xcords.append(float(coords[0]))
ycords.append(float(coords[1]))
zcords.append(float(coords[2]))
fig = plt.figure(figsize=(12, 12))
ax = plt.axes(projection='3d')
ax.grid(False)
ax.xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.zaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
xarr = np.array(xcords)
yarr = np.array(ycords)
zarr = np.array(zcords)
scatter = ax.scatter3D(xarr, yarr, zarr, c=(xarr + yarr + zarr), cmap=plt.get_cmap("coolwarm"))
ax.set_xlabel('X axis', fontweight='bold')
ax.set_ylabel('Y axis', fontweight='bold')
ax.set_zlabel('Z axis', fontweight='bold')
fig.colorbar(scatter, ax=ax, shrink=0.5)
plt.savefig("q3plot.jpg", bbox_inches='tight')
import itertools as it
# import operator as op
def myFunc(deg, vals, coeffs):
## write your code here
\ No newline at end of file
class BlackMoneyHolder:
## write your code here
\ No newline at end of file
python3 q7.py testcase/input.txt > out
diff -Z testcase/output.txt out > result
if [[ -s result ]];
then
echo failed
else
echo passed
fi
rm out result
\ No newline at end of file
2
12 60 60 1 0 0
10 6 7 1 3 2
\ No newline at end of file
import sys
import os
from collections import OrderedDict
def func():
cwd = os.getcwd()
filepath = sys.argv[1]
filetoread = open(cwd + "/" + filepath, 'r')
namesline = filetoread.readline()
namesList = namesline.split(" ")
namegiftdict = OrderedDict()
for name in namesList:
if name not in namegiftdict.keys():
namegiftdict[name] = 1
else:
namegiftdict[name] += 1
sortedDict = sorted(namegiftdict.items(), key=lambda x: x[1], reverse=True)
print(sortedDict[0][0])
func()
Shubham Mohit Binod Dinesh Salman Shubham Debabrata Jalay Salman Binod Dharmendra Salman Binod Shubham Binod Avijit Binod Amit Binod Ajay Arun Arjun Guru Fenil Aditya
\ No newline at end of file
piyush kanda(203050017 - piyushkanda) - Problem 1,2
chaitanya varma(203050026 - chaitanyavarma) - Problem 1,3,8
Git Link
https://git.cse.iitb.ac.in/chaitanyavarma/outlab_lab5
references
https://www.geeksforgeeks.org/3d-scatter-plotting-in-python-using-matplotlib/
https://stackoverflow.com/questions/44001613/matplotlip-3d-surface-plot-turn-off-background-but-keep-axes
https://www.learnpython.org/en/Map,_Filter,_Reduce
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment