Skip to content

Instantly share code, notes, and snippets.

View heejune's full-sized avatar

Heejune heejune

View GitHub Profile
unsigned long get_nth_prime_without_sieve(unsigned long n) {
if (n == 0) return 0;
if (n == 1) return 2;
unsigned long prime_num = 3;
unsigned long local_n = 2; // 2th prime number is 3
while (local_n != n) {
/// snippet from
/// http://www.geeksforgeeks.org/sieve-of-eratosthenes/
///
std::vector<bool> SieveOfEratosthenes(unsigned long less)
{
// Create a boolean array "prime[0..n]" and initialize
// all entries it as true. A value in prime[i] will
// finally be false if i is Not a prime, else true.
vector<bool> prime(less + 1);
std::fill(begin(prime), end(prime), true);
#include <memory>
// note1. 홀수 n이 주어졌을 때, n이 몇 번째 홀수인지 알아내려면 (n - 3) >> 1 한다.
unsigned long get_nth_prime_with_optimized_sieve(unsigned long n) {
unsigned long precompute_max_count = 200000;
// prime number를 체크하기 위해 우선 대상이 될 모든 odd number들을 담을 배열을 만든다.
vector<bool> odd_numbers_divisible(precompute_max_count/2); // odd numers

Keybase proof

I hereby claim:

  • I am heejune on github.
  • I am heejune (https://keybase.io/heejune) on keybase.
  • I have a public key ASBTjB-ljb8r_A1ald0ZHD--uWUwa009owTp3KM3FZyKoQo

To claim this, I am signing this object:

struct routing_delegator
{
routing_delegator() {} // default
routing_delegator(std::vector<std::string> r) : ruleset(r) {}
// register functor handler
template <typename F>
void to(F&& f)
{
routing_data = std::make_unique<typed_routing_recored<decltype(&F::operator())>>(f);
struct routing_record
{
virtual reply handle(void*) abstract;
};
template <typename T>
struct typed_routing_recored;
template <typename RetType, typename classTy, typename... ArgType>
struct typed_routing_recored<RetType(classTy::*)(ArgType...) const> : public routing_record
@heejune
heejune / set_package_version.py
Last active September 22, 2017 07:13
AssemblyInfo.cs update version info
def set_package_version(manifest_file, target_version):
from xml.etree import ElementTree as et
et.register_namespace("", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
et.register_namespace("mp","http://schemas.microsoft.com/appx/2014/phone/manifest")
et.register_namespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
tree = et.parse(manifest_file)
e = tree.find('{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity')