Skip to content

Instantly share code, notes, and snippets.

View arnabkd's full-sized avatar

Arnab Datta arnabkd

View GitHub Profile
irb(main):001:0> require 'capybara/culerity'
=> true
irb(main):002:0> session = Capybara::Session.new(:culerity)
=> #<Capybara::Session>
irb(main):003:0> session.visit('http://www.vg.no')
Capybara::DriverNotFoundError: no driver called :culerity was found, available drivers: :rack_test, :selenium
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.5.0/lib/capybara/session.rb:82:in `driver'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.5.0/lib/capybara/session.rb:232:in `visit'
from (irb):3
from /usr/bin/irb:12:in `<main>'
import random
def rand7():
return random.randrange(1,8)
def rand5_mod():
return rand7() % 5 + 1
def rand5_recursive():
roll = rand7()
[{
"cells": {"1": "one", "2": "two"}
}]
public static void main () {
System.err.println();
}
#return fitness of a path
def fitness(path):
pass
#swap two random indices
def random_swap(l):
i = randint(0,len(l) - 1)
j = randint(0,len(l) - 1)
l[i], l[j] = l[j], l[i]
return l
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
@arnabkd
arnabkd / math_quiz.py
Created June 12, 2012 11:15
Example of FP and imperative in python
#Task 9.5 - Arnab Kumar Datta (arnabkd)
import operator,random
levels = {'B' : 10 , 'I': 25 , 'A':100}
func = {'add': operator.add, 'mul' : operator.mul, 'sub' : operator.sub}
ops = {func['add'] : '+' , func['mul'] : '*', func['sub'] : '-'}
messages = ['Please ask your math teacher for help!','You need more practice.',\
'Well done!']
def play(level,op):
operand1 = random.randint(1,level); operand2 = random.randint(1,level)
@arnabkd
arnabkd / roshambo.py
Created October 27, 2011 21:49
Rock paper scissors
import random
players = ['Tie','Player','Computer']
scores = [0,0,0]
choices = {'r':0 , 'p':1 , 's':2}
inv_choices = {0:'rock', 1:'paper', 2:'scissors'}
def main():
try:
post = int(raw_input("Enter number of points required to win: "))
except: