273 questions
0
votes
2
answers
121
views
How to create a nested list dynamically inside a for loop and append it recursively to the final result set?
I have the following python script that I would like to modify in order to create a new nested for loop inside the for j in i["attributes"] loop to retrieve dynamically for each customer_id ...
0
votes
2
answers
137
views
Why an integer has different value even when its position is not changed
I was trying to do one coding questions solve, that says:
Write an alternate version of squeeze(s1, s2) which deletes each character in s1 which matches any character in the string s2.".
Well i ...
0
votes
1
answer
185
views
Getting 'Fatal error index out of range' in two layer Lazy Stack with using ForLoop SwiftUI
I have an array of elements that contains a nested array of other elements inside.
When deleting a row of an array, sometimes a crash occurs with the message
'Swift/ContiguousArrayBuffer.swift:600: ...
0
votes
3
answers
166
views
Loop over pairs from 2 constexpr arrays to instantiate and run template function
C++ version for project is 20.
Suppose we have some service class template:
template<int someSegmentSize>
class SomeAbstractFileService {
public:
void init() {
std::cout << &...
0
votes
1
answer
35
views
Refresh page after double for loop, selenium with python
I run into a stale element reference every time I run this double for loop and the page refreshes after I click the back element. I tried to call the driver again in the for loop and pull up the ...
0
votes
0
answers
64
views
How to do a nested loop over a variable length list of generators? [duplicate]
I have a list of generators L = [gen_1,...,gen_n] with variable length n.
How can I implement in a compact way the following:
for el_1 in gen_1:
for ...
for el_n in gen_n:
...
0
votes
0
answers
168
views
Using p5.js to try and make a repeating pattern that looks like the flower of life, bit stuck
I'm doing an art project on sacred geometry and want to create my own flower of life pattern on p5.js. After a lot of trial and error I've managed to get 6 circles intersecting evenly while rotating ...
1
vote
1
answer
66
views
Django: My context variable cannot be used for duplicate for loops
In views.py I have the variable
mylist = zip(set1,set2,set3)
In templates I do
{% for val1, val2, val3 in mylist%}
{% endfor %}
It works fine. However, if I duplicate the condition it fails. Is it ...
0
votes
2
answers
78
views
How to make nested for-loop's number greater than or equal to previous for-loop's number
How can I make it so that the right number is always greater than or equal to the left number?
for i in range(5):
for j in range(5):
# Right (j) should be greater than or equal to left (i)
# ...
0
votes
2
answers
402
views
How do I count the occurrences of a string within multiple arrays that are part of an object?
I have an exercise that requires me to use a for loop to iterate through the object 'tutorPetTypes' and calculate the collective total number of cats owned by the tutors.
Here's my current code. It ...
0
votes
1
answer
26
views
Inputing integers in nested for loops to 2D arrays are replaced by inputed values in incrementation
league_size = int(input("How many teams are in the league?"))
match_no = int(input("How many maches are played?"))
team_points = [[0]*match_no] * league_size
for i in range(len(...
-3
votes
2
answers
111
views
Why is the 'i' variable incrementing weirdly? [closed]
Given a 9x9 Sudoku grid with a valid solution.
I am trying to code a method that validates (in other words, checking for duplicates or out of range values) in the Sudoku 'box' (which in this case ...
0
votes
1
answer
28
views
Better patter for nested for loops -- recusion
I have a dictionary that is made up of nested dictionaries and lists. I need to search it and pull out selected sub elements. Everything is working fine but I feel like there a better way to drive it. ...
0
votes
0
answers
117
views
How to get data only from all the sheets containing specific text in the name?
I have been trying to use ChatGPT to write and troubleshoot this Script with no luck. I have tried so many things and it always just returns data from the first sheet that matches the condition, and ...
0
votes
1
answer
123
views
for loop and generating random panel data
I want to generate a panel data sets with 5 units and 10 observations in r and get the test statistics. However, my problem here is to do this process 1000 times. For each id I need to restart the ...
0
votes
3
answers
201
views
Is there any other way to print solid rhombus with * using for loops
I am leaning Java, trying to solve the patterns in Java using for loop
Solid Rhombus.
Print Format:
line 1 :5 Spaces *****(5 Stars) then
Line 2 :4 Spaces *****
line 3 :3 Spaces *****
Line 4 :2 Spaces ...
3
votes
1
answer
1k
views
How to I seperate a SpatRaster into multiple layers in terra?
I've applied a function to create a multi-layer SpatRaster using terra. It's worked find, but now I'd like to separate each layer and name the new SpatRaster after the layer name. For three layers it'...
0
votes
2
answers
295
views
How do I get a list of 10 most recently purchased products in Shopify?
I'm trying to create a "Buy Again" list in Shopify. My coding skills are very basic, but I know enough to get by. I can loop through a customer's previous 10 orders, but that's not really ...
0
votes
4
answers
738
views
How to generate a unique set of 3 digit numbers from an array
You are given an integer array digits, where each element is a digit. The array may contain duplicates.
You need to find all the unique integers that follow the given requirements:
The integer ...
1
vote
1
answer
39
views
Question about the problem of shooting stars using Java for statements
Solving the problem of taking stars in Java. The questions are as follows.
Print out a square with a width and length of 10*10 using *.
The columns that match the x and y coordinates in the ...
0
votes
2
answers
44
views
Deleting upper left triangle from multiplication table
I'm new to programming and am taking an intro to programming class which focuses on java.
I have an assignment that have been working on but can't seem to get the last portion of the requirements.
I ...
0
votes
1
answer
90
views
Nested For Loop to copy and rename a worksheet based on a variable
I am trying to loop through a column full of dates, and for each tax year in the column create a copy of a template Worksheet and rename it to the tax year.
The loop for finding and returning the tax ...
1
vote
1
answer
142
views
Complex conditional df subsetting with nested for loops in r
I apologize in advance for this headache, and in particular, the minimum amount of data I need to give you to reproduce my situation.
I have two data frames that look like:
> dput(df_long[1:60,])
...
1
vote
1
answer
1k
views
Issue in nested iteration issue in Azure Logic Apps - foreach loop
I hope this message finds you well. I am writing to bring to your attention an issue I have encountered while working with nested iterations in Azure Logic Apps. I believe there might be a bug or ...
0
votes
1
answer
30
views
Nested-for-loop is returning a table with wrong repetitive values
glas <- vector()
ess <- vector()
sal <- vector()
deep <- vector()
bdate_group <- vector()
doy_group <- vector()
for (bdate_group_num in 1:8) { #repeats same values for corresponding ...
0
votes
1
answer
599
views
Compare two arrays of objects using nested for loop
I have two arrays of objects that I'm going to compare. If the values in all properties are the same then I want to remove the property in arr1. Below is the arrays with objects. They have the same ...
0
votes
1
answer
52
views
Word Hangingman C# Using Only Loops
I'm trying to make a hangman word-guessing game. I have come this far. The only problem now is that I would like to insert a statement of "There is no {0} in the word", playerGuess when the ...
-2
votes
3
answers
1k
views
Summing rows of a table in a for loop
I'm trying to create a function that takes a table and returns a list containing the sum of each row.
E.g. func([[0.2,0.1],[-0.2,0.1],[0.2,-0.1],[-0.2,-0.1]]) returns [0.3, -0.1, 0.1, -0.3].
I know ...
0
votes
1
answer
59
views
Is there a faster way to parse large json list of lists?
I am fetching responses from thousands of API calls, each of which is a new JSON, as the api is paginated. The result I get is a list of lists, with each inner list the JSON of one page. The following ...
1
vote
1
answer
110
views
Trying to produce stacked bar plots in ggplot using loops
Introduction
Hello everyone. This is my first post here - I am trying my best to give you everything needed to be able to help me, hopefully I do not forget anything.
I am trying to build a loop that ...
1
vote
2
answers
475
views
How to write a for loop to calculate Cohen's kappa for several questions?
I am very new to for looping in R and could use your help.
Say a dataset as below:
dog <- c("Dog1","Dog1","Dog2","Dog2","Dog3","Dog3", &...
-6
votes
1
answer
69
views
Accessing indices in nested list
all_folders is nested list of interest as below:
all_folders = [['\\\\1234\\Costing\\Folder1\\', '\\\\4567\\Costing\\Folder1\\', '\\\\8910\\Costing\\Folder1\\', '\\\\1112\\Costing\\Folder1\\', '\\\\...
0
votes
0
answers
99
views
Include for loop iteration number in list name
this working for-loop creates a single output list of 10 dataframes each containing a random sample of two rows from my input dataframe.
dat <- iris
lst_2 <- list()
for (i in 1:10){
...
1
vote
1
answer
102
views
Is there a better way to get a min value of all elements in a column, especially in a 2d array in java?
I was coding a Java program for AP CSA that took the max value from the columns of a two dimensional array, and it was used to determine and print out which area of a brand was the most popular/or had ...
3
votes
1
answer
1k
views
How can I design a standalone C++17 std::views::join alternative?
For a C++17 restricted project I would like to have a standalone implementation of C++20 std::views::join(). I am aware of the existence of range-v3 but unfortunately the person in charge is unwilling ...
-2
votes
3
answers
101
views
python for loop with if condition
This is my data set:
q1 q2 q3 q4
0 a a a a
1 b a a a
2 c c b a
3 d d b a
4 a a a a
5 b c b a
6 b a b a
7 c c b a
8 d d b ...
0
votes
1
answer
50
views
Arraylist sorting method isn't returning what it's supposed to. Probably a logical error
I have a method that's supposed to go through an ArrayList of words and put them in order alphabetically using .compareTo().
This is the testing text in a txt document: environment,city,character,road,...
0
votes
2
answers
46
views
Error with the return of a sorting words alphabetically method. Probably a logical error?
I have a method thats supposted to go through an ArrayList of words and put them in order alphabetically using .compareTo(). However I get this message when the program is run
Exception message: java....
-2
votes
1
answer
125
views
How can I display a nxn matrix depending on users input?
For a school task I need to display a nxn matrix depending on users input:
heres an example:
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
(users input: 5)
And here is my code until now:
n = ...
0
votes
1
answer
117
views
Is a loop in a loop really the best way to output nested dict items in Python?
I have a dict from a json API call that looks like this:
{
'id': '63d08d5c57abd98fdeea7985',
'pageName': 'Some Page Name',
'bodyContent':
[{
'children': [{
'alpha': 'foo foo foo'...
0
votes
3
answers
259
views
Combining two lists into dictionary using a for loop
I have two lists:
headers = [Header1, Header2, Header3]
data = [(1, 'Name1'), (2, 'Name2'), (3, 'Name3'))]
I need to combine the lists into a dictionary into the format:
database = {Header1 : [1, 2, ...
0
votes
1
answer
128
views
How to display month only one point while showing data in angular 13?
I'm New To angular. In a Milestone section there is a year and month loop. In the month loop the month name should be displayed only once for the specific year. please help me to find the possible ...
-1
votes
2
answers
53
views
Java | For loop, loops infinitely but there seems to be no reason why? [closed]
As part of a homework assigment I was tasked to printout this shape here: LinkToTask
But in the code I made which can be found below, the nested for loop seems to loop infinetley and after reading ...
0
votes
0
answers
40
views
How can I fix this Nested For Loop script (R) to estimate Model Ages
I'm new to R (and coding in general). The data itself is taken from lead isotope analysis and are lead isotopes.
I was hoping to create a nested for loop which compared the output of an equation to a ...
0
votes
3
answers
365
views
Parse list of strings and find max values
I'm quite new to Python and struggling to get my head round the logic in this for loop. My data has two values, a city and a temp. I would like to write a "for loop" that outputs the maximum ...
0
votes
1
answer
220
views
how to create a matrix with 1 for loop c#
How can i make a matrix as the one seen below, but with simply 1 for loop (instead of two):
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 ...
0
votes
1
answer
93
views
Is there a way to speed up or vectorize a nested for loop?
I am fairly new to coding in general and to Python in particular. I am trying to apply a weighted average scheme into a big dataset, which at the moment is taking hours to complete and I would love to ...
0
votes
1
answer
181
views
Create a new columns based on multiple conditions between two different dataframes with different dimensions
I am trying to build a stock portfolio. I have mainly 2 dfs: 1 with my transactions and 1 with the stock prices of the individual stocks.
My transactions df looks like this:
Date Ticker ...
3
votes
3
answers
115
views
Not Another Batch File Nested For Loop Question?
I'm trying to find a way to make nested for loops work, but this iteration is different than the most popular results (where an OP is looping through directories, or using a numerical for /l loop, etc....
1
vote
1
answer
96
views
trying to print a square of X's and Y's using nested for loops
Input:
3
7
4
Output:
XXXY
XXYY
XYYY
XXXXXXXY
XXXXXXYY
XXXXXYYY
XXXXYYYY
XXXYYYYY
XXYYYYYY
XYYYYYYY
XXXXY
XXXYY
XXYYY
XYYYY
I have an idea that involves 2 for loops nested in another for loop that ...