View bulls-and-cows-profiler.py
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 python | |
# -*- coding: utf-8 -*- | |
import Queue | |
import argparse | |
import os | |
import random | |
import subprocess | |
import sys | |
import threading | |
import time |
View gist:3813238
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
n, m = map(int, raw_input().split()) | |
table = [map(int, list(raw_input())) for _ in xrange(n)] | |
weighted_table = [] | |
for r in table: | |
if sum(r) == 0: | |
print -1 | |
exit() | |
weighted_row = [] | |
for i in xrange(len(r)): | |
if r[i] == 1: |
View gist:3950140
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
#include <stdio.h> | |
#include <string.h> | |
void reverse_char_array(char * first, char * last) { | |
while (first != last && first != --last) { | |
*first ^= *last; | |
*last ^= *first; | |
*first++ ^= *last; | |
} | |
} | |
void reverse_string(char * sentence) { |
View bigcat
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/time.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#define CANDSIZE 1024 | |
// #define BUFSIZE 8 * 1024 * 1024 |
View kcwu
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <assert.h> | |
#include <sys/time.h> | |
#include <pthread.h> |
View tkcn
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/time.h> | |
#define BUF_SIZE (1<<16) | |
#define LIST_LEN (1024*1024*38) | |
#define WORD_LEN (16) |
View gist:5637045
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
//Dog.java | |
public class Dog extends Animal { | |
public final String mMyString = "bark"; | |
@Override | |
public void doSomething() { | |
System.out.print(mMyString); | |
} | |
} |
View deadlock-tester-1.c
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/file.h> | |
#include <unistd.h> | |
int main() { | |
FILE * f1 = fopen("output1.txt", "a"); | |
FILE * f2 = fopen("output2.txt", "a"); | |
char buf[4] = {0}; |
View four-char-reverse.py
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 -*- | |
''' | |
請用少於 50 (UPD: 45) 個字元的 Python Code 將字串 s 每四個字元為一組反序呈現( s 的長度是 4 的倍數), 舉例 當 s="abcd1234efgh5678" | |
目前允許多行程式碼: 換行算一個字元, 一層縮排算一個字元 | |
''' | |
s = 'EFGHABCD56781234' |
View two-eggs-problem.py
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
n = int(input()) | |
t = [0] * (n + 1) | |
def find_min_test(x, t): | |
if x < 3: | |
t[x] = x | |
return x | |
if t[x]: | |
return t[x] | |
t[x] = min(max(i, 1 + find_min_test(x - i, t)) for i in range(1, x + 1)) |
OlderNewer