New answers tagged beginner
1
vote
Simple non balancing indexed binary search tree
More horizontal spacing please. Give your operators some breathing space. It is very hard to read things like root==nullptr||i<0||i>=root->size. BTW, I ...
1
vote
Show/hide depending on ID and Class
We can be a lot shorter easily with a bunch of css selector and js string manipulation and for optimisation purpose we will use JQuery visible selector:
Starts with selector:
...
1
vote
Sidenav menu that appears when click on button
From a short review;
x is not an evocative name,
JavaScript is lowerCamelCase so mobile_menu -> ...
2
votes
Simple non balancing indexed binary search tree
Use unique_ptr for root, left, and right
Because each ...
5
votes
Accepted
Blackjack game in C++
General Observations
Playing is fun. There one upgrade could be allowing the player to double down their bet. The program could use some error handling, when the program prompted me with "cash ...
0
votes
Calculate sum and count of even and odd numbers
Sure it's good.
I think loops in this case are not needed.
The following is based on the famous:
1 = 1^2
1+3 = 2^2
1+3+5 = 3^2
...
Included the loop so you see how ...
2
votes
Accepted
Three efficient JavaScript functions that converge to pi extremely fast
In terms of more precision, I can't really help there... But, in terms of general code styling and performance, I'd be happy to give some pointers. This is good code, but slightly inconsistent (which ...
1
vote
Accepted
Python CLI math game
I want to know if there are ways I don't know about to make it even shorter.
Shorter isn't always better, and this is not code golf. Strive for good code, and the short code will come naturally as a ...
1
vote
Clojure Prime Numbers from 1 to 1000
Note: It has been a long time since I actively played with Clojure, so I will mostly refrain from writing and/or reviewing any actual code in my answer and will only provide a high-level review.
...
2
votes
Passwords with C++ Console
Overall
A good first go.
I have some minor points below. But the main thing I think you need to read up on is passing parameters by reference.
...
0
votes
Modify a string by identifying a substring, and replace it and the characters following it with a newly computed substring
Create a function that does the replacing
It is good practice to create a function for what you are doing. A function will have a name that describes what it is doing, and it clearly defines the input ...
4
votes
Battle terminal-based game
Enemy and Player are really just the same class, right? Nothing is different between them. ...
4
votes
Battle terminal-based game
Fun little game, easy to win though :P
As for the code:
Naming things enemy in enemy class is a bit double.
Same goes for player
...
4
votes
Accepted
Automate the Boring Stuff CH 10 - filling in the gaps
I believe that my logic is closer to a functional programming style
It isn't, and new developers often confuse this with procedural programming; yours is the latter.
Otherwise:
Avoid ...
0
votes
Object-oriented design implementation of an Elevator
To model Elevator better, you may have following two options:
Singleton class Elevator which has existence independent of Person.
Rename Elevator to ElevatorTrip. This way ElevatorTrip can exist ...
1
vote
Register/Login for Rock/Paper/Scissors
Recently I have been learning Python after years of putting it off, and I am having a really fun time with it.
Keep it up!
In register, your ...
3
votes
A Simple Tic-Tac-Toe Game
You definitely need more functions.
You state that you could put print(display_table) in a function, but not sure how you could update the table since it would be a ...
5
votes
A Simple Tic-Tac-Toe Game
General Style
Add a main guard
This convention is specific to Pyton.
Use a block if __name__ == '__main__': to put all your main logic into.
Functions should do one ...
11
votes
Accepted
A Simple Tic-Tac-Toe Game
Put all code in functions. This is what experienced programmers do, so you
would be wise to adopt the practice even if you don't fully appreciate all of
the reasons yet. After that change, you'll end ...
1
vote
Pascal's triangle solution in Python code
Use functions. You have a review with some useful advice, and its best
advice is that you organize your programs around functions. Here I'll extend
that idea.
Functions should be focused. If we take a ...
1
vote
Pascal's triangle solution in Python code
PEP 8
The Style Guide for Python Code has many recommendations that all Python programs should follow. These include:
snake_case for variable and function names, ...
-1
votes
2
votes
Accepted
Partitioning a list so that even numbers appear before odd numbers
welcome to the Rust community!
Your code is already quite idiomatic. You may use an unsafe and unstable feature to improve efficiency, swap_unchecked. It's only ...
0
votes
Partitioning a list so that even numbers appear before odd numbers
You can use Vec::sort_by instead.
...
2
votes
Accepted
Tic Tac Toe Module in Rust: Implementing "new"
Just put it in a local value for brevity. That's it.
...
1
vote
Accepted
JavaScript function that generates Fibonacci like sequences of given order
Your algorithm for an n element Fibbonacci series order k is O(N*K) Your JavaScript implementation may be inefficient. I revised your algorithm to become O(N). I revised your JavaScript implementation ...
2
votes
Accepted
Automate the Boring Stuff Chapter 5 Project - Chess Dictionary Validator
Your implementation has broken the spec. Pieces aren't supposed to have a single letter to identify them; they're supposed to have the full word.
Your message and <...
3
votes
Tic-Tac-Toe vanilla JS Pseudo OOP
Answering Questions
How to implement a MVC pattern? Right now, the state and HTML elements are global variables, but I think this could be stored in state and UI classes Also, I'm having troubles ...
0
votes
A simple JavaScript function that does prime factorization
Taking a square root is a very slow operation, so it's a bad idea to do it for every iteration of the loop. Rather, you should only update the limit whenever n ...
2
votes
Accepted
FizzBuzz in JavaScript (node.js), my first JavaScript program
A short review;
special is not an evocative name, maybe divisors?
special is polluting the ...
2
votes
FizzBuzz in JavaScript (node.js), my first JavaScript program
Wikipedia: Fizz buzz
Programming
Fizz buzz (often spelled FizzBuzz in this context) has been used as an interview screening device for computer programmers. Writing a program to output the first 100 ...
1
vote
Word Analyzer: Counts total characters, names starting and ending letter, determines if my initials are present in the word
Welcome to Code Review, and welcome to the world of Python programming!
Everyone's code is awful at the start; don't worry about that. Just be open to feedback, learn from feedback you get from ...
1
vote
Tic-Tac-Toe vanilla JS Pseudo OOP
It's good for what it is, and the end result looks nice.
I want to suggest you look into Typescript for type safety and readability, a framework like React/Vue/Angular/Svelte to avoid having to do DOM ...
1
vote
Merge sort in PHP 5
It appears that you have quite a bit of experience with mergesort in various programming languages. While it may obviously be deemed a bit tangential to the purpose of StackOverflow I can’t help but ...
8
votes
Word Analyzer: Counts total characters, names starting and ending letter, determines if my initials are present in the word
Bug
This test does not do what you think it does:
...
6
votes
Accepted
Binary search algorithm (Python 3.9)
Your binary search is flawed in various ways, but don't feel bad. It's a
deceptively difficult
algorithm to get right.
The primary problem: confusion between indexes and values. Some of your
code ...
Top 50 recent answers are included
Related Tags
beginner × 7232python × 1877
java × 1013
c++ × 846
python-3.x × 786
javascript × 679
performance × 590
c# × 544
c × 516
object-oriented × 462
programming-challenge × 423
game × 404
strings × 312
algorithm × 299
php × 236
calculator × 205
haskell × 195
html × 189
tic-tac-toe × 187
jquery × 178
array × 173
rust × 167
ruby × 165
console × 157
python-2.x × 149