Skip to content
Open
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
99 changes: 99 additions & 0 deletions answers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## About You.

### 1. Introduce yourself.

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?

Yes, I have a personal laptop

### 3. Describe your development environment.

Windows 11, VS Code, Cursor, Replit

## Social Profile

### 1. Stack Overflow 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

## The real stuff.
### 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.
```js
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
```js
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”.
```js
// Convert English to Pig Latin
const toPigLat = (text) => {
return text
.split(" ")
.map(word => word.slice(1) + word[0] + "ay")
.join(" ");
};

// Convert Pig Latin back to English
const fromPigLat = (text) => {
return text
.split(" ")
.map(word => {
const withoutAy = word.slice(0, -2); // remove 'ay'
return withoutAy.slice(-1) + withoutAy.slice(0, -1);
})
.join(" ");
};
toPigLat("The quick brown fox");
fromPigLat("hetay uickqay rownbay oxfay");
```
### 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;

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
};
```