Puzzle from Ecole 42 evaluation [closed] - puzzle

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
Improve this question
This is Evaluation game 2 for Ecole 42. I'm stuck with this one in my mind. Is there any solution or suggestion for this one?

f0 - {if red turn right / forward / if blue f1 / f0 }
f1 - {forward /if red turn left / if blue f0 / f1}

I got stuck in this one too. I wonder if this could be a good solution, but can't test it...
f0 - {if red turn left / forward / if blue f1 / f0 }
f1 - {forward /if red turn right / if blue f0 / f1}
like a zig-zag and the blue box do the shift of the turn side...

Related

How can I create a more elegant array diagram in LabVIEW? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I want the LEDs to light up in the following order:
station A - w - w2 - station B - w2 - w3 - w4 - station C -w4 - w5 - station D - w5 - w4 - w3 - station E - w3 - w2 - w - station A
and this is repeated.
I started giving a false value to the leds that can't be lit in that case but I didn't continue after the fourth. Does anyone have any idea how this could be solved more elegantly?
What you really want is a Simple State Machine.
These are a recommended early design pattern from NI and allow you to do the kind of sequential operation you are after while allowing for more dynamic responsiveness to inputs.
This allows you to do a bunch of different things like:
Not need all those off/on local variables
Have a single timer running for consistent operation time
The ability to interrupt the sequence at any step
Significantly simplified extension of the process.
Something like this:

nCr mod 10^9 + 7 for n<=10^9 and r <=1000 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
This may have been asked before but none of the answers I saw worked for me. I tried Lucas Theorem,Fermat's theorem but none of them worked. Is there an efficient way to find the value of:
nCr mod 10^9+7 where n<=10^9 and r<=1000
Any help will be very useful
n is large while r is small, you are better off compute nCr by n(n-1)...(n-r+1)/(1*2*...*r)
You may need to find multiplicate inverse of 1, 2, ... r mod 10^9+7

automata theorem: existance of a DFA [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I need to prove that for every k, there's a DFA M with k+2 states, so in every automat M' who accepts the language reverse(L(M)) there are at least 2^k states.
Help would be really appreciated.
Thanks :)
Assuming that the alphabet set contains at least two elements, let it be {0,1}.
Next, let M be the automata accepting the language L defined as:
All the strings which k-th position is 1
defined as:
M = {Q,{0,1},q0,{qk+1},δ}, where
Q={q0,q1,...,qk,qF}
δ(qi,a) = qi+1, for a in {0,1} and i=0,1,...,k-2
δ(qk-1,0) = qF,
δ(qk-1,1) = qk,
δ(qF,a) = qF, for a in {0,1}
Note that M has exactly k+2 states, and that it accepts the language L.
Now, note that the language reverse(L(M)) can be translated as:
All the strings which k-th position from the end is 1
To recognize that language, note that we need to remember the last k symbols, because we don't know when the string will end. We know that there are at least 2k possible strings of length k (since the alphabet size is at least 2).
So using a DFA, we need at least 2k states, each to represent one possible string of length k. ▢
Author's note:
The idea of this proof is to find a language which is "easy" to be recognized in normal way, but "difficult" when is read backward. Through experience, I remember that fixing the k-th position from the beginning is "easy", while k-th position from the end is "difficult", hence my answer.

"Search within distance" API for OpenStreetMap [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there any API for OpenStreetMap which allows me to obtain a list of POIs within a certain distance (e.g. 10 miles) from a reference location?
As far as I know, the API doesn't support this directly. The simplest approach is to select a (quasi-)rectangular bounding box that your circle fits into, and use this to retrieve your POIs. Then you can do a distance calculation to each point of interest, and discard those that exceed your radius. This will remove the small fraction of POIs that lie close to the corners of the box, and so aren't within your circle. You want to do it in this order so that you only have to do the distance calculation on a relatively small number of target locations.
Don't forget that the bounding box is defined by lat/long corners, so it isn't truly rectangular. Longitude lines converge at the poles, so the top of your box is not the same width as the bottom. How much this affects you depends on how close you are to a pole (a degree of long ~= (40000km / 360) * cos (lat)).
If you don't require supreme accuracy, then you calculate your distances using Pythagoras's theorem, remembering the cosine variation in longitude, and the factor 2 unit difference (360 degrees of longitude, but only 180 of latitude). If you do require accuracy, then you're into the realms of spherical trigonometry, and also need to consider the ellipsoidal earth. Here's an online calculator, complete with equations and open source code, that is helpful in this regard.
Yes. The Overpass API has an "Around" feature which does exactly this (search for items within a radius of the given point). You can combine that with other requirements (eg to get a list of a particular item type):
http://wiki.openstreetmap.org/wiki/Overpass_API#Around
For example using OverPass Turbo Api (List all towns near of "Manzanares, Spain" with latitude and longitude with a radius of 150 Km, try it live!):
<osm-script output="json" timeout="25">
<id-query {{nominatimArea:Spain}} into="area"/>
<query type="node">
<has-kv k="place" modv="" v="town"/>
<around lat="38.996507" lon="-3.371946" radius="150000"/>
</query>
<print e="" from="_" geometry="skeleton" limit="" mode="body" n="" order="id" s="" w=""/>
</osm-script>
Here is documentation:
http://developers.cloudmade.com/wiki/geocoding-http-api/Documentation
Here is example of what you need - HTML, JSON.

How to represent this sentence in description logic? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How to describe this in description logic?
"every human is either male or female"
Thanks
The answers provided here so far do not use Description Logic syntax (which is variable-free).
Assuming you want the actual Description Logic syntax that is used in scientific papers about Description Logics, check out this:
human \sqsubseteq (male \sqcup female) \sqcap \neg (male \sqcap female)
Its written in LaTeX, you can use an online LaTeX equation editor, e.g. this to render this expression.
With propositional calculus, this would be described as:
∀x.H(x) ⊃ (M(x) ∨ F(x)) ∧ (¬(M(x) ∧ F(x)))
where:
H(x) = x is human
M(x) = x is male
F(x) = x is female
In description logic, it's a little bit different:
human ⊆ (male ∪ female) ∩ ¬(male ∩ female)
don't have the ability to comment yet as a newbie but i believe you would want to use an "exclusive or"... then again, i guess it depends on your universe of discourse ;)