Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 153917

An algorithm is a sequence of well-defined steps that define an abstract solution to a problem. Use this tag when your issue is related to algorithm design.

1 vote
Accepted

Python Combinatory Algorithm - A Binomial Coefficient application with n mutable and k fixed...

You should really only use comments to explain a design choice or a complicated equation/algorithm. Comments like #if the condition is satisfied just clutters your code. …
Linny's user avatar
  • 10.4k
5 votes
3 answers
597 views

Largest number order in string

I'd like feedback mainly on the algorithm, as I wrote this up very quickly. I used comprehension syntax to find the largest num, which I'm trying to use more. …
Linny's user avatar
  • 10.4k
9 votes
Accepted

Optimizing a function to find the closest multiple of 10

The algorithm is: Get remainder of number with modulo by 10 If remainder is less than 5, return number minus remainder Else, return number + (10 - remainder) def closest_multiple_10(x): rem = x % …
Linny's user avatar
  • 10.4k
1 vote
2 answers
341 views

Find the shortest distance between two letters

I've been tasked with finding the distance between two letters in the alphabet. Below is my solution. My main concerns are if there is any shorter way to do this, and if there are any edge cases I'm n …
Linny's user avatar
  • 10.4k
2 votes

Collecting numbers in ascending order

Here are a few suggestions: You should get in the habit of wrapping all code that isn't contained in a function, in a main guard. This will protect the code from being run when the file is imported. …
Linny's user avatar
  • 10.4k
1 vote

My prime number generation program in Python

Remove print statements Printing to the console takes a significant amount of time, and you are printing for every iteration and every element in the list. Run it once with the statements, and once wi …
Linny's user avatar
  • 10.4k
5 votes
Accepted

A simple Decryption Program using Python

Use built in methods! Your position_in_alphabets function can be reduced to one line. In fact, replace y = ... with the following: alphabets.index(character) + 1 index returns the first occurrence …
Linny's user avatar
  • 10.4k
7 votes

Are the sum of two numbers desired?

Your function code can be simplified to one line. from itertools import combinations from typing import List def array_sum(inputs: List[int], tests: List[int]) -> bool: """ Determines if any …
Linny's user avatar
  • 10.4k
1 vote

Python Sudoku Solver

Class Names Classes should be in PascalCase, not lowercase. So your class should be App. Operator Spacing There should be a space before and after every operator (+-*/=, etc) in your program. It im …
Linny's user avatar
  • 10.4k
7 votes
1 answer
285 views

Random Maze Pathfinder

""" Code written by: Linny Github: https://github.com/Linnydude3347 This program demonstrates a pathfinding algorithm """ from os import system, name import time import random import math def calculate_distance … go_down return spaces[1][0], spaces[1][1] GRID[x][y] = go_left return spaces[3][0], spaces[3][1] return -1, -1 def find(start_x, start_y): """ This is the main algorithm
Linny's user avatar
  • 10.4k
1 vote

My implementation of bubble sort using Python

Your bubble sort algorithm has way too many variables. You don't need to keep track of the right and left item. …
Linny's user avatar
  • 10.4k
2 votes

Longest Palindromic Substring better approach

Unnecessary else after return In the body of an if, if you end up returning something in that body, an else is not required. A return will exit the body of the function, so the code in the else won't …
Linny's user avatar
  • 10.4k
6 votes

Determine if a triangle is equilateral, isosceles, or scalene

After a very quick pass, here's what I have for you: I assumed ... sorted(sides)[-1]: was a typo, so I removed the :. Return Expressions: It's better to return expressions than to just else: return …
Linny's user avatar
  • 10.4k
5 votes
2 answers
2k views

Sum of all digits in a string

I would really only like suggestions on the actual algorithm, but anything else is appreciated. …
Linny's user avatar
  • 10.4k
4 votes
Accepted

Tic-Tac-Toe with changeable board size (Part 2)

Winning Bug When the board is at this stage and the user gets the next move: | | X | O | X | | ---------------------- | | | O …
Linny's user avatar
  • 10.4k

15 30 50 per page