Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
0
votes
0answers
25 views
Find Missing Numbers in an int list
I have an alternative algorithm to the same problem as Finding missing items in an int list.
My implementation includes optional min and max bounds to selectively fill in the list.
The linked ...
2
votes
1answer
32 views
3
votes
2answers
313 views
Project Euler #14 solution takes quite a long time
Can anybody give me suggestions for making it faster? (Project Euler #14)
...
1
vote
1answer
32 views
Parse data into three logs
In the bit of code below:
How can I make add_day, add_ week and add_month work as a single ...
4
votes
3answers
30 views
Displaying sorted results of a web crawl
The issue I have with this class is that most of the methods are almost the same. I would like for this code to be more pythonic.
Note: I plan on replacing all the ...
-3
votes
1answer
26 views
Simple betting game in python not working [on hold]
So the problem I am having with this code is that when I run the code, there are no issues, however when it gets to the result of the dice roll, it does not subtract money if the person lost the bet, ...
5
votes
2answers
275 views
Calculating the volume of a tetrahedron
Here's my function for calculating the volume of a tetrahedron. I've tried to comment well, and perform a few checks on the types of the objects passed to it. Can ...
4
votes
1answer
65 views
Speeding up Python date conversion function currently using list comprehension and datetime
I am reading a large data file where the time is given in number of days since some epoch. I am currently converting this to Python's datetime format using this function:
...
0
votes
0answers
19 views
Use of get queryset and using pass to ignore an exception and proceed in my django view
I wrote a view to update my draft object. Before updating my draft I need to see if any draft exists for package(draft.package) in db or not. If any draft is ...
2
votes
2answers
39 views
Python path-breaking script for use in R
R does not support line continuation as Python, and it's disturbing to have long file paths like
/media/user/data/something-not-very-important-but-super-long/some-curious-secret-file.pdf
and ...
4
votes
4answers
571 views
Squaring an integer by repetitive addition
I've written two functions:
is_integer(), which tries to get a positive or a negative integer as input and returns the same value.
...
-1
votes
0answers
39 views
My code won't let me win if I get the correct number [on hold]
I created a simple 'Guess The Number' game, but when I choose the right random number, it says: "You lost!".
...
1
vote
1answer
24 views
Dynamically calculate status in MLM
Problem: dynamically calculate status in MLM only based on a structure.
It works correctly but it's so slow. Only test processing takes about 20 seconds. I tried to replace some lists by generators, ...
-2
votes
2answers
80 views
return inside a loop - is it a good style? [on hold]
Is it a bad style to return inside a loop?
I have the following method
...
2
votes
3answers
120 views
2
votes
1answer
31 views
Fetching and displaying the provisioning status of a phone number
I have the following function:
...
4
votes
2answers
200 views
Trivago hotels price checker
I've decided to write my first project in Python. I would like to hear some opinion from you.
Description of the script:
Generate Trivago URLs for 5 star hotels in specified city.
Scrap these URLs ...
2
votes
2answers
198 views
Math equation generator program
I am building this program in Python to generate 10 random arithmetic questions of either multiplication, addition or subtraction and then saves users scores to a .txt file. I just wanted some help ...
1
vote
1answer
60 views
Faster solution for row-wise matrix subtraction
I have 2 matrices. I have to calculate the euclidean distance between every row of matrix A and every row of matrix B.
In the first solution I loop over the rows of the two matrices and for each row ...
4
votes
2answers
142 views
Python Find All Adjacent Subsets of Set of Coins Which Have a Tails Minority
Given a sequence of heads and tails I want to find how many significant subsequences are in this sequence where the number of heads is not less than the number of tails. I want to achieve this in ...
2
votes
2answers
55 views
Four fours to get any number
I decided to solve a problem from Code Golf called the four fours.
Problem description:
The Four fours puzzle is a popular recreational mathematical puzzle
that involves using exactly four 4s ...
2
votes
1answer
33 views
Books Algorithm Dealing with Square Digit Sums
A little context:
Book has 411 Pages
Read a random number of pages on the first day which is unknown
Number of pages to read next day is the square of the sum of the digits of the page ...
4
votes
1answer
123 views
Python prettyXML and prettyHTML functions
After much searching around the web, I couldn't find a single module which did a decent prettyXML or prettyHTML. Because:
...
-2
votes
0answers
14 views
New project - solenoid valve - guidance [closed]
Using python 3.4.2
I'm starting a new project to take pictures of water drops and ive created a simple interface which can be seen below but id just like some simple guidance to help me in my ...
4
votes
1answer
74 views
Finding the minimum number of required deletions to have a non-repeating string
I wrote code for the following problem:
Given a string, print out the number of deletions required so that the adjacent alphabets are distinct.
Please suggest different methods by which I can ...
-2
votes
0answers
45 views
Code Looping Confusion? [closed]
This is the prompt. I really don't understand how to stimulate the # of Freddy's escapes or how to know what direction he escaped.
Poor ol' Freddie the Wonderdog is lost in a tunnel at NODE 0 (see ...
4
votes
5answers
496 views
Tic-Tac-Toe game in Python
I've decided to use some of my free time to create a simple game in Python. I chose Tic-Tac-Toe, but I decided not to make it too trivial. I made my game support any board size. I would greatly ...
1
vote
1answer
43 views
Iterating and fetching values from dictionary
Here is my dictionary:
c_result1 = {"1": {"time": "89.46%"}, "2": {"date": "10.54%"}}
c_result2 = {"1": {"money": "89.46%"}, "2": {"finance": "10.54%"}}
I want ...
1
vote
2answers
63 views
Book pages algorithm dealing with digit sum and squares [closed]
I would like some help condensing this code to make it more efficient. Could someone also help me output the number of pages she reads instead of the page number she is on...
...
2
votes
1answer
106 views
Loading 40GB twitter JSON TAR file from archive.org and load into PostgreSQL
I wrote the script below to load data obtained from the twitter JSON archive on archive.org into a PostgreSQL database.
I'm looking for optimizations in the code. It currently runs at ~1.7 seconds ...
3
votes
2answers
47 views
Number of files with specific file size ranges
I am trying to write a script that will traverse through my directory and sub directory and list the number of files in a specific size.
For example, 0kb-1kb: 3, 1kb-4kb:4, 4-16KB: 4, 16kb-64-kb:11. ...
4
votes
2answers
50 views
Faster way to perform function calculation in Python?
I'm interested in whether there is a way to further improve a "fast" version of a function used in a homework assignment I received recently (I've already submitted the completed work).
...
2
votes
1answer
26 views
Rule based link processing
Here is piece of code with few if ... else, I appreciate if anyone can clean it.
...
2
votes
3answers
354 views
Program that multiplies numbers over and over
Would appreciate a review on this. The program does work as it is intended to. However I am unsure if there is a more elegant or better way to execute this process with less code.
...
8
votes
1answer
132 views
Python-based Git pre-commit hook to manage multiple users/Git identities
A couple of months ago I posted a bash script to manage multiple Git identities as a solution on Stack Overflow but soon found the hook isn't flexible enough.
Thus I decided to rewrite the hook in ...
6
votes
4answers
110 views
Python 8-Puzzle and solver
I wrote a simple 8-Puzzle and solver and am interested in seeing how it might be improved. Please let me know if any style or design changes might enhance the readability/performance of my code.
...
1
vote
1answer
36 views
Creates an Excel inventory from Cisco Show Version text files
This has been written for network engineers to be able to create an Excel inventory of switch/router device info from a folder of 'Show version' .txt files. I've put it here to help me learn about ...
0
votes
0answers
31 views
Simple k-means implemention using Python3 and Pandas
Is there anything I can improve? The distance function is Pearson correlation.
...
1
vote
1answer
46 views
Managing birthdays with a dictionary [closed]
This program attempts to get a selection from the user, then several functions are executed depending on the process the user requires to do.
I need some advice from any of you on how to make this ...
2
votes
1answer
23 views
Optimizing for data import in Neo4j using py2neo
Here is my code for importing from a .csv to a neo4j graph using py2neo and cypher statements. I've noticed that it slows down significantly the bigger the graph gets. It takes several seconds just to ...
0
votes
1answer
43 views
Linear regression with visualization
I have created a small script that:
Creates a lot of random points.
Runs a small brute force search to find a rect that has a low error, that is a good fit for the data.
Runs a linear regression on ...
3
votes
5answers
146 views
Getting a 4.0 GPA
This is my code, for calculating a GPA for 7 subjects. It works, but is there a better way? Any hints on making it more flexible?
...
4
votes
3answers
270 views
Truth Table Calculator
In of my software engineering classes, I had to write a truth table calculator in the language of my choice. This is what I came up with, and I would like to know what I should do better next time:
...
1
vote
0answers
26 views
Server socket implementation with Python asyncio
I want a socket server implementation with the Python asyncio library. I have this code but I don't know if it's correct. I want to implement SSL, too.
I used code from the documentation example and ...
3
votes
0answers
70 views
Sync Eye Movements with External Events (Python ØMQ ZeroMQ)
This solution was used to synchronize events between two applications: An eye tracking software, python, and a stimulus control software, object free pascal/delphi.
I tried to avoid a rewrite of the ...
1
vote
0answers
31 views
PyQt5 GUI Application
I'd just like this PyQt5 code reviewed. I'm relatively new to classes and GUI programming, and wanted to make sure I wasn't doing anything too bad. If absolutely necessary, I can give you the other ...
5
votes
5answers
583 views
Interactive dice simulator
After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions.
...
2
votes
0answers
42 views
GUI for products and orders
I am building a simple Store Management System and I have 4 classes, 3 of which are for Product, Vendor and ...
1
vote
1answer
47 views
Transposing rows and columns for file contents [closed]
This program transposes rows and columns for file contents:
...
2
votes
1answer
37 views
Ping function in Python
Below is a piece of code which takes a list of IPs, pings the hosts and returns (prints) the list for "Alive" and "Dead". Any feedback on what can be done better is welcomed, mainly, speed and ...