Tagged Questions

Loops are a type of control flow structure, in which, a series of statements may be executed repeatedly until some condition is met.

learn more… | top users | synonyms

-2
votes
0answers
26 views
3
votes
1answer
22 views

Merging predicted values into measured values

I created the following function below to merge the real values with the predicted values (when real are absent) in a new column in data.frame. The function ...
-3
votes
0answers
14 views

Very basic password checker [on hold]

Pretty obvious what I'm trying to do, how do I make it loop back to the "If" statement after the second input? Started last week, sorry for my newness, cheers. ...
4
votes
2answers
214 views

Scaling jsTree performance

I am using jsTree v1.0 (latest v3.0, they withdraw support from older versions) to display the hierarchy in my application. It was good until until I started showing groups/user up to 200 levels, but ...
4
votes
1answer
44 views

Number-guessing game with maximum and minimum values

This is a simple guessing game where you are prompted for a minimum and maximum value, then you must guess the number the computer chooses! This is the first program I have written so any and all ...
5
votes
3answers
270 views

Avoiding label in a loop to sort links

How can I refactor my code to remove the label and the need for it? I am aware that a loop with label is "forbidden". But I can not find a way to rewrite this without the label. ...
0
votes
0answers
6 views

Getter within loop returning null after assigning values [migrated]

I've got a slight problem with my program. Simply put, what I do is this: Choose the option to "Add a new Student record". When I try to display the newly added values (First Name, Last Name, ...
4
votes
1answer
101 views

Using array values to create variables, if statements and highchart dataset

I am trying to make my script maintenance-free by replacing some "static" variables and labels with dynamic ones. The main function of my code is to extract data from a SharePoint-list which contains ...
4
votes
1answer
48 views

Efficiency of looping though a text map to draw objects

I am making a game that uses a text map to draw obstacles and courses for the player to navigate. However, I am concerned that my method of looping through the text map to draw objects on the screen ...
4
votes
1answer
58 views

Speeding up nested for-loop analysis code

I have two matrices, the first one is mat 2000*500, the second one is 6000*500 ...
3
votes
0answers
50 views

Another way to loop this code in AutoHotKey

I have a working AutoHotKey code, but I am curious if there is a better/shorter way to do this loop: ...
3
votes
1answer
47 views

Fast counting of interactions between groups given users interactions and groups assignments

Given: An array c that contains the group assignment of every user (c[i]=4 indicates that user i belongs to group 4) A matrix ...
3
votes
1answer
34 views

Loop through products and return first product that matches criteria

I am writing a function which loops through an array of products. The function needs to return: the ID of the first product that has an image and is ...
-2
votes
1answer
57 views

Count percentage of audio samples exceeding a threshold

