Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
0
votes
0answers
3 views
Locating a sequence in a sorted array
I read the following question : Searching an element in a sorted array and I thought that I could give it a try in python.
Given a sorted list of integers and an integer. Return the (index) bounds of ...
0
votes
0answers
8 views
Text representation for numbers with python
Simple function which returns a text representation for numbers in range [1...1000].
...
-4
votes
0answers
15 views
Python program to calculate total miles per gallon [on hold]
I'm trying to write a program for an entry level Python class that will (using a while loop) get input from the user for miles driven and gallons used for multiple tankfuls. It's supposed to calculate ...
1
vote
0answers
9 views
Finding the date from “2nd Friday of X month”-style input
I've been working through some puzzles from exercism.io. Current puzzle asks me to return a date() from input that essentially says "The 3rd Friday of December" or ...
5
votes
0answers
32 views
Fastest possible Cython for Black-Scholes algorithm
I started with a pure python implementation, and have been trying to get the performance as close to native C as possible using numpy, numexpr, and cython. Here is the the numpy version that I ...
1
vote
1answer
23 views
Python TCP echo server
The below code is a simple TCP echo server. The folks using it claim "it is going down evey now and again". Any thoughts on how this could be improved would be really appreciated, particularly if they ...
5
votes
1answer
33 views
Solver for a number-game (8-queens applied to Sudoku)
Since I while ago I've been addicted to a number-game that you can think of as a binary Sudoku. The game is called (in Italian) Alberi (trees) and I haven't found any equivalent when searching the ...
2
votes
0answers
17 views
Platform to buy services, where you can receive notifications
I am developing a website, where people can buy services, also it has a notification system; I do this in views to show log in and sign up, on index.html.
views.py
...
1
vote
2answers
39 views
Scrapy spider for products on a site
I recently submitted a code sample for a web scraping project and was rejected without feedback as to what they didn't like. The prompt, while I cannot give it here verbatim, basically stated that I ...
-2
votes
1answer
24 views
Python Simple Math While Loop [on hold]
Write a program in Python that defines a function that takes a single argument, a positive integer (you can assume all integers entered will be positive, you do not need to check). The function ...
1
vote
2answers
249 views
Binary tree data structure
I am learning about the binary tree data structure and implemented some basic functionality.
It was working great with module level functions until I realized that I need to keep track of the root ...
2
votes
2answers
44 views
Simple text game
I am new to coding and am working through Learn Python The Hard Way. I wrote a simple text game as instructed. The logic appears to be sound. I played through it and didn't run into any dead ends. ...
4
votes
1answer
32 views
Simple Game Of Life with infinite size
I decided to try make a version of the Game Of Life that'd be infinitely big. The idea was to store a dictionary of each Y value, which contain a set of X values (for fast lookup), as opposed to ...
2
votes
1answer
23 views
Extract data from large JSON and find frequency of contiguous sub lists
I have been writing some code (see component parts here and here) that:
Takes a very large JSON (15GB gzipped, ~10million records)
Extracts the relevant parts of the JSON into a list of lists
...
2
votes
3answers
67 views
Condense my Cipher?
I need some help condensing my Caesar Cipher (encryption and decryption).
Encryption
...
4
votes
2answers
91 views
Password Keeper/Generator
Is there anything I should add or change? Is it easy to follow? How could I shorten it?
How can I improve the overall program to make it a program you would use on a regular basis?
...
4
votes
0answers
27 views
Pygame version of my 3D Tic Tac Toe/Connect 4
I posted a question a while back asking for some feedback on the code of a game I made (it was limited to typing the input and drawing the output in ASCII).
Now I've got it linked up with pygamef. ...
1
vote
1answer
40 views
Map all symbols in module to dictionary
The div and add functions are located randomly in my package structure. I have a function with this signature:
...
-1
votes
0answers
15 views
Flask, Python, MySQL - Query with parameters works locally on dev but not on the production server [on hold]
This issue has stumped me.
Locally I'm using Anaconda and running python 2.7. I serve my Flask app using run.py but connect to my actual database (hosted by dreamhost.com) even in the "dev" ...
4
votes
1answer
28 views
Slicing time spans into calendar months
I have apparently correct code that still runs for weeks on my data (tens of millions of rows). I show the entire code for reference (and maybe other gains to be made), but the key operation is in the ...
3
votes
2answers
37 views
Getting a hash string for a very large file
After reading about large files and memory problems, I'm suspecting that my code below may be inefficient because it reads the entire files into memory before applying the hash algorithm. Is there a ...
4
votes
2answers
57 views
Assembling very large files
I have users uploading files sometimes as large as 100+ GB to a local web server. The upload process works well and chunks come in at 50MB. The problem seems to be after the file is uploaded, when ...
-4
votes
0answers
29 views
Python Rock, Paper, Scissors. Struggling Newb [on hold]
Struggling Python Newb here. Simple RPS game. Struggling to get it working. Im sure theres alot wrong. Any help would be appreciated. Kinda lost and overwhelmed. The menu loads but then it throws up ...
3
votes
1answer
49 views
Alternating Direction Method of Multipliers
This is a python implementation of the Alternating Direction Method of Multipliers - a method of constrained optimisation that is used widely in statistics (http://stanford.edu/~boyd/admm.html).
...
-2
votes
0answers
17 views
Creating lingo game using python [on hold]
have to create this lingo game using python. Here are the requirements
In a game of Lingo, there is a hidden word, five characters long. The object of the game is to
find this word by guessing, and ...
5
votes
2answers
332 views
C++ equivalent of Python's deque with maxlen - sliding window
In Python it is really easy to get sliding window functionality using a deque with maxlen:
...
1
vote
2answers
41 views
Scraping and using JSON data from thousands of files in a directory
I have a few thousand json files containing order histories sitting in a directory from one of our systems. Since customers can opt in to receive marketing I'm opening each json file and then ...
2
votes
2answers
47 views
Iterate over large amount of words in Python
I wrote a program that should check a dictionary that contains about 50000 other dictionaries. In those dictionaries, one of the keys has a list of words as value. Now, I iterate over those words, ...
2
votes
3answers
46 views
Search dictionary by value
I have a dictionary which I use to lookup my binary and ASCII values (from A - P). It works, but my ascii2bin function just doesn't really feel right (and ...
4
votes
1answer
19 views
DuckyScript precompiler for Arduino Leonardo
I've made a python program to convert DuckyScript code to Arduino code for Leonardo boards. Below you can find both the project files and a sample script.
...
4
votes
4answers
224 views
Merge two list and discarding duplicates
I am trying to implement a function that merges two ordered lists into a third (ordered) one, but duplicates have to be discarded (basically the last step of a mergesort).
I think that this code can ...
2
votes
2answers
61 views
Mnenomic Password Generator
I have this code that creates unique passwords using the first letter of each word from the file. Before each password is created (written to a file) it is compared to all passwords that are currently ...
2
votes
2answers
63 views
IRC logging bot
I've recently been learning Python and decided to write an IRC bot as a good first project. Before now I've only really written scripts.
I am using the Python IRC library.
The IRC bot joins an IRC ...
2
votes
3answers
168 views
Remove repetitive strings from a given sentence efficiently
I recently gave a test on HackerRank:
Given a string, return the most concise string that can be formed from it.
For example:
...
2
votes
3answers
60 views
Creating a tuple from a CSV file
I have written code that reads in a CSV file and creates a tuple from all the items in a group. The group ID is in column 1 of the table and the item name is in column 2. The actual datafile is ~500M ...
5
votes
1answer
58 views
Printing a staircase of text
So basically, a user is prompted to input a number of stairs and a staircase when a guy on it is generated. I know this is sloppy and my variable names are rough, I'm actively working to change them ...
5
votes
2answers
48 views
Simplified DES encryption
This is one of my first Python scripts and I was wondering if it meets the correct conventions. Also are there things that you would write different? I am looking for some good comments so I can start ...
3
votes
1answer
46 views
Finding most common contiguous sub-lists in an array of lists
Objective: Given a set of sequences ( eg: step1->step2->step3, step1->step3->step5) ) arranged in an array of lists, count the number of times every contiguous sub-lists occur
Where I need your help:
...
4
votes
2answers
137 views
Simple data entry form that writes data to textfile
I made a data entry form that writes each category into a text file. As an example I used Regular, Premium and Diesel categories. They each have open, delivery, total, sales and close numbers for that ...
1
vote
1answer
116 views
Binary tree from given Inorder and Preorder traversal
Below is code which builds a Binary Tree from given Inorder and Preorder lists.
...
0
votes
0answers
7 views
Pyton List Frequency [migrated]
I have to figure out how to print a frequency set. So far this is my code, but it keeps skipping the fist number in the list. I assume thats because I have previous starting at data[0] but I don't ...
2
votes
3answers
76 views
List comprehension method
I have developed some Python code which revolves around two custom classes - a 'Library' class (Lib) which contains a Python list of several objects based on a 'Cas' class. I've not posted the code ...
3
votes
1answer
35 views
Application to test my own website security
I made a simple application to test your own website security for DDoSes in Python. Any suggestion is welcome.
...
-4
votes
0answers
11 views
Scikit-Learn - Getting NAN value while measuring accuracy [closed]
I am classifying positive and negative sentiment on sample data. I used the following code snippet.
Everything looks OK until line 20 where it print expected predictions.
But when i try to measure ...
2
votes
1answer
79 views
Inversion count via divide and conquer
I'm happy to hear thoughts and ideas on structure/performance/testing/whatever and multi-threading, which I haven't gotten into yet with Python.
Full code here. Assignment file and a test file ...
5
votes
2answers
77 views
Knuth–Morris–Pratt string match algorithm
The Knuth–Morris–Pratt string search algorithm is described in the paper Fast Pattern Matching in Strings (SIAM J. Computing vol. 6 no. 2, June 1977). The initial step of the algorithm is to compute ...
-1
votes
0answers
15 views
python RPG battle in renpy [closed]
I have like two versions of how can this can go, one is with class another is using text buttons to deal damage. the main problem with these two codes are that i cant make the button work. defining ...
1
vote
1answer
58 views
Find the kth prime and all the primes below it
It works by finding 2n+1 with n from 1 to k, but not where 2n+1 would be divisible by one of the already known primes. I'd like to know if the program can find every prime, and if so, how it compares ...
5
votes
1answer
50 views
Project Euler no. 17: Counting letters to write the numbers from 1 to 1000
I'm very new to programming and am admittedly embarrassed sharing my code for critique. This code works and produces the correct answer to the Project Euler Problem 17, which asks how many letters ...
4
votes
2answers
45 views
m3u file collector
I'm new to Python and wrote this code for collecting all files in an m3u (playlist) file and copying them into a directory.
...