All Questions
1,206 questions
5
votes
3
answers
1k
views
Project Euler Problem #1: Multiples of 3 or 5
Project Euler Problem #1
Multiples of 3 or 5 states:
If we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of ...
5
votes
2
answers
84
views
Calculate distance score for local alignments (ex. Gotoh local)
Is there a better way to calculate distance scores for local alignment than this? Or is the method that I'm currently using robust enough? The full code is here with the actual alignment ...
7
votes
3
answers
549
views
Team picker command line application
I've made a program for randomly splitting game participants into different teams. The code works and solves the problem. I'm interested in advice on what you'd do differently or better.
...
7
votes
2
answers
528
views
Subtracting the sum of the current digits from a positive integer N until it reaches 0
Given a positive integer N, subtract the sum of its digits and count how many times this operation must be applied to make N become 0.
...
3
votes
1
answer
104
views
backward induction algorithm computation
Is there a way to significantly speed-up this code?
I'm solving a dynamic programming model using a backward induction algorithm. A crucial step is to calculate the current-period value function (VF), ...
2
votes
0
answers
147
views
How to make this arbitrary precision π calculator using Machin-like formula run faster?
Two days ago (or yesterday depending on your timezone) was π-day. So I thought it was a good day to calculate π.
I used Machin-like formula to calculate π, in homage of William Shanks, who calculated ...
7
votes
4
answers
506
views
Traversal Heap Sort (No Extractions)
I developed a heap sort variant that sorts a heap through traversal. Unlike in the standard heap sort, the algorithm does not remove the min element from the heap instead it traverses all the nodes of ...
5
votes
3
answers
1k
views
Coding exercise to represent an integer as words using python
Context:
Convert a non-negative integer num to its English words representation.
Example 1:
Input: num = 123
Output: "One Hundred Twenty Three"
Example 2:
Input: num = 12345
Output: "...
2
votes
1
answer
96
views
Check which sinks are connected in the pipe system using Python
It would be very helpful to me as a beginner if I could get feedback on my code, specifically about the efficiency of algorithm used and potential improvements in code quality.
Code context:
There is ...
4
votes
1
answer
137
views
Advanced Python Calculator using OOP
I've been into computer science fundamentals (proper data structures/algorithms/etc) including Object Oriented Programming. Therefore, I decided to reformat my old traditional Python Calculator into ...
7
votes
3
answers
772
views
Optimal Algorithm to Append and Access Tree Data
I have been studying intermediate or more advanced data structures in Python, one of which I've decided to try out is the Tree Data Structure. I've been studying the theories as well as the ...
4
votes
1
answer
142
views
Efficient polynomial multiplication in Python
I'm practicing problems for the ICPC competition, and one of the problems requires solving it by using an FFT to compute the product of two polynomials efficiently. Since this is for the ICPC ...
6
votes
3
answers
1k
views
Implementation of Euler-Maruyama numerical solver
I am trying to write a python implementation of Euler-Maruyama and Milstein schemes for numerically solving stochastic differential equations. The pseudo-code for the algorithms is in the Wikipedia ...
3
votes
2
answers
211
views
Find the join of two set partitions
Two partitions of a set have a greatest lower bound (meet) and a least upper bound (join).
See here: Meets and joins in the lattice of partitions (Math SE)
The meet is easy to calculate. I am trying ...
3
votes
1
answer
90
views
Number of partitions of (a,b) into k distinct parts which sum up to (a,b)
Problem set
This is somewhat a generalization of the famous partition of integer n into k parts.
Given two integers ...