I have this practice question that I have an answer to: In this stage of the project, you will identify any "danger" spots, in which the SPL is greater than or equal to 80 dB (the value above ...
2
votes
1answer
30 views

Simple for loop to calculate headers size based on a specific ratio

How can I improve the following for loop (wannabe function) to create harmonic sizes for headers based on a specific ratio? ...
10
votes
4answers
2k views

Possible antipattern: looping until a search condition is met

Whenever I write a loop, I always use closure if it's appropriate by way of a self-executing anonymous function. I will typically write my searching loops as follows: ...
6
votes
3answers
981 views

Generating a not-the-same-as-last-time random number

I have to generate random number which differs from the number generated last time. Which of these two variants is better? Or maybe you can suggest better implementation. ...
1
vote
2answers
79 views

Notifying Students in Courses - Strategically

I have the following implementation, and hope to get suggestions on how to improve the code. treeListViewModel.Courses is an observablecollection ...
5
votes
1answer
86 views

Vector comparison inside for-loop

The following code finds no-rain periods in a time series that were preceded by rain over a threshold (e.g. 10mm in 2 days [k=48]). ...
4
votes
2answers
51 views

Determining if a discount is valid for a product

I'm in the process of re-writing a method I've come across in our code base. It's pretty lengthy and a lot of it seemed redundant. It's a Discount object class ...
6
votes
1answer
70 views

MicroC task switching

My background for this review is a university course in embedded systems using MicroC and this question. Now my program appears to run ok, but I'd like to know what you think can be improved or if the ...
3
votes
0answers
35 views

Simplifying the building of an adjacency array starting from a flat structure

Purpose: to make an adjacency PHP array with parent_id, name, level and ...
6
votes
3answers
186 views

Panagram Solution - Best approach?

I want to check if the given string is a Panagram or not. A Panagram is a sentence containing every letter of the alphabet at least once. This is what I've come up with as solution: ...
0
votes
0answers
44 views

Speed up Pandas DataFrame expansion to include time-lagged information about events

Using pandas and Python 3, information about a simple timeseries data set is being processed. Within the span of .5 seconds, 3 names are being said. We record the onset of each utterance, the length ...
5
votes
2answers
213 views

Applying different filters within loops

What I have is an outer loop which loops through a list of strings, followed by another loop which loops through a list of filters; and if the current column is the current filter in the list of ...
6
votes
2answers
199 views

Array from file

I have this code which is performed each time I click the 'show polygons' button. The problem is that it takes a few seconds to finish running through the code before actually drawing the polygons + ...
5
votes
1answer
101 views

Using Reddit API in R

I'm scraping some comments from Reddit using Reddit JSON API and R. Since the data does not have a flat structure, extracting it is a little tricky, but I've found a way. To give you a flavour of ...
4
votes
3answers
407 views

More efficient loops to generate unpronounceable words

I wanted to write a function to generate only unpronounceable words. I realised afterwards that the same thing could probably be achieved by just taking out the vowels. Regardless, I feel that there ...
2
votes
2answers
65 views

Optimizing a particle filter weighted selection step

I have a vector with 10000 particles that I use in a Particle Filter. The problem is that it's taking too long to compute the weighted selection of the particles. I want to use a vector of weights ...
5
votes
1answer
86 views

Pausing a SwingWorker with a Timer

I made a SwingWorker which is fetching tweets using the twitter4j API. The twitter API will allow 180 queries every 15 minutes, and then throw an exception with ...
4
votes
3answers
220 views

More efficient and readable nested loop to compare keywords

I've created an algorithm which weighs the relevance of a list of articles against two lists of keywords that correlate to attributes of the article. It works great and is super efficient... but it's ...
3
votes
1answer
70 views

Where is the bottleneck in my Cython code?

The profile tells me it took ~15s to run, but without telling me more. ...
7
votes
1answer
122 views

Incrementing letter-spacing of one line of text

I was asked to create a script which will increment the letter-spacing of one line of text, until its width matches that of the first line; for use in headline/subheadline text to maintain a block ...
6
votes
1answer
272 views

Sorting numbers into bins

I have two 2D arrays of doubles a and b. Both have two rows and different numbers of columns. ...
4
votes
2answers
76 views

Finding matching strings in a column

I have col D (in sheet1 called Students), col A (in Sheet2 called Students too) and col B ...
3
votes
1answer
43 views

Showing the domain of a URL

I have such a method which takes a URL, such as http://twitter.com/ttt or twitter.com/dasd, and should show its domain with http: http://twitter.com and name twitter ...
3
votes
2answers
80 views

While loop uses extra variables - can this be cleaned up?

A piece of my program allows the looping and incrementing of a targeted entity to be used in a while loop somewhere else. Here is a sample of the while loop: ...
5
votes
3answers
2k views

Assigning value to cells with Excel VBA

I have an Excel Worksheet consisting of two columns, one of which is filled with strings and the other of which is empty. I would like to use VBA to assign the value of the cells in the empty column ...
3
votes
1answer
125 views

Is this roulette selection extension method beautiful or disgusting?

So I just wrote the following extension method to do roulette selection on a generic list. I'm specifically unsure of the use of the while loop. Is this beautiful or a disgusting mess? ...
3
votes
6answers
282 views

Looping through an array of strings containing approximately 3 million elements

I have a function that loops through an array of strings containing approximately 3 million lines of strings. My problem is this loop is running too slowly and I want to know how to make it faster. ...
5
votes
1answer
65 views

Periodically checking for internet connection

I have a SwingWorker which checks periodically for an internet connection and updates a jLabel accordingly. ...
6
votes
2answers
97 views

Basic Imitation of C# Enumerable in VBA - or any other static class

Since implementing static classes in VBA actually seems possible I came up with an idea to try to imitate C#' Enumerable class (well, to some extent...). This is ...
1
vote
2answers
809 views

Printing the sums of numbers from 1 to 10 with only 1 loop

The code below prints sum from 1 to 10: 1 1+2 = 1+2+3 = 1+2+3+4 = ...... 1 + ... 10 = 55 ...
2
votes
3answers
1k views

Foreach loop to generate HTML table with title in first cell of each row in PHP

I've used quite a lot of foreach loops to achieve this type of HTML table that has titles in the first cell of each row: ...
7
votes
3answers
431 views

Ticket management system

I am building a ticket management system for a state server we use at work. Back end is node.js with multiple front ends. I am rewriting my back end to be more maintainable as the scope grows. For ...
5
votes
3answers
54 views

Faster way to group email-date pairs by date without many nested for loops?

Given list of pairs (email-date): ...
6
votes
2answers
312 views

Improving performance for Codility max slice swap problem

Problem Description: Find the maximum sum of a compact subsequence of array elements after performing a single swap operation. Solution: ...
3
votes
2answers
97 views

More efficient way to draw bufferedimage into another

For what I'm doing, I need to be able to draw a buffered image directly into a larger buffered image. I've searched around a little and still have failed to find a better way, but my current way is ...
3
votes
2answers
139 views

Multiple loops versus multiple stringbuilders

I've come across the following piece of code in a Razor view ...