Python Forum
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check matrix...
#6
(Apr-13-2017, 07:59 AM)jkk30 Wrote: I stack in if  . What do I need to write there to control columns

def on_bingo_tabel(bingo):
    for i in range(len(bingo)):
        for j in range(len(bingo[i])):
            if ????????: 
                return False
            
    return True        
  
    
    
bingo = [[1, 30, 34, 55, 75], 
        [10, 16, 40, 50, 67], 
        [5, 20, 38, 48, 61], 
        [4, 26, 43, 49, 70], 
        [15, 17, 33, 51, 66]]  


ranges=[(1,15) ,(16,30),(31,45),(46,60),(61,75)]


print(on_bingo_tabel(bingo)) 

i-th element of line compared to the bounds from i-th element of ranges

The one-liner (don't put in your holework unless you really understand how it works):
def check(bingo):
    return any(any(not  minvalue <= actual <= maxvalue for actual,(minvalue,maxvalue) in zip(line,ranges)) for line in bingo)  
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Check matrix... - by jkk30 - Apr-12-2017, 04:45 AM
RE: Check matrix... - by micseydel - Apr-12-2017, 05:12 AM
RE: Check matrix... - by jkk30 - Apr-12-2017, 05:35 AM
RE: Check matrix... - by Ofnuts - Apr-12-2017, 08:02 AM
RE: Check matrix... - by jkk30 - Apr-13-2017, 07:59 AM
RE: Check matrix... - by Ofnuts - Apr-13-2017, 09:40 PM
RE: Check matrix... - by jkk30 - Apr-14-2017, 09:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  define a diagonal matrix from a matrix amalalaoui 1 2,370 May-15-2019, 01:12 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020