The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
No - each prisoner looks at the prisoner in front of them and reports his hat color to him - they can then do the same for the next prisoner and announce (correctly) their own hat color since it was told to them by the prisoner behind them. They can all be the same color or any number of identifiable colors.
Only fails if there are liars or blind prisoners - but picks up again.
The guy at the back can save the others but not himself. They agree a code - let's say if there's an even number of black hats in front of him he calls black, otherwise he calls white. That gives everyone in front of him enough information to work out what colour hat they're wearing e.g. second guy knows that there are an even number of black hats but knows that there are an odd number so can conclude that his own hat is black.
The guy at the back's chances are 50-50 (probably less if a sadistic guard heard the prisoners devising the code) but at least he's taking one for the team.
Solution 2 is build a time-machine; go back and vote for someone else. This is a very unhealthy country that they're living in.
MATLAB? Oh the nightmare! I used it at Uni, I was doing some Nueral Net stuff and Simulink had some useful bits but the language, it has a JVM now? That has me worried, like Labview it happened more than designed...