Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
3
votes
1answer
30 views
1
vote
1answer
32 views
Longest palindromic substring by memoization
I've written some code to solve the longest palindromic substring problem.
...
0
votes
1answer
60 views
Highest floor of a building from which to drop an egg without breaking it [on hold]
You have two eggs, with the lowest number of drops. Find the maximum floor of a 100-floor building from which you can drop the egg without it breaking.
I created a function which takes an ...
2
votes
1answer
24 views
Writing embedded list to CSV in Python
I have a method in a Python app to write a list of records to a CSV file. Each record is a "football player", which is really just a dictionary. But one of the dictionary items contains a list of ...
2
votes
0answers
25 views
Alberi puzzle creator - follow-up
This is a follow-up to this question.
Using his ExactCover class, I slightly modified Garth Rees' Alberi class to cope with ...
3
votes
1answer
42 views
“Day-of-the-week-finder”
I'm new to Python/Programming and wrote this simple "Day of the week/Holiday finder" script. Ideally I'd use something so I can have a little widget on my desktop, but right now I'm looking for any ...
2
votes
1answer
38 views
1
vote
0answers
20 views
Abstracting away implementation details of my rethinkdb Model class
I have a module called db, which looks like this (shortened):
...
3
votes
2answers
60 views
Find first unique char in string
I intentionally avoided Python tools which would make this even more trivial. I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
2
votes
1answer
42 views
Find 3 elements that sum to zero in an int array
Find 3 elements that sum to zero in an int array.. I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
9
votes
3answers
463 views
Push all zeros to tail of int array
My script pushes zeros to end of an int array. I'd like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
4
votes
1answer
33 views
Find an array slice equaling sum
I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
0
votes
1answer
23 views
Applying a formula to 2D numpy arrays row-wise
The user has two 2D input arrays A and B, and a given matrix S. He wants to apply a
...
3
votes
0answers
32 views
Simple Python plugin loader
I have written a simple system to load plugins from files in Python 2.7, and I'd like to see if any of it can be improved upon.
vedo.py
...
2
votes
1answer
27 views
SOAP request in a while loop
I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the ...
1
vote
1answer
31 views
Extracting an arbitrary element from each row of a np.array
I have a large numpy array of shape (n,m). I need to extract one element from each row, and I have another array of shape (n,) that gives the column index of the element I need. The following code ...
2
votes
1answer
39 views
TDD Hackerrank: Library Fines
From this hackerrank:
Problem Statement
The Head Librarian at a library wants you to make a program that
calculates the fine for returning the book after the return date. You
are given ...
4
votes
2answers
34 views
Watch a directory and insert new entries into database - Follow up
This is now my new code implementing the recommendations from my previous question.
...
1
vote
2answers
24 views
Get list of indices from searching for values in list of lists
I have a list of lists of numbers. The numbers are in sequential order, ranging from 0 to n and each number only appears once. I want to loop over all the numbers in the list of lists and return the ...
2
votes
1answer
48 views
Checking for hyperthreading
I want to just write a simple function to check if my linux box has hyperthreading enabled. I want to know if there's a simpler way to produce the cpuinfo dict ...
4
votes
2answers
41 views
Multiplication Grid function
I've made a small function to output a multiplication grid (those things from primary school! :P) to an inputted number.
...
5
votes
3answers
433 views
Project Euler 92: Square digit chains
A number chain is created by continuously adding the square of the
digits in a number to form a new number until it has been seen before.
For example,
44 → 32 → 13 → 10 → 1 → 1
85 ...
-2
votes
0answers
14 views
Removing values from a list [on hold]
For a hobby I am making a quiz on pygame to make it more graphical - looks better than just in the python shell! I have done snippets and when I run it it works, but I need to add extra things in. I ...
1
vote
2answers
27 views
Remove (not extract) timestamp from HTML string
I've got strings coming from irregularly and ugly formatted HTML sites, that contain a timestamp. I am interested in removing the timestamp entirely and get all the rest.
...
-1
votes
0answers
13 views
subprocess.call() giving an non-zero exit status 22 and stopped working suddenly [on hold]
I need to call a perl program with command line arguments using python IDLE (since I am working with python). I tried using subprocess.call() and everything worked fine initially. Suddenly it stopped ...
1
vote
2answers
52 views
Read a txt file and split into 2 csvs based on regex
So I have been told that my code is not good and needs refactoring. I'm struggling to see what I need to do. How do I specify the success and failure conditions for lambda? Also don't get what the ...
1
vote
1answer
46 views
Replacing values in a file based on values in another file
I am writing Python code which reads through two text files and prints the output based on those two files. Basically, the first file, demo.txt, has a matrix of numbers and the second file, days.txt, ...
5
votes
6answers
112 views
__repr__ for a binary tree whose constructor has default arguments
I recently have been working on a BinaryTree class, and looked into creating a proper __repr__ which when eval'ed would recreate ...
-1
votes
0answers
13 views
Hacked together 5Temp Data Logger [on hold]
Attached is my current non working version of a python script I found that started out collecting temps from two sensors, I wanted it to collect from five but I'm clearly not succeeding... I get an ...
1
vote
2answers
43 views
Django search method
I have done this small piece of code used to search for a given word across several fields of a Django model.
Goal was to have first entries equals to the word, then entries starting by the world ...
1
vote
0answers
15 views
Object-oriented URL loading and HTTP client with requests in Python
I have an API which I want to consume in Python 3.x using the requests module.
Right now, my solution is to create Requests objects for each URL like the ...
6
votes
6answers
946 views
Shipping charge based on weight
The program here is simply supposed to tell you the shipping charge based off of the weight of the package. I am just wondering if there is any further way to concise it? At the moment, I do not think ...
1
vote
0answers
23 views
REST service API using Python Bottle
I am working on a sample REST service to study testing related aspects using the Python Bottle framework. I read a lot about REST but I do not have a lot of practical experience designing RESTful APIs ...
3
votes
0answers
37 views
ID3 Decision Tree in python
I've been working my way through Pedro Domingos' machine learning course videos (although the course is not currently active). His first homework assignment starts with coding up a decision tree ...
3
votes
2answers
51 views
Program to retrieve key/message from a multiple times used one time pad
I wrote a program to retrieve the key/messages from 10 different ciphers which were all encrypted with the same key with an xor one-time-pad method via crib dragging.
To do this, I wrote a python ...
3
votes
1answer
33 views
Using Pandas to parse adwords export, Google Analytics
I did this exercise yesterday mostly as practice, but it has some utility as well in day to day. I was basically attempting to take a string that looked like the following:
...
3
votes
1answer
33 views
Serving a growing audio file with Django
I would like to serve a growing audio file (raw PCM audio for now) with the possibility of seeking. I tried to manage it with Apache, but in the end wasn't able to achieve what I wanted.
Now I ...
1
vote
2answers
47 views
Blocking until condition is met
I have a class called _NodeProcess. It consists of a mainloop (main function) which is run in a separate process and methods ...
-1
votes
0answers
51 views
Opening databases connection [closed]
Description:
New to python scripting, I would like to improve my code making it more functional oriented (just refactoring).
Actually I organized the structure of the project like this :
...
-5
votes
1answer
72 views
3
votes
2answers
504 views
Zeros in Factorial
Ram was busy calculating the factorials of some numbers. He saw a
pattern in the number of zeros in the end of the factorial. Let \$n\$ be
the number and \$Z(n)\$ be the number of zeros in ...
0
votes
0answers
17 views
levenshtein distance in python [closed]
I am trying to write a code that will find an levenshtein distance between two words. The way I am approaching is first, clean up the words (get rid of punctuations, empty space, capitalization) then ...
3
votes
2answers
43 views
Watch a directory and insert new entries into database
This program's main function is to:
Watch a directory.
If there are new files, insert those as entries into the database.
Delete the files from the directory.
My below code runs well, but I want ...
5
votes
2answers
53 views
Statistics with Python
Write a program to determine the mean, median, and standard deviation of a list of numbers
Count the duplicate numbers in the code, listing any that occur more than once with the number of times ...
1
vote
3answers
30 views
Convert scalar arguments to arrays, and check that lengths are equal
I've got a Python function that takes two arguments, lat and lon. These arguments can be either scalar values (...
2
votes
2answers
38 views
Count number of matching nodes in a Binary tree
Problem
Count the number of matching nodes in the subtree rooted at some node n.
Solution
...
2
votes
3answers
71 views
Python Tic Tac Toe Game
I made this as a personal challenge. It seems to work fine as I can't find any bugs and am happy with how it runs, but I am interested in what I should do to make the code more professional.
I think ...
3
votes
2answers
37 views
Auto backup Chrome bookmarks
This script, once added to the Windows Scheduler, automatically creates a backup of your Google Chrome bookmarks.
...
1
vote
3answers
117 views
Collision detection algorithm
This is my second algorithm and I will try to make it as simple for you to understand how it works. It is pretty expensive and I'd like to make it more efficient.
.
It works by splitting a square ...
-1
votes
2answers
61 views