@Jamal as much as I like seeing that declaration in big capital letters, I think it (and all related posts, including this one) should be vacuum-cleaned, politics don't belong here. (removed)
@retailcoder pffff.... why so PC? Canadian politics is like kindergarten whereas when it comes to hiockey.... then you really see what canadians feel....
I was wondering if there's any way I can improve this code to execute faster: I want to use it on a 10*10 grid, but it takes too long to solve this 4*4 This program takes as input a 4*4 matrix represented as a 1d matrix and it returns the solution to the puzzle in the variable solution Any commen...
I asked a question on StackOverflow recently and had trouble with the MarkDown processor: the code block would not render as code despite being indented four spaces. I've not had this trouble before; maybe the StackOverflow devs have been tinkering and have broken something? It seems to be connec...
OK, weekend challenge.... we all solve the Rock Paper Scissors Lizzard Spock problem with our 'favourite' language, and we all have to post a question here with our solution to be reviewed.
I'm working on my framework constructor. First I tried to look into jQuery and understand it, but it's so out of my league. Instead I googled and put this code together. Though there aren't many posts about creating a framework. Anyway, since I'm not a guru I might be doing it the wrong way or mi...
@rolfl Since @Malachi shotgunned c# I'll try to do mine with vb.net. That one being my favorite language is a long, long, veeeeeery long stretch though.
@rolfl "No reason why we have to choose unique languages....", thank goodness - Otherwise I would have to fight you for Java. Or are you planning on using COBOL? (Good luck finding a reviewer for that... You'd have to review it yourself)
But what exactly is the challenge? Should we code an AI for the game of rock, paper, scissors, lizard, Spock?
I need to preprend N spaces to a string to make it 10 characters in length. I came up with the following method, but since it is going to be called often, I want to ensure it is optimized. Could this be made more efficient?
public static string PrependSpaces(string str)
{
StringBuilder sb = ...
If you add the tag wiki, I sort of agree with it... although it should be more formal, like rock-paper-scissors - "Use this tag for reviews of any of various implementations of the famous game"... but @Jamal might vaporize it and edit our posts with game
Rock-paper-scissors-lizard-Spock is an expansion of the classic selection method game rock-paper-scissors. It operates on the same basic principle, but includes two additional weapons: the lizard (formed by the hand as a sock-puppet-like mouth) and Spock (formed by the Star Trek Vulcan salute). This reduces the chances of a round ending in a tie. The game was invented by Sam Kass with Karen Bryla, as "Rock Paper Scissors Spock Lizard".
The game was mentioned in four episodes of The Big Bang Theory. According to an interview with Kass, the series producers did not ask for permission to ...
@retailcoder I am trying to work on both monitors. but I have the tv going as well and I only got like 4 hours of sleep last night. and I am having doubts about my skills as a C# Coder, and don't want to look like a loser.....
The following is a program that lets a Human play "Rock Paper Scissors Lizard Spock" against the computer.
Comments, critiques, suggestions are welcome and encouraged.
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
/**
* Rock Paper Scissors Lizard Spock
* <p>
* ...
"Scissors cuts paper, paper covers rock,
rock crushes lizard, lizard poisons Spock,
Spock smashes scissors, scissors decapitate lizard,
lizard eats paper, paper disproves Spock,
Spock vaporizes rock. And as it always has, rock crushes scissors." ...
This program is supposed to be a player VS player Tic-Tac-Toe game. The computer then checks whether you've won, lost, or tied. The code does work, but I don't want it to work through hacking; I want it to be done the right way.
Sub Main()
'Initialise variables
Dim StrCoordinate(3, 3) As Strin...
Also, after some consideration, I'm wondering if we should add some game-specific tags such as tic-tac-toe and rock-paper-scissors. It would probably just be for these games since they're the most common. Others can just stay with game. What do you think?
I have a huge collection of list elements. the concept is that the user can select only two items from that collection. I am showing a check/Uncheck as an image infront of the list item, just for visual purposes that the list is selected or not. The image is defined in a class, so I have to switc...
Is it correct to use a parameter's property which is object (navigation property) in our methods?
If yes how the developer who uses my method should know which properties are required?(you can see requirements is nested)
If No what is the solution? Please give me some design patterns, references...
I am trying to make this code work. My inital concept is to have a configuration file to keep all the variables that are static and use them in various other files in calculations in order to return values to my main. In this code for example I want to get the date values from my configuration, c...
@retailcoder: I've killed pong anyway; it only had two questions and seemed to have stayed that way. But yeah, you have a good point. We're not a gaming site, either.
import javax.swing.JOptionPane;
public class DividedBy10v2{
public static void main( String[] args ){
int block[][] = new int[3][3];
int DetermineRow = 0; // The variable assigned for counting rows
int DetermineColumn = 0; // The variable assigned for counting columns
int bloc...
It was sitting there for a while, so I assumed it wasn't going to be looked at for a while. Or do you all only wait for questions to appear in the feed? :-P
I've done this piece of code for creating samples without repetitions, but I think that it is a so heavy algorithm because every time I call this recursive function I create a new vector that is passed to it. What means create any samples without repetitions? it means creating every combination g...
@rolfl: I see you don't have the Cleanup badge yet. Perhaps you may want to roll back this question. The edit just consists of an update specifying that the question has been answered on SO, although it can still receive additional answers here.
I have a huge collection of list elements. the concept is that the user can select only two items from that collection. I am showing a check/Uncheck as an image infront of the list item, just for visual purposes that the list is selected or not. The image is defined in a class, so I have to switc...
The Challenge
Create an implementation of "Rock - Paper - Scissors - Lizard - Spock".
The rules:
Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper disproves Spock, Spock vaporizes r...
I am new to code review, and to PHP also.
Last night I made the below image uploading class. It was the first time I made a file uploader to be used on a real site, so I thought I would share it here and on Github to get some reviews, hoping if I can perfect it with your help, I will use the cl...
The Challenge
Create an implementation of "Rock - Paper - Scissors - Lizard - Spock".
The rules:
Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper disproves Spock, Spock vaporizes r...
Three men are talking: A programmer, a doctor, and a lawyer. The lawyer says, "Man, the only way is to have a mistress. With all these divorce suits, it's terrible
The only way is to have a mistress." The doctor says, "Are you kidding? With all the STDs out there, you want a wife and that's it."
The programmer says, "You need both a wife and a mistress. Because when you're not with the mistress, she'll assume you're with your wife, and when you're not with your wife, she'll assume you're with your mistress, and THAT leaves you more time to be in the lab programming!"
@SimonAndréForsberg I looked at it a little bit, but not much. I am going simple or trying to anyway.
since it is a Console Application, just use Writeline, just have the application spit the important stuff out to the Console.
I did something Similar in an application that I created to export PDF's from a SQL Server Database back into PDF Format
you can do it many different ways. if you are co...
going to a movie with my Kids.
weird Ubuntu, said I spelled movie wrong
this is one of my Questions that I finally answered because I had to.
I need to write an application or Query to export a large amount of PDF's to file and create a delimited text file that shows where the files are and contains the ID of the record.
what I was thinking about doing was using a console application that would write the entry to the text file after e...
Can someone please highlight to me the problem With my main method? I am getting the error exception that scanner is closed? Thanks
public class Assignment2 {
/**
* Scanner used for input within program
*/
public static Scanner scanner = new Scanner(System.in);
/**
* Main method that provid...
Also, I think I fell in to the 'get-it-done-fast' trap, and it shows.
My wife teaches kindergarten. They have a scale from 1 to 4. 1 is struggling, 2 is meets minimum requirements, 3 is does things well, and 4 is does everything well, and extends beyond the problem at hand and shows advanced thinking.
Your's is a solid 3.
Mine is a weak 3.
No-one has hit a 4 yet.
@retail-coder shows some advanced thinking, but, based on other answers to his question, he is not hitting enough of the level3 items to rank a 4.
@rolfl Yeah, I especially fell in the "get-it-done-fast" trap when I used override on my players. If I only would have paused for a short moment and thought it through....
@rolfl I am considering writing a review on your code, but since you've read my code, it feels like you already know what you can improve :P
@rolfl Thanks! @SimonAndréForsberg I don't like how I determined what wins over what either, and Svick's answer is correct, my usage of IComparable<T> is wrong... that's where I got into get-it-done-fast - we all have weak spots :)
I have an algorithm that evaluates in input byte[] with a source byte[]. Several conditions can be encountered:
Match found
No match found
End of input array
End of source array
Input wildcard (*) matches against any source byte
All of these conditions are dealt with in this algorithm. Havi...
I have the following mysql select statement. It is working fine except that the code is too long. I have been trying and looking through internet how I could make it shorter. Please can anyone of you make it shorter?
SELECT regd, Subject, Section, date,
SUM(CASE WHEN (Name_of_exam = 'First Un...
I trying to implement cubic spline interpolation based on the algorithm from Wikipedia, but I received very bad results.
x(0) is points.get(0), y(0) is values[points.get(0)], α is alfa and μ is mi. The rest is the same as in pseudocode.
public void createSpline(double[] values, ArrayList<Integer
@Jamal - prng's are not actually that complicated.... and for the degree of randomness you only need to beat what a human could guess. Using the modulo of the system CPU ticks would be enough.
This problem begs for recursion....
private static final void checkWord(char[] chars, char[]current, int len, List<String> results) {
if (len == chars.length) {
final String result = new String(current);
if (sortedDictionary.contains(result)) {
results.add(result...
I am doing infix to post fix notation. my program complies, although, for some reason it will not take in any infix expressions, only postfix expressions. Which is the opposite I wanted to do. Here is my program:
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
using nam...
@Jamal Only @retailcoder has included that message so far. Both Rolf and I simply write who wins instead, without a specific covers/eats/vaporizes message.
@Jamal Just be prepared for the review when it comes! (On the other hand, I think C++ code usually tends to be more procedural-oriented than C# and Java)
I can, but I still don't like KOing questions too often since the community does well at closing. We're much smaller than SO.
Let me clarify this: if both players' moves do NOT correspond to one of those combinations in the rules, does that imply a win for you? On the other hand, do you lose if one of the move combinations match?
Sorry to throw that in out of the blue like this, but @Jamal would it be appropriate to create a follow-up to tag questions that are following-up on another?
@Jamal Well, besides the fact that all the rules actually map out to all the possible combinations (besides if both are equal), I think that if there is not an available rule then it should be considered a tie.
I could put this into Ideone for any of you to test first. For the input, you just need to put in 1-5 (each corresponding weapon). It may just work with one turn, but that's okay.
This post is following-up on Rock-Paper-Scissors-Lizard-Spock Challenge
I had a gut feeling that I was somehow abusing IComparable<T>, @svick's answer confirmed that.
As @dreza was posting his answer I was in the process of proceeding with exactly that refactoring: stuffing the SelectionBase c...
Sometimes I stumble upon follow-up questions, where code is being posted again after having gone through a review (or two).
Examples of possible sets of follow up questions:
Find missing numbers - Find even more missing numbers - Even more missing numbers
Binary search tree - Another binary s...
Your solution requires that you create a new Vector for every combination. You are right that there is no better algorithm. The way you have it implemented though, is not as efficient as it should be.
Float should be a primitive.... float. Using a Float object instead of the primitive float will...