Skip to main content

New answers tagged

1 vote

Gomoku game 5 in a row. Javascript simple game Canvas

Made changes according to tdy's advice and Wimanicesir's advice. Fixed errors. The code works as expected. Equality of elements is determined horizontally, vertically and diagonally. Edited the code ...
Василий Иванович's user avatar
2 votes

Bash script to automate post install process on Fedora

Consider putting your functional blocks in functions instead of just indenting them and then just calling each of those if the previous function succeeds, e.g.: ...
Ed Morton's user avatar
  • 194
1 vote

Creating Layout of 2D Board game

Three major improvements are: try to avoid using continue as much as possible. It is rarely needed, and obfuscates the logic. It is not needed at all in your case. ...
fishinear's user avatar
  • 121
1 vote

Creating Layout of 2D Board game

Bug uint8_t board[100]; ... for (uint8_t i = 1; i < 101; i++) { board[i] = i; } attempts to access board[100] which is out ...
4 votes

Creating Layout of 2D Board game

Arrays are indexed starting from 0 in C, which means that valid indices for buffer are 0..<...
TrayMan's user avatar
  • 343
3 votes

Creating Layout of 2D Board game

As @toolic said, You can use "%3d" to print the number on a 3 width field, aligning every one. In addition You can completely remove the ...
Groux's user avatar
  • 31
5 votes
Accepted

Creating Layout of 2D Board game

Simplify In the "even" clause, you can simplify the check: if (((k % 10) == 0) && (k != 0)) { as: ...
toolic's user avatar
  • 4,479
0 votes

Gomoku game 5 in a row. Javascript simple game Canvas

On the advice of TDI. I removed function isEqual(a1, a2, a3, a4, a5) from my code. Added function isEqual(arr). Set the condition using the slice() method. ...
Василий Иванович's user avatar
1 vote

Gomoku game 5 in a row. Javascript simple game Canvas

The accepted review has a few useful tips but is a little bit short IMO. General You used functional programming to tackle this problem. Which is doable but creates a mess real quick! Consider to ...
Wimanicesir's user avatar
4 votes
Accepted

Gomoku game 5 in a row. Javascript simple game Canvas

...
tdy's user avatar
  • 2,141
6 votes

Coding exercise to represent an integer as words using python

First, the spec itself is not very good. Conventionally, English numerals are never written out in Title Case so it doesn't make sense to code for that. Also, the spec is missing the hyphen and ...
Reinderien's user avatar
  • 63.1k
4 votes
Accepted

Coding exercise to represent an integer as words using python

In addition to the good suggestions in the previous answer, here are some more things to consider. Bug When I run your code and give the "Example 3" input (...
toolic's user avatar
  • 4,479
5 votes

Coding exercise to represent an integer as words using python

My two cents: ...
Luke L's user avatar
  • 181
2 votes
Accepted

Printing a pattern of input string in X shape

Writing index-conditional statements on the inside of a loop is a code smell. Instead you should prefer "looping like a native" making appropriate use of ...
Reinderien's user avatar
  • 63.1k
3 votes

userform with textboxes and dates to show timeline

We can use Me.Controls to reference the Controls by name. Although, it looks cleaner there will be no noticeable change in performance. ...
TinMan's user avatar
  • 4,288
4 votes

Printing a pattern of input string in X shape

A big change would be to improve the readability of the program. Some changes I would make are: Add spacing between operators and make bracket style consistent (e.g. ...
AryaanSheth's user avatar
5 votes

Simple casino game

Some things not mentioned in other answers: What's the problem with "using namespace std;"? std::endl does more than just newline, so don't use it unless ...
Toby Speight's user avatar
  • 79.1k
4 votes

Simple casino game

In general, I would avoid using global variables. Variables such as pHand should be defined in blackJack and then passed by ...
Confettimaker's user avatar
7 votes

Simple casino game

Here are a few suggestions: Give more instructions for user input and validate it carefully. I tried out the program, entered "1.", and immediately got stuck in an infinite loop. It is much ...
Justin Chang's user avatar
  • 1,499
3 votes

Guess-the-number game in Python

The bulk of your code deals with validating the input. My suggestion is to factor them out to separate functions, making the code cleaner. Also, it helps to write down what kind of input is acceptable,...
Hai Vu's user avatar
  • 720
1 vote

adding data to a CSV file for it to be read

Let me address the most obvious issue: not using the csv standard Python library. You should use it because: It handles the CSV data It makes code easier to read ...
Hai Vu's user avatar
  • 720
3 votes

Bash manual page selection menu (version 2)

I guess the reset command to clear terminal and scrollback buffer isn't available on your target? In any case, that's an irritating thing for a program to do. ...
Toby Speight's user avatar
  • 79.1k
3 votes

A simplified Blackjack C++ OOP console game

getch returns 0 (not '0'!) only in special circumstances. But normally it's supposed to ...
jeancallisti's user avatar
5 votes
Accepted

A simplified Blackjack C++ OOP console game

Miscellaneous observations I already have a long answer examining blackjack.h; these are the unrelated issues I've spotted, in no particular order. ...
Toby Speight's user avatar
  • 79.1k
4 votes

A simplified Blackjack C++ OOP console game

There are some problems with blackjack.h that I'd like to address. What jumps out immediately is the large number of header files it includes. Particularly ...
Toby Speight's user avatar
  • 79.1k
8 votes

A simplified Blackjack C++ OOP console game

General Observations There are a few good practices here, the include guards are implemented properly. Overall the code should be reworked following best practices ...
pacmaninbw's user avatar
  • 24k
2 votes
Accepted

Parsing Lists: BIO 2024 Q2

This is clear, well-presented code; much better than the thrown-together hacks often seen as programming-challenge entries. We could perhaps make it even clearer by giving a name to ...
Toby Speight's user avatar
  • 79.1k
4 votes

C - mini string lib

Lots of good reviews already done. I'll add some points only about concat() - many of these points apply to the overall code. Concatenation detail Make clear this ...
chux - Reinstate Monica's user avatar
1 vote

Number Guesser Game in plain C

Do not use scanf() for user input: Checking the return value alone does not suffice. If the converted input is larger than the maximum value of an ...
Harith's user avatar
  • 9,687
9 votes

C - mini string lib

...
Toby Speight's user avatar
  • 79.1k
7 votes
Accepted

C - mini string lib

Overview: You don't keep the String consistent when you free the string. You set the buffer to NULL but the length is not reset. So if you now use this with any ...
Loki Astari's user avatar
  • 95.7k
3 votes

Plain JavaScript Rock, Paper, Scissors

There are a ton of RPS implementations in JS and even on the code review site. So I will mainly focus on your specific style. First let's address your questions: Are the variables named well? The 3 ...
Wimanicesir's user avatar
2 votes

Number Guesser Game in plain C

In addition to the good points in the other answer, here are some other things to consider. Displayed messages The messages you display to the user make it clear how to play the game and make it easy ...
toolic's user avatar
  • 4,479
5 votes
Accepted

Number Guesser Game in plain C

Good re-learning effort. Bug (kinda) printf("Guess the number (0-%d): ", range); implies that 0 to range is a ...
chux - Reinstate Monica's user avatar

Top 50 recent answers are included