« first day (526 days earlier)      last day (3507 days later) » 

12:02 AM
@EngieOP I used to, but don't really play it anymore.
 
Ditto ^^
 
0
Q: repeating problem with Simon says game?

CaptainCodyoverview 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 ...

 
Simon says: This question is off-topic. — Simon André Forsberg 1 min ago
 
12:19 AM
Darn
 
@EngieOP why are you asking?
my brother plays it a lot, even has his own server with about 20 or so players on it
hmm... 666 views...
28
Q: FizzBuzz in Brainfuck

Simon André ForsbergInspired 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 tag? I want it supported in Android, but the code itself really has nothing to do with Android.
11
Q: A Scoring approach to Computer Opponents

Simon André ForsbergThis 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...

I don't think that just because you intend for a library/code to be supported in Android, that the question should be tagged with Android.
 
Seems no need for that tag, agreed.
Monking, all, BTW
 
Monking @rolfl
 
Canada celebrtes Thanksgiving this weekend... Like the Turkey, I'm stuffed
So, no real mod duties for me tonight, lots of food, and more than enough wine ;-)
 
@rolfl funny that you were the one who added the tag... 5 months ago :)
 
12:30 AM
I was?
 
> I am using Java 6 because I need to support Android. I also need to support GWT which makes String.format impossible.
I probably would have
The tag is still probably OK.
 
I removed the tag
 
now that I look at it, without the tag, people will make suggestions that are not appropriate for Android, which is a requirement
 
If it should be tagged Android, then it also should have a GWT tag.
I think stating that requirement in the question is enough
 
12:34 AM
I think with the tag it's OK and without the tag it's OK.
Your call.
 
without it is then :)
 
@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
 
The reason it's on there, technically, is [badge:generalist], for the most part
 
@EngieOP never heard of the mod, I have used Lua though.
@rolfl lol, desperate needs calls for desperate measures
 
I'm not going to lie....
But, even now, looking back on it, the tag makes some sense. It's not a cheat.
I would rather people overtag things than undertag them... and a person who followed would have some unique insights to it.
 
12:50 AM
nvm, no worries
 
1:00 AM
TTGTB
 
People are not talking about code right now, or CR. So... I feel I can exclaim that 30 out of 50 states in the USA no longer deny marriage between gays!
Sorry for political-ish post, I just feel it is significant. It is effective Oct 6 '14
 
1:16 AM
0
Q: Caesar Cipher - JavaScript encode function return is undefined

Earl SwitzerI 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...

 
1:31 AM
u like my ad lulz? ( ͡° ͜ʖ ͡°)
 
 
3 hours later…
4:09 AM
0
Q: How to avoid mounting SQL by concatenating strings?

fotanusI 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...

 
 
2 hours later…
6:07 AM
0
Q: Optimizing a divide-and-conquer algorithm for counting inversions in Haskell

wei2912I have the following code: inversions :: (Ord a) => [a] -> Int inversions xs = snd $ countInv' (xs, length xs) countInv' :: (Ord a) => ([a], Int) -> ([a], Int) countInv' ([], _) = ([], 0) countInv' ([x], _) = ([x], 0) countInv' (xs, n) = (sorted, leftInv + splitInv + rightInv) where ...

 
6:24 AM
0
Q: Using Custom Attributes to Populate Members from IDataReader

druciferreJust 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...

1
Q: User-defined classes for a box

JamesWe 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(){}; ...

 
7:06 AM
0
Q: Evaluation of a solution for Run-length encoding algorithm

JackI 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...

 
7:26 AM
except it has many of its own problems, so it's well worth reviewing, again
 
also +1
 
he-he
time to get breakfast
 
8:17 AM
Hope your breakfast includes bacon. Engie's favorite.
 
user image
2
 
8:40 AM
Congratulations, @janos, on reaching 20k!
 
wow, fast reaction time. thanks @200_success
 
Well, I did just upvote one of your answers.
 
he-he, ok
 
I was finding this question a bit troubling, though:
5
Q: Delaying execution of a function

Sean AndersonI 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...

MyObject, foo(), and bar() seem to make it hypothetical.
 
yeah, I think this would have been better on programmers, not really code review material
 
8:44 AM
Flambino kind of pointed that out, but didn't explicitly say so.
> I'm a little confused about the intended use of this object.
I think I'll migrate it to Programmers.
 
I agree
 
