1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-16 20:56:57 +02:00
CodeWars/8kyu/to_square_or_not_to_square/solution.cs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

18 lines
396 B
C#

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;
}
}