Hmm ... what idioms are we allowed then? :-)

Iterate over the sizes
    within each size
       iterate over the colours
          make a combination and stow it somewhere

Does that make sense?

Either that or get some sleep :-)

Torm3nt wrote:
> This may seem rather simple to some, but being late at night it's
> driving me up the wall..
>
> The context behind this is I'm trying to create all unique product
> options for a product.
>
> Consider:
>
> We have two product option groups, size and colour.
>
> Size contains: S, M, L, XL
> Colour contains: red, blue, green, black, brown
>
> I need to write an algorithm (this isn't for ruby btw, so no ruby
> idioms =P), that gets all unique combinations, for example:
>
> S red, S blue, S green, S black, S brown
> M red, M blue.etc.etc.
>
> They're all valid, but I can't then go:
>
> red S - it's exactly the same option as before.
>
> I have tried to do this three different ways and each way I've hit a daed end.
>
>
> HELP!
>
> =)
>
> >
>
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to