I hereby claim:
- I am rcongiu on github.
- I am drcongiu (https://keybase.io/drcongiu) on keybase.
- I have a public key ASC1zbptwtMmXIkqD-MG16Vj8Sfl982JyFTzZAE7_9eDiwo
To claim this, I am signing this object:
def pairGifts(l:Seq[Person]) = { | |
@tailrec | |
def innerPair(pairs:Seq[(Person,Person)], b:List[Person], r:List[Person]):Seq[(Person,Person)] = { | |
// avoid last giving to itself | |
if(b.size == 2 && b.last == r.last) return pairs :+ (b.head, r.last) :+ (b.last, r.head) | |
(b, r) match { | |
case (Nil, Nil) => pairs | |
case ( (bh :: bt), (rh :: rt)) => | |
// avoid one person give to himself. In that case, pick next and put back current | |
val (recipient, recipients) = if (bh != rh) (rh, rt) else ( rt.head, rh :: rt.tail) |
I hereby claim:
To claim this, I am signing this object: