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
local function keys(o) | |
local len = #o | |
local skeys = {} | |
local ukeys = {} | |
local n = 1 | |
for k,v in pairs(o) do | |
local nk = math.tointeger(k) | |
if nk == nil or nk <= 0 or nk > len then | |
local sk = tostring(k) | |
if type(k) == "string" then |
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> | |
static void | |
minmax(int height[], int n, int *min, int *max) { | |
int i; | |
*min = *max = height[0]; | |
for (i=1;i<n;i++) { | |
if (height[i] < *min) | |
*min = height[i]; | |
else if (height[i] > *max) |
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 "clog.h" | |
#include <stdatomic.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define LOGMETA_BUFFER 4096 | |
#define LOGDATA_BUFFER (64 * 1024) | |
// [..........................] | |
// ^ |
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
// interface | |
struct object { | |
object * create(); | |
void release(); | |
int getState(); | |
}; | |
// implementation |
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 <assert.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#define N (100000063/64) | |
struct bitset { | |
uint64_t bits[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
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#define CHUNK_N 64 | |
struct eid_chunk { | |
uint64_t id[2]; |
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 <stdint.h> | |
#include <assert.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
#include <string.h> | |
// .size is size of sec[] | |
// .size * 8 >= .section_n * 8 + .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
#include <lua.h> | |
#include <lualib.h> | |
#include <lauxlib.h> | |
#include <stdio.h> | |
const char * source = "print 'A' ; coroutine.yield() ; print 'B'"; | |
int | |
main() { | |
lua_State *L = luaL_newstate(); |
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 <stdbool.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
struct set { | |
int n; | |
int count; | |
}; | |
static int |
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
// See: https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination/ | |
#include <stdio.h> | |
#define MAXN 40 | |
#define MAXSTEP (40*40) | |
struct coord { | |
unsigned char x; | |
unsigned char y; | |
}; |
NewerOlder