Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
#This code gets all the comic strips from the webcomic
#Saturday Morning Breakfast Cereal (SMBC) and downloads them to a local folder
#Tobias Rusås Olsen (& Bjørn Arild Mæland) - © 2008.
require 'date'
require 'net/http'
STARTDATE = "2008-08-20"
TARGETDIR = "bilder/"
# -*- coding: utf-8 -*-
#This code gets all the comic strips from the webcomic
#Saturday Morning Breakfast Cereal (SMBC) and downloads them to a local folder
#Tobias Rusås Olsen (& Bjørn Arild Mæland) - © 2008.
require 'rubygems'
require 'net/http'
require 'active_support'
STARTDATE = "2008-08-31"
def consistent?(phone_numbers)
phone_numbers.each do |num|
phone_numbers - [ num ].each { |o| return "NO" if %r{^#{num}}.match(o) }
end
"YES"
end
gets.to_i.times do
num_array = []
gets.to_i.times { num_array << gets.chomp }
def max_discount(prices)
prices = prices.sort.reverse
discount = 0
while prices != []
discount += prices[0..2].min
prices = prices[3..-1]
end
discount
end
def hashing_necessary? numwords, hashkeys
numkeys = hashkeys.flatten.uniq.size
(numkeys < numwords) ? "rehash necessary" : "successful hashing"
end
puts hashing_necessary? 3, [[0, 1], [1, 2], [2, 0]]
puts hashing_necessary? 6, [[2, 3], [3, 1], [1, 2], [5, 1], [2, 5]]
Opg 1.
Action(move(X, Y),
Precond: blank(X) ^ tile(Y) ^ adjacent(X, Y)
Effect: blank(Y) ^ tile(X)
Opg 2.
1)
#!/usr/bin/env python
r"""
=================
snippet_copier.py
=================
A script which downloads snippets from bundles in the `TextMate`_ `svn repo`_
and attempts to create duplicate `YASnippets`_, written by `Jeff Wheeler`_.
Synopsis
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
(require 'htmlize)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# NLTK test-suite runner
#
# Author: Bjørn Arild Mæland <[email protected]>
#
import os, sys
import doctest_driver
#!/usr/bin/env ruby
require "rton"
include Automaton
pda = Automaton.setup(:pda) do
initial_state :q0 do
transition ['a', EMPTY], [:q0, 'A']
transition ['b', 'A'], [:q1, EMPTY]
end