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

Just testing if an NSArray can contain actual ints or only NSNumbers.

#import <Foundation/Foundation.h>

void testFunction() {
  NSMutableArray *myArray = [NSMutableArray array];
  [myArray addObject: 1];
  [myArray addObject: 2];
  [myArray addObject: 3];
  for (int i = 0; i < [myArray count]; i++) NSLog(@"%d\n", myArray[i]);
  // Invalid - compiles but doesn't give correct values 1, 2, 3
  // for (int i = 0; i < [myArray count]; i++) NSLog(@"%@\n", myArray[i]);
  NSLog(@"NSArray can indeed store `int`s as-is :D\n");
}

Just confirming that UKIntsEqual from UnitKit accepts primitive integers as arguments as opposed to NSNumber.

#import <Foundation/Foundation.h>

Just a simple check to confirm that nested NSArrays in Objective-C are allowed.

#import <Foundation/Foundation.h>

void testing() {
  @[
    @[@1, @0, @0],
    @[@0, @1, @0],
    @[@0, @0, @1]
  ];
  NSLog(@"<PASSED::>Success!\n");
}
const text* = "Hello world!"
echo text
class Box
    attr_accessor :box, :lines, :cols
    def initialize cols, lines
        @lines = lines
        @cols = cols
        @box = []
        for line in 0...@lines do
            row = []
            for col in 0...@cols do
                isEdge = col == 0 || line == 0 || col == @cols - 1 || line == @lines - 1
                row << 'x' if isEdge
                row << ' ' unless isEdge
            end
            @box << row
        end
    end

    def printBox
        for line in 0...@lines do
            str = ''
            for col in 0...@cols do
                str << @box[line][col]
            end
            puts str
        end
    end

    def placeText text, x, y
      textLength = text.length - 1 + x
      letters = text.split ""
      for col in x..textLength do
        @box[y][col] = letters[col-x]
      end
    end
end

box = Box.new 30, 30
box.placeText "Hello World", 10, 10
box.printBox
object Adder {
  def add(a: Int, b: Int): Int = a + b
}
a = "Baguette baguette baguette Encore!"
b = "Baguette baguette baguette Encore!"
p a == b
p a === b

This my solusion pass the KATA, but it fails on
test generated by rolling 3 elements ASC and DESC arrays.
https://www.codewars.com/kata/simple-array-rotation/ruby

Generating tests:

"ROTATING [1, 10, 100]is ASC"
"rt: 0 ar: [1, 10, 100]is ASC a<b and b<c and a<c"
"rt: 1 ar: [10, 100, 1] ac and a>c"

"ROTATING [100, 10, 1]is DESC"
"rt: 0 ar: [100, 10, 1]is DESC a>b and b>c and a>c"
"rt: 1 ar: [10, 1, 100] a>b and b<c and a<c"

PS:
code for generate tests https://gist.github.com/lbvf50mobile/85f5abb840f3926feb80f7dfe85d2e01

def solve(arr)
   return "A" if asc_? arr
   return "D" if desc_? arr
   if( arr.size == 3)
     a = arr
     return "RA" if  a[0] > a[1] and a[1] < a[2];
   end
   ch_rd = arr.chunk_while{ |x,y| x > y }.to_a
   ch_ra = arr.chunk_while{ |x,y| x < y }.to_a
   return "RD" if ch_rd.any?{|x| desc_? x} and ch_rd.size == 2
   return "RA" if ch_ra.any?{|x| asc_? x} and ch_ra.size == 2
   
  
end

def asc_? arr
 arr == arr.sort
end
def desc_? arr
   arr == arr.sort.reverse
end

Compare JS and Ruby REEGEX

RUBY s.scan(/!+|\?+/).inspect == JS s.match(/!+|\?+/g)

RUBY s.scan(/([?!])\1*/) != JS s.match(/([?!])\1*/g)

https://gist.github.com/lbvf50mobile/4b3cd312ad411e47582af40c7cbd4e05/edit

let slot = s => {
  console.log("ONE")
  console.log("input ", s)
  console.log("output" ,s.match(/!+|\?+/g))
  
  console.log("ONE")
  console.log("input ", s)
  console.log("output", s.match(/([?!])\1*/g))
}

slot("!!!??")