4,960 questions
0
votes
0
answers
19
views
is this a new line character input buffer? [duplicate]
enter image description here
when i entered number of columns, after hitting enter got the newline character within the input buffer.
enter image description here
i was expecting this kind of result.
...
0
votes
3
answers
57
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
43
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
39
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
39
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
113
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
52
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
27
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
38
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
91
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 ...
1
vote
3
answers
64
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 ...
0
votes
0
answers
50
views
How would I go about creating a loop that tests variables in sequence to determine the source of the entry?
In creating a user form application where I enter in customer information, I want to have the information I type into the Entry boxes do two things: 1) Update in real time to a label off to the side ...
1
vote
0
answers
70
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
54
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
65
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
195
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
159
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
69
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
1
answer
52
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
92
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
37
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
39
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
35
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
0
answers
18
views
Analytic Formula for counter inside unique nested for loop for parallelization
Is there an analytic formula for c, such that the outermost loop on i can be parallelized so that c can be computed for any given iteration of i, j, k? N is known. The code is iterating through all ...
0
votes
1
answer
65
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
91
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
45
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
71
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
78
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
21
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
80
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
83
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
131
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
138
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
58
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("...
0
votes
4
answers
119
views
Why does this code write the answers more than once instead of just once?
I've just made a C program about finding perfect numbers. It is kinda working, but it writes out the answers more than once(and it writes 24 as well for some reason).
I have very basic C knowledge, I ...
0
votes
0
answers
12
views
Can't access object in nested loop (JS and three.js) [duplicate]
I have a question about JavaScript and Threejs.
I made an object title_and_coord that stores sentences and their Vector3 coordinates (for wherever each sentence appears in my scene). I am trying to ...
1
vote
2
answers
73
views
C language pattern with unexpected result
I am trying to create a program in C to draw this pattern :
1 1 2 1 3 1
1 2 2 2 3 2
1 3 2 3 3 3
1 4 2 4 3 4
1 5 2 5 3 5
I checked the answer from solutions.
#include <stdio.h>
int main ()
{
...
0
votes
1
answer
63
views
Parallel processing for nested loops isn't working correctly in R
I'm trying to run a nested loop using the parallel() and foreach() packages to increase speed, but I'm not having success.
I have a dataframe where the first column is a categorical data and the ...
1
vote
1
answer
72
views
VBA nested if-do-while to sum values
What I'm attempting to do:
Loop through 2 worksheets (same workbook), comparing 2 criteria (farm and batch). If criteria match, then sum the values in the 'No. of Samples" cells and paste to &...
0
votes
0
answers
59
views
Flatting out multiple nested dictionary into a dataframe for use in data modeling
I am slowly working through different python courses to teach myself Python. After taking courses for ~ a month I started to work on building a model using a data API feed from DataGolf.
The data is ...
0
votes
1
answer
129
views
Terraform Nested loop for.each example
I'm attempting to create nested loops to iterate over each environment (dev, qa, uat) and build target group attachments for the target IPs associated with each environment.
Here's what I have so far:
...
2
votes
1
answer
66
views
When processing a matrix, the c++ code, finding in each of its lines, does not write out a line with the minimum amount, but simply the first line
I need to write a code, with instruction:
Write a program that finds the row with the minimum amount in the matrix. If there are several such lines, find the first such line.
My code:
#include <...
0
votes
1
answer
36
views
In a three nested for loop with labeled break, why is the output the same when the labeled break is positioned in the inner and middle loop?
Why is the output exactly the same when the labeled break is positioned before the start of the middle and inner loop?
Example code 1 - When break point is positioned at the start of the inner loop
...
-1
votes
1
answer
101
views
LibreOffice Calc - Check if event date is in period of time and return event attribute
In spreadsheet like this:
A
B
C
D
E
1
Shift start
Shift end
Sum of event durations on that shift (min)
2
01.03.2024 15:35
02.03.2024 08:00
105
3
13.03.2024 15:35
14.03.2024 08:00
120
4
28.03....
4
votes
1
answer
90
views
How to make nested for-loop more efficient?
I have the following code, which I would like to speed up:
foreach (var workflow in closedWorkflows)
{
var w = relatedWorkflows.FirstOrDefault(r => r.Fingerprint != workflow.Fingerprint &&...
2
votes
1
answer
34
views
Modification pgm fill 2-D Array using a pointer and it doesn't work
Initial pgm
void assign( int **mat, int n, int m ) {
int **p = mat;
int **p_end = p + n;
for ( ; p < p_end; ++p ) {
int *q = *p;
int *q_end = q + m;
for ( ; q < q_end; ++q ) {
printf( ...
0
votes
1
answer
67
views
How to code calculation of Walsh & Lawler Rainfall seasonality index in R
I am struggling to loop across multiple variables that require counters to calculate rainfall seasonality. I end up getting errors due to counters not functioning correctly or in the correct order. I ...
0
votes
1
answer
71
views
Get list of options that have multiple sub options
I've bee trying everything I can, but I just can't seem to wrap my head around this. I have a microsoft teams auto attendant and this has multiple Menu Options assigned. I can load the menu options ...