From 02ab039506e87c7eeacb460a07a82f4cd2a6b6c8 Mon Sep 17 00:00:00 2001 From: Fabio Mughilan <64077520+fabiomughilan@users.noreply.github.com> Date: Sat, 14 Jun 2025 12:30:17 +0530 Subject: [PATCH 1/6] Create answers.md --- answers.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 answers.md diff --git a/answers.md b/answers.md new file mode 100644 index 0000000..684f748 --- /dev/null +++ b/answers.md @@ -0,0 +1,44 @@ +## About You. + +1. Introduce yourself. + +This is Fabio Mughilan, I am doing my final year in B.Tech CSE at Vel Tech University,Chennai, and have 1+ year experience in Blockchain Development + +2. Do you own a personal computer? + +Yes, I have a personal laptop + +3. Describe your development environment. + +Windows 11, Visual Studio Code + +## Social Profile + +Stack Overflow: https://stackoverflow.com/users/29971569/fabio-mughilan + +2. Personal website, blog or something you want us to see. + +Github: https://github.com/fabiomughilan +Linkedin: https://www.linkedin.com/in/fabiomughilan +Website: + +## The real stuff. +1. Which all programming languages are installed on your system. + +Solidity, Javascript, Python, Rust, C, Java + +3. Write a function that takes a number and returns a list of its digits in an array. + +5. Remove duplicates of an array and returning an array of only unique elements + +7. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. + +9. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? + +Note: It is not mandatory that you answer all the questions. You may leave some behind and create a PR. However maximum questions will earn you maximum points. It is advised that you answer all the puzzles in a language that you are applying for. + +### Notes + +- [Pig Latin](https://en.wikipedia.org/wiki/Pig_Latin) +- [Fun](http://www.snowcrest.net/donnelly/piglatin.html) +- [Nice Read](https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95) From c22e0511b6330a52e7b77f13bfbeb200044ca2fd Mon Sep 17 00:00:00 2001 From: Fabio Mughilan Date: Sat, 14 Jun 2025 13:06:22 +0530 Subject: [PATCH 2/6] changes --- answers.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/answers.md b/answers.md index 684f748..e996e40 100644 --- a/answers.md +++ b/answers.md @@ -2,7 +2,7 @@ 1. Introduce yourself. -This is Fabio Mughilan, I am doing my final year in B.Tech CSE at Vel Tech University,Chennai, and have 1+ year experience in Blockchain Development +This is Fabio Mughilan, I am doing my final year in B.Tech CSE at Vel Tech University,Chennai, and have 1+ year experience in building Dapps and 2. Do you own a personal computer? @@ -10,7 +10,7 @@ Yes, I have a personal laptop 3. Describe your development environment. -Windows 11, Visual Studio Code +Windows 11, VS Code, Cursor, Replit ## Social Profile @@ -25,15 +25,55 @@ Website: ## The real stuff. 1. Which all programming languages are installed on your system. -Solidity, Javascript, Python, Rust, C, Java +Solidity, Javascript, Typescipt, Python, Rust, C, Java -3. Write a function that takes a number and returns a list of its digits in an array. +2. Write a function that takes a number and returns a list of its digits in an array. -5. Remove duplicates of an array and returning an array of only unique elements - -7. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. +const numToarray = (num) => { + if (typeof num !== "number" || isNaN(num)) return []; //prevent Nan value + num = Math.abs(num); // remove -ve value + if (!Number.isInteger(num)) return []; // Remove decimal point + return num.toString().split("").map(Number); +} +console.log(numToarray(12345)); + + +3. Remove duplicates of an array and returning an array of only unique elements + +const removDup = (arr) => { +return Array.isArray(arr) ? [...new Set(arr)] : []; +}; + +console.log(removDup([1, 2, 1, 2, 3, 4])); + +4. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. + +// Convert English to Pig Latin +const toPigLatin = (text) => { + return text + .split(" ") + .map(word => word.slice(1) + word[0] + "ay") + .join(" "); +}; + +// Convert Pig Latin back to English +const fromPigLatin = (text) => { + return text + .split(" ") + .map(word => { + const withoutAy = word.slice(0, -2); // remove 'ay' + return withoutAy.slice(-1) + withoutAy.slice(0, -1); + }) + .join(" "); +}; + +toPigLatin("The quick brown fox"); +// → "hetay uickqay rownbay oxfay" + +fromPigLatin("hetay uickqay rownbay oxfay"); +// → "the quick brown fox" -9. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? +5. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? Note: It is not mandatory that you answer all the questions. You may leave some behind and create a PR. However maximum questions will earn you maximum points. It is advised that you answer all the puzzles in a language that you are applying for. From d0e09ffe15f01334e0622f2a5755b65e4f4df30e Mon Sep 17 00:00:00 2001 From: Fabio Mughilan Date: Sat, 14 Jun 2025 14:15:18 +0530 Subject: [PATCH 3/6] coding done --- answers.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/answers.md b/answers.md index e996e40..b2d852f 100644 --- a/answers.md +++ b/answers.md @@ -49,7 +49,7 @@ console.log(removDup([1, 2, 1, 2, 3, 4])); 4. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. // Convert English to Pig Latin -const toPigLatin = (text) => { +const toPigLat = (text) => { return text .split(" ") .map(word => word.slice(1) + word[0] + "ay") @@ -57,7 +57,7 @@ const toPigLatin = (text) => { }; // Convert Pig Latin back to English -const fromPigLatin = (text) => { +const fromPigLat = (text) => { return text .split(" ") .map(word => { @@ -67,18 +67,31 @@ const fromPigLatin = (text) => { .join(" "); }; -toPigLatin("The quick brown fox"); +toPigLat("The quick brown fox"); // → "hetay uickqay rownbay oxfay" -fromPigLatin("hetay uickqay rownbay oxfay"); +fromPigLat("hetay uickqay rownbay oxfay"); // → "the quick brown fox" 5. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? -Note: It is not mandatory that you answer all the questions. You may leave some behind and create a PR. However maximum questions will earn you maximum points. It is advised that you answer all the puzzles in a language that you are applying for. +const rotateInPlace = (arr, k) => { + const n = arr.length; + if (!Array.isArray(arr) || n === 0 || k % n === 0) return; + + k = k % n; // handle k > n + + const reverse = (start, end) => { + while (start < end) { + [arr[start], arr[end]] = [arr[end], arr[start]]; // swap + start++; + end--; + } + }; + + reverse(0, k - 1); // Reverse first part + reverse(k, n - 1); // Reverse second part + reverse(0, n - 1); // Reverse whole array +}; -### Notes -- [Pig Latin](https://en.wikipedia.org/wiki/Pig_Latin) -- [Fun](http://www.snowcrest.net/donnelly/piglatin.html) -- [Nice Read](https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95) From 04dc01bb9f6000518980664dd20f9a8791b4a224 Mon Sep 17 00:00:00 2001 From: Fabio Mughilan Date: Sat, 14 Jun 2025 14:58:16 +0530 Subject: [PATCH 4/6] changes --- answers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/answers.md b/answers.md index b2d852f..0e07d09 100644 --- a/answers.md +++ b/answers.md @@ -28,7 +28,7 @@ Website: Solidity, Javascript, Typescipt, Python, Rust, C, Java 2. Write a function that takes a number and returns a list of its digits in an array. - +'''javascript const numToarray = (num) => { if (typeof num !== "number" || isNaN(num)) return []; //prevent Nan value num = Math.abs(num); // remove -ve value From 9b87e3cb0d7023fe85f40ea5a2810ffee16c8a04 Mon Sep 17 00:00:00 2001 From: Fabio Mughilan <64077520+fabiomughilan@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:29:52 +0530 Subject: [PATCH 5/6] Update answers.md --- answers.md | 60 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/answers.md b/answers.md index 0e07d09..69c69cb 100644 --- a/answers.md +++ b/answers.md @@ -1,34 +1,40 @@ ## About You. -1. Introduce yourself. +### 1. Introduce yourself. -This is Fabio Mughilan, I am doing my final year in B.Tech CSE at Vel Tech University,Chennai, and have 1+ year experience in building Dapps and +This is Fabio Mughilan, a final-year B.Tech CSE student at Vel Tech University, Chennai, with over a year of experience in building DApps, smart contracts, and Web3 solutions. I specialize in React, Vue.js, and Next.js, with a strong passion for open-source contributions and problem-solving. Always eager to innovate and explore decentralized technologies. -2. Do you own a personal computer? +### 2. Do you own a personal computer? Yes, I have a personal laptop -3. Describe your development environment. +### 3. Describe your development environment. Windows 11, VS Code, Cursor, Replit ## Social Profile -Stack Overflow: https://stackoverflow.com/users/29971569/fabio-mughilan +### 1. Stack Overflow Profile +- Stack Overflow: https://stackoverflow.com/users/29971569/fabio-mughilan -2. Personal website, blog or something you want us to see. +### 2. Personal website, blog, or something you want us to see. -Github: https://github.com/fabiomughilan -Linkedin: https://www.linkedin.com/in/fabiomughilan -Website: +- Github: https://github.com/fabiomughilan +- LinkedIn: https://www.linkedin.com/in/fabiomughilan ## The real stuff. -1. Which all programming languages are installed on your system. - -Solidity, Javascript, Typescipt, Python, Rust, C, Java +### 1. Which all programming languages are installed on your system. + +- Solidity +- JavaScript, +- Typescript +- Python +- Rust +- C +- Java -2. Write a function that takes a number and returns a list of its digits in an array. -'''javascript +### 2. Write a function that takes a number and returns a list of its digits in an array. +```js const numToarray = (num) => { if (typeof num !== "number" || isNaN(num)) return []; //prevent Nan value num = Math.abs(num); // remove -ve value @@ -36,18 +42,18 @@ const numToarray = (num) => { return num.toString().split("").map(Number); } console.log(numToarray(12345)); +``` - -3. Remove duplicates of an array and returning an array of only unique elements - +### 3. Remove duplicates of an array and returning an array of only unique elements +```js const removDup = (arr) => { -return Array.isArray(arr) ? [...new Set(arr)] : []; + return Array.isArray(arr) ? [...new Set(arr)] : []; }; console.log(removDup([1, 2, 1, 2, 3, 4])); - -4. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. - +``` +### 4. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. +```js // Convert English to Pig Latin const toPigLat = (text) => { return text @@ -66,15 +72,11 @@ const fromPigLat = (text) => { }) .join(" "); }; - toPigLat("The quick brown fox"); -// → "hetay uickqay rownbay oxfay" - fromPigLat("hetay uickqay rownbay oxfay"); -// → "the quick brown fox" - -5. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? - +``` +### 5. Write a function that rotates a list by `k` elements. For example [1,2,3,4,5,6] rotated by `2` becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? +```js const rotateInPlace = (arr, k) => { const n = arr.length; if (!Array.isArray(arr) || n === 0 || k % n === 0) return; @@ -93,5 +95,5 @@ const rotateInPlace = (arr, k) => { reverse(k, n - 1); // Reverse second part reverse(0, n - 1); // Reverse whole array }; - +``` From 7f69998f51ee53a3909ce4b3aa06ac1c3fadcbfc Mon Sep 17 00:00:00 2001 From: Fabio Mughilan <64077520+fabiomughilan@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:31:37 +0530 Subject: [PATCH 6/6] Update answers.md --- answers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/answers.md b/answers.md index 69c69cb..130687c 100644 --- a/answers.md +++ b/answers.md @@ -26,7 +26,7 @@ Windows 11, VS Code, Cursor, Replit ### 1. Which all programming languages are installed on your system. - Solidity -- JavaScript, +- JavaScript - Typescript - Python - Rust