Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.
2
votes
2answers
27 views
Collatz Conjecture in Python
The Collatz's Conjecture states that any number can either be halved (if it is even) or multiplied by three and added one to (if it is odd) and eventually reach 1.
I was wondering if there was a more ...
0
votes
0answers
13 views
6
votes
2answers
181 views
Command-line-based capacitance decoding
I am an amateur programmer and have just written a simple Capacitor Identifier mostly to practice. I have not had many people review my coding and thought this would be a good time to start. It is ...
0
votes
0answers
35 views
Longest increasing subsequence and common substring
I wrote a program that computes longest increasing subsequences and common substrings.
Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a ...
6
votes
2answers
82 views
Caesar cipher with GUI
I have created a functional Caesar cipher in Python 3 and I have implemented a GUI using Tkinter.
...
4
votes
1answer
46 views
Kindergarten Garden challenge: ugly zip-group-flatten?
I wrote up a solution for the "Kindergarten Garden" problem on exercism.io.
My class will be handed a string that describes two rows of plants. Each student (either in a pre-set list or given as ...
1
vote
2answers
68 views
Code to generate a dictionary from two lists
I created a script to perform a union on 2 lists: keys and words. I needed to create a dictionary from them. If there are more keys than words, missing words are replaced with "None". Any excess words ...
5
votes
1answer
91 views
Transpose a large matrix in Python3
I want to transpose this matrix input:
1.000 2.00 3.0 4.00
5.00 6.000 7.00000 8.0000000
9.0 10.0 11.0 12.00000
And get this output:
...
7
votes
2answers
84 views
List files in a directory
I have folder1 that contains other folders (which may contain other folders etc). This process stops at some point where a folder contains only files, and some of ...
1
vote
1answer
55 views
Simple backup script
I haven't done much Python in the past, so I was wondering if you could look over my code and make sure everything is up to snuff?
I know programs that do this exist already, but I am having a ...
1
vote
2answers
34 views
Code for showing installed python packages/modules
Any comments about style (especially any "non-pythonic" code), performance, readability, etc would be much appreciated! I've tested this on CentOS and OSX 10.9. Works for Python 2.7 and 3.
...
3
votes
0answers
45 views
Python API for TreeStructInfo - new simple config format
I've created a simple (300 SLOC) API for a new configuration format (I'm not the author of it). Unfortunately, the specification is only in Polish at the moment, but you can see how it looks here.
...
2
votes
2answers
55 views
Tracking current during iteration
I have a list of posts. I need to generate it each one by one. For generation of each post, I need to know about other posts. However, I want to make the current post marked.
...
4
votes
1answer
89 views
Static blog generator
I want yet another review on my static blog generator script for improvements.
...
7
votes
2answers
110 views
Espresso Queue simulation
I was asked to do a technical test with the following specification, but my solution was rejected and I was not selected for the available position (Junior to "normal" level, with 4 days of time to ...
4
votes
1answer
61 views
Madlibs Program
I just started to learn Python, and wrote this Madlib program that works the way I intended it to, so I do not need help debugging, just some advice on tips to improve the code or make it simpler.
...
1
vote
2answers
43 views
Number of maximal PAIRS-values
I had an interview question like this:
In a company there are different people. One can measure how well they
suits for pair coding as follows:
First, let us compute the PAIRS-value which ...
4
votes
2answers
71 views
Python List Continuation with multiple lambdas applied
I'm attempting to apply multiple filters and maps to a list and attempted to refactor into something i believe is more readable. In my code, I am reading a file to create a list of terms, then munging ...
5
votes
3answers
212 views
Caesar cipher exercise
I was doing this exercise from here. I made a solution work but can't help feel it could have been done in fewer lines. I'm quite new to python so I'm not too sure of the little shortcuts.
...
2
votes
2answers
219 views
HackerRank “Manasa and Stones” in Python
Problem Statement:
Manasa is out on a hike with friends. She finds a trail of stones with numbers on them. She starts following the trail and notices that two consecutive stones have a difference ...
5
votes
2answers
364 views
HackerRank “Service Lane” in Python
Problem statement:
Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any ...
2
votes
2answers
117 views
Project Euler 81 (minimum path sum through a matrix)
Problem Statement:
In the 5 by 5 matrix below,
131 673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331
...
4
votes
2answers
89 views
Readable way to print a list of things in Python
I am trying to solve the common "print a character after every item in a list, except the last one" problem.
I do not want to use list indices. There are a couple of simple ways to do this in Python, ...
4
votes
1answer
60 views
Pathname matching and listing program
This Python 3 program outputs a list of all pathnames in the filesystem
that match a list of rules taken from a file. You can add and remove
sets of pathnames.
The original purpose was to generate ...
3
votes
2answers
84 views
Numbers to Strings in Python part 2
After implementing most of the suggestions from the first question, This is the code I got:
...
4
votes
2answers
116 views
Numbers to English Strings in Python3
Inspired by the recent surge of questions dealing with changing numbers to their English equivalents (See here, here, and here), I decided to write my own version in Python.
...
4
votes
1answer
61 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 ...
1
vote
0answers
102 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.
...
2
votes
0answers
61 views
Python using a base class but defining a property
I have designed a python tree node base class, so all tree nodes I implement can inherit from this. However, due to the laziness inherent in a lot of trees, I would like some fields to be properties ...
6
votes
2answers
172 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
52 views
Faster way to group email-date pairs by date without many nested for loops?
Given list of pairs (email-date):
...
2
votes
3answers
421 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, ...
1
vote
1answer
49 views
Speeding up prime factorization
I have written the following code for returning the list of prime factors. Any speed-enhancing suggestions?
...
6
votes
1answer
735 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 ...
5
votes
1answer
87 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 ...
8
votes
1answer
141 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?
EDIT: Assume that the file chunks are too large to be held in memory. Assume ...
5
votes
1answer
82 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
47 views
Hints to make Sukoku 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 Sudokus gives ...
5
votes
1answer
393 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 ...
7
votes
1answer
163 views
Multiple dispatch decorator in Python
I've written a decorator for easily creating multiple dispatch functions:
...
6
votes
1answer
50 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?
...
3
votes
2answers
152 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 ...
3
votes
1answer
147 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 ...
1
vote
3answers
73 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 ...
3
votes
1answer
183 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 ...
4
votes
0answers
58 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 reference.
The code does the following
...
1
vote
2answers
434 views
The efficiency of looping over nested dictionaries in Python
How to make the following code more efficient?
...
3
votes
2answers
189 views
How to organize a paint cost calculator using functions?
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 ...
4
votes
3answers
133 views
Second try at a Python game
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 and TIPs would be much appreciated, especially on:
Getting rid of the ...
1
vote
3answers
170 views
How could I make my simple Python maze game better?
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. Please note that I have only been programming for a couple of ...