Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
I still get nothing but Solution.main()<:LF:>
It doesn't really tell us enough to debug it.
Okay, this works for me right now...
class Fridge def initialize @items = {} end def add(item, amount = 1) @items[item] ||= 0 @items[item] += amount end def serve(item, amount = 1) _amount = [amount, inventory(item)].min add(item, _amount * -1) _amount.times do puts "One #{item} coming right up!" end (amount - _amount).times do puts "We're all out of #{item}" end end def inventory(item = nil) if item @items[item] else @items.values.reduce(0) {|s, v| s + v} end end end ## examples: fridge = Fridge.new fridge.add :beer, 6 fridge.add :pudding, 8 fridge.add :salsa fridge.add :soda fridge.add :eggs fridge.add :steak puts "There are #{fridge.inventory} items in the fridge" puts "#{fridge.inventory(:beer)} of those are beers" fridge.serve(:beer, 7) fridge.serve(:steak) puts "There are #{fridge.inventory} items in the fridge" puts "#{fridge.inventory(:beer)} of those are beers"
Proc = fun(Y, Items) ->receive{Sender, Item} when is_pid(Sender) ->case dict:find(Item, Items) of{ok, Value} ->NewCount = Value - 1,io:format("One ~p coming right up!~n", [Item]),Sender ! Item,Y(Y, dict:store(Item, NewCount, Items));_ ->io:format("We're all out of ~p~n", [Item]),Y(Y, Items)end;{count, Item} ->case dict:find(Item, Items) of{ok, Value} -> io:format("~p: ~p~n", [Item, Value]);_ -> io:format("We're all out of ~p~n", [Item])end,Y(Y, Items);{Item, Count} when is_atom(Item) andalso is_integer(Count) ->io:format("~p added.~n", [Item]),NewCount = case dict:find(Item, Items) of{ok, Value} -> Value + Count;_ -> Countend,Y(Y, dict:store(Item, NewCount, Items));count ->io:format("~p~n", [dict:to_list(Items)]),Y(Y, Items);Item when is_atom(Item) ->io:format("~p added.~n", [Item]),NewCount = case dict:find(Item, Items) of{ok, Value} -> Value + 1;_ -> 0end,Y(Y, dict:store(Item, NewCount, Items));_ -> io:format("Killing Fridge...")- class Fridge
- def initialize
- @items = {}
- end
end,- def add(item, amount = 1)
- @items[item] ||= 0
- @items[item] += amount
- end
- def serve(item, amount = 1)
- _amount = [amount, inventory(item)].min
- add(item, _amount * -1)
- _amount.times do
- puts "One #{item} coming right up!"
- end
- (amount - _amount).times do
- puts "We're all out of #{item}"
- end
- end
- def inventory(item = nil)
- if item
- @items[item]
- else
- @items.values.reduce(0) {|s, v| s + v}
- end
- end
- end
- ## examples:
- fridge = Fridge.new
- fridge.add :beer, 6
- fridge.add :pudding, 8
- fridge.add :salsa
- fridge.add :soda
- fridge.add :eggs
- fridge.add :steak
Pid = spawn(fun() -> Proc(Proc, dict:new()) end),- puts "There are #{fridge.inventory} items in the fridge"
- puts "#{fridge.inventory(:beer)} of those are beers"
Pid ! {beer, 6},Pid ! {pudding, 8},Pid ! salsa,Pid ! soda,Pid ! eggs,Pid ! steak,Pid ! count,Pid ! {count, beer},Pid ! {self(), beer},Pid ! {count, beer},- fridge.serve(:beer, 7)
- fridge.serve(:steak)
init:stop().- puts "There are #{fridge.inventory} items in the fridge"
- puts "#{fridge.inventory(:beer)} of those are beers"
import subprocess import re mongod = subprocess.Popen("mongod", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # @jhoffner: I listen to my child process until it prints "waiting for connections" instead of sleeping... while True: l = mongod.stdout.readline() m = re.match(r".*waiting for connections on port 27017", l) if m: print l break from pymongo import MongoClient with MongoClient() as client: table = client["mongoid"]["User"] table.insert({'_id': 9999, 'first name': 'William', 'last name': 'the Conqueror'})
require 'mongoid'File.open('mongoid.yml', 'w') do |file|file.write <<-CONFIGdevelopment:sessions:default:database: mongoidhosts:- localhost:27017CONFIGendfork { `mongod` }sleep 1 # need to find a better way to wait for mongo to startup- import subprocess
- import re
- mongod = subprocess.Popen("mongod", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- # @jhoffner: I listen to my child process until it prints "waiting for connections" instead of sleeping...
- while True:
- l = mongod.stdout.readline()
- m = re.match(r".*waiting for connections on port 27017", l)
- if m:
- print l
- break
ENV['RACK_ENV'] = 'development'Mongoid.load!('mongoid.yml')class Userinclude Mongoid::Documentfield :nameend- from pymongo import MongoClient
- with MongoClient() as client:
- table = client["mongoid"]["User"]
- table.insert({'_id': 9999, 'first name': 'William', 'last name': 'the Conqueror'})
test.describe("Checking to see if Mongo contains little Billy...") from pymongo import MongoClient with MongoClient() as client: table = client["mongoid"]["User"] test.assert_equals(table.find_one()['first name'], 'William')
describe User doit 'should save' doTest.expect(User.new.save)Test.assert_equals(User.count, 1)endend- test.describe("Checking to see if Mongo contains little Billy...")
- from pymongo import MongoClient
- with MongoClient() as client:
- table = client["mongoid"]["User"]
- test.assert_equals(table.find_one()['first name'], 'William')
Proc = fun (Index) -> timer:sleep(10), io:format("~p~n", [Index]) end, [spawn(fun() -> Proc(X) end) || X <- lists:seq(1, 40)], init:stop().
Proc = fun () ->io:format("Hello Process.~n")- Proc = fun (Index) ->
- timer:sleep(10),
- io:format("~p~n", [Index])
- end,
Pid = spawn(Proc),io:format(" Hello's Pid: ~p~n", [Pid]),- [spawn(fun() -> Proc(X) end) || X <- lists:seq(1, 40)],
- init:stop().