09_kontrola - ocena 10_2
This commit is contained in:
		
							parent
							
								
									7652318932
								
							
						
					
					
						commit
						261eca0fe5
					
				@ -156,14 +156,13 @@ def najboljsa_cetrt(a: int, zemljevid: list[str]):
 | 
			
		||||
 | 
			
		||||
def dosegljive(x, y, max_d, max_n, zemljevid):
 | 
			
		||||
    def dosegljive_r(x, y, n, prepovedani):
 | 
			
		||||
 | 
			
		||||
        if zemljevid[y][x] == "*":
 | 
			
		||||
            n = max_n
 | 
			
		||||
        else:
 | 
			
		||||
            if n == 0:
 | 
			
		||||
                return set()
 | 
			
		||||
            prepovedani.add((x, y))
 | 
			
		||||
 | 
			
		||||
        points = set()
 | 
			
		||||
        prepovedani = prepovedani.copy()
 | 
			
		||||
 | 
			
		||||
        accessible = set()
 | 
			
		||||
        for d in range(1, max_d + 1):
 | 
			
		||||
@ -182,7 +181,13 @@ def dosegljive(x, y, max_d, max_n, zemljevid):
 | 
			
		||||
                    ry_inc = -1
 | 
			
		||||
                ry += ry_inc
 | 
			
		||||
 | 
			
		||||
        points.update(accessible)
 | 
			
		||||
        if n == 0:
 | 
			
		||||
            if any(zemljevid[y][x] == "*" for x, y in accessible):
 | 
			
		||||
                accessible = {(x, y) for x, y in accessible if zemljevid[y][x] == "*"}
 | 
			
		||||
            else:
 | 
			
		||||
                return set()
 | 
			
		||||
 | 
			
		||||
        points = set(accessible)
 | 
			
		||||
        for x, y in accessible:
 | 
			
		||||
            points.update(dosegljive_r(x, y, n - 1, prepovedani))
 | 
			
		||||
        return points
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user