Skip to main content

All Questions

Tagged with
-1 votes
2 answers
4k views

Loop pattern for batch data processing

When processing data sets in batches I usually can think of the following three implementations. Which one do you consider better than the other and why? Notes: The implementation is in C# but the ...
Botond Botos's user avatar
-4 votes
1 answer
139 views

Is there any formula or trick to count how many times a statement inside a nested loop gets executed?

I am modifying a software which is for trash collection. While reading the code, I asked myself is there any formula or trick to quickly calculate the number of time the statement gets executed inside ...
AKdeBerg's user avatar
0 votes
2 answers
320 views

Permutations for time in JSON

Let's say that I have a JSON file like at example below. How would I go about finding all possible values of item combination time sums that exist between let's say 00:03:04 to 00:25:55 without ...
user2676326's user avatar
7 votes
1 answer
357 views

Automatic Realtime Cycle Detection of function calls

I am running into a wall mentally when trying to think of a way to solve this problem. At my work we process customer data through some complex reasoning logic. Sometimes this logic will cause ...
Hangman4358's user avatar
2 votes
2 answers
3k views

Efficiency considerations: nested loop vs recursion

I would consider myself an intermediate Python programmer. One of my recent challenges was creating a list of all possible solutions to a given Countdown problem. Without getting into too much detail,...
IliaK's user avatar
  • 23
0 votes
1 answer
139 views

how to reach all nodes in a Tree Structure where end of the tree is unknown

There is a XML link, which provides the children of any parentID given. http://www.browsenodes.com/xml.php?action=BrowseNodeInfo&node=1036592 Then you can run the URL again with a children ID ...
brainHax's user avatar
  • 103
-2 votes
2 answers
621 views

Find index of string in an array of strings where overlap could occur

I am having some trouble writing a variant of sub-string search. Essentially the goal is to write a method that can perform sub-string search except that the source data is in an array of Strings ...
AbuZubair's user avatar
  • 145
0 votes
2 answers
3k views

Refactoring method with nested loops and 6 variables [duplicate]

I have a method which implements a small section of a (complex) algorithm. This algorithm has taken me several weeks to perfect and is by far the fastest method I can find. The method in question has ...
o.comp's user avatar
  • 135
2 votes
2 answers
290 views

How to iterate between these elements

I have an array of elements: int[] elem = new int[] {A, B, C}; I need to calculate the sum of ALL the combinations of those elements, where only some of the elements can be optionally selected. I ...
Juan Carlos Oropeza's user avatar
39 votes
2 answers
84k views

General way to convert a loop (while/for) to recursion or from a recursion to a loop?

This problem is mainly focusing on the algorithm, maybe something abstract and more academic. The example is offering a thought, I wanna a generic way, so example is only used as to make us more ...
xqMogvKW's user avatar
  • 543
1 vote
2 answers
766 views

Sorting Sentences by New Words in Each

A very useful learning tool I stumbled across for Chinese was a massive list of sentences that, barring the first 10 or 15, only differed by the ones before by one or two words, or at least as few as ...
William Brun's user avatar
-1 votes
1 answer
122 views

Finding "spare time" in a day from within a list of events

I have a list of events which is always sorted chronologically. The start time is always followed by the end time. Times are strings formatted as 'HHmmss'. // list of events var events = [ '...
MFB's user avatar
  • 105
3 votes
4 answers
385 views

Indefinite loops where the first time is different

This isn't a serious problem or anything someone has asked me to do, just a seemingly simple thing that I came up with as a mental exercise but has stumped me and which I feel that I should know the ...
George T's user avatar
  • 295
1 vote
1 answer
2k views

Is there a purely SQL alternate to looping?

Historically, I probably would have written a script (php or something) to loop through all spreadsheet rows and perform some calculations. I'm looking for a pure SQL solution on the presumption ...
mOrloff's user avatar
  • 211
3 votes
4 answers
9k views

Complexity in nested loops

Foreword: In this post, I will make the common confusion between O(n) and Theta(n) as complexity notations. I will write pseudo-code to talk about algorithms, using whatever notation I find to my ...
Pierre Arlaud's user avatar

15 30 50 per page