overview of the assignment: Simon says game of 4 level, random number 1-4 only;start with one digit then keep adding until hit the user input level. i have few problems, and i cant seem to find them. main one is the menu of asking level keep repeating after one digit being put by user. i believe ...
Inspired a bit by a previous Brainfuck question and the recent fizzbuzz invasion, I decided to make FizzBuzz in Brainfuck.
The code is entirely my own, except for the inclusion of the Printing a number algorithm that I found on StackOverflow.
My code is divided into several parts.
Setup Const...
@rolfl Didn't notice this until now, do you really think this question warrants the android tag? I want it supported in Android, but the code itself really has nothing to do with Android.
This code is starting to be used within several of my projects, and therefore I thought it's time to get it reviewed.
Description
The most common application for this code is that there is a computer opponent in a game which needs to make a decision based on some parameters. A list of all possi...
@SimonAndréForsberg I was messing around with ComputerCraft. A mod that allows you to program turtlebots using Lua. Just wondered if anyone else has used the mod before. :p
I am not sure if my code is right, but it is returning undefined. I think the problem is right here:
http://jsfiddle.net/qjdxj2y2/
return text.innerHTML = ciphertext;
I don't know what to return, and my logic and variables might be off.
HTML:
<form action="#" method="get" onsubmit="return f...
I found myself mounting a query by concatenating strings. This just seems wrong. Any ideas of how to avoid this kind of situation?
I'm using Rails 4, and I don't see how can Arel make things better for my case.
def self.search(params)
# query example
# SELECT "jobs".* FROM "jobs" WHER...
Just learned how to use custom attributes in C# and the first useful thing I did with it was to make a class object representing a database table. The constructor can accept an IDataReader and populate the members based on the custom attribute. Is this a good usage of custom attributes?
[Attrib...
We have just learned about classes. Please help me improve this program. I created a class called Box with members that represent its dimensions. Then I calculate the volume and surface area and print it.
#include <iostream>
using std::cout;
using std::endl;
class Box
{
public:
Box(){};
...
I wrote an answer for the following question and wondering if there is any better approach to it.
Using the Java language, have the function RunLength(str) take the str
parameter being passed and return a compressed version of the string
using the Run-length encoding algorithm. This algor...
I have an object with an arbitrary number methods and a property indicating whether it is ready or not. The methods can be called before the object is ready, but should do nothing until it is ready. When the object becomes ready, if a method was called beforehand, it should re-run the last called...
We (the team of developers) write a small game for iPhones.
We have an architecture, where the logic of the game entities is separated from their view on the screen.
When we create an object, that must appear on a user's screen, we add it model (class, representing the object's state) to the l...
I am currently working on developing a small Java application in which trusted code must be run alongside untrusted code. To accomplish this, I have installed a custom SecurityManager that throws SecurityExceptions any time a permission is checked.
As a bridge between the trusted and untrusted c...
You can use that style of comment across multiple lines:
<detail>
<band height="20">
<!--
Hello,
I am a multi-line XML comment
<staticText>
<reportElement x="180" y="0" width="200" height="20"/>
<text><![CDATA[Hello World!]]></text>
I am not really sure how to organise my Java packages, for example let's say I have these classes:
Vehicle.java
VehicleType.java (an enum containing car types)
VehicleFactory.java (some factory class for creating vehicles)
Car.java
Plane.java
Motorcycle.java
SpaceCraft.java
Main.java
would you ...
I have looked on the internet for this question but couldn't find my answer.
I have a switch in the index.php file. When there is a value in the $_GET['page'] and it matches the switch it includes a page for example: www.website.com/index.php?page=home. So basically you always be in the index.ph...
but without that wrapper, the code that uses the resource would need to make sure that there's always a matching pair of acquire() and release() calls, and that can be quite tedious to sort out sometimes, especially in longer blocks with many exit points
Why do you explicitly want some specific use ccase to fail? You coud simply put in the documentation "use as a guard,do not store". Scope guards can be stored but we know that they shouldn't be, and so w don't store them.
Can someone straighten out a new user for me? I'm too angry about this comment to be nice.
The "ERROR" message is for me personally for reference while debugging and will be removed when code goes into production. Your reply/post is off topic and does not contain any contextual constructive advice. — Zyre9 hours ago
If that will be removed before going into production, that code isn't ready for review.
I am going to release an open source C++ lib.
I use snake_case for all classes and functions but seems CamelCase is more popular amongst open source projects.
What notation would be preferred ?
I could probably provide both options: dumb block macro that fails inside a for loop, and a guard that works the same way but should not be stored anywhere
I wanted to write depth first search reaversal, iteratively on java. Can someone review my code? I'm not that much interested in naming of the variables, but in the structure of the code, i.e. I don't need to mark the nodes as visited, when I traverse binary tree, right?
public static void dfs(...
I am trying to make a loading screen but my code isn't dry! How could I make it dry? I have thought about using css3 keyframes but I might have problems cross-platform.
$(document).ready(function() {
var lc = $('.loaderContainer'),
wh = $('.welcomeH'),
th = $('.toH'),
meeuh = $('.me...
I am implementing some basic data structures to freshen up my memory and I wanted my DoubleLinkedList remove method to be reviewed. I feel like it has extra checks but I could not think of another way to implement.
My implementation holds both the head and the tail of the list making things a bi...
So i want t be able to input a number then the program should input integers up-til the number The users input. e.g. user inputs 12. Program shows the integers 1,2,3,4,5,6,7,8,9,10,11,12.
So I've been working on a Final Fantasy-ish game. I'm leaning toward more like 1 - 3. This is my attempt at map movement. It does work. But if anyone has any suggestions or critiques, I would like to hear them. Such as is there a different way you would do something or is there a way I can clean ...
Just wondering if anyone knows of some good websites that user's can submit their own programs. I am looking to distribute a program I wrote so that I can get some feedback.
Thanks!
What is the policy to tag a question with "beginner"? Looking at the way he designed his class I'm fairly confident the author of this question is a beginner http://codereview.stackexchange.com/questions/66419/top-down-movement
the following code calculates a perfect
elimination ordering in a special case in Haskell.
I am less worried about its correctness than
its high use of memory. The following code runs
out of memory on my computer. It seems it should be
possible execute the algorithm without ever having
more than...
I don't add the beginner tag unless the author explicitly states he is a beginner or he states he has just started learning the language. I don't think it's right to assume...tho I could be wrong. >.>
> beginner : Add this tag to your question to indicate that you are new to the language of your code. This will often be taken in to consideration by reviewers when assessing your code.
We're all aware of Fibonacci sequence calculators but they look like C-style code. I want to avoid that and take advantage of the standard library. This code is very short, so I'm focusing on readability and correctness.
Barring comments, will people be able to understand the code just by look...
I'm a fan of developing to interfaces and language-provided immutability, so I've refactored your Node and Edge classes to that end:
INode interface:
public interface INode
{
string Name { get; }
IEnumerable<IEdge> Edges { get; }
void AddEdge(INode targetNode, double weight);
}
...
I'm making an Unrolled Linked List (Linked List with an array of 50 in each Node) for a class project with an iterator. In addition, whenever more than half of the arrays are unused (they would all be at the end of the chain), I should deallocate half the unused arrays. The code is all written an...
Does the implementation look correct? Did I miss something major/minor
class CircularBuffer
class BufferEmptyException < StandardError; end;
class BufferFullException < StandardError; end;
def initialize(size)
@size = size
@buffer = []
end
def write(data)
raise Circul...
The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusive?
My effort is as follows
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = ...
I just started to learn Java and had to write a "guess the number" game.
It works quite well for the most parts, but one thing is missing. If the user types "exit" (in the guessing part) the programm should terminate. It would be great if someone could help me with this task, as I really don´t ...
I hate it when you give people the exact code to execute and somehow instead of adding 1 + 1, it starts spawning pink ponies from wormholes on their machine
5
Same Python version, exact code inside a gist ready to execute. How much can go wrong..
I'm figuring out how to run external code (from a different JAR) without permissions such that it doesn't harm my own system. I have it almost working, however I've come to find a strange situation where a call to System.exit(0) still kills the whole system.
The idea is that different JARs will ...
So my one-time pad program is working partially. It is supposed to return null if its key's length does not equal the phrase's amount of letters. Otherwise, it should encrypt it properly. It is able to encrypt any word/phrase with a length of a number between 1-7. After that, if the length is an ...
Personally, I think your approach is very complicated for what it should be trying to do: loop over all days between the start and the end date and count how many of those are not in the weekend.
Translating that sentence to code, gives me this:
private static int GetNumberOfWorkingDaysJeroen(D...
I have been asked to evaluate the close reasons for this question here:
Operating on files from source directory
Has been closed "off-topic - example code".
Is the question actually on-topic?
If it is off-topic, is the 'example-code' the right close reason?
@rolfl In this case, no. I would leave it closed. A "bad access code exception" is... bad. The OP is aware that the program crashes, so it's knowingly not working. It would be better if the part that is causing the crash is removed completely from the program, then the rest could be reviewed (assuming that the rest can work without it)
Furthermore, I would actually consider rolling back the edit to make it perfectly clear that the code is not working
Welcome to CodeReview. This isn't really a place to ask for help implementing new functionality (I edited your question to be on-topic). But we are more than happy to review the code that you do have. — tim2 hours ago
@mariosangiorgio another problem with the working days q, workDaysInPartialWeek should be workDaysInPartialWeeks. it also seems to be off-by-one (should be inclusive of both start and end dates)
I think that the original code is off by one too. It computes TimeSpan interval = stop - start; I looked at the implementation and I overlooked when the question said it wanted both the dates to be included
var start = DateTime.Now;
for (int i = 0; i < 600; i++)
{
var end = start.AddDays(i);
var a = GetNumberOfWorkingDaysJeroen(start, end);
var b = GetNumberOfWorkingDays(start, end);
if (a != b)
{
Console.WriteLine("i, a, b = {0}, {1}, {2}", i, a, b);
}
}
first few difference:
i, a, b = 0, 1, 0
i, a, b = 1, 2, 1
i, a, b = 2, 3, 2
i, a, b = 3, 4, 3
i, a, b = 4, 5, 4
i, a, b = 6, 5, 4
i, a, b = 7, 6, 5
i, a, b = 8, 7, 6
i, a, b = 9, 8, 7
i, a, b = 10, 9, 8
ah... that's with your code as-is. adding +1 gives:
i, a, b = 5, 5, 6
i, a, b = 12, 10, 11
i, a, b = 19, 15, 16
i, a, b = 26, 20, 21
One of the nice things about git is that commit messages cannot be edited. .... I have found a few occasions in the past where changing history has make more problems than it solves.
It also makes people more thoughtful, first time around.
sure you can edit them, git commit --amend or git rebase -i. it's a local branch that i want to clean up before pushing. i should definitely try to be more thoughtful first time around though
you can go back further, try git rebase -i HEAD~10
# Rebase 21505e6..973cf8d onto 21505e6
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
i think i've become overly reliant on it... i have a couple of commit messages that are just squash and then later i have to go back and find them all..