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

ziada-js-wheresWaldo-class-14 #167

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0709ec8
update mhd ziada pesudo code
mohamadziada Apr 9, 2021
815cb82
solve HTML Practice Mohamad Ziada
mohamadziada Apr 9, 2021
11e6376
update HTML Practice
mohamadziada Apr 10, 2021
4b8674c
delete the class-1 solutions to submit pesudo code
mohamadziada Apr 10, 2021
89d8477
update class-1
mohamadziada Apr 11, 2021
0d91e44
Merge branch 'class-1'
mohamadziada Apr 11, 2021
14e9820
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 11, 2021
e51bc41
solve the blogPage
mohamadziada Apr 11, 2021
09457ce
update class-2
mohamadziada Apr 13, 2021
cb5a624
change class one folder name
mohamadziada Apr 13, 2021
8b193b0
delete .ds-store file
mohamadziada Apr 13, 2021
4495b76
delete ds-store
mohamadziada Apr 13, 2021
38414d3
.DS_Store removed
mohamadziada Apr 13, 2021
b7d971f
.DS_Store removed
mohamadziada Apr 13, 2021
89078b8
resloving merge issue
mohamadziada Apr 21, 2021
15f0740
resolve merge conflict for class-2
mohamadziada Apr 21, 2021
28e0016
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 21, 2021
77e07d6
commiting intro js class4 mustafa & ziada
mohamadziada Apr 21, 2021
698fe8b
commit all class4 activities
mohamadziada Apr 21, 2021
2ec1e83
ziada & mustafa class 4 if function
mohamadziada Apr 21, 2021
8b2f2e1
ziada-mustafa-js-if-conditions update
mohamadziada Apr 21, 2021
a93567c
if condition ziada-mustafa and js intro ziada-nidal of class4
mohamadziada Apr 21, 2021
37bfd55
sperating the activites of class 4 into branches
mohamadziada Apr 21, 2021
70d867b
ziada & ali riza solution class 5
mohamadziada Apr 21, 2021
136953a
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 23, 2021
c0adeef
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 23, 2021
33affff
ziada and mustafa js-dom-and-array
mohamadziada Apr 23, 2021
98dcc28
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 25, 2021
791ef77
ziada and isa claculator and madlibs
mohamadziada Apr 25, 2021
f51eb27
update folder name to ziada-isa
mohamadziada Apr 26, 2021
841e9ad
Merge branch 'class-6'
mohamadziada Apr 30, 2021
71aeb3b
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 30, 2021
933066d
ziada and deniz scope activity
mohamadziada Apr 30, 2021
5465f16
remove scope activity from main due to previous opened PR
mohamadziada Apr 30, 2021
404bf9c
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 2, 2021
aa25c67
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 11, 2021
efdf362
pull upstream
mohamadziada May 19, 2021
e4b8b4f
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 19, 2021
93f7533
update
mohamadziada May 19, 2021
2dae3cb
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 22, 2021
1edf54e
my solution to wheres waldo - no partner due to absent
mohamadziada May 22, 2021
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
Binary file removed .DS_Store
Binary file not shown.
80 changes: 80 additions & 0 deletions class-14-js-wheresWaldo/ziada/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const arr1 = [
["A", "A", "A"],
["A", "A", "A"],
["A", "B", "A"]
];


const arr2 = [
["c", "c", "c", "c"],
["c", "c", "c", "d"]
];

const arr3 = [
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["P", "O", "O", "O"],
["O", "O", "O", "O"]
];

const whereIsWaldoTest = function(arr) {
let result =
arr.reduce((acc, curr) => {
for (let i = 0; i < curr.length; i++) {
if ( i == 0 && curr[0] !== curr[1] && curr[0] !==curr[2]) {
acc.push(arr.indexOf(curr)+1)
acc.push(0+1)
break
}
else if (curr[i] !== curr[i+1] && curr[i] !==curr[0]) {
acc.push(arr.indexOf(curr)+1)
acc.push(i+1)
break
}
}

console.log(acc)
return acc
}, [])
return result
}

whereIsWaldoTest(arr3); 
whereIsWaldoTest(arr1);
whereIsWaldoTest(arr2);



// Another way to solve the activity

// const whereIsWaldoTest = (array) => {
// let location = [];
// for (let i = 0; i < array.length; i++){
// for (let j = 0; j < array[i].length; j++){
// if (j === array[i].length - 1 && array[i][j] !== array[i][0]) {
// location.push(i+1);
// location.push(j+1);
// break;
// }
// else if (j !== 0){
// if(array[i][j] !== array[i][j+1] && array[i][j] !== array[i][j-1]) {
// location.push(i+1);
// location.push(j+1);
// break;
// }
// }
// else if(array[i][j] !== array[i][j+1] && array[i][j] !== array[i][j+2]) {
// location.push(i+1);
// location.push(j+1);
// break;
// }
// }
// }
// return location;
// };

// console.log(whereIsWaldoTest(arr1));
// console.log(whereIsWaldoTest(arr2));
// console.log(whereIsWaldoTest(arr3));
32 changes: 32 additions & 0 deletions class-14-js-wheresWaldo/ziada/readme.md
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]
Binary file removed class-3/.DS_Store
Binary file not shown.