Click here to Skip to main content
15,914,400 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 10:30
mvahoney the codewitch16-Aug-19 10:30 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 10:59
professionalSander Rossel16-Aug-19 10:59 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:02
mvahoney the codewitch16-Aug-19 11:02 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 11:09
professionalSander Rossel16-Aug-19 11:09 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:16
mvahoney the codewitch16-Aug-19 11:16 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 1:35
professionalSander Rossel17-Aug-19 1:35 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 3:16
mvahoney the codewitch17-Aug-19 3:16 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:08
professionalSander Rossel17-Aug-19 4:08 
honey the codewitch wrote:
Because look carefully. In that loop I'm modifying the passed in collection.
The passed in collection isn't the Rules, right?
You're using the Count of rules, but you're adding to result.
In any case, I'd either use Count directly, like I did, or create the variable out of the for statement for readability.

I didn't know i++ created a copy where ++i doesn't (I know pre- and postfix, and that they're more efficient than i += 1, but not their inner workings).
That said, I always use i += 1 because the i++ is something for C(++)'s Big Grin | :-D
honey the codewitch wrote:
Yes I really like foreach, and I use it a lot. But not if I don't have to.
I use foreach always, except when I can't (because I need that index) Laugh | :laugh:
C++ vs. C# I guess.
honey the codewitch wrote:
alse HandleRules is unnecessary
Except to get out of that nasty seven times nesting Wink | ;)
It also reads a bit better, in my opinion, as it's clear that we're handling the rules in the for loop (which isn't directly clear in the original).
One level of nesting could easily be eliminated by taking two if's and combining them with &&.
honey the codewitch wrote:
Literally all you factored was the loop itself.
Well, what did you expect, that was the code I was given.
To me, it's more readable with less nesting.
I wish I could do something about the while loop, but that would require a lot more in-depth knowledge on what you're doing.
Personally, I (almost) never need while loops, so I'm pretty sure you could somehow do without.

You're dealing with difficult logic in a difficult language.
You were complaining about the many nestings that you couldn't change because of the many states you keep, and for that I've given you one solution in this particular method.
Whether you like the solution and if it meets your (performance) requirements is up to you Big Grin | :-D

GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:14
mvahoney the codewitch17-Aug-19 4:14 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:27
professionalSander Rossel17-Aug-19 4:27 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:30
mvahoney the codewitch17-Aug-19 4:30 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:32
professionalSander Rossel17-Aug-19 4:32 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:41
mvahoney the codewitch17-Aug-19 4:41 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:06
dandy7216-Aug-19 5:06 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:08
mvahoney the codewitch16-Aug-19 5:08 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:11
dandy7216-Aug-19 5:11 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:12
mvahoney the codewitch16-Aug-19 5:12 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:16
dandy7216-Aug-19 5:16 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:20
mvahoney the codewitch16-Aug-19 5:20 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 9:31
professionalJon McKee16-Aug-19 9:31 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 9:35
mvahoney the codewitch16-Aug-19 9:35 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 10:33
professionalJon McKee16-Aug-19 10:33 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 10:35
mvahoney the codewitch16-Aug-19 10:35 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 9:39
mvahoney the codewitch16-Aug-19 9:39 
GeneralRe: when algorithms attack Pin
Jörgen Andersson16-Aug-19 5:44
professionalJörgen Andersson16-Aug-19 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.