Created
June 16, 2014 12:49
-
-
Save natefaubion/b65077c388f3b5f0475c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance { | |
['black', ['red', ['red', *, *, *], *, *], *, *] => 'balance-1', | |
['black', ['red', *, *, ['red', *, *, *]], *, *] => 'balance-2', | |
['black', *, *, ['red', ['red', *, *, *], *, *]] => 'balance-3', | |
['black', *, *, ['red', *, *, ['red', *, *, *]]] => 'balance-4', | |
* => 'balanced' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance(a0) { | |
if ((Array.isArray ? Array.isArray(a0) : Object.prototype.toString.call(a0) === '[object Array]') && a0.length === 4) { | |
var r0 = a0[0]; | |
if (r0 === 'black') { | |
var r1 = a0[1]; | |
if ((Array.isArray ? Array.isArray(r1) : Object.prototype.toString.call(r1) === '[object Array]') && r1.length === 4) { | |
var r2 = r1[0]; | |
if (r2 === 'red') { | |
var r3 = r1[1]; | |
if ((Array.isArray ? Array.isArray(r3) : Object.prototype.toString.call(r3) === '[object Array]') && r3.length === 4) { | |
var r4 = r3[0]; | |
if (r4 === 'red') { | |
return 'balance-1'; | |
} | |
} | |
var r5 = r3[3]; | |
if ((Array.isArray ? Array.isArray(r5) : Object.prototype.toString.call(r5) === '[object Array]') && r5.length === 4) { | |
var r6 = r5[0]; | |
if (r6 === 'red') { | |
return 'balance-2'; | |
} | |
} | |
} | |
} | |
var r7 = r1[3]; | |
if ((Array.isArray ? Array.isArray(r7) : Object.prototype.toString.call(r7) === '[object Array]') && r7.length === 4) { | |
var r8 = r7[0]; | |
if (r8 === 'red') { | |
var r9 = r7[1]; | |
if ((Array.isArray ? Array.isArray(r9) : Object.prototype.toString.call(r9) === '[object Array]') && r9.length === 4) { | |
var r10 = r9[0]; | |
if (r10 === 'red') { | |
return 'balance-3'; | |
} | |
} | |
var r11 = r9[3]; | |
if ((Array.isArray ? Array.isArray(r11) : Object.prototype.toString.call(r11) === '[object Array]') && r11.length === 4) { | |
var r12 = r11[0]; | |
if (r12 === 'red') { | |
return 'balance-4'; | |
} | |
} | |
} | |
} | |
} | |
} | |
return 'balanced'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance(a) { | |
if ((Array.isArray ? Array.isArray(a) : "[object Array]" === Object.prototype.toString.call(a)) && 4 === a.length && "black" === a[0]) { | |
a = a[1]; | |
if ((Array.isArray ? Array.isArray(a) : "[object Array]" === Object.prototype.toString.call(a)) && 4 === a.length && "red" === a[0]) { | |
var b = a[1]; | |
if ((Array.isArray ? Array.isArray(b) : "[object Array]" === Object.prototype.toString.call(b)) && 4 === b.length && "red" === b[0]) { | |
return "balance-1"; | |
} | |
b = b[3]; | |
if ((Array.isArray ? Array.isArray(b) : "[object Array]" === Object.prototype.toString.call(b)) && 4 === b.length && "red" === b[0]) { | |
return "balance-2"; | |
} | |
} | |
a = a[3]; | |
if ((Array.isArray ? Array.isArray(a) : "[object Array]" === Object.prototype.toString.call(a)) && 4 === a.length && "red" === a[0]) { | |
a = a[1]; | |
if ((Array.isArray ? Array.isArray(a) : "[object Array]" === Object.prototype.toString.call(a)) && 4 === a.length && "red" === a[0]) { | |
return "balance-3"; | |
} | |
a = a[3]; | |
if ((Array.isArray ? Array.isArray(a) : "[object Array]" === Object.prototype.toString.call(a)) && 4 === a.length && "red" === a[0]) { | |
return "balance-4"; | |
} | |
} | |
} | |
return "balanced"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment