Here is another idea for calculating hamming numbers
  ([: /:~ [: ,@:(*/"0 1)/ 2 3 5x&(^"0 1)) i.40

The next step is to work out how big the integer list needs to be for a given 
problem
>:@>....@%: y  is a quick & dirty solution but seems to work.

 hamming2=:  <: { ([: /:~ [: ,@:(*/"0 1)/ 2 3 5x&(^"0 1))@(i.@>:@>....@%:@(>./))
   hamming2 >:i.20
1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36
   hamming2 1691
2125764000

- doesn't solve the 1e6 problem though

> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Aai
> Sent: Wednesday, 6 January 2010 06:17
> To: Programming forum
> Subject: [Jprogramming] Rosetta code: hamming numbers
> 
> J-ers and RC-ers,
> 
> I entered a solution for this task:
> http://rosettacode.org/wiki/Hamming_numbers .
> 
> hamming =: {. (/:~...@~.@] , 2 3 5 * {)/ @ (1x ,~ i...@-)
> 
> 
> However the problem is (which I didn't realize while entering my
> solution) producing the millionth hamming number. So if anyone has a
> better idea on this, go ahead. Of course it's also a challenge to come
> up with a very J-ish solution for this problem.
> 
> R.E.Boss perhaps? I used your solution HN00 and it produced the answer
> in ca. 47 sec on my computer.
> 
> --
> Met vriendelijke groet,
> =@@i
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to