Puzzle on Probability of 7 people being seen or ignored - puzzle

I have a question.
Suppose i have 7 people sitting next to each other.
A B C D E F G
When i say "look", the people can either look towards their right or left.
The Question is :
- What is the probability that "A" and "G" could be ignored?
- What is the probability that each Person can be either ignored or looked.
I found it too confusing.
Can anyone help?
Thanks and Good day.

A is ignored if everyone looks to the right, so probability is 0.5^5, same answer for G...

Related

Solve for q: (log(n))^q = log(log(n))

I'm proving the big O runtime of an algorithm for an assignment but am unfortunately quite rusty when it comes to logs. Currently, I have:
(log(n))^q <= log(log(n))
I am trying to isolate q in terms of n (where I'm hoping n will cancel out). Can someone please explain to me how to do this (and not just provide an answer)? Thanks!
This would've been prettier on math stackexchange (because we can use latex), but you can just log both sides to bring the q exponent down (since log(x^n) = nlog(x) is a property of logs over the reals):
q log(log(n)) <= log(log(log(n)))
Now you can divide both sides to isolate q:
q <= log(log(log(n)))/log(log(n))

Running at the same time 2 algorithms that designed to solve the mutual-exclusion

Question I saw on site that explains the issue of mutual-exclusion (http://www.faculty.idc.ac.il/gadi/PPTs/Chapter2-Mutex-BasicTopics.pptx - page 8). Unfortunately there is no answer. Also, the original question is only about C but I didn't understand If the order is changing how it affects the result, so I added D.
Let A and B be two algorithms designed to solve the mutual-exclusion problem. In other words, their structure consists of an entry-section, critical-section and exit-section (but you cannot assume they satisfy mutual-exclusion or deadlock-freedom unless written otherwise). Assume that algorithms A and B do not use the same variables. We construct a new mutual-excusion algorithm, C, as follows:
Algorithm C
entry code of A
entry code of B
Critical Section
exit code of B
exit code of A
For each of the following assertions, please prove or disprove its correctness.
If both A and B are deadlock-free, C is deadlock-free.
If both A and B are starvation-free, C is starvation-free.
If A or B satisfy mutual-exclusion, C satisfies mutual-exclusion.
If A is deadlock-free and B is starvation-free, C is starvation-free.
If A is starvation-free and B is deadlock-free, C is starvation-free.
Also that same questions, but this time on D instead of C, where D is:
Algorithm D
entry code of A
entry code of B
Critical Section
exit code of A
exit code of B
Thanks!

cgal corefinement demo : cutting mesh A surface with mesh B, then remove A in B

I posted some time ago a CGAL question that was kindly answered by pointing to the Polyhedron demo and the corefinement plugin. The basic idea being that one open polyhedron A is cut by another open polyhedron B, and I need the list of intersection half edges owned by A, or better, A minus the part of A in B.
The co-refinement demo does this, but I want to select, as a result, all parts of A not in B. This does not match the available predicates in the demo (A - B (leaves parts of B inside A) , B - A (leaves parts of B outside A), A inter B, A union B). I tried combining/modifying them to get what I want but I must be missing something. The information on the 'darts' seem to be mutually exclusive.
The picture below illustrates this : A as been cut by B (I have a hole with the shape of B) but some parts of B are still in A (the facets on the hole border).
(edit : sorry : not enough reputation to post an image here :-()
Any advices on how to write a predicate that would select only A with a hole, and leave out any face coming from B?
Thank you!

Understanding Google Code Jam 2013 - X Marks the Spot

I was trying to solve Google Code Jam problems and there is one of them that I don't understand. Here is the question (World Finals 2013 - problem C): https://code.google.com/codejam/contest/2437491/dashboard#s=p2&a=2
And here follows the problem analysis: https://code.google.com/codejam/contest/2437491/dashboard#s=a&a=2
I don't understand why we can use binary search. In order to use binary search the elements have to be sorted. In order words: for a given element e, we can't have any element less than e at its right side. But that is not the case in this problem. Let me give you an example:
Suppose we do what the analysis tells us to do: we start with a left bound angle of 90° and a right bound angle of 0°. Our first search will be at angle of 45°. Suppose we find that, for this angle, X < N. In this case, the analysis tells us to make our left bound 45°. At this point, we can have discarded a viable solution (at, let's say, 75°) and at the same time there can be no more solutions between 0° and 45°, leading us to say that there's no solution (wrongly).
I don't think Google's solution is wrong =P. But I can't figure out why we can use a binary search in this case. Anyone knows?
I don't understand why we can use binary search. In order to use
binary search the elements have to be sorted. In order words: for a
given element e, we can't have any element less than e at its right
side. But that is not the case in this problem.
A binary search works in this case because:
the values vary by at most 1
we only need to find one solution, not all of them
the first and last value straddle the desired value (X .. N .. 2N-X)
I don't quite follow your counter-example, but here's an example of a binary search on a sequence with the above constraints. Looking for 3:
1 2 1 1 2 3 2 3 4 5 4 4 3 3 4 5 4 4
[ ]
[ ]
[ ]
[ ]
*
I have read the problem and in the meantime thought about the solution. When I read the solution I have seen that they have mostly done the same as I would have, however, I did not thought about some minor optimizations they were using, as I was still digesting the task.
Solution:
Step1: They choose a median so that each of the line splits the set into half, therefore there will be two provinces having x mines, while the other two provinces will have N - x mines, respectively, because the two lines each split the set into half and
2 * x + 2 * (2 * N - x) = 2 * x + 4 * N - 2 * x = 4 * N.
If x = N, then we were lucky and accidentally found a solution.
Step2: They are taking advantage of the "fact" that no three lines are collinear. I believe they are wrong, as the task did not tell us this is the case and they have taken advantage of this "fact", because they assumed that the task is solvable, however, in the task they were clearly asking us to tell them if the task is impossible with the current input. I believe this part is smelly. However, the task is not necessarily solvable, not to mention the fact that there might be a solution even for the case when three mines are collinear.
Thus, somewhere in between X had to be exactly equal to N!
Not true either, as they have stated in the task that
You should output IMPOSSIBLE instead if there is no good placement of
borders.
Step 3: They are still using the "fact" described as un-true in the previous step.
So let us close the book and think ourselves. Their solution is not bad, but they assume something which is not necessarily true. I believe them that all their inputs contained mines corresponding to their assumption, but this is not necessarily the case, as the task did not clearly state this and I can easily create a solvable input having three collinear mines.
Their idea for median choice is correct, so we must follow this procedure, the problem gets more complicated if we do not do this step. Now, we could search for a solution by modifying the angle until we find a solution or reach the border of the period (this was my idea initially). However, we know which provinces have too much mines and which provinces do not have enough mines. Also, we know that the period is pi/2 or, in other terms 90 degrees, because if we move alpha by pi/2 into either positive (counter-clockwise) or negative (clockwise) direction, then we have the same problem, but each child gets a different province, which is irrelevant from our point of view, they will still be rivals, I guess, but this does not concern us.
Now, we try and see what happens if we rotate the lines by pi/4. We will see that some mines might have changed borders. We have either not reached a solution yet, or have gone too far and poor provinces became rich and rich provinces became poor. In either case we know in which half the solution should be, so we rotate back/forward by pi/8. Then, with the same logic, by pi/16, until we have found a solution or there is no solution.
Back to the question, we cannot arrive into the situation described by you, because if there was a valid solution at 75 degrees, then we would see that we have not rotated the lines enough by rotating only 45 degrees, because then based on the number of mines which have changed borders we would be able to determine the right angle-interval. Remember, that we have two rich provinces and two poor provinces. Each rich provinces have two poor bordering provinces and vice-versa. So, the poor provinces should gain mines and the rich provinces should lose mines. If, when rotating by 45 degrees we see that the poor provinces did not get enough mines, then we will choose to rotate more until we see they have gained enough mines. If they have gained too many mines, then we change direction.

RSA algorthum calculations

I have been working though a network book and hit the RSA section.
Consider the RSA algorithm with p=5 and q=11.
so I get N = p*q = 55 right?
and z = (p-1) * (q -1) = 40
I think I got this right but the book is not very clear on how to calculate this.
The example in the book says that e = 3 but does not give a reason why. Because the author likes it or is there another reason?
and how do i go about finding d so that de= 1(mod z) and d < 160
Thanks for any help with this its a bit above me right now.
Your calculations of n and z are correct.
An RSA cryptosystem consists of three variables n, d and e. Variable e is the least important of the three, and is usually chosen arbitrarily to make computations simple; 3 and 65537 are the most common choices for e. The only requirements are that e is odd and co-prime to the totient (z in your implementation); thus e is frequently chosen prime so that it will be co-prime to the totient no matter what totient is chosen. The reason that 3 and 65537 are frequently used for e is because it makes the computation easy; both numbers have only two 1-bits in their binary representation, so only two iterations of a complicated loop are needed.
You can see an implementation of an RSA cryptosystem at my blog. If you poke around there, you will also find some other crypto-related stuff that may interest you.
what you are looking for is the extended euclidean algorithm
for an example see wikipedia or here