Instantly share code, notes, and snippets.

# Felix021felix021

• Sort options
Last active Aug 29, 2015
Sudoku：解数独
View sudoku.py
 #!/usr/bin/python import copy def grid_id(x, y): return ((x - 1) / 3 * 3) + (y - 1) / 3 + 1 class Position: def __init__(self, x, y): self.x = x self.y = y
Created Sep 14, 2014

View switch_pic
 #!/usr/bin/python #coding:utf-8 import sys import PIL from PIL import Image if len(sys.argv) < 2: raise Exception("bad parameter")
Last active Aug 29, 2015 — forked from chuangbo/README.md

Created Oct 28, 2014

View pyinterpreter.py
Created Jun 3, 2015

View basic permutation
 #include int visit[1024] = {0}; void perm_rec(int *a, int n, int i) { int j; if (i == n) { for (j = 0; j < n; j++) printf("%d ", a[j]);
Last active Dec 31, 2015

View magicpython
 #!/usr/bin/env python import os import sys import compiler fsrc = open(sys.argv[1]) code = fsrc.read() lines = code.split('\n') fsrc.close()
Last active Jan 1, 2016

View toy_midi.py
 #!/usr/bin/env python #coding=utf-8 # WINDOWS ONLY # import winsound import time freq_map = { "C<" : 262,
Created Jan 25, 2014

View 4x4 puzzle
 #!/usr/bin/env python #coding:utf-8 #problem description: https://www.v2ex.com/t/98224 start_node = dict(state='2011001100110011', row=0, col=0, prev=None); target_state = '2101101001011010' def swap(state, r1, c1, r2, c2): m, n = list(sorted([r1 * 4 + c1, r2 * 4 + c2])) return state[:m] + state[n] + state[m+1:n] + state[m] + state[n+1:]
Last active Apr 12, 2016
Python多进程库multiprocessing的封装
View multiprocess.py
 #!/usr/bin/python #coding: utf-8 """ Usage: import multiprocess slices = multiprocess.split_list(filelist, 8) #分成8份 processes = map(lambda slice: multiprocess.spawn(file_processor, slice), slices)
Created Jul 21, 2016
View ucloud-chinajoy-2016
 import urllib print len(urllib.urlopen('http://106.75.28.160/UCloud.txt#rd?n').read().split('UCanUup')) - 1 #728
You can’t perform that action at this time.