Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9119345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:22:26+00:00 2026-06-17T05:22:26+00:00

The thing I need to do is very simple, so I don’t need to

  • 0

The thing I need to do is very simple, so I don’t need to create a complex program and I only need to use this once, making the result of this the feed data for the real project I’m working now.

I need to obtain the 50 first (or, better, 50 randoms) combinations of a set of N elements, being N every value from 2 to 50.

In Ruby, logically, will be something like

require 'pp'

pp (1..50).to_a.permutation.to_a.first(50)

But sadly, that programs always ran out of memory. As I matter of fact, the “maximum” number I could generate on my machine is 10, and I need 50.

I’m pretty sure that exists some other, more efficient way, to achieve this, but because I don’t know very well the maths involved, I need to desperately ask for you help. Any of you know about some gem, library, or even an algorithm who do that in a way that doesn’t consume all the memory. It doesn’t matter if is slow, as I said, I only need to generate this thing once.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:22:28+00:00Added an answer on June 17, 2026 at 5:22 am

    Don’t call to_a on the permutation enumerator, just use it as an enumerator:

    (1..50).to_a.permutation.first(50)
    

    But if you want random permutations, you can just shuffle the array 50 times:

    ar = (1..50).to_a
    Array.new(50){ar.shuffle}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems to be a very simple thing, but I don't know how to
This is a very simple question, but I don't find how to do it.
I need to write an OCR program for digits only. I will use MNIST
This SQL statement example is very close to what I think I need... update
I'm quite new to this Git thing and need a little help. I recently
This is a kind of a random thing I need. Basically my setup is
simple thing which I need to do is, that I have a pdf document
I have this thing that i need to do and some advices will be
I am trying to do simple thing: I just need to set some cells
I need to do the same thing from this post Pop Images like Google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.