Just looking over the two functions, I would probably say the first function is a better practice. It's shorter (meaning it's more maintainable), it uses fewer variables (which can cause less confusion), and does the same thing as the second function. Overall the advantage is that the first func...
AI Improved2 vs. AI Improved: 528 wins, 44 draws, 428 losses (55,23 %) AI Improved2 vs. AI Random: 807 wins, 49 draws, 144 losses (84,86 %) 3000 games played in 3559.856455 milliseconds
Perhaps I should try to fight against my own AI now?
012 345 678
-------------
0|- X|X- |OOO|
1|-X | X | O |
2|XX | -X|- |
-------------
3| X |O | X|
4|-X |O- | O|
5| X |O--| |
-------------
6|--X|XX | |
7| X | O | X |
8|X |OO |O O|
-------------
Game is won by X
Looking for general constructive positive feedback.
/***************************************************************************************************
**COMMS
The goal is to create the smallest most efficient communications library.
It is also to reduce dependencies between package...
Yeah, he is putting them into different questions and he's also providing good follow-up information when appropriate... but he's just... never stops. Never seems to think: "OK, code is fine now".
I read a meta answer recently that said something about answering questions with fine code - something about knowing when to say 'your code is fine, move on'.. link link link.....
Knowing when to say "That code is done, move on" is just as important a skill as finding fault.
If the code is "fine" someone should say so (as an answer) which can then be voted up (or down) by the community. Why force users to only provide criticism where there may simply be none to be had?
P...
Honestly though, I don't know if I would want such an answer or not to any of my future code... In one way, isn't that what we all are struggling for, to write "the best possible" code? But then also, why did we bother posting the question if the code is fine?
But an "your code is fine and here's why: (really long list...)", that would be a nice answer to get :D
We have a whole month to get our TTT ultimate. Some of us are going to come up with some nice pieces of code. Reviewing code that's already like, Wow! is going to be interesting. Explain Why each good design decision was a good one.
Indeed. I think we very often just focus on the parts that needs improvement and then just say "The rest of your code seems fine", perhaps we should start elaborate more on the "The rest of your code seems fine"-part?
I'm not quite sure about this one. After comparing the two tags, I can see some differences.
Questions tagged as asking-questions mostly involve asking whether or not a certain question can be asked here.
Questions tagged as questions involve things such as feature requests or anything else ab...
I have programmed a simple client in Java with a GUI interface. I am currently coding the thread that takes care of sending and receiving messages from the server. The rest is just setup for when I get this client thread working smoothly.
I would like a review of the code in terms of how well t...
The text editor will not let me paste the text into it. It exceed its 30k character limit. I'm not sure how else to do it. // I did try a few times to put it in there, I know people on here only want it on this site, sorry to not do so I had no other choice. — BumSkeeter5 mins ago
^^^ Not too sure I feel sorry ... apparently his code has a bug too.
But, I'm out of here.... I have 28 Kindergarten report cards to proof-read.
By the way, I have realized that instead of me copying my game board and pasting it here and then adding four spaces in front of each line, I could make my code output the code with four spaces already added!
I was trying to code up a R-nary trie.
I tried declaring an inner class keeping in mind that we can't instantiate an array of generics. However, I got a compiler error saying I can't declare an array of generics. The same declaration worked with an inner static class.
// Snippet with Compiler E...
I was trying to code up a R-nary trie.
I tried declaring an inner class keeping in mind that we can't instantiate an array of generics. However, I got a compiler error saying I can't declare an array of generics. The same declaration worked with an inner static class.
// Snippet with Compiler E...
@lol.upvote I was also wondering why it was like that at first, but then I understood that the generics-part of the outer class is somehow included in the inner, which makes a generic array creation impossible.
Lets say I design a database model for an online seller such as Amazon:
Next, to create the database model for the larger data warehouse, I flatten the Order and OrderDetails tables, and flatten the Product and Vendor tables:
I do this to apply the concept of designing models for parent-chi...
Lets say I design a database model for an online seller such as Amazon:
Next, to create the database model for the larger data warehouse, I flatten the Order and OrderDetails tables, and flatten the Product and Vendor tables:
I do this to apply the concept of designing models for parent-chi...
I want to know if I'm going about creating and calling two functions from my model to my controller in the simplest and cleanest way.
Model
public function getPosts()
{
$post = $this->paginate(4);
return $post;
}
public function getMonth($post)
{
$post->month = date('M', strtotime...
This site is for code reviews, not model reviews. Since your model is dealing with databases, Database Administrators would probably be the best place for this question. — syb0rg16 secs ago
I have programmed a simple client in Java with a GUI interface. I am currently coding the thread that takes care of sending and receiving messages from the server. The rest is just setup for when I get this client thread working smoothly.
I would like a review of the code in terms of how well t...
Even if you do shorten the code down, that is going to be a lot of code for one review. Splitting it up into parts will: make a reviewer have a faster response time; create a more specific review; and make the reviewed code easier for you to implement. — syb0rg10 secs ago
A DW isn't intended to be normalized, it's supposed to be optimized for SELECT AFAIK; also your dimensions don't seem to be storing history of changes, which may or may not be a requirement/problem. If you want a model review, I think you should avoid Etc columns in your model. But I agree with @syb0rg, DBA probably has a more targeted audience. — lol.upvote8 secs ago
Looking for general constructive positive feedback. I'm happy with the style, the naming conventions and white-space.
/***************************************************************************************************
**COMMS
The goal is to create the smallest most efficient communicat...
I have written a function that launches the default editor set in git config, right now I have managed to get it working for Sublime, nano and Vim.
def launchEditor(editor):
""" this function launchs the default git editor
set in git config for user to compose message
to be s...
After initially struggling with the board size, I have now decided the dimension. Please review my code. In the code I am generating HTML code using PHP and MySql. I have not added the database, please let me know how to add it in my question.
The key functionality is drawBoard() it has 3 parame...
I've written in Java, C/C++, and Python for a while; this is my first time trying Ruby.
These two functions search for directories with a certain prefix that contain no files of a given type.
Does the code adhere to Ruby standards and conventions? Am I doing something the hard way or the "non-R...
Would love some feedback on this, I'm coming from a Java background and kinda feel like I've just done exactly what I would do in Java. Is there a better way?
for (i <- 1 to 100) {
if ( i % 3 == 0 && i% 5 == 0)
println(i +" = FizzBuzz")
else if (i % 3 == 0)
println(i +" = Fizz")
...
Instead of both 3 and 5:
if (i % 3 == 0 && i % 5 == 0)
you can use 15:
if (i % 15 == 0)
You're also supposed to print the number if neither of cases apply:
else
println(i);
Maybe ........ ? I was following through on that meta answer, and the list of not-upvoted answers..... and found thi question had 3 good-looking answers, none of them upvoted...
All from big names.... figured it needed someone with domain knowledge to figure out why none of them voted for each other.
A discussion arose not long ago on the 2nd Monitor about how much reputation has been lost due to the reputation caps. There are a number of queries on the SEDE which try to address this:
A Users total Rep ON META if there was no reputation cap
Percent lost to reputation cap among top 1000 user...
I am scrapping an online shop page and I am trying to get the price mentioned in that page. In the following block price is mentioned:
<span id="hs18Price" itemprop="price" title="New Baby Care Pack">
<span class='WebRupee'>₹</span> 999</span>
I am using Beautiful soup to get this ...
@syb0rg When dealing with follow-up questions (i.e. when dealing with all that specific user's questions), versioning them might help a lot I think to get a nice little "timeline" of the questions. What would the alternative be: "Follow up to a follow up to a follow up about a package"?
I don't think that there is any problem. I have done this before in this and this. No problems occurred as long as I made it clear that it was changed code. If you look through my questions I have done it some more times. Too lazy to give all.
Some comments on your style of selecting:
div.pagination is overqualified. A container is almost everytime going to be a div, so you just can write .pagination
In many cases, there is no use for an extra container. You might as well apply the pagination class to the list itself: <ul class="pagi...
FizzBuzz is kind of a difficult example because its simplicity means it looks more or less the same in every language. That said, we can go out of our way to emphasize the functional aspect of Scala.
First, we can wrap the core logic of FizzBuzz up in its own function:
def fizzBuzz(x:Int) = {
...
@Jamal I don't really agree with the notice on the deleted answer here: codereview.stackexchange.com/questions/10167/… . The main reason why he's downvoted is that he's just plain wrong. If he would have been correct, that answer would have been fine I believe.
As for the question itself, although the question is on-topic, he seems like a troll to me. (I know, it's an old one)
I looked through the major SE sites and their logos and noticed they're nice and minimalistic. So I grabbed my sketch blog and a pen. This is what I came up with:
Update 1
Update 2
Huh.. Sometimes clicking on "Save Edits" simply doesn't work, only setting :focus but not firing the click event..
Checkout lol's t-shirt question.. The last image is "I <3 CR".
function RegisterN() {
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if (isset($_POST["password"],$_POST["password1"]) && $_POST["password"]!=$_POST["password1"]) { # Check if password and password1 are same
echo "Your password confirmation is not equal to your password or it missing.";
...
I'm looking for aid in correctness and possible improvements in the code.
Other concerns are possible errors that may occur and/or already exist within the code.
One main.py files, 3 enemy classes in separate .py files (modules I guess), a player class and a game files for importing all the b...
Write a function strend(s, t) which returns 1 if the string t occurs at the end of s, and 0 otherwise.
Here is my solution:
unsigned int strend(char *source, char *pattern) {
char *saver = pattern;
while(*source)
source++;
while(*saver)
saver++;
while(saver >
Here's my code, I want to make it OOP, want feedback from you on correctness, tidyness, design patterns and so on.
# -*- coding: utf-8 -*-
#Ignore the swedish comments, this is my project for my ICT education.
#Börjar med att importera alla moduler för att få spelkoden att funka här.
#Importera...
I have been working on a website template, so my clients can use it easily, here is what I have so far: www.loaistudio.com
Now I reached the optimization stage, and I really need some help, can anyone please review the following .htaccess file and let me if it is correctly put together?
What I ...
Happy with the style, that is the naming conventions and whitespace.
/***************************************************************************************************
**ALGO
The goal is a learning exercise and to possibly compare to native implementation speeds. Bubble
sort, selection sort, ...
It is the project euler problem 7.
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?
I believe that my code is working but very very slow.....
I guess increment divisor can be changed but not sure...
When you have a custom implementation of something, and it has internal structures, like, in your case, the BinarySearchTreeNode, there is no real reason to have the interface for it. There is no public use of the interface, and not even your actual tree uses it. It is redundant. You can delete i...
Is there a better way I can code this below? It's an old code and I'm not sure makes sense today. Jslint gives me a lot of error too. I dont have experience with JavaScript and I would like to optimize this snippet. Any suggestion? Maybe I can achieve a better code with jquery?
<script type="t...
As a first step to attempting the Weekend Challenger Reboot, I decided to first implement a regular 'tic-tac-toe' game and then expand it later to be 'ultimate tic-tac-toe'.
Below is the code for the tic-tac-toe board. It's fully functional and unit tested, but I'm not too happy about the getWin...
This code work fine and i hope it's write in correct mode.
Sorry for the italian's name of the fields inside the html code.
function richiesti() { //open function richiesti
var dati=0;
var cognome=document.clienti.cognome;
var nome=document.clienti.nome;
var codfisc=document.cli...
Is this your revised code from the reviews? It looks like it reading the reviews and this code. If so, you this is considered "Not an answer". See here for more details. — syb0rg2 mins ago
@SimonAndréForsberg And that is fine, since we know he will most likely include the code in his final implementation. Then we can improve it further there.
I'm seeing the potential for a while loop in there.