How can I write a code to obtain the lowest values of each list within a list in python?

The name of the pictureThe name of the pictureThe name of the pictureClash 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)









share|improve this question









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.























    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)









    share|improve this question









    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.





















      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)









      share|improve this question









      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






      share|improve this question









      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.











      share|improve this question









      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.









      share|improve this question




      share|improve this question








      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.






















          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






          share|improve this answer





























            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)





            share|improve this answer


















            • 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

















            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.






            share|improve this answer




















            • 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










            • 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 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

















            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.






            share|improve this answer


















            • 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 using min and max.
              – 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










            Your Answer





            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            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






























            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






            share|improve this answer


























              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






              share|improve this answer
























                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






                share|improve this answer














                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







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 4 hours ago

























                answered 5 hours ago









                blhsing

                21.3k41032




                21.3k41032






















                    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)





                    share|improve this answer


















                    • 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














                    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)





                    share|improve this answer


















                    • 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












                    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)





                    share|improve this answer














                    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)






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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












                    • 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










                    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.






                    share|improve this answer




















                    • 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










                    • 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 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














                    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.






                    share|improve this answer




















                    • 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










                    • 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 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












                    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.






                    share|improve this answer












                    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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 4 hours ago









                    Heagon

                    312




                    312











                    • 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










                    • 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 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
















                    • 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










                    • 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 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















                    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










                    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.






                    share|improve this answer


















                    • 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 using min and max.
                      – 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














                    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.






                    share|improve this answer


















                    • 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 using min and max.
                      – 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












                    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.






                    share|improve this answer















                    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.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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 using min and max.
                      – 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




                      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 using min and max.
                      – 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










                    Tasdid Sarker is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    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.













                     


                    draft saved


                    draft discarded














                    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













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery