hjpotter92
  • Member for 9 years, 9 months
  • Last seen more than a week ago
System that manages employee data for managers
Accepted answer
18 votes

Welcome to Code Review! Kudos to writing a fairly large program. Several things pop-out from your program. But, a few things first. If you are using any intelligent editor; please see if you can get ...

View answer
Data encryption with python
Accepted answer
13 votes

That seems like a very long method to splice and put together the string every even set of characters. You are essentially trying to build a square matrix using the characters from the given string. ...

View answer
Histogram word counter in Python
Accepted answer
12 votes

Several things can be improved in your existing code. First and foremost being, replacing your usage of re module. Regex matching is very heavy. You have a defined set of characters being replaced. ...

View answer
Two ways to remove duplicates from a list
Accepted answer
11 votes

The teacher is obviously using a better way. Check/read more about time complexity for lists in python here (python wiki). In your case, you are going for a time complexity: \$ O(n) \$ for iteration \...

View answer
Return first duplicate
10 votes

Perhaps, using a dictionary to keep account of already seen values? from collections import defaultdict def first_duplicate(given_list): seen = defaultdict(bool) for value in given_list: ...

View answer
Pythonic way to flatten lists or arbitrary depth using assignment expressions
10 votes

Welcome to Code Review. Follow the PEP8 guide for naming conventions. Functions and variables would be snake_case. When checking for empty list, you don't need to find the length. Empty lists/...

View answer
My first project in Python: Tic Tac Toe
10 votes

Welcome to the community. Here are few pointers from first look at the code: The code does not follow PEP-8 style guide. You should follow the snake_case naming convention for variables and functions;...

View answer
Generate Letter Combinations of a Phone Number
10 votes

You can set the keypad lookup as a constant instead of computing it dynamically. Setting it up as constant makes it clearer that what your intent is. KEYPAD = { '2': 'abc', '3': 'def', '4'...

View answer
Verify string format with given pattern
10 votes

I'd instead use the std::isalpha() to check for the alphabets, and for the rest; use isalnum() plus an or condition for the _ character. Another check, I'd put is whether the input's length is indeed ...

View answer
guess your number
9 votes

Magic numbers As already mentioned in comments, the numbers \$ 1, 2, \cdots \$ appear to be completely random to anyone not sure about how the summation is going to (or supposed to) work. The ...

View answer
Python3 - merge sort, O(n) space efficiency
8 votes

Welcome to Code Review! PEP-8 Python has a style guide to help developers write clean, maintainable and readable code. It is referred to as PEP-8. A few points of note: Avoid extraneous whitespace in ...

View answer
FASTA-to-tsv conversion script
8 votes

Welcome to Code Review! I'll add to the other answer from Reinderien. PEP-8 In python, it is common (and recommended) to follow the PEP-8 style guide for writing clean, maintainable and consistent ...

View answer
Compare all files to each other
8 votes

Welcome to Code Review! Shellcheck Use the amazing shellcheck utility to verify for common practices when writing bash/shell scripts. It reports missing shebang. Loop using seq Since you know the ...

View answer
Avoiding Python tricks to find anagrams
8 votes

Welcome to Code Review. Since you're looking for Python tricks here, there are great many things which can both make it Pythonic, maintainable, shorter, etc. Depending on your understanding, as well ...

View answer
Simple square root calculator
Accepted answer
8 votes

Welcome to the community :). A few pointers: The code does not follow PEP-8 style guide. You should follow the snake_case naming convention for variables. Split code into separate functions. Instead ...

View answer
Python 3 Vigenere Cipher
Accepted answer
7 votes

shebang The shebang should be generic. You are currently calling python, which might point to python 2 on certain systems. A generic, virtual environment friendly python shebang is: #!/usr/bin/env ...

View answer
Best Algorithm for solving USACO: Photoshoot - Python
Accepted answer
7 votes

Mathematical approach Let us assume the following notation: $$ \mathbb{B} = \sum_{i = 1}^{n - 1} b_i = b_1 + b_2 + \cdots + b_{n-1} $$ As mentioned earlier in comments, you have set of interdependent ...

View answer
first pizza order program
7 votes

Welcome to CR community. Keep constant declarations at the top. Although you follow the PEP8 naming conventions throughout (almost) the whole code base, constant (or globals) are named as ...

View answer
Git delete all merged in local branches
7 votes

I am assuming you are starting nano so that you may remove possible occurrences of master branch (or some other static branch) from the list. You can do the same in a single line command: git branch -...

View answer
Cryptocurrency notifier - let's get rich (or at least let's try)
Accepted answer
7 votes

I know I don't have docstrings and that my API keys shouldn't be stored in my program (the same for DB credentials), so try to avoid these aspects when reviewing my code. Just mentioning even ...

View answer
Accepting user input for tickets and tips
7 votes

Instead of calling str(datetime...), use the isoformat() method available to the object. Understanding the difference between amnt and amntt variables is not so straighforward. Both could mean amount ...

View answer
Get file name with extension and get only extension
7 votes

Since you want to get everything from the end, until first / or . are found; use a lua-pattern. While Yu Hao's suggested pattern would give you the desired results; you can also use the following: ...

View answer
Validating ISBN-10s, with or without dashes in C++11
Accepted answer
6 votes

When you're comparing against 8 different patterns, and then simply removing - for 7 of those validations, why not just remove - initially, and then validate against the only remaining pattern. ...

View answer
Pizza Order System
Accepted answer
6 votes

Welcome to CR community. Keep constant declarations at the top. Although you follow the PEP8 naming conventions throughout (almost) the whole code base, I'll point out a few key things: variables, ...

View answer
Java Regex for Chess notations
Accepted answer
6 votes

No. The matching for a-zA-Z would be slower than the exact character-set you supply: RNBQKrnbqk. You can observe this behaviour by checking the backtrace it generates. I compared 3 different patterns,...

View answer
Recursive implementation of power set in Python
6 votes

input is a library function. Use a different variable name. Python comes with the methods itertools.combinations, which can generate all combinations of given size. The function can be compressed to: ...

View answer
String cut by a separator with the separator in the respective list element in python
6 votes

As already commented, use the str.split() version itself: SEPARATOR = "my_separator " s = "my_separator first thing my_separator second thing" data = [SEPARATOR + part for part in s.split(SEPARATOR) ...

View answer
Very simple Python RPG
6 votes

Welcome to Code Review. This is a really awesome piece of program you have :) And thanks to A. Romeu for translations. Because I noticed the awkward syntax highlighting towards the end of main.py ...

View answer
Storing the API endpoints in a Pythonic way
6 votes

If the API routes are consistent, I'd suggest making use of the __getattr__ metamethod. A simple example would be class APIRoutes: _BASE = "https://wallet.shiftnrg.org/" _BASE_API = _BASE + "...

View answer
Metathesis pairs
6 votes

You have a very well written piece of code. It is well documented, split into proper functions; can be followed through without needing any external help. However, a few points to note: for ...

View answer
1
2 3 4 5
7