Then again, there seems to be too much code and therefore not quite right for Programmers either.
It would feel like we're sending them our crap.
(Though it's not quite a crap question either.)
 
@JaDogg I really like it!
 
it's kind of borderline. If it might not be liked on programmers, then better to keep it.
@mariosangiorgio good one @JaDogg
 
I'll just close it with an explanation.
 
9:00 AM
monking
 
Thanks, dont think I will use this site again..... — Ronald 2 mins ago
 
That sounds like a mutually beneficial arrangement.
 
Give us time to explain?
Hm. Maybe my rollback ended up removing the working code (I didn't bother to look for differences). I have to go to bed soon anyway.
 
I commented on it to clarify for him
monking @Christoph
I don't think he deserves downvotes
 
Neither were mine. I'm actually in a good mood now.
 
9:06 AM
he just posted on the wrong site, and misunderstood the close message, that's all
 
Downvotes on off-topic questions are still normal, though. In the event that they're not improved, it helps with the cleanup process.
 
I don't think it should be normal. Downvoting is a harsh response, it should be used for bad questions. This isn't nearly bad enough
this should be migrated to SO
 
10:04 AM
Monking
 
monking @skiwi
 
Another coding day :)
 
Another rainy day here.
 
0
Q: Create a graphic nodes without a lot of dynamic casts

Jesus ChristWe (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...

 
Time to fix this stackoverflow error inside a security manager...
I found something yesterday night on phone though
7
Q: Why does my custom SecurityManager cause exceptions the 16th time I create an object with Constructor.newInstance?

templatetypedefI 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...

 
10:13 AM
Above question ... looks like example code?
   if(dynamic_cast<BigGuyEntity*>(entity)!=nullptr)
   {
        graphicNode = new BigGuyNode(entity, some_other_params);
   }
 
@Phrancis Entity is often a good name, especially when you work with virtual and runtime polymorphism.
 
Is some_other_params a good name too? lol
 
Hahaha, of course.
Of course not, I totally missed that one.
 
10:44 AM
Java's security/permissions model seems completely broken to work with :|
 
11:11 AM
@Morwenn do you remember me asking about disallowing non-local storage of an object?
 
@Christoph Honestly, I don't remember.
 
	<!--
	-- This file adds the following data tags to cards:
	-- <ID>
	-- <NAME>
	-- <DESCRIPTION>
	-->
Is this a decent way of multi-line commenting a XML file? ^^
 
well, you said "good question" (or something similar). I found out how: programmers.stackexchange.com/a/258741/112996
 
Oh, I kind of remember now. I will read your Q&A :)
Anonymous struct in a for loop declaration hidden by a macro? That's ballsy.
 
226
A: How do I comment out a block of tags in XML?

Noon SilkYou 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>

 
11:20 AM
Thank you Simon :)
 
@Morwenn I had to look up "ballsy" and now I'm not sure if that's a positive reaction ;)
"reckless", "courageous", or "potent"?
 
@Christoph Well, that looks kind of awesome, but I believe that misused, it can go terribly wrong.
 
0
Q: Java package organisation

user2405469I 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 ...

0
Q: Calling new classes

ProlinerI 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...

 
@Morwenn probably
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.
 
11:39 AM
*we* know, but the target "audience" is mainly beginners. They already know

ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
...do stuff with interrupts disabled
} // interrupts automatically restored

And the hardware acquire/release block macro I wrote works just like that. They're used to this kind of construction
 
You should explicitly document that it is built on the top of a for so that the behaviour with break, continue and no block is known.
 
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. — Zyre 9 hours ago
If that will be removed before going into production, that code isn't ready for review.
 
@RubberDuck
That's all well and good. Next time it would be best to state this in your question to avoid confusion. — Phrancis 14 secs ago
 
0
Q: C++: What would be the preferred naming convention for open source lib

GabiMeI 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 ?

 
Thanks @Phrancis.
 
11:51 AM
@Morwenn well, what do think might happen? Who would use break or continue in a block that doesn't start with a "loop"-type statement?
 
@Christoph Inner loop, or your block being put inside a for loop.
 
hm...I didn't think about that. could there be a workaround for those situations?
 
Document.
That's why I prefered the scope guard solution: it is hard to misuse it.
 
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
 
Other advantage of a guard: that's not a macro.
Also, it is a pattern common enough, so people generally know that it is not to be stored.
 
 
2 hours later…
1:34 PM
0
Q: DFS on a binary tree, written in Java

