:) (i don't know how to code)
public static class Kata { public static int SameCase(char a, char b) => !(char.IsLetter(a) && char.IsLetter(b)) ? -1 : char.IsUpper(a) == char.IsUpper(b) ? 1 : 0; }
- public static class Kata
- {
public static int SameCase(char a, char b)=> !(char.IsLetter(a) && char.IsLetter(b)) ? -1: char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;- public static int SameCase(char a, char b) => !(char.IsLetter(a) && char.IsLetter(b)) ? -1 : char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
- }
basically refactored
def max_sequence(arr): # Code to find maximum sum of subarray sum_b = sum(arr) for i in range(len(arr)): for k in range(len(arr)-i+1): sum_c = sum(arr[k:k+i]) if sum_c > sum_b: sum_b = sum_c return(sum_b)
- def max_sequence(arr):
- # Code to find maximum sum of subarray
l_a = len(arr)- sum_b = sum(arr)
for i in range(l_a):for k in range(l_a-i+1):- for i in range(len(arr)):
- for k in range(len(arr)-i+1):
- sum_c = sum(arr[k:k+i])
- if sum_c > sum_b: sum_b = sum_c
- return(sum_b)
.IsUpper() returns bools for you
public static class Kata { public static int SameCase(char a, char b) { if (char.IsLetter(a) && char.IsLetter(b)) { if (char.IsUpper(a) == char.IsUpper(b)) { return 1; } else { return 0; } } return -1; } }
- public static class Kata
- {
- public static int SameCase(char a, char b) {
bool areBothCharsLetter = char.IsLetter(a) && char.IsLetter(b);bool areSameLetters = char.IsUpper(a) == char.IsUpper(b);if (areBothCharsLetter)- if (char.IsLetter(a) && char.IsLetter(b))
- {
if (areSameLetters)- if (char.IsUpper(a) == char.IsUpper(b))
- {
- return 1;
- }
- else
{- {
- return 0;
- }
- }
- return -1;
- }
- }
ez
def other_angle(a, b): return 180 - (a + b)
def other_angle(a, b):req_angle = 180 - (a + b)return req_angle- def other_angle(a, b): return 180 - (a + b)
import codewars_test as test @test.describe("tests") def fixed_tests(): @test.it('test cases') def basic_test_cases(): test.assert_equals(other_angle(30, 60), 90) test.assert_equals(other_angle(60, 60), 60) test.assert_equals(other_angle(43, 78), 59) test.assert_equals(other_angle(10, 20), 150) test.assert_equals(other_angle(110, 30), 40) test.assert_equals(other_angle(100, 40), 40)
- import codewars_test as test
- @test.describe("tests")
- def fixed_tests():
- @test.it('test cases')
- def basic_test_cases():
- test.assert_equals(other_angle(30, 60), 90)
- test.assert_equals(other_angle(60, 60), 60)
- test.assert_equals(other_angle(43, 78), 59)
- test.assert_equals(other_angle(10, 20), 150)
- test.assert_equals(other_angle(110, 30), 40)
- test.assert_equals(other_angle(100, 40), 40)