fork download
  1. import random
  2.  
  3. n, m = 10, 5
  4. x = '3'
  5.  
  6. b = [[random.randint(20, 40) for _ in range(n)] for _ in range(m)]
  7. print(*b, sep='\n')
  8.  
  9. result = sum(1 if (sum(1 for val in row if str(val)[0] == x) < n//2) else 0 for row in b)
  10. print(result)
Success #stdin #stdout 0.04s 9892KB
stdin
Standard input is empty
stdout
[32, 25, 38, 40, 20, 27, 21, 32, 40, 39]
[34, 29, 32, 39, 25, 25, 38, 36, 33, 40]
[23, 21, 23, 38, 39, 40, 24, 32, 21, 27]
[36, 36, 25, 30, 37, 40, 32, 29, 27, 26]
[39, 24, 31, 21, 38, 39, 33, 37, 20, 39]
2