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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:55:08+00:00 2026-06-16T03:55:08+00:00

I have an algorithm that stores the coordinates of an n by m matrix

  • 0

I have an algorithm that stores the coordinates of an n by m matrix of characters in python. For example

a b 
c d 

would be stored as a list of coordinate-character pairs:

(0, 0) a    (0, 1) b   
(1, 0) c    (1, 1) d

My python code is as below

def init_coordination(self):

    list_copy = self.list[:]
    row = 0
    column = 0
    coordination = {}

    for char in list copy

        if column >= self.column:
            row += 1
            column = 0

        coordination[char] = (row, column)
        column += 1

    return coordination

I am trying to implement this algorithm in ruby, and I am guessing that the closest data structure to dictionary in ruby is hash. I need some suggestion with the following ruby code:

def self.init_coordination
    position = Hash.new("Coordination of char")
    row = 0
    column = 0
    @list.each do |char|
        if column < @column
            position[row, column] = char
            column = column + 1
        elsif column == @column
            column = 0
            row = row + 1
        elsif row == @row
            puts position
        end
    end

Also, how would I represent a list in ruby?

  • 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-16T03:55:09+00:00Added an answer on June 16, 2026 at 3:55 am

    Lists in Ruby are called Arrays.

    arr = []
    arr.push(0) # => [0]
    arr.concat([1,2,3]) # => [0, 1, 2, 3]
    arr2d = [[0,0],[0,1],[1,0],[1,1]]
    

    There is also a Matrix type which is probably more efficient and likely has more operations of interest.

    require 'matrix'
    matrix = Matrix[[0,0],[0,1],[1,0],[1,1]]
    matrix[0,0] # => 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a spell checker algorithm. I have constructed a Trie that stores
I have a complicated algorithm that updates 3 histograms that are stored in arrays.
We have an application that stores a sparse matrix. This matrix has entries that
I have an algorithm that finds the minimum of function/n on Rn. And I
I have an algorithm that finds a value in a cell, for this case
I have an algorithm that recursively makes change in the following manner: public static
I have this algorithm that I want to implement on VB6. Sub Main() dim
I have simple algorithm that clean the whitespace from half string until end. Here
If I have an algorithm that takes n log n steps (e.g. heapsort), where
I have written an algorithm that takes geospatial data and performs a number of

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.