Re: Count vowels in a string

2014-05-22 Thread Brad Kurtz
keep is cool, thanks for showing me that :)

On Wednesday, May 21, 2014 2:35:50 AM UTC-5, Vesa Marttila wrote:

 On Wednesday, May 21, 2014 2:03:14 AM UTC+3, Brad Kurtz wrote:

 I saw a rant online about interviewing developers that mentioned 
 candidates not being able to count the number of vowels in a string. So 
 naturally, I decided to see if I could do it in Clojure!

 I wanted to see others' opinions on other ways of doing it.

 *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e 
 https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e*


 Hi,

 I ended up with this: https://gist.github.com/ponzao/7399c08bb3b40d349289

 (def vowels
   #{\a \e \i \o \u})
  
 (defn count-vowels
   [s]

   (count (keep vowels (.toLowerCase s

 Vesa


-- 
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.


Count vowels in a string

2014-05-20 Thread Brad Kurtz
I saw a rant online about interviewing developers that mentioned candidates 
not being able to count the number of vowels in a string. So naturally, I 
decided to see if I could do it in Clojure!

I wanted to see others' opinions on other ways of doing it.

*https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e*

-- 
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.


Re: Count vowels in a string

2014-05-20 Thread Brad Kurtz
I like the one-liner. That was the kind of feedback I was looking for, 
thanks.

On Tuesday, May 20, 2014 6:13:48 PM UTC-5, puzzler wrote:

 You're seriously overthinking this if it's any more than a one-liner.

 (defn count-vowels [s] (count (filter #{\a \e \i \o \u \A \E \I \O \U} 
 (seq s


 On Tue, May 20, 2014 at 4:03 PM, Brad Kurtz bkurt...@gmail.comjavascript:
  wrote:

 I saw a rant online about interviewing developers that mentioned 
 candidates not being able to count the number of vowels in a string. So 
 naturally, I decided to see if I could do it in Clojure!

 I wanted to see others' opinions on other ways of doing it.

 *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e 
 https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e*
  
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
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.


Re: Looking for help with a Stack Overflow error

2014-05-18 Thread Brad Kurtz
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.


Looking for help with a Stack Overflow error

2014-05-16 Thread Brad Kurtz
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.


Re: Looking for help with a Stack Overflow error

2014-05-16 Thread Brad Kurtz
I have since fixed the original stack overflow error I was getting, it was 
a result of not using recur. However, I'm still trying to find the best 
way to actually iterate through the permutations to find the result...

On Friday, May 16, 2014 2:31:26 PM UTC-5, 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.