Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buse-mustafa-whereiswaldo #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions class-14-js-wheresWaldo/buse-mustafa-class14-whereiswaldo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
let example = [
["A", "A", "A"],
["A", "A", "A"],
["A", "X", "A"],
["A", "A", "A"],
["A", "A", "A"]
];

let example2 = [
["c", "c", "c", "c"],
["c", "c", "c", "d"]
];

function whereIsWaldo(array){
for (let i=0;i<array.length;i++){
for(let j = 0; j < array[i].length; j++){
if(array[i][j]!==array[0][0]){
let waldo = [i+1, j+1]

return waldo;
}else if(array[0][0]!==array[0][1]&&array[0][0]!==array[0][2]){
let waldo = [i+1, j+1]
return waldo;
}else {
continue
}
}
}
}

////////////////////////////////////////////////Buse&Mustafa






Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Where's Waldo?

Return the coordinates ([row, col]) of the element that differs from the rest.

### Notes:

- Rows and columns are 1-indexed (not zero-indexed).
- If you get stuck on a challenge please search it online and try to find resources
- If you are really stuck, please ask your Instructors.


### Examples:

whereIsWaldo([
["A", "A", "A"],
["A", "A", "A"],
["A", "B", "A"]
]) ➞ [3, 2]

whereIsWaldo([
["c", "c", "c", "c"],
["c", "c", "c", "d"]
]) ➞ [2, 4]

whereIsWaldo([
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["P", "O", "O", "O"],
["O", "O", "O", "O"]
]) ➞ [5, 1]