RT @ALmendili: The talented guys at Teenage Engineering @jugendingenieur have an updated site up. http
RT @davidsundin: Alla bara klagar på iPhonens auto correct-funktion men jag tycker den är väldigt bragokex.
Our floor heating is broken, enjoy our playlist while we're freezing our asses off. Best served ice cold. http://t.co/OZBWdIO0
RT @madonnaarsan: latest and greatest fun project: sad pug face http://t.co/rAuhsGFq check it out!
First elevator-pic of 2012! @madonnaarsan http://t.co/n6OOXrcA
RT @fritjofsson: Loading 2012 ███████████████] 99.4% Complete
RT @JGamblin: In those days Caesar Augustus decreed that all must return to the town of their birth, that they may provide tech support for their families
@appelstoffe 10.000!
It's snowing inside @Spotify on my iPhone...nice! Merry X-mas!
marco
RT @HackerNewsYC: Why European startup had to move to USA to fulfill its vision http://t.co/2AHr9YXw. YS is making a move in 2012
RT @greggvm: Social media is ruining our minds and we have the proof [Infographic] http://t.co/w3hHuYav [there goes their Klout score!]
RT @DaveHolmes: Your life will never be the same after you watch this video. http://t.co/6fU37pvb
RT @MikeSimonetti: i deleted my facebook so its twitter from now on. tell your friends.
RT @NittyGrittyShop: This seasons beloved Nitty Gritty Applemust is now back in store. As always, 100% handpicked and 100% homemade.... http://t.co/4a53xJXS
RT @jugendingenieur: Wow: @MusicRadar awards "Compact Hardware Synth of the Year" to the OP-1! Happy and humbled! 15.12.11 4.48 pm
User unknown? "
Friday Challenge – Numbers without magic numbers http://t.co/nh88I9Lk
Printed Electronic Labels Light Up Beverage Bottles | Print Media Centr http://t.co/DfLCnp7K
2012 = good year for Young Skilled RT @PhilipGre: Top 10 BI predictions For 2012 | Forrester Blogs http://t.co/uovChQ8u 04.12.11 9.44 pm
RT @TheEconomist: Estonia, Latvia and Lithuania depend almost completely for their security on outside help. Sweden plays a key role http://t.co/tMXGCiP4
RT @baratunde: 2% of Americans major in "leisure & fitness studies" in college. Same % as computer science. @jonbruner at 04.12.11 9.54 am
RT @hemeon: really great article on the the tech that supports and scales instagram http://t.co/HNJgGPNM
RT @Techmeme: Firefox faces uncertain future as Google deal apparently ends (@edbott / The Ed Bott Report Blog)
RT @newsycombinator: NYC Man Earns $55,000 A Year Peddling Candy On Subway http://t.co/1sKAktee
RT @onecaseman: It has to seem like a no risk time to become a tech entrepreneur. If you fail you just get acquired by a great technology company.
RT @TheEconomist: Today even Sweden’s supporters of the #euro are grateful to the 56% of voters who said no
RT @rsa: FACEBOOK ACQUIRES FACEBOOK.
Our bike-mac-Rimowa SCRUM http://t.co/7xzROijm
All devs eating chicken massala and naan – evening hackathon at Y/S HQ
RT @VentureBeat: Facebook’s entire business model is under fire in the EU, thanks to a proposed ad ban - http://t.co/bio6jdNZ
When the $h17 goes down, you better be ready #cypresshill. http://t.co/HRPCnyGB & ht
RT @Swizec: Truth. RT @giniji: "Telling an entrepreneur to focus is like telling a fat person to lose weight" @ 25.11.11 7.42 pm
RT @youngskilled: "FF won't transmit the complete URL of web pages that you visit to anyone other than Mozilla and its service providers" http://t.co/ohNLEm1k<
RT @newsycombinator: Hacked NASDAQ Servers were running on unpatched Windows 2003 http://t.co/p1hyHHjs
Some of that hot Magic SaaS http://t.co/nZIZbpTN
RT @jonikorpi: Here's a pretty simple jQuery snippet for injecting nbsp;s to prevent widows: http://t.co/PuHymoho (thanks @ 25.11.11 5.12 pm
RT @youngskilled: We have a quartet of devs representing Y/S on DreamHack. Behave boys, oh behave!
"FF won't transmit the complete URL of web pages that you visit to anyone other than Mozilla and its service providers" http://t.co/ohNLEm1k
RT @WeSC1999: Happy Thanksgiving!
We have a quartet of devs representing Y/S on DreamHack. Behave boys, oh behave!
RT @carlbildt: Congratulations to Anders Borg for being named by FT as best finance minister of the year in EU. Sweden works! http://t.co/2LS6XVI2
Happy chair! http://t.co/wB72GN1E
RT @aplusplus: Crackdown on Fashion Internships http://t.co/lBNofCHl
RT @laragon: 5 words in Sarah Palin's WSJ column that prove it was ghost written: gravitate, transcend, myriad, endemic, detriment.
RT @jonikorpi: Occupy Flash? Haha, tempted. http://t.co/BCimZw2o
RT @sechrest: Got a business idea using MS Kinect , There is a 3 month accelerator sponsored by MS , with development support http://t.co/VuNBHn8M
We tend to have something we call Friday Challenges at Y/S. It's basically a small hackathon with a specific goal and a reward of some sort. The fun thing with these challenges tend to be the discussions afterwards and while doing the code review you can clearly see the differences in approach. You can also earn extra points if you do something spectacular or easteregg-ish.
Last week we had the following task:
"Numbers without magic numbers
Create a function that returns our office number: 4687203333
Extreme: Not using any standard constants nor strings/numbers.
Hard: Only using standard-functions/constants.
Medium: Without using any strings nor numbers. Think outside the box...
Easy: Only using the number 1.
You can use Javascript, Python or PHP.
The function should be called get_office_number() and should return the value as a string.
Good luck."
And, here's the results and solutions that we came up with.
1. David went with the extreme solution not using any contants/numbers nor strings.
<?
function get_office_number(){
$one = pi()/pi();
$two = $one+$one;
$four = $two*$two;
$base = floor(getrandmax()*(pi()-$one));
$base += str_repeat(($four*$two), $two).str_repeat(($one-$one), (($four*$two)-$two));
$base += pow($four, ($four*$two) + ($one) ) / $two;
$base += pow($four, ($four*$two) ) / $two;
$base += (pow($four, ($four + $two)));
$base += (pow($four, ($four-$one))) * ($two+$one);
$base += ($two + $one);
return $base;
}
echo get_office_number();
die;
2. Frans went insane and created a jibberish version of combined constants ad infinitum. He motivated it with "but it's an oneliner!", not sure that counts though...
<?
function get_office_number() {
return (PHP_INT_MAX+PHP_INT_MAX+((((((PHP_INT_MAX-UPLOAD_ERR_PARTIAL)/PHP_MINOR_VERSION/PHP_MINOR_VERSION)-E_ERROR)/PHP_MINOR_VERSION)-E_ERROR)/PHP_MINOR_VERSION*UPLOAD_ERR_PARTIAL))-PHP_VERSION_ID*PHP_RELEASE_VERSION*PHP_MINOR_VERSION*PHP_RELEASE_VERSION-PHP_VERSION_ID-PHP_VERSION_ID-PHP_VERSION_ID-PHP_VERSION_ID-PHP_VERSION_ID-PHP_VERSION_ID-PHP_VERSION_ID-(PHP_VERSION_ID/PHP_MINOR_VERSION)+E_USER_NOTICE+E_USER_ERROR+E_COMPILE_WARNING+E_CORE_WARNING-E_PARSE-UPLOAD_ERR_PARTIAL;
}
echo get_office_number();
3. Fredrik did a HAXX0R version. I think the code says it all...or does it?
<?
function get_office_number(){
$hax=@hax; $__=ord($hax)-ord($hax);
@$_[]=(@${__}); $__=((++$__)+$__++); $_[]=@${__}; $___=$__/$__;
$_[++$_[$___]]=$_[$___]+(($___<<$___<<$___)-($___<<$___)-$___); $_[$_[($_[($___<<$___<<$___)-$___]/($___<<$___<<$___))]]=@${__};
$_[$_[$___/$___]*$_[($___<<$___)+$___]]=--$__; $_[$_[(@${__})]+$__]=(count(@${_})); $_[$_[(@${__})]+(++$__)]=(((--$__)<<($__<<$__<<$__))/((@${__})+$__));
return ($_[($___<<$___<<$___)].($_[($___<<$___<<$___)+@${__}]-(++$__)).($_[($__<<$__)>>$___]*($___<<$___)).(($__<<$__<<$__>>($___<<$___))-(--$__)).($___<<$___).(--$__).str_repeat($_[($__++)+$___],$___<<($___<<$___)));
}
echo get_office_number();
4. Mathias did a bit shifting scenario, but actually failed, since he missed the last digit in our office number :<
<?
//IF not running >5.3
#define ('PHP_ROUND_HALF_UP', 1);
#define ('PHP_ROUND_HALF_DOWN', 2);
#define ('PHP_ROUND_HALF_EVEN', 3);
#define ('PHP_ROUND_HALF_ODD', 4);
function get_office_number(){
return ((PHP_ROUND_HALF_UP<<(((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) * PHP_ROUND_HALF_ODD)+(PHP_ROUND_HALF_ODD * PHP_ROUND_HALF_DOWN)))^(PHP_ROUND_HALF_UP<<(((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP)+PHP_ROUND_HALF_ODD) * PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) * (PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP)))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_DOWN * PHP_ROUND_HALF_EVEN) * PHP_ROUND_HALF_ODD))^(PHP_ROUND_HALF_UP<<(((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) * PHP_ROUND_HALF_ODD) + PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<<(((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) * PHP_ROUND_HALF_ODD) + PHP_ROUND_HALF_DOWN))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_EVEN) * PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) * PHP_ROUND_HALF_ODD))^(PHP_ROUND_HALF_UP<<(PHP_ROUND_HALF_ODD * PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) + (PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP) + PHP_ROUND_HALF_UP))^(PHP_ROUND_HALF_UP<<((PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_UP)+PHP_ROUND_HALF_ODD))^(PHP_ROUND_HALF_UP<<(PHP_ROUND_HALF_ODD + PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<<(PHP_ROUND_HALF_DOWN * PHP_ROUND_HALF_EVEN))^(PHP_ROUND_HALF_UP<}
echo get_office_number();
He also made an easteregg. If you count the characters in the function, it's 1337... nice one!
5. Richard/Desmond did a coder's collab. They followed the rules but the code required you to create a file named as the number you wanted as the output. Smallest amount of code, but required extra effort!
Place a file named '4687203333' inside the the same directory as the file below.
<?php echo get_office_number(); function get_office_number(){ $arr=scandir(getcwd()); array_shift($arr); array_shift($arr); $arr2=array_shift($arr); return $arr2; }
Together we announced Fredrik as the winner of the challenge. Congrats Fredrik!