Skip to main content

Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

29 votes
4 answers
8k views

I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
Igglyboo's user avatar
  • 447
84 votes
4 answers
22k views

The following function works well to print out a help message for the program I have written. It prints a multi-line string message that describes the command line usage with some examples: ...
noisy's user avatar
  • 1,001
18 votes
1 answer
7k views

When writing Code Review answers, it becomes often necessary to measure how long the modified code takes vs how long the OP's code takes. I needed a nice way to visualize this as a function of the ...
Graipher's user avatar
  • 41.9k
60 votes
9 answers
14k views

I'd like suggestions for optimizing this brute force solution to problem 1. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to ...
Robert S Ciaccio's user avatar
27 votes
1 answer
51k views

I wrote a simple Python snake game which is about 250 lines of code. Can someone give me some advice on how I can refactor/make it better? game.py ...
Ryan's user avatar
  • 721
11 votes
1 answer
4k views

I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings. ...
SohamC's user avatar
  • 221
2 votes
1 answer
156 views

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 2 of 3, CLI: Newspaper Bill ...
eccentricOrange's user avatar
19 votes
2 answers
1k views

Password generators are extremely popular on CodeReview with beginners to both coding in general and Python in particular, for a number of reasons: They're (seemingly) easy to implement They offer an ...
15 votes
4 answers
407 views

(See the newer version here: CodeReview question markdown downloader) As an adjunct to From new Q to compiler in 30 seconds, I've created a Python script to automatically download the markdown from ...
Edward's user avatar
  • 67.5k
14 votes
1 answer
9k views

I'm trying to solve 15 puzzle using A* algorithm, but something really bad goes on in my get_solution() function that ruins performance. I guess there is a too much ...
Tikhon Belousko's user avatar
7 votes
2 answers
4k views

This was a very fun and thought provoking problem, and I'm quite proud of the way I was able to pull it off. I broke it down into 2 parts, testing and comparing. Testing each group of cards for a ...
blitzmann's user avatar
  • 173
7 votes
3 answers
3k views

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, ...
yask's user avatar
  • 245
6 votes
3 answers
694 views

This question used to contain a mistake in the code, so I had to debug and reformat it. This is the correct version. Why I made it A friend and I wanted to make a lightweight browser, since our ...
Chip01's user avatar
  • 900
15 votes
1 answer
4k views

Over the weekend I was curious about efficiently merging multiple sorted iterators together, and for them to be in sorted order. This is quite like a challenge on HackerRank: You’re given the ...
Peilonrayz's user avatar
  • 44.8k
15 votes
2 answers
7k views

I have written some simple code for evaluating expressions. However, I am not sure how well I am following conventions (this is my first time trying to). Specs for problem: All binary operators (+, -,...
internet_user's user avatar

15 30 50 per page
1
2 3 4 5
87