Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.
6
votes
2answers
128 views
Factoring Polynomials Completely
I am relativly new to Python and I decided to try to write code that would factor any polynomial using the Rational Root Theorem and synthetic division. I have two questions.
Is there any way I can ...
2
votes
2answers
41 views
Project Euler #18: Maximum path sum I
Problem
I want to receive advice on my code, which takes 0.012 seconds.
...
2
votes
2answers
79 views
Roll the die… play again?
Is there a way to write this code more efficiently so that it is easier to read, maybe using loops and lists?
...
3
votes
1answer
87 views
Project Euler #14: Longest Collatz sequence
Problem : source
Which starting number, under one million, produces the longest chain?
n → n/2 (n is even)
n → 3n + 1 (n is odd)
I want to receive advice on my code.
It is too slow... It ...
1
vote
1answer
33 views
Project Euler #12: Highly divisible triangular number
I want to receive advice on my code. It is too slow... The problem I am trying to solve is:
What is the value of the first triangle number to have over five hundred divisors?
...
-5
votes
0answers
12 views
Encryption and Decryption with python…Help I don't get what is wrong [on hold]
Help I don't get what is wrong with my code it doesn't seem to encrypt properly please get back to me asap.
...
2
votes
1answer
32 views
Dead-end filling maze solver in Python
I was reading Wikipedia about maze-algorithms, and I decided to write my own maze-solver. It uses dead-end-filling as it seemed simple to implement (it seemed, I said).
The code I wrote is pretty ...
11
votes
1answer
255 views
Cactus Reborn - A game engine for text-based adventure games
I'm currently working on reincarnation of the Cactus project, Cactus Reborn, and I've gotten the basic implementation so far. At this point, you can create simple, playable games.
There are currently ...
5
votes
1answer
63 views
Notifying if a plane has been found
The object is to notify if a plane was found or not.
The aircraft_identifier variable is a must. cpl_id and ...
0
votes
1answer
33 views
Snake game with graphics and classes [on hold]
I just finished my first PyGame project here (GitHub), and would like to get some reviews on the code.
It's multiple files of code and few images for graphics, so I figured it's easier if I just link ...
3
votes
2answers
190 views
1
vote
1answer
35 views
Tic Tac Toe Player written in Python
I am posting this as a follow up to the Tic Tac Toe class in Python question. I have made extensive changes and rearchitected the code. I now have a board class, a game class, players and an ...
4
votes
1answer
42 views
Words in text counter
This accepts text and returns a list of all words which occur with a required frequency (default frequency is 2). It works well, but gets too slow with large texts, more than 1M words. Where can this ...
22
votes
4answers
4k views
Beheading of knights, who survives?
We have a round table of n knights, where n is some positive
integer. These have failed to satisfy the expectations of the ...
16
votes
4answers
2k views
My first calculator
I've just wrote my first code, which is basically a calculator. Please rate it and suggest improvements (keeping in mind that I'm a beginner).
...
14
votes
2answers
327 views
Simple game of Hangman in Python
I'm starting out with learning how to program in Python and created a Hangman game. I think there is a lot of unnecessary code but I am not sure how to improve it. I wanted to avoid using global ...
9
votes
3answers
406 views
Computing the n-th prime
I've written some Python 3 code that computes the \$n\$-th prime. I implemented first a naive isprime function that looks for divisors of \$m\$ between \$2\$ and \$\lfloor \sqrt m \rfloor+1\$. Then a ...
5
votes
1answer
33 views
Sieve of Eratosthenes in Python 3
Currently, the code will generate a range of natural numbers from 1 to N and store it in a list. Then the program will iterate through that list, marking each multiple of a prime as 0 and storing ...
4
votes
2answers
60 views
Find duplicate files using Python
Most Python "duplicate file finder" scripts I found do a brute-force of calculating the hashes of all files under a directory. So, I wrote my own -- hopefully faster -- script to kind of do things ...
5
votes
1answer
35 views
Dividing valuable items so that two persons get the most similar value possible
You have n items, each one of those has a certain value, represented here as an integer.
How do you give to two persons the most similar value?
No comment from me here as my code already ...
7
votes
1answer
47 views
Function and method debugging decorator - Part 2
This is a follow-up to this question.
I've refactored my previous debugging decorator, and added a couple new features, and changed a few things. Here's a complete list of things that have changed:
...
5
votes
2answers
58 views
Method and class method debugging decorator
A little while ago in The 2nd Monitor, me and @Phrancis were talking about Python and debugging, and the topic of function decorators came up with this message:
Ethan Bierlein: You could even ...
2
votes
2answers
48 views
Simple stream cipher encryption/decryption function
This is a Python implementation of a stream cipher encryption algorithm. This implementation originates from the one displayed on the TI-Basic wikidot cryptography page.
I am well aware that this ...
7
votes
1answer
59 views
Search iteratively in a ternary search tree
I was trying to write an iterative search function for my Ternary Search Tree class based on a pseudo-code, and now it seems to work, but I think it can definitely be improved.
...
2
votes
0answers
74 views
Best team of three programmers
I have the following exercise:
Consider a weighted undirected graph G = (V, E) representing a group of programmers and their affinity for team work, such that ...
4
votes
1answer
32 views
Find a triangle in a graph represented as an adjacency list
I have a graph represented as an adjacency list. I need to find a triangle in this graph. A triangle is a triple of vertices u, ...
3
votes
0answers
51 views
Subset sum whose set contains only positive integers
I was trying to write a dynamic programming algorithm using a bottom up approach that solves the subset sum problem's version where the solution can be either an empty set and the initial set can only ...
5
votes
1answer
54 views
“Lights Off” puzzle in tkinter
I'm a newbie in Tkinter and I've managed to make the "Lights Off" puzzle using Tkinter with Python 3.
The game starts by presenting 9 buttons arranged in a 3x3 matrix. The text of the button will be ...
4
votes
1answer
80 views
Tic-Tac-Toe class written in Python
How well is this Tic Tac Toe code written? Where may I improve it? This is meant to be a platform for a machine learning algorithm.
The code is written so any player may play first. Once a player ...
8
votes
5answers
663 views
Reversing a number
I was working through a programming challenge I found on Reddit and it seemed easy enough:
Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) ...
4
votes
1answer
30 views
Webscraping Bing wallpapers
I wanted to scrape all the wallpapers from the Bing wallpaper gallery. This was for personal use and to learn about webscraping. The gallery progressively gets images using javascript as the user ...
6
votes
2answers
57 views
Encrypter - Double Vigenere Cipher in Python
I wrote this encrypter based on the idea of a Vigenere cipher, but instead of using only one key, it "makes" another key from the existing key. The length of the second key also depends on the ...
9
votes
5answers
1k views
4
votes
2answers
59 views
Dataset and frequency list generation by looping over files
I have been told that it would be wise to split up my code into semantically useful blocks. I tried the following but I need feedback.
What I already did:
As you can see I create two .csv files, so ...
8
votes
2answers
92 views
'Mini Twitter' in Python 3
I've written a 'Mini Twitter' (that's what I've called it) in Python. It includes a text-based login screen and user panel where you can create Tweets, and change your username and password.
Users' ...
4
votes
2answers
150 views
Generating frequency tables based on CSV dataset
I am working on a project which crunches plain text files (.lst).
The name of the file names (fileName) are important because ...
3
votes
0answers
39 views
Simple backup script in Python
Since rsync lacks compression and I'm not a big fan of rdiff, I thought I'd try my own little backup script. Since I'm very ...
5
votes
1answer
117 views
Simple hotel reservation system
This is a reservations software for hotel and restaurant management, allowing you to add and delete rooms, show available rooms, keep track of reservations etc. I am looking to trim my code a bit and ...
4
votes
1answer
42 views
GUID to hex-string and back
I'm new to Python and I'm trying to convert between Microsoft GUIDs and plain hex strings:
...
8
votes
2answers
175 views
Parsing a list of single numbers and number ranges
I have input of a string containing a single number (like: \$3\$) or a range (like: \$1-5\$). Sample input, all together, looks like: "1-5,3,15-16", and sample ...
4
votes
1answer
67 views
Project Euler 91 (via HackerRank): Right triangles with integer coordinates
This is my code to solve HackerRank's version of Project Euler Problem 91: on an N × N grid, find the number of possible right triangles where one vertex is (0, 0) and the other two vertices are ...
8
votes
3answers
668 views
Computer guesses the user's number
After the feedback for my last script, I realized I should be using functions and trying to adhere to the style guide. I tried to do that here, though still very beginner.
The rounding in Python ...
4
votes
1answer
122 views
Binary search implementation [closed]
Is there a better way to implement a binary search than I am in my code? My function is taking two two lists - first_booth_voters and ...
2
votes
0answers
28 views
Elo Rating Tracking Applet
I have a little applet that I wrote in Python and Tkinter, and I was wondering what a good way would be to make it public, or open source or whatever.
I think it's quite fun. You can add players, ...
1
vote
2answers
84 views
Army strength based on level and modifiers
Right so I was doing a quick project, and sought a quick way to finish one section of my Python code. I handed it in, but I'm well aware that it's bad code, but I was wondering if there was a good way ...
3
votes
1answer
41 views
Implement selection from array by 'random' or 'if/elif conditionals'
I'm working on some code examples in 'Automate the boring stuff in python...' to prepare for my first year of CS. I want to know if its better to use an array with random selection below or rather ...
7
votes
1answer
61 views
Small text-based RPG (v2)
This is my first text-based game I made. It's very small because I just learned Python and wanted to start small, and then code bigger programs. I added some stuff since the last time. Please give ...
5
votes
3answers
137 views
Small text-based RPG
This is my first text-based game I made. It's very small because I just learned Python and wanted to start small and then code bigger programs. Please comment on this.
...
8
votes
2answers
1k views
Guess a random number between 1 and 100
I want some recommendations or something I could add to the game. Please tell me what I could do better or what I did wrong. I made this during the time I learned Python.
...
8
votes
2answers
1k views
Text based fight game
I learned code about a week ago and I wanna hear some recommendations and stuff I could add to my code. This is a fight system I made for my text based game. Please tell me what I could do better.
...