4,963 questions
0
votes
1
answer
127
views
Trouble cycling through values in a for loop and filling a list in R
I'm trying to estimate the population growth of a population with different growths rates, shown below
r <-c(0.5, 1.0, 1.5, 2, 2.5, 2.6, 2.7, 2.8, 2.9)
I'm trying to fill N_List with the ...
-5
votes
3
answers
138
views
How does control flow work in nested loops in C? (Understanding execution order) [closed]
While practising nested loops in C, I wanted to understand how control flows between an outer loop and an inner loop. I understood that the inner loop runs for each iteration of the outer loop, but ...
3
votes
1
answer
89
views
Problem with nested loop logic and indentation in python
I am trying to re-run a nested for loop within a while loop if the while condition is not met. If the condition is met then I want the inner loop to terminate and proceed to the next iteration of the ...
0
votes
2
answers
159
views
Nested for-loop alternative
I have a python code that calculates a function F(X), where both F and X are arrays of the same shape. F(X) uses another function called from a package that only accepts a scalar as an argument, but I ...
0
votes
4
answers
111
views
VBA code to Fill excel rows in column with dates and time, using only weeksdays and per day displaying 13 hours incremented by 15 minutes [closed]
I'm trying to fill rows in several columns with dates and time from given start date to given end date to create a schedule.
In the first column I want the date displayed as "year", 2nd ...
0
votes
1
answer
62
views
Nested For loop in bat with arrays
I'm trying to figure out how to get this nested loop to work without delayedexpansion. My original block shown below works as intended, but after writing it, I discovered I can't save the changes to ...
1
vote
1
answer
95
views
Finding Numerical Relationships between Columns
I have selected a subset of numerical columns from a database and I want to iterate through the columns selecting a target_column and comparing it with the result of a numerical operation between two ...
1
vote
1
answer
62
views
How do I calculate the time complexity of this problem?
I'm trying to determine the time complexity of the following code. It has a nested loop structure, and inside the inner loop, a recursive function is called. I want to understand how the recursive ...
0
votes
1
answer
60
views
Approaches To Optimize Nested For Loops and Dataframe Creation?
I am not very experienced with coding but I am creating a customtkinter application style script where a user can input a specific type of html that contains diagnostic addresses and various ...
0
votes
0
answers
95
views
Lua table index changes its values without assigning any to them
Lua table (ref) index changes its values without assigning any to them.
Why does ref table change its values after assigning it to tab[c] or using string.match()? The actual behavior is that the ref ...
0
votes
0
answers
135
views
Explanation for VHDL loops not going to completion
I am making a mockup CPU in VHDL. I am using Vivado for simulation and programming environment. I need help understanding why my simulation won't follow through with the nestled loops.
I need ...
0
votes
0
answers
34
views
How do I deploy multiple CosmosDB accounts with Databases/containers using ARM templates without nested loops?
Let me preface this with the fact that I am new to ARM templates.
I am trying to create a template that will created a bunch of CosmosDB accounts, databases, and containers based on a config file that ...
2
votes
1
answer
117
views
Is there a smart way to vectorize a nested for-loop where the inner index is limited by the outer index?
Is there a smart way to vectorize a nested for loop of inner products, where the inner index is lower bound by the outer index?
Here's a simple example. Say that arr1 and arr2 are numpy arrays each ...
0
votes
1
answer
55
views
What is the difference between writing in one and two lines when transporting a matrix? [closed]
If the replacement of elements is written in two lines, then the matrix is transported incorrectly
x=[[i for i in list(map(int,input().split()))]
for _ in range(int(input()))]
print("Result:...
0
votes
2
answers
118
views
How to loop through dimetial array using VBA in excel?
I'm trying to create a file that transpose the data in on row to multiple rows and columns. Currently using an array. I can get the first row to look the way I need in order to load it into our system....
0
votes
0
answers
298
views
How can I optimize Elliott Wave detection in large cryptocurrency datasets?
I am working on a Python program that identifies Elliott Wave patterns in cryptocurrency market data. The current implementation uses nested loops and exhaustive searches, which makes it ...
0
votes
0
answers
77
views
How can I print all possible x-letter words in python using loops? [duplicate]
How can I print all possible words of a user-specified length "x" in python? I already know how to do it for a specific number of characters like all possible 3 letter words by using for ...
0
votes
3
answers
125
views
The best way to reduce the calculation time of formulas in nested loops?
Could you tell me what is the best way to reduce the calculation time of formulas in nested loops? I have code like this:
for k in range(0, 130):
for i in range(0, 1600):
array2[i,k] = 0
...
2
votes
2
answers
73
views
Why this nested loop generator does not seem to be working?
I was trying this:
tuple(map(tuple, tuple(((x,y) for x in range(5)) for y in range(3))))
I got this:
(((0, 2), (1, 2), (2, 2), (3, 2), (4, 2)),
((0, 2), (1, 2), (2, 2), (3, 2), (4, 2)),
((0, 2), (1,...
-2
votes
1
answer
40
views
How do I set up range based on loop counter?
I am new here and I do not have much experience. I greatly appreciate any advice you may provide.
I have a 2D array representing staff scheduled to work on a particular date. The data looks like this ...
0
votes
1
answer
43
views
R For loops and Simulations [closed]
set.seed(2024)
#conditions
b1<-c(-0.3,0.3)
b2<-c(-0.3,0.3)
conditions <- expand.grid(b1 = b1, b2 = b2)
# some other conditions
sample_size <- 200
nsim<- 10 #number of simulations
#...
1
vote
2
answers
127
views
Nested loops with recursive functions
Could some one help me how to implement below version of nested_loops with recursive_loops? I was able to generated the exact output what I want using nested_loops, but it is always limited to 3 loops....
0
votes
1
answer
55
views
How to speed up the passage of a nested loop in Python
How to speed up the passage of a nested loop. I am doing browser automation using Selenium and in one section of the code I need to compare coefficients and dates with table cells. The code needs ...
0
votes
0
answers
35
views
Blackjack game loop sometimes hang after standing
For an assignment, I'm making a Blackjack game in Kotlin. The catch is that each player has a player skill that allows them to modify the results of their next draw.
Here is the important game loop:
...
0
votes
2
answers
48
views
How to consolidate list of inner elements from map into a map with a value of set type
Hello I'm trying to convert a set of bucket notifications defined as follows to a map: sequence structure so I can iterate over the sequence with a dynamic block in my bucket notifications.
...
0
votes
1
answer
159
views
How to create a Terraform nested loop for Azure with inner and outer loop
I'm trying to figure out how to use what I think might require a nested loop in Terraform.
I have a module that creates Azure storage accounts from a list of storage accounts.
I would like to extend ...
0
votes
3
answers
88
views
Looping with Multiple Arrays
i am having trouble creating an efficient code that loops and returns the result for 7 scenarios starting in a particular cell and having each scenario return in the cell immediately below the ...
1
vote
0
answers
76
views
Problem parallelizing nested inter-dependent loops for arrays assignments
I am learning omp and came across nested loops involving arrays assignments etc. with details:
Loop indices are inter-dependent
Arrays a, b, and c have been initialized
I am using Visual Studio 2022 (...
0
votes
2
answers
90
views
Trying to figure out the best and worst case time complexity of a function. Is it possibly that worst and best case are the same?
I've been asked to find the best and worst case time complexity "in terms of their running time as a function of input size, n." I'm pretty new to Big O but I was doing okay will the other ...
0
votes
1
answer
68
views
Reducing length with a loop
I have a class which has a series of loops inside of it. Each loop uses a pandas.dataframe to add data to a new list that can be called as an instance attribute.
data = [player_stats, ...
1
vote
4
answers
227
views
How to combine 3 for loops into 1?
#include <iostream>
using namespace std;
int main()
{
int count = 1;
// Declaring 3D array
int array1[3][4][5];
// Initialize 3D array using loop
for (int i ...
1
vote
2
answers
189
views
Iterator for nested loops unrolling in C++
Very often I have nested loops at least two-level depth where elements from the same container interact which each other. Imagine interaction of particles in physics.
This leads to two cases of the ...
0
votes
1
answer
84
views
Why is my Rust code suddenly almost freezing for slightly larger values?
I am making a fun program to find magic squares of squares. I have 9 nested for_each loops corresponding to each of the 3x3 numbers of the square. I use the constant LIMIT to set how many square ...
0
votes
1
answer
34
views
String folder structure with all matching folders listed
I've been trying to do this for a few days and really I'm struggling. How do I generate all possible scanned folders from the string below and replace all possible folders in %%%ANY_DIR%%%?
$...
1
vote
2
answers
94
views
postscript: how to make two nested for loops
Want to print a raster of circles in a rectangular frame. Found example of one loop, worked fine. Added a second loop inside, no good; I only get a single column of circles. Suggestions welcome!
% ...
2
votes
1
answer
114
views
how to pandas fast nested for loop for "non numeric" columns?
how to pandas fast nested for loop for "non numeric" columns?
because this for loop is way to slow:
for i in range(len(df1[column_A]):
for j in range(len(df2[column_A]):
if df1[...
0
votes
0
answers
45
views
Implementing nested loop in Ansible
I wanted to know how to implement nested loop concept to schedule a job in task scheduler which schedules 2 executables,
This is my source yaml
---
scheduledTasks:
# 2 ACTIONS PLEASE CHECK
- name: ...
1
vote
1
answer
51
views
Nested for loops too slow - PHP Codewars Kata Integers: Recreation One
I was working on the codewars kata Integers: Recreation One:
1, 246, 2, 123, 3, 82, 6, 41 are the divisors of number 246. Squaring these divisors we get: 1, 60516, 4, 15129, 9, 6724, 36, 1681. The ...
0
votes
0
answers
36
views
How to loop through all values between a set of values in nested loops and get all combinations of values in python
My goal is to find the minimum of some function "V" on a condition curve "R=0" V and R are both functions of variables X, Y, D, L. I need as outputs all of {X,Y,D,L,V,R} so i can ...
0
votes
1
answer
67
views
Trying to find a Wordpress (PHP code) that will work well
I need help figuring this out. I need to display different posts and pages in a loop but I am having challenges nesting them. I am not sure that's the right word to Use but I am pasting my code below ...
-1
votes
1
answer
106
views
Terraform Nested or For Loops to provision Azure Resources
So I have a Terraform locals.tf file which has the below content to represent a set of environments I intend to deploy to:
locals {
environments = [
"sandbox",
"test", ...
0
votes
0
answers
48
views
Order of nester requestAnimation frame seems incorrect
What I want to achieve is 2 loops (anim1 and anim2), while anim2 contains nested loop internalAnim2
The output of the following code should be:
anim1 - 4 times (= a1Max)
and 5 times (=a2Max) those 3 ...
1
vote
1
answer
80
views
Loop models multiple times
I am trying to run the following code multiple times with different values for the 'aux' object.
time <- seq(0, 30, 1)
stock <- c(sK=0, sF=1)
aux <- c(aH=0.4, aRel=0.5, aRes=0.5, aS=0.8)
...
-2
votes
1
answer
110
views
How to Convert Nested for Loops with Multiple Internal Loops into map() Function? [closed]
I was trying to speed up some nested for loops with multiple internal loops in python 3.11:
for item1 in iterable1:
for item2 in interable2:
if condition == true:
expression1
...
0
votes
0
answers
23
views
Difference in Output Between Two Similar C++ Codes with Nested Loops and transform
I'm experiencing a strange issue with two similar pieces of C++ code that are supposed to perform the same task but yield different results.
The problem is around the inner loop statement .
While ...
3
votes
1
answer
86
views
Remove In Nested Loops (Remove Inside Foreach) [closed]
These are my entities:
public class Permissions
{
public string PermissionName { get; set; }
public List<Controllers> controllers { get; set; }
}
public class Controllers
{
public ...
-3
votes
1
answer
88
views
How to Display All Repetitive Digits from a String ? in vb.Net
String = 24-06-1966
repetitive Nos to be displayed 6, 6, 6
Non-Repetitive Nos to be displayed 2, 4, 1, 9
Hello
If someone can help me to get or displayed Repetitive digits from Numeric String
...
-2
votes
3
answers
139
views
Getting random symbols after trying to replace chars in C++
I'm trying to replace every letter in string to next letter (a -> b, c -> d, etc.).
I get random symbols or XXXX after compiling and running the program.
#include <iostream>
#include <...
0
votes
1
answer
146
views
Use vectorised functions instead of the loops
My function is such that it takes the minimum over the range of dataframe which keeps increasing in length and maximum over the dataframe which reduces in length with each iteration.
The dataframe ...
1
vote
1
answer
61
views
Store result from nested for loop with two factor variables
I'd like to generate some simple calculations for each combination of two factor variables and store the results in a data frame. Here are the data:
df <- data.frame(SPECIES = as.factor(c(rep("...