This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": [ | |
{ | |
"status": { | |
"date": 20160806, | |
"age": 10, | |
"last_login": 3 | |
}, | |
"data": { | |
"account": 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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] << " "; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <iostream> | |
struct Klass { | |
int value; | |
}; | |
struct Data { | |
int value; | |
Klass *klass; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
token = "" | |
def send(url): | |
return urllib2.urlopen(url.format(token)).read() | |
def get(url): | |
return urllib2.urlopen(url).read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |