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
acf87d55
Commit
acf87d55
authored
Sep 18, 2020
by
Samarth Joshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing join function and using filter instead
parent
68f931f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
q2/main.py
q2/main.py
+20
-0
q2/output
q2/output
+5
-0
q2/q2.py
q2/q2.py
+5
-3
No files found.
q2/main.py
View file @
acf87d55
...
...
@@ -12,3 +12,23 @@ print(l)
L
=
[[
"this"
],[
"is"
],[
"the"
],[
"easiest"
],[
"problem"
],[
"of"
],[
"this"
],[
"outlab"
]]
l
=
collapse
(
L
)
print
(
l
)
L
=
[[
"this"
]]
l
=
collapse
(
L
)
print
(
l
)
L
=
[[],
[
"Once"
,
"upon"
,
"a"
,
"time"
],
[
"in"
,
"a"
,
"galaxy"
,
"far"
,
"far"
,
"away"
]]
l
=
collapse
(
L
)
print
(
l
)
L
=
[[
str
(
2
),
"+"
,
str
(
2
)],
[
'='
],
[
str
(
5
)]]
l
=
collapse
(
L
)
print
(
l
)
L
=
[[],[],[],[],[],[]]
l
=
collapse
(
L
)
print
(
l
)
L
=
[[
str
(
2
),
"+"
,
str
(
2
)],
[
'='
],
[
str
(
5
)]]
l
=
collapse
(
L
)
print
(
l
)
\ No newline at end of file
q2/output
View file @
acf87d55
this is an interesting python programming exercise.
this is a bad problem
this is the easiest problem of this outlab
this
Once upon a time in a galaxy far far away
2 + 2 = 5
2 + 2 = 5
\ No newline at end of file
q2/q2.py
View file @
acf87d55
import
functools
import
operator
def
collapse
(
L
)
:
flat
=
functools
.
reduce
(
lambda
x
,
y
:
operator
.
concat
(
x
,
y
),
L
)
return
" "
.
join
(
flat
)
flat
=
functools
.
reduce
(
lambda
x
,
y
:
x
+
y
,
L
)
if
flat
:
return
functools
.
reduce
(
lambda
x
,
y
:
x
+
" "
+
y
,
flat
)
else
:
return
""
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