12 個の要素の配列total
があり、各要素は int を表します。たとえばtotal[0] = 1
。-という別の配列remaining
があります。 の要素が少なくなります。total
occupied spaces
remaining
total
total
配列内の連続する int 間に >=size
ギャップがあるインスタンスを調べることができるメソッドを作成したいと考えています。例えば:
If `foo.total = [1,2,6,7,8,9,]`
then when I call `foo.number_of_slots_available(3)`
I get `2` (because 3,4,5 is not included and 10,11,12 is not included)
これが私の方法の始まりです:
def number_of_slots(size)
total_array = (1..12).to_a
occupied_spaces = some_map.to_a
remaining_array = total_array - occupied_spaces
return ????
end