user3371223I 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(...

 
2:31 PM
1
Q: Loading Screen Animation: DRY Code

user3476070I 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...

 
@RubberDuck you were not exact enough :(..
Then please include code to be reviewed. For more information about what is on topic, please see our help center. — RubberDuck 2 hours ago
 
3:01 PM
Reached a whole new low...
java.lang.RuntimeException: The forked VM terminated without properly saying goodbye.
 
3:15 PM
0
Q: Double Linked List remove method

Sillicon TouchI 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...

 
> You've earned the [winforms] tag badge.
@RubberDuck woah, we managed to get badgeable before ! :)
 
3:31 PM
 
3:58 PM
Anyone wanna give me $16 (USD) to renew my Domain?
@EngieOP Where is the original picture without the text?
 
@Malachi you could sell your linux box for that much I guess ;)
 
@Mat'sMug lol. I need it!
 
4:19 PM
0
Q: Have the user input a positive integer. Output the numbers from 0 to the inputted value in increasing order

MajidSo 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.

0
Q: Generic logging class for tracing the function calls in C++

Mantosh Kumar#include<iostream> #include<string> using namespace std; // Generic class for tracing the function call class functionlogging { private: string name; string in{ ">>" }; string out{ "<<" }; public: functionlogging(string x) :name(x) { cout << in << name << endl; } ...

 
4:41 PM
Oh JavaScript...
 
what....really!? (I never used JS, so...*really*???)
 
4:58 PM
that's too frustrating to read on a sunday, yet I just read it. damn.
 
5:21 PM
@Malachi I just Google Image searched lul
 
5:37 PM
I know @Vogel. I saw that. =(
 
0
Q: Top-down movement

TwiggySo 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 ...

-1
Q: Website to submit your own C program

SamuelJust 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!

 
6:06 PM
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
 
0
Q: Perfect elimination ordering and high memory usage

mnathe 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...

 
@mariosangiorgio Beginners should self-identify with the tag... tag if they want to be handled as a beginner.
 
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. >.>
6
 
^^^ my policy as well.
 
ok. that's why I asked
 
6:09 PM
@rolfl A question to you... Have you ever worked with AccessController.doPrivileged in Java?
 
no.
> : 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.
 
Ok, then no point in asking the question here... Seems like I'll need to use SO if I cannot figure it out
 
6:34 PM
1
Q: Iterative Fibonacci sequence using standard library functions

user55893We'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...

 
7:21 PM
4
A: Breadth First Search not SOLID enough v2.0

Jesse C. SlicerI'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); } ...

^^^ Just sayin.... still undervalued.
 
0
Q: C++ Unrolled Linked List with Iterator

Data_Structs_AnonymousI'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...

 
Congrats on 20K @Janos !!!!
9
 
Congratz @janos!
 
 
And now it's a race between konijn and I for 20K.
 
7:31 PM
@rolfl You're late
11 hours ago, by 200_success
Congratulations, @janos, on reaching 20k!
Congratulations btw, @janos. Getting that Epic badge soon?
 
@SimonAndréForsberg What ... I'm not allowed to congratulate him .... (yeah, I was awol at the time ;-).
 
@rolfl I feel threatened by him for a spot at the first row, so no, you are not allowed :)
 
and you're closing in on palacsint.
Nice answer,BTW
 
0
Q: Circular Buffer implementation in Ruby

gitarchieDoes 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...

 
@SimonAndréForsberg By my counts (which are slightly inaccurate, but I don't know how inaccurate), you are both now neck-and-neck: data.stackexchange.com/codereview/query/160805/… at 44
 
7:41 PM
@rolfl thanks santa!
@rolfl codereview.stackexchange.com/reputation shows 41 days for me
 
and mine shows 90 ..... (not 96).
Theres a inconsistency in the data which makes it impossible to get right.
 
ok
I have a feeling that @janos will get Epic before I do
 
7:55 PM
thank you guys, @rolfl @skiwi @SimonAndréForsberg :)
 
0
Q: The simplest method to find the number of working days between two dates inclusive?

In PSTricks we trustThe 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 = ...

0
Q: Java - guess the number game

chritschlI 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 ...

 
8:40 PM
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..
 
If anyone with experience of Java is bored and wants to learn a new API...
0
Q: Why can I break out of a restricted AccessControlContext?

skiwiI'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 ...

@JeroenVannevel That's rather interesting
Still that same issue as you discussed last week?
Would be perhaps be easier to work with if I understood the API I'm using
 
9:01 PM
0
Q: One-Time Pad Encryption

ProgrammerSo 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 ...

 
He does 5 new exercises each week. I'm getting a free education in mathematical exercises in Python by helping him
 
9:30 PM
@JeroenVannevel have you figured out what went wrong? I'm quite curious to know it
 
