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

  • Home
  • SEARCH
  • 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 8530537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:16:14+00:00 2026-06-11T09:16:14+00:00

How to build this sequence in ruby? { 0 => 00000, 1 => 00001,

  • 0

How to build this sequence in ruby?

{
"0" => "00000",
"1" => "00001",
"2" => "00002",
"3" => "00003",
"4" => "00010",
"5" => "00011",
"6" => "00012",
....
"1020" => "33330",
"1021" => "33331",
"1022" => "33332",
"1023" => "33333"
}
  • 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-11T09:16:15+00:00Added an answer on June 11, 2026 at 9:16 am

    You can do:

    nums = Hash.new
    0.upto(1023){ |x| nums[x] = x.to_s(4) }
    puts nums
    

    Basically Fixnum.to_s(4) will convert your base 10 number to base 4.

    Update – As a one liner

    If you want a one liner, you can do:

    puts (0..1023).inject({}){ |hash, e| hash[e] = e.to_s(4); hash }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build this layout: I have this at this time: http://jsfiddle.net/Gh6mB/12/ The
I might end up having to build this, but it would be nice if
This build warning just started showing up. I'm building for 3.1.3. Not sure what
I get this build error when I build my iPhone project to run on
I have a doubt, I made this build file in order to build 3
my project this year : build safe search engine for kids so i need
At present I'm having to do something like this to build a Type definition
My jar will not run after I compiled it. I use this ant build
This may be a build in feature of FMOD, but I'd like to see
Imagine this as the code from build.xml: <project name=test project> <target name=first> <echo>first</echo> </target>

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.