Saturday

Factory's backdoor

class Factory { public class ProprietarySmartphone { protected string _osVersion; public string OsVersion { get { return _osVersion; } set { throw new Exception("Don't touch this!"); } } } private class DeveloperSmartphone : ProprietarySmartphone { public new string OsVersion { get { return _osVersion; } set { _osVersion = value; } } } public static ProprietarySmartphone BuyPhone() { var keepSecret = new DeveloperSmartphone(); Factory.OnSoftwareUpdate += delegete(int v) { keepSecret.OsVersion = v; }; var readyToSell = (ProprietarySmartphone)keepSecret; return readyToSell; } }

Monday

Lost in brackets

++[[]][+[]]+[+[]] === ++[[]][0] + [0] === 1+[[]][0] + [0] === 1 + [] + [0] === 1 + "" + "0" === "10"

Thursday

Yet another Fibonacci

(function(){ window.fibonacci = function(){ var n = new Number(1); n.next = next; return n; }; function next(){ var n = new Number( this + (this.prev||0) ); n.prev = +this; n.next = next; return n; }; })();
jsperf.com/fibonacci-battle