Find Jobs
Hire Freelancers

optimize python algorithm function - find out what elements are added and deleted in second list

$80-240 HKD

Completato
Pubblicato più di 5 anni fa

$80-240 HKD

Pagato al completamento
basically, I need to compare two lists. I need to know what elements are added and deleted. Here is my code but it's running slow. I would like to have "high speed" version function instead of this. import itertools def compareQueues2(prev:list, curr:list): common_max_length = min(len(prev), len(curr)) m1=0 for pi in prev: for ci in curr: if pi == ci: m1+=1 break notfound = True prev_same = [] curr_same = [] common_max_length=min(common_max_length, m1) for n in range(common_max_length, 0, -1): # print(n) if notfound: for p_it in [login to view URL](range(len(prev)), n): # print (p_it) if notfound: for c_it in [login to view URL](range(len(curr)), n): s = sum([prev[p_it[i]] == curr[c_it[i]] for i in range(n)]) if s == n: #print("{} matches {}".format(p_it, c_it)) prev_same = p_it curr_same = c_it notfound = False break deleted = [i for i in range(len(prev)) if i not in prev_same] added = [i for i in range(len(curr)) if i not in curr_same] return prev_same, curr_same, deleted, added --------------------- compareQueues2(['ab', 'will del', 'gh', 'cc'], ['ab', 'gh','added', 'cc']) sample result: ((0, 2, 3), (0, 1, 3), [1], [2])
Rif. progetto: 18624003

Info sul progetto

2 proposte
Progetto a distanza
Attivo 5 anni fa

Hai voglia di guadagnare un po'?

I vantaggi delle offerte su Freelancer

Imposta il tuo budget e le scadenze
Fatti pagare per il lavoro svolto
Delinea la tua proposta
La registrazione e le offerte sui lavori sono gratuite
Assegnato a:
Avatar dell'utente
I have experience with algorithms and data structures using python. We shall discuss the rest of the details on chat.
$95 HKD in 1 giorno
4,9 (4 valutazioni)
2,0
2,0
2 freelance hanno fatto un'offerta media di $168 HKD
Avatar dell'utente
I'm an experienced Python developer and some of my skills are analyzing and optimizing algorithms. For that reason I think I'm the best candidate for this work.
$240 HKD in 0 giorno
3,2 (4 valutazioni)
3,3
3,3

Info sul cliente

Bandiera: HONG KONG
Hong kong, Hong Kong
5,0
5
Metodo di pagamento verificato
Membro dal apr 12, 2018

Verifica del cliente

Grazie! Ti abbiamo inviato tramite email il link per richiedere il tuo bonus gratuito.
Non è stato possibile inviarti l'email. Riprova per piacere.
di utenti registrati di lavori pubblicati
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Caricamento anteprima
Autorizzazione per la geolocalizzazione concessa.
La tua sessione è scaduta ed è stato effettuato il log out. Accedi nuovamente per piacere.