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
2 answers
4k views

Capitalize a sequence of lines entered via console input and print/return

I'm running through the popular python practice exercises located at github: https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises....
Dave's user avatar
  • 753
2 votes
1 answer
102 views

Most efficient way to find spatial order from a list of tuples (Python)

I have a circle-growth algorithm (line-growth with closed links) where new points are added between existing points at each iteration. The linkage information of each point is stored as a tuple in a ...
solub's user avatar
  • 123
3 votes
1 answer
489 views

Filling values for nested dictionaries

I have a text file where any name followed with sequence word is considered a dictionary. The task is to go through the keys and values of a particular dictionary, which is already identified, and see ...
user3777713's user avatar
2 votes
1 answer
9k views

Computing the powerset of a list

I've written the following code for computing the powerset of a list (we consider the list has all distinct elements, although it doesn't really matter). Can this function be further optimized? <...
Hisoka Moroh's user avatar
7 votes
2 answers
716 views

Recursive function and memorization to find minimum operations to transform n to 1

I'm a new, self-taught programmer working on the Google FooBar challenge. I've submitted my answer (code at bottom) and it was accepted, but I'd like suggestions on how to improve my solution. ...
user7875185's user avatar
6 votes
1 answer
482 views

Ackermann function in Python 2.7

I'm relatively new to Python. I just want some constructive feedback on how to improve my code efficiency, style, error handling, etc. In this case, I've programmed the Ackermann function, but it won'...
Plue's user avatar
  • 379
19 votes
5 answers
65k views

Get value from dictionary given a list of nested keys

I would like to get a deeply-nested value, for example {"a":{"b":{"c":"myValue"}} by providing the keys to traverse. I tried chaining together .get() but that didn'...
Martin Burch's user avatar
8 votes
2 answers
2k views

Python traverse a directory recursively and print contact numbers

I am writing a python code to recursively traverse a directory containing only text files and then print the 10 digit Indian phone number and all its variants. I am very new to python and I have ...
Sinscary's user avatar
  • 181
2 votes
2 answers
613 views

Decompress files files in a directory recursively

Currently I'm trying to redo this code to avoid the breaking line because of the 80 characters rule: ...
Amanda Ferrari's user avatar
2 votes
1 answer
2k views

Tower of Hanoi: graphical representation of optimal solution

I wrote a program to show graphically the solution of the problem of the Tower of Hanoi. Here is a video of an example run. The logic of the solving is taken from StackOverflow (see links in ...
Caridorc's user avatar
  • 28k
3 votes
1 answer
8k views

Count digits in a given number using recursion

Here is my code that finds the number of digits in a given integer (either positive or negative). The code works and results in expected output. ...
srk's user avatar
  • 628
5 votes
1 answer
4k views

Calculate the arclength

I am trying to estimate a good approximation for the arclength of the curve \$ y = \sqrt{1-x^2}\$ for \$x \in [0, 1]\$. I did this using a Bezièr curve, and made it so that the area under the two ...
N3buchadnezzar's user avatar
2 votes
1 answer
823 views

Find all distinct subsets that sum to a given number

The function wants to achieve to find all distinct subsets that sum up to an given number. ...
user3613886's user avatar
2 votes
2 answers
232 views

Computing the largest substring starting with a substring

Given a string and a non-empty substring sub, compute recursively the largest substring which starts and ends with sub and return its length. ...
Diba SH's user avatar
  • 101
5 votes
2 answers
2k views

An implementation for the double factorial

I have written this piece of code that implements the double factorial in Python both iteratively and recursively; the code works without problems, but I'm interested in improving my overall ...
james42's user avatar
  • 151

15 30 50 per page