All Questions
Tagged with python performance
2,344
questions
8
votes
2
answers
1k
views
Beginner level password generator optimization
I've been learning python for a few days now, and I programmed this password generator after today's lesson (following the 100 days of code on udemy course). This code works like it should and gives ...
5
votes
3
answers
909
views
Optimizing Pi Estimation Code
I'm trying to write a program in Python that estimates pi, but to get a more accurate estimation in a feasible amount of time, I want to make it faster.
I'm using a method that estimates the area of ...
6
votes
8
answers
1k
views
Reversing vowels in a string
Given a string s, reverse only all the vowels in the string and return it.
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper ...
4
votes
1
answer
136
views
5
votes
3
answers
855
views
Project Euler 127 - abc-hits
Problem (Rephrased from here):
The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$.
We shall ...
1
vote
1
answer
269
views
Rules-engine to be improved/simplified for Efficiency (performance), Extensibility and Maintenance?
This is a simple implementation of a rules engine. I am really hating the very long MATCH/CASE function. I am wondering what kind of Design Patterns could be used there to make this code more ...
5
votes
0
answers
83
views
Optimizing SymPy Implementation of prime factorization in form of QUBO
I'm trying to reproduce a paper on Prime Factorization. This paper converts the problem into a QUBO form, which then we can map it to an Ising Minimizer. I've basically done everything and I've ...
3
votes
1
answer
107
views
Benchmark for loop and deque/map/methodcaller
While discussing with some colleagues, one argued that a for loop over a list of objects to call a method is a bad practice because it has bad performance compared ...
3
votes
5
answers
1k
views
How do I speed up this simulation program
This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations.
The differential equation is called ...
8
votes
3
answers
2k
views
Bug Byte puzzle from Jane Street
This is a puzzle from Jane Street.
Given this graph:
Fill in the edge weights in the graph with the numbers 1 through 24, using each number exactly once. Labeled nodes provide some additional ...
2
votes
1
answer
132
views
Multithreaded sparse linear solver in Python
I would like to know if there are any multithreaded sparse linear solvers for LU decomposed sparse matrices.
I want to increase the solving speed of a system like:
...
1
vote
2
answers
71
views
Using odd prime powers, my heuristic tries to solve instances of Exact 3 Cover in polytime, what can be done to optimize it?
By the way, a heuristic is not the same thing as a proven working algorithm that solves all input instances. It could either be experimental or be used to study intricacies in a problem.
The purpose ...
3
votes
1
answer
81
views
Pytorch code running slow for Deep Q learning (Reinforcement Learning)
I'm a new student in reinforcement learning. Below is the code that I wrote for deep Q learning:
...
6
votes
1
answer
329
views
Codeforces: D2. Counting Is Fun (Hard Version)
The code works okay for the following problem.
Problem
An array 𝑏 of 𝑚 non-negative integers is said to be good if all the elements of 𝑏 can be made equal to 0 using the following operation some (...
2
votes
2
answers
142
views
BlackJack in python
I began creating blackjack in python; however, I'm looking to simulate it, so I'm thinking I'm going to need to optimize it so that I don't just leave my computer running for three hours waiting for ...