I'm not much good at these things.

It feels like you want to aim toward a tree of requirements, aiming to end
up with the variable that is required to be the smallest as the root node.

So, make a directed graph where each requirement is an edge.  Any cycles
can be collapsed down to a single edge, as if a <= b, b <= c and c <= a
then the only solution is a=b=c.

Then start with all variables set to 0 - this is always a valid solution
(any solution with all variables equal is valid).  You can freely increment
any variable that doesn't appear on the left of a requirement.  In the
given sample there are 2 such variables (4 and 5), so that's 100 solutions
with the first four variables each set to 0.

Now, if we increment to 0,0,0,1, the variable 4 must increment here too, as
it must not be less than variable 3.  That leaves us with a 'base' of
0,0,0,1,1,0, from which we can again freely increment 5 and 6, to get 90
more solutions.

Similarly, 0,0,0,2 gives 80 more, 0,0,0,3 gives 70 more, etc.

When we get to 0,0,1, we get a 'base' of 0,0,1,0,1,1 as we have the
requirements '4 isn't greater than 2' and '5 isn't greater than 2'.

When we finally get round to incrementing variable 0, we get a base of
1,1,1,1,1,1 as we have a chain of requirements that forces us to increment
every variable.

So I think the trick is to think of the N variables representing an N digit
number in base 10, and count upwards through the numbers, noting that
incrementing an 'earlier' digit may have implications on a later digit, as
in the above where incrementing digit 4 implied I had to also increment
digit 5.

I'm not quite sure how to generalise this into a program, but maybe it
gives someone the necessary leg-up :)

If you did have a cycle of requirements such that a <=b, b <=c and c <= a,
you know a, b, and c must always be equal, so put those digits next to each
other and simplify by removing the redundant digits?

Like I said, I'm not much good at these things.

Paul Smith

[email protected]


On Sun, Jan 20, 2013 at 5:36 PM, Luke Pebody <[email protected]> wrote:

> Wording. Content is interesting but I am not sure how to start on it.
>
>
>
> On 20 Jan 2013, at 16:28, paulmcq <[email protected]> wrote:
>
> I would assume that means "Report the answer modulo 1007" from someone for
> whom English is a second language.
>
> More importantly, are you objecting to the wording or to the content of
> the problem?
>
> On Saturday, January 19, 2013 10:38:06 AM UTC-6, Luke wrote:
>>
>> "Module the answer by 1007" is a new usage to me.
>>
>> I don't like it.
>>
>>
>>
>> On 19 Jan 2013, at 16:31, Hussein El-Sayed <[email protected]> wrote:
>>
>> Its is name is Requirement .. you can view it from this 
>> url<https://www.interviewstreet.com/challenges/dashboard/#problem/4f6db7f5a79f5>
>> .
>>
>>
>> On Sat, Jan 19, 2013 at 6:20 PM, Amir Hossein Sharifzadeh <
>> [email protected]> wrote:
>>
>>> Which problem?
>>>
>>> On Sat, Jan 19, 2013 at 8:57 AM, Hussein El-Sayed <[email protected]>wrote:
>>>
>>>> Hello,
>>>>
>>>> Can you please help me solving this problem?
>>>>
>>>> Thanks,
>>>> Hussein
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Google Code Jam" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to google-code...@**
>>>> googlegroups.com.
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Google Code Jam" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to google-code...@**
>>> googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to google-code...@**
>> googlegroups.com.
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-code/-/40y_zNXxDN4J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to