Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad

I still get nothing but Solution.main()<:LF:>
It doesn't really tell us enough to debug it.

Code
Diff
  • class Solution {
        public static void main(String[] args) {
            System.out.println("Hello World :D");
        }
    }
    • class Solution {
    • public static void main(String[] args) {
    • System.out.println("Hello darkness, my old friend...");
    • System.out.println("Hello World :D");
    • }
    • }

Okay, this works for me right now...

Code
Diff
  • public class Java {
      public static int multiply(int x, int y) {
        return y * x;
      }
    }
    • public class Java {
    • public static int multiply(int x, int y) {
    • return x * y;
    • return y * x;
    • }
    • }
Code
Diff
  • fn main() {
        println!("All we are in rust in the wind...");
    }
    • println "hello, world"
    • fn main() {
    • println!("All we are in rust in the wind...");
    • }
Code
Diff
  • 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;
    • _ -> Count
    • end,
    • 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;
    • _ -> 0
    • end,
    • 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"
MongoDB
NoSQL
Databases
Code
Diff
  • 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 <<-CONFIG
    • development:
    • sessions:
    • default:
    • database: mongoid
    • hosts:
    • - localhost:27017
    • CONFIG
    • end
    • fork { `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 User
    • include Mongoid::Document
    • field :name
    • end
    • from pymongo import MongoClient
    • with MongoClient() as client:
    • table = client["mongoid"]["User"]
    • table.insert({'_id': 9999, 'first name': 'William', 'last name': 'the Conqueror'})
Code
Diff
  • 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().