1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 16:43:46 +01:00
CodeWars/8kyu/to_square_or_not_to_square/solution.cs

19 lines
396 B
C#
Raw Normal View History

using System;
public class Kata
{
public static int[] SquareOrSquareRoot(int[] array)
{
int[] new_array = new int[array.Length];
for (int i = 0, max = array.Length; i < max; i++)
{
double root = Math.Sqrt(array[i]);
if (root - (int) root <= double.Epsilon) new_array[i] = (int) root;
else new_array[i] = array[i] * array[i];
}
return new_array;
}
}