'I know how to do it with a different set of numbers but not with these
I was asked to make a pattern like the below:
11111
12221
12321
12221
11111
While messing around and figuring it out I could only do:
55555
54445
54345
54445
55555
Using the code below, I want to know if I can use the same framework and change variables and such to get the desired output. (Note: The code must use nested for loops)
function m(c){
var maxi=0
for(var i =0; i<c.length; i++){
if(maxi<c[i]){
maxi=c[i]
}
}
return(maxi)
}
var n = 5
for(var i = 0; i<n; i++){
var a = ''
for(var j = 0; j<n; j++){
a+= String(m([i+1,j+1, n-i,n-j]))
}
console.log(a)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
