All Questions
95 questions
14
votes
4
answers
3k
views
Shell Sort, Insertion Sort, Bubble Sort, Selection Sort Algorithms (Python)
There is a follow-up question available:
shell-sort-insertion-sort-bubble-sort-selection-sort-algorithms-python.
Selection Sort
The selection sort algorithm sorts a list (array) by finding the ...
14
votes
3
answers
7k
views
Maze solver and generator in Python
After watching Computerphile's video I decided to create my own maze solver and generator in Python. I've never written anything in Python so I'd like to get some feedback about my code, specifically ...
12
votes
3
answers
3k
views
A simple encryption program using Python
I made this encryption program in Python.
I don't have much experience (or any experience at all) about encryption (since I just gave my 9th grade finals), but I had this idea about an algorithm some ...
12
votes
3
answers
658
views
Becoming the greatest tower builder
I am trying to learn how to write proper code in python, and stumbled upon the following problem.
Bob is given a set of building blocks b, and a number ...
11
votes
3
answers
2k
views
Producing and comparing maximum sub array sum algorithms
This is an exercise in implementing the maximum sub-array sum problem.
It asks for several solutions of complexity:
\$O(n)\$
\$O(n \log n)\$
\$O(n^2)\$
\$O(n^3)\$
For an additional challenge I ...
10
votes
9
answers
3k
views
Beginner FizzBuzz in Python
This is my first attempt at solving Fizzbuzz. I've always been pretty weak at algorithms, so I'm trying to improve. Specific feedback on performance would be appreciated.
...
9
votes
2
answers
619
views
Justify text from a file using a LaTeX method
I wrote a bit of code that takes a file, justifies the text and writes to another file.
It uses a DP approach to minimise a badness metric, which is the amount of undershoot of the line length, cubed ...
8
votes
4
answers
2k
views
Implementing Sieve of Eratosthenes faster
I wrote a version of Sieve of Eratosthenes:
...
8
votes
5
answers
19k
views
Merge Sort Algorithm in Python
I'm implementing basic sorting algorithms to learn them, and coding, better. Criticisms and possible optimizations welcome.
...
8
votes
2
answers
1k
views
Selection Sort Algorithm (Python)
Selection Sort
The selection sort algorithm sorts a list by finding the minimum
element from the right unsorted part of the list and putting it at the
left sorted part of the list. The algorithm ...
8
votes
1
answer
5k
views
Genetic Algorithm in Python
I'm a new programmer, so any help is welcome. Preferably to make it faster, avoid heavy memory usage, and so on.
...
8
votes
4
answers
526
views
Finding factorials
How can this script be optimized?
...
7
votes
2
answers
3k
views
Magic Square (Python)
Problem
Write a method to return a boolean if an input grid is magic square.
A magic square is a \$NxN\$ square grid (where N is the number of cells on each side) filled with distinct positive ...
7
votes
2
answers
913
views
Counting Fermat witnesses and liars
We were asked to implement a program that calculates the number of Fermat witnesses and liars for odd numbers greater 1. This involves Fermat’s little theorem.
Fermat’s little is used to identify ...
7
votes
2
answers
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! ...