99 Ninja missions and a single lantern From http://blog.liveramp.com/2014/01/30/the-case-of-ninety-nine-ninja/:

A team of 99 ninja are each sent out on individual missions by their master. Their master tells the ninja that one of them must come back to the fortress and tell him when all 99 missions are complete - if this ninja is wrong and any mission is incomplete, they will all be slain for incompetence. These ninja are strictly prohibited from seeing each other while outside their fortress, lest they be discovered - they may never meet in person, and may only communicate through a single lantern left in the darkest part of the forest, which they may either turn on or off. Each ninja can visit the lantern whenever he or she wants - there is no danger of accidentally overlapping with another ninja. What plan of communication should the ninja put in place so that at least one of them knows when to return to the fortress?

 A: This is a variant of a classical problem. Before leaving, they choose one ninja who will report back to the master. Each ninja goes and completes his mission. When he is done, he returns to the lantern. If he finds the lantern off, he turns it on. If he finds it on, he leaves without doing anything. The only ninja who is allowed to turn off the lantern is the ninja chosen to report back to the master. You should be able to figure it out from here.
A: I failed to "figure it out from here" for the accepted answer.
Here are some alternate solutions:
Solution A
Starting with a lamp which is off. Only the chosen ninja may turn off 
the lamp and he regularly returns to turn off the lamp if it is turned on, 
noting each such occcurence.
Every ninja that completes a mission goes back to the lamp and if he finds 
it turned off turns it on and goes away, but If he finds it turned on, he comes 
back later and tries again.
Each toggle of the lamp requires a reset by the chosen ninja (so every report
is counted) and since the chosen ninja resets the lamp regularly, we are guaranteed 
to make progress. Since the number of ninjas is finite the process will terminate
when the chosen ninja has finished his own mission and has turned off the lamp 98 times.
Solution B
This one is more elaborate, but allows ninjas to go about their
assasinating ways for most of each day rather then having to 
busy loop the lamp, while giving a reasonable upper bound on
the time itakes for the chosen ninja to know he should head back home.
In the pre-killing-spree huddle, the following takes place:


*

*Each ninja is given a (daily) timeslot in which only he (she?) are 
allowed to access the lamp.

*Each ninja visits the lamp regularly at his alloted timeslot.


The lamp is initially off. At every visit, any ninja who has not yet
completed his task should turn on the lamp.
The chosen ninja has the last timeslot of the day. If the lamp is on
he turns it off and tries again the next day, If it's off he can report
back to his lord.
Unlike the first solution, there's a realtime schedueling requirement
to be met so if a ninja missed his timeslot (ninja flu, sleeps in late, etc')
he could get them all killed. The first scheme is more forgiving of temporary
delays.
Solution C
This solution accommodates the well known fact that ninjas are extremely competitive,
and insecure and tend to obsess about their ranking compared to other ninjas, a natural
side-effect of cutthroat competition in their vocation. This solution helps prevent
the buildup of unresolved social tensions by enabling them to engage in a primitive
form of gossip, which on the one hand lets them know when they've excelled their
betters and on the other hand, allows the weaker and more insecure to hide
their mediocrity, by aggregating their personal performance with all of their superiors.
At the pre-rampage-huddle, the following takes place:


*

*The ninja are ordered by their lethality (is there a standard scale for this?
7.5 chucks perhaps?), from most lethal to least lethal.

*Each ninja is given a timeslot as before, ordered by their rank. The most lethal
has the first timeslot of each day. The last and least lethal ninja is in charge
of reporting back to the castle and resetting the light at the end of each day (in other words, he gets the sh*t jobs)


The rest of the solution is as previously, with the added feature every ninja who 
has completed his mission and sees the light turned on knows he has done better then
someone who was so foolishly ranked higher then he in that biased and 
highly-politicized popularity contest with which this whole thing began. 
But the bested ninja can take comfort in knowing that the ninja ranked
lower the him will only know that someone ranked higher failed, but
not specifically who. The highest ranked ninjas enjoy less of this 
protection since the group is smaller, but then again they have larger 
reputations to uphold.
