Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
tsu-nera / RelationClassifier.py
Last active December 5, 2015 04:51
SRM 674 DIV2
class RelationClassifier:
def isBijection(self, domain, ran):
dd = {}
rr = {}
for d, r in zip(domain, ran):
dd[d] = 0
rr[r] = 0
for d, r in zip(domain, ran):
@tsu-nera
tsu-nera / InterestingDigits.py
Last active November 14, 2015 10:40
SRM 150 Div2 Level2
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class InterestingDigits:
def digits(self, base):
ans = []
for n in range(2, base):
ok = True
for k1 in range(0, base):
@tsu-nera
tsu-nera / Cryptography.cpp
Last active November 14, 2015 06:28
SRM480 Div 2 Level 1
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
@tsu-nera
tsu-nera / KiwiJuiceEasy.cpp
Last active November 14, 2015 06:10
SRM478 Div 2 Level 1
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
@tsu-nera
tsu-nera / InterestingParty.cpp
Last active November 14, 2015 05:48
SRM494 Div 2 Level 1
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
(ns fx-clj.core
(:require [clojure.data.json :as json])
(:require [clj-http.client :as client]))
(defn get-instruments []
(client/get
"http://api-sandbox.oanda.com/v1/prices?instruments=EUR_USD" {:as :json}))
(defrecord tick-event [instrument time bid ask])
@tsu-nera
tsu-nera / regression.py
Last active December 12, 2016 09:22
為替データを線形回帰
Time,Open,High,Low,Close,Volume
16.07.2015 00:10:00.000,1.09375,1.09376,1.09364,1.09375,64.0800
16.07.2015 00:11:00.000,1.09375,1.09378,1.09364,1.09367,51.3600
16.07.2015 00:12:00.000,1.09367,1.09379,1.09367,1.09375,81.7400
16.07.2015 00:13:00.000,1.09375,1.09375,1.09334,1.09355,177.2900
16.07.2015 00:14:00.000,1.09354,1.09358,1.09328,1.09334,181.5900
16.07.2015 00:15:00.000,1.09337,1.09346,1.09328,1.09336,84.2500
16.07.2015 00:16:00.000,1.09336,1.09338,1.09326,1.09330,174.3800
16.07.2015 00:17:00.000,1.09330,1.09347,1.09328,1.09346,61.3400
16.07.2015 00:18:00.000,1.09346,1.09350,1.09337,1.09337,123.2300
"""
Demonstrates streaming feature in OANDA open api
To execute, run the following command:
python streaming.py [options]
To show heartbeat, replace [options] by -b or --displayHeartBeat
"""
int start() {
//変数の宣言
int cnt, CurrentPosition;
int Ticket;
double kakoa,gennzaia;
double kakob,gennzaib;
// オーダーチェック(ポジションなどのデータ)
CurrentPosition=-1;
for(cnt=0;cnt<OrdersTotal();cnt++) {
@tsu-nera
tsu-nera / sanmoku.scala
Last active August 29, 2015 14:23
Scalaで 三目並べ
// TODO State monadを導入
import scala.util.{Try, Success, Failure}
object Main {
var initial = Array(
Array('-','-','-'),
Array('-','-','-'),
Array('-','-','-'))