task_id
stringlengths 18
20
| language
stringclasses 1
value | prompt
stringlengths 366
1.93k
| test
stringlengths 438
26.2k
| entry_point
stringlengths 1
24
| canonical_solution
stringclasses 0
values | description
stringlengths 0
1.21k
|
---|---|---|---|---|---|---|
HumanEval_csharp/103 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given two positive integers n and m, and your task is to compute the
/// average of the integers from n through m (including n and m).
/// Round the answer to the nearest integer and convert that to binary.
/// If n is greater than m, return -1.
/// Example:
/// RoundedAvg(1, 5) => "0b11"
/// RoundedAvg(7, 5) => -1
/// RoundedAvg(10, 20) => "0b1111"
/// RoundedAvg(20, 33) => "0b11010"
///
/// </summary>
public static object RoundedAvg (int n, int m)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = RoundedAvg(1,5);
var expected1 = "0b11";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = RoundedAvg(7,13);
var expected2 = "0b1010";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = RoundedAvg(964,977);
var expected3 = "0b1111001010";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = RoundedAvg(996,997);
var expected4 = "0b1111100100";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = RoundedAvg(560,851);
var expected5 = "0b1011000010";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = RoundedAvg(185,546);
var expected6 = "0b101101110";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = RoundedAvg(362,496);
var expected7 = "0b110101101";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = RoundedAvg(350,902);
var expected8 = "0b1001110010";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = RoundedAvg(197,233);
var expected9 = "0b11010111";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = RoundedAvg(7,5);
var expected10 = -1;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = RoundedAvg(5,1);
var expected11 = -1;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = RoundedAvg(5,5);
var expected12 = "0b101";
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
}
}
}
| RoundedAvg | null | You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and convert that to binary.
If n is greater than m, return -1.
Example:
rounded_avg(1, 5) => "0b11"
rounded_avg(7, 5) => -1
rounded_avg(10, 20) => "0b1111"
rounded_avg(20, 33) => "0b11010"
|
HumanEval_csharp/104 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a list of positive integers x. return a sorted list of all
/// elements that hasn't any even digit.
///
/// Note: Returned list should be sorted in increasing order.
///
/// For example:
/// >>> UniqueDigits([15, 33, 1422, 1])
/// [1, 15, 33]
/// >>> UniqueDigits([152, 323, 1422, 10])
/// []
///
/// </summary>
public static List<int> UniqueDigits (List<int> x)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = UniqueDigits(new List<int> {15,33,1422,1});
var expected1 = new List<int> {1,15,33};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = UniqueDigits(new List<int> {152,323,1422,10});
var expected2 = new List<int> {};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = UniqueDigits(new List<int> {12345,2033,111,151});
var expected3 = new List<int> {111,151};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = UniqueDigits(new List<int> {135,103,31});
var expected4 = new List<int> {31,135};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| UniqueDigits | null | Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
>>> unique_digits([15, 33, 1422, 1])
[1, 15, 33]
>>> unique_digits([152, 323, 1422, 10])
[]
|
HumanEval_csharp/105 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given an array of integers, sort the integers that are between 1 and 9 inclusive,
/// reverse the resulting array, and then replace each digit by its corresponding name from
/// "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
///
/// For example:
/// arr = [2, 1, 1, 4, 5, 8, 2, 3]
/// -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
/// -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
/// return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]
///
/// If the array is empty, return an empty array:
/// arr = []
/// return []
///
/// If the array has any strange number ignore it:
/// arr = [1, -1 , 55]
/// -> sort arr -> [-1, 1, 55]
/// -> reverse arr -> [55, 1, -1]
/// return = ['One']
///
/// </summary>
public static List<string> ByLength (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = ByLength(new List<int> {2,1,1,4,5,8,2,3});
var expected1 = new List<string> {"Eight","Five","Four","Three","Two","Two","One","One"};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = ByLength(new List<int> {});
var expected2 = new List<string> {};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = ByLength(new List<int> {1,-1,55});
var expected3 = new List<string> {"One"};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = ByLength(new List<int> {1,-1,3,2});
var expected4 = new List<string> {"Three","Two","One"};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = ByLength(new List<int> {9,4,8});
var expected5 = new List<string> {"Nine","Eight","Four"};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| ByLength | null |
Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
For example:
arr = [2, 1, 1, 4, 5, 8, 2, 3]
-> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
-> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]
If the array is empty, return an empty array:
arr = []
return []
If the array has any strange number ignore it:
arr = [1, -1 , 55]
-> sort arr -> [-1, 1, 55]
-> reverse arr -> [55, 1, -1]
return = ['One']
|
HumanEval_csharp/106 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Implement the Function F that takes n as a parameter,
/// and returns a list oF size n, such that the value oF the element at index i is the Factorial oF i iF i is even
/// or the sum oF numbers From 1 to i otherwise.
/// i starts From 1.
/// the Factorial oF i is the multiplication oF the numbers From 1 to i (1 * 2 * ... * i).
/// Example:
/// F(5) == [1, 2, 6, 24, 15]
///
/// </summary>
public static List<int> F (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = F(5);
var expected1 = new List<int> {1,2,6,24,15};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = F(7);
var expected2 = new List<int> {1,2,6,24,15,720,28};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = F(1);
var expected3 = new List<int> {1};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = F(3);
var expected4 = new List<int> {1,2,6};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| F | null | Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of numbers from 1 to i otherwise.
i starts from 1.
the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
Example:
f(5) == [1, 2, 6, 24, 15]
|
HumanEval_csharp/107 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a positive integer n, return a tuple that has the number of even and odd
/// integer palindromes that fall within the range(1, n), inclusive.
///
/// Example 1:
///
/// Input: 3
/// Output: (1, 2)
/// Explanation:
/// Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
///
/// Example 2:
///
/// Input: 12
/// Output: (4, 6)
/// Explanation:
/// Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
///
/// Note:
/// 1. 1 <= n <= 10^3
/// 2. returned tuple has the number of even and odd integer palindromes respectively.
///
/// </summary>
public static List<int> EvenOddPalindrome (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = EvenOddPalindrome(123);
var expected1 = new List<int> {8,13};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = EvenOddPalindrome(12);
var expected2 = new List<int> {4,6};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = EvenOddPalindrome(3);
var expected3 = new List<int> {1,2};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = EvenOddPalindrome(63);
var expected4 = new List<int> {6,8};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = EvenOddPalindrome(25);
var expected5 = new List<int> {5,6};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = EvenOddPalindrome(19);
var expected6 = new List<int> {4,6};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = EvenOddPalindrome(9);
var expected7 = new List<int> {4,5};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = EvenOddPalindrome(1);
var expected8 = new List<int> {0,1};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| EvenOddPalindrome | null |
Given a positive integer n, return a tuple that has the number of even and odd
integer palindromes that fall within the range(1, n), inclusive.
Example 1:
Input: 3
Output: (1, 2)
Explanation:
Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
Example 2:
Input: 12
Output: (4, 6)
Explanation:
Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
Note:
1. 1 <= n <= 10^3
2. returned tuple has the number of even and odd integer palindromes respectively.
|
HumanEval_csharp/108 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Write a function CountNums which takes an array of integers and returns
/// the number of elements which has a sum of digits > 0.
/// If a number is negative, then its first signed digit will be negative:
/// e.g. -123 has signed digits -1, 2, and 3.
/// >>> CountNums([]) == 0
/// >>> CountNums([-1, 11, -11]) == 1
/// >>> CountNums([1, 1, 2]) == 3
///
/// </summary>
public static int CountNums (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = CountNums(new List<int> {});
var expected1 = 0;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = CountNums(new List<int> {-1,-2,0});
var expected2 = 0;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = CountNums(new List<int> {1,1,2,-2,3,4,5});
var expected3 = 6;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = CountNums(new List<int> {1,6,9,-6,0,1,5});
var expected4 = 5;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = CountNums(new List<int> {1,100,98,-7,1,-1});
var expected5 = 4;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = CountNums(new List<int> {12,23,34,-45,-56,0});
var expected6 = 5;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = CountNums(new List<int> {0,1});
var expected7 = 1;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = CountNums(new List<int> {1});
var expected8 = 1;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| CountNums | null |
Write a function count_nums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will be negative:
e.g. -123 has signed digits -1, 2, and 3.
>>> count_nums([]) == 0
>>> count_nums([-1, 11, -11]) == 1
>>> count_nums([1, 1, 2]) == 3
|
HumanEval_csharp/109 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
/// numbers in the array will be randomly ordered. Your task is to determine if
/// it is possible to get an array sorted in non-decreasing order by performing
/// the following operation on the given array:
/// You are allowed to perform right shift operation any number of times.
///
/// One right shift operation means shifting all elements of the array by one
/// position in the right direction. The last element of the array will be moved to
/// the starting position in the array i.e. 0th index.
///
/// If it is possible to obtain the sorted array by performing the above operation
/// then return True else return False.
/// If the given array is empty then return True.
///
/// Note: The given list is guaranteed to have unique elements.
///
/// For Example:
///
/// MoveOneBall([3, 4, 5, 1, 2])==>True
/// Explanation: By performin 2 right shift operations, non-decreasing order can
/// be achieved for the given array.
/// MoveOneBall([3, 5, 4, 1, 2])==>False
/// Explanation:It is not possible to get non-decreasing order for the given
/// array by performing any number of right shift operations.
///
///
/// </summary>
public static bool MoveOneBall (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = MoveOneBall(new List<int> {3,4,5,1,2});
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = MoveOneBall(new List<int> {3,5,10,1,2});
var expected2 = true;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = MoveOneBall(new List<int> {4,3,1,2});
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = MoveOneBall(new List<int> {3,5,4,1,2});
var expected4 = false;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = MoveOneBall(new List<int> {});
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| MoveOneBall | null | We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in non-decreasing order by performing
the following operation on the given array:
You are allowed to perform right shift operation any number of times.
One right shift operation means shifting all elements of the array by one
position in the right direction. The last element of the array will be moved to
the starting position in the array i.e. 0th index.
If it is possible to obtain the sorted array by performing the above operation
then return True else return False.
If the given array is empty then return True.
Note: The given list is guaranteed to have unique elements.
For Example:
move_one_ball([3, 4, 5, 1, 2])==>True
Explanation: By performin 2 right shift operations, non-decreasing order can
be achieved for the given array.
move_one_ball([3, 5, 4, 1, 2])==>False
Explanation:It is not possible to get non-decreasing order for the given
array by performing any number of right shift operations.
|
HumanEval_csharp/110 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// In this problem, you will implement a function that takes two lists of numbers,
/// and determines whether it is possible to perform an Exchange of elements
/// between them to make lst1 a list of only even numbers.
/// There is no limit on the number of Exchanged elements between lst1 and lst2.
/// If it is possible to Exchange elements between the lst1 and lst2 to make
/// all the elements of lst1 to be even, return "YES".
/// Otherwise, return "NO".
/// For example:
/// Exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES"
/// Exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO"
/// It is assumed that the input lists will be non-empty.
///
/// </summary>
public static string Exchange (List<int> lst1, List<int> lst2)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Exchange(new List<int> {1,2,3,4},new List<int> {1,2,3,4});
var expected1 = "YES";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Exchange(new List<int> {1,2,3,4},new List<int> {1,5,3,4});
var expected2 = "NO";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Exchange(new List<int> {1,2,3,4},new List<int> {2,1,4,3});
var expected3 = "YES";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Exchange(new List<int> {5,7,3},new List<int> {2,6,4});
var expected4 = "YES";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Exchange(new List<int> {5,7,3},new List<int> {2,6,3});
var expected5 = "NO";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Exchange(new List<int> {3,2,6,1,8,9},new List<int> {3,5,5,1,1,1});
var expected6 = "NO";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Exchange(new List<int> {100,200},new List<int> {200,200});
var expected7 = "YES";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| Exchange | null | In this problem, you will implement a function that takes two lists of numbers,
and determines whether it is possible to perform an exchange of elements
between them to make lst1 a list of only even numbers.
There is no limit on the number of exchanged elements between lst1 and lst2.
If it is possible to exchange elements between the lst1 and lst2 to make
all the elements of lst1 to be even, return "YES".
Otherwise, return "NO".
For example:
exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES"
exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO"
It is assumed that the input lists will be non-empty.
|
HumanEval_csharp/111 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a string representing a space separated lowercase letters, return a dictionary
/// of the letter with the most repetition and containing the corresponding count.
/// If several letters have the same occurrence, return all of them.
///
/// Example:
/// Histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
/// Histogram('a b b a') == {'a': 2, 'b': 2}
/// Histogram('a b c a b') == {'a': 2, 'b': 2}
/// Histogram('b b b b a') == {'b': 4}
/// Histogram('') == {}
///
///
/// </summary>
public static Dictionary<string, int> Histogram (string test)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Histogram("a b b a");
var expected1 = new Dictionary<string, int> {{"a", 2},{"b", 2}};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Histogram("a b c a b");
var expected2 = new Dictionary<string, int> {{"a", 2},{"b", 2}};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Histogram("a b c d g");
var expected3 = new Dictionary<string, int> {{"a", 1},{"b", 1},{"c", 1},{"d", 1},{"g", 1}};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Histogram("r t g");
var expected4 = new Dictionary<string, int> {{"r", 1},{"t", 1},{"g", 1}};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Histogram("b b b b a");
var expected5 = new Dictionary<string, int> {{"b", 4}};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Histogram("r t g");
var expected6 = new Dictionary<string, int> {{"r", 1},{"t", 1},{"g", 1}};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Histogram("");
var expected7 = new Dictionary<string, int> {};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Histogram("a");
var expected8 = new Dictionary<string, int> {{"a", 1}};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| Histogram | null | Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters have the same occurrence, return all of them.
Example:
histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
histogram('a b b a') == {'a': 2, 'b': 2}
histogram('a b c a b') == {'a': 2, 'b': 2}
histogram('b b b b a') == {'b': 4}
histogram('') == {}
|
HumanEval_csharp/112 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Task
/// We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
/// then check if the result string is palindrome.
/// A string is called palindrome if it reads the same backward as forward.
/// You should return a tuple containing the result string and True/False for the check.
/// Example
/// For s = "abcde", c = "ae", the result should be ('bcd',False)
/// For s = "abcdef", c = "b" the result should be ('acdef',False)
/// For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
///
/// </summary>
public static List<object> ReverseDelete (string s, string c)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = ReverseDelete("abcde","ae");
var expected1 = new List<object> {"bcd",false};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = ReverseDelete("abcdef","b");
var expected2 = new List<object> {"acdef",false};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = ReverseDelete("abcdedcba","ab");
var expected3 = new List<object> {"cdedc",true};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = ReverseDelete("dwik","w");
var expected4 = new List<object> {"dik",false};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = ReverseDelete("a","a");
var expected5 = new List<object> {"",true};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = ReverseDelete("abcdedcba","");
var expected6 = new List<object> {"abcdedcba",true};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = ReverseDelete("abcdedcba","v");
var expected7 = new List<object> {"abcdedcba",true};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = ReverseDelete("vabba","v");
var expected8 = new List<object> {"abba",true};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = ReverseDelete("mamma","mia");
var expected9 = new List<object> {"",true};
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
}
}
}
| ReverseDelete | null | Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is called palindrome if it reads the same backward as forward.
You should return a tuple containing the result string and True/False for the check.
Example
For s = "abcde", c = "ae", the result should be ('bcd',False)
For s = "abcdef", c = "b" the result should be ('acdef',False)
For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
|
HumanEval_csharp/113 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a list of strings, where each string consists of only digits, return a list.
/// Each element i of the output should be "the number of odd elements in the
/// string i of the input." where all the i's should be replaced by the number
/// of odd digits in the i'th string of the input.
///
/// >>> OddCount(['1234567'])
/// ["the number of odd elements 4n the str4ng 4 of the 4nput."]
/// >>> OddCount(['3',"11111111"])
/// ["the number of odd elements 1n the str1ng 1 of the 1nput.",
/// "the number of odd elements 8n the str8ng 8 of the 8nput."]
///
/// </summary>
public static List<string> OddCount (List<string> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = OddCount(new List<string> {"1234567"});
var expected1 = new List<string> {"the number of odd elements 4n the str4ng 4 of the 4nput."};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = OddCount(new List<string> {"3","11111111"});
var expected2 = new List<string> {"the number of odd elements 1n the str1ng 1 of the 1nput.","the number of odd elements 8n the str8ng 8 of the 8nput."};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = OddCount(new List<string> {"271","137","314"});
var expected3 = new List<string> {"the number of odd elements 2n the str2ng 2 of the 2nput.","the number of odd elements 3n the str3ng 3 of the 3nput.","the number of odd elements 2n the str2ng 2 of the 2nput."};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
}
}
}
| OddCount | null | Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should be replaced by the number
of odd digits in the i'th string of the input.
>>> odd_count(['1234567'])
["the number of odd elements 4n the str4ng 4 of the 4nput."]
>>> odd_count(['3',"11111111"])
["the number of odd elements 1n the str1ng 1 of the 1nput.",
"the number of odd elements 8n the str8ng 8 of the 8nput."]
|
HumanEval_csharp/114 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given an array of integers nums, find the minimum sum of any non-empty sub-array
/// of nums.
/// Example
/// MinSubArraySum([2, 3, 4, 1, 2, 4]) == 1
/// MinSubArraySum([-1, -2, -3]) == -6
///
/// </summary>
public static int MinSubArraySum (List<int> nums)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = MinSubArraySum(new List<int> {2,3,4,1,2,4});
var expected1 = 1;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = MinSubArraySum(new List<int> {-1,-2,-3});
var expected2 = -6;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = MinSubArraySum(new List<int> {-1,-2,-3,2,-10});
var expected3 = -14;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = MinSubArraySum(new List<int> {-9999999999999999});
var expected4 = -9999999999999999;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = MinSubArraySum(new List<int> {0,10,20,1000000});
var expected5 = 0;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = MinSubArraySum(new List<int> {-1,-2,-3,10,-5});
var expected6 = -6;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = MinSubArraySum(new List<int> {100,-1,-2,-3,10,-5});
var expected7 = -6;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = MinSubArraySum(new List<int> {10,11,13,8,3,4});
var expected8 = 3;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = MinSubArraySum(new List<int> {100,-33,32,-1,0,-2});
var expected9 = -33;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = MinSubArraySum(new List<int> {-10});
var expected10 = -10;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = MinSubArraySum(new List<int> {7});
var expected11 = 7;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = MinSubArraySum(new List<int> {1,-1});
var expected12 = -1;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
}
}
}
| MinSubArraySum | null |
Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
minSubArraySum([-1, -2, -3]) == -6
|
HumanEval_csharp/115 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You are given a rectangular grid of wells. Each row represents a single well,
/// and each 1 in a row represents a single unit of water.
/// Each well has a corresponding bucket that can be used to extract water from it,
/// and all buckets have the same capacity.
/// Your task is to use the buckets to empty the wells.
/// Output the number of times you need to lower the buckets.
///
/// Example 1:
/// Input:
/// grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
/// bucket_capacity : 1
/// Output: 6
///
/// Example 2:
/// Input:
/// grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
/// bucket_capacity : 2
/// Output: 5
///
/// Example 3:
/// Input:
/// grid : [[0,0,0], [0,0,0]]
/// bucket_capacity : 5
/// Output: 0
///
/// Constraints:
/// * all wells have the same length
/// * 1 <= grid.length <= 10^2
/// * 1 <= grid[:,1].length <= 10^2
/// * grid[i][j] -> 0 | 1
/// * 1 <= capacity <= 10
///
/// </summary>
public static int MaxFill (List<List<int>> grid, int capacity)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = MaxFill(new List<List<int>> {new List<int> {0,0,1,0},new List<int> {0,1,0,0},new List<int> {1,1,1,1}},1);
var expected1 = 6;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = MaxFill(new List<List<int>> {new List<int> {0,0,1,1},new List<int> {0,0,0,0},new List<int> {1,1,1,1},new List<int> {0,1,1,1}},2);
var expected2 = 5;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = MaxFill(new List<List<int>> {new List<int> {0,0,0},new List<int> {0,0,0}},5);
var expected3 = 0;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = MaxFill(new List<List<int>> {new List<int> {1,1,1,1},new List<int> {1,1,1,1}},2);
var expected4 = 4;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = MaxFill(new List<List<int>> {new List<int> {1,1,1,1},new List<int> {1,1,1,1}},9);
var expected5 = 2;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| MaxFill | null |
You are given a rectangular grid of wells. Each row represents a single well,
and each 1 in a row represents a single unit of water.
Each well has a corresponding bucket that can be used to extract water from it,
and all buckets have the same capacity.
Your task is to use the buckets to empty the wells.
Output the number of times you need to lower the buckets.
Example 1:
Input:
grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
bucket_capacity : 1
Output: 6
Example 2:
Input:
grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
bucket_capacity : 2
Output: 5
Example 3:
Input:
grid : [[0,0,0], [0,0,0]]
bucket_capacity : 5
Output: 0
Constraints:
* all wells have the same length
* 1 <= grid.length <= 10^2
* 1 <= grid[:,1].length <= 10^2
* grid[i][j] -> 0 | 1
* 1 <= capacity <= 10
|
HumanEval_csharp/116 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// In this Kata, you have to sort an array of non-negative integers according to
/// number of ones in their binary representation in ascending order.
/// For similar number of ones, sort based on decimal value.
///
/// It must be implemented like this:
/// >>> SortArray([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
/// >>> SortArray([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
/// >>> SortArray([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
///
/// </summary>
public static List<int> SortArray (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SortArray(new List<int> {1,5,2,3,4});
var expected1 = new List<int> {1,2,4,3,5};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SortArray(new List<int> {-2,-3,-4,-5,-6});
var expected2 = new List<int> {-4,-2,-6,-5,-3};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SortArray(new List<int> {1,0,2,3,4});
var expected3 = new List<int> {0,1,2,4,3};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SortArray(new List<int> {});
var expected4 = new List<int> {};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SortArray(new List<int> {2,5,77,4,5,3,5,7,2,3,4});
var expected5 = new List<int> {2,2,4,4,3,3,5,5,5,7,77};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SortArray(new List<int> {3,6,44,12,32,5});
var expected6 = new List<int> {32,3,5,6,12,44};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SortArray(new List<int> {2,4,8,16,32});
var expected7 = new List<int> {2,4,8,16,32};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = SortArray(new List<int> {2,4,8,16,32});
var expected8 = new List<int> {2,4,8,16,32};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| SortArray | null |
In this Kata, you have to sort an array of non-negative integers according to
number of ones in their binary representation in ascending order.
For similar number of ones, sort based on decimal value.
It must be implemented like this:
>>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
>>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
>>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
|
HumanEval_csharp/117 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a string s and a natural number n, you have been tasked to implement
/// a function that returns a list of all words from string s that contain exactly
/// n consonants, in order these words appear in the string s.
/// If the string s is empty then the function should return an empty list.
/// Note: you may assume the input string contains only letters and spaces.
/// Examples:
/// SelectWords("Mary had a little lamb", 4) ==> ["little"]
/// SelectWords("Mary had a little lamb", 3) ==> ["Mary", "lamb"]
/// SelectWords("simple white space", 2) ==> []
/// SelectWords("Hello world", 4) ==> ["world"]
/// SelectWords("Uncle sam", 3) ==> ["Uncle"]
///
/// </summary>
public static List<string> SelectWords (string s, int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SelectWords("Mary had a little lamb",4);
var expected1 = new List<string> {"little"};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SelectWords("Mary had a little lamb",3);
var expected2 = new List<string> {"Mary","lamb"};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SelectWords("simple white space",2);
var expected3 = new List<string> {};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SelectWords("Hello world",4);
var expected4 = new List<string> {"world"};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SelectWords("Uncle sam",3);
var expected5 = new List<string> {"Uncle"};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SelectWords("",4);
var expected6 = new List<string> {};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SelectWords("a b c d e f",1);
var expected7 = new List<string> {"b","c","d","f"};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| SelectWords | null | Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these words appear in the string s.
If the string s is empty then the function should return an empty list.
Note: you may assume the input string contains only letters and spaces.
Examples:
select_words("Mary had a little lamb", 4) ==> ["little"]
select_words("Mary had a little lamb", 3) ==> ["Mary", "lamb"]
select_words("simple white space", 2) ==> []
select_words("Hello world", 4) ==> ["world"]
select_words("Uncle sam", 3) ==> ["Uncle"]
|
HumanEval_csharp/118 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given a word. Your task is to find the closest vowel that stands between
/// two consonants from the right side of the word (case sensitive).
///
/// Vowels in the beginning and ending doesn't count. Return empty string if you didn't
/// find any vowel met the above condition.
///
/// You may assume that the given string contains English letter only.
///
/// Example:
/// GetClosestVowel("yogurt") ==> "u"
/// GetClosestVowel("FULL") ==> "U"
/// GetClosestVowel("quick") ==> ""
/// GetClosestVowel("ab") ==> ""
///
/// </summary>
public static string GetClosestVowel (string word)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = GetClosestVowel("yogurt");
var expected1 = "u";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = GetClosestVowel("full");
var expected2 = "u";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = GetClosestVowel("easy");
var expected3 = "";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = GetClosestVowel("eAsy");
var expected4 = "";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = GetClosestVowel("ali");
var expected5 = "";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = GetClosestVowel("bad");
var expected6 = "a";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = GetClosestVowel("most");
var expected7 = "o";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = GetClosestVowel("ab");
var expected8 = "";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = GetClosestVowel("ba");
var expected9 = "";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = GetClosestVowel("quick");
var expected10 = "";
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = GetClosestVowel("anime");
var expected11 = "i";
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = GetClosestVowel("Asia");
var expected12 = "";
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = GetClosestVowel("Above");
var expected13 = "o";
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
}
}
}
| GetClosestVowel | null | You are given a word. Your task is to find the closest vowel that stands between
two consonants from the right side of the word (case sensitive).
Vowels in the beginning and ending doesn't count. Return empty string if you didn't
find any vowel met the above condition.
You may assume that the given string contains English letter only.
Example:
get_closest_vowel("yogurt") ==> "u"
get_closest_vowel("FULL") ==> "U"
get_closest_vowel("quick") ==> ""
get_closest_vowel("ab") ==> ""
|
HumanEval_csharp/119 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You are given a list of two strings, both strings consist of open
/// parentheses '(' or close parentheses ')' only.
/// Your job is to check if it is possible to concatenate the two strings in
/// some order, that the resulting string will be good.
/// A string S is considered to be good if and only if all parentheses in S
/// are balanced. For example: the string '(())()' is good, while the string
/// '())' is not.
/// Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
///
/// Examples:
/// MatchParens(['()(', ')']) == 'Yes'
/// MatchParens([')', ')']) == 'No'
///
/// </summary>
public static string MatchParens (List<string> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = MatchParens(new List<string> {"()(",")"});
var expected1 = "Yes";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = MatchParens(new List<string> {")",")"});
var expected2 = "No";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = MatchParens(new List<string> {"(()(())","())())"});
var expected3 = "No";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = MatchParens(new List<string> {")())","(()()("});
var expected4 = "Yes";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = MatchParens(new List<string> {"(())))","(()())(("});
var expected5 = "Yes";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = MatchParens(new List<string> {"()","())"});
var expected6 = "No";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = MatchParens(new List<string> {"(()(","()))()"});
var expected7 = "Yes";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = MatchParens(new List<string> {"((((","((())"});
var expected8 = "No";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = MatchParens(new List<string> {")(()","(()("});
var expected9 = "No";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = MatchParens(new List<string> {")(",")("});
var expected10 = "No";
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = MatchParens(new List<string> {"(",")"});
var expected11 = "Yes";
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = MatchParens(new List<string> {")","("});
var expected12 = "Yes";
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
}
}
}
| MatchParens | null |
You are given a list of two strings, both strings consist of open
parentheses '(' or close parentheses ')' only.
Your job is to check if it is possible to concatenate the two strings in
some order, that the resulting string will be good.
A string S is considered to be good if and only if all parentheses in S
are balanced. For example: the string '(())()' is good, while the string
'())' is not.
Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
Examples:
match_parens(['()(', ')']) == 'Yes'
match_parens([')', ')']) == 'No'
|
HumanEval_csharp/120 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given an array arr of integers and a positive integer k, return a sorted list
/// of length k with the Maximum k numbers in arr.
///
/// Example 1:
///
/// Input: arr = [-3, -4, 5], k = 3
/// Output: [-4, -3, 5]
///
/// Example 2:
///
/// Input: arr = [4, -4, 4], k = 2
/// Output: [4, 4]
///
/// Example 3:
///
/// Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
/// Output: [2]
///
/// Note:
/// 1. The length of the array will be in the range of [1, 1000].
/// 2. The elements in the array will be in the range of [-1000, 1000].
/// 3. 0 <= k <= len(arr)
///
/// </summary>
public static List<int> Maximum (List<int> arr, int k)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Maximum(new List<int> {-3,-4,5},3);
var expected1 = new List<int> {-4,-3,5};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Maximum(new List<int> {4,-4,4},2);
var expected2 = new List<int> {4,4};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Maximum(new List<int> {-3,2,1,2,-1,-2,1},1);
var expected3 = new List<int> {2};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Maximum(new List<int> {123,-123,20,0,1,2,-3},3);
var expected4 = new List<int> {2,20,123};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Maximum(new List<int> {-123,20,0,1,2,-3},4);
var expected5 = new List<int> {0,1,2,20};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Maximum(new List<int> {5,15,0,3,-13,-8,0},7);
var expected6 = new List<int> {-13,-8,0,0,3,5,15};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Maximum(new List<int> {-1,0,2,5,3,-10},2);
var expected7 = new List<int> {3,5};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Maximum(new List<int> {1,0,5,-7},1);
var expected8 = new List<int> {5};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = Maximum(new List<int> {4,-4},2);
var expected9 = new List<int> {-4,4};
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = Maximum(new List<int> {-10,10},2);
var expected10 = new List<int> {-10,10};
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = Maximum(new List<int> {1,2,3,-23,243,-400,0},0);
var expected11 = new List<int> {};
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
}
}
}
| Maximum | null |
Given an array arr of integers and a positive integer k, return a sorted list
of length k with the maximum k numbers in arr.
Example 1:
Input: arr = [-3, -4, 5], k = 3
Output: [-4, -3, 5]
Example 2:
Input: arr = [4, -4, 4], k = 2
Output: [4, 4]
Example 3:
Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
Output: [2]
Note:
1. The length of the array will be in the range of [1, 1000].
2. The elements in the array will be in the range of [-1000, 1000].
3. 0 <= k <= len(arr)
|
HumanEval_csharp/121 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
///
///
/// Examples
/// Solution([5, 8, 7, 1]) ==> 12
/// Solution([3, 3, 3, 3, 3]) ==> 9
/// Solution([30, 13, 24, 321]) ==>0
///
/// </summary>
public static int Solution (List<int> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Solution(new List<int> {5,8,7,1});
var expected1 = 12;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Solution(new List<int> {3,3,3,3,3});
var expected2 = 9;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Solution(new List<int> {30,13,24,321});
var expected3 = 0;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Solution(new List<int> {5,9});
var expected4 = 5;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Solution(new List<int> {2,4,8});
var expected5 = 0;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Solution(new List<int> {30,13,23,32});
var expected6 = 23;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Solution(new List<int> {3,13,2,9});
var expected7 = 3;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| Solution | null | Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
solution([5, 8, 7, 1]) ==> 12
solution([3, 3, 3, 3, 3]) ==> 9
solution([30, 13, 24, 321]) ==>0
|
HumanEval_csharp/122 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a non-empty array of integers arr and an integer k, return
/// the sum of the elements with at most two digits from the first k elements of arr.
///
/// Example:
///
/// Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
/// Output: 24 # sum of 21 + 3
///
/// Constraints:
/// 1. 1 <= len(arr) <= 100
/// 2. 1 <= k <= len(arr)
///
/// </summary>
public static int AddElements (List<int> arr, int k)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = AddElements(new List<int> {1,-2,-3,41,57,76,87,88,99},3);
var expected1 = -4;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = AddElements(new List<int> {111,121,3,4000,5,6},2);
var expected2 = 0;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = AddElements(new List<int> {11,21,3,90,5,6,7,8,9},4);
var expected3 = 125;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = AddElements(new List<int> {111,21,3,4000,5,6,7,8,9},4);
var expected4 = 24;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = AddElements(new List<int> {1},1);
var expected5 = 1;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| AddElements | null |
Given a non-empty array of integers arr and an integer k, return
the sum of the elements with at most two digits from the first k elements of arr.
Example:
Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
Output: 24 # sum of 21 + 3
Constraints:
1. 1 <= len(arr) <= 100
2. 1 <= k <= len(arr)
|
HumanEval_csharp/123 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
///
/// The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
/// as follows: start with any positive integer n. Then each term is obtained from the
/// previous term as follows: if the previous term is even, the next term is one half of
/// the previous term. If the previous term is odd, the next term is 3 times the previous
/// term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
///
/// Note:
/// 1. Collatz(1) is [1].
/// 2. returned list sorted in increasing order.
///
/// For example:
/// GetOddCollatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
///
/// </summary>
public static List<int> GetOddCollatz (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = GetOddCollatz(14);
var expected1 = new List<int> {1,5,7,11,13,17};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = GetOddCollatz(5);
var expected2 = new List<int> {1,5};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = GetOddCollatz(12);
var expected3 = new List<int> {1,3,5};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = GetOddCollatz(1);
var expected4 = new List<int> {1};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| GetOddCollatz | null |
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as follows: start with any positive integer n. Then each term is obtained from the
previous term as follows: if the previous term is even, the next term is one half of
the previous term. If the previous term is odd, the next term is 3 times the previous
term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
Note:
1. Collatz(1) is [1].
2. returned list sorted in increasing order.
For example:
get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
|
HumanEval_csharp/124 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You have to write a function which validates a given date string and
/// returns True if the date is valid otherwise False.
/// The date is valid if all of the following rules are satisfied:
/// 1. The date string is not empty.
/// 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
/// 3. The months should not be less than 1 or higher than 12.
/// 4. The date should be in the format: mm-dd-yyyy
///
/// for example:
/// ValidDate('03-11-2000') => True
///
/// ValidDate('15-01-2012') => False
///
/// ValidDate('04-0-2040') => False
///
/// ValidDate('06-04-2020') => True
///
/// ValidDate('06/04/2020') => False
///
/// </summary>
public static bool ValidDate (string date)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = ValidDate("03-11-2000");
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = ValidDate("15-01-2012");
var expected2 = false;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = ValidDate("04-0-2040");
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = ValidDate("06-04-2020");
var expected4 = true;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = ValidDate("01-01-2007");
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = ValidDate("03-32-2011");
var expected6 = false;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = ValidDate("");
var expected7 = false;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = ValidDate("04-31-3000");
var expected8 = false;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = ValidDate("06-06-2005");
var expected9 = true;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = ValidDate("21-31-2000");
var expected10 = false;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = ValidDate("04-12-2003");
var expected11 = true;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = ValidDate("04122003");
var expected12 = false;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = ValidDate("20030412");
var expected13 = false;
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
var actual14 = ValidDate("2003-04");
var expected14 = false;
var result14 = compareLogic.Compare(actual14, expected14);
if (!result14.AreEqual) {throw new Exception("Exception --- test case 13 failed to pass");}
var actual15 = ValidDate("2003-04-12");
var expected15 = false;
var result15 = compareLogic.Compare(actual15, expected15);
if (!result15.AreEqual) {throw new Exception("Exception --- test case 14 failed to pass");}
var actual16 = ValidDate("04-2003");
var expected16 = false;
var result16 = compareLogic.Compare(actual16, expected16);
if (!result16.AreEqual) {throw new Exception("Exception --- test case 15 failed to pass");}
}
}
}
| ValidDate | null | You have to write a function which validates a given date string and
returns True if the date is valid otherwise False.
The date is valid if all of the following rules are satisfied:
1. The date string is not empty.
2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
3. The months should not be less than 1 or higher than 12.
4. The date should be in the format: mm-dd-yyyy
for example:
valid_date('03-11-2000') => True
valid_date('15-01-2012') => False
valid_date('04-0-2040') => False
valid_date('06-04-2020') => True
valid_date('06/04/2020') => False
|
HumanEval_csharp/125 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
/// should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
/// alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
/// Examples
/// SplitWords("Hello world!") ➞ ["Hello", "world!"]
/// SplitWords("Hello,world!") ➞ ["Hello", "world!"]
/// SplitWords("abcdef") == 3
///
/// </summary>
public static object SplitWords (string txt)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SplitWords("Hello world!");
var expected1 = new List<object> {"Hello","world!"};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SplitWords("Hello,world!");
var expected2 = new List<object> {"Hello","world!"};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SplitWords("Hello world,!");
var expected3 = new List<object> {"Hello","world,!"};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SplitWords("Hello,Hello,world !");
var expected4 = new List<object> {"Hello,Hello,world","!"};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SplitWords("abcdef");
var expected5 = 3;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SplitWords("aaabb");
var expected6 = 2;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SplitWords("aaaBb");
var expected7 = 1;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = SplitWords("");
var expected8 = 0;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| SplitWords | null |
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
Examples
split_words("Hello world!") ➞ ["Hello", "world!"]
split_words("Hello,world!") ➞ ["Hello", "world!"]
split_words("abcdef") == 3
|
HumanEval_csharp/126 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a list of numbers, return whether or not they are sorted
/// in ascending order. If list has more than 1 duplicate of the same
/// number, return False. Assume no negative numbers and only integers.
///
/// Examples
/// IsSorted([5]) ➞ True
/// IsSorted([1, 2, 3, 4, 5]) ➞ True
/// IsSorted([1, 3, 2, 4, 5]) ➞ False
/// IsSorted([1, 2, 3, 4, 5, 6]) ➞ True
/// IsSorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
/// IsSorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
/// IsSorted([1, 2, 2, 3, 3, 4]) ➞ True
/// IsSorted([1, 2, 2, 2, 3, 4]) ➞ False
///
/// </summary>
public static bool IsSorted (List<int> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = IsSorted(new List<int> {5});
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = IsSorted(new List<int> {1,2,3,4,5});
var expected2 = true;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = IsSorted(new List<int> {1,3,2,4,5});
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = IsSorted(new List<int> {1,2,3,4,5,6});
var expected4 = true;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = IsSorted(new List<int> {1,2,3,4,5,6,7});
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = IsSorted(new List<int> {1,3,2,4,5,6,7});
var expected6 = false;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = IsSorted(new List<int> {});
var expected7 = true;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = IsSorted(new List<int> {1});
var expected8 = true;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = IsSorted(new List<int> {3,2,1});
var expected9 = false;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = IsSorted(new List<int> {1,2,2,2,3,4});
var expected10 = false;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = IsSorted(new List<int> {1,2,3,3,3,4});
var expected11 = false;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = IsSorted(new List<int> {1,2,2,3,3,4});
var expected12 = true;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = IsSorted(new List<int> {1,2,3,4});
var expected13 = true;
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
}
}
}
| IsSorted | null |
Given a list of numbers, return whether or not they are sorted
in ascending order. If list has more than 1 duplicate of the same
number, return False. Assume no negative numbers and only integers.
Examples
is_sorted([5]) ➞ True
is_sorted([1, 2, 3, 4, 5]) ➞ True
is_sorted([1, 3, 2, 4, 5]) ➞ False
is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
|
HumanEval_csharp/127 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given two intervals,
/// where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
/// The given intervals are closed which means that the interval (start, end)
/// includes both start and end.
/// For each given interval, it is assumed that its start is less or equal its end.
/// Your task is to determine whether the length of Intersection of these two
/// intervals is a prime number.
/// Example, the Intersection of the intervals (1, 3), (2, 4) is (2, 3)
/// which its length is 1, which not a prime number.
/// If the length of the Intersection is a prime number, return "YES",
/// otherwise, return "NO".
/// If the two intervals don't intersect, return "NO".
///
///
/// [input/output] samples:
/// Intersection((1, 2), (2, 3)) ==> "NO"
/// Intersection((-1, 1), (0, 4)) ==> "NO"
/// Intersection((-3, -1), (-5, 5)) ==> "YES"
///
/// </summary>
public static string Intersection (List<int> interval1, List<int> interval2)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Intersection(new List<int> {1,2},new List<int> {2,3});
var expected1 = "NO";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Intersection(new List<int> {-1,1},new List<int> {0,4});
var expected2 = "NO";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Intersection(new List<int> {-3,-1},new List<int> {-5,5});
var expected3 = "YES";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Intersection(new List<int> {-2,2},new List<int> {-4,0});
var expected4 = "YES";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Intersection(new List<int> {-11,2},new List<int> {-1,-1});
var expected5 = "NO";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Intersection(new List<int> {1,2},new List<int> {3,5});
var expected6 = "NO";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Intersection(new List<int> {1,2},new List<int> {1,2});
var expected7 = "NO";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Intersection(new List<int> {-2,-2},new List<int> {-3,-2});
var expected8 = "NO";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| Intersection | null | You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (start, end)
includes both start and end.
For each given interval, it is assumed that its start is less or equal its end.
Your task is to determine whether the length of intersection of these two
intervals is a prime number.
Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
which its length is 1, which not a prime number.
If the length of the intersection is a prime number, return "YES",
otherwise, return "NO".
If the two intervals don't intersect, return "NO".
[input/output] samples:
intersection((1, 2), (2, 3)) ==> "NO"
intersection((-1, 1), (0, 4)) ==> "NO"
intersection((-3, -1), (-5, 5)) ==> "YES"
|
HumanEval_csharp/128 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You are given an array arr of integers and you need to return
/// sum of magnitudes of integers multiplied by product of all signs
/// of each number in the array, represented by 1, -1 or 0.
/// Note: return None for empty arr.
///
/// Example:
/// >>> ProdSigns([1, 2, 2, -4]) == -9
/// >>> ProdSigns([0, 1]) == 0
/// >>> ProdSigns([]) == None
///
/// </summary>
public static object ProdSigns (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = ProdSigns(new List<int> {1,2,2,-4});
var expected1 = -9;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = ProdSigns(new List<int> {0,1});
var expected2 = 0;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = ProdSigns(new List<int> {1,1,1,2,3,-1,1});
var expected3 = -10;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = ProdSigns(new List<int> {});
var expected4 = null;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = ProdSigns(new List<int> {2,4,1,2,-1,-1,9});
var expected5 = 20;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = ProdSigns(new List<int> {-1,1,-1,1});
var expected6 = 4;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = ProdSigns(new List<int> {-1,1,1,1});
var expected7 = -4;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = ProdSigns(new List<int> {-1,1,1,0});
var expected8 = 0;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| ProdSigns | null |
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None for empty arr.
Example:
>>> prod_signs([1, 2, 2, -4]) == -9
>>> prod_signs([0, 1]) == 0
>>> prod_signs([]) == None
|
HumanEval_csharp/129 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a grid with N rows and N columns (N >= 2) and a positive integer k,
/// each cell of the grid contains a value. Every integer in the range [1, N * N]
/// inclusive appears exactly once on the cells of the grid.
///
/// You have to find the minimum path of length k in the grid. You can start
/// from any cell, and in each step you can move to any of the neighbor cells,
/// in other words, you can go to cells which share an edge with you current
/// cell.
/// Please note that a path of length k means visiting exactly k cells (not
/// necessarily distinct).
/// You CANNOT go off the grid.
/// A path A (of length k) is considered less than a path B (of length k) if
/// after making the ordered lists of the values on the cells that A and B go
/// through (let's call them lst_A and lst_B), lst_A is lexicographically less
/// than lst_B, in other words, there exist an integer index i (1 <= i <= k)
/// such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
/// lst_A[j] = lst_B[j].
/// It is guaranteed that the answer is unique.
/// Return an ordered list of the values on the cells that the minimum path go through.
///
/// Examples:
///
/// Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
/// Output: [1, 2, 1]
///
/// Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
/// Output: [1]
///
/// </summary>
public static List<int> MinPath (List<List<int>> grid, int k)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = MinPath(new List<List<int>> {new List<int> {1,2,3},new List<int> {4,5,6},new List<int> {7,8,9}},3);
var expected1 = new List<int> {1,2,1};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = MinPath(new List<List<int>> {new List<int> {5,9,3},new List<int> {4,1,6},new List<int> {7,8,2}},1);
var expected2 = new List<int> {1};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = MinPath(new List<List<int>> {new List<int> {1,2,3,4},new List<int> {5,6,7,8},new List<int> {9,10,11,12},new List<int> {13,14,15,16}},4);
var expected3 = new List<int> {1,2,1,2};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = MinPath(new List<List<int>> {new List<int> {6,4,13,10},new List<int> {5,7,12,1},new List<int> {3,16,11,15},new List<int> {8,14,9,2}},7);
var expected4 = new List<int> {1,10,1,10,1,10,1};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = MinPath(new List<List<int>> {new List<int> {8,14,9,2},new List<int> {6,4,13,15},new List<int> {5,7,1,12},new List<int> {3,10,11,16}},5);
var expected5 = new List<int> {1,7,1,7,1};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = MinPath(new List<List<int>> {new List<int> {11,8,7,2},new List<int> {5,16,14,4},new List<int> {9,3,15,6},new List<int> {12,13,10,1}},9);
var expected6 = new List<int> {1,6,1,6,1,6,1,6,1};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = MinPath(new List<List<int>> {new List<int> {12,13,10,1},new List<int> {9,3,15,6},new List<int> {5,16,14,4},new List<int> {11,8,7,2}},12);
var expected7 = new List<int> {1,6,1,6,1,6,1,6,1,6,1,6};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = MinPath(new List<List<int>> {new List<int> {2,7,4},new List<int> {3,1,5},new List<int> {6,8,9}},8);
var expected8 = new List<int> {1,3,1,3,1,3,1,3};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = MinPath(new List<List<int>> {new List<int> {6,1,5},new List<int> {3,8,9},new List<int> {2,7,4}},8);
var expected9 = new List<int> {1,5,1,5,1,5,1,5};
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = MinPath(new List<List<int>> {new List<int> {1,2},new List<int> {3,4}},10);
var expected10 = new List<int> {1,2,1,2,1,2,1,2,1,2};
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = MinPath(new List<List<int>> {new List<int> {1,3},new List<int> {3,2}},10);
var expected11 = new List<int> {1,3,1,3,1,3,1,3,1,3};
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
}
}
}
| MinPath | null |
Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on the cells of the grid.
You have to find the minimum path of length k in the grid. You can start
from any cell, and in each step you can move to any of the neighbor cells,
in other words, you can go to cells which share an edge with you current
cell.
Please note that a path of length k means visiting exactly k cells (not
necessarily distinct).
You CANNOT go off the grid.
A path A (of length k) is considered less than a path B (of length k) if
after making the ordered lists of the values on the cells that A and B go
through (let's call them lst_A and lst_B), lst_A is lexicographically less
than lst_B, in other words, there exist an integer index i (1 <= i <= k)
such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
lst_A[j] = lst_B[j].
It is guaranteed that the answer is unique.
Return an ordered list of the values on the cells that the minimum path go through.
Examples:
Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
Output: [1, 2, 1]
Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
Output: [1]
|
HumanEval_csharp/130 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
/// the last couple centuries. However, what people don't know is Tribonacci sequence.
/// Tribonacci sequence is defined by the recurrence:
/// Tri(1) = 3
/// Tri(n) = 1 + n / 2, if n is even.
/// Tri(n) = Tri(n - 1) + Tri(n - 2) + Tri(n + 1), if n is odd.
/// For example:
/// Tri(2) = 1 + (2 / 2) = 2
/// Tri(4) = 3
/// Tri(3) = Tri(2) + Tri(1) + Tri(4)
/// = 2 + 3 + 3 = 8
/// You are given a non-negative integer number n, you have to a return a list of the
/// first n + 1 numbers of the Tribonacci sequence.
/// Examples:
/// Tri(3) = [1, 3, 2, 8]
///
/// </summary>
public static List<object> Tri (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Tri(3);
var expected1 = new List<object> {1,3,2.0,8.0};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Tri(4);
var expected2 = new List<object> {1,3,2.0,8.0,3.0};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Tri(5);
var expected3 = new List<object> {1,3,2.0,8.0,3.0,15.0};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Tri(6);
var expected4 = new List<object> {1,3,2.0,8.0,3.0,15.0,4.0};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Tri(7);
var expected5 = new List<object> {1,3,2.0,8.0,3.0,15.0,4.0,24.0};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Tri(8);
var expected6 = new List<object> {1,3,2.0,8.0,3.0,15.0,4.0,24.0,5.0};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Tri(9);
var expected7 = new List<object> {1,3,2.0,8.0,3.0,15.0,4.0,24.0,5.0,35.0};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Tri(20);
var expected8 = new List<object> {1,3,2.0,8.0,3.0,15.0,4.0,24.0,5.0,35.0,6.0,48.0,7.0,63.0,8.0,80.0,9.0,99.0,10.0,120.0,11.0};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = Tri(0);
var expected9 = new List<object> {1};
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = Tri(1);
var expected10 = new List<object> {1,3};
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
}
}
}
| Tri | null | Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
the last couple centuries. However, what people don't know is Tribonacci sequence.
Tribonacci sequence is defined by the recurrence:
tri(1) = 3
tri(n) = 1 + n / 2, if n is even.
tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
For example:
tri(2) = 1 + (2 / 2) = 2
tri(4) = 3
tri(3) = tri(2) + tri(1) + tri(4)
= 2 + 3 + 3 = 8
You are given a non-negative integer number n, you have to a return a list of the
first n + 1 numbers of the Tribonacci sequence.
Examples:
tri(3) = [1, 3, 2, 8]
|
HumanEval_csharp/131 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given a positive integer n, return the product of the odd Digits.
/// Return 0 if all Digits are even.
/// For example:
/// Digits(1) == 1
/// Digits(4) == 0
/// Digits(235) == 15
///
/// </summary>
public static int Digits (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Digits(5);
var expected1 = 5;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Digits(54);
var expected2 = 5;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Digits(120);
var expected3 = 1;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Digits(5014);
var expected4 = 5;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Digits(98765);
var expected5 = 315;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Digits(5576543);
var expected6 = 2625;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Digits(2468);
var expected7 = 0;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| Digits | null | Given a positive integer n, return the product of the odd digits.
Return 0 if all digits are even.
For example:
digits(1) == 1
digits(4) == 0
digits(235) == 15
|
HumanEval_csharp/132 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Create a function that takes a string as input which contains only square brackets.
/// The function should return True if and only if there is a valid subsequence of brackets
/// where at least one bracket in the subsequence is nested.
///
/// IsNested('[[]]') ➞ True
/// IsNested('[]]]]]]][[[[[]') ➞ False
/// IsNested('[][]') ➞ False
/// IsNested('[]') ➞ False
/// IsNested('[[][]]') ➞ True
/// IsNested('[[]][[') ➞ True
///
/// </summary>
public static bool IsNested (string string0)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = IsNested("[[]]");
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = IsNested("[]]]]]]][[[[[]");
var expected2 = false;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = IsNested("[][]");
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = IsNested("[]");
var expected4 = false;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = IsNested("[[[[]]]]");
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = IsNested("[]]]]]]]]]]");
var expected6 = false;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = IsNested("[][][[]]");
var expected7 = true;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = IsNested("[[]");
var expected8 = false;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = IsNested("[]]");
var expected9 = false;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = IsNested("[[]][[");
var expected10 = true;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = IsNested("[[][]]");
var expected11 = true;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = IsNested("");
var expected12 = false;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = IsNested("[[[[[[[[");
var expected13 = false;
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
var actual14 = IsNested("]]]]]]]]");
var expected14 = false;
var result14 = compareLogic.Compare(actual14, expected14);
if (!result14.AreEqual) {throw new Exception("Exception --- test case 13 failed to pass");}
}
}
}
| IsNested | null |
Create a function that takes a string as input which contains only square brackets.
The function should return True if and only if there is a valid subsequence of brackets
where at least one bracket in the subsequence is nested.
is_nested('[[]]') ➞ True
is_nested('[]]]]]]][[[[[]') ➞ False
is_nested('[][]') ➞ False
is_nested('[]') ➞ False
is_nested('[[][]]') ➞ True
is_nested('[[]][[') ➞ True
|
HumanEval_csharp/133 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given a list of numbers.
/// You need to return the sum of squared numbers in the given list,
/// round each element in the list to the upper int(Ceiling) first.
/// Examples:
/// For lst = [1,2,3] the output should be 14
/// For lst = [1,4,9] the output should be 98
/// For lst = [1,3,5,7] the output should be 84
/// For lst = [1.4,4.2,0] the output should be 29
/// For lst = [-2.4,1,1] the output should be 6
///
///
///
/// </summary>
public static int SumSquares (List<object> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SumSquares(new List<object> {1,2,3});
var expected1 = 14;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SumSquares(new List<object> {1.0,2,3});
var expected2 = 14;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SumSquares(new List<object> {1,3,5,7});
var expected3 = 84;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SumSquares(new List<object> {1.4,4.2,0});
var expected4 = 29;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SumSquares(new List<object> {-2.4,1,1});
var expected5 = 6;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SumSquares(new List<object> {100,1,15,2});
var expected6 = 10230;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SumSquares(new List<object> {10000,10000});
var expected7 = 200000000;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = SumSquares(new List<object> {-1.4,4.6,6.3});
var expected8 = 75;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = SumSquares(new List<object> {-1.4,17.9,18.9,19.9});
var expected9 = 1086;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = SumSquares(new List<object> {0});
var expected10 = 0;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = SumSquares(new List<object> {-1});
var expected11 = 1;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = SumSquares(new List<object> {-1,1,0});
var expected12 = 2;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
}
}
}
| SumSquares | null | You are given a list of numbers.
You need to return the sum of squared numbers in the given list,
round each element in the list to the upper int(Ceiling) first.
Examples:
For lst = [1,2,3] the output should be 14
For lst = [1,4,9] the output should be 98
For lst = [1,3,5,7] the output should be 84
For lst = [1.4,4.2,0] the output should be 29
For lst = [-2.4,1,1] the output should be 6
|
HumanEval_csharp/134 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Create a function that returns True if the last character
/// of a given string is an alphabetical character and is not
/// a part of a word, and False otherwise.
/// Note: "word" is a group of characters separated by space.
///
/// Examples:
/// CheckIfLastCharIsALetter("apple pie") ➞ False
/// CheckIfLastCharIsALetter("apple pi e") ➞ True
/// CheckIfLastCharIsALetter("apple pi e ") ➞ False
/// CheckIfLastCharIsALetter("") ➞ False
///
/// </summary>
public static bool CheckIfLastCharIsALetter (string txt)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = CheckIfLastCharIsALetter("apple");
var expected1 = false;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = CheckIfLastCharIsALetter("apple pi e");
var expected2 = true;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = CheckIfLastCharIsALetter("eeeee");
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = CheckIfLastCharIsALetter("A");
var expected4 = true;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = CheckIfLastCharIsALetter("Pumpkin pie ");
var expected5 = false;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = CheckIfLastCharIsALetter("Pumpkin pie 1");
var expected6 = false;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = CheckIfLastCharIsALetter("");
var expected7 = false;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = CheckIfLastCharIsALetter("eeeee e ");
var expected8 = false;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = CheckIfLastCharIsALetter("apple pie");
var expected9 = false;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = CheckIfLastCharIsALetter("apple pi e ");
var expected10 = false;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
}
}
}
| CheckIfLastCharIsALetter | null |
Create a function that returns True if the last character
of a given string is an alphabetical character and is not
a part of a word, and False otherwise.
Note: "word" is a group of characters separated by space.
Examples:
check_if_last_char_is_a_letter("apple pie") ➞ False
check_if_last_char_is_a_letter("apple pi e") ➞ True
check_if_last_char_is_a_letter("apple pi e ") ➞ False
check_if_last_char_is_a_letter("") ➞ False
|
HumanEval_csharp/135 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Create a function which returns the largest index of an element which
/// is not greater than or equal to the element immediately preceding it. If
/// no such element exists then return -1. The given array will not contain
/// duplicate values.
///
/// Examples:
/// CanArrange([1,2,4,3,5]) = 3
/// CanArrange([1,2,3]) = -1
///
/// </summary>
public static int CanArrange (List<int> arr)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = CanArrange(new List<int> {1,2,4,3,5});
var expected1 = 3;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = CanArrange(new List<int> {1,2,4,5});
var expected2 = -1;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = CanArrange(new List<int> {1,4,2,5,6,7,8,9,10});
var expected3 = 2;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = CanArrange(new List<int> {4,8,5,7,3});
var expected4 = 4;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = CanArrange(new List<int> {});
var expected5 = -1;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| CanArrange | null | Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The given array will not contain
duplicate values.
Examples:
can_arrange([1,2,4,3,5]) = 3
can_arrange([1,2,3]) = -1
|
HumanEval_csharp/136 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Create a function that returns a tuple (a, b), where 'a' is
/// the largest of negative integers, and 'b' is the smallest
/// of positive integers in a list.
/// If there is no negative or positive integers, return them as None.
///
/// Examples:
/// LargestSmallestIntegers([2, 4, 1, 3, 5, 7]) == (None, 1)
/// LargestSmallestIntegers([]) == (None, None)
/// LargestSmallestIntegers([0]) == (None, None)
///
/// </summary>
public static List<object> LargestSmallestIntegers (List<int> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = LargestSmallestIntegers(new List<int> {2,4,1,3,5,7});
var expected1 = new List<object> {null,1};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = LargestSmallestIntegers(new List<int> {2,4,1,3,5,7,0});
var expected2 = new List<object> {null,1};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = LargestSmallestIntegers(new List<int> {1,3,2,4,5,6,-2});
var expected3 = new List<object> {-2,1};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = LargestSmallestIntegers(new List<int> {4,5,3,6,2,7,-7});
var expected4 = new List<object> {-7,2};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = LargestSmallestIntegers(new List<int> {7,3,8,4,9,2,5,-9});
var expected5 = new List<object> {-9,2};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = LargestSmallestIntegers(new List<int> {});
var expected6 = new List<object> {null,null};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = LargestSmallestIntegers(new List<int> {0});
var expected7 = new List<object> {null,null};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = LargestSmallestIntegers(new List<int> {-1,-3,-5,-6});
var expected8 = new List<object> {-1,null};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = LargestSmallestIntegers(new List<int> {-1,-3,-5,-6,0});
var expected9 = new List<object> {-1,null};
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = LargestSmallestIntegers(new List<int> {-6,-4,-4,-3,1});
var expected10 = new List<object> {-3,1};
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = LargestSmallestIntegers(new List<int> {-6,-4,-4,-3,-100,1});
var expected11 = new List<object> {-3,1};
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
}
}
}
| LargestSmallestIntegers | null |
Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no negative or positive integers, return them as None.
Examples:
largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
largest_smallest_integers([]) == (None, None)
largest_smallest_integers([0]) == (None, None)
|
HumanEval_csharp/137 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Create a function that takes integers, floats, or strings representing
/// real numbers, and returns the larger variable in its given variable type.
/// Return None if the values are equal.
/// Note: If a real number is represented as a string, the floating point might be . or ,
///
/// CompareOne(1, 2.5) ➞ 2.5
/// CompareOne(1, "2,3") ➞ "2,3"
/// CompareOne("5,1", "6") ➞ "6"
/// CompareOne("1", 1) ➞ None
///
/// </summary>
public static object CompareOne (object a, object b)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = CompareOne(1,2);
var expected1 = 2;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = CompareOne(1,2.5);
var expected2 = 2.5;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = CompareOne(2,3);
var expected3 = 3;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = CompareOne(5,6);
var expected4 = 6;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = CompareOne(1,"2,3");
var expected5 = "2,3";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = CompareOne("5,1","6");
var expected6 = "6";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = CompareOne("1","2");
var expected7 = "2";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = CompareOne("1",1);
var expected8 = null;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| CompareOne | null |
Create a function that takes integers, floats, or strings representing
real numbers, and returns the larger variable in its given variable type.
Return None if the values are equal.
Note: If a real number is represented as a string, the floating point might be . or ,
compare_one(1, 2.5) ➞ 2.5
compare_one(1, "2,3") ➞ "2,3"
compare_one("5,1", "6") ➞ "6"
compare_one("1", 1) ➞ None
|
HumanEval_csharp/138 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
/// Example
/// IsEqualToSumEven(4) == False
/// IsEqualToSumEven(6) == False
/// IsEqualToSumEven(8) == True
///
/// </summary>
public static bool IsEqualToSumEven (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = IsEqualToSumEven(4);
var expected1 = false;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = IsEqualToSumEven(6);
var expected2 = false;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = IsEqualToSumEven(8);
var expected3 = true;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = IsEqualToSumEven(10);
var expected4 = true;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = IsEqualToSumEven(11);
var expected5 = false;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = IsEqualToSumEven(12);
var expected6 = true;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = IsEqualToSumEven(13);
var expected7 = false;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = IsEqualToSumEven(16);
var expected8 = true;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| IsEqualToSumEven | null | Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
is_equal_to_sum_even(4) == False
is_equal_to_sum_even(6) == False
is_equal_to_sum_even(8) == True
|
HumanEval_csharp/139 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// The Brazilian factorial is defined as:
/// brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
/// where n > 0
///
/// For example:
/// >>> SpecialFactorial(4)
/// 288
///
/// The function will receive an integer as input and should return the special
/// factorial of this integer.
///
/// </summary>
public static int SpecialFactorial (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SpecialFactorial(4);
var expected1 = 288;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SpecialFactorial(5);
var expected2 = 34560;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SpecialFactorial(7);
var expected3 = 125411328000;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SpecialFactorial(1);
var expected4 = 1;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| SpecialFactorial | null | The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
>>> special_factorial(4)
288
The function will receive an integer as input and should return the special
factorial of this integer.
|
HumanEval_csharp/140 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a string text, replace all spaces in it with underscores,
/// and if a string has more than 2 consecutive spaces,
/// then replace all consecutive spaces with -
///
/// FixSpaces("Example") == "Example"
/// FixSpaces("Example 1") == "Example_1"
/// FixSpaces(" Example 2") == "_Example_2"
/// FixSpaces(" Example 3") == "_Example-3"
///
/// </summary>
public static string FixSpaces (string text)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = FixSpaces("Example");
var expected1 = "Example";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = FixSpaces("Mudasir Hanif ");
var expected2 = "Mudasir_Hanif_";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = FixSpaces("Yellow Yellow Dirty Fellow");
var expected3 = "Yellow_Yellow__Dirty__Fellow";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = FixSpaces("Exa mple");
var expected4 = "Exa-mple";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = FixSpaces(" Exa 1 2 2 mple");
var expected5 = "-Exa_1_2_2_mple";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
}
}
}
| FixSpaces | null |
Given a string text, replace all spaces in it with underscores,
and if a string has more than 2 consecutive spaces,
then replace all consecutive spaces with -
fix_spaces("Example") == "Example"
fix_spaces("Example 1") == "Example_1"
fix_spaces(" Example 2") == "_Example_2"
fix_spaces(" Example 3") == "_Example-3"
|
HumanEval_csharp/141 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Create a function which takes a string representing a file's name, and returns
/// 'Yes' if the the file's name is valid, and returns 'No' otherwise.
/// A file's name is considered to be valid if and only if all the following conditions
/// are met:
/// - There should not be more than three digits ('0'-'9') in the file's name.
/// - The file's name contains exactly one dot '.'
/// - The substring before the dot should not be empty, and it starts with a letter from
/// the latin alphapet ('a'-'z' and 'A'-'Z').
/// - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
/// Examples:
/// FileNameCheck("example.txt") # => 'Yes'
/// FileNameCheck("1example.dll") # => 'No' (the name should start with a latin alphapet letter)
///
/// </summary>
public static string FileNameCheck (string file_name)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = FileNameCheck("example.txt");
var expected1 = "Yes";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = FileNameCheck("1example.dll");
var expected2 = "No";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = FileNameCheck("s1sdf3.asd");
var expected3 = "No";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = FileNameCheck("K.dll");
var expected4 = "Yes";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = FileNameCheck("MY16FILE3.exe");
var expected5 = "Yes";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = FileNameCheck("His12FILE94.exe");
var expected6 = "No";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = FileNameCheck("_Y.txt");
var expected7 = "No";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = FileNameCheck("?aREYA.exe");
var expected8 = "No";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = FileNameCheck("/this_is_valid.dll");
var expected9 = "No";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = FileNameCheck("this_is_valid.wow");
var expected10 = "No";
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = FileNameCheck("this_is_valid.txt");
var expected11 = "Yes";
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = FileNameCheck("this_is_valid.txtexe");
var expected12 = "No";
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = FileNameCheck("#this2_i4s_5valid.ten");
var expected13 = "No";
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
var actual14 = FileNameCheck("@this1_is6_valid.exe");
var expected14 = "No";
var result14 = compareLogic.Compare(actual14, expected14);
if (!result14.AreEqual) {throw new Exception("Exception --- test case 13 failed to pass");}
var actual15 = FileNameCheck("this_is_12valid.6exe4.txt");
var expected15 = "No";
var result15 = compareLogic.Compare(actual15, expected15);
if (!result15.AreEqual) {throw new Exception("Exception --- test case 14 failed to pass");}
var actual16 = FileNameCheck("all.exe.txt");
var expected16 = "No";
var result16 = compareLogic.Compare(actual16, expected16);
if (!result16.AreEqual) {throw new Exception("Exception --- test case 15 failed to pass");}
var actual17 = FileNameCheck("I563_No.exe");
var expected17 = "Yes";
var result17 = compareLogic.Compare(actual17, expected17);
if (!result17.AreEqual) {throw new Exception("Exception --- test case 16 failed to pass");}
var actual18 = FileNameCheck("Is3youfault.txt");
var expected18 = "Yes";
var result18 = compareLogic.Compare(actual18, expected18);
if (!result18.AreEqual) {throw new Exception("Exception --- test case 17 failed to pass");}
var actual19 = FileNameCheck("no_one#knows.dll");
var expected19 = "Yes";
var result19 = compareLogic.Compare(actual19, expected19);
if (!result19.AreEqual) {throw new Exception("Exception --- test case 18 failed to pass");}
var actual20 = FileNameCheck("1I563_Yes3.exe");
var expected20 = "No";
var result20 = compareLogic.Compare(actual20, expected20);
if (!result20.AreEqual) {throw new Exception("Exception --- test case 19 failed to pass");}
var actual21 = FileNameCheck("I563_Yes3.txtt");
var expected21 = "No";
var result21 = compareLogic.Compare(actual21, expected21);
if (!result21.AreEqual) {throw new Exception("Exception --- test case 20 failed to pass");}
var actual22 = FileNameCheck("final..txt");
var expected22 = "No";
var result22 = compareLogic.Compare(actual22, expected22);
if (!result22.AreEqual) {throw new Exception("Exception --- test case 21 failed to pass");}
var actual23 = FileNameCheck("final132");
var expected23 = "No";
var result23 = compareLogic.Compare(actual23, expected23);
if (!result23.AreEqual) {throw new Exception("Exception --- test case 22 failed to pass");}
var actual24 = FileNameCheck("_f4indsartal132.");
var expected24 = "No";
var result24 = compareLogic.Compare(actual24, expected24);
if (!result24.AreEqual) {throw new Exception("Exception --- test case 23 failed to pass");}
var actual25 = FileNameCheck(".txt");
var expected25 = "No";
var result25 = compareLogic.Compare(actual25, expected25);
if (!result25.AreEqual) {throw new Exception("Exception --- test case 24 failed to pass");}
var actual26 = FileNameCheck("s.");
var expected26 = "No";
var result26 = compareLogic.Compare(actual26, expected26);
if (!result26.AreEqual) {throw new Exception("Exception --- test case 25 failed to pass");}
}
}
}
| FileNameCheck | null | Create a function which takes a string representing a file's name, and returns
'Yes' if the the file's name is valid, and returns 'No' otherwise.
A file's name is considered to be valid if and only if all the following conditions
are met:
- There should not be more than three digits ('0'-'9') in the file's name.
- The file's name contains exactly one dot '.'
- The substring before the dot should not be empty, and it starts with a letter from
the latin alphapet ('a'-'z' and 'A'-'Z').
- The substring after the dot should be one of these: ['txt', 'exe', 'dll']
Examples:
file_name_check("example.txt") # => 'Yes'
file_name_check("1example.dll") # => 'No' (the name should start with a latin alphapet letter)
|
HumanEval_csharp/142 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// </summary>
public static int SumSquares (List<int> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SumSquares(new List<int> {1,2,3});
var expected1 = 6;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SumSquares(new List<int> {1,4,9});
var expected2 = 14;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SumSquares(new List<int> {});
var expected3 = 0;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SumSquares(new List<int> {1,1,1,1,1,1,1,1,1});
var expected4 = 9;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SumSquares(new List<int> {-1,-1,-1,-1,-1,-1,-1,-1,-1});
var expected5 = -3;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SumSquares(new List<int> {0});
var expected6 = 0;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SumSquares(new List<int> {-1,-5,2,-1,-5});
var expected7 = -126;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = SumSquares(new List<int> {-56,-99,1,0,-2});
var expected8 = 3030;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = SumSquares(new List<int> {-1,0,0,0,0,0,0,0,-1});
var expected9 = 0;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = SumSquares(new List<int> {-16,-9,-2,36,36,26,-20,25,-40,20,-4,12,-26,35,37});
var expected10 = -14196;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = SumSquares(new List<int> {-1,-3,17,-1,-15,13,-1,14,-14,-12,-5,14,-14,6,13,11,16,16,4,10});
var expected11 = -1448;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
}
}
}
| SumSquares | null | |
HumanEval_csharp/143 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You are given a string representing a sentence,
/// the sentence contains some words separated by a space,
/// and you have to return a string that contains the words from the original sentence,
/// whose lengths are prime numbers,
/// the order of the words in the new string should be the same as the original one.
///
/// Example 1:
/// Input: sentence = "This is a test"
/// Output: "is"
///
/// Example 2:
/// Input: sentence = "lets go for swimming"
/// Output: "go for"
///
/// Constraints:
/// * 1 <= len(sentence) <= 100
/// * sentence contains only letters
///
/// </summary>
public static string WordsInSentence (string sentence)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = WordsInSentence("This is a test");
var expected1 = "is";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = WordsInSentence("lets go for swimming");
var expected2 = "go for";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = WordsInSentence("there is no place available here");
var expected3 = "there is no place";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = WordsInSentence("Hi I am Hussein");
var expected4 = "Hi am Hussein";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = WordsInSentence("go for it");
var expected5 = "go for it";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = WordsInSentence("here");
var expected6 = "";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = WordsInSentence("here is");
var expected7 = "is";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| WordsInSentence | null |
You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence,
whose lengths are prime numbers,
the order of the words in the new string should be the same as the original one.
Example 1:
Input: sentence = "This is a test"
Output: "is"
Example 2:
Input: sentence = "lets go for swimming"
Output: "go for"
Constraints:
* 1 <= len(sentence) <= 100
* sentence contains only letters
|
HumanEval_csharp/144 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Your task is to implement a function that will Simplify the expression
/// x * n. The function returns True if x * n evaluates to a whole number and False
/// otherwise. Both x and n, are string representation of a fraction, and have the following format,
/// <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
///
/// You can assume that x, and n are valid fractions, and do not have zero as denominator.
///
/// Simplify("1/5", "5/1") = True
/// Simplify("1/6", "2/1") = False
/// Simplify("7/10", "10/2") = False
///
/// </summary>
public static bool Simplify (string x, string n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Simplify("1/5","5/1");
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Simplify("1/6","2/1");
var expected2 = false;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Simplify("5/1","3/1");
var expected3 = true;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Simplify("7/10","10/2");
var expected4 = false;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Simplify("2/10","50/10");
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Simplify("7/2","4/2");
var expected6 = true;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Simplify("11/6","6/1");
var expected7 = true;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Simplify("2/3","5/2");
var expected8 = false;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = Simplify("5/2","3/5");
var expected9 = false;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = Simplify("2/4","8/4");
var expected10 = true;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = Simplify("2/4","4/2");
var expected11 = true;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = Simplify("1/5","5/1");
var expected12 = true;
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = Simplify("1/5","1/5");
var expected13 = false;
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
}
}
}
| Simplify | null | Your task is to implement a function that will simplify the expression
x * n. The function returns True if x * n evaluates to a whole number and False
otherwise. Both x and n, are string representation of a fraction, and have the following format,
<numerator>/<denominator> where both numerator and denominator are positive whole numbers.
You can assume that x, and n are valid fractions, and do not have zero as denominator.
simplify("1/5", "5/1") = True
simplify("1/6", "2/1") = False
simplify("7/10", "10/2") = False
|
HumanEval_csharp/145 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Write a function which sorts the given list of integers
/// in ascending order according to the sum of their digits.
/// Note: if there are several items with similar sum of their digits,
/// order them based on their index in original list.
///
/// For example:
/// >>> OrderByPoints([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
/// >>> OrderByPoints([]) == []
///
/// </summary>
public static List<int> OrderByPoints (List<int> nums)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = OrderByPoints(new List<int> {1,11,-1,-11,-12});
var expected1 = new List<int> {-1,-11,1,-12,11};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = OrderByPoints(new List<int> {1234,423,463,145,2,423,423,53,6,37,3457,3,56,0,46});
var expected2 = new List<int> {0,2,3,6,53,423,423,423,1234,145,37,46,56,463,3457};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = OrderByPoints(new List<int> {});
var expected3 = new List<int> {};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = OrderByPoints(new List<int> {1,-11,-32,43,54,-98,2,-3});
var expected4 = new List<int> {-3,-32,-98,-11,1,2,43,54};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = OrderByPoints(new List<int> {1,2,3,4,5,6,7,8,9,10,11});
var expected5 = new List<int> {1,10,2,11,3,4,5,6,7,8,9};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = OrderByPoints(new List<int> {0,6,6,-76,-21,23,4});
var expected6 = new List<int> {-76,-21,0,4,23,6,6};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
}
}
}
| OrderByPoints | null |
Write a function which sorts the given list of integers
in ascending order according to the sum of their digits.
Note: if there are several items with similar sum of their digits,
order them based on their index in original list.
For example:
>>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
>>> order_by_points([]) == []
|
HumanEval_csharp/146 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Write a function that takes an array of numbers as input and returns
/// the number of elements in the array that are greater than 10 and both
/// first and last digits of a number are odd (1, 3, 5, 7, 9).
/// For example:
/// SpecialFilter([15, -73, 14, -15]) => 1
/// SpecialFilter([33, -2, -3, 45, 21, 109]) => 2
///
/// </summary>
public static int SpecialFilter (List<int> nums)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SpecialFilter(new List<int> {5,-2,1,-5});
var expected1 = 0;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SpecialFilter(new List<int> {15,-73,14,-15});
var expected2 = 1;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SpecialFilter(new List<int> {33,-2,-3,45,21,109});
var expected3 = 2;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SpecialFilter(new List<int> {43,-12,93,125,121,109});
var expected4 = 4;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SpecialFilter(new List<int> {71,-2,-33,75,21,19});
var expected5 = 3;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SpecialFilter(new List<int> {1});
var expected6 = 0;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SpecialFilter(new List<int> {});
var expected7 = 0;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| SpecialFilter | null | Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, 3, 5, 7, 9).
For example:
specialFilter([15, -73, 14, -15]) => 1
specialFilter([33, -2, -3, 45, 21, 109]) => 2
|
HumanEval_csharp/147 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You are given a positive integer n. You have to create an integer array a of length n.
/// For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
/// Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
/// and a[i] + a[j] + a[k] is a multiple of 3.
///
/// Example :
/// Input: n = 5
/// Output: 1
/// Explanation:
/// a = [1, 3, 7, 13, 21]
/// The only valid triple is (1, 7, 13).
///
/// </summary>
public static int GetMaxTriples (int n)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = GetMaxTriples(5);
var expected1 = 1;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = GetMaxTriples(6);
var expected2 = 4;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = GetMaxTriples(10);
var expected3 = 36;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = GetMaxTriples(100);
var expected4 = 53361;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| GetMaxTriples | null |
You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
and a[i] + a[j] + a[k] is a multiple of 3.
Example :
Input: n = 5
Output: 1
Explanation:
a = [1, 3, 7, 13, 21]
The only valid triple is (1, 7, 13).
|
HumanEval_csharp/148 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// There are eight planets in our solar system: the closerst to the Sun
/// is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
/// Uranus, Neptune.
/// Write a function that takes two planet names as strings planet1 and planet2.
/// The function should return a tuple containing all planets whose orbits are
/// located between the orbit of planet1 and the orbit of planet2, sorted by
/// the proximity to the sun.
/// The function should return an empty tuple if planet1 or planet2
/// are not correct planet names.
/// Examples
/// Bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus")
/// Bf("Earth", "Mercury") ==> ("Venus")
/// Bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
///
/// </summary>
public static List<string> Bf (string planet1, string planet2)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Bf("Jupiter","Neptune");
var expected1 = new List<string> {"Saturn","Uranus"};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Bf("Earth","Mercury");
var expected2 = new List<string> {"Venus"};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Bf("Mercury","Uranus");
var expected3 = new List<string> {"Venus","Earth","Mars","Jupiter","Saturn"};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Bf("Neptune","Venus");
var expected4 = new List<string> {"Earth","Mars","Jupiter","Saturn","Uranus"};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Bf("Earth","Earth");
var expected5 = new List<string> {};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Bf("Mars","Earth");
var expected6 = new List<string> {};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Bf("Jupiter","Makemake");
var expected7 = new List<string> {};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| Bf | null |
There are eight planets in our solar system: the closerst to the Sun
is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
Uranus, Neptune.
Write a function that takes two planet names as strings planet1 and planet2.
The function should return a tuple containing all planets whose orbits are
located between the orbit of planet1 and the orbit of planet2, sorted by
the proximity to the sun.
The function should return an empty tuple if planet1 or planet2
are not correct planet names.
Examples
bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus")
bf("Earth", "Mercury") ==> ("Venus")
bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
|
HumanEval_csharp/149 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Write a function that accepts a list of strings as a parameter,
/// deletes the strings that have odd lengths from it,
/// and returns the resulted list with a sorted order,
/// The list is always a list of strings and never an array of numbers,
/// and it may contain duplicates.
/// The order of the list should be ascending by length of each word, and you
/// should return the list sorted by that rule.
/// If two words have the same length, sort the list alphabetically.
/// The function should return a list of strings in sorted order.
/// You may assume that all words will have the same length.
/// For example:
/// assert list_sort(["aa", "a", "aaa"]) => ["aa"]
/// assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"]
///
/// </summary>
public static List<string> SortedListSum (List<string> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = SortedListSum(new List<string> {"aa","a","aaa"});
var expected1 = new List<string> {"aa"};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = SortedListSum(new List<string> {"school","AI","asdf","b"});
var expected2 = new List<string> {"AI","asdf","school"};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = SortedListSum(new List<string> {"d","b","c","a"});
var expected3 = new List<string> {};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = SortedListSum(new List<string> {"d","dcba","abcd","a"});
var expected4 = new List<string> {"abcd","dcba"};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = SortedListSum(new List<string> {"AI","ai","au"});
var expected5 = new List<string> {"AI","ai","au"};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = SortedListSum(new List<string> {"a","b","b","c","c","a"});
var expected6 = new List<string> {};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = SortedListSum(new List<string> {"aaaa","bbbb","dd","cc"});
var expected7 = new List<string> {"cc","dd","aaaa","bbbb"};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| SortedListSum | null | Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings and never an array of numbers,
and it may contain duplicates.
The order of the list should be ascending by length of each word, and you
should return the list sorted by that rule.
If two words have the same length, sort the list alphabetically.
The function should return a list of strings in sorted order.
You may assume that all words will have the same length.
For example:
assert list_sort(["aa", "a", "aaa"]) => ["aa"]
assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"]
|
HumanEval_csharp/150 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// A simple program which should return the value of x if n is
/// a prime number and should return the value of y otherwise.
///
/// Examples:
/// for XOrY(7, 34, 12) == 34
/// for XOrY(15, 8, 5) == 5
///
///
/// </summary>
public static int XOrY (int n, int x, int y)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = XOrY(7,34,12);
var expected1 = 34;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = XOrY(15,8,5);
var expected2 = 5;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = XOrY(3,33,5212);
var expected3 = 33;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = XOrY(1259,3,52);
var expected4 = 3;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = XOrY(7919,-1,12);
var expected5 = -1;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = XOrY(3609,1245,583);
var expected6 = 583;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = XOrY(91,56,129);
var expected7 = 129;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = XOrY(6,34,1234);
var expected8 = 1234;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = XOrY(1,2,0);
var expected9 = 0;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = XOrY(2,2,0);
var expected10 = 2;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
}
}
}
| XOrY | null | A simple program which should return the value of x if n is
a prime number and should return the value of y otherwise.
Examples:
for x_or_y(7, 34, 12) == 34
for x_or_y(15, 8, 5) == 5
|
HumanEval_csharp/151 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a list of numbers, return the sum of squares of the numbers
/// in the list that are odd. Ignore numbers that are negative or not integers.
///
/// DoubleTheDifference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
/// DoubleTheDifference([-1, -2, 0]) == 0
/// DoubleTheDifference([9, -2]) == 81
/// DoubleTheDifference([0]) == 0
///
/// If the input list is empty, return 0.
///
/// </summary>
public static int DoubleTheDifference (List<object> lst)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = DoubleTheDifference(new List<object> {});
var expected1 = 0;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = DoubleTheDifference(new List<object> {5,4});
var expected2 = 25;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = DoubleTheDifference(new List<object> {0.1,0.2,0.3});
var expected3 = 0;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = DoubleTheDifference(new List<object> {-10,-20,-30});
var expected4 = 0;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = DoubleTheDifference(new List<object> {-1,-2,8});
var expected5 = 0;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = DoubleTheDifference(new List<object> {0.2,3,5});
var expected6 = 34;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = DoubleTheDifference(new List<object> {-99,-97,-95,-93,-91,-89,-87,-85,-83,-81,-79,-77,-75,-73,-71,-69,-67,-65,-63,-61,-59,-57,-55,-53,-51,-49,-47,-45,-43,-41,-39,-37,-35,-33,-31,-29,-27,-25,-23,-21,-19,-17,-15,-13,-11,-9,-7,-5,-3,-1,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99});
var expected7 = 166650;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
}
}
}
| DoubleTheDifference | null |
Given a list of numbers, return the sum of squares of the numbers
in the list that are odd. Ignore numbers that are negative or not integers.
double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
double_the_difference([-1, -2, 0]) == 0
double_the_difference([9, -2]) == 81
double_the_difference([0]) == 0
If the input list is empty, return 0.
|
HumanEval_csharp/152 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// I think we all remember that feeling when the result of some long-awaited
/// event is finally known. The feelings and thoughts you have at that moment are
/// definitely worth noting down and comparing.
/// Your task is to determine if a person correctly guessed the results of a number of matches.
/// You are given two arrays of scores and guesses of equal length, where each index shows a match.
/// Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
/// the value is 0, and if not, the value is the absolute difference between the guess and the score.
///
///
/// example:
///
/// Compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
/// Compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
///
/// </summary>
public static List<int> Compare (List<int> game, List<int> guess)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Compare(new List<int> {1,2,3,4,5,1},new List<int> {1,2,3,4,2,-2});
var expected1 = new List<int> {0,0,0,0,3,3};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Compare(new List<int> {0,0,0,0,0,0},new List<int> {0,0,0,0,0,0});
var expected2 = new List<int> {0,0,0,0,0,0};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Compare(new List<int> {1,2,3},new List<int> {-1,-2,-3});
var expected3 = new List<int> {2,4,6};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Compare(new List<int> {1,2,3,5},new List<int> {-1,2,3,4});
var expected4 = new List<int> {2,0,0,1};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| Compare | null | I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and comparing.
Your task is to determine if a person correctly guessed the results of a number of matches.
You are given two arrays of scores and guesses of equal length, where each index shows a match.
Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
the value is 0, and if not, the value is the absolute difference between the guess and the score.
example:
compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
|
HumanEval_csharp/153 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You will be given the name of a class (a string) and a list of extensions.
/// The extensions are to be used to load additional classes to the class. The
/// strength of the extension is as follows: Let CAP be the number of the uppercase
/// letters in the extension's name, and let SM be the number of lowercase letters
/// in the extension's name, the strength is given by the fraction CAP - SM.
/// You should find the strongest extension and return a string in this
/// format: ClassName.StrongestExtensionName.
/// If there are two or more extensions with the same strength, you should
/// choose the one that comes first in the list.
/// For example, if you are given "Slices" as the class and a list of the
/// extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
/// return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
/// (its strength is -1).
/// Example:
/// for StrongestExtension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
///
/// </summary>
public static string StrongestExtension (string class_name, List<string> extensions)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = StrongestExtension("Watashi",new List<string> {"tEN","niNE","eIGHt8OKe"});
var expected1 = "Watashi.eIGHt8OKe";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = StrongestExtension("Boku123",new List<string> {"nani","NazeDa","YEs.WeCaNe","32145tggg"});
var expected2 = "Boku123.YEs.WeCaNe";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = StrongestExtension("__YESIMHERE",new List<string> {"t","eMptY","nothing","zeR00","NuLl__","123NoooneB321"});
var expected3 = "__YESIMHERE.NuLl__";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = StrongestExtension("K",new List<string> {"Ta","TAR","t234An","cosSo"});
var expected4 = "K.TAR";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = StrongestExtension("__HAHA",new List<string> {"Tab","123","781345","-_-"});
var expected5 = "__HAHA.123";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = StrongestExtension("YameRore",new List<string> {"HhAas","okIWILL123","WorkOut","Fails","-_-"});
var expected6 = "YameRore.okIWILL123";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = StrongestExtension("finNNalLLly",new List<string> {"Die","NowW","Wow","WoW"});
var expected7 = "finNNalLLly.WoW";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = StrongestExtension("_",new List<string> {"Bb","91245"});
var expected8 = "_.Bb";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = StrongestExtension("Sp",new List<string> {"671235","Bb"});
var expected9 = "Sp.671235";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
}
}
}
| StrongestExtension | null | You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as follows: Let CAP be the number of the uppercase
letters in the extension's name, and let SM be the number of lowercase letters
in the extension's name, the strength is given by the fraction CAP - SM.
You should find the strongest extension and return a string in this
format: ClassName.StrongestExtensionName.
If there are two or more extensions with the same strength, you should
choose the one that comes first in the list.
For example, if you are given "Slices" as the class and a list of the
extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
(its strength is -1).
Example:
for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
|
HumanEval_csharp/154 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
/// CycpatternCheck("abcd","abd") => False
/// CycpatternCheck("hello","ell") => True
/// CycpatternCheck("whassup","psus") => False
/// CycpatternCheck("abab","baa") => True
/// CycpatternCheck("efef","eeff") => False
/// CycpatternCheck("himenss","simen") => True
///
///
/// </summary>
public static bool CycpatternCheck (string a, string b)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = CycpatternCheck("xyzw","xyw");
var expected1 = false;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = CycpatternCheck("yello","ell");
var expected2 = true;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = CycpatternCheck("whattup","ptut");
var expected3 = false;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = CycpatternCheck("efef","fee");
var expected4 = true;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = CycpatternCheck("abab","aabb");
var expected5 = false;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = CycpatternCheck("winemtt","tinem");
var expected6 = true;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
}
}
}
| CycpatternCheck | null | You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
cycpattern_check("abcd","abd") => False
cycpattern_check("hello","ell") => True
cycpattern_check("whassup","psus") => False
cycpattern_check("abab","baa") => True
cycpattern_check("efef","eeff") => False
cycpattern_check("himenss","simen") => True
|
HumanEval_csharp/155 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Given an integer. return a tuple that has the number of even and odd digits respectively.
///
/// Example:
/// EvenOddCount(-12) ==> (1, 1)
/// EvenOddCount(123) ==> (1, 2)
///
/// </summary>
public static List<int> EvenOddCount (int num)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = EvenOddCount(7);
var expected1 = new List<int> {0,1};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = EvenOddCount(-78);
var expected2 = new List<int> {1,1};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = EvenOddCount(3452);
var expected3 = new List<int> {2,2};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = EvenOddCount(346211);
var expected4 = new List<int> {3,3};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = EvenOddCount(-345821);
var expected5 = new List<int> {3,3};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = EvenOddCount(-2);
var expected6 = new List<int> {1,0};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = EvenOddCount(-45347);
var expected7 = new List<int> {2,3};
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = EvenOddCount(0);
var expected8 = new List<int> {1,0};
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| EvenOddCount | null | Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
even_odd_count(-12) ==> (1, 1)
even_odd_count(123) ==> (1, 2)
|
HumanEval_csharp/156 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a positive integer, obtain its roman numeral equivalent as a string,
/// and return it in lowercase.
/// Restrictions: 1 <= num <= 1000
///
/// Examples:
/// >>> IntToMiniRoman(19) == 'xix'
/// >>> IntToMiniRoman(152) == 'clii'
/// >>> IntToMiniRoman(426) == 'cdxxvi'
///
/// </summary>
public static string IntToMiniRoman (int number)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = IntToMiniRoman(19);
var expected1 = "xix";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = IntToMiniRoman(152);
var expected2 = "clii";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = IntToMiniRoman(251);
var expected3 = "ccli";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = IntToMiniRoman(426);
var expected4 = "cdxxvi";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = IntToMiniRoman(500);
var expected5 = "d";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = IntToMiniRoman(1);
var expected6 = "i";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = IntToMiniRoman(4);
var expected7 = "iv";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = IntToMiniRoman(43);
var expected8 = "xliii";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = IntToMiniRoman(90);
var expected9 = "xc";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = IntToMiniRoman(94);
var expected10 = "xciv";
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = IntToMiniRoman(532);
var expected11 = "dxxxii";
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
var actual12 = IntToMiniRoman(900);
var expected12 = "cm";
var result12 = compareLogic.Compare(actual12, expected12);
if (!result12.AreEqual) {throw new Exception("Exception --- test case 11 failed to pass");}
var actual13 = IntToMiniRoman(994);
var expected13 = "cmxciv";
var result13 = compareLogic.Compare(actual13, expected13);
if (!result13.AreEqual) {throw new Exception("Exception --- test case 12 failed to pass");}
var actual14 = IntToMiniRoman(1000);
var expected14 = "m";
var result14 = compareLogic.Compare(actual14, expected14);
if (!result14.AreEqual) {throw new Exception("Exception --- test case 13 failed to pass");}
}
}
}
| IntToMiniRoman | null |
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> int_to_mini_roman(19) == 'xix'
>>> int_to_mini_roman(152) == 'clii'
>>> int_to_mini_roman(426) == 'cdxxvi'
|
HumanEval_csharp/157 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given the lengths of the three sides of a triangle. Return True if the three
/// sides form a right-angled triangle, False otherwise.
/// A right-angled triangle is a triangle in which one angle is right angle or
/// 90 degree.
/// Example:
/// RightAngleTriangle(3, 4, 5) == True
/// RightAngleTriangle(1, 2, 3) == False
///
/// </summary>
public static bool RightAngleTriangle (int a, int b, int c)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = RightAngleTriangle(3,4,5);
var expected1 = true;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = RightAngleTriangle(1,2,3);
var expected2 = false;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = RightAngleTriangle(10,6,8);
var expected3 = true;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = RightAngleTriangle(2,2,2);
var expected4 = false;
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = RightAngleTriangle(7,24,25);
var expected5 = true;
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = RightAngleTriangle(10,5,7);
var expected6 = false;
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = RightAngleTriangle(5,12,13);
var expected7 = true;
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = RightAngleTriangle(15,8,17);
var expected8 = true;
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = RightAngleTriangle(48,55,73);
var expected9 = true;
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = RightAngleTriangle(1,1,1);
var expected10 = false;
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
var actual11 = RightAngleTriangle(2,2,10);
var expected11 = false;
var result11 = compareLogic.Compare(actual11, expected11);
if (!result11.AreEqual) {throw new Exception("Exception --- test case 10 failed to pass");}
}
}
}
| RightAngleTriangle | null |
Given the lengths of the three sides of a triangle. Return True if the three
sides form a right-angled triangle, False otherwise.
A right-angled triangle is a triangle in which one angle is right angle or
90 degree.
Example:
right_angle_triangle(3, 4, 5) == True
right_angle_triangle(1, 2, 3) == False
|
HumanEval_csharp/158 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// Write a function that accepts a list of strings.
/// The list contains different words. Return the word with maximum number
/// of unique characters. If multiple strings have maximum number of unique
/// characters, return the one which comes first in lexicographical order.
///
/// FindMax(["name", "of", "string"]) == "string"
/// FindMax(["name", "enam", "game"]) == "enam"
/// FindMax(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
///
/// </summary>
public static string FindMax (List<string> words)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = FindMax(new List<string> {"name","of","string"});
var expected1 = "string";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = FindMax(new List<string> {"name","enam","game"});
var expected2 = "enam";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = FindMax(new List<string> {"aaaaaaa","bb","cc"});
var expected3 = "aaaaaaa";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = FindMax(new List<string> {"abc","cba"});
var expected4 = "abc";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = FindMax(new List<string> {"play","this","game","of","footbott"});
var expected5 = "footbott";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = FindMax(new List<string> {"we","are","gonna","rock"});
var expected6 = "gonna";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = FindMax(new List<string> {"we","are","a","mad","nation"});
var expected7 = "nation";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = FindMax(new List<string> {"this","is","a","prrk"});
var expected8 = "this";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
var actual9 = FindMax(new List<string> {"b"});
var expected9 = "b";
var result9 = compareLogic.Compare(actual9, expected9);
if (!result9.AreEqual) {throw new Exception("Exception --- test case 8 failed to pass");}
var actual10 = FindMax(new List<string> {"play","play","play"});
var expected10 = "play";
var result10 = compareLogic.Compare(actual10, expected10);
if (!result10.AreEqual) {throw new Exception("Exception --- test case 9 failed to pass");}
}
}
}
| FindMax | null | Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of unique
characters, return the one which comes first in lexicographical order.
find_max(["name", "of", "string"]) == "string"
find_max(["name", "enam", "game"]) == "enam"
find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
|
HumanEval_csharp/159 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// You're a hungry rabbit, and you already have Eaten a certain number of carrots,
/// but now you need to Eat more carrots to complete the day's meals.
/// you should return an array of [ total number of Eaten carrots after your meals,
/// the number of carrots left after your meals ]
/// if there are not enough remaining carrots, you will Eat all remaining carrots, but will still be hungry.
///
/// Example:
/// * Eat(5, 6, 10) -> [11, 4]
/// * Eat(4, 8, 9) -> [12, 1]
/// * Eat(1, 10, 10) -> [11, 0]
/// * Eat(2, 11, 5) -> [7, 0]
///
/// Variables:
/// @number : integer
/// the number of carrots that you have Eaten.
/// @need : integer
/// the number of carrots that you need to Eat.
/// @remaining : integer
/// the number of remaining carrots thet exist in stock
///
/// Constrain:
/// * 0 <= number <= 1000
/// * 0 <= need <= 1000
/// * 0 <= remaining <= 1000
///
/// Have fun :)
///
/// </summary>
public static List<int> Eat (int number, int need, int remaining)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Eat(5,6,10);
var expected1 = new List<int> {11,4};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Eat(4,8,9);
var expected2 = new List<int> {12,1};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Eat(1,10,10);
var expected3 = new List<int> {11,0};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Eat(2,11,5);
var expected4 = new List<int> {7,0};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Eat(4,5,7);
var expected5 = new List<int> {9,2};
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Eat(4,5,1);
var expected6 = new List<int> {5,0};
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
}
}
}
| Eat | null |
You're a hungry rabbit, and you already have eaten a certain number of carrots,
but now you need to eat more carrots to complete the day's meals.
you should return an array of [ total number of eaten carrots after your meals,
the number of carrots left after your meals ]
if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
Example:
* eat(5, 6, 10) -> [11, 4]
* eat(4, 8, 9) -> [12, 1]
* eat(1, 10, 10) -> [11, 0]
* eat(2, 11, 5) -> [7, 0]
Variables:
@number : integer
the number of carrots that you have eaten.
@need : integer
the number of carrots that you need to eat.
@remaining : integer
the number of remaining carrots thet exist in stock
Constrain:
* 0 <= number <= 1000
* 0 <= need <= 1000
* 0 <= remaining <= 1000
Have fun :)
|
HumanEval_csharp/160 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given two lists operator, and operand. The first list has basic algebra operations, and
/// the second list is a list of integers. Use the two given lists to build the algebric
/// expression and return the evaluation of this expression.
///
/// The basic algebra operations:
/// Addition ( + )
/// Subtraction ( - )
/// Multiplication ( * )
/// Floor division ( // )
/// Exponentiation ( ** )
///
/// Example:
/// operator['+', '*', '-']
/// array = [2, 3, 4, 5]
/// result = 2 + 3 * 4 - 5
/// => result = 9
///
/// Note:
/// The length of operator list is equal to the length of operand list minus one.
/// Operand is a list of of non-negative integers.
/// Operator list has at least one operator, and operand list has at least two operands.
///
///
/// </summary>
public static int DoAlgebra (List<string> operator, List<int> operand)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = DoAlgebra(new List<string> {"**","*","+"},new List<int> {2,3,4,5});
var expected1 = 37;
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = DoAlgebra(new List<string> {"+","*","-"},new List<int> {2,3,4,5});
var expected2 = 9;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = DoAlgebra(new List<string> {"//","*"},new List<int> {7,3,4});
var expected3 = 8;
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
}
}
}
| DoAlgebra | null |
Given two lists operator, and operand. The first list has basic algebra operations, and
the second list is a list of integers. Use the two given lists to build the algebric
expression and return the evaluation of this expression.
The basic algebra operations:
Addition ( + )
Subtraction ( - )
Multiplication ( * )
Floor division ( // )
Exponentiation ( ** )
Example:
operator['+', '*', '-']
array = [2, 3, 4, 5]
result = 2 + 3 * 4 - 5
=> result = 9
Note:
The length of operator list is equal to the length of operand list minus one.
Operand is a list of of non-negative integers.
Operator list has at least one operator, and operand list has at least two operands.
|
HumanEval_csharp/161 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
/// You are given a string s.
/// if s[i] is a letter, reverse its case from lower to upper or vise versa,
/// otherwise keep it as it is.
/// If the string contains no letters, reverse the string.
/// The function should return the resulted string.
/// Examples
/// Solve("1234") = "4321"
/// Solve("ab") = "AB"
/// Solve("#a@C") = "#A@c"
///
/// </summary>
public static string Solve (string s)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = Solve("AsDf");
var expected1 = "aSdF";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = Solve("1234");
var expected2 = "4321";
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = Solve("ab");
var expected3 = "AB";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = Solve("#a@C");
var expected4 = "#A@c";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
var actual5 = Solve("#AsdfW^45");
var expected5 = "#aSDFw^45";
var result5 = compareLogic.Compare(actual5, expected5);
if (!result5.AreEqual) {throw new Exception("Exception --- test case 4 failed to pass");}
var actual6 = Solve("#6@2");
var expected6 = "2@6#";
var result6 = compareLogic.Compare(actual6, expected6);
if (!result6.AreEqual) {throw new Exception("Exception --- test case 5 failed to pass");}
var actual7 = Solve("#$a^D");
var expected7 = "#$A^d";
var result7 = compareLogic.Compare(actual7, expected7);
if (!result7.AreEqual) {throw new Exception("Exception --- test case 6 failed to pass");}
var actual8 = Solve("#ccc");
var expected8 = "#CCC";
var result8 = compareLogic.Compare(actual8, expected8);
if (!result8.AreEqual) {throw new Exception("Exception --- test case 7 failed to pass");}
}
}
}
| Solve | null | You are given a string s.
if s[i] is a letter, reverse its case from lower to upper or vise versa,
otherwise keep it as it is.
If the string contains no letters, reverse the string.
The function should return the resulted string.
Examples
solve("1234") = "4321"
solve("ab") = "AB"
solve("#a@C") = "#A@c"
|
HumanEval_csharp/162 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given a string 'text', return its md5 hash equivalent string.
/// If 'text' is an empty string, return None.
///
/// >>> StringToMd5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
///
/// </summary>
public static object StringToMd5 (string text)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = StringToMd5("Hello world");
var expected1 = "3e25960a79dbc69b674cd4ec67a72c62";
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = StringToMd5("");
var expected2 = null;
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = StringToMd5("A B C");
var expected3 = "0ef78513b0cb8cef12743f5aeb35f888";
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = StringToMd5("password");
var expected4 = "5f4dcc3b5aa765d61d8327deb882cf99";
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| StringToMd5 | null |
Given a string 'text', return its md5 hash equivalent string.
If 'text' is an empty string, return None.
>>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
|
HumanEval_csharp/163 | csharp | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using KellermanSoftware.CompareNetObjects;
namespace Solution
{
public class Program
{
/// <summary>
/// You're an expert C# programmer
///
/// Given two positive integers a and b, return the even digits between a
/// and b, in ascending order.
///
/// For example:
/// GenerateIntegers(2, 8) => [2, 4, 6, 8]
/// GenerateIntegers(8, 2) => [2, 4, 6, 8]
/// GenerateIntegers(10, 14) => []
///
/// </summary>
public static List<int> GenerateIntegers (int a, int b)
{ |
public static void Main(string[] args)
{
CompareLogic compareLogic = new CompareLogic();
var actual1 = GenerateIntegers(2,10);
var expected1 = new List<int> {2,4,6,8};
var result1 = compareLogic.Compare(actual1, expected1);
if (!result1.AreEqual) {throw new Exception("Exception --- test case 0 failed to pass");}
var actual2 = GenerateIntegers(10,2);
var expected2 = new List<int> {2,4,6,8};
var result2 = compareLogic.Compare(actual2, expected2);
if (!result2.AreEqual) {throw new Exception("Exception --- test case 1 failed to pass");}
var actual3 = GenerateIntegers(132,2);
var expected3 = new List<int> {2,4,6,8};
var result3 = compareLogic.Compare(actual3, expected3);
if (!result3.AreEqual) {throw new Exception("Exception --- test case 2 failed to pass");}
var actual4 = GenerateIntegers(17,89);
var expected4 = new List<int> {};
var result4 = compareLogic.Compare(actual4, expected4);
if (!result4.AreEqual) {throw new Exception("Exception --- test case 3 failed to pass");}
}
}
}
| GenerateIntegers | null |
Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
generate_integers(2, 8) => [2, 4, 6, 8]
generate_integers(8, 2) => [2, 4, 6, 8]
generate_integers(10, 14) => []
|