Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

Filter by
Sorted by
Tagged with
4
votes
2answers
316 views

Comparison of Fibonacci (Multinacci) Functions in Python3

After coming up with a formula on this Stack Overflow question, defeating recursion limits and finding a few new ways of calculating these numbers (as per this Stack Overflow question), I decided that ...
2
votes
0answers
2k views

Encrypt texts, with saved password using pycrypto

I have the code bellow, which is supposed to be used inside a larger program. Please see notes about the requirements below the code. ...
3
votes
2answers
156 views

Using a base class but defining a property

I have designed a Python TreeNodeBase class, so all tree nodes I implement can inherit from this. However, due to the laziness inherent in a lot of trees, I would ...
6
votes
2answers
956 views

Abstract card game code in Python3

I've written up some generic code for a card-game and would like to hear any and all suggestions for how to improve this code further, in any way shape or form. The code is on github or pasted ...
5
votes
3answers
69 views

Faster way to group email-date pairs by date without many nested for loops?

Given list of pairs (email-date): ...
6
votes
3answers
2k views

Efficiency of Project Euler problem 35

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, ...
1
vote
2answers
137 views

Speeding up prime factorization

I have written the following code for returning the list of prime factors. Any speed-enhancing suggestions? ...
9
votes
1answer
15k views

Generating random email addresses [closed]

The code below generates only 10 email domains. To me, this is bruteforce programming. Is there another random integer library? Could I use something like ...
8
votes
2answers
8k views

Efficiently matching IP addresses with a list of CIDRs

I am using Python3 to extract some information from a dictionary that contains 10k of CIDRs, but the running time is pretty long. Here is my purpose: I have a dictionary of CIDRs (10000) and a list ...
11
votes
2answers
18k views

Split large file into smaller files

I recently suggested this method for emulating the Unix utility split in Python. Is there a more elegant way of doing it? Assume that the file chunks are too large to be held in memory. Assume that ...
9
votes
1answer
441 views

Multiple dispatch decorator classes in Python

This is based on my first review and the suggested points in "Multiple dispatch decorator in Python": ...
1
vote
1answer
86 views

Hints to make Sudoku solver more Pythonic (II)

I tried to implement as many changes suggested as possible as well as expanding the code base according to the suggested link. The original question can be found here. It does solve 4x4 and 9x9 ...
5
votes
1answer
911 views

Hints to make Sudoku solver more Pythonic

As you will see, I am not very familiar with Python and NumPy but want to learn it. The following code is a very basic Sudoku solver which works fine for simple examples. Although it runs, I still ...
12
votes
1answer
1k views

Multiple dispatch decorator in Python

I've written a decorator for easily creating multiple dispatch functions: ...
7
votes
1answer
152 views

Sorted unidirectional list with add, delete and find

I am aware of the fact that a sorted unidirectional list has only very few use cases, but nevertheless, this python code feels fairly long for Python code. How can I improve it? ...
4
votes
2answers
4k views

Connect 4 game for AI agents

This Connect 4 game will be used for implementing game-playing AI. Sample players are supplied. One takes user input, and the other plays randomly. Right now it's set for a human player to play ...
5
votes
2answers
2k views

Minimum number of letters removed, to make a string Peragram

Here is the link to the problem Peragrams. Peragrams: If a word is an anagram of at least one palindrome, we call it a Peragram. Problem: Given a string, find the minimum number of letters ...
2
votes
3answers
98 views

Large number to many characters

My goal is to take any size number, and convert it to a string of smaller characters that represent the concatenation of the binary expansion of the number. To illustrate what I am talking about, here ...
4
votes
1answer
246 views

Script for saving top wallpapers from wallbase.cc into a directory

I am newish to Python and I am looking for some extra eyes on a script I wrote. I wrote this script to learn more about web-scraping and using requests and Beautiful Soup. I use it to connect to the ...
5
votes
1answer
145 views

Personal Project for managing Bookmarks - View Part

The code is the view part of my bookmarker - project for managing bookmarks by categories. It uses Python 3.4/Django 1.6. I have also included models.py for ...
2
votes
2answers
5k views

The efficiency of looping over nested dictionaries in Python

How to make the following code more efficient? ...
6
votes
2answers
3k views

Paint cost calculator

This is the task I was given after completing my program. I don't have a clue what procedures and functions are to be honest. Therefore I have no clue on how to break down my program into different ...
6
votes
3answers
198 views

Spin-the-bottle-like game, follow-up

I've posted this some time ago. Here is the new version that I made based on all the comments that were made. Another look would be much appreciated, especially on: Getting rid of the ...
5
votes
3answers
12k views

Simple Python maze game

The program is running fine but I was just wondering whether there was anything I could do to make it more user friendly or efficient. ...
7
votes
1answer
229 views

Tapes, Trees, Trunks & Tallies

I've written these two command-line tools to be used to facilitate forestry surveys. For a little background, the idea here is that often a landowner needs to know precisely how much wood is coming ...
2
votes
1answer
330 views

