Skip to content

Instantly share code, notes, and snippets.

Yi Wang wangkuiyi

  • Ant Financial USA
  • San Francisco Bay Area, CA
Block or report user

Report or block wangkuiyi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#include <math.h>
#include <stdio.h>
#include <set>
typedef std::set<int> Set;
bool is_prime(int a, Set* primes) {
for (Set::const_iterator i = primes->begin();
i != primes->end() && *i <= sqrt(a);
++i) {
#include <math.h>
#include <stdio.h>
#include <vector>
typedef std::vector<long> Queue;
long find_smallest_divisor(long number) {
for (long i = 2; i < sqrt(number); ++i) {
if (number % i == 0) {
return i;
wangkuiyi /
Created Sep 6, 2012
Find the largest palindrome made from the product of two 3-digit numbers.
#include <stdio.h>
#include <string>
std::string positive_to_string(int num) {
std::string s;
while (num > 0) {
s.push_back((char)('0' + (num % 10)));
num /= 10;
return s;
wangkuiyi /
Created Sep 6, 2012
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
// Question: What is the smallest number divisible by each of the
// numbers 1 to 20?
// I factorize each of the numbers 1 to 20. For example, 12=2*2*3.
// This factorization can be represented by a histogram (2*2 3*1). If
// a number is evenly divisible by 20, it must be a product of at
// least two 2's and a 3. So I accumulate each factorization into a
// histogram by the following rule: if the factorization contains two
// 2's, the accumulation must contain at least two 2's. Then the
// final result is the product of numbers in the accumulation.
wangkuiyi /
Created Dec 14, 2012
O(n)-time non-recursive traversal of binary trees without extract space cost.
#include <iostream>
struct Node {
int key;
Node* left;
Node* right;
Node* parent;
Node(int k, Node* l, Node* r) {
key = k;
wangkuiyi / BUILD
Created Feb 23, 2013
Go invokes C samples
name = 'lda',
srcs = ['lda.c'],
deps = ['#pthread']
wangkuiyi / install_mpich_and_plda.bash
Last active Mar 3, 2016
Download, Build and Deploy MPICH 3.1 and PLDA 3.1 on Computers in a Cluster
View install_mpich_and_plda.bash
# This script download, build and deploy MPICH 3.1
# ( and pLDA 3.1 (
# to computers in a cluster.
# Usage:
# You download and run this script from any directory. For example,
# consider that Alice is running this script to install MPICH and pLDA
# on David's workstation in the role of Steven, she should do:
wangkuiyi / pre-commit-clang-format
Last active Oct 10, 2019
Git pre-commit hook that invokes clang-format to reformat C/C++/Objective-C source code.
View pre-commit-clang-format
# git pre-commit hook that runs an clang-format stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
# modifications for clang-format by
# This file is part of a set of unofficial pre-commit hooks available
# at github.
wangkuiyi / jsonrpc_example.go
Last active Aug 29, 2015
JSON RPC Go Example
View jsonrpc_example.go
package main
import (
View learn-go-hdfs-write.go
// This simple program shows how to use the write-support branch of
//, which accesses HDFS of Hadoop
// 2.2.x throught the native protobuf-based RPC protocol
You can’t perform that action at this time.