Skip to content

Instantly share code, notes, and snippets.

View Cee's full-sized avatar
🎀
ハネだ (<ゝω·)☆

Tianyu Wang Cee

🎀
ハネだ (<ゝω·)☆
View GitHub Profile
@Cee
Cee / dfs.cpp
Created November 18, 2014 01:13
DFS
#include <iostream>
using namespace std;
int n, m;
bool vector[100][100];
bool visited[100];
void dfs(int point){
cout << (point + 1);
@Cee
Cee / power.c
Last active August 29, 2015 14:08
Power
int power(int n, int k) {
if (k == 0) return 1;
if (k == 1) return n;
int ret = power(n, k >> 1);
return (k & 1)
? ret * ret * n //odd
: ret * ret; //even
}
@Cee
Cee / power.c
Created November 2, 2014 15:40
Power
int pow(int n, int k) {
if (k == 0) return 1;
if (k == 1) return n;
return n * pow(n, k - 1);
}
@Cee
Cee / BinarySearch.c
Created October 31, 2014 18:01
BinarySearch
int search(int array[], int n, int value) {
int left = 0;
int right = n - 1;
while (left <= right) {
int mid = left + ((right - left) >> 1);
if (array[mid] > value) {
right = mid - 1;
} else if (array[mid] < value) {
left = mid + 1;
} else {
@Cee
Cee / Tree.cpp
Created September 24, 2014 06:12
Tree
#include <iostream>
#include <cstring>
using namespace std;
char pre[100] = "zWbTghHV3oPp8LFGuAfn01rmwxJ7eiQYZ25vKqk9yCBNDU4lcMIEaOj6SRXsdt"; //前序序列
char mid[100] = "TbHVh3ogPWFLuAfGrm1xJ7we0iQYnZ8Kvqk9y5CNBD24UlcpIEMaj6SROXsdzt"; //中序序列
char post[100] = "TVHo3hPgbFfAumr7Jxew1YQi0ZnGLKy9kqvNDBC54clU28EIRS6jdsXOaMpWtz"; //后序序列
typedef struct _Node
{
@Cee
Cee / NQueens.py
Created August 4, 2014 08:25
NQueens
from itertools import permutations
import hashlib
n = 9
cols = range(n)
for vec in permutations(cols):
if (n == len(set(vec[i] + i for i in cols))
== len(set(vec[i] - i for i in cols))):
s = "zWp8LGn01wxJ7"
for x in vec:
@Cee
Cee / Test.c
Created July 31, 2014 15:34
Test
void test() {
volatile unsigned long long val;
volatile unsigned long long local = 0xdeadbeef;
char* variable_length;
entry_check(3); /* Make sure entered this function properly */
val = getbuf();
if (val <= 40) {
variable_length = alloca(val);
}
entry_check(3);
@Cee
Cee / Bang.d
Created July 31, 2014 14:17
Bang
0000000000401020 <bang>:
401020: 48 83 ec 08 sub $0x8,%rsp
401024: 48 8b 35 dd 12 20 00 mov 0x2012dd(%rip),%rsi # 602308 <global_value>
40102b: 48 3b 35 ee 12 20 00 cmp 0x2012ee(%rip),%rsi # 602320 <cookie>
401032: c7 05 74 12 20 00 02 movl $0x2,0x201274(%rip) # 6022b0 <check_level>
401039: 00 00 00
40103c: 74 13 je 401051 <bang+0x31>
40103e: bf 70 15 40 00 mov $0x401570,%edi
401043: 31 c0 xor %eax,%eax
401045: e8 a6 f7 ff ff callq 4007f0 <printf@plt>
@Cee
Cee / Bang.c
Created July 31, 2014 14:07
Bang
unsigned long long global_value = 0;
void bang(unsigned long long val)
{
entry_check(2); /* Make sure entered this function properly */
if (global_value == cookie)
{
printf("Bang!: You set global_value to 0x%llx\n", global_value);
validate(2);
} else {
printf("Misfire: global_value = 0x%llx\n", global_value);
@Cee
Cee / Fizz.c
Created July 31, 2014 07:50
Fizz
void fizz(int arg1, char arg2, long arg3,
char* arg4, short arg5, short arg6, unsigned long long val)
{
entry_check(1); /* Make sure entered this function properly */
if (val == cookie)
{
printf("Fizz!: You called fizz(0x%llx)\n", val);
validate(1);
}
else {