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 6473957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:31:42+00:00 2026-05-25T06:31:42+00:00

Which data structure is best to organize 32 items. I have 8 groups of

  • 0

Which data structure is best to organize 32 items. I have 8 groups of 4 items.

Right now I have each item defined and put into an array of 4 (did that 8 times).

Then I took 4 of those arrays of 4 and put them into another array (so the group is half of the total size, i.e. 16).

Then I made a an array with two items, where each entry in the array had 16 items in it.

I’m new to Ruby but there has to be a better way to structure this data.

Help is much appreciated.

  • 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-05-25T06:31:42+00:00Added an answer on May 25, 2026 at 6:31 am

    Use a hash http://www.ruby-doc.org/core/classes/Hash.html you could also benefit from just writing your own classes I suppose.

    If you just use the native classes it’s very easy to fit the data structures to what you need:

    ree-1.8.7-2010.02 :036 > hsh = {"big"=>[234234, 234243, 23242], "small"=>[1, 2, 3]}
     => {"big"=>[234234, 234243, 23242], "small"=>[1, 2, 3]} 
    # access all the values in a single array
    ree-1.8.7-2010.02 :037 > hsh.values.flatten
     => [234234, 234243, 23242, 1, 2, 3] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I commonly run into the following situation where I have a data structure which
I am trying to determine which implementation of the data structure would be best
I have a data structure which uses composite ids (Which I dont wish to
I have a data structure which is as given below: class File { public
Guys, I have a data structure which has 25 distinct keys (integer) and a
I have a speed critical multithreaded program which involves data in a tree structure.
Which data structure (Array or B+ tree) is best for the fowllowing scenario in
I want to test which data structure is the best by looking at the
I have multiple databases with the same structure in which data is sometimes copied
I want to know that which data structure suits best for storing the family

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.