User Profile

Collapse

Profile Sidebar

Collapse
jcl43
jcl43
Last Activity: Dec 13 '08, 08:35 AM
Joined: Nov 16 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jcl43
    started a topic Can someone describe what these functions do?

    Can someone describe what these functions do?

    Code:
    def swime(lst):
        p = lst[0]
        S = []
        B = []
        for x in lst:
            if x < p:
                S.append(x)
            else:
                B.append(x)
        return S + swerve(B)	
    
    def swerve(lst):
        result = []
        for x in lst:
            if x > 0:
                result.append(x)
        result.sort()
        return result
    ...
    See more | Go to post

  • jcl43
    replied to distance between multiple locations
    ok.so now i have it like this but I how do i add the distance between the citeis to the distance ?
    which is this part :
    Code:
     distance += get_distance(i[1],i[0],n[1],n[0])
    Code:
    def total_distance(cities):
        total = []
        for i in cities:
            distance = 0
            for n in cities:
                distance += get_distance(i[1],i[0],n[1],n[0])
                total.append(distance)
    ...
    See more | Go to post

    Leave a comment:


  • jcl43
    started a topic distance between multiple locations

    distance between multiple locations

    so after that part, I have to make a function that returns a list of total distances between each of the cities in the cities list (a list of pair-lists) and I have to have it so the function calculates the total distances between each city and all the other cities. The index of the results list should correspond to the index in the cities list so that index i in the results list represents the total distance between cities[i] and all the other cities....
    See more | Go to post

  • jcl43
    replied to Beginner Python-er !!!Need help urgently !!!
    so after that part, I have to make a function that returns a list of total distances between each of the cities in the cities list (a list of pair-lists) and I have to have it so the function calculates the total distances between each city and all the other cities. The index of the results list should correspond to the index in the cities list so that index i in the results list represents the total distance between cities[i] and all the other cities....
    See more | Go to post

    Leave a comment:


  • jcl43
    replied to Beginner Python-er !!!Need help urgently !!!
    This function is suppose to generate a list of cities with random cooridnates but also making sure that they are not too close to each other
    but now when i run it, it doesn't give me an error(only if i use generate_cities (-10,10,-10,10,10,10) but if i switch the numbers say to -30 or something it gives me this error :

    >>> generate_cities (-10,30,-10,10,10,10)
    Traceback (most recent call last):
    File "<pyshell#6 >",...
    See more | Go to post

    Leave a comment:


  • jcl43
    started a topic Beginner Python-er !!!Need help urgently !!!

    Beginner Python-er !!!Need help urgently !!!

    Ok...so I have this psedecode that I want to follow but it keeps giving me an error so I'm not sure where I went wrong.

    Here is the psedecode:
    Code:
    repeat n times	
             generate random coordinates for new_city	
             too_close = True	
             while too_close == True		
                      too_close = False		
                      for each city in the city list so far
    ...
    See more | Go to post
No activity results to display
Show More
Working...