<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I did find a better solution but it’s still slow<div class=""><br class=""></div><div class=""><div style="font-size: 15px;" class="">let cities = 6</div><div style="font-size: 15px;" class="">let clinics = 10</div><div style="font-size: 15px;" class=""><div class="">let populations = [1,10000,2,3,400,1]</div><div class="">let nparts n k = filter ((==n) . sum)  $ replicateM k [1..n]</div><div class="">let d2 = nparts clinics cities</div><div class="">let d1 = map maximum (map (\x -> zipWith (/) populations (map (\n-> fromIntegral n) x)) $ d2)</div></div><div style="font-size: 15px;" class=""><div style="font-family: -apple-system-font; line-height: 20px;" class="">maximum $ zipWith (\n x -> (n `div` x) + (n `mod` x) ) populations $ d2 !! (head $ filter ((==minimum d1) . (d1 !!)) [0..])</div><div class=""><br class=""></div><div class="">here also nparts take time….if we choose clinics > 10</div><div class=""><br class=""></div><div class="">Heres the problem statement</div><div class=""><br class=""></div><div class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">The World Health Organization (WHO) wants to establish a total of B</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">vaccination clinics across Ncities to immunization people against</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">fatal diseases. Every city must have at least 1 clinic, and a clinic</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">can only vaccinate people in the same city where they live. The goal</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">is to minimize the number of vaccination kits needed in the largest</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">clinic. For example, suppose you have:</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">2 cities and</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">7 clinics to be opened.</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">If 200,000 is the population of the first city and</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">500,000 is the population of the second city, then</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">two clinics can open in the first city and</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">five in the second. This way,</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">100,000 people can be immunized in each of the two clinics in the</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">first city, and</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">100,000 can be immunized in each clinic in the second city.</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">So the maximum number of people to be immunized in the largest clinic is 100,000</span><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""><br style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;" class=""></div><div class=""><br class=""></div><div class="">-Animesh</div><div class=""><br class=""></div></div><div><blockquote type="cite" class=""><div class="">On Apr 27, 2015, at 10:19 PM, Ertugrul Söylemez <<a href="mailto:ertesx@gmx.de" class="">ertesx@gmx.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">as 20, because it finds 2^19 partitionings.  You need to eliminate</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><br class=""></div></body></html>