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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:03:32+00:00 2026-06-03T15:03:32+00:00

Please no built-ins besides len() or range(). I’m studying for a final exam. Here’s

  • 0

Please no built-ins besides len() or range(). I’m studying for a final exam.

Here’s an example of what I mean.

def find_numbers(x, lst):


lst = [3, 8, 1, 2, 0, 4, 8, 5]

find_numbers(3, lst) # this should return -> (1, 6, 7)

I tried this not fully….couldn’t figure out the best way of going about it:

def find_K_highest(lst, k):
 newlst = [0] * k
 maxvalue = lst[0]


 for i in range(len(lst)):
    if lst[i] > maxvalue:
        maxvalue = lst[i]
        newlst[0] = i
  • 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-03T15:03:34+00:00Added an answer on June 3, 2026 at 3:03 pm

    I dont know is it good to post a solution, but this seems to work:

    def find_K_highest(lst, k):
        # escape index error
        if k>len(lst):
            k=len(lst)
        # the output array
        idxs = [None]*k
        to_watch = range(len(lst))
        # do it k times
        for i in range(k):
            # guess that max value is at least at idx '0' of to_watch
            to_del=0
            idx = to_watch[to_del]
            max_val = lst[idx]
            # search through the list for bigger value and its index
            for jj in range(len(to_watch)):
                j=to_watch[jj]
                val = lst[j]
                # check that its bigger that previously finded max
                if val > max_val:
                    idx = j
                    max_val = val
                    to_del=jj
                # append it
            idxs[i] = idx
            del to_watch[to_del]
            # return answer
        return idxs
    

    PS I tried to explain every line of code.

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

Sidebar

Related Questions

Please help me with using the DrScheme built-in function filter. create a function hello
Please, suggest the shortest way to convert Dictionary<Key, Value> to Hashset<Value> Is there built-in
I built a simple voting system: votes_controller.rb: class VotesController < ApplicationController def vote_up @post
Please excuse the confusing title ;) We've built an ASP.NET MVC application to replace
Please see this post for code example : How to map Type with Nhibernate
Could anyone please suggest how to test whether WCF with wsHttpBinding you built is
Please help! I'm still learning so this might be completely wrong. I have built
I have built a website(asp.net): http://avior-ins.co.il/ I can view the site on my computer(I
Any one please help me to build a horizontal bar graph in my android
Please help to the newbie in WPF! I need to build a TreeView with

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.