mirror of
https://github.com/friuns2/BlackFriday-GPTs-Prompts.git
synced 2026-04-30 22:13:55 +07:00
2024 chatgpt update
This commit is contained in:
+70
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
[](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22LBBg6prUxcfJtDUePqDxI%22%2C%22flow%22%3Atrue%7D%7D)
|
||||
|
||||
# Coder errors | [Start Chat](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22LBBg6prUxcfJtDUePqDxI%22%2C%22flow%22%3Atrue%7D%7D)
|
||||
shows alternative code to solve an specific error
|
||||
|
||||
@@ -9,6 +9,75 @@ shows alternative code to solve an specific error
|
||||
given the code {{Code}} and the error {{Error}} fix the error
|
||||
```
|
||||
|
||||
## Welcome Message
|
||||
To fix the error and exclude rectangles with spaces or other symbols, you can add a condition to check if the current element is a '+' symbol before counting it as a rectangle. Here's the modified code:
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
|
||||
export function count(diagram) {
|
||||
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < diagram.length-1; i++) {
|
||||
|
||||
for (let j = 0; j < diagram[i].length-1; j++) {
|
||||
|
||||
if(diagram[i][j]==='+'){
|
||||
|
||||
for (let k = j+1; k < diagram[i].length; k++) {
|
||||
|
||||
if(diagram[i][k]==='+'){
|
||||
|
||||
for (let l = i+1; l < diagram.length; l++) {
|
||||
|
||||
if(diagram[l][j]==='+'&& diagram[l][k]==='+'){
|
||||
|
||||
let isRectangle = true;
|
||||
|
||||
for(let m = i; m <= l; m++) {
|
||||
|
||||
if(diagram[m][j] !== '+' || diagram[m][k] !== '+'){
|
||||
|
||||
isRectangle = false;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isRectangle){
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
This updated code introduces a new loop (m) to check all the elements between the top-left corner (i, j) and the bottom-left corner (l, j) of a potential rectangle. If any element is not a '+' symbol, it means it's not a rectangle, and the count is not incremented.
|
||||
|
||||
## Conversation
|
||||
|
||||
**ASSISTANT**: To fix the error and exclude rectangles with spaces or other symbols, you can add a condition to check if the current element is a '+' symbol before counting it as a rectangle. Here's the modified code:
|
||||
@@ -79,4 +148,3 @@ export function count(diagram) {
|
||||
|
||||
This updated code introduces a new loop (m) to check all the elements between the top-left corner (i, j) and the bottom-left corner (l, j) of a potential rectangle. If any element is not a '+' symbol, it means it's not a rectangle, and the count is not incremented.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user