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
package algo; | |
import java.util.ArrayList; | |
import java.util.List; | |
// https://v2ex.com/t/1065513 | |
public class Main { | |
public static void main(String[] args) { | |
Box box = new Box(4, 7, 2, 6, 3, 5, 8, 1, 8, 4, 76, 2, 3, 14, 0, 9, 7); |
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
# -*- coding: utf-8 -*- | |
import os | |
from hashlib import md5 | |
from bitarray import bitarray | |
class BloomFilter(object): | |
def __init__(self, count, size, hash_count=8): |
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
img.grayscale { | |
filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='grayscale'><feColorMatrix type='matrix' values='0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */ | |
filter: gray; /* IE6-9 */ | |
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */ | |
} | |
img.grayscale.disabled { | |
filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='grayscale'><feColorMatrix type='matrix' values='1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0'/></filter></svg>#grayscale"); | |
-webkit-filter: grayscale(0%); | |
} |
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://segmentfault.com/q/1010000000187028 | |
* 由递归改为循环 | |
* 时间复杂度 O(n - m) | |
*/ | |
#include <stdio.h> |
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
/* | |
* 给定一个32位无符号整数n,求n的二进制表示中1的个数 | |
* 算法来自 http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html | |
*/ | |
#include <stdio.h> | |
#define PRT(func, num) (printf("%s(%x):\t%d\n", #func, num, func(num))) | |
unsigned int bc_plain(unsigned int n) |
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
#input_outer { | |
border: 1px solid orange; | |
border-radius: 3px; | |
padding: 2px; display: | |
inline; width: 200px; | |
overflow: hidden; | |
} | |
.t_input { | |
width: 100px; |
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
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
plus = lambda x : x + 7 | |
minus = lambda x : x - 5 | |
mul = lambda x : x * 3 | |
div = lambda x : x // 2 | |
func = {'+': plus, | |
'-': minus, |
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
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from functools import reduce | |
# 系数,fix = (2 ** (17 - i) % 11 for i in range(17)) | |
fix = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2) | |
# 根据身份证号前17位计算第18位 | |
def get_check_code(id_head): |