Tagged Questions
4
votes
1answer
85 views
Optimizing python code for big data sets
I'm trying to optimize a python string that works on big data sets, the way it works is by taking in a with a list of keywords and scores and taking in a file loaded with data from the twitter api. ...
3
votes
1answer
72 views
Project Euler 407: Is there any more optimal way to solve this idempotent equation (modulo n ring)?
Project Euler problem 407:
If we calculate a2 mod 6 for 0 ≤ a ≤ 5 we get: 0, 1, 4, 3, 4, 1.
The largest value of a such that a2 mod 6 = a is 4.
Let's call M(n) the largest value of a < n ...
4
votes
2answers
174 views
How can I memoize or otherwise optimize this code?
The code checks many more conditions like the one below. I was thinking to memoize it, but I can't think about how (writers block). How else could I optimize this? I know it seems silly, but my code ...
1
vote
1answer
38 views
Improve file-path finding method
I am using a recursive algorithm to find all of the file-paths in a given directory: it returns a dictionary like this: {'Tkinter.py': 'C:\Python27\Lib\lib-tk\Tkinter.py', ...}.
I am using this in a ...
5
votes
2answers
149 views
Help refactoring my tic tac toe game
I'm very new to coding and have been diving into the skill with Python as my first language. One of the first programs I wrote for a class was this Tic Tac Toe game. I re-wrote this game using classes ...
2
votes
1answer
27 views
Eliminate for loops in numpy implementation
I have the following dataset in numpy
indices | real data (X) |targets (y)
| |
0 0 | 43.25 665.32 ... |2.4 } 1st block
0 0 | 11.234 |-4.5 }
0 ...
-2
votes
2answers
152 views
Any way to change optimize this or/and change to recursion?
Number can be very big.Script is taking number as a "number" list and crossing from 10-decimal based system to n-based system until list equals "5".I don't use letters like in 16-base ...
2
votes
2answers
204 views
How do I make this program run less unnecessary loops?
I am currently trying to teach myself some programming. I have started to work with Python by doing this challenge. When I test run it works out fine, however when I run this code with longer strings ...
2
votes
1answer
60 views
Iterative Collatz with memoization
I'm trying to write efficient code for calculating the chain-length of each number.
For example, 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1.
It took 13 iterations ...
0
votes
1answer
61 views
Progressbar in Python
i wish to improve my Progressbar in Python
from __future__ import division
import sys
import time
class Progress(object):
def __init__(self, maxval):
self._seen = 0.0
self._pct = ...
0
votes
3answers
104 views
How to optimize this simple Python program?
Here is a simple piece of code in Python. It is a solution to the SPOJ's JPESEL problem. Basically the problem was to calculate cross product of 2 vectors modulo 10. If there is a positive remainder, ...
1
vote
1answer
99 views
Hangman in Python
I created this version of Hangman in Python 3, anyone got any tips for optimization or improvement?
import random
HANGMAN = (
'''
-------+''',
'''
+
|
|
|
|
...
3
votes
1answer
148 views
Improve efficiency for finding word frequency in text
Premise: Write a program that counts the frequencies of each word in a text, and
output each word with its count and line numbers where it appears. We
define a word as a contiguous sequence of ...
2
votes
1answer
36 views
How can I speed up this correlation function Python
I am writing a specialized version of the cross correlation function as used in neuroscience. The function below is supposed to take a time series data and ask how many of its values fall in specified ...
0
votes
0answers
33 views
Merge all text files in a directory and save a temp file. Suggestion to improve my code
i coded this function where you read all text file in a directory and you save in a temporary file all values. The text files are x,y, and z format. The function returns the name of the temporary ...