mirror of
https://github.com/friuns2/BlackFriday-GPTs-Prompts.git
synced 2026-04-30 22:13:55 +07:00
Added new GPTs for Black Friday
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
|
||||
[]()
|
||||
# Coder errors
|
||||
shows alternative code to solve an specific error
|
||||
|
||||
# Prompt
|
||||
|
||||
```
|
||||
given the code {{Code}} and the error {{Error}} fix the error
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
|
||||
|
||||
```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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user