1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 19:19:07 +01:00
CodeWars/6kyu/rectangle_into_squares/solution.cs

27 lines
490 B
C#
Raw Normal View History

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