Questions tagged [loops]
The loops tag has no usage guidance.
13
questions
0
votes
0
answers
16
views
Optimize Working Live Search & Highlight Function
I've written a custom Live Search & Highlight function in vanilla JS. It is working and does what I expect it to.
The issue is that the more items I add to the page content to search, the slower ...
1
vote
1
answer
104
views
Calculate directed acyclic graph dependency level [closed]
This code calculates the directed acyclic graph dependency level for each row of the pre-sorted CSR-format lower triangular sparse matrix lower. The result is used ...
3
votes
1
answer
116
views
VBA code used to build a diverse portfolio of DFS lineups to minimize risk
This code works great and does exactly what I want but it takes around 10 minutes for the code for find 150 lineups. I am hoping to get help and learn how to make it much faster.
The goal of this code ...
1
vote
2
answers
121
views
Printing a pattern of input string in X shape
Context:
Write a program to print the output for the given input(Example is given in comments of my code). String is of odd length.
I would be grateful if anyone could give feedback on my following ...
3
votes
1
answer
80
views
Search through all the sub-folders in a given folder for files
I use the below code to loop through a list of data and search through all the sub-folders in a given folder for files which match my requirements.
Right now it takes this code about 22 minutes to run,...
0
votes
1
answer
71
views
Replace iterrow loops in pandas matrices with something else to shorten the running time
This post is modified from this one: https://codereview.stackexchange.com/posts/292885/edit (Alternatives to iterrow loops in python pandas dataframes).
I have a piece of code to calculate price ...
5
votes
2
answers
663
views
Alternatives to iterrow loops in python pandas dataframes
I have a piece of code to calculate price sensitivity based on the product and its rating.
Below is the original data set with product type, reported year, customer’s rating, price per unit, and ...
7
votes
5
answers
3k
views
Check if license plate number is formatted correctly
I'm just learning Python and am looking for some feedback on some of the code exercises I've completed and do work. In particular, what would make them more Pythonic, or more closely align with ...
2
votes
1
answer
39
views
Maintain a log containing values if certain conditions are met
I'm trying to capture profits and set a stop loss in my trading strategy. I want the stop loss to be set daily based on the past data and if the current price, i.e., price for the date falls below the ...
3
votes
1
answer
98
views
In Java, replace for loop with condition with lambdas [closed]
I want to replace a for loop with a break/return condition inside with a lambda.
I think I have a good replacement, but I want ...
2
votes
1
answer
191
views
Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms
I was doing the Hackerrank "New Year chaos" problem. Here is the description:
It is New Year's Day and people are in line for the Wonderland
rollercoaster ride. Each person wears a sticker ...
3
votes
1
answer
115
views
Performing tasks on for-loop over thousands of items in Rcpp
I am trying to adapt an R script that I wrote to perform several tasks in a for-loop. The for-loop run over thousands of items, for about 900 times, therefore I would like to optimise my code at the ...
3
votes
2
answers
298
views
Calculate the base 10 log with loops in Java without using Math
I'm looking for a simple way to calculate the logarithm without using java.lang.Math, just out of interest.
Here's my try (I adopted some code parts from this ...