Making a list from user input - follow-up

I have made the changes that people have suggested from my previous question. I want to try and make it even tidier if possible. What can I change to make it more optimized? My ...
4
votes
1answer
5k views

Making a list from user input

I have wrote a program that lets the user open up their text file that would look something like this: 1 2 3 4 5 6 It would then let the user enter a name for ...
24
votes
2answers
989 views

Spin-the-bottle-like game

I've started coding about 3 weeks ago, just for fun and maybe practical uses later. My GF dared me to make a PGM that would replace this dice game where you roll two dice, one with body parts and one ...
7
votes
2answers
2k views

Social Media Hashtag Splitting

I decided to try out Python (3.x) two or so weeks ago, and this is my first real script using it. The program I've written below is slow, clunky, inefficient, inaccurate, and probably poorly coded! ...
0
votes
1answer
1k views

Is this Pygame projectile code efficient?

Just wanted a few opinions on whether this game's code is efficient, from looking at it, it does look a bit all over the place but I just don't know how to 'tidy' it up to say so. Would love to hear ...
6
votes
3answers
2k views

Calculating the point of intersection of two parabolas

I recently wrote a function to calculate the intersection point(s) of two parabolas. Working it out on paper was a nightmare, but I eventually did it (I think it's correct), and ended up with: \$ x ...
4
votes
1answer
2k views

Python script to find large folders

I wrote this script a few days ago to find all files which were taking up over a certain threshold of memory on the hard drive. A hard drive on one of my computers had just 6 GB left, so I needed to ...
7
votes
3answers
4k views

Python implementation of the Ramer-Douglas-Peucker Algorithm

I recently implemented the RDP polygon approximation algorithm in Python and I'm skeptical of whether or not I implemented it correctly of with the greatest efficiency. The algorithm runs in around 0....
3
votes
2answers
590 views

Python Barcode Generator v2

This is a complete rewrite of the code posted for review in this question. The question is identical. ...
2
votes
3answers
191 views

How can I optimize this hash string function?

I'm writing a function which gets two strings and a number k as an input, and outputs a string with length k which is present in ...
5
votes
2answers
6k views

Class Vector with Python 3

Here is a class vector in python 3, for n-dimmensional vectors. Please suggest ways to improve the code as well as fix bugs and errors. The only rule is not using: numpy, sympy, scipy and so on. Only ...
2
votes
3answers
2k views

Python Barcode Generator

I was asked to provide some example code for a job interview and didn't have anything to offer, so I wrote the following function. A barcode generator may seem a bit basic, but there's some logic ...
17
votes
2answers
19k views

Python Back-Up Script

I wrote this script to backup some important files. It backs up the files to a local folder as well as to an external hard drive. It creates a new subdirectory which has its name constructed with ...
3
votes
1answer
7k views

ISBN Number Check

I’ve recently coded a way of checking a 10-digit ISBN. I was wondering if the code works to check the numbers, and if there are any flaws in my code. ...
3
votes
3answers
6k views

Generating a random string of characters and symbols

After coding this, I was wondering if there are any ways in which I can improve upon it. It generates a random string of characters and symbols the same length as what is entered by the user. It uses ...
9
votes
2answers
19k views

Measuring Execution Times

I was wondering which time.time() of from datetime import timedelta was the quickest and best way to find how long a programme ...
5
votes
1answer
66 views

Does this code actually give a valid representation of how quick a system is?

So I wrote this code a while ago as a way of seeing how many times it could compute a simple sum in a second (one tick). I was wondering if this gives me valid results or is in fact giving me bogus ...
7
votes
4answers
791 views

Are there any bugs or ways to make my divisor code better?

After coding my divisor code which I did as a practice for my GCSE stuff which I have to take soon, I have decided to ask the community if there are any bugs or ways I can improve my code. ...
41
votes
3answers
2k views

We'll be counting stars

Lately, I've been, I've been losing sleep Dreaming about the things that we could be But baby, I've been, I've been praying hard, Said, no more counting dollars We'll be counting stars, yeah we'll be ...
3
votes
1answer
354 views
5
votes
2answers
101 views

Geometry table for use in regexes

I have been teaching myself Python 3. I watched a video on YouTube entitled "stop writing classes". The Gtable class doesn't even have an init function, so I can't help but wonder if I should have ...
3
votes
1answer
833 views

Write and control Perlin noise for 1D

I'm reading this tutorial and it's the first time I try something this new. Here is my attempt: ...
5
votes
2answers
4k views

ASN.1 BER Encoding and Decoding

I have a project (ldaplib) I am working on that needs to do ASN1-BER decoding and encoding. The function I have for the decoding portion is slightly more complex but neither are all that complicated. ...
6
votes
1answer
2k views

Segment tree in Python3

I've implemented a Segment Tree in Python3: ...
6
votes
1answer
70 views

Determining the least-accurately known physical constants

So, I thought I'd do this using scipy.constants: ...