I've seen David Nolen talk a bit about core.logic and I admit it seems interesting. Since I'm new to Clojure I didn't think to look into it. I'll take a look at your solution Leif. Thanks for the suggestions everyone.
On Sunday, May 18, 2014 6:28:15 PM UTC-5, Leif wrote: > > Hi, Brad (and Karsten). > > I solved the problem with core.logic, to try out its CLP(FD) features. It > took about 220-230ms to find a solution. It took about 400ms to find all > solutions. > > Here it is for you to peek at after you try it: > https://gist.github.com/leifp/b4af5f4cd7289c38b55a > > The code looked very similar to the problem statement, no careful > hand-crafting required. The one minor irritation is that there is no way > to easily specify equations involving vectors of logic vars. I think I > could've done it in this case with macros, but I wouldn't want to do that > if I had hundreds or thousands of variables. Maybe I'm just not > experienced enough with core.logic, experts chime in if so. > > --Leif > > On Friday, May 16, 2014 3:31:26 PM UTC-4, Brad Kurtz wrote: >> >> I'm pretty new to Clojure so I'm trying out simple examples to see if I >> can get myself in the functional programming/Lisp mindset. My team lead >> sends out puzzles from his Mensa calendar, and every once in a while I find >> one that seems fun to solve as a Clojure program. >> >> With this particular puzzle, I've tried a couple of different ways of >> "solving" the puzzle, and I decided to try a recursive function. I'm fairly >> certain that what I've done here is not anywhere near ideal, and I'm >> looking for insight into how to better write this solution. >> >> Also, with my latest attempt I seem to be getting a stack overflow error, >> and I'm not quite sure why. I'm pretty sure it has to do with the >> permutation sequence (it's basically 10 factorial, or around 3 million >> sequences), but I don't really know how to better represent this problem in >> Clojure. Can anyone help? Thanks! >> >> https://github.com/bradkurtz/clojure-puzzles/tree/master/billiards >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.