Skip to content

Instantly share code, notes, and snippets.

@cocodrips
cocodrips / math_.py
Created January 19, 2017 05:51
丸めるのと切り下げるの
import decimal
def round_n(value, n):
if n <= 0:
return decimal.Decimal(str(value)).quantize(decimal.Decimal('1.'), rounding=decimal.ROUND_HALF_UP)
return decimal.Decimal(str(value)).quantize(decimal.Decimal('.{}1'.format('0' * (n - 1))), rounding=decimal.ROUND_HALF_UP)
def floor_n(value, n):
if n <= 0:
return decimal.Decimal(str(value)).quantize(decimal.Decimal('1.'), rounding=decimal.ROUND_FLOOR)
@cocodrips
cocodrips / 8queen.py
Created October 17, 2016 18:10
n-queen
class QueenN():
def __init__(self):
pass
def create(self, n):
boards = [[-1] * n]
for row in range(n):
boards = self.add_row(row, n, boards)
print n, "Pattern:", len(boards)
@cocodrips
cocodrips / GetSelectedCell.cs
Created August 29, 2016 06:34
Excelの選択してるCellとる
using Excel = Microsoft.Office.Interop.Excel;
# ...
public List<string> GetSelectedItems() {
Excel.Range range = Globals.ThisAddIn.Application.Selection as Excel.Range;
List<string> cells = new List<string>();
foreach (string cell in range.Value)
{
{
"data": [
{
"status": {
"date": 20160806,
"age": 10,
"last_login": 3
},
"data": {
"account": 10
#include <iostream>
using namespace std;
int q1() {
int array[3][3];
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++) {
array[i][j] = i * 3 + j;
cout << array[i][j] << " ";
}
@cocodrips
cocodrips / offset.cpp
Last active May 2, 2016 10:50
脳みそ整理用
#include "stdafx.h"
#include <iostream>
struct Klass {
int value;
};
struct Data {
int value;
Klass *klass;
@cocodrips
cocodrips / ElliSocks.py
Created March 27, 2016 04:05
TCO 2016 Round1 Med
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class EllysSocks:
def getDifference(self, S, P):
INF = 100000000000
S = list(S)
S.append(0)
S.sort()
@cocodrips
cocodrips / ElliSocks.py
Created March 27, 2016 04:05
TCO 2016 Round1 Med
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class EllysSocks:
def getDifference(self, S, P):
INF = 100000000000
S = list(S)
S.append(0)
S.sort()
@cocodrips
cocodrips / coderunner.py
Last active October 31, 2015 14:37
CodeRunner2015 予選B 33位でした〜
import urllib2
token = ""
def send(url):
return urllib2.urlopen(url.format(token)).read()
def get(url):
return urllib2.urlopen(url).read()
@cocodrips
cocodrips / Main.java
Created October 30, 2015 17:42
Javaのリハビリ幅優先探索
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Main {
public static class Position {