Skip to content

Instantly share code, notes, and snippets.

View odanado's full-sized avatar

odanado odanado

View GitHub Profile
def nextLCG(seed)
seed = seed * 0x5D588B656C078965 + 0x269EC3
seed = seed % 0x10000000000000000
return seed
end
def prevLCG(seed)
seed = seed *0xDEDCEDAE9638806D+0x9B1AE6E9A384E6F9
seed = seed % 0x10000000000000000
return seed
@odanado
odanado / gist:10160013
Created April 8, 2014 17:31
時間無駄にしたやつ
private void modDefensePower() {
int mod = 0x1000;
if(field.isBenefitSandstorm) {
defensePower = calcRoundHalfDown(defensePower * 3 / 2);
}
//しんかいの鱗 メタルパウダー 心の雫
switch (defenseAbility) {
case MARVEL_SCALE:
template <typename T>
void exEuclidAlgo2(T a,T b,T& x,T &y) {
T x0,y0,u0,v0;
T x1,y1,u1,v1;
T r0,r1,r2;
T k;
r0 = a;
r1 = b;
k = r0 / r1;
#include <iostream>
#include <cstdint>
#include <cstdio>
class MT {
uint32_t mt_table[624];
uint32_t mt_count;
public:
MT(uint32_t s){
mt_table[0] = s;
for(int i=1; i<624; i++) {
# -*- coding: utf-8 -*-
require "net/http"
require "uri"
require "json"
require "nokogiri"
require "open-uri"
#メガ進化はまだ
def to_ja(name)
# -*- coding: utf-8 -*-
require 'nokogiri'
require 'open-uri'
def hoge(index)
uri = "http://www.serebii.net/pokedex-xy/#{index}.shtml"
doc = Nokogiri::HTML(open(uri))
data = doc.xpath('//*/text()[contains(.,"Base Stats")]/../../td/text()').to_a
@odanado
odanado / create_db.rb
Last active August 29, 2015 14:01
serebii.net からデータを落としてくる
# -*- coding: utf-8 -*-
require "nokogiri"
require "open-uri"
require "sqlite3"
def get_base_stats(doc)
base_stats = Array.new
data = doc.xpath("//*/text()[contains(.,'Base Stats')]/../..")
#include <iostream>
#include <thread>
#include <mutex>
#include <vector>
#include <cstdint>
#include <cstdlib>
std::mutex print_mutex;
template <class T>
void print_hex(T x) {
@odanado
odanado / tmp-prime.cpp
Last active August 29, 2015 14:03
O(sqrt(n))
#include <iostream>
template<bool Cond>
struct bool_;
template<>
struct bool_<true> {
static const bool value = true;
};
template<>
struct bool_<false> {
static const bool value = false;
require "dxruby"
load "object.rb"
Window.width=800
Window.height=600
font = Font.new(32)
win = false
lose = false
def distance(obj1,obj2)
Math.sqrt((obj1.x-obj2.x)**2 + (obj1.y-obj2.y)**2 )