Skip to main content
155 votes
Accepted

Basic Pokedex in C++

Your Pokemon class (declaration) ...
Zeta's user avatar
  • 19.3k
152 votes
Accepted

Disproving Euler proposition by brute force in C

Note: At some point, this review drifted into the realm of assembler and GMP. An actual review is at the end of this post, whereas the first section discusses the runtime-problems concerning ...
Zeta's user avatar
  • 19.3k
81 votes
Accepted

Message decoder

That's not a bad program, despite the number of suggestions I'm about to make. I do recognize you're a learner, and a young learner at that. There are several levels at which we can analyze this ...
Jonathan Leffler's user avatar
79 votes

Disproving Euler proposition by brute force in C

Well let's start with this: for (a = 1; a < 100000; a++) { for (b = 1; b < 300000; b++) { for (c = 1; c < 500000; c++) { let's ignore ...
Eric Lippert's user avatar
  • 14.9k
55 votes

Café in C++ program

Don't. Repeat. Yourself. That's an essential principle. You repeat the "do you want XY" cycle over and over manually. That's not only error prone, but also hard to maintain. For example, let's say ...
Zeta's user avatar
  • 19.3k
53 votes
Accepted

FizzBuzz in Javascript

I'd like to see if this is a reasonable solution, or is just plain terrible. I wouldn't say it is "terrible" - mostly because it works and doesn't appear to be very inefficient. However, ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
52 votes

A simple mastermind clone

This is sophisticated for a first attempt, but today would be a great day to break yourself of bad habits. Your code is full of them. Start with: format your code using standard formatting ...
Eric Lippert's user avatar
  • 14.9k
51 votes
Accepted

Password checker in Python

Concept Obligatory XKCD comic, before I begin: Enforcing password strength by requiring human-unfriendly characters is no longer considered good practice. Nevertheless, I'll review the code as you ...
200_success's user avatar
48 votes

Brainfuck interpreter written in C

This is a pretty reasonable start on a simple interpreter. Edward's suggestions are all good; a few additional suggestions: interpret("+++++++++++++[->.... ...
Eric Lippert's user avatar
  • 14.9k
42 votes
Accepted

Project Euler Problem 45

Arithmetic Project Euler questions are meant to educate you about both mathematics and programming. It would be a good idea to understand what these triangular, pentagonal, and hexagonal numbers ...
200_success's user avatar
41 votes

Rock Paper Scissors. My first C++ program. Please judge harshly

It's not too terrible, especially for a first program, but there are a number of things that you might improve. Decompose your program into functions Almost all of the logic here is in ...
Edward's user avatar
  • 66.5k
39 votes
Accepted

Find nth Fibonacci Number, using iteration and recursion

Why do most people (on the internet) recommend using recursion because it's simpler and easier to write the program? Logically I thought that we should write it in a way that is fast and simple. This ...
Eric Lippert's user avatar
  • 14.9k
36 votes
Accepted

Fishing simulator

Welcome to CodeReview. It's never too early to develop good coding habits, and reviewing your code is about the best way to do so. First, congratulations on writing a clean, straightforward program. ...
aghast's user avatar
  • 12.4k
35 votes

Basic Pokedex in C++

Just a few things that seem like they might be open to improvement. Evolution Rather than having a Boolean to indicate whether a particular type is the final step in its evolution, I think I'd have ...
Jerry Coffin's user avatar
  • 33.6k
33 votes

Disproving Euler proposition by brute force in C

All of the answers given (when this 'answer' was first written) ignore an important constraint: native types. In C, a long int is a 32-bit (or greater) signed type,...
whydoubt's user avatar
  • 461
33 votes
Accepted

Basic Java library to hold books

Naming Java has a Naming Conventions that you currently don't follow. int Capacity = 10; int Volume = 0; You should have : ...
Marc-Andre's user avatar
  • 6,711
33 votes

Verifying IPv6 addresses

Python has a philosophy of "Batteries Included". Don't reinvent what's in the standard library! In particular, this code is much more easily written if we take advantage of ...
Toby Speight's user avatar
  • 79.1k
33 votes
Accepted

Implementing any_of in C++

The algorithm looks correct. Regarding the function signature, I'd make three changes: You're not modifying elements, so take it by constant reference rather than reference. You don't need to ...
Errorsatz's user avatar
  • 1,354
32 votes

Disproving Euler proposition by brute force in C

Some interesting things no one have mentioned about this, but it is an improvement when looking for the smallest solution: If the \$\gcd(a,b,c) \neq 1\$ then \$a^4\$,\$b^4\$,\$c^4\$ and \$d^4\$ are ...
mascoj's user avatar
  • 421
32 votes

Disproving Euler proposition by brute force in C

I'm not able to comment on vnp's solution, but vnp was right the first time: you can brute force it in \$O(n^2\log(n))\$ time and \$O(n)\$ space. You don't need \$O(n^2)\$ space because you don't have ...
Alex Selby's user avatar
32 votes
Accepted

Project Euler Problem #4 - Palindromic number

The other answers are all giving you different ways to reorganize your loops. They're all not bad in their own way, but the better solution in C# is to not write any loops in the first place. Your ...
Eric Lippert's user avatar
  • 14.9k
32 votes

Tic Tac Toe console program

This is not bad for a programmer as new to C++ as you have said you are. Keep up the good work! With that said, here are some ideas on how you might be able to improve your program. Don't abuse <...
Edward's user avatar
  • 66.5k
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
31 votes

A counterexample in balanced parentheses

May I suggest a simpler solution: You need only a counter. it is incremented by 1 whenever you encounter an openning parenthesis "(" and is decreased by 1 whenever you encounter a closing parenthesis ...
Sharon Ben Asher's user avatar
31 votes
Accepted

"Compliment giver" mini-program

Don't be discouraged by how much I have written. I'm a professional software developer and my colleagues make fun of me because of how pedantic my code reviews are. I think what you've done is ...
Ben Wainwright's user avatar
30 votes
Accepted

Yet another boring FizzBuzz

Coming from Python world, I was tempted to create a separate method named fizzBuzz() which I then called in my main() method. Is ...
Heslacher's user avatar
  • 50.4k
30 votes

Perl CGI script to serve a PDF file

I will go through your code line by line and give feedback. We will skip the general advice on don't use CGI as it's actually suited for what you are trying to do here. I wrote this answer in two ...
simbabque's user avatar
  • 993
30 votes

A first "Hangman" game in Python

You define a clear_screen function, but then at the top you have ...
Carcigenicate's user avatar
30 votes
Accepted

A Caesar cipher in Python3

You say you're new to Python. Well, that's ok. And a Caeser Cipher is a good place to start since it's complex enough for an absolute beginner while easy enough to understand what goes on, why and ...
Mast's user avatar
  • 13.4k
30 votes

Providing advice based on user's favourite YouTuber

I've heard of dictionary lookups but I don't really understand what they are so if anyone thinks that they maybe relevant and could show me how to implement it that would be great! Here you go! Use ...
Linny's user avatar
  • 10.3k

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