Skip to main content
47 votes
Accepted

ASCII text-based RPG game in C++

First of all, let me join others in pointing out what sweet ASCII art you've done. This definitely has the beginnings of a much nicer text game than most. I'd start by defining some structures to ...
Jerry Coffin's user avatar
  • 33.6k
35 votes
Accepted

The right way to hang a man

Repetitions All your elif share the same structure. You just need to ensure that the inserted pattern is always 3 wide and you can drop your offsets adjustments. ...
301_Moved_Permanently's user avatar
31 votes
Accepted

Print 10 × 10 square of X and O characters, split diagonally

Lots of answers already, but most of them seem to be about alternative solutions. I'll review your code on the details and show you how to refactor your code step by step. (This is a long answer, link ...
Pimgd's user avatar
  • 22.3k
29 votes

ASCII text-based RPG game in C++

There's good news and bad news about this code. The bad news is that it's not very good code. The good news is that it's not going to be too hard to improve it greatly, and the ASCII art is awesome! ...
Edward's user avatar
  • 66.5k
17 votes
Accepted

Printing binary trees

First of all, in my opinion, both the algorithm is nice and interesting, and the code is really well-written, broken down into easily understandable functions! Well done! The only addition that I can ...
Attilio's user avatar
  • 1,645
16 votes

ASCII text-based RPG game in C++

Control Flow I want to endorse and flesh out a bit Edward’s advice on removing the goto statements. A better approach here is some kind of state machine. You’ve ...
Davislor's user avatar
  • 7,956
16 votes

Generate an Hour Glass pattern

Read PEP8, it will give you directions on how to write Python code that look like Python code to other. Other than that, the behaviour you're seeking is already implemented in ...
301_Moved_Permanently's user avatar
15 votes

Print 10 × 10 square of X and O characters, split diagonally

for (int i = 0; i < 10; i++) { System.out.println("XXXXXXXXXXOOOOOOOOO".substring(9 - i, 19 - i)); } This uses a string of 10 Xs and 9 Os It suggests that ...
Joop Eggen's user avatar
  • 3,536
12 votes

Java diamond with numbers

Before going into any coding I would give you a quick hack for the diamond problem . Instead of making so many for looping and columns and keeping track of variables the diamond problem is a variant ...
Abhinav Pandey's user avatar
12 votes

ASCII text-based RPG game in C++

You might want to load the ascii art from separate text files so you can edit those without messing with the functional code.
Rchn's user avatar
  • 221
12 votes
Accepted

Printing a multiplication table in C

You should generally try to avoid global variables (like tableSize). Since they can be used everywhere ("globally"), at the worst case you need to read all of the ...
Curtis F's user avatar
  • 334
11 votes
Accepted

Printing staircase revisited

JavaScript function names should start with a lowercase character, and "staircase" is one compound word in English. Since every line is nearly the same, and only one character changes at a time, you ...
200_success's user avatar
11 votes

Print 10 × 10 square of X and O characters, split diagonally

You are doing a lot of if-condition to find what you need to print. This works but this is a verbose. You could find some logic in what you want to print. Your output is a simple square matrix that ...
AxelH's user avatar
  • 319
10 votes
Accepted

Homework to display a square and calculate tips

The code is not self-documenting, because the problem description is non-trivial and involves what you'd call "business logic". That is, you're not trying to perform some technical operation (like a ...
Pimgd's user avatar
  • 22.3k
10 votes
Accepted

An ASCII histogram of a die rolled n times

The roll function generates a random sequence of integers. The loop body shows me that you know how to seed a pseudo-RNG with a true source of randomness but you're ...
Indiana Kernick's user avatar
9 votes
Accepted

A Rusty implementation of CowSay

The tests fail. That's not a good thing: ...
Shepmaster's user avatar
  • 8,658
9 votes
Accepted

Printing a diamond shape in ASCII

Calling print is very slow, you should focus on building strings then have one print. Fortunately Python has some really nice string manipulation options. ...
Peilonrayz's user avatar
  • 43.4k
9 votes
Accepted

Convert image into ASCII art

myList should be my_list by PEP8. Add PEP484 type hints. from bisect import bisect_left ...
Reinderien's user avatar
  • 62.5k
8 votes
Accepted

Print list items in a rectangular frame

You can let .format() do most of the work for you: ...
Jaime's user avatar
  • 6,572
8 votes

Python ASCII-Art Table

In no particular order: Your approach to default keyword arguments with the **k is unusual. I’d expect to see something more like: ...
alexwlchan's user avatar
  • 8,565
8 votes
Accepted

Python ASCII-Art Table

There are a lot of duplicated code, inefficiencies and redundancies (wait…) but there is that one thing that you are doing right: you use join instead of trying to ...
301_Moved_Permanently's user avatar
8 votes
Accepted

Print a chessboard

First of all, your code has a little flaw. It will print the first two lines like this: ◼◻◼◻◼◻◼◻ ◼◻◼◻◼◻◼ You may haven't noticed it, because it's hard to spot ...
insertusernamehere's user avatar
8 votes

Console-based table structure: Revisited

this->headers = {headers}; In the constructor? You mean to use an initializer instead :headers{headers} before the ...
JDługosz's user avatar
  • 11.4k
8 votes
Accepted

Console-based table structure: Revisited

This version is definitely much improved. Good job! I see a few things that might help you improve it even further. Use all required #includes The code uses <...
Edward's user avatar
  • 66.5k
8 votes

Pretty printing of the numpy ndarrays

If A.ndim is not in 1, 2, 3, your code tries to return a non-existing string s. It would be ...
Graipher's user avatar
  • 41k
8 votes
Accepted

Output a pyramid of numbers

Don’t write using namespace std;. You can, however, in a CPP file (not H file) or inside a function put individual ...
JDługosz's user avatar
  • 11.4k
7 votes

Beginning of simple rogue-like RPG (in console) in C++

I see a number of things that may help you improve your code. Fix the typo It's probably a cut-and-paste error rather than a real error, but in the posted version of the code, the ...
Edward's user avatar
  • 66.5k
7 votes

Print 10 × 10 square of X and O characters, split diagonally

Your code is not good, because you have a lot of duplicate lines, you create a lot of strings during the execution of your loop ( because strings are immutable, + ...
Jens's user avatar
  • 297
7 votes
Accepted

Python ASCII-Art Text Generator

Style You’ve already been told that by @alexwlchan in your previous question but: "whitespace is cheap" and it improves readability a lot. Compare your code to: ...
301_Moved_Permanently's user avatar
7 votes
Accepted

Show a diamond shape with numbers

Code issues that decrease readability and maintainability Plenty of loops. Non-meaningful variable names: n, l, ...
Dmitry's user avatar
  • 4,589

Only top scored, non community-wiki answers of a minimum length are eligible