addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

London D Programmers Message Board › Secret Santa Coding Challenge

Secret Santa Coding Challenge

Kingsley
kingsleyh
Chafford Hundred, GB
Post #: 2
Hi

At the meetup we did a secret santa coding challenge and some of the group have sent in their work :)

Feel free to discuss. I'll post the links to each solution in here.

These were the rules:
http://slides.com/kin...­

You can still do the challenge if you like :)
Kingsley
kingsleyh
Chafford Hundred, GB
Post #: 3
From Ross: Here is the solution David and I came up with, it weights and sorts the names so that family names will not appear next to each other, then each assigns a present to its next neighbour. http://pastebin.com/0...­
Kingsley
kingsleyh
Chafford Hundred, GB
Post #: 4
From Andy:
Good stuff. I had a crack at finishing off the problem...critiques from any of the ninjas in the group welcome :-) Kingsley the link didn't work so I stole some names from anither variant of the same problem. Cheers, A.

http://pastebin.com/A...­
Kingsley
kingsleyh
Chafford Hundred, GB
Post #: 5
This an attempt I made this morning:
http://pastebin.com/h...­
Andy Smith J.
user 10720016
London, GB
Post #: 1
From Ross: Here is the solution David and I came up with, it weights and sorts the names so that family names will not appear next to each other, then each assigns a present to its next neighbour. http://pastebin.com/0...­

Andy Smith J.
user 10720016
London, GB
Post #: 2
Don't know what happened there - pls ignore my empty reply :-)

One thing that seems to stand out is that ( whether by accident or design, although I suspect by design :-) ), D ends up being very readable. Can see the intent, flow etc.. very clearly which I think bodes very well for the language.

One thing at the end maybe an improvement is that the foreach supports a key,value syntax in the foreach loop which would obviate the need to loop over keys and pull out the value.

Cheers,

A.
Ross M.
user 14069267
London, GB
Post #: 1
Thanks, I am still getting the syntax down!

There is actually a critical flaw(!) in our otherwise-flawless algorithm that renders it quite useless with certain sets of data. I have fixed it now with a different approach, and it is still optimal in the sense that after some initial preparations it only takes one pass.

I will hopefully try and write up the issues I discovered and the new solution tomorrow - this is a really nice problem!
Ross M.
user 14069267
London, GB
Post #: 2
Hey guys,

I have written up my revised solution to this problem, and also some other extended bits where I have been tinkering with the various metaprogramming features.

http://pinksquirrella...­

Cheers

Ross
Powered by mvnForum

People in this
group are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy