Tagged Questions
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
0
votes
0answers
14 views
Find path from source to destination in tilt maze (part 2)
For a tilt maze general reference, you can refer to for example, this one.
Previous related code review discussion could be referred by this, and my major ideas how to define tilt maze data structure ...
-3
votes
0answers
15 views
Raw_Input help in python. Not defined? [on hold]
I'm making a character customization feature to my unmade "game" and I'm running into some error when I run this:
...
1
vote
1answer
25 views
Python REST API clients
I am working on a project right now, where we need to search different APIs, then clean & persists data to database and finally pushing to Elasticsearch.
The high level code looks like this:
<...
7
votes
2answers
427 views
Making a deck of cards in Python
I want to have a deck of cards that looks like this:
['H1', 'H2', 'H3', 'H4', 'H5', 'H6'...]
For that I wrote the following code:
...
-1
votes
0answers
16 views
Compile time error on 'Day 10: Binary Numbers' at HackerRank [on hold]
I tried to solve the Day 10: Binary Numbers on HackerRank with my poor algorithmic skills. This solution works on my PC:
...
3
votes
3answers
92 views
4
votes
2answers
38 views
Quarto game in Python revisited
A while ago, I posted about advice for refactoring a game of Quarto I had coded before. I got some good advice, and did some revisions in lieu of this.
...
3
votes
1answer
18 views
Email redirection script in python
I am new to python and wrote a email redirect script. It extracts mails from a server and than resend them. I would like to get some feedback:
...
2
votes
2answers
266 views
Optional arguments in a function [on hold]
I'm writing a python script to find restrictionplaces. I was wondering if there is a better way to write the following:
...
0
votes
0answers
8 views
Game where two players take turns picking numbers until a target sum (part 3)
Here is a continued discussion (Game where two players take turns picking numbers until a target sum (part 2)), since it is new code and new topic for discussion, I start a new thread.
Working on the ...
2
votes
2answers
66 views
Get height for tallest possible stack of boxes
This code is meant to compute the height for the tallest stack of boxes out of a given collection of boxes. A box has width, height, and depth dimensions. The height of a stack of boxes is the sum of ...
2
votes
0answers
18 views
Shakesort Python3
Hello I've done the Shakesort Algorithm win O(N²) but doesnt seem that O(N²) is correct because it takes 6-9 steps in the while loop for a list of 4 integers and 4² is 8. ~1975 steps for 80 entries. I'...
0
votes
0answers
31 views
Generate random URL and download HTML from website [on hold]
I'm very new to Python and I wrote the following program as my first program. My code works as intended but it's really really slow and sometimes it gets stuck for multiple minutes. I don't really ...
5
votes
0answers
24 views
Bitex - Cryptocurrency Exchange API Framework for Python
BitEx is a python module I've been working on for a little over 9 months now, as a side project. It was published 6 months ago on GitHub, and as I edge closer to my 1.0 release, I wanted to take the ...
0
votes
0answers
29 views
Extracts features for 5 electrodes
This is part of my code that extracts features (PSD bands) for 5 electrodes. But I have other 14 electrodes from which I want to extract features too. The name of the 5 electrodes used here are C3, C4,...
3
votes
1answer
187 views
Removing duplicate files in a given directory
The following code is a python script that removes duplicate files in a given directory. At first I considered the most basic thing: relying on identical names, but you might have 2 different files ...
2
votes
0answers
17 views
Print Python docstrings when module is executed interactively
I have written a module, which should only be used by means of import, then call the functions as required.
I do not want this module to do anything when ran interactively, other than printing out ...
3
votes
2answers
30 views
Parsing an XML file with elements for keys and values
I'm parsing an XML file that is structured like this:
...
0
votes
0answers
28 views
Find max in-order difference in array
Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j].
If there is no solution possible, return 0.
Example :
A : [3 5 4 2]
Output : 2
for the pair ...
-4
votes
0answers
22 views
How can I save a string as a list so that it can be checked for a certain word?(Find keywords in a string) [on hold]
So I am new to Python, I wanted to know how I can make it so, if I trigger a keyword in the input it will give a set response. For example, if in a sentence the word "puddle" is used, it will trigger ...
-3
votes
0answers
21 views
Converting txt file into csv in python for Analytics [on hold]
I just started to learn data analytics and recommendation system. For the first part of learning, I followed a web-page to build a food recommendation system. The first step is to change the dataset ...
0
votes
0answers
29 views
Find overlaps between lists of axis-aligned rectangles using line sweep
Triggered by Finding overlaps between two lists of axis-aligned rectangles, I tried to code "rectilinear" intersection using line sweep - in python.
I'm not keen on discussing (2D) line sweep in ...
3
votes
1answer
42 views
Unique nucleotide permutations, Python itertools product
I'm searching for all the unique possible permutations of nucleotide given a defined length. By unique, I mean the reverse complement would not be counted.
ACGT
For example, permutations of length ...
3
votes
2answers
55 views
Plotting a 2D iso-probability curve
I have a library function that returns a pair of two numbers like this
def library_function(x0, x1):
return x0**2 + x1**2, 10*x0*x1 + 1
(Actually, it is a ...
2
votes
1answer
30 views
Phonetic Alphabet Trainer
This is a little program I put together to help people learn the phonetic alphabet. Feel free to query the code.
...
6
votes
0answers
42 views
Downloading HTML from random websites
I've never written a single line of Python before this program was made and all my "knowledge" of the syntax is from Enki ( an app ).
I just wanted to download the HTML code from random websites and ...
1
vote
0answers
16 views
Repeat prompt until correctly answered [on hold]
Objective
I want the program to ask the user the same question if they get the answer wrong until they get it right.
Code
...
5
votes
2answers
131 views
Handlers for checkboxes to select various map features
I am developing a plugin for QGIS (a Geographic Information Systems) software which uses Python. I have several functions where each of them is connected to a QCheckbox. So when a checkbox is checked, ...
-4
votes
0answers
26 views
I wrote some apps and want some feedback [on hold]
Currently I am looking for a job as a junior/intern python developer. I've been on 5 interviews and everytime heard that my skills are too low. Could You give me some feedback about my code?
Link to ...
7
votes
3answers
791 views
Project Euler Problem 35: counting circular primes below 1 million
Project Euler Problem 35 asks:
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
How many circular primes are there ...
7
votes
2answers
606 views
To the right, to the left, now rotate
I was working on HackerRank: Circular Array Rotation which is about coming up with an efficient algorithm for array rotations in right-ward manner.
John Watson performs an operation called a right ...
6
votes
2answers
66 views
Generating matrix/image kernel from List
I have another question from same program where is full code, but this question focus only single process/function of that program.
My problem is performance when creating dynamic Image kernel from ...
3
votes
0answers
13 views
Python simulacrum of windows copy window
I wrote a program to copy files with an progress bar that looks similar to Windows built in function. The copy function is run in a separate thread and the tkinter GUI is run in the main thread. This ...
3
votes
0answers
50 views
Monte Carlo simulation to price an Option in Python
In what ways can I make this code more efficient?
I haven't put in comments and descriptions yet. I need to do that.
Ideally, I'd like to make the S, v, r, and K user entered as I did with T. I'm ...
3
votes
2answers
25 views
Largest substring which starts and ends with some substring
This code is meant to find the length of the largest substring within a string that starts and ends with a given non-empty substring. Here are some examples:
...
1
vote
1answer
36 views
Finding all factors of n efficiently
This function generates all factors of an input n.
It begins at the square root of n, and checks numbers down to zero. When a factor x is found, then another factor must be n divided by x.
Also, if ...
1
vote
0answers
36 views
Word comparison in Python
I'm developing a Python script which looks up over a huge-prelexicographically sorted list of different words (such as 33.000) and the goal is to remove those words which have less than two letter ...
6
votes
2answers
57 views
Find a famous writer in a random string
I'm doing a CodeEval challenge, where the object is to find a famous writers name and a year, inside of a random given string.
You have a set of rows with names of famous writers encoded inside. ...
3
votes
2answers
148 views
Transforming a list of two-dimensional coordinates into a flat list of relative changes
I have a little function that parse a nested list of coordinates into a flat list of compressed coordinates. By compressed coordinates, I mean that only the delta (distance) between each coordinates ...
4
votes
2answers
73 views
Justify Text using LaTeX method
I wrote a bit of code that takes a file, justifies the text and writes to another file.
It uses a DP approach to minimise a badness metric, which is the amount of under or overshoot of the line ...
3
votes
1answer
55 views
Find Row Pairs that are never both 1
Given sample_size many arrays of length dim. For each index from 1 to dim, i want to give a list of indices, where no sample ...
3
votes
1answer
39 views
Multiplication Exercise Generator
I'm new to programming in Python, and I am trying to create a multiplication exercise generator. I've got the following code for the solution, but I'm wondering if there is any more elegant solutions ...
4
votes
2answers
68 views
Converting an integer to Greek and Roman numerals
Yesterday I posted a question about converting an integer to it's Roman Numeral equivalent. Apparently you guys liked it and gave me some good advice, so I decided to take all your advice, and go a ...
1
vote
0answers
43 views
Match the maximum consective count of `)` followed by a keyword
I am applying a regular expression to match and keyword that is followed by maximum number of closing parenthesis. Code is done in python using ...
9
votes
2answers
1k views
Rock, Paper, Scissors - Python game
This is my attempt at making a 'rock, paper, scissors' game in python. The game takes the user's input and the computer's random selection and calculates who has won. All feedback appreciated.
...
5
votes
1answer
63 views
Civil status database with Django
I'm beginning with Django and I have a Civil Status project.
I created my first models.py in order to get a Form, but I had some advices in order to normalize my database.
I made this process and I ...
4
votes
0answers
37 views
Elegant way to alter datasets with explicit filters
I would like to write a small helper to filter datasets. Each dataset is a dictionary and some filters I want to apply are common to all the datasets.
That my needs, I wrote this following pattern:
<...
3
votes
1answer
31 views
Get a path between graph nodes using breadth-first search
This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using breadth-first search.
I'm doing this to improve my style ...
12
votes
1answer
143 views
+100
Trie implementation in Python
I have created a trie in Python and am looking for feedback. Specifically, I am looking for feedback on:
If my code is 'pythonic'
If my logic is proper when inserting and retrieving from the trie
I ...
9
votes
2answers
149 views
Decoding grayscale PNG and performing Prewitt operator for edge detection
I'm a hobbyist programmer.
What I try to do here is to read 8-bit grayscale PNG file. Then unfilter it. (That caused a headache). And after that perform Prewitt operator for "edge detection". I know ...