Posts

Showing posts from September, 2011

Calendar Maker Script (for Python) Pythonでカレンダーを作る

Image
My wife pushed me to create a calendar of her design, but I couldn't find a good image, so I decided to make one as a programmer! Here is the image. And this is a code. #Attention! Holidays are Japanese ones. To know which day is holiday, I got "jholiday.py" from here . Thank you "AddingBox"!! Also you need to install PIL(Python Image Library). """ CREATE LARGE CALENDER IMAGE This code is created by tiid (http://makerwannabe.blogspot.com/) This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. """ import Image from PIL import ImageFont, ImageDraw from jholiday import holiday_name from datetime import timedelta import datetime class CalenderImage() : def __init__(self, width, height): self.image

Source code for slide puzzles of DevQuiz 2011(Google Developer Day)

Is it too late to public source code for DevQuiz? First purpose is to solve over 1000 puzzles in a day and this code got 1130 correct answers which was good enough for me. If anybody has a comment, please feel free to do so! (もちろん日本語でも) from heapq import heappush, heappop, heapreplace from copy import copy from random import seed class Board: def __init__(self, w, h, situation): self.w = w self.h = h self.length = len(situation) self.firstSituation = situation self.goal_str = self.createGoalMap() self.scoremap = self.createScoreMap() print "Board:",w,h,self.scoremap def move(self, situation, pos, i): assert(situation[pos]=="0") i = {0:0, 1:1, 2:2, 3:3, 'U':0, 'D':1, 'L':2, 'R':3}[i] def switch(i,j): if(i&ltj): left,right=i,j else: left,right = j, i s = situation return s[:left] + s[right] + s[left