Skip to content

Instantly share code, notes, and snippets.

@Endle
Endle / gist:d0b30b1a70756a1f0fa2
Last active August 29, 2015 14:03
用位运算求 f(x, y) -> 2^y > x
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
uint32_t slow(uint32_t b)
{
int n, i;
for(n=-1, i = 1; i <= b; i<<=1, n++);
/* not optimal */
@Endle
Endle / FUD 2014 Beijing
Last active August 29, 2015 14:01
Regular Expression for FUD 2014 Beijing Air Ticket
#!/usr/bin/python3
FILE='asia'
fin = open(FILE, 'r')
strings = fin.readlines()
strings.sort()
strings = [s.strip() for s in strings]
print(strings)
/*****************
* cellBlockA.js *
*****************
*
* Good morning, Dr. Eval.
*
* It wasn't easy, but I've managed to get your computer down
* to you. This system might be unfamiliar, but the underlying
* code is still JavaScript. Just like we predicted.
*
@Endle
Endle / gist:9321564
Created March 3, 2014 09:42
Test C array out of range
/* gcc t.c -Wall -Werror -o test && ./test */
#include <stdio.h>
int arr[10];
int main()
{
int n;
scanf("%d", &n);
printf("got %d\n", arr[n]);
return 0;
}
@Endle
Endle / Have A Try
Created May 31, 2013 03:01
My Gist
It seems that Gist is Wonderful. Alright, let me have a try.