# 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 would look something like: String ret = ""; for (int row = 0; row < size; row++) //size is the input… Read More trying to print a square of X's and Y's using nested for loops

# How to print reverse number pyramid like this one in c#?

i was trying to do thsi bellow pattern but didn’t understand it 1 3 2 6 5 4 10 9 8 7 this i what the basic increment number pattern i did int counterNumPattern = 1; for(int i = 1; i <= 4; i++) { for(int j=1;j<=i; j++) { Console.Write( counterNumPattern++); } Console.WriteLine(); } >Solution… Read More How to print reverse number pyramid like this one in c#?

# Undefined when reading length with nested for loops in JAVA SCRIPT

let arr=[[1,2,3],[4,5,6],[7,8,9]]; for (let i=arr.length;i>=0;i–){ console.log(arr[i]); for (let n=arr[i].length;n>=0;n–){ console.log(arr[i][n]); } } >Solution : You are trying to read out of range of arrays. Add -1 let arr = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; for (let i = arr.length – 1; i >= 0; i–) { console.log(arr[i]); for (let… Read More Undefined when reading length with nested for loops in JAVA SCRIPT

# Elegant solution – Nested for loops (eslint no-await-in-loop)

I have some code that works broadly as follows: function getRegionUsers(region) { return new Promise((resolve) => { setTimeout(() => { if (region === "emea") { return resolve(["dave", "mike", "steve"]); } return resolve(["kiki", "maya", "yukiko"]); }, 1000); }); } function sendMail(user, region) { console.info(`sendMail called: \${user} (\${region})`); } async function test() { const regions = ["emea",… Read More Elegant solution – Nested for loops (eslint no-await-in-loop)

# Print all even values in all object key end with odd value

I want to print all even values in all object key end with odd value but the coding I made just now is only specified for arr1, arr3, and arr5. Can anyone suggest me how to fix ‘let oddArr’ method (maybe in loop) so that when I changed arr1 into arr7, the result would be… Read More Print all even values in all object key end with odd value

# My python list is being printed entirely in one row in a HTML table

I am making a python script which makes a html table with a list (Without a module), but it keeps printing the entire list in one row instead of wrapping it like I need. My list is data = [‘1’, ‘2’, ‘3’, … , ’30’]. Im trying to get it to 5 cells in each… Read More My python list is being printed entirely in one row in a HTML table

# Converting elements in multiple variables by for loop is not working

I have ran code to save names of variables which are character and binary in object binvar print(binvar) [1] "x1" "x2" "x3" "x4" [5] "x5" I want to use this to select columns in my the original dataframe df in order to run a for loop where I convert yes and no to 1 and… Read More Converting elements in multiple variables by for loop is not working

# Bash Shell nested for loop on multiple arrays doesn't go though all elements

OUTER_LIST=(1 2) INNER_LIST=(a b) for (( i=0; i < \${#OUTER_LIST[@]}; i++ )); do echo "outer…\${OUTER_LIST[\$i]}" for (( i=0; i < \${#INNER_LIST[@]}; i++ )); do echo "inner…\${INNER_LIST[\$i]}" done done Output: outer…1 inner…a inner…b Question: why does it loop OUTER_LIST only 1 time ? >Solution : You use the same loop variable, i, in the inner loop… Read More Bash Shell nested for loop on multiple arrays doesn't go though all elements