This file contains 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<body> | |
</body> | |
<script> | |
function yourCode() { | |
function a(b,c){for(x in d)y?c|=0>b.indexOf(x)&&!a(b+x):m[c=b-2*d[p[7*(b%w+3)*(0|b/w+5)%24][x]]]&&a(c,r=m[c]=m[b+c>>1]="");c||p.push(b)}for(d=[1,w=56,-1,-w],p=[],m=[],y=-1848,a(r="");1960>y;r+="■ \n"[!m[y++]+!(y%w)])y?m[w-2-y]=-2>y%w:a(274);return r | |
} | |
document.write("<pre>" + yourCode() + "</pre>"); |
This file contains 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 | |
''' | |
Created on 2013/06/05 | |
@author: toshihiro | |
''' | |
import os | |
import os.path as P |
This file contains 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 | |
from flask import Flask, url_for, request, redirect | |
app = Flask(__name__) | |
@app.route('/login', methods=['GET', 'POST']) | |
def login(): | |
if request.method == 'POST': | |
user = request.form["user"] | |
password = request.form["password"] |
This file contains 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 sys | |
def count(v): | |
""" | |
Get sum of single-digit numbers in string. Use 'x' for 10. | |
>>> count("123") | |
6 |
This file contains 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 re | |
from mrjob.job import MRJob | |
WORD_RE = re.compile(r"[\w']+") | |
class WordCollocationCount(MRJob): | |
def mapper(self, _, line): | |
t = [word.lower() for word in WORD_RE.findall(line)] | |
for w1, w2 in zip(t, t[1:]): | |
yield (w1, w2), 1 |
This file contains 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
iimport re | |
from itertools import groupby | |
from mrjob.job import MRJob | |
WORD_RE = re.compile(r"[\w']+") | |
class WordCollocationCount(MRJob): | |
def mapper(self, _, line): | |
t = [word.lower() for word in WORD_RE.findall(line)] | |
for w1, w2 in zip(t, t[1:]): |
This file contains 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
ここに解答を記述してください。 | |
【理由】 | |
以下の2つの理由による。 | |
・reallocは新しいヒープを確保する場合と元のヒープを拡張する場合の2通りの動作がある。 | |
・10行目の代入分の実行で、左辺が先に評価されるか右辺が先に評価されるかは処理系によって異なる | |
(C言語の規格はどちらも許す)。 | |
左辺が先に評価され、かつ、reallocが新しいヒープを確保する場合に、実行結果がret=0になる。 |
This file contains 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 pymongo | |
>>> | |
>>> db = pymongo.Connection('localhost', 27017).somedb # specify "somedb" db | |
>>> db.serialnum.insert({"student_id": "kamiya", "seq": 0}) # add seed entry for a student "kamiya" in "serialnum" table | |
>>> db.serialnum.find_and_modify({"student_id": "kamiya"}, update={"$inc": {"seq": 1}}, new=True)["seq"] # generate a serial number for "kamiya" | |
>>> db.serialnum.find_and_modify({"student_id": "kamiya"}, update={"$inc": {"seq": 1}}, new=True)["seq"] # generate another serial number for "kamiya" | |
make a function for the above operation... | |
>>> def init_serial_number(student_id, db): |
This file contains 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 sys | |
nums = "123456789" | |
opes = ["", "+", "-", "*", "/"] | |
def gen(remaining_nums, ex): | |
ex = ex + remaining_nums[0] | |
remaining_nums = remaining_nums[1:] | |
if not remaining_nums: | |
yield ex |
This file contains 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 os | |
import subprocess | |
files = os.listdir(".") | |
for f in files: | |
root, ext = os.path.splitext(f) | |
if ext == ".eps": |