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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
# http://stackoverflow.com/questions/2136910/can-i-unit-test-an-inner-function-in-python | |
"""Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 - 5 + 67 - 8 + 9 = 100. | |
""" | |
def cons(head, tails): | |
""" |
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
""" | |
## Goal | |
This program parses md file to generate moniwiki page. | |
## Input/Output | |
>>> | |
Input: | |
## 03:07pm - 04:00pm | |
### [rubichevTask] - [moniwikiGen] |
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
def replace_image_url(self, html): | |
"""Given html from md that only has 'pic/abc.png' or similar, we return the full path that is | |
displayable from http address. | |
1. The file **should** be in the static directory, so the image files should be copied into static directory | |
2. The image link should be changed to point to that file | |
""" | |
if self.image_list: | |
# Need to create | |
# from <img alt="pic" src="pic/hello.png"/> |
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 hashlib | |
def getHash(key, bytes = 8): | |
length = len(key) | |
p = ord(key[0]) | |
x = (p << 7) | |
for i in range(length): | |
x = (1000003 * x) ^ ord(key[i]) #^ 0xDEADBEEF | |
x = x ^ length + 1 | |
return (x % (1 << 8*bytes)) |
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 unittest | |
import sys | |
import os | |
suiteString = """ | |
def suite(): | |
test_suite = unittest.TestSuite() | |
{s} | |
return test_suite | |
""" |