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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:54:21+00:00 2026-06-10T10:54:21+00:00

What would be the most efficient approach to perform a logical OR (on 1’s

  • 0

What would be the most efficient approach to perform a logical OR (on 1’s and 0’s) on every column of a matrix in Python?

   0    0    0
   0    0    0
   1    0    1
   0    0    1
OR 0    0    1
   _    _    _
   1    0    1

Some context: I am employing a dynamic programming method for generating a table for a small project I’v been working on. I have 2 tables, one is 3-d and the other is 2-d. In the 3-d table only has 1’s or 0’s in it and the other has contains ints.

The 2-d table is generated as the 3-d one is, so I have to interleave them. The reason I want to OR an entire column is see if there was any 1’s in it, if so the same column will contain a 1 in the 2-d table.

Example:

3-d table:

[1][i][j]
1000010000000000...
1000000001000000...
1000000000010000...
1000000000000001...

[2][i][j]
1000100000000000...
1000001000000000...
1000000001000000...

2-d table:
(after OR’ing each column of the 3-d table, where the left-most most indices corresponds to a row in the 2-d table):

1000010001100001...
100010100000000...

Not sure if this is all clear…but thank you to anyone who helps! 😀

I wont explain the method I used

  • 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-10T10:54:23+00:00Added an answer on June 10, 2026 at 10:54 am

    How do you represent this data? If that’s lists of lists, then swap last two indexes of a 3D-array, so “columns” can be accessed as sequential lists, and use any. That’s about as fast as you can get in vanilla CPython: loop will be completely executed in C runtime.

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

Sidebar

Related Questions

I was wondering which would be the most efficient approach to implement some kind
What would be the most efficient way of counting the number of times a
I'm trying to figure out what would be the most efficient (with respect to
I have this string: B82V16814133260 what would be the most efficient way to get
If I have two associative arrays, what would be the most efficient way of
What would you say is the most efficient way to delete old records from
I'm looking for the most efficient Java method that would allow me to 'delete
What are the most efficient SQL queries that would take an existing MySQL table
Would anyone please be able to tell me the most efficient way to compare
I would like to ask you what's the most efficient way for checking user's

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.