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.
Better than a loop! Still using padStart one the minutes.
function minutes(minutes){ var hours = Math.floor(minutes/60); minutes = minutes - hours*60; return hours.toString() + ":" + minutes.toString().padStart(2, 0); }
- function minutes(minutes){
var hours = 0;while (minutes >= 60){minutes -= 60;hours += 1;};- var hours = Math.floor(minutes/60);
- minutes = minutes - hours*60;
- return hours.toString() + ":" + minutes.toString().padStart(2, 0);
- }
Another one-line version - using lambda, filter rather than a comprehension. Can anyone think of any more one-liners?
Works for unknown number of int[]
using System; using System.Linq; public static class Kata { public static int ArraySum(params int[][] arrs) { int sum = 0; foreach (int[] arr in arrs) { sum += arr.Sum(); } return sum; } }
using System;- using System;
- using System.Linq;
public static class Kata{public static int ArraySum(int[] arr1, int[] arr2, int[] arr3){int[] newArray1 = arr1.Concat(arr2).ToArray();int[] newArray2 = newArray1.Concat(arr3).ToArray();int sum = newArray2.Sum();return sum;}- public static class Kata
- {
- public static int ArraySum(params int[][] arrs)
- {
- int sum = 0;
- foreach (int[] arr in arrs)
- {
- sum += arr.Sum();
- }
- return sum;
- }
- }
type Gender = Male | Female type Person = { Name : string; Gender : Gender } let alice = { Name = "Alice"; Gender = Female } let bob = { Name = "Bob"; Gender = Male } let femaleOrMale = function | { Name = name; Gender = Female } -> name + " is female." | { Name = name; Gender = Male } -> name + " is male."
- type Gender = Male | Female
- type Person = { Name : string; Gender : Gender }
- let alice = { Name = "Alice"; Gender = Female }
- let bob = { Name = "Bob"; Gender = Male }
let femaleOrMale p =match p.Gender with| Female -> p.Name + " is female."| Male -> p.Name + " is male."- let femaleOrMale = function
- | { Name = name; Gender = Female } -> name + " is female."
- | { Name = name; Gender = Male } -> name + " is male."
using System; class Kata { public static string Main(string greeting, string language) => $"{greeting} {language}!".Tee(Console.WriteLine); } public static class Extensions { public static T Tee<T>(this T @this, Action<T> action) { action(@this); return(@this); } }
- using System;
- class Kata {
public static string Main(string greeting, string language) {Console.WriteLine(Greeting(greeting, language));return Greeting(greeting, language);}public static string Greeting(string greeting, string language) => $"{greeting} {language}!";- public static string Main(string greeting, string language)
- => $"{greeting} {language}!".Tee(Console.WriteLine);
- }
- public static class Extensions
- {
- public static T Tee<T>(this T @this, Action<T> action)
- {
- action(@this);
- return(@this);
- }
- }