Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.
1
vote
0answers
34 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 ...
-2
votes
0answers
14 views
Calculating average using a loop [on hold]
For my homework I need to create a program that calculates a students average for 3 tests, and the total average of the class. I have to do this by using a single user input to gather their names, and ...
-3
votes
0answers
28 views
optimize python3 code in competitive programming [on hold]
the following codes from python3 and C++ do the same job
...
7
votes
2answers
384 views
Tic Tic Tic Tac Tac Tac Toe Toe Toe
I created a Tic_Tac_Toe class to play the game Tic Tac Toe.
Is there a better way of coding a game like this? I started learning python 5 days ago and my knowledge ...
2
votes
0answers
38 views
Compute the box covering on a graph using CPython
Edit:
My initial idea was to use numpy to solve efficiently this problem but after trying without results, someone comment on stackoverflow:
"Numpy can speed things up a lot IF your problem is ...
2
votes
2answers
53 views
Project Euler #85: Find the rectangular grid with closest to 2M rectangles
For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 85. We talked through different approaches and came ...
4
votes
2answers
84 views
Project Euler problem 79: deducing a passcode
For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 79. We talked through different approaches and came ...
-2
votes
0answers
20 views
How to count the number of times a word appears in a txt file but not including the possessive form of the word? [closed]
I am just starting to learn how to program in Python for my intro to programming class.
The assignment is to prompt the user for a search word and then search the file, Text_File.txt for the search ...
3
votes
2answers
40 views
Beeping Alarm Function
I'm trying to create an alarm function with Python3. The below code does work but it doesn't seem like this is the most optimal way of achieving something like this. Is there a more pythonic way?
...
5
votes
2answers
51 views
Mandelbrot Set Fractal
I thought I would give this months community challenge a try. This is my first time using Python.
It does take quite a while to run and it's not very colourful but it works.
...
7
votes
3answers
265 views
Shrinking and expanding square
I'm a computer science student who's just starting out with algorithms and their implementation. I wrote this code for a dynamically morphing square. I was wondering if I could get a review on it. I ...
3
votes
2answers
43 views
Caesar Encryption Tool
I'm newbie in Python and I wrote a tool called Caesar Encryption Tool. At the moment it only encrypts. It takes a plain text and a key from the user then encrypts the plain text using the key. How can ...
4
votes
2answers
52 views
Strand Sort in Python
After reading about Strand Sort on Wikipedia and testing the provided Python version, I decided to try my hand at a faster implementation. I've studied the "Time Complexity" page, read many different ...
6
votes
3answers
91 views
Simple interpreter for a golfing language
This is the seconds version of an interpreter yesterday. It's supposed to be used for code golf, but it currently can't do much.
...
2
votes
3answers
46 views
App for a tabletop RP that generates hits and misses for weapons
I'm looking for tips on cleaning this up. I think it's legible, but it sure ain't pretty. In particular, I'd love to clean up the hitCheck function. I've dealt with ...
2
votes
2answers
34 views
Member function to turn class into dict
I'm working on a project where I often want to turn class instances into dictionaries to write them to MongoDB. I'd like some feedback on the following:
...
2
votes
1answer
48 views
Very simple interpreter
I created a very simple interpreter in Python. It's capable of doing basic math (unfortunately with only two numbers), creating quines and printing text.
...
-1
votes
0answers
50 views
Returning the range of a number as a palindrome [migrated]
I like to do programming challenges in my free time to teach myself and keep fresh, this one I can't seem to optimize though and it's driving me insane.
The goal is essentially, "Given a number, ...
2
votes
1answer
51 views
Implementing a Trie in Python - follow-up
This is a follow-up of Wikipedia Trie pseudocode in Python
Code quality improvements
find has been fixed and a regression test ("bana" vs "banana") has been ...
1
vote
4answers
104 views
Generating arithmetic quiz questions
I have created a quiz in Python that will generate a series of 10 questions to test the basic arithmetic skills of primary school children. To do this, I have used a while loop and random functions to ...
2
votes
0answers
48 views
A web crawler for scraping images from stock photo websites
I created a web crawler that uses beautiful soup to crawl images from a website and scrape them to a database. in order to use it you have to create a class that inherits from Crawler and implements 4 ...
6
votes
2answers
145 views
Rock Paper Scissors game in Python
I'm new to programming and I'm trying to teach myself Python through some online books.
One of the exercises has me making a Rock Paper Scissors game. The one I have written works well enough I ...
6
votes
2answers
63 views
Parsing mathematical expressions in Reverse Polish Notation
I've wanted to make a calculator for a long time now, so I wrote one of my first parsers, where the input is in reverse polish notation, \$1 \ 1 +\$ becomes \$2\$.
It supports to following operators; ...
5
votes
2answers
58 views
Wikipedia Trie pseudocode in Python
I translated the Wikipedia pseudo-code into Python code (little changes only were required), but I do not like the end result, as it looks like C with all those while loops and counters.
The fact is ...
3
votes
1answer
49 views
Web crawlers for three image sites
I'm very new to python and only vaguely remember OOP from doing some Java a few years ago so I don't know what the best way to do this is.
I've build a bunch of classes that represent a crawler that ...
2
votes
1answer
51 views
TCP server with user accounts, connection threading, and groups/permissions
This is a TCP server I am currently working on. It is accessed through telnet (I know it isn't secure, its just a project for uni). The server is programmed in Python 3.
I am currently trying to ...
3
votes
1answer
34 views
“ACM ICPC Team” challenge
I'm attempting this question on HackerRank, which states the follows:
You are given a list of \$N\$ people who are attending ACM-ICPC World
Finals. Each of them are either well versed in a topic ...
5
votes
2answers
270 views
FizzBuzz for CodeEval
I'm a beginner programmer and decided to try some coding challenges. I found CodeEval and attempted the first challenge, FizzBuzz. However upon submitting my code I found that my submission only ...
5
votes
1answer
62 views
Simple Python + Gtk.Window
I'm learning Python and Gtk so I decided to write a simple application that will take some image let user annotate with a pen and send results through email or save to a file.
So far I have the ...
7
votes
2answers
67 views
Strict types decorator (works only with Python 3.5)
I wrote a decorator which makes Python 3.5 raise exceptions if the arguments that are passed to a type-hinted function are of the wrong type.
...
7
votes
2answers
147 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 ...
3
votes
2answers
51 views
Project Euler #18: Maximum path sum I
Problem
I want to receive advice on my code, which takes 0.012 seconds.
...
1
vote
2answers
97 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
94 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
36 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?
...
2
votes
1answer
43 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 ...
12
votes
1answer
306 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
68 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 ...
3
votes
2answers
207 views
2
votes
1answer
67 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 ...
4
votes
1answer
43 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 ...
26
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 ...
17
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
340 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 ...
10
votes
3answers
419 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
40 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
76 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
37 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
48 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
62 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 ...