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.
fn solution(mut x: i32) -> bool { x.to_string().chars().into_iter().position(|s| s == '3').map_or(false, |_| true) } /* fn solution(mut x: i32) -> bool { while x != 0 { if x - x/10 == 3 { return true; } } false } */
- fn solution(mut x: i32) -> bool {
match x.to_string().chars().into_iter().position(|s| s == '3') {Some(_t) => true,_e => false,- x.to_string().chars().into_iter().position(|s| s == '3').map_or(false, |_| true)
- }
- /*
- fn solution(mut x: i32) -> bool {
- while x != 0 {
- if x - x/10 == 3 {
- return true;
- }
- }
}- false
- }
- */
Design an algorithm that accepts a positive integer and reverses the order of its digits.
def reverse_int(int) int.to_s.reverse.to_i end
public class Algorithms {public static int reverseInt(int n) {int reversed = 0;while(n != 0){reversed = reversed * 10 + (n % 10);n /= 10;}return reversed;}}- def reverse_int(int)
- int.to_s.reverse.to_i
- end
describe "test reverse_int()" do it "should return reversed integers" do for i in 0..4 do int = [698, 132, 86, 2345, 29384765][i] answer = [896, 231, 68, 5432, 56748392][i] expect(reverse_int(int)).to eq(answer) puts "int#{i}: " + int.to_s puts "answer#{i}: " + answer.to_s end end end
import org.junit.Test;import static org.junit.Assert.assertEquals;import org.junit.runners.JUnit4;// TODO: Replace examples and use TDD development by writing your own testspublic class SolutionTest {@Testpublic void reverseIntTest() {assertEquals(54321, Algorithms.reverseInt(12345));}}- describe "test reverse_int()" do
- it "should return reversed integers" do
- for i in 0..4 do
- int = [698, 132, 86, 2345, 29384765][i]
- answer = [896, 231, 68, 5432, 56748392][i]
- expect(reverse_int(int)).to eq(answer)
- puts "int#{i}: " + int.to_s
- puts "answer#{i}: " + answer.to_s
- end
- end
- end
def prime_checker(n): if n in [2, 3, 5]: return True elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0: return False a = int(n ** 0.5 / 30) b = [7, 11, 13, 17, 19, 23, 29, 31] for i in [30 * j for j in range(a + 1)]: if True in [n % (i + q) == 0 for q in b if i + q is not n]: return False return True
"""https://en.wikipedia.org/wiki/Primality_testThis one has lesser tests or usage of % operator.An alternative using primality mod 30 = 2 * 3 * 5 instead of 6 = 2 * 3"""- def prime_checker(n):
- if n in [2, 3, 5]:
- return True
- elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
- return False
- a = int(n ** 0.5 / 30)
- b = [7, 11, 13, 17, 19, 23, 29, 31]
- for i in [30 * j for j in range(a + 1)]:
- if True in [n % (i + q) == 0 for q in b if i + q is not n]:
- return False
- return True