Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
63 views

Optimizing code for this function that filters a JSON file

I made a function that turns all child from a JSON file to parents (or brothers?). It adds the parent name to the key, so there are no duplicates. It works ok, but I would like to ask if there are ...
Albert's user avatar
  • 31
4 votes
2 answers
409 views

Prioritise injured cats for treatment (dictionary/map search optimization Python and C++)

I am once again attempting another CP problem, and I have ONCE AGAIN run into an optimization issue because of the time limit of one second: https://open.kattis.com/problems/doctorkattis It is common ...
CoderTang's user avatar
  • 141
3 votes
1 answer
2k views

Better way of comparing two lists of dictionaries and display unique changes

Can I get a review of my code which compares 2 dictionaries and display unique changes. ...
Samuel Traxler's user avatar
10 votes
2 answers
8k views

Efficient renaming of dict keys from another dict's values - Python

I have a dictionary in Python (uglyDict) that has some really un-cool key names. I would like to rename them based on values from another dictionary (...
Noah Broyles's user avatar
3 votes
2 answers
582 views

Handle missing children nodes when parsing XML into a dictionary

I work on a code-base that uses xml to set up problems and specify model parameters. I've created a script that I run in tandem with our code. This script will ...
dylanjm's user avatar
  • 245
2 votes
2 answers
206 views

Finding unique keys

I made the following snippet. It finds unique keys based on their values. For all keys \$s\$ that are contained in another key \$D\$ with the same value, key \$s\$ is discarded and key \$D\$ is ...
Victor Adeyemo's user avatar
7 votes
1 answer
1k views

Merging two dictionaries together whilst adding keys but multiplying values

I have two dictionaries and a merged dictionary: dict1 = {-3: 0.3, -2: 0.1, 1: 0.8} dict2 = {0: 0.3, 1: 0.5, -1: 0.7} dict_merged = {} I have code that basically ...
gjdpm1's user avatar
  • 73
1 vote
1 answer
70 views

Iterating lists and updating dictionary for corresponding match logic improvement

I have two lists: Users - [<UserObject1>, <UserObject2>, ...] Contributions - [...
ParthS007's user avatar
  • 207
9 votes
2 answers
4k views

Better way to iterate through a dictionary and comparing its keys with itself

I have a dictionary with author names as keys and values of None. I want to use fuzzywuzzy ...
Trevor Allen's user avatar
-1 votes
1 answer
64 views

Comparing dictionary values from list [closed]

I'm writing some Python code that will handle huge datasets. On a small scale, this snippet works fine, but as the datasets become bigger it grinds my script to a halt (I know it is this part as I ...
Jessica Chambers's user avatar
1 vote
2 answers
201 views

Bi Directional Dictionary

I wrote a class that extends the dict class to provide indexing like functionality, so I can find which key(s) map to a given value in the dict. It's pretty bare ...
Tobi Alafin's user avatar
  • 1,792
9 votes
3 answers
1k views

Creating an affinity-matrix between protein and RNA sequences

I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues: ...
KaPy3141's user avatar
  • 263
2 votes
1 answer
167 views

Comparing web-scraped data from several sports betting APIs

I have written a python script that requests information from several Sports Betting API's, processes and standardises the results into a dictionary, Matches items between dictionaries and then ...
Jordan's user avatar
  • 21
1 vote
1 answer
52 views

tablename alias in attribute name

I have dataframe like this: ...
elisa's user avatar
  • 185
11 votes
3 answers
2k views

Find the common ancestor between two nodes of a tree

Here is my code in Python for to find a common ancestor between two nodes in a particular tree. This is a question from Cracking the Coding Interview that I decided to implement on my own. No one has ...
SDG's user avatar
  • 213

15 30 50 per page