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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:23:29+00:00 2026-06-04T02:23:29+00:00

I hoping someone can help me with a problem I’m stuck(again) with. if i

  • 0

I hoping someone can help me with a problem I’m stuck(again) with.

if i have coordinates:

 x = array[0,1,2,3,4,3,2,3,-2,-4,-7,2,2]
 y = array[0,1,2,3,4,5,6,7,8,9,10,11,12]

and with help in Categorizing the list of array in python, i could make:

x = [(0, 1, 2, 3, 4), (4, 3, 2), (2, 3), (3, -2, -4, -7), (-7, 2), (2, 2)]

The question is, how should i made y like this:

y = [(0,1,2,3,4),(4,5,6),(6,7),(7,8,9,10),(10,11),(11,12)]

since, x and y is actually coordinates and they bounded each other.

i have tried to use loop function, and i realize the code is still wrong

se = []
for i in range(len(z)):
        k = z[i]
        for i in range(len(k)):
                se.append(y[i])

best regards,

Glenn

  • 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-04T02:23:31+00:00Added an answer on June 4, 2026 at 2:23 am

    The following does what you want:

    x = [(0, 1, 2, 3, 4), (4, 3, 2), (2, 3), (3, -2, -4, -7), (-7, 2), (2, 2)]
    y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    
    s = map(len, x)
    s = [0] + [sum(s[:i])-i for i in range(1, len(s))] + [len(y)]
    y = [tuple(y[a:b+1]) for a, b in zip(s, s[1:])]
    

    Result:

    >>> y
    [(0, 1, 2, 3, 4), (4, 5, 6), (6, 7), (7, 8, 9, 10), (10, 11), (11, 12)]
    

    This basically constructs a list of positions where y will be split. We figure this out using the length of each tuple in x, but it gets a little tricky because the last element of a set is included as the next element in the following set.

    Here is one of the intermediate values which may help to clarify how this works:

    >>> zip(s, s[1:])
    [(0, 4), (4, 6), (6, 7), (7, 10), (10, 11), (11, 13)]
    

    We use this to construct the new y like this:

    [(0, 4), (4,  6), (6,  7), (7, 10), (10, 11), (11, 13)]
       \ |     \   \    \_  \
       | |      \  |      \  |
    [y[0:4+1], y[4:6+1], y[6:7+1], ...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hoping someone can help me as I've been stuck on this problem for
I have a problem I'm hoping someone has come across and can help. I
Im hoping someone can help me with a small problem! I have a php
I am hoping someone can help me with a problem I'm stuck with. I
I have a weird problem that I am hoping someone can help me with.
I'm really stuck with a problem I'm hoping someone can help me with. I'm
got a small little problem I'm hoping someone can help me with. I have
This problem is very strange and I'm hoping someone can help me. For the
im hoping someone can help me quickly with a question i have. As site
I am hoping someone can help me with a question i have relating to

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.