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
puts' ______________________________ ' | |
puts'< What\'s wrong with this food? >' | |
puts' ------------------------------ ' | |
puts' \ ^__^' | |
puts' \ (oo)\_______' | |
puts' (__)\ )\/\'' | |
puts' ||----w |' | |
puts' || ||' |
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 Data.Char (digitToInt) | |
numberToBaseString :: Int -> Int -> String | |
numberToBaseString n base | |
| n < base = show n | |
| otherwise = numberToBaseString ((n - (n `mod` base)) `div` base) base ++ show (n `mod` base) | |
baseStringToValue :: String -> Int -> Int | |
baseStringToValue n base | |
| n == [] = 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
def find_max(data): | |
"""Return the maximum element from a nonempty Python list.""" | |
biggest = data[0] | |
for val in data: | |
if val > biggest: | |
biggest = val | |
return biggest |
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 sortCommands(histFile, limit=10) | |
file = open(histFile, 'r') | |
lines = file.readlines | |
file.close | |
freqs = Hash.new(0) | |
lines.each do |line| | |
freqs[line] += 1 | |
end | |
a = freqs.sort_by {|k, v| -v}[0..limit] | |
i = 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 urllib2 | |
import random | |
import difflib | |
import datetime | |
def fetch(url): | |
"""Fetches requested url, returns lines in list""" | |
response = urllib2.urlopen(url) | |
lines = response.readlines() | |
return lines |
NewerOlder