New answers tagged

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 ...
user avatar
  • 53k
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: ...
user avatar
  • 561
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 -> ...
user avatar
  • 32.4k
2 votes

Simple non balancing indexed binary search tree

Use unique_ptr for root, left, and right Because each ...
user avatar
  • 1,141
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 ...
user avatar
  • 18.2k
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 47.9k
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. ...
user avatar
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. ...
user avatar
  • 91.5k
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 ...
user avatar
  • 32.4k
4 votes

Battle terminal-based game

Enemy and Player are really just the same class, right? Nothing is different between them. ...
user avatar
  • 47.9k
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 ...
user avatar
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 ...
user avatar
  • 47.9k
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 ...
user avatar
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 ...
user avatar
  • 47.9k
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 ...
user avatar
  • 30.4k
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 ...
user avatar
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 ...
user avatar
  • 9,475
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 ...
user avatar
  • 9,475
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, ...
user avatar
  • 30.4k
-1 votes

Letter Changes coderbyte

I would use a hash table to keep things simpler ...
user avatar
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 ...
user avatar
0 votes

Partitioning a list so that even numbers appear before odd numbers

You can use Vec::sort_by instead. ...
user avatar
  • 1,637
2 votes
Accepted

Tic Tac Toe Module in Rust: Implementing "new"

Just put it in a local value for brevity. That's it. ...
user avatar
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 ...
user avatar
  • 3,273
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 <...
user avatar
  • 47.9k
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 32.4k
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 ...
user avatar
  • 3,273
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 ...
user avatar
  • 30.4k
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 ...
user avatar
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 ...
user avatar
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: ...
user avatar
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 ...
user avatar
  • 9,475

Top 50 recent answers are included