How can I write a code to obtain the lowest values of each list within a list in python?
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
I need help writing a code that will help me obtain the lowest number of the each list within a list in python. And then out of the lowest values obtained I must somehow find the highest number of the lowest numbers. I am not allowed to call the built-in functions min
or max
, or use any other functions from pre-written modules. How can I go about doing this? I have already tried using the following code:
for list in ells:
sort.list(ells)
python python-3.x
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
6
down vote
favorite
I need help writing a code that will help me obtain the lowest number of the each list within a list in python. And then out of the lowest values obtained I must somehow find the highest number of the lowest numbers. I am not allowed to call the built-in functions min
or max
, or use any other functions from pre-written modules. How can I go about doing this? I have already tried using the following code:
for list in ells:
sort.list(ells)
python python-3.x
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I need help writing a code that will help me obtain the lowest number of the each list within a list in python. And then out of the lowest values obtained I must somehow find the highest number of the lowest numbers. I am not allowed to call the built-in functions min
or max
, or use any other functions from pre-written modules. How can I go about doing this? I have already tried using the following code:
for list in ells:
sort.list(ells)
python python-3.x
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need help writing a code that will help me obtain the lowest number of the each list within a list in python. And then out of the lowest values obtained I must somehow find the highest number of the lowest numbers. I am not allowed to call the built-in functions min
or max
, or use any other functions from pre-written modules. How can I go about doing this? I have already tried using the following code:
for list in ells:
sort.list(ells)
python python-3.x
python python-3.x
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 4 hours ago
blhsing
21.3k41032
21.3k41032
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 5 hours ago
Tasdid Sarker
311
311
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Tasdid Sarker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
2
down vote
Since you are not allowed to use built-in functions, you can instead use a variable to keep track of the lowest number you find so far while you iterate through the sublists, and another to keep track of the highest of the lowest numbers you find so far you iterate through the list of lists:
l = [
[2, 5, 7],
[1, 3, 8],
[4, 6, 9]
]
highest_of_lowest = None
for sublist in l:
lowest = None
for item in sublist:
if lowest is None or lowest > item:
lowest = item
if highest_of_lowest is None or highest_of_lowest < lowest:
highest_of_lowest = lowest
print(highest_of_lowest)
This outputs: 4
add a comment |Â
up vote
2
down vote
You can iterate through your lists and compare to a variable, here using lo
, if the item is less than the current amount then assign that as the new lo
. After repeat the process but with hi
and opposite logic.
lst = [[1, 2, 3], [4, 5, 6,], [7, 8, 9]]
lows =
for i in lst:
lo = None
for j in i:
if lo == None: # to get initial lo
lo = j
elif j < lo:
lo = j
lows.append(lo)
hi = 0
for i in lows:
if i > hi:
hi = i
print(hi)
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
add a comment |Â
up vote
1
down vote
In my opinion the cleanest solution would be to write:
max([min(inner_list) for inner_list in list_of_lists])
But you said that you were not allowed to use built-in max and min. Well... Why don't we just implement them ourselfs? Here you go:
def min(iterable):
result = iterable[0]
for element in iterable:
if element < result:
result = element
return result
def max(iterable):
result = iterable[0]
for element in iterable:
if element > result:
result = element
return result
Now, that might not be the most robust min and max in the world (and they could sure use more code reuse), but they are short, clear, and will do just fine. Also this would keep the main line of code clear of loops, which make it more difficult to read your code.
And, as an added bonus (which you probably won't need here, but it is a good practice in software design)---your code would have some semblance of SRP, requiring you to only replace the max and min without ever touching the actual logic of your program.
Here is the full snippet.
The OP specifically says not to use themin
ormax
functions.
– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list beforemax
can start processing them. The cleanest solution would be to use a generator expression instead:max(min(inner_list) for inner_list in list_of_lists)
.
– blhsing
4 hours ago
 |Â
show 3 more comments
up vote
1
down vote
a=[6,4,5]
b=[8,3,9]
listab=[a,b]
sorted([sorted(x)[0] for x in listab])[-1]
Output > 4
You can do this for an arbitrary number of lists. This also avoids having to write your own min and max functions.
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of usingmin
andmax
.
– blhsing
4 hours ago
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Since you are not allowed to use built-in functions, you can instead use a variable to keep track of the lowest number you find so far while you iterate through the sublists, and another to keep track of the highest of the lowest numbers you find so far you iterate through the list of lists:
l = [
[2, 5, 7],
[1, 3, 8],
[4, 6, 9]
]
highest_of_lowest = None
for sublist in l:
lowest = None
for item in sublist:
if lowest is None or lowest > item:
lowest = item
if highest_of_lowest is None or highest_of_lowest < lowest:
highest_of_lowest = lowest
print(highest_of_lowest)
This outputs: 4
add a comment |Â
up vote
2
down vote
Since you are not allowed to use built-in functions, you can instead use a variable to keep track of the lowest number you find so far while you iterate through the sublists, and another to keep track of the highest of the lowest numbers you find so far you iterate through the list of lists:
l = [
[2, 5, 7],
[1, 3, 8],
[4, 6, 9]
]
highest_of_lowest = None
for sublist in l:
lowest = None
for item in sublist:
if lowest is None or lowest > item:
lowest = item
if highest_of_lowest is None or highest_of_lowest < lowest:
highest_of_lowest = lowest
print(highest_of_lowest)
This outputs: 4
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Since you are not allowed to use built-in functions, you can instead use a variable to keep track of the lowest number you find so far while you iterate through the sublists, and another to keep track of the highest of the lowest numbers you find so far you iterate through the list of lists:
l = [
[2, 5, 7],
[1, 3, 8],
[4, 6, 9]
]
highest_of_lowest = None
for sublist in l:
lowest = None
for item in sublist:
if lowest is None or lowest > item:
lowest = item
if highest_of_lowest is None or highest_of_lowest < lowest:
highest_of_lowest = lowest
print(highest_of_lowest)
This outputs: 4
Since you are not allowed to use built-in functions, you can instead use a variable to keep track of the lowest number you find so far while you iterate through the sublists, and another to keep track of the highest of the lowest numbers you find so far you iterate through the list of lists:
l = [
[2, 5, 7],
[1, 3, 8],
[4, 6, 9]
]
highest_of_lowest = None
for sublist in l:
lowest = None
for item in sublist:
if lowest is None or lowest > item:
lowest = item
if highest_of_lowest is None or highest_of_lowest < lowest:
highest_of_lowest = lowest
print(highest_of_lowest)
This outputs: 4
edited 4 hours ago
answered 5 hours ago
blhsing
21.3k41032
21.3k41032
add a comment |Â
add a comment |Â
up vote
2
down vote
You can iterate through your lists and compare to a variable, here using lo
, if the item is less than the current amount then assign that as the new lo
. After repeat the process but with hi
and opposite logic.
lst = [[1, 2, 3], [4, 5, 6,], [7, 8, 9]]
lows =
for i in lst:
lo = None
for j in i:
if lo == None: # to get initial lo
lo = j
elif j < lo:
lo = j
lows.append(lo)
hi = 0
for i in lows:
if i > hi:
hi = i
print(hi)
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
add a comment |Â
up vote
2
down vote
You can iterate through your lists and compare to a variable, here using lo
, if the item is less than the current amount then assign that as the new lo
. After repeat the process but with hi
and opposite logic.
lst = [[1, 2, 3], [4, 5, 6,], [7, 8, 9]]
lows =
for i in lst:
lo = None
for j in i:
if lo == None: # to get initial lo
lo = j
elif j < lo:
lo = j
lows.append(lo)
hi = 0
for i in lows:
if i > hi:
hi = i
print(hi)
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can iterate through your lists and compare to a variable, here using lo
, if the item is less than the current amount then assign that as the new lo
. After repeat the process but with hi
and opposite logic.
lst = [[1, 2, 3], [4, 5, 6,], [7, 8, 9]]
lows =
for i in lst:
lo = None
for j in i:
if lo == None: # to get initial lo
lo = j
elif j < lo:
lo = j
lows.append(lo)
hi = 0
for i in lows:
if i > hi:
hi = i
print(hi)
You can iterate through your lists and compare to a variable, here using lo
, if the item is less than the current amount then assign that as the new lo
. After repeat the process but with hi
and opposite logic.
lst = [[1, 2, 3], [4, 5, 6,], [7, 8, 9]]
lows =
for i in lst:
lo = None
for j in i:
if lo == None: # to get initial lo
lo = j
elif j < lo:
lo = j
lows.append(lo)
hi = 0
for i in lows:
if i > hi:
hi = i
print(hi)
edited 4 hours ago
answered 4 hours ago


vash_the_stampede
2,9401218
2,9401218
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
add a comment |Â
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
1
1
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
There's no maximum limit to Python's integers, so picking an arbitrary number assuming the numbers in the given lists will all be lower is not a safe assumption.
– blhsing
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing I know I was shortcutting, I knew it too when I posted will fix this sorry
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
@blhsing welp now my answer looks alot like yours not sure if its even needed :/
– vash_the_stampede
4 hours ago
1
1
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
That's fine. Just wanted to point out the potential issues.
– blhsing
4 hours ago
1
1
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
@blhsing appreciate it, ty for the lookout
– vash_the_stampede
4 hours ago
add a comment |Â
up vote
1
down vote
In my opinion the cleanest solution would be to write:
max([min(inner_list) for inner_list in list_of_lists])
But you said that you were not allowed to use built-in max and min. Well... Why don't we just implement them ourselfs? Here you go:
def min(iterable):
result = iterable[0]
for element in iterable:
if element < result:
result = element
return result
def max(iterable):
result = iterable[0]
for element in iterable:
if element > result:
result = element
return result
Now, that might not be the most robust min and max in the world (and they could sure use more code reuse), but they are short, clear, and will do just fine. Also this would keep the main line of code clear of loops, which make it more difficult to read your code.
And, as an added bonus (which you probably won't need here, but it is a good practice in software design)---your code would have some semblance of SRP, requiring you to only replace the max and min without ever touching the actual logic of your program.
Here is the full snippet.
The OP specifically says not to use themin
ormax
functions.
– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list beforemax
can start processing them. The cleanest solution would be to use a generator expression instead:max(min(inner_list) for inner_list in list_of_lists)
.
– blhsing
4 hours ago
 |Â
show 3 more comments
up vote
1
down vote
In my opinion the cleanest solution would be to write:
max([min(inner_list) for inner_list in list_of_lists])
But you said that you were not allowed to use built-in max and min. Well... Why don't we just implement them ourselfs? Here you go:
def min(iterable):
result = iterable[0]
for element in iterable:
if element < result:
result = element
return result
def max(iterable):
result = iterable[0]
for element in iterable:
if element > result:
result = element
return result
Now, that might not be the most robust min and max in the world (and they could sure use more code reuse), but they are short, clear, and will do just fine. Also this would keep the main line of code clear of loops, which make it more difficult to read your code.
And, as an added bonus (which you probably won't need here, but it is a good practice in software design)---your code would have some semblance of SRP, requiring you to only replace the max and min without ever touching the actual logic of your program.
Here is the full snippet.
The OP specifically says not to use themin
ormax
functions.
– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list beforemax
can start processing them. The cleanest solution would be to use a generator expression instead:max(min(inner_list) for inner_list in list_of_lists)
.
– blhsing
4 hours ago
 |Â
show 3 more comments
up vote
1
down vote
up vote
1
down vote
In my opinion the cleanest solution would be to write:
max([min(inner_list) for inner_list in list_of_lists])
But you said that you were not allowed to use built-in max and min. Well... Why don't we just implement them ourselfs? Here you go:
def min(iterable):
result = iterable[0]
for element in iterable:
if element < result:
result = element
return result
def max(iterable):
result = iterable[0]
for element in iterable:
if element > result:
result = element
return result
Now, that might not be the most robust min and max in the world (and they could sure use more code reuse), but they are short, clear, and will do just fine. Also this would keep the main line of code clear of loops, which make it more difficult to read your code.
And, as an added bonus (which you probably won't need here, but it is a good practice in software design)---your code would have some semblance of SRP, requiring you to only replace the max and min without ever touching the actual logic of your program.
Here is the full snippet.
In my opinion the cleanest solution would be to write:
max([min(inner_list) for inner_list in list_of_lists])
But you said that you were not allowed to use built-in max and min. Well... Why don't we just implement them ourselfs? Here you go:
def min(iterable):
result = iterable[0]
for element in iterable:
if element < result:
result = element
return result
def max(iterable):
result = iterable[0]
for element in iterable:
if element > result:
result = element
return result
Now, that might not be the most robust min and max in the world (and they could sure use more code reuse), but they are short, clear, and will do just fine. Also this would keep the main line of code clear of loops, which make it more difficult to read your code.
And, as an added bonus (which you probably won't need here, but it is a good practice in software design)---your code would have some semblance of SRP, requiring you to only replace the max and min without ever touching the actual logic of your program.
Here is the full snippet.
answered 4 hours ago


Heagon
312
312
The OP specifically says not to use themin
ormax
functions.
– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list beforemax
can start processing them. The cleanest solution would be to use a generator expression instead:max(min(inner_list) for inner_list in list_of_lists)
.
– blhsing
4 hours ago
 |Â
show 3 more comments
The OP specifically says not to use themin
ormax
functions.
– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list beforemax
can start processing them. The cleanest solution would be to use a generator expression instead:max(min(inner_list) for inner_list in list_of_lists)
.
– blhsing
4 hours ago
The OP specifically says not to use the
min
or max
functions.– blhsing
4 hours ago
The OP specifically says not to use the
min
or max
functions.– blhsing
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
@blhsing "I am not allowed to call the built-in functions min or max". Which is why I implement them myself.
– Heagon
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
Oops sorry my bad. Did not read beyond your first line. :-)
– blhsing
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
@blhsing No problem :D
– Heagon
4 hours ago
Using list comprehension would require materializing the items in the inner list before
max
can start processing them. The cleanest solution would be to use a generator expression instead: max(min(inner_list) for inner_list in list_of_lists)
.– blhsing
4 hours ago
Using list comprehension would require materializing the items in the inner list before
max
can start processing them. The cleanest solution would be to use a generator expression instead: max(min(inner_list) for inner_list in list_of_lists)
.– blhsing
4 hours ago
 |Â
show 3 more comments
up vote
1
down vote
a=[6,4,5]
b=[8,3,9]
listab=[a,b]
sorted([sorted(x)[0] for x in listab])[-1]
Output > 4
You can do this for an arbitrary number of lists. This also avoids having to write your own min and max functions.
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of usingmin
andmax
.
– blhsing
4 hours ago
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
add a comment |Â
up vote
1
down vote
a=[6,4,5]
b=[8,3,9]
listab=[a,b]
sorted([sorted(x)[0] for x in listab])[-1]
Output > 4
You can do this for an arbitrary number of lists. This also avoids having to write your own min and max functions.
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of usingmin
andmax
.
– blhsing
4 hours ago
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
a=[6,4,5]
b=[8,3,9]
listab=[a,b]
sorted([sorted(x)[0] for x in listab])[-1]
Output > 4
You can do this for an arbitrary number of lists. This also avoids having to write your own min and max functions.
a=[6,4,5]
b=[8,3,9]
listab=[a,b]
sorted([sorted(x)[0] for x in listab])[-1]
Output > 4
You can do this for an arbitrary number of lists. This also avoids having to write your own min and max functions.
edited 4 hours ago
answered 4 hours ago
Arjun Venkatraman
317
317
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of usingmin
andmax
.
– blhsing
4 hours ago
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
add a comment |Â
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of usingmin
andmax
.
– blhsing
4 hours ago
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
1
1
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
Sorting requires an average time complexity of O(n log n), while finding minimum or maximum should require only O(n).
– blhsing
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
True, and by that token @Heagon's first line should do it. However the problem states that the built in min and max should not be used.
– Arjun Venkatraman
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of using
min
and max
.– blhsing
4 hours ago
Yes, so you should implement finding minimum and maximum through loops instead of using
min
and max
.– blhsing
4 hours ago
1
1
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Well, IMHO, since the problem makes no comment about efficiency, I would shoot for fewer lines of code. I'll let the asker pick their route! But thank you for your input, I'm not the most resource economical programmer around!
– Arjun Venkatraman
4 hours ago
Fair enough then.
– blhsing
4 hours ago
Fair enough then.
– blhsing
4 hours ago
add a comment |Â
Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.
Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.
Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.
Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52789176%2fhow-can-i-write-a-code-to-obtain-the-lowest-values-of-each-list-within-a-list-in%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password