Questions tagged as 'loop'

1
answer

Extracting data from a data frame in R

I have a date frame in R and the table has row sets with the same attribute (name of an instance) and with different columns with data about each instance. INSTÂNCIA VALOR 1 VALOR 2 Instancia 1 10 20 Instância 1 34...
asked by 03.12.2018 / 16:00
3
answers

How to reference the first loop from the second in a looping of loops?

In PHP, how can I reference the first for from the second, as in the example below? for ($i=0; $i < 10; $i++) { for ($j=0; $j < 10; $j++) { // Quero que esse afete o primeiro 'for' e não o segundo if ($j ==...
asked by 09.08.2017 / 19:01
1
answer

calculate percentage of iterated items in a loop

How to get the percentage of total items in an array that were processed in a loop? Example: // array fictício (238 itens) var arr = ["AF","AL","DZ","AS","AD","AO","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","...
asked by 18.06.2017 / 05:38
2
answers

Recurring print in triangle format

I have to read an integer value and pass it as parameter to a function. This should show the number using the sample format. Ex: if the number you entered was 3, show: 1 1 2 1 2 3 I can show the format that asks the question, but not exa...
asked by 29.10.2018 / 23:51
1
answer

Python - Problem when doing print within a loop

I have the following code Python , representative of the game Pedra,Papel,Tesoura . import random listChoices = ["rock","paper","scissor"] print("Choose rock, paper or scissor to play or write exit to leave the game") userChoice =...
asked by 14.02.2017 / 04:14
1
answer

Loop is within loop for

for(pass = 0; pass < size - 1; pass++){ for(j = 0; j < size - 1; j++){ if(array[j] > array[j + 1]){ swap( &array[j], &array[j + 1]); } } } I just put a piece of code where I have a doubt...
asked by 18.01.2017 / 03:08
4
answers

Increment a counter inside a foreach in php

In a foreach loop, I need to increment a counter to set the tabindex of the form fields so that the result is: <input type="text" name="endereco[0][cep]" value="00000-000" tabindex="1"> <input type="text" name="endereco[0][rua]" va...
asked by 03.11.2017 / 20:50
1
answer

How to get different outputs (fasta) files with unix or python

I have a fasta file that has several gene sequences, such as: >gene1 C.irapeanum 5.8S rRNA gene CGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGATGAGACCGTGGAATAAACGATCGAGTG >gene2 C.irapeanum 5.8S rRNA gene AATTTCAAGGTTTCCGTAGGTGAACCTGCGGAAGGA...
asked by 02.02.2017 / 17:32
4
answers

C-Factor Algorithm

I need to create a program in C that fills any number that the user types. I wrote this code, but it does not work fully because it calculates only once. I do not want a ready answer, I want an explanation, why that happens. #include <stdio...
asked by 13.06.2014 / 16:17
2
answers

How to loop with regex in javascript?

Hello everyone, how are you? I'm breaking my head on the following question: I have a string set: var teste = blabla 555.. 999 I have double white space between the digits and did the regex: var str = teste.replace(/\s{2,}/g, '.');...
asked by 09.08.2014 / 05:19