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

26 lines
490 B
C#

using System;
using System.Collections.Generic;
public class SqInRect {
public static List<int> sqInRect(int lng, int wdth) {
if (lng == wdth) return null;
List<int> result = new List<int>();
while (lng > 0 && wdth > 0) {
if (lng < wdth) {
int a = lng;
result.Add(a);
lng = wdth - a;
wdth = a;
} else {
int a = wdth;
result.Add(a);
wdth = lng - a;
lng = a;
}
}
return result;
}
}