This file contains 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
rating :: Integer -> Integer -> Double | |
rating pos neg = rating' 1 2.24 (pos+neg) (fromIntegral pos) | |
-- 2.24 is quantile function for 0.9875, 97.5% certainity | |
-- {max}-star rating system | |
rating' :: Double -> Double -> Integer -> Double -> Double | |
rating' _ _ 0 _ = 0 | |
rating' max z cnt total | |
| max > 0 && z > 0 && cnt > 0 && total >= 0 = | |
let cnt' = fromIntegral cnt |
This file contains 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
var mas = [7,21,5,6,34,67,34,53,6,4,77,42,55]; | |
function calcCapacity(arr) { | |
var walls = [], | |
capacity = 0; | |
arr.forEach(function(height, index) { | |
var prev, prev2; | |
while (walls.length && walls[walls.length - 1].height <= height) { | |
prev = walls.pop(); |
This file contains 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 htmlEscape(str) { | |
var set = { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
"'": ''', | |
'"': '"' | |
}; | |
return ('' + str).replace(/[&<>"']/g, function (char) { | |
return set[char]; |
This file contains 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
import Data.List | |
sigmaRejection = sigmaRejection' 3 | |
sigmaRejection' distance xs = | |
mean $ filter (\x-> abs(mean xs - x) < distance * sigma) xs | |
where | |
mean xs = realToFrac (sum xs) / (genericLength xs) | |
sigma = sqrt $ ((sum xs)^2 - (sum $ map (^2) xs)) / genericLength xs |
This file contains 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
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static bool IsAnagram(string word1, string word2) { | |
if (word1.Length != word2.Length) { |
This file contains 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
// License=WTFPLv2 | |
$(function () { | |
function sortCommentList(parent, recursive) { | |
var comments = $(parent).find('>.comment_item'); | |
$(parent).append(keySort(comments, extractRating, true)); | |
recursive && comments.find('>.reply_comments:has(div)').each(function (idx, replies) { | |
sortCommentList(replies, recursive); | |
}); | |
} |
This file contains 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 Kallman(config) { | |
if (!(this instanceof Kallman)) { | |
return new Kallman(config); | |
} | |
for(var k in config) { | |
if (config.hasOwnProperty(k)) { | |
this[k] = config[k]; | |
} | |
} | |
this.steps = 1; |
This file contains 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
lvl1: NOT | |
eNrt2VEOgjAQRVHK9Ic1sAX/XYv73wihEImkY2ihdIALqW1yfGo0edTgX77vPq57 | |
O9/knAQJEiRIkCDBpwfbDacSnGY3r7RZDS4rbX7OzxG2c61+BBWR6Niv4ZDV+L4v | |
it5RfVOPLX4jYxONjz/L5TmivMQZ3RTtxE2liaIoWkK1MrT3malKFEVRqhJFUbOq | |
/0kXa3tOqhJF0TL6v+7MlSFViaJolapcHwm7ymtWJXe7URQtoJk70jL3uA+pyvjY | |
r1yFURRN1QqNNABUscfB | |
lvl2: AND | |
eNrt2U0KgCAQhuF03HiGrtC+s3T/iwSubFKyXytfQ1o8DIXU50RucL2fjB+N644c | |
nyw02aPwilad/7Q4FFJIIYUUUlitcGODLdnKk1t6E6sa2jmbH0FFJDnPqxU1F9cN |
This file contains 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
def dictcmp(a, b, stacka=None, stackb=None): | |
if a is b: | |
return True | |
if type(a) is not type(b): | |
return False | |
stacka = stacka or [] | |
stackb = stackb or [] | |
stacka.append(id(a)) | |
stackb.append(id(b)) | |
res = False |
This file contains 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
// http://nolandc.com/sandbox/fractals/?x=25&y=1&l=8&d=6&sa=80&a=-45&s=F++F++F++F++&r=F,F+D---F++F,D,+F+D---F+D | |
// space-filling fractal, a modification of Sierpinski curve | |
function d2xy(d, s) { | |
var r = {x: 0, y: 0}, p = {x: 0, y: 0}; | |
for (s = s-1; s >= 0; s--) { | |
p.x *= 2; | |
p.y *= 2; | |
var pow = 1 << (s*2); | |
rot(r, (d & pow*3) >> s*2); | |
if(s==1){ |