I'm not even sure how this program is expected to work, but part of the
difficulty of this problem is that there are many solutions for most
possible inputs and you need to come up with an algorithm that gives you a
good one quickly. But consider the output you get from this input:
2
6 13
6 12



On Wed, May 11, 2016 at 2:36 AM, Aditya S <sirna.adi...@gmail.com> wrote:

> I have tried solving the above problem "Slides" and few of my test cases
> are failing and I got 2 wrong attempts. I tried to figure out which test
> case was failing but couldn't identify. Below attached is my code for the
> above problem. I am sure that it times out for Large input but can you
> please help me to identify which test case is failing for Small input and
> the reason
>
>
>
>
> import itertools
>
> def get_combs(lst):
>     combs = []
>     for i in xrange(1, len(lst)+1):
>         els = [list(x) for x in itertools.combinations(lst, i)]
>         combs.extend(els)
>     return combs
>
> def find(buildings,ways):
>
>     ans = ['0']*buildings
>     for i in range(buildings):
>         ans[i] = ['0']*buildings
>     if (1<<(buildings-2)) < ways:
>         print "IMPOSSIBLE"
>     else:
>         combs = get_combs(range(1,buildings+1))
>         for i in range(len(combs)-1,-1,-1):
>             if 1 in combs[i] and buildings in combs[i]:
>                 for j in range(len(combs[i])-1):
>                     ans[combs[i][j]-1][combs[i][j+1]-1] = '1'
>                 ways -=1
>             if ways == 0:
>                 print "POSSIBLE"
>                 for xx in range(buildings):
>                     print "".join(ans[xx])
>                 break
>
> for i in range(1,input()+1):
>
>     buildings,time = map(int,raw_input().split())
>     print "Case #{0}:".format(i),
>     find(buildings,time)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/cf15582b-3848-460e-a49b-932d4294d109%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAMAzhzh9AbjOptO7jJ0nH5Dsnfae%3DGEBCA1RjWpR_J3p1qVS-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to