Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test and implementation for returning the maximum amount of free

slots within a range given by Start and Length
  • Loading branch information...
commit a273fe2a048bed5ac257c6ced33b5dd5549e867e 1 parent 3bdf61a
gianfranco authored
Showing with 18 additions and 1 deletion.
  1. +8 −0 Booking/booking.dyalog
  2. +10 −1 Booking/booking_unittests.dyalog
8 Booking/booking.dyalog
View
@@ -25,4 +25,12 @@ GETID ← { Lookup ⍵,2 }
Z ,/ Ids,[1.5]{(),1} ¨ MaxFreeSlots
+ Z MaxFreeSlots Input;Table;SlotRange;Slots;Ids;SubTable
+ (Table SlotRange) Input
+ Slots ¯1 + +/ SlotRange
+ Ids Table[;1]
+ SubTable (1[2] Table)[;Slots]
+ ZMaxFree Ids,SubTable
+ Z[;2 Z] + Slots
+
:EndNamespace
11 Booking/booking_unittests.dyalog
View
@@ -30,6 +30,15 @@ UTTable ← ↑ (3 0 0 0) (1 0 0 0) (2 0 0 0)
Z Expected #.Booking.MaxFree UTTable2
+ Z UT6;UTTable2;SlotRange;Expected;RangeStart;RangeLength
+ UTTable2 (3 0 2 0 0 0) (1 5 7 0 0 3) (2 0 0 0 2 4)
+ RangeStart 3
+ RangeLength 3
+ SlotRange RangeStart RangeLength
+ Expected (3 3 3) (1 2 3) (2 1 3)
+ Z Expected #.Booking.MaxFreeSlots UTTable2 SlotRange
+
+
Z RunTest Name
Z ⍎ Name
:If ~ Z
@@ -40,7 +49,7 @@ UTTable ← ↑ (3 0 0 0) (1 0 0 0) (2 0 0 0)
Z Test;Tests
- Tests 'UT1' 'UT2' 'UT3' 'UT4' 'UT5'
+ Tests 'UT1' 'UT2' 'UT3' 'UT4' 'UT5' 'UT6'
Z RunTest ¨ Tests
:if ^/ Z
'All ' ( Tests) 'tests passed'
Please sign in to comment.
Something went wrong with that request. Please try again.