And even more by removing the foreach bracket, writing System.IComparable instead of writing "using System" at the beggining and removing the useless "public" before the class declaration
class Math{public static T Max<T>(params T[]p)where T:System.IComparable<T>{foreach(T a in p)p[0]=p[0].CompareTo(a)<0?a:p[0];return p[0];}}
using System;public class Math{public static T Max<T>(params T[]p)where T:IComparable<T>{foreach(T a in p){p[0]=p[0].CompareTo(a)<0?a:p[0];}return p[0];}}- class Math{public static T Max<T>(params T[]p)where T:System.IComparable<T>{foreach(T a in p)p[0]=p[0].CompareTo(a)<0?a:p[0];return p[0];}}
better lol
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){if (!char.IsLetter(a) || !char.IsLetter(b))return -1;return 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;
- }
Binary (or base two) is the counting system computers use to do calculations.
Binary values are written using only two values, contrary to our usual counting system which uses ten values.
Here's the wikipedia on binary numbers: https://en.wikipedia.org/wiki/Binary_number#Binary_counting
Your goal is to write a function that adds too binary numbers together whatever their length is.
using System;
using System.Collections.Generic;
class BinaryCalc
{
public static IEnumerable<bool> Add(bool[] a, bool[] b)
{
const bool I = true;
const bool O = false;
for (int i = 0; i < a.Length; i++)
{
}
return new bool[1];
}
}
namespace Solution {
using NUnit.Framework;
using System;
[TestFixture]
public class SolutionTest
{
private const bool I = true;
private const bool O = false;
[Test]
public void MyTest()
{
bool[] a1 = new bool[] {I, I, O};
bool[] b1 = new bool[] {I, O, I, I};
bool[] r1 = new bool[] {I, O, O, O, I};
Assert.AreEqual(r1, BinaryCalc.Add(a1, b1));
}
}
}