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

TIL that

instance Foldable ((,) a) where
    foldMap f (_, y) = f y
    foldr f z (_, y) = f y z
module FoldableTuple2 where
-- see the tests

Why when i try to run it i get the EOFError? I don't get it when i test in Python 3.6.5 Shell

from datetime import datetime
a = datetime.now()
c = str(a.hour) + str(a.minute)
b = input("Please, print the password here (without letters!): ")
if b.isdigit():
    if(b == c):
        print("ACCESS CONFIRMED")
    else:
        print("ACCESS DENIED")
else:
    print("Please, don't print letters.")
    print("Reset the program.")
#include <stdlib.h>

typedef struct IntVector {
  int *data;
} IntVector;

IntVector *IntVector_new(size_t size) {
  IntVector *this = malloc(sizeof(IntVector));
  this->data = calloc(sizeof(*this->data), size);
  return this;
}

void IntVector_free(IntVector *this) {
  free(this->data);
  free(this);
}

int IntVector_get(const IntVector *this, size_t index) {
  return this->data[index];
}

void IntVector_set(IntVector *this, size_t index, int value) {
  return this->data[index] = value;
}

Yes and no. A queue can be implemented using one explicit stack by leveraging the technique of recursion in the "dequeue" operation but note that recursion is handled internally by a function call stack; hence, technically, there are still two stacks at work ;)

class Queue {
  constructor() {
    this._stack = []; // We will be using this array as a stack - only
    // its push and pop operations will ever be called
  }
  enqueue(data) {
    this._stack.push(data);
  }
  dequeue() {
    if (this._stack.length === 1)
      return this._stack.pop();
    else {
      var tmp = this._stack.pop(), result = this.dequeue();
      this.enqueue(tmp);
      return result;
    }
  }
}
def array_of_two(n)
  raise 'n is not a number' unless n.is_a?(Numeric)  # comment to fail test case
  [n, n]
end

Just testing whether it is possible to "cheat" using the stack internally maintained by the computer to "implement" stack operations (between calls) in NASM.

Conclusion: It doesn't seem to be possible - at least with the way I did it, I got a segfault during the first call to stack_push() which just attempts to push its second argument to the internal stack and returns to the caller, let alone the pop and peek operations. There also doesn't seem to be a reliable way to check whether the internal stack is empty. Thus, it should be safe to translate my recent Stacks kata into NASM.

global stack_push, stack_pop, stack_peek ; , stack_is_empty
section .text
stack_push:
  push rsi
  ret
stack_pop:
  pop rsi
  ret
stack_peek:
  pop rsi
  push rsi
  ret
class Functionator
  def initialize(s)
    s.split(' ').each { | i | define_singleton_method :"#{i}" do Functionator.new(s.split(' ')[1..-1].join(' ')) end }
  end
end

def functionator(string)
  Functionator.new(string)
end

A mistake they don't want to fix...

function describePhp() {
  return 2 * 2 == 4 ? 'php is good' : 2 * 2 == 5 ? 'php is weird' : 'php has features';
}

Don't know how this "kumite" stuff works yet, so i may be doing sth wrong.
This is about finding better/more efficient ways to permutate a list starting with my sorry attempt. The result requires types of the typeclass Ord, to get a common result for the test cases. Havent thought about a way to solve that differently yet.

module Permutation where

import Data.List (sort)

permu :: [a] ->[[a]]
permu []  = [[]]
permu [x] = [[x]]
permu x = fuzz (length x) 0 x
        where fuzz l n (x:xs) |n == l = []
                              |otherwise = map ((:) x) (permu xs) ++ fuzz l (n+1) (xs ++ [x])
                            
permutation :: Ord a => [a] -> [[a]]                           
permutation x = permu x

Lets go back to grade school!

Solve for the hypotenuse of a triangle.

Round a float to 4 decimal places.

def hypotenuse(a,b):

    import math
    h = round(math.sqrt(a**2 + b**2),4)
    #print(h)
    return h