Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SpartanBotsOutlab67
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roshan Rabinarayan
SpartanBotsOutlab67
Commits
dd98cd52
Commit
dd98cd52
authored
Sep 30, 2020
by
Samarth Joshi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.cse.iitb.ac.in/sroshan/SpartanBotsOutlab67
parents
db898502
74dcc2fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
42 deletions
+16
-42
q1/triwizard.py
q1/triwizard.py
+16
-42
No files found.
q1/triwizard.py
View file @
dd98cd52
...
...
@@ -40,40 +40,47 @@ def avada_kedavra(my_list):
# 'my_integer': an even integer
def
incendio
(
my_integer
):
# create an array 'arng0' of shape (3,2) containing consecutive even numbers starting from 'my_integer', arranged along rows
#my_integer=4
arng0
=
np
.
arange
(
my_integer
,
my_integer
+
12
,
2
)
arng0
=
arng0
.
reshape
(
3
,
2
)
# print arng0
print
(
"arng0
\n
{}"
.
format
(
arng0
))
# create another array 'arng1' of shape ((4,3)) containing consecutive numbers starting from 'my_integer' arranged along columns:
arng1
=
np
.
arange
(
my_integer
,
my_integer
+
12
,
1
)
arng1
=
arng1
.
reshape
(
3
,
4
)
arng1
=
np
.
transpose
(
arng1
)
# print arng1
print
(
"arng1
\n
{}"
.
format
(
arng1
))
# multiply transpose of arng0 with transpose of arng1 to get mult0:
mult0
=
np
.
transpose
(
arng0
)
.
dot
(
np
.
transpose
(
arng1
))
# print mult0:
print
(
"mult0
\n
{}"
.
format
(
mult0
))
# take min of mult0 along its rows and store it in v0:
v0
=
mult0
.
min
(
axis
=
1
)
# print v0's shape:
print
(
"shape of v0:
\n
{}"
.
format
(
v0
.
shape
))
# reshape v0 to make it a column vector:
v0
=
v0
.
reshape
(
2
,
1
)
# subtract v0 from each column of mult0 and store it in base0:
base0
=
mult0
-
v0
# print base0
print
(
"base0
\n
{}"
.
format
(
base0
))
# square all the elements present in base0
base0
=
base0
*
base0
# store the sum of all elements of base0 in ans
ans
=
np
.
cumsum
(
base0
)
# print ans
ans
=
np
.
sum
(
ans
)
print
(
"ans : {}"
.
format
(
ans
))
# ---- Task (c) -------
# 'n': integer
# 'm': integer that divides n
...
...
@@ -114,39 +121,6 @@ def leviosa(arr, k):
# return type: n-D integer array; dim: (m,k)
def
accio
(
mat
,
k
):
pass
'''#test crucio
arr =np.array([[0 ,0, 0],[1, 1, 1],[2, -3, 5],[-4, 0, 3]])
print(crucio(arr))
'''
'''#test avada_kedavra
my_integer=random.sample(range(1,101), 25)
a0=np.array(my_integer)
# print a0
print("a0 at beginning:
\n
{}".format(a0))
# reshape a0 to create a 5X5 matrix a1
a1=a0.reshape(5,5)
# print a1
print("a1 at the beginning:
\n
{}".format(a1))
# now, change the central element of a1 to 0
a1[2][2]=0
# print a1
print("a1 after change:
\n
{}".format(a1))
# print a0
print("a0 after changing a1:
\n
{}".format(a0))
print("reshaping doesn't create a copy of array. It just returns another view. So, changing one changed the other")
# make a copy of a1 and flatten it (call it a1cpy)
a1cpy=a1.copy()
# multiply each element of a1cpy by 0.7:
a1cpy=np.round(np.multiply(a1cpy,0.7),2)
# print a1cpy:
print("a1cpy
\n
{}".format(a1cpy))
# print a1:
print("a1 after changing its copy:
\n
{}".format(a1))
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment