Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

-3
votes
0answers
14 views

Testing if the arc between two (lat,lon) seapoints, intersect landmass [on hold]

I have the following problem: I have a bunch of points (latitude,longitude) that I know are located in the mediterranean sea. I have to check if the great circle path among each pair intersect the ...
1
vote
1answer
22 views

Another Python prime-listing algorithm

I wrote a small program in Python that finds primes (how original) up to some limit. I tried to produce very clean code, so I'd be vary grateful if you could point out any improvement I could do to ...
1
vote
1answer
26 views

TLE in APS - Amazing Prime Sequence in Python at Spoj

This series is similar to Fibonacci Series defined as : a[0] = a[1] = 0 and For n > 1, a[n] = a[n - 1] + f(n), where f(n) is ...
2
votes
1answer
19 views

Dynamic Official Receipt increment algorithm

I made a function that would automatically generate official receipt for POS. it is able to accept format such as xxx, xxx-xxx, xx-xx. But my code is really messy and horrible and it needs review. I ...
3
votes
1answer
28 views

Power flow analysis using the PSS/E simulation tool

The intro is a bit long, but I think it's necessary. I'm very interested in any improvements, but you can assume that all calls starting with psspy. are correct and ...
3
votes
1answer
28 views

Permutation index Python

Here is my Python code for finding the permutation index of a given digits and a target number. And by permutation index I mean, for example, given digits ...
5
votes
1answer
20 views

Testing file IO errors in python

Below is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling. There is also a ...
4
votes
3answers
53 views

Time Limit Exceeded for ETF - Euler Totient Function at Spoj

In number theory, the totient φ of a positive integer n is defined to be the number of positive integers less than or equal to n that are coprime to n. Given an integer n (1 ≤ n ≤ 106), compute the ...
5
votes
1answer
38 views

Showing virus scan results from an API and a CSV file

I am utilizing an API module for interacting with virustotal.com in order to get AntiVirus results based of SHA256 hashes. The code I have is working but I feel like it can be improved greatly. I ...
2
votes
2answers
32 views

Capturing the positions of “start” and “end” markers in a multi-line string

Is there any better (and shorter) way to get index of a regex match in Python? ...
-2
votes
0answers
20 views

Python icmp tools [on hold]

I am developing ICMP tools package with Python. Currently I've implemented IPv4 ping using raw sockets. The current roadmap is: icmp traceroute Simultaneous ping ICMPv6 Documentation Tests https:/...
4
votes
0answers
43 views

Two versions of Sudoku

I have written two versions of a sudoku solver. Both can solve 9x9 sudoku boards in <200 ms. One of the implementations uses numpy. I am looking for feedback on both, but particularly on why my ...
3
votes
1answer
20 views

Django Create Profile Example

this is my first post here so I apologize if this already exists as I haven't gotten acclimated to the nuances of this website yet. I was creating a view with Django that would create a user profile ...
2
votes
2answers
84 views

Find if a part of the integer from another integer is divisible by 7?

The question states: Given an integer A, and two indices Li, Ri. Find if the number from A which is bounded by the two indices is divisible by 7? For example if A = 357753 indices Li = 3, ...
1
vote
2answers
52 views

Google Foobar Challenge: Spy Snippets in Python [on hold]

I am getting all the answers correct. But still the solution is not accepted as only 4/5 tests cases are passed. I have not posted the whole problem statement but the problem is similar to this. I ...
3
votes
1answer
31 views

Emulating super() in Python 3.x using Python 2.7

Depending on the name of the first argument, self.__sup or cls.__sup behaves like super() in ...
1
vote
0answers
42 views

Moving a div inside p by to the body element

I get malformed HTML input with divs inside other HTML elements like the ...
7
votes
1answer
39 views

Steganography with AES encryption

I created a small program that hides arbitrary files in png images using steganography - it encodes the files in the two least significant bits of every channel, so using a 4-channel png we can encode ...
5
votes
0answers
36 views

Recursive vs non-recursive file/folder copy functions with optional replacement

Would someone else reading my code wish it wasn't recursive? I'm writing a function to report file and folder copy errors. For now exceptions are being printed but they will be eventually sent to a ...
1
vote
1answer
16 views

Extract specified field value from filename using positional indexing

I have some filenames, and they each have data contained in them at specific locations in the string. I want a function that returns the value of the data specified by ...
6
votes
2answers
40 views

Todo-list practice code accepts title and list

I am new to OOP principles and best practices. People often say I write "unpythonic code," so give me your perspective on how to do things better. ...
2
votes
1answer
25 views

Stack implementation in Python 3

I'm learning Python by implementing commonly used data structures. My primary language is Java, thus would like to know if I'm being Pythonic enough. Any means to better up will be appreciated. ...
0
votes
1answer
33 views

Singly Linked List implementation in Python

I'm new to Python and thus learning it by implementing a set of commonly used data structures. Here's my implementation of a LinkedList. First the Node class. ...
3
votes
2answers
70 views

“Hangman” game in Python

I have been using Python 3 to learn programming, and this is a very basic task, but I want to gain good programming patterns/habits at the very beginning. ...
-5
votes
0answers
19 views

Python Treap implementation [closed]

I know there are probably many problems with this (since I haven't tested it yet), but I'd appreciate any advice (stylistic hints as well). ...
9
votes
1answer
420 views

Palindrome-inize a number

For example if I start with the number 146. I first reverse it, so it becomes 641. Then I add this to the original number to ...
5
votes
1answer
64 views

Apriori algorithm in Python 2

This takes in a dataset, the minimum support and the minimum confidence values as its options, and returns the association rules. I'm looking for pointers towards better optimization, documentation ...
-4
votes
0answers
18 views

Python3: Continuous variable update within Mainframe [closed]

Basically, I have created a thread which continuously writes a global variable in an infinite loop. Then I have the mainframe which should read and display that variable. The problem is that once the ...
-3
votes
1answer
21 views

Inner function accessing variables directly from outer function scope - What are the drawbacks? [closed]

I saw this snippet in a code that I am working on. And I feel that accessing the outer function variable directly in the inner function brings some undesirable magic. For e.g. when I read the function,...
-1
votes
0answers
27 views

Explode list of lists to separate lists in Python [closed]

I currently have a list of lists like L = [['E2', 'C1', 'A1', 'B1', 'C2'], ['C1', 'D1', 'A1'], ['C1', 'C2']] My aim is to compare L[i] against L[i+1] to make sets. ...
6
votes
0answers
65 views
+50

Similarity research : K-Nearest Neighbour(KNN) using a linear regression to determine the weights

I have a set of houses with categorical and numerical data. Later I will have a new house and my goal will be to find the 20 closest houses. The code is working fine, and the result are not so bad but ...
9
votes
2answers
80 views

Simon memory game

I have recently started to learn Python and I have decided to apply what I have learnt so far to creating a Simon Memory Game clone. I am now looking for help with improving the code. Any help with ...
2
votes
1answer
52 views

Simple Python script to sort and make json data unique

I'm retrieving e-mails from a collection of a few hundred *.json files using the following: Python Script ...
4
votes
1answer
55 views

Generate dictionary of points on n-sphere

This is a long-shot, but my question is to simply optimize this particular function in some code I have written: ...
1
vote
1answer
41 views

Entity resolution with NLTK

I am trying to write a script of Python code, for entity extraction and resolution. The excerpts of the algorithm: It is trying to extract the entity as PoS Tag with Hidden Markov Model(HMM). After ...
2
votes
0answers
27 views

Using pandas.io.pytables.TableIterator for several iterations

I'm writing method that takes a pandas iterator and then computes something based on that. The problem is that some of these computations require iterating twice over the data. For example the ...
-1
votes
2answers
59 views

Partially complete text-based adventure game [closed]

I have run the code and it's error free. As this is partial code which only defines one class of the many more to come, there is no output involved yet, therefore I am looking for testing whether the ...
-2
votes
0answers
13 views

My pandas parellelization is not working, please advise [migrated]

I have written the below code to parallelize my pandas script, but it seems to be not working, can you advise what went wrong. To give an idea My code is taking data from the data frame grouped by "...
7
votes
2answers
66 views

20+ functions for generating different waveforms

I added a guard clause to the functions in scipy.signal.windows, but the way they are currently written means the same 11 lines are now repeated in every function. ...
5
votes
5answers
71 views

Get a list of indexes for list A based on criteria in list B in Python

I have one list of data with duplicate IDs and a second list of data with attributes for the IDs. ...
3
votes
1answer
48 views

Base64 encoder and decoder

I'd like to have some feedback on this small snippet I wrote to implement a base64 encoder and decoder. Specifically, I'm not sure I'm handling padding in the best way possible. ...
5
votes
2answers
50 views

Finding longest common prefix

I have been trying to solve a modification of the Longest Common Prefix problem. It is defined below. Defining substring For a string P with characters P1, P2,…, Pq, let us denote by P[i, j] ...
6
votes
2answers
406 views

Beginning Python guessing game

I am new to Python (and coding in general) and after about a week of reading "Thinking Like a Computer Scientist: Learning with Python" I decided to try and build a version the classic "guessing game"....
9
votes
2answers
450 views

Break a full name into a dictionary of its parts

It seems like I'm repeating myself here. Is there a standard way to deal with code like this? ...
3
votes
2answers
921 views

Morse Code Conversion

Challenge Write a program which reads a file containing Morse Code and outputs the conversion. Specifications The first argument is a path to a file. The file contains multiple lines. Each line ...
0
votes
0answers
28 views

Number extraction from specific pattern lines in file and finding their average [closed]

Here I have a text file saved in computer containing multiple lines which I open. ...
4
votes
1answer
70 views

Extracting time duration in the session from 30 million rows

I am looking for making my code faster. I am working on yoochoose recsys 2015 dataset.. and trying to perform some transformations.. [recsys2015], it has got 30 million plus rows of data. The goal of ...
0
votes
1answer
37 views

Image-processing filters using decorator pattern in Python 3

The goal of the following short Python 3 program is to improve my understanding of the decorator design pattern. Therefore, I would be mostly interested about feedback on this aspect, i.e. whether ...
2
votes
1answer
65 views

Finds all the prime numbers up to n using a strange pattern

Here's an odd pattern I found for sieving out composite numbers to find primes. I wrote it myself, originally thinking I made an indexing error, but it turned out to work after removing squares. <...