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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:11:40+00:00 2026-05-11T20:11:40+00:00

My data structure is initialized as follows: [[0,0,0,0,0,0,0,0] for x in range(8)] 8 characters,

  • 0

My data structure is initialized as follows:

[[0,0,0,0,0,0,0,0] for x in range(8)]

8 characters, 8 rows, each row has 5 bits for columns, so each integer can be in the range between 0 and 31 inclusive.

I have to convert the number 177 (can be between 0 and 319) into char, row, and column.

Let me try again, this time with a better code example. No bits are set.

Ok, I added the reverse to the problem. Maybe that’ll help.

chars = [[0,0,0,0,0,0,0,0] for x in range(8)]

# reverse solution
for char in range(8):
    for row in range(8):
        for col in range(5):
            n =  char * 40 + (row * 5 + col)
            chars[char][row] = chars[char][row] ^ [0, 1<<4-col][row < col]

for data in range(320):
    char = data / 40
    col = (data - char * 40) % 5
    row = ?
    print "Char %g, Row %g, Col %g" % (char, row, col), chars[char][row] & 1<<4-col
  • 1 1 Answer
  • 1 View
  • 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-11T20:11:41+00:00Added an answer on May 11, 2026 at 8:11 pm

    Okay, this looks as if you’re working with a 1×8 LCD display, where each character is 8 rows of 5 pixels.

    So, you have a total of 8 * (8 * 5) = 320 pixels, and you want to map the index of a pixel to a position in the “framebuffer” decribing the display’s contents.

    I assume pixels are distributed like this (shown for the first char only), your initial loops indicate this is is correct:

     0  1  2  3  4
     5  6  7  8  9
    10 11 12 13 14
    15 16 17 18 19
    20 21 22 23 24
    25 26 27 28 29
    30 31 32 33 34
    35 36 37 38 39
    

    We then have:

     # Compute which of the 8 characters the pixel falls in, 0..7:
     char = int(number / 40)
    
     # Compute which pixel column the pixel is in, 0..4:
     col = number % 5
    
     # Compute which pixel row the pixel is in, 0..7:
     row = int((number - char * 40) / 5)
    

    I used explicit int()s to make it clear that the numbers are integers.

    Note that you might want to flip the column, since this numbers them from the left.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A text file holds information about a softball team. Each line has data arranged
I often* find myself in need of a data structure which has the following
A data structure that I use commonly in multi-threaded applications is a ConcurrentHashMap where
Which data structure is most suitable for forward and backward webpage traversal in web
I need a data structure which will support the following operations in a performant
I have a data structure which uses composite ids (Which I dont wish to
What's the best data structure (in java) for the task of loading 51 million
Is there a .NET data structure I could use for bidirectional lookup? Here's the
A single data structure to store different types in a single variable. Not asking
I have a data structure defined as struct myDataStruct { int32_t header; int16_t data[8];

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.