Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SpartanBots
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
SpartanBots
Commits
d9980a5f
Commit
d9980a5f
authored
Sep 19, 2020
by
Samarth Joshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Koi review karo ise, poora time isme hi gya
parent
acf87d55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
q4/q4.py
q4/q4.py
+32
-2
No files found.
q4/q4.py
View file @
d9980a5f
import
itertools
as
it
#
import operator as op
import
operator
as
op
""" def myFunc(deg, vals, coeffs):
for index in it.count():
if index > deg:
break
key = "x*" * (deg-index) + "y*" * (index) """
def
myFunc
(
deg
,
vals
,
coeffs
):
## write your code here
\ No newline at end of file
list1
=
it
.
combinations_with_replacement
(
vals
,
deg
)
list2
=
it
.
combinations_with_replacement
(
'xy'
,
deg
)
list3
=
it
.
zip_longest
(
coeffs
,
list1
,
list2
)
for
coeff
,
values
,
keys
in
list3
:
values_c
=
it
.
chain
([
coeff
],
values
)
accv
=
it
.
accumulate
(
values_c
,
op
.
mul
)
sliced_value
=
it
.
islice
(
accv
,
deg
,
deg
+
1
)
keys_c
=
it
.
accumulate
(
keys
,
lambda
x
,
y
:
x
+
"*"
+
y
)
sliced_key
=
it
.
islice
(
keys_c
,
deg
-
1
,
deg
)
merge
=
it
.
zip_longest
(
sliced_key
,
sliced_value
)
result
=
it
.
starmap
(
lambda
x
,
y
:
x
+
" --> "
+
str
(
y
),
merge
)
yield
from
result
""" deg = 7
vals = [2,3]
coeffs = [4, 3, 5, 9, 3, 7, 2, 5]
gen = myFunc(deg, vals, coeffs)
for i in gen:
print(i) """
\ No newline at end of file
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