@mariosangiorgio spawnPinkPonies was set to true
3
Nah, some different interpretation about the input
I read the exercise as "read it line by line"
he read it as "read one big chunk immediately"
so he tested it differently
I told him to ask a tutor how we should do it
 
Fair enough
 
9:45 PM
Congrats @janos!
 
9:56 PM
Hmmm.... if you ask a question, and part of the description says "Parts E and G don't work properly", and the question gets closed.....
.... is it OK to remove the part of the description that says "Parts E and G don't work properly" so that the question is now on-topic?
(admittedly there's the parts A,B,C,D,E,F,G,H ..... only E and G were/are problems).
Hi @Mat's
 
@RubberDuck No, I have not. The context and its purpose are very clear without those unnecessary details. — user16547 24 mins ago
Was I wrong to start the close process? ^
 
10:20 PM
@RubberDuck Absolutely not.
What is clear to him is apparently not clear to me.
 
0
A: Find the number of working days between two dates inclusively

Jeroen VannevelPersonally, 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...

The joys of overengineering
 
@rolfl I believe it sometimes is beneficial, yes. If parts A,B,C,D,F and H can work together on their own and don't depend on parts E and G.
 
Okay. Thanks @Simon. Just wanted to double check.
 
10:37 PM
0
Q: Is this question closed inappropriately: "Operating on files from source directory"

rolflI 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
 
That's my feeling too, it is "known broken code", just because the description no longer admits it, does not change it.
 
@JeroenVannevel I would define it premature optimization, not overengineering
 
@rolfl I think this edit was good though:
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. — tim 2 hours ago
 
I just passed 2,000 reputation and gained access to moderator tools. It's time to celebrate (and almost time to go to bed)
5
 
10:43 PM
CELEBRATION TIME! Whoo Hoo!
 
@SimonAndréForsberg I would agree with that too.
 
@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)
 
@mjolka I'll have a look at it
 
@mariosangiorgio ta :)
 
10:49 PM
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
 
ah, i haven't checked OP's code, was just comparing it to jeroen's
which afaict is correct
 
I'm just gong to check how a difference between two DateTime instances is defined
Yes, both the OP and me are off by one
 
i tried just adding 1 but that didn't fix it
definitely worth pointing out that OP is off-by-one in your answer though
 
Sure. I'm going to figure out the right way to solve it and I'll edit my answer. It is a bit strange that adding 1 didn't fix it. I'l write some tests
 
cool, looking forward to seeing/trying to understand the fix :)
oh and congrats on the 2k!
 
11:07 PM
can you tell me what is the input you're testing and is not fixed by adding 1?
These test cases all passes if I add 1
https://gist.github.com/mariosangiorgio/54e55cd82e56a007fef5
 
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
plus more
this is the change:
        return 1 + workDaysInFullWeeks(days) + workDaysInPartialWeek(start.DayOfWeek, days);
 
thanks
I think the fix is this:
var days = (stop - start).Days + 1;
 
that still gives me different results (this is all assuming Jeroen's code is correct, which may be a wrong assumption)
private static int GetNumberOfWorkingDays(DateTime start, DateTime stop)
{
    var days = (stop - start).Days + 1;
    return workDaysInFullWeeks(days) + workDaysInPartialWeek(start.DayOfWeek, days);
}
i, a, b = 5, 5, 4
i, a, b = 12, 10, 9
i, a, b = 19, 15, 14
i, a, b = 26, 20, 19
but given that it's monday here, i=5 should return 5
 
11:23 PM
yes, definitely
I think the culprit is when I subtract -2
If the parital week ends on a saturday I need to subtract only 1, not two
 
I hate data processing.
Isn't the right advice in this context, to use Skeet's library?
 
yes, using the appropriate library is the first advice I gave on my answer
but I wanted to write some code
2
 
^^^ that's something I can relate to
 
(failing miserably for now. But I'm close enough to the working version)
 
you know what would be cool? if you could edit commit messages and squash using gitk
 
11:35 PM
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
 
well, you can edit just the last....
(or am I wrong, can you go back further?).
 
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.
 
Urgh, yuck. OK. I hate being wrong.
 
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..
 
11:46 PM
@mjolka I think I have the fixed version now codereview.stackexchange.com/a/66439/17000
 
@mariosangiorgio just saw it, looks like it works :)
 
@mjolka finally :)
now it's really time to go to bed. Thanks for spotting the bug
 
np, goodnight
 
@mjolka Seems like I am using the -i option not often enough.
 

« first day (526 days earlier)      last day (3507 days later) »