Category "for-loop"

program to find the sum of the first N odd numbers

I'm trying to make a program that calculates the sum of the first N odd numbers. where N is the number of the first odd numbers (e.g. N=4, then the first odds a

Create new numpy array by duplicating each item in an array

I would like to create a new numpy array by repeating each item in another array by a given number of times (n). I am currently doing this with a for loop and .

How do you remove duplicate values in array in Python?

I have an array where each element is the mean of a set of random numbers. I want to be able to remove duplicate values in this array. How would I go about doin

Function to see if word is isogram

An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only le

How to find or count the duplicate in multidimensional array in c# [closed]

I am creating a 2d (3 * 3) array in c# which has to count or find the duplicate value int[,] arr = new int[3, 3] { {1, 2, 6}, {4, 1, 5}

How to start iterating a file at specific line?

I’m iterating through a file’s lines with enumerate(), and sometimes would need to start the iterating at a specific file line, so I attempted testf

How to get value printed on Postgres

I have a requirement to translate it to an SQL script. I am using the information schema to get all the columns of a table and print their distinct count. I was

Using for loop in R to combine column values based on preceeding column conditions

I am working with a big dataset with multiple observations for a certain gene, on varying dates and with varying expression levels. Data used I would like to su

can I use partials in a for loop in ejs?

I'm trying to include partials in a for loop in EJS. <% let index = 1 %> <% for (let item in db) { %> <div class="box unfocused box_<

For loop not stopping and random generated number not being saved (number guessing game)

I'm doing a number guessing game in an Android app. You have three tries to guess the number. If you run out of trials, then you loose. I added a for loop so th

For LOOP throw away by Compiler optimization

I was doing an experiment to measure the execution time of ''for loop'' on microcotroller. This ''for loop'' contain some integer and pointer operation. Case 1

Why does my for loop to disable buttons not work, but the same loop works for setting colors in JFrame?

I am programming a TicTacToe game and I want to use a for loop with my JButton components inside them like this: private void clearField(){ for (int i = 0;

How to extract multiple 7z file using Python?

I would like to extract multiple .7z files using Python. I've tried this, but it only extracted one file. I already put in a loop. Below is what I've tried. imp

How do you change parts of a string with a list variable in a for loop?

I want to open many files to do an analysis through python. The title changes in three ways, ID, intervention and drug_type So I define the path where the files

How to use tqdm in bash for loops?

I have this for loop for example that takes so much time to finish so I want to use tqdm to have a nice progress bar like in python. But I can't find any way to

Are infinite for loops possible in Python?

Is it possible to get an infinite loop in for loop? My guess is that there can be an infinite for loop in Python. I'd like to know this for future references.

Is there any way to improve performance (e.g. vectorize) this look-up and recoding problem implemented by a for loop?

I need to make recodings to data sets of the following form. # List elements of varying length set.seed(12345) n = 1e3 m = sample(2:5, n, T) V = list() for(i

How to deal with large number inside of for loop in javascript?

I am working on hacker rank problem. Repeated String [1] : https://www.hackerrank.com/challenges/repeated-string/problem function main() { var s = readLine

append values in for loop R as in python

I am trying to reproduce the following functions created in Python in R. # Python def square_area(side): return side * side results = [] for i in range(1

Return the first word with the greatest number of repeated letters

This is a question from coderbyte’s easy set. Many people asked about it already, but I’m really curious about what’s wrong with my particular