31

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 Dictionaries! The entire if/elif/else if yelling, if not screaming, to be put into a dictionary. This is a lot faster than your implementation because it's a ...


3

Ok, so I'm also a beginner and some weeks ago I worked on a tic-tac-toe kind of game and learned a lot from it, here's what I think you could improve on. DRY (Don't Repeat Yourself): Whenever you see that you are having to copy and paste your code a lot, you can generally assume there's a shorter way to do the same thing you're trying to do, either by using ...


3

First of all, as per PEP8 I'd recommend you follow the best practices. Naming conventions allNagiosInfo -> this is most likely a constant, so: ALL_NAGIOS_INFO nagiosEntry, nagiosBaseURL, nagiosUsername, nagiosPassword, nagiosAuthType -> nagios_entry, nagios_base_url, nagios_username, nagios_password, nagios_auth_type. And so on with the naming, you got ...


3

Well, your biggest problem is the length of the scope of variables. You declare/define all the variables at the beginning before all the code. This is not required, nor is it any good. When I try to read the code I have no chance to find the usage of variables as I have to scan all(!) lines if it is altered somewhere. Such long scope is real evil. As you ...


3

I'd recommend having a look at Python's "official" Style Guide aka PEP 8, which is widely accepted in the community as a guideline on how Python code should be formatted. But you can also learn a lot from looking at other peoples code, e.g. here on Code Review. E.g. it's very common to have imports at the top of the file, followed by constants, class and ...


3

extern crate argparse; 2018 Rust edition doesn't require this, see. return State { fizz: false, buzz: false, count: count, message: String::from(""), } Here return is not idiomatic and you can omit count:, more info here and here. Same thing Game { state: State::new(count), limit: limit }. Also, this time you did omit the return keyword, ...


2

To get you started: Naming Hungarian notation (e.g., bValid) is not generally used in C++. C++ is a statically typed language, so the compiler will do type checking. Also, the common naming scheme in C++ is: snake_case for variables and functions; CamelCase (or Like_this) for classes; and ALL_CAPS for macros. You can come up with your own naming scheme ...


2

General comments The parameters you're passing in to almost every function collectively represent the current game state, which is perfectly fine for this style of programming which favors using functions over classes. Some might prefer modeling Hangman as a class with the game state, i.e. word and guessed_letters, as instance variables, but both styles are ...


2

if correct_answer == 'True': self.correct_answer = ['yes', 'y', 'f', 'true'] elif correct_answer == 'False': self.correct_answer = ['no', 'n', 'f', 'false'] f is recognized as a correct answer for both True and False answers, so I can collect all the points without knowing the correct answer to any of the questions by consistently answering f. This ...


2

You've actually run into a big gotcha here. Scheme doesn't actually specify the order to evaluate operands. This can be a problem for code with side effects, especially if you aren't careful to encapsulate the order you expect explicitly. Any time you see an exclamation mark at the end of the function, pay attention to ensure a correct and defined semantic ...


2

You've followed some conventions very well like CAPS for constants. Very nice. Here are some points: Standard library imports precede 3rd party ones import pygame import random should be changed to import random import pygame The middle line is to differentiate between the two types of imports Two lines after imports There should be two lines after ...


2

Since letters is a list of characters (1 length strings) you logistically have made letters a string. And so you can simplify writing it as a string rather than a list of characters. letters = "ABCDE..." You can remove the need to define letters by using string.ascii_uppercase. It's good to see some type hints. Good job! I would suggest changing your ...


1

On my computer while the program runs and gives answers it still terminates with 0xC0000005 which means the memory problem is still there but it no longer stops the program. The type of recursion you are using, where 2 functions (int succ_value_smaller(struct list * ptr, int * V, int * count, int k) and int complete_list_to_array(struct list * ptr, int * V, ...


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