Facebook
From Perl Peccary, 5 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 184
  1. allPossibleSolutions = []
  2. def helper(arr, spotsTaken, ind):
  3.       if ind == len(arr):
  4.         return
  5.       for j in range(arr[ind][0], arr[ind][1]+1):
  6.         if j not in spotsTaken:
  7.             allPossibleSolutions.append(spotsTaken+[j])
  8.             helper(arr, spotsTaken+[j], ind+1)
  9.            
  10. def max_meetings(times):
  11.     helper(times, [], 0)
  12.     myMax = 0
  13.     for sol in allPossibleSolutions:
  14.         if len(sol) > myMax:
  15.             myMax = len(sol)
  16.     return myMax
  17.    
  18. ret = max_meetings([[2, 2], [4, 5], [4, 10], [5, 6], [5, 7], [6, 6]])

Replies to Untitled rss

Title Name Language When
Re: Untitled Emerald Pelican python 5 Years ago.