I will be going to Toorcon 12 tomorrow. I have never been to a San Diego or Toorcon, so this will be a first. It looks to be a pretty good line up of talks this year. In order to get back on Sunday I have to leave a bit early so I won’t be able to catch all the talks on Sunday.
I was also asked this week to write a few PHP functions. And while I didn’t do so hot on the spot, I did find a good way to accomplish the task. The question was: write a function to return true or false (or print) if two elements in a given array SUM to be 100. The first function is really slow, but more of an answer if all else fails type of approach.
$RandomArray = Array(74,122,103,125,80,29,127,123,35,33,142,91,
95,36,12,57,115,103,15,58,150,133,73,143,96,48,81,18,63,10,134,
30,30,28,88,25,30,84,40,27,102,136,32,93,115,132,55,142,68,60,
128,30,128,31,115,28,93,24,2,53,98,23,129,145,3,114,36,108,63,
60,70,97,66,26,28,64,62,96,104,114,5,7,121,4,145,62,38,115,112,
128,92,142,45,136,2,6,47,9,25);
$RequestedNum = 100;
function Search1($RandomArray, $RNum){
while($count < count($RandomArray)){
$count = 0;
foreach($RandomArray as $Num){
if($RandomArray[$count]+$Num == $RNum){
echo $RandomArray[$count] . " + " . $Num . " = " . $RNum . " : True";
break 2;
}
}
$count++;
}
if(count > count($RandomArray)){
echo "No match found : False";
}
}
The second one is a bit quicker and uses the built in function in_array();
function Search2($RandomArray, $RNum){
asort($RandomArray);
$SortedArray = $RandomArray;
foreach($SortedArray as $SA){
$findNum = $RNum - $SA;
$Success = in_array($findNum, $SortedArray);
if($Success == True){
echo $SA . " + " . $findNum . " = " . $RNum . " : True";
break;
}
}
if($Success == False){
echo "No match found : False";
}
}
I’ve been playing around with the idea of an ultra cheap (sub $100) HTPC with XBMC running on it. Most boxes that would be suited for this are > $100. I’m looking around at some devices that might be able to run as a cheap media streaming box for those extra TVs you might have sitting around in your room/basement. Most of my focus has been towards Nettops and Thin Clients. I also found a cool project of someone in England porting it to a beagleboard.
This makes me want to get one and continue or contribute to his work.