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 fb(n): | |
ret = "" | |
if n % 3 == 0: | |
ret += "Fizz" | |
if n % 5 == 0: | |
ret += "Buzz" | |
return ret | |
i = 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
mod3 = {True: "Fizz", False: ""} | |
mod5 = {True: "Buzz", False: ""} | |
def fb(n): | |
return mod3[n % 3 == 0] + mod5[n % 5 == 0] | |
i = 1 | |
while i <= 20: | |
print i, fb(i) |
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 | |
argc = len(sys.argv) | |
if argc == 1: | |
f = sys.stdin | |
elif argc == 2: | |
try: | |
f = open(sys.argv[1], "rU") | |
except IOError: | |
sys.exit("nl : %s: No such file or directory" % (sys.argv[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
import sys | |
import time | |
start = time.clock() | |
s = sys.stdin.read() | |
lap1 = time.clock() | |
s = s.lower() | |
for c in ",.-_;:'\"?(){}[]/@~`!*": | |
s = s.replace(c, ' ') |
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 | |
import time | |
from collections import Counter | |
start = time.clock() | |
s = sys.stdin.read() | |
lap1 = time.clock() | |
s = s.lower() | |
for c in ",.-_;:'\"?(){}[]/@~`!*": |
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
start = Time.now | |
s = $stdin.read | |
lap1 = Time.now | |
l = s.downcase().split(/\W+/) | |
puts "Number of words: #{l.size}" | |
lap2 = Time.now | |
g = Hash.new(0) | |
l.each { |w| g[w] += 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
#include <string> | |
#include <unordered_map> | |
#include <iostream> | |
#include <ctime> | |
using namespace std; | |
const int MAX_SIZE = 100000000; // 100MB buffer | |
bool isSeparator(char c) { |
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 sum7(li): | |
ret = 0 | |
pre_seven = 1 | |
for a in li: | |
ret = ret + a * pre_seven | |
if a == 7: | |
pre_seven = 2 | |
else: | |
pre_seven = 1 | |
return ret |
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 verb_post(s): | |
s.lower() | |
dict = { | |
"go": "went", | |
"write": "wrote", | |
"read": "read", | |
"have": "had", | |
"has": "had" | |
} |
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
print("### rekog.py library import start") | |
import picamera | |
import subprocess | |
from google_translate import * | |
import json | |
print("### Camera Start") | |
camera = picamera.PiCamera() | |
camera.resolution = (1024, 768) |
OlderNewer