[
  {
    "path": ".gitignore",
    "content": ".git/"
  },
  {
    "path": "DAY01/Questions.md",
    "content": "# DAY - 01\n\n1. **Program to Print Integer Numbers Entered by the User:**\n\n   Write a program where the user is asked to enter an integer number, and the program prints that number back to them. For example:\n\n   - **Input:** **`42`**\n   - **Output:** **`You entered: 42`**\n\n2. **Write a Program to Find the Size of `int`, `float`, `double`, and `char` on Your Computer:**\n\n   Write a program that displays the size of fundamental data types (**`int`**, **`float`**, **`double`**, and **`char`**) on your system. For example:\n\n   - **Output:**\n     ```jsx\n     Size of int: 4 bytes\n     Size of float: 4 bytes\n     Size of double: 8 bytes\n     Size of char: 1 byte\n     ```\n\n3. **Program to Find the Larger Number Among Two Numbers:**\n\n   Write a program to compare two integers entered by the user and print the larger one. For example:\n\n   - **Input:** **`Enter two numbers: 15, 20`**\n   - **Output:** **`The larger number is: 20`**\n"
  },
  {
    "path": "DAY01/Solutions.js",
    "content": "// # Program to Print Integer Numbers Entered by the User:\n\n/*\n    - Since, NaN (Not-a-Number) is a special value in JavaScript, and comparing it with == or === will always return false. This is because NaN is not equal to itself by design. So we use isNaN() function\n    - isNaN(): This function checks if the value is NaN and returns true if it is, and false otherwise.\n*/\n\nvar num = parseInt(prompt(\"Enter any number\", 0));\nisNaN(num)\n  ? console.log(num + \" is not a valid number\")\n  : console.log(\"You entered: \" + num);\n\n// ----------------------------------------------------------\n\n// # Write a Program to Find the Size of int, float, double, and char on Your Computer:\n\n/*\n    - In JavaScript, we cannot directly determine the memory size of fundamental data types like int, float, or char as you would in statically typed languages like C or C++. This is because JavaScript is a dynamically typed language, and it abstracts away memory management details.\n    \n    - All numbers in JavaScript, whether integers or floating points, are represented as 64-bit floating-point values (IEEE 754 standard). \n    - Strings are collections of characters, and their size depends on encoding (e.g., UTF-16 in JavaScript).There is no direct equivalent for a char type.\n\n    - We need to use workarounds involving buffers, typed arrays, or specialized libraries, but those are more advanced concepts for now.\n\n*/\n\n// ----------------------------------------------------------\n\n// # Program to Find the Larger Number Among Two Numbers:\n\nconst num1 = parseInt(prompt(\"Enter num1 value\", 0));\nconst num2 = parseInt(prompt(\"Enter num2 value\", 0));\n\nfunction findMax(num1, num2) {\n  if (isNaN(num1) || isNaN(num2)) {\n    return \"Invalid Inputs\";\n  } else {\n    return Math.max(num1, num2);\n  }\n}\n\nconsole.log(findMax(num1, num2));\n"
  },
  {
    "path": "DAY02/Questions.md",
    "content": "# DAY - 02\n\n1. **Program to Check Whether the Number is Odd or Even:**\n\n   Write a program that checks whether a number entered by the user is odd or even. For example:\n\n   - **Input:** **`Enter a number: 7`**\n   - **Output:** **`7 is an odd number`**\n\n2. **Program to Check Whether the Number is Divisible by 5:**\n\n   Write a program that determines if a number entered by the user is divisible by 5. For example:\n\n   - **Input:** **`Enter a number: 25`**\n   - **Output:** **`25 is divisible by 5.`**\n\n3. **Program to Check Whether the Number is a Multiple of 7:**\n\n   Write a program that verifies if a number entered by the user is a multiple of 7. For example:\n\n   - **Input:** **`Enter a number: 14`**\n   - **Output:** **`14 is a multiple of 7.`**\n\n---\n\n# NOTES\n\n## Taking Input from the user in NodeJs Environment\n\n- Node.js provides several methods for receiving input from users, including reading from standard input (stdin), command-line arguments, and user prompts.\n\n  ### Using readline-sync\n\n  - This module is used to receive input from the user synchronously, ensuring program execution line by line.\n\n  command : npm install readline-sync\n\n  #### Importing the module\n\n  const readline = require(\"readline-sync\");\n\n  #### Enter the number\n\n  ```javascript\n  let a = Number(readline.question());\n  let number = [];\n  for (let i = 0; i < a; ++i) {\n    number.push(Number(readline.question()));\n  }\n  console.log(number);\n  ```\n\n  #### Output\n\n  2\n  1\n  2\n  [1,2]\n"
  },
  {
    "path": "DAY02/Solutions.js",
    "content": "let num = parseInt(prompt(\"Enter a number: \", 0));\n\n//* Program to Check Whether the Number is Odd or Even:\n\nfunction CheckEvenOdd(num) {\n  if (isNaN(num)) {\n    console.log(\"Invalid Input\");\n  } else {\n    if (num % 2 == 0) {\n      console.log(`${num} is an even number`);\n    } else console.log(`${num} is an Odd number`);\n  }\n}\n\nCheckEvenOdd(num);\n\n// ------------------------------------------------------------------------------------------------------\n\n//* Program to Check Whether the Number is Divisible by 5:\n\nfunction divisibleBy5(num) {\n  if (isNaN(num)) {\n    console.log(\"Invalid Input\");\n  } else {\n    if (num % 5 == 0) {\n      console.log(`${num} is divisible`);\n    } else console.log(`${num} is not divisible by 5`);\n  }\n}\n\ndivisibleBy5(num);\n\n// --------------------------------------------------------------------------------------------------------\n\n//* Program to Check Whether the Number is a Multiple of 7:\nfunction multipleOf7(num) {\n  if (isNaN(num)) {\n    console.log(\"Invalid Input\");\n  } else {\n    if (num % 7 === 0) {\n      console.log(`${num} is a multiple of 7`);\n    } else console.log(`${num} is not divisible by 7`);\n  }\n}\n"
  },
  {
    "path": "DAY03/Questions.md",
    "content": "# DAY - 03\n\n1. **Program to Calculate the Square and Cube of a Number:**\n\n   Write a program where the user enters a number, and the program calculates its square and cube. For example:\n\n   - **Input:** **`Enter a number: 3`**\n   - **Output:** **`Square: 9, Cube: 27`**\n\n2. **Program to Calculate the Area of a Circle and Triangle:**\n\n   Write a program to calculate the area of a circle given its radius and a triangle given its base and height. For example:\n\n   - **Input:** **`Radius: 5, Base: 10, Height: 4`**\n   - **Output:**\n\n   ```markdown\n   Area of Circle: 78.5\n   Area of Triangle: 20\n   ```\n\n3. **Write a Program to Find the Quotient and Remainder of Two Integers:**\n\n   Write a program where the user enters two integers (divisor and dividend) and calculates their quotient and remainder. For example:\n\n   - **Input:** **`Dividend: 22, Divisor: 7`**\n   - **Output:**\n\n   ```markdown\n   Quotient: 3\n   Remainder: 1\n   ```\n"
  },
  {
    "path": "DAY03/Solutions.js",
    "content": "// # Program to Calculate the Square and Cube of a Number\n\nlet num = parseInt(prompt(\"Enter a number\", 0));\nfindSquareAndCube(num);\nfunction findSquareAndCube(num) {\n  if (isNaN(num)) {\n    console.log(\"Invalid Input\");\n    return;\n  } else {\n    console.log(`Square of the ${num} : ${num * num}`);\n    console.log(`Cube of the ${num} : ${num * num * num}`);\n  }\n}\n\n// -----------------------------------------------------------------------------------------------------------------------\n\n// # Program to Calculate the Area of a Circle and Triangle\n\nlet radius = parseInt(prompt(\"Enter the radius of the circle\", 1));\nlet base = parseInt(prompt(\"Enter the base of the triangle\", 1));\nlet height = parseInt(prompt(\"Enter the heght of the triangle\", 1));\n\nAreaOfCircleAndTriangle(radius, base, height);\n\nfunction AreaOfCircleAndTriangle(radius, base, height) {\n  if (isNaN(radius) || isNaN(base) || isNaN(height)) {\n    console.log(\"Invalid Input\");\n    return;\n  }\n  circleArea(radius);\n  triangleArea(base, height);\n}\n\nfunction circleArea(radius) {\n  let area = Math.round(Math.PI * radius * radius);\n  console.log(`Area of the circle : ${area}`);\n}\n\nfunction triangleArea(base, height) {\n  let area = Math.round(0.5 * base * height);\n  console.log(`Area of the triangle : ${area}`);\n}\n\n// -----------------------------------------------------------------------------------------------------------------------\n\n// # Write a Program to Find the Quotient and Remainder of Two Integers\n\nlet divisor = parseInt(prompt(\"Enter the divisor\", 1));\nlet dividend = parseInt(prompt(\"Enter the dividend\", 1));\n\nfindQuotientAndRemainder(divisor, dividend);\n\nfunction findQuotientAndRemainder(divisor, dividend) {\n  if (isNaN(divisor) || isNaN(dividend)) {\n    console.log(\"Invalid Input\");\n    return;\n  }\n\n  if (divisor === 0) {\n    console.log(\"ERROR : Divide by Zero\");\n    return;\n  }\n\n  let Quotient = Math.floor(dividend / divisor);\n  let remainder = dividend % divisor;\n\n  console.log(`Quotient : ${Quotient} and Remainder : ${remainder} `);\n}\n"
  },
  {
    "path": "DAY04/Questions.md",
    "content": "# DAY - 04\n\n1. **Print the Multiplication Table of a Given Number:**\n\n   Write a program where the user enters a number, and the program prints its multiplication table. For example:\n\n   - **Input:** **`Enter a number: 5`**\n   - **Output:**\n     ```jsx\n     5 x 1 = 5\n     5 x 2 = 10\n     ...\n     5 x 10 = 50\n     ```\n\n2. **Write a Program to Make a Simple Calculator Using a Switch Case:**\n\n   Write a program that acts as a calculator, taking two numbers and an operator (**`+`**, **`-`**, **`*`**, **`/`**) from the user, and performing the operation based on the operator. For example:\n\n   - **Input:** **`Enter first number: 10, Operator: +, Second number: 20`**\n   - **Output:** **`10 + 20 = 30`**\n\n3. **Print a Number in Reverse Order:**\n\n   Write a program where the user enters a number, and the program prints it in reverse order. For example:\n\n   - **Input:** **`1234`**\n   - **Output:** **`4321`**\n"
  },
  {
    "path": "DAY04/Solutions.js",
    "content": "//* Print the Multiplication Table of a Given Number\n\nlet number = 5;\nfunction PrintTable(num) {\n  for (let i = 1; i <= 10; i++) {\n    console.log(`${num} x ${i} = ${num * i} `);\n  }\n}\n\nPrintTable(number);\n\n// --------------------------------------------------------------------------------------------------------------------\n\n//* Write a Program to Make a Simple Calculator Using a Switch Case\n\nlet Operand1 = 12;\nlet Operand2 = 13;\nlet Operator = \"*\";\n\nfunction Calculator() {\n  switch (Operator) {\n    case \"+\":\n      console.log(`Addition: ${Operand1 + Operand2}`);\n      break;\n    case \"-\":\n      console.log(`Subtraction: ${Operand1 - Operand2}`);\n      break;\n    case \"*\":\n      console.log(`Multiplication: ${Operand1 * Operand2}`);\n      break;\n    case \"/\":\n      console.log(`Division: ${(Operand1 / Operand2).toFixed(2)}`);\n      break;\n    default:\n      console.log(\"Invalid Operator\");\n      break;\n  }\n}\n\nCalculator(Operand1, Operand2, Operator);\n\n// ----------------------------------------------------------------------------------------------------------------\n\n//* Print a Number in Reverse Order\n\nlet num = 1234;\n\nfunction PrintReverseNum(num) {\n  let reverse = null;\n  while (num > 0) {\n    let rem = num % 10;\n    reverse = reverse * 10 + rem;\n    num = Math.floor(num / 10);\n  }\n  return reverse;\n}\n\nconsole.log(PrintReverseNum(num));\n"
  },
  {
    "path": "DAY05/Questions.md",
    "content": "# DAY - 05\n\n1. **Calculate the Sum of Digits of a Given Number:**\n\n   Write a program that calculates the sum of the digits of a number entered by the user. For example:\n\n   - **Input:** **`Enter a number: 1234`**\n   - **Output:** **`Sum of digits: 10`**\n\n2. **Write a Program to Check Whether a Character is a Vowel or Consonant:**\n\n   Write a program to check whether a character entered by the user is a vowel (**`a, e, i, o, u`**) or a consonant. For example:\n\n   - **Input:** **`Enter a character: e`**\n   - **Output:** **`e is a vowel.`**\n\n3. **Write a Program to Find the ASCII Value of a Character:**\n\n   Write a program that takes a character as input and displays its ASCII value. For example:\n\n   - **Input:** **`Enter a character: A`**\n   - **Output:** **`ASCII value of A: 65`**\n"
  },
  {
    "path": "DAY05/Solutions.js",
    "content": "//* Calculate the Sum of Digits of a Given Number\n\nlet number = 1234;\n\nfunction findSumOfDigits(num) {\n  let sum = 0;\n  while (num > 0) {\n    let rem = num % 10;\n    sum += rem;\n    num = Math.floor(num / 10);\n  }\n  return sum;\n}\n\nconsole.log(`The Sum of Digits of ${number} :`, findSumOfDigits(number));\n\n// -----------------------------------------------------------------------------------------------------------\n\n//* Write a Program to Check Whether a Character is a Vowel or Consonant\n\nlet char = \"Z\";\n\nfunction checkCharacter(char) {\n  if (char.length != 1 || !/[a-zA-Z]/.test(char)) {\n    return \"Invalid Input\";\n  }\n\n  let letter = char.toLowerCase();\n\n  if (\"aeiou\".includes(letter)) {\n    return `${char} is an Vowel`;\n  } else {\n    return `${char} is a Consonant`;\n  }\n}\n\nconsole.log(checkCharacter(char));\n\n// ------------------------------------------------------------------------------------------------------------\n\n//* Write a Program to Find the ASCII Value of a Character\n\nlet Value = \"@\";\n\nfunction findASCIIValue(val) {\n  if (val === \" \" || val.length != 1) {\n    return \"Invalid Input\";\n  }\n  return `ASCII value of ${val}: ${val.charCodeAt(0)}`;\n}\n\nconsole.log(findASCIIValue(Value));\n"
  },
  {
    "path": "DAY06/Questions.md",
    "content": "# DAY - 06\n\n## Pattern 1: Sqaure\n\n```\n* * * * *\n* * * * *\n* * * * *\n* * * * *\n* * * * *\n```\n\n## Pattern 2: Right-angled trinagle\n\n```\n*\n* *\n* * *\n* * * *\n* * * * *\n```\n\n## Pattern 3: Hallow Rectangle\n\n```\n* * * * *\n*       *\n*       *\n*       *\n* * * * *\n```\n"
  },
  {
    "path": "DAY06/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction Pattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n    for (let j = 1; j <= n; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern);\n  }\n}\n\nconsole.log(\"Pattern - 1\");\n\nPattern1(5);\n\n// --------------------------------------------------------------------------------------\n\n//* Pattern - 2\n\nfunction pattern2(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern);\n  }\n}\n\nconsole.log(\"Pattern - 2\");\npattern2(5);\n\n// --------------------------------------------------------------------------------------\n\n//* Pattern - 3\n\nfunction Pattern3(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= n; j++) {\n      if (i == 1 || i == n || j == 1 || j == n) {\n        rowPattern += \"* \";\n      } else {\n        rowPattern += \"  \";\n      }\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nconsole.log(\"Pattern - 3\");\nPattern3(5);\n"
  },
  {
    "path": "DAY07/Questions.md",
    "content": "# DAY - 07\n\n## Pattern 1: Inverted Right-angled triangle\n\n```\n* * * * *\n* * * *\n* * *\n* *\n*\n```\n\n## Pattern 2: traingle\n\n```\n        *\n      * * *\n    * * * * *\n  * * * * * * *\n* * * * * * * * *\n```\n\n## Pattern 3: Inverted traingle\n\n```\n* * * * * * * * *\n  * * * * * * *\n    * * * * *\n      * * *\n        *\n```\n"
  },
  {
    "path": "DAY07/Solutions.js",
    "content": "//* Pattern-1 :\n\nfunction Pattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = n; j >= i; j--) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern1(5);\n\n// ---------------------------------------------------------------------------------------------------------------------------------------\n\n// * Pattern - 2 :\n\nfunction Pattern2(n) {\n  for (let i = 1; i <= n; i++) {\n    // rows\n    let rowPattern = \" \";\n    for (let j = 1; j <= n - i; j++) {\n      // spaces\n      rowPattern += \". \";\n    }\n    for (let k = 1; k <= 2 * i - 1; k++) {\n      // starts\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern2(5);\n\n// ---------------------------------------------------------------------------------------------------------------------------\n\n//* Pattern - 3\n\nfunction Pattern3(n) {\n  for (let i = n; i >= 1; i--) {\n    // rows\n    let rowPattern = \" \";\n    for (let j = 1; j <= n - i; j++) {\n      // spaces\n      rowPattern += \". \";\n    }\n    for (let k = 1; k <= 2 * i - 1; k++) {\n      // starts\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern3(10);\n"
  },
  {
    "path": "DAY08/Questions.md",
    "content": "# DAY - 08\n\n## Pattern 7:\n\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n\n## Pattern 8\n\n1\n2 2\n3 3 3\n4 4 4 4\n5 5 5 5 5\n\n## Pattern 9\n\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n"
  },
  {
    "path": "DAY08/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction Pattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += `${j} `;\n    }\n    console.log(rowPattern);\n  }\n}\n\nPattern1(5);\n\n// -------------------------------------------------------------------------\n\n//* Pattern - 2\n\nfunction Pattern2(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += `${i} `;\n    }\n    console.log(rowPattern);\n  }\n}\n\nPattern2(5);\n\n// -------------------------------------------------------------------------\n\n//* Pattern - 3\n\nfunction Pattern3(n) {\n  for (let i = n; i >= 1; i--) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += `${j} `;\n    }\n    console.log(rowPattern);\n  }\n}\n\nPattern3(5);\n"
  },
  {
    "path": "DAY09/Questions.md",
    "content": "## Pattern 1\n\n```\n1             1\n1 2         2 1\n1 2 3     3 2 1\n1 2 3 4 4 3 2 1\n\n```\n\n## Pattern 2\n\n```\nA\nA B\nA B C\nA B C D\nA B C D E\n```\n\n## Pattern 3\n\n```\nA B C D E\nA B C D\nA B C\nA B\nA\n```\n"
  },
  {
    "path": "DAY09/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction Pattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += `${j} `;\n    }\n    for (let k = 1; k <= 2 * (n - i); k++) {\n      rowPattern += \"  \";\n    }\n    for (let l = i; l >= 1; l--) {\n      rowPattern += `${l} `;\n    }\n    console.log(rowPattern);\n  }\n}\n\nPattern1(5);\n\n// --------------------------------------------------------------------------------------\n\n//* Pattern - 2\n\nfunction Pattern2(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 0; j < i; j++) {\n      rowPattern += String.fromCharCode(65 + j) + \" \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern2(5);\n\n// --------------------------------------------------------------------------------------\n\n//* Pattern - 3\n\nfunction Pattern3(n) {\n  for (let i = n; i >= 1; i--) {\n    let rowPattern = \" \";\n    for (let j = 0; j < i; j++) {\n      rowPattern += String.fromCharCode(65 + j) + \" \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern3(5);\n"
  },
  {
    "path": "DAY10/Questions.md",
    "content": "## Pattern 1\n\n```\nA\nB B\nC C C\nD D D D\nE E E E E\n```\n\n## Pattern 2\n\n```\n      A\n    A B A\n  A B C B A\nA B C D C B A\n```\n\n## **Program to Perform Swapping of Two Numbers:**\n\nWrite a program to swap two numbers entered by the user. For example:\n\n- **Input:** **`Enter first number: 10, Enter second number: 20`**\n- **Output:**\n\n```\n    Before swapping: a = 10, b = 20\n    After swapping: a = 20, b = 10\n```\n"
  },
  {
    "path": "DAY10/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction Pattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += String.fromCharCode(65 + i - 1) + \" \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern1(5);\n\n// ---------------------------------------------------------------------------------------------------\n//* Pattern - 2\n\nfunction Pattern2(n) {\n  for (let i = 0; i < n; i++) {\n    let rowPattern = \" \";\n\n    for (let j = 0; j < n - i; j++) {\n      rowPattern += `. `;\n    }\n\n    for (let k = 0; k < i; k++) {\n      rowPattern += String.fromCharCode(65 + k) + \" \";\n    }\n\n    for (let l = 0; l <= i; l++) {\n      rowPattern += String.fromCharCode(65 + i - l) + \" \";\n    }\n\n    console.log(rowPattern.trim());\n  }\n}\n\nPattern2(4);\n\n// ---------------------------------------------------------------------------------------------------\n//* Question - 3\n\nlet number1 = 10;\nlet number2 = 28;\n\nconsole.log(\"Before Swap\");\n\nconsole.log(`Number1 : ${number1}`);\nconsole.log(`Number2 : ${number2}`);\n\nfunction SwapTwoNumbers1(num1, num2) {\n  let temp = null;\n\n  temp = num1;\n  num1 = num2;\n  num2 = temp;\n\n  console.log(\"After Swap\");\n\n  console.log(`Number1 : ${num1}`);\n  console.log(`Number2 : ${num2}`);\n}\n\nSwapTwoNumbers1(number1, number2);\n\nfunction SwapTwoNumbers2(num1, num2) {\n  num1 = num1 + num2;\n  num2 = num1 - num2;\n  num1 = num1 - num2;\n\n  console.log(\"After Swap\");\n\n  console.log(`Number1 : ${num1}`);\n  console.log(`Number2 : ${num2}`);\n}\n\n// SwapTwoNumbers2(number1, number2);\n"
  },
  {
    "path": "DAY11/Questions.md",
    "content": "# DAY - 11\n\n1. **Write a Program to Find the Largest Number Among Three Numbers:**\n\n   Write a program where the user enters three numbers, and the program finds and displays the largest number among them. For example:\n\n   - **Input:** **`Enter three numbers: 12, 25, 7`**\n   - **Output:** **`The largest number is: 25`**\n\n2. **Write a Program to Check Whether a Year Entered by the User is a Leap Year:**\n\n   Write a program to determine whether a given year is a leap year. For example:\n\n   - **Input:** **`Enter a year: 2024`**\n   - **Output:** **`2024 is a leap year.`**\n\n3. **Write a Program to Calculate the Sum of the First N Natural Numbers:**\n\n   Write a program where the user enters a number **`N`**, and the program calculates the sum of all natural numbers up to **`N`**. For example:\n\n   - **Input:** **`Enter a number: 5`**\n   - **Output:** **`The sum of the first 5 natural numbers is 15.`**\n"
  },
  {
    "path": "DAY11/Solutions.js",
    "content": "//* Program to Find the Largest Number Among Three Numbers\n\nfunction LargestAmongThreeNums(num1, num2, num3) {\n  if (num1 > num2) {\n    if (num1 > num3) {\n      console.log(`${num1} is Largest`);\n    } else {\n      console.log(`${num3} is Largest`);\n    }\n  } else {\n    if (num2 > num3) {\n      console.log(`${num2} is Largest`);\n    } else {\n      console.log(`${num3} is Largest`);\n    }\n  }\n}\n\nLargestAmongThreeNums(-3, -2, -1);\n\n// --------------------------------------------------------------\n\n//*  Program to Check Whether a Year Entered by the User is a Leap Year\n\nfunction isLeapYear(year) {\n  if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n    console.log(`${year} is a Leap year`);\n  } else {\n    console.log(`${year} is not a Leap Year`);\n  }\n}\n\nisLeapYear(2024);\n\n// --------------------------------------------------------------\n\n//*  Program to Calculate the Sum of the First N Natural Numbers\n\nfunction SumOfFirstNnaturalNums(n) {\n  let sum = 0;\n  for (let i = 1; i <= n; i++) {\n    sum += i;\n  }\n\n  return `Sum : ${sum}`;\n}\n\nconsole.log(SumOfFirstNnaturalNums(5));\n"
  },
  {
    "path": "DAY12/Questions.md",
    "content": "# DAY - 12\n\n1. **Factorial of a Number Using a For Loop:**\n\n   Write a program to calculate the factorial of a number entered by the user using a **`for`** loop. For example:\n\n   - **Input:** **`Enter a number: 4`**\n   - **Output:** **`Factorial of 4 is 24.`**\n\n2. **Print Fibonacci Series:**\n\n   Write a program to print the Fibonacci series up to a number **`N`** entered by the user. For example:\n\n   - **Input:** **`Enter the number of terms: 7`**\n   - **Output:** **`Fibonacci series: 0 1 1 2 3 5 8`**\n\n3. **Write a Program to Find the GCD or HCF of Two Numbers:**\n\n   Write a program where the user enters two numbers, and the program calculates their greatest common divisor (GCD) or highest common factor (HCF). For example:\n\n   - **Input:** **`Enter two numbers: 60, 48`**\n   - **Output:** **`The GCD of 60 and 48 is 12.`**\n"
  },
  {
    "path": "DAY12/Solutions.js",
    "content": "//*  Factorial of a Number Using a For Loop\n\nfunction FindFactorial(n) {\n  let fact = 1;\n\n  for (let i = 1; i <= n; i++) {\n    fact *= i;\n  }\n\n  return fact;\n}\n\nconsole.log(FindFactorial(4));\n\n// ---------------------------------------------------------------------------------\n\n//*  Print Fibonacci Series\n\nfunction PrintFibonacciSeries(n) {\n  let prev = 0,\n    next = 1;\n\n  let series = `${prev} ${next}`;\n\n  for (let i = 2; i < n; i++) {\n    let result = prev + next;\n    series += ` ${result}`;\n\n    prev = next;\n    next = result;\n  }\n\n  console.log(series);\n}\n\nPrintFibonacciSeries(7);\n\n// ---------------------------------------------------------------------------------\n\n//*  Write a Program to Find the GCD or HCF of Two Numbers\n\nfunction findHCF(num1, num2) {\n  let hcf = 1;\n\n  //   let i = Math.min(num1, num2); i >= 1;  i--\n\n  for (let i = 1; i < Math.min(num1, num2); i++) {\n    if (num1 % i === 0 && num2 % i === 0) {\n      hcf = i;\n    }\n  }\n  return hcf;\n}\n\nconsole.log(findHCF(60, 48));\n"
  },
  {
    "path": "DAY13/Questions.md",
    "content": "# DAY - 13\n\n1. **Write a Program to Find the LCM of Two Numbers:**\n\n   Write a program where the user enters two numbers, and the program calculates their least common multiple (LCM). For example:\n\n   - **Input:** **`Enter two numbers: 4, 6`**\n   - **Output:** **`The LCM of 4 and 6 is 12.`**\n\n2. **Write a Program to Calculate the Power of a Number:**\n\n   Write a program that takes a base and an exponent as input and calculates the power of the base raised to the exponent using both manual calculation and the **`pow()`** function. For example:\n\n   - **Input:** **`Base: 2, Exponent: 3`**\n   - **Output:**\n     ```markdown\n     Result using manual calculation: 8\n     Result using pow(): 8\n     ```\n\n3. **Program to Print Integers in Words:**\n\n   Write a program that converts each digit of an integer entered by the user into its corresponding word representation. For example:\n\n   - **Input:** **`Enter a number: 123`**\n   - **Output:** **`One Two Three`**\n"
  },
  {
    "path": "DAY13/Solutions.js",
    "content": "//* Write a Program to Find the LCM of Two Numbers\n\nfunction findLCM(num1, num2) {\n  if (num1 === 0 || num2 === 0) {\n    return \"LCM is not defined for zero.\";\n  }\n\n  let lcm = null;\n  let max = Math.max(Math.abs(num1), Math.abs(num2));\n\n  while (true) {\n    if (max % num1 == 0 && max % num2 == 0) {\n      lcm = max;\n      break;\n    }\n    max++;\n  }\n\n  return lcm;\n}\n\nconsole.log(findLCM(5, 7));\n\n// -----------------------------------------------------------------------------------------------------------\n\n//* Write a Program to Calculate the Power of a Number\n\nfunction findPowerManual(base, expo) {\n  let power = base ** expo;\n\n  return power;\n}\n\n// console.log(findPowerManual(2, 3));\n\nfunction findPowerBuiltIn(base, expo) {\n  let power = Math.pow(base, expo);\n  return power;\n}\n\nconsole.log(findPowerBuiltIn(2, 3));\n\n// -----------------------------------------------------------------------------------------------------------\n\n//* Program to Print Integers in Words\n\nfunction DigitToWord(num) {\n  const digitToWord = [\n    \"Zero\",\n    \"One\",\n    \"Two\",\n    \"Three\",\n    \"Four\",\n    \"Five\",\n    \"Six\",\n    \"Seven\",\n    \"Eight\",\n    \"Nine\",\n  ];\n\n  let numStr = num.toString();\n  let result = \" \";\n\n  for (let i = 0; i < numStr.length; i++) {\n    let char = numStr[i];\n\n    if (char === \"-\") {\n      result += \"Negative \";\n    } else {\n      result += digitToWord[parseInt(char)] + \" \";\n    }\n  }\n\n  return result.trim();\n}\n\nconsole.log(DigitToWord(1028));\n"
  },
  {
    "path": "DAY14/Questions.md",
    "content": "# DAY - 14\n\n1. **Print Numbers in Words in Reverse Order Using a Switch Case:**\n\n   Write a program that takes an integer, reverses it, and prints each digit as a word using a **`switch`** case. For example:\n\n   - **Input:** **`Enter a number: 321`**\n   - **Output:** **`One Two Three`**\n\n2. **Write a Program to Display All Factors of a Number:**\n\n   Write a program to find and print all factors of a number entered by the user. For example:\n\n   - **Input:** **`Enter a number: 28`**\n   - **Output:** **`Factors of 28: 1, 2, 4, 7, 14, 28`**\n\n3. **Amstrong Number or Not:**\n\n   Write a program to check if a number is an Armstrong number. For example:\n\n   - **Input:** **`Enter a number: 153`**\n   - **Output:** **`153 is an Armstrong number.`**\n"
  },
  {
    "path": "DAY14/Solutions.js",
    "content": "//*  Print Numbers in Words in Reverse Order Using a Switch Case\n\nfunction NumToWordsReverse(num) {\n  if (isNaN(num)) {\n    console.log(\"Invalid Input\");\n    return;\n  }\n\n  let result = \"\";\n\n  if (num < 0) {\n    result += \"Negative \";\n    num = Math.abs(num);\n  }\n\n  while (num > 0) {\n    let digit = num % 10;\n\n    switch (digit.toString()) {\n      case \"0\":\n        result += \"Zero \";\n        break;\n      case \"1\":\n        result += \"One \";\n        break;\n      case \"2\":\n        result += \"Two \";\n        break;\n      case \"3\":\n        result += \"Three \";\n        break;\n      case \"4\":\n        result += \"Four \";\n        break;\n      case \"5\":\n        result += \"Five \";\n        break;\n      case \"6\":\n        result += \"Six \";\n        break;\n      case \"7\":\n        result += \"Seven \";\n        break;\n      case \"8\":\n        result += \"Eight \";\n        break;\n      case \"9\":\n        result += \"Nine \";\n        break;\n    }\n\n    num = Math.floor(num / 10);\n  }\n\n  return result;\n}\n\nconsole.log(NumToWordsReverse(-321));\n\n// -----------------------------------------------------------\n\n//*  Write a Program to Display All Factors of a Number\n\nfunction PrintFactors(n) {\n  let result = [];\n\n  for (let i = 1; i <= n; i++) {\n    if (n % i === 0) {\n      result.push(i);\n    }\n  }\n\n  return result;\n}\n\nconsole.log(PrintFactors(28));\n\n// ----------------------------------------------------------\n\n//*  Amstrong Number or Not:\n\nfunction ValidAmstrong(num) {\n  if (isNaN(num) || num < 0) {\n    console.log(\"Invalid Input, Please enter a non-negative integer.\");\n    return;\n  }\n\n  let OriginalNum = num;\n  let DigitCount = num.toString().length;\n  let result = 0;\n\n  while (num > 0) {\n    let digit = num % 10;\n\n    result += digit ** DigitCount;\n\n    num = Math.floor(num / 10);\n  }\n\n  result === OriginalNum\n    ? console.log(`${OriginalNum} is an Amstrong Number`)\n    : console.log(`${OriginalNum} is not an Amstrong Number`);\n}\n\nValidAmstrong(1634);\n"
  },
  {
    "path": "DAY15/Questions.md",
    "content": "# DAY - 15\n\n1. **Check Whether a Number is Prime or Not:**\n\n   Write a program that checks if a number entered by the user is a prime number. For example:\n\n   - **Input:** **`Enter a number: 17`**\n   - **Output:** **`17 is a prime number.`**\n\n2. **Print Prime Numbers Within a Range:**\n\n   Write a program to display all prime numbers between two intervals entered by the user. For example:\n\n   - **Input:** **`Enter two numbers: 10, 30`**\n   - **Output:** **`Prime numbers between 10 and 30: 11, 13, 17, 19, 23, 29`**\n\n3. **Print Factorial Series:**\n\n   Write a program that prints the factorial of numbers from 1 to **`N`**, where the user enters N. For example:\n\n   - **Input:** **`Enter a number: 5`**\n   - **Output:**\n     ```\n     1! = 1\n     2! = 2\n     3! = 6\n     4! = 24\n     5! = 120\n     ```\n"
  },
  {
    "path": "DAY15/Solutions.js",
    "content": "//*  Check Whether a Number is Prime or Not\n\nfunction ValidPrime(num) {\n  if (num <= 1) {\n    return `${num} is Not Prime`;\n  }\n\n  if (num == 2) {\n    return `${num} is Prime`;\n  }\n\n  if (num % 2 === 0) {\n    return `${num} is Not Prime`;\n  }\n\n  for (let i = 3; i <= Math.sqrt(num); i += 2) {\n    if (num % i === 0) {\n      return `${num} is Not Prime`;\n    }\n  }\n  return `${num} is Prime`;\n}\n\nconsole.log(ValidPrime(5));\n\n// -----------------------------------------------------------\n\n//*  Print Prime Numbers Within a Range\n\nfunction PrimeNumsInRange(start, end) {\n  let result = [];\n  for (let i = Math.max(start, 2); i <= end; i++) {\n    let isPrime = true;\n\n    for (let j = 2; j <= Math.sqrt(i); j++) {\n      if (i % j === 0) {\n        isPrime = false;\n        break;\n      }\n    }\n\n    if (isPrime) result.push(i);\n  }\n  return result;\n}\n\nconsole.log(PrimeNumsInRange(5, 15));\n\n// -----------------------------------------------------------\n\n//*  Print Factorial Series\n\nfunction PrintFactorialSeries1(num) {\n  for (let i = 1; i <= num; i++) {\n    let fact = 1;\n    for (let j = 1; j <= i; j++) {\n      fact = fact * j;\n    }\n    console.log(`${i}! = ${fact}`);\n  }\n}\n\n// PrintFactorialSeries1(5);\n\nfunction PrintFactorialSeries2(num) {\n  let fact = 1;\n  for (let i = 1; i <= num; i++) {\n    fact = fact * i;\n    console.log(`${i}! = ${fact}`);\n  }\n}\n\nPrintFactorialSeries2(5);\n"
  },
  {
    "path": "DAY16/Questions.md",
    "content": "# DAY - 16\n\n1. **Write a Program to Check Whether a Number is a Palindrome:**\n\n   Write a program to determine if a number is a palindrome. For example:\n\n   - **Input:** **`Enter a number: 121`**\n   - **Output:** **`121 is a palindrome.`**\n\n2. **Check if an Integer Can Be Expressed as the Sum of Two Prime Numbers:**\n\n   Write a program to check if a number can be expressed as the sum of two prime numbers. Print all such combinations. For example:\n\n   - **Input:** **`Enter a number: 34`**\n   - **Output:**\n     ```\n     34 = 3 + 31\n     34 = 5 + 29\n     34 = 11 + 23\n     34 = 17 + 17\n     ```\n\n3. **Print All Digits and Alphabets Using a For Loop:**\n\n   Write a program to print all digits (0–9) and alphabets (A–Z, a–z) using a **`for`** loop. For example:\n\n   - **Output:**\n     ```markdown\n     Digits: 0 1 2 3 4 5 6 7 8 9\n     Alphabets: A B C ... Z a b c ... z\n     ```\n"
  },
  {
    "path": "DAY16/Solutions.js",
    "content": "//*  Write a Program to Check Whether a Number is a Palindrome\n\nfunction ValidPalindrome(num) {\n  if (isNaN(num)) {\n    return \"Invalid Input!\";\n  }\n\n  let OriginalNum = num;\n  let reversedNum = 0;\n\n  while (num > 0) {\n    let rem = num % 10;\n    reversedNum = reversedNum * 10 + rem;\n    num = Math.floor(num / 10);\n  }\n\n  console.log(reversedNum);\n\n  if (OriginalNum === reversedNum) {\n    return `${OriginalNum} is a Valid Palindrome`;\n  }\n\n  return `${OriginalNum} is not a Valid Palindrome`;\n}\n\nconsole.log(ValidPalindrome(12));\n\n// ----------------------------------------------------------------------\n\n//*  Check if an Integer Can Be Expressed as the Sum of Two Prime Numbers\n\nfunction isPrime(n) {\n  if (n < 1) return false;\n  for (let i = 2; i < Math.sqrt(n); i++) {\n    if (n % i === 0) return false;\n  }\n  return true;\n}\nfunction SumOfTwoPrimes(N) {\n  let Primes = [];\n  for (let i = 2; i <= N / 2; i++) {\n    let compliment = N - i;\n\n    if (isPrime(i) && isPrime(compliment)) {\n      Primes.push(`${N} = ${i} + ${compliment}`);\n      //   Primes.push(i, compliment);\n    }\n  }\n\n  if (Primes.length === 0) {\n    console.log(`${N} cannot be expressed as the sum of two prime numbers`);\n  } else {\n    console.log(Primes.join(\"\\n\"));\n  }\n}\n\nSumOfTwoPrimes(34);\n\n// -------------------------------------------------------------------------\n\n//*  Print All Digits and Alphabets Using a For Loop\n\nfunction PrintNumbers() {\n  let Digits = [];\n  for (let i = 0; i < 10; i++) {\n    Digits.push(i);\n  }\n\n  return Digits;\n}\n\nfunction PrintAlphabets() {\n  let Alphabets = [];\n  for (let i = \"A\".charCodeAt(0); i <= \"Z\".charCodeAt(0); i++) {\n    Alphabets.push(String.fromCharCode(i));\n  }\n\n  for (let i = \"a\".charCodeAt(0); i <= \"z\".charCodeAt(0); i++) {\n    Alphabets.push(String.fromCharCode(i));\n  }\n\n  return Alphabets;\n}\n\nconsole.log(PrintNumbers());\nconsole.log(PrintAlphabets());\n"
  },
  {
    "path": "DAY17/Questions.md",
    "content": "# DAY - 17\n\n1. **Write a Program to Convert Binary Numbers to Decimal and Vice Versa Manually:**\n\n   Write a program that uses user-defined functions to convert binary numbers to decimal and decimal numbers to binary. For example:\n\n   - **Input:** **`Enter a binary number: 1010`**\n   - **Output:** **`Decimal equivalent: 10`**\n   - **Input:** **`Enter a decimal number: 10`**\n   - **Output:** **`Binary equivalent: 1010`**\n\n2. Pattern - 1\n\n   ```\n   *\n   * *\n   * * *\n   * * * *\n   * * * * *\n   * * * *\n   * * *\n   * *\n   *\n   ```\n\n3. Pattern - 2\n\n```\n        *\n      * * *\n    * * * * *\n  * * * * * * *\n* * * * * * * * *\n  * * * * * * *\n    * * * * *\n      * * *\n        *\n```\n"
  },
  {
    "path": "DAY17/Solutions.js",
    "content": "//* Program to Convert Binary Numbers to Decimal and Vice Versa Manually:\n\n// Function to convert Binary to Decimal\nfunction binaryToDecimal(binary) {\n  let decimal = 0;\n  let position = 0;\n\n  while (binary > 0) {\n    let digit = binary % 10; // Extract the last digit\n    decimal += digit * Math.pow(2, position); // Multiply by 2^position\n    position++;\n    binary = Math.floor(binary / 10); // Remove the last digit\n  }\n\n  return decimal;\n}\n\n// Function to convert Decimal to Binary\nfunction decimalToBinary(decimal) {\n  let binary = \"\";\n\n  while (decimal > 0) {\n    let remainder = decimal % 2; // Get remainder\n    binary = remainder + binary; // Add remainder to the left\n    decimal = Math.floor(decimal / 2); // Divide by 2\n  }\n\n  return binary || \"0\"; // If input is 0, return \"0\"\n}\n\n// User Input and Output\nconst binaryInput = 1010;\nconsole.log(\n  `Binary ${binaryInput} -> Decimal: ${binaryToDecimal(binaryInput)}`\n);\n\nconst decimalInput = 10;\nconsole.log(\n  `Decimal ${decimalInput} -> Binary: ${decimalToBinary(decimalInput)}`\n);\n\n// -----------------------------------------------------------\n\n//* Pattern - 1\n\nfunction PrintPattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern.trim());\n  }\n  for (let i = n - 1; i >= 1; i--) {\n    let rowPattern = \" \";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern.trim());\n  }\n}\n\nPrintPattern1(5);\n\n// ----------------------------------------------------------\n\n//* Pattern - 2\n\n\nfunction PrintPattern2(n) {\n  // Upper half of the pattern\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"  \".repeat(n - i) + \"* \".repeat(i * 2 - 1);\n    console.log(rowPattern);\n    // console.log(rowPattern.trim());\n  }\n\n  // Lower half of the pattern\n  for (let i = n - 1; i >= 1; i--) {\n    let rowPattern = \" \".repeat((n - i) * 2) + \"* \".repeat(i * 2 - 1);\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern2(5);\n"
  },
  {
    "path": "DAY17/notes.md",
    "content": "## Binary to Decimal Conversion:\n\n### Binary Number:\n\n- A binary number is made up of 0's and 1's and uses base 2.\n- To convert a binary number to decimal, multiply each binary digit (bit) by 2nd position, where the position starts from 0 (right to left).\n  Add up all these values to get the decimal number\n\n---\n\n## Decimal to Binary Conversion:\n\n### Decimal Number:\n\n- A number using base 10 (0-9 digits).\n- To convert to binary: Repeatedly divide the decimal number by 2.\n- Record the remainder at each step (this will be the binary digit).\n- Continue until the quotient becomes 0.\n- Read the remainders from bottom to top to get the binary number.\n\n---\n\n## repeat() method\n\n- The repeat() method in JavaScript is a built-in method for strings.\n- It allows a string to be repeated a specified number of times.\n\n### Syntax:\n\nstring.repeat(count); where\n\n- string: The string to repeat.\n- count: The number of times to repeat the string. This must be a non-negative integer.\n"
  },
  {
    "path": "DAY18/Questions.md",
    "content": "# DAY - 18\n\n**Pattern - 1**\n\n```\n*                 *\n* *             * *\n* * *         * * *\n* * * *     * * * *\n* * * * * * * * * *\n* * * *     * * * *\n* * *         * * *\n* *             * *\n*                  *\n```\n\n**Pattern - 2**\n\n```\n* * * * * * * * * *\n* * * *     * * * *\n* * *         * * *\n* *             * *\n*                 *\n*                 *\n* *             * *\n* * *         * * *\n* * * *     * * * *\n* * * * * * * * * *\n```\n\n**Pattern - 3**\n\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n\n```\n"
  },
  {
    "path": "DAY18/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction PrintPattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n\n    for (let k = 1; k <= 2 * (n - i); k++) {\n      rowPattern += \"  \";\n    }\n\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern);\n  }\n\n  for (let i = n - 1; i >= 1; i--) {\n    let rowPattern = \"\";\n\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n\n    for (let k = 1; k <= 2 * (n - i); k++) {\n      rowPattern += \"  \";\n    }\n\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern1(5);\n\nfunction PrintPattern1Optimized(n) {\n  for (let i = 1; i <= 2 * n - 1; i++) {\n    // Determine the row index\n    let rowIndex = i <= n ? i : 2 * n - i;\n\n    // Left stars\n    let leftStars = \"* \".repeat(rowIndex);\n\n    // Middle spaces\n    let middleSpaces = \"  \".repeat(2 * (n - rowIndex));\n\n    // Right stars\n    let rightStars = \"* \".repeat(rowIndex);\n\n    // Print the complete row\n    console.log(leftStars + middleSpaces + rightStars);\n  }\n}\n\n// PrintPattern1Optimized(5);\n\n// -----------------------------------------------------------\n\n//* Pattern - 2\n\nfunction PrintPattern2(n) {\n  for (let i = n; i >= 1; i--) {\n    rowPattern = \"\";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n\n    for (let k = 1; k <= 2 * (n - i); k++) {\n      rowPattern += \"  \";\n    }\n\n    for (let l = 1; l <= i; l++) {\n      rowPattern += \"* \";\n    }\n\n    console.log(rowPattern);\n  }\n\n  for (let i = 1; i <= n; i++) {\n    rowPattern = \"\";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += \"* \";\n    }\n\n    for (let k = 1; k <= 2 * (n - i); k++) {\n      rowPattern += \"  \";\n    }\n\n    for (let l = 1; l <= i; l++) {\n      rowPattern += \"* \";\n    }\n\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern2(5);\n\n// ----------------------------------------------------------\n\n//* Pattern - 3\n\nfunction PrintPattern3(n) {\n  let num = 1;\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n    for (let j = 1; j <= i; j++) {\n      rowPattern += num + \" \";\n      num++;\n    }\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern3(5);\n"
  },
  {
    "path": "DAY19/Questions.md",
    "content": "# DAY - 19\n\n## Pattern 1:\n\n```\n1\n0 1\n1 0 1\n0 1 0 1\n1 0 1 0 1\n```\n\n## Pattern 2:\n\n```\n4 4 4 4 4 4 4\n4 3 3 3 3 3 4\n4 3 2 2 2 3 4\n4 3 2 1 2 3 4\n4 3 2 2 4 3 4\n4 3 3 3 3 3 4\n4 4 4 4 4 4 4\n```\n\n## Pattern 3:\n\n```\nE\nD E\nC D E\nB C D E\nA B C D E\n```\n"
  },
  {
    "path": "DAY19/Solutions.js",
    "content": "//*  Pattern - 1\n\nfunction PrintPattern1(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    for (let j = 1; j <= i; j++) {\n      if ((i + j) % 2 == 0) {\n        rowPattern += 1 + \" \";\n      } else {\n        rowPattern += 0 + \" \";\n      }\n    }\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern1(5);\n\n// --------------------------------------------------------------------------------\n\n//* Pattern - 2\n\nfunction PrintPattern2(n) {\n  let size = 2 * n - 1;\n  for (let i = 1; i <= size; i++) {\n    let rowPattern = \"\";\n    for (let j = 1; j <= size; j++) {\n      let value =\n        n -\n        Math.min(\n          Math.min(i - 1, size - i), // Distance from top or bottom edge\n          Math.min(j - 1, size - j) // Distance from left or right edge\n        );\n      rowPattern += `${value} `;\n    }\n\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern2(4);\n\n// -------------------------------------------------------------------------------\n\n//* Pattern - 3\n\nfunction PrintPattern3(n) {\n  let startChar = \"E\".charCodeAt(0);\n\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    let currentChar = startChar - i;\n\n    for (let j = 1; j <= i; j++) {\n      rowPattern += String.fromCharCode(currentChar + j) + \" \";\n    }\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern3(5);\n"
  },
  {
    "path": "DAY20/Questions.md",
    "content": "# DAY - 20\n\n## Pattern 1\n\n```\n   *\n  * *\n *   *\n*     *\n *   *\n  * *\n   *\n```\n\n## Pattern 2\n\n```\n    1\n  1 2 1\n1 2 3 2 1\n\n```\n\n## Pattern 3\n\n```\n0 1 0 1\n1 0 1 0\n0 1 0 1\n1 0 1 0\n```\n"
  },
  {
    "path": "DAY20/Solutions.js",
    "content": "//* Pattern - 1\n\nfunction PrintPattern1(n) {\n  // Top half of the diamond\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    rowPattern += \" \".repeat(n - i);\n\n    // Print stars and spaces\n    for (let j = 1; j <= 2 * i - 1; j++) {\n      if (j === 1 || j === 2 * i - 1) {\n        rowPattern += \"*\";\n      } else {\n        rowPattern += \" \";\n      }\n    }\n\n    console.log(rowPattern);\n  }\n\n  // Bottom half of the diamond\n  for (let i = n - 1; i >= 1; i--) {\n    let rowPattern = \"\";\n\n    rowPattern += \" \".repeat(n - i);\n\n    // Print stars and spaces\n    for (let j = 1; j <= 2 * i - 1; j++) {\n      if (j === 1 || j === 2 * i - 1) {\n        rowPattern += \"*\";\n      } else {\n        rowPattern += \" \";\n      }\n    }\n\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern1(4);\n\n// ----------------------------------------------------------\n\n//* Pattern - 2\n\nfunction PrintPattern2(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    // Print leading spaces\n    rowPattern += \".\".repeat(2 * (n - i));\n\n    // Print ascending numbers\n    for (let j = 1; j <= i; j++) {\n      rowPattern += j + \" \";\n    }\n\n    // Print descending numbers\n    for (let j = i - 1; j >= 1; j--) {\n      rowPattern += j + \" \";\n    }\n\n    console.log(rowPattern.trim());\n  }\n}\n\nPrintPattern2(3);\n\n// ----------------------------------------------------------\n\n//* Pattern - 3\n\nfunction PrintPattern3(n) {\n  for (let i = 1; i <= n; i++) {\n    let rowPattern = \"\";\n\n    for (let j = 1; j <= n; j++) {\n      if ((i + j) % 2 == 0) {\n        rowPattern += \"0 \";\n      } else {\n        rowPattern += \"1 \";\n      }\n    }\n    console.log(rowPattern);\n  }\n}\n\nPrintPattern3(4);\n"
  },
  {
    "path": "DAY21/Questions.md",
    "content": "# DAY - 21\n\n1. **Perfect Number**\n   Write a program to determine if a number is a perfect number.\n\n   - **Input:** **`number = 6`**\n   - **Output:** **`Perfect Number`**\n   - Explanation: 6 is a perfect number because its divisors (1, 2, 3) sum up to 6.\n\n2. **Largest Prime Factor**\n   Write a program to find the largest prime factor of a given number.\n\n   - **Input:** **`number = 28`**\n   - **Output:** **`7`**\n\n3. **Sum of the series of n terms**\n   Write a program to calculate the sum of the series 1 + 1/2 + 1/3 + ... + 1/n up to the nth term.\n\n   - **Input:** **`n = 4`**\n   - **Output:** **`2.083333`**\n"
  },
  {
    "path": "DAY21/Solutions.js",
    "content": "//* Perfect Number\n\nfunction PerfectNum(n) {\n  if (n <= 0) {\n    return `Input must be Posivitve Number`;\n  }\n\n  let sum = 0;\n  for (let i = 1; i < n; i++) {\n    if (n % i === 0) {\n      sum += i;\n    }\n  }\n\n  sum === n\n    ? console.log(`${n} is a Perfect Number`)\n    : console.log(`${n} is Not a perfect number`);\n}\n\nPerfectNum(28);\n\n// ----------------------------------------------------------\n\n//* Largest Prime Factor\n\nfunction isPrime(n) {\n  if (n <= 1) return false;\n  for (let i = 2; i < Math.sqrt(n); i++) {\n    if (n % i == 0) return false;\n  }\n  return true;\n}\n\nfunction LargestPrimeFactor(num) {\n  if (num <= 1) return \"No prime factors\";\n  let MaxPrime = -1;\n  for (let i = 2; i < Math.sqrt(num); i++) {\n    if (num % i == 0 && isPrime(i)) {\n      MaxPrime = i;\n    }\n  }\n\n  // Check if the remaining number is a prime factor\n  //   if (num > 1 && isPrime(num)) {\n  //     MaxPrime = num;\n  //   }\n\n  return MaxPrime;\n}\n\nconsole.log(LargestPrimeFactor(13195));\n\n// ---------------------------------------------------------\n\n//* Sum of Series of n terms\n\nfunction SumSeries(n) {\n  if (n <= 0) {\n    return `Input must be Posivitve Number`;\n  }\n\n  let sum = 0;\n\n  for (let i = 1; i <= n; i++) {\n    sum = sum + 1 / i;\n  }\n\n  return parseFloat(sum.toFixed(3));\n}\n\nconsole.log(SumSeries(4));\n"
  },
  {
    "path": "DAY22/Questions.md",
    "content": "# DAY - 22\n\n1. **Print the Array in Sorted Order (Ascending and Descending):**\n\n   Write a program to sort an array in ascending and descending order. For example:\n\n   - **Input:** **`[5, 3, 8, 1]`**\n   - **Output:**\n     ```\n     Ascending: [1, 3, 5, 8]\n     Descending: [8, 5, 3, 1]\n     ```\n\n2. **Finding the Longest Sequence of Consecutive 1s in a Binary Array**\n\n   Write a program to find the longest sequence of consecutive 1s in a binary array.\n\n   - **Input:** binaryArray = [1, 1, 0, 1, 1, 1]\n   - **Output:** 3\n\n3. **Finding the Most Frequent Element in an Array**\n\n   Write a program to find the most frequent element in an array.\n\n   - **Input:** array = [1, 2, 2, 3, 3, 3]\n   - **Output:** 3\n"
  },
  {
    "path": "DAY22/Solutions.js",
    "content": "//*  Print the Array in Sorted Order (Ascending and Descending)\n\n/*\n  Built-In Methods\nAscending Order : arr.sort((a, b) => a - b);\nDescending Order : arr.sort((a, b) => b - a);\n\n*/\n\nfunction SortAscendingOrder(arr) {\n  for (let i = 0; i < arr.length - 1; i++) {\n    for (let j = i + 1; j < arr.length; j++) {\n      if (arr[i] > arr[j]) {\n        let temp = arr[i];\n        arr[i] = arr[j];\n        arr[j] = temp;\n      }\n    }\n  }\n\n  return arr;\n}\n\nfunction SortDescendingOrder(arr) {\n  for (let i = 0; i < arr.length - 1; i++) {\n    for (let j = i + 1; j < arr.length; j++) {\n      if (arr[i] < arr[j]) {\n        let temp = arr[i];\n        arr[i] = arr[j];\n        arr[j] = temp;\n      }\n    }\n  }\n\n  return arr;\n}\n\nconsole.log(SortAscendingOrder([5, 3, 8, 1]));\nconsole.log(SortDescendingOrder([5, 3, 8, 1]));\n\n// ---------------------------------------------------------------------------\n\n//*  Finding the Longest Sequence of Consecutive 1s in a Binary Array\n\nfunction LongConsequence1(arr) {\n  let count = 0;\n  for (let i = 0; i < arr.length; i++) {\n    if (arr[i] == 1) {\n      count++;\n    } else {\n      count = 0;\n    }\n  }\n  return count;\n}\n\nconsole.log(LongConsequence1([1, 1, 0, 1, 1, 1, 1]));\n\n// --------------------------------------------------------------------------\n\n//*  Finding the Most Frequent Element in an Array\n\n// Return the most frequent number, else returns -1\n\nfunction MostFrequentElement(arr) {\n  let FrequentNum = -1;\n  let MaxCount = 0;\n\n  for (let i = 0; i < arr.length; i++) {\n    let count = 0;\n\n    for (let j = 0; j < arr.length; j++) {\n      if (arr[i] == arr[j]) {\n        count++;\n      }\n    }\n\n    if (MaxCount < count) {\n      MaxCount = Math.max(MaxCount, count);\n      MaxCount > 1 ? (FrequentNum = arr[i]) : (FrequentNum = -1);\n    }\n  }\n\n  return FrequentNum;\n}\n\nconsole.log(MostFrequentElement([1, 2, 3, 4, 5]));\n"
  },
  {
    "path": "DAY23/Questions.md",
    "content": "# DAY - 23\n\n1. **Find the Missing Number in an Array**\n\n   - Given an array of numbers from 1 to n with one number missing, find the missing number.\n   - **Input:** **[1, 2, 4, 5, 6]**\n   - **Output:** **Missing Number: 3**\n\n2. **Find the Majority Element in an Array**\n\n   - Find the element that appears more than n/2 times in the array (if any).\n   - **Input:** **[3, 3, 4, 2, 4, 4, 2, 4, 4]**\n   - **Output:** **Majority Element: 4**\n\n3. **Reverse an Array**\n   - Reverse the order of elements in the given array.\n   - **Input:** **[1, 2, 3, 4, 5]**\n   - **Output:** **[5, 4, 3, 2, 1]**\n"
  },
  {
    "path": "DAY23/Solutions.js",
    "content": "//* Missing Number\n\nfunction FindMissingNum(arr) {\n  let MissingNum = null;\n\n  let n = arr.length + 1;\n\n  let TotalSum = (n * (n + 1)) / 2;\n\n  let ActualSum = arr.reduce((acc, currNum) => acc + currNum, 0);\n\n  MissingNum = TotalSum - ActualSum;\n\n  return MissingNum;\n}\n\nconsole.log(FindMissingNum([1, 2, 4, 5, 6]));\n\n// -----------------------------------------------------------------\n\n//* Majority Element\n\nfunction FindMajorityElement(arr) {\n  let MajorityCount = arr.length / 2;\n  let MajorityElem = 0;\n\n  for (let i = 0; i < arr.length; i++) {\n    let count = 0;\n\n    for (let j = 0; j < arr.length; j++) {\n      if (arr[i] == arr[j]) {\n        count++;\n      }\n    }\n\n    if (count > MajorityCount) {\n      MajorityCount = count;\n      MajorityElem = arr[i];\n    }\n  }\n\n  return MajorityElem;\n}\n\nconsole.log(FindMajorityElement([3, 3, 4, 2, 4, 4, 2, 4, 4]));\n\n// ---------------------------------------------------------------\n\n//* Reverse an Array\n\n/*\n    arr.reverse() method returns a new array with the desired result, but it also modifies the existing array as well\n\n    arr.toReversed() method returns a new array with the desired result, but it will not modify the existing array.\n*/\n\nfunction ReverseArray(arr) {\n  //   let reversedArr = arr.reverse();\n  let reversedArr = arr.toReversed();\n\n  //   console.log(arr);\n  console.log(reversedArr);\n}\n\nReverseArray([1, 2, 3, 4, 5]);\n"
  },
  {
    "path": "DAY24/Questions.md",
    "content": "# DAY - 24\n\n1.  **Find the Second Largest Element in an Array**\n\n    - Find the second largest element in the array.\n    - **Input:** **[10, 20, 4, 45, 99]**\n    - **Output:** **Second Largest: 45**\n\n2.  **Remove Duplicates from an Array**\n\n    - Remove all duplicates from the given array and return the unique elements..\n    - **Input:** **[1, 2, 2, 3, 4, 1, 5]**\n    - **Output:** **[1, 2, 3, 4, 5]**\n\n3.  **Move Zeros to the End of an Array**\n\n    - Move all zeros in the array to the end while maintaining the relative order of non-zero elements.\n    - **Input:** **[0, 1, 2, 0, 3, 4, 0]**\n    - **Output:** **[1, 2, 3, 4, 0, 0, 0]**\n"
  },
  {
    "path": "DAY24/Solutions.js",
    "content": "//*  Find the Second Largest Element in an Array\n\nfunction FindSecondLargest(arr) {\n  if (arr.length < 2) {\n    return \"Array must have atleast two elements\";\n  }\n\n  let FirstMax = -Infinity;\n  let SecondMax = -Infinity;\n\n  for (let i = 0; i < arr.length; i++) {\n    if (arr[i] > FirstMax) {\n      SecondMax = FirstMax;\n      FirstMax = arr[i];\n    } else if (arr[i] > SecondMax && arr[i] < FirstMax) {\n      SecondMax = arr[i];\n    }\n  }\n\n  return SecondMax;\n}\n\nconsole.log(FindSecondLargest([10, 20, 4, 45, 99]));\n\n// -----------------------------------------------------------------\n\n//* Remove Duplicates from an Array\n\nfunction RemoveDuplicates(arr) {\n  let result = [];\n\n  for (let i = 0; i < arr.length; i++) {\n    let elem = arr[i];\n    if (!result.includes(elem)) {\n      result.push(elem);\n    }\n  }\n\n  return result;\n}\n\nconsole.log(RemoveDuplicates([1, 2, 2, 3, 4, 1, 5]));\n\n// ----------------------------------------------------------------\n\n//*  Move Zeros to the End of an Array\n\nfunction MoveZeroEnd(arr) {\n  let result = [];\n  let count = 0;\n\n  for (let i = 0; i < arr.length; i++) {\n    if (arr[i] == 0) {\n      count++;\n    }\n  }\n\n  for (let i = 0; i < arr.length; i++) {\n    if (arr[i] != 0) {\n      result.push(arr[i]);\n    }\n  }\n\n  for (let i = 0; i < count; i++) {\n    result.push(0);\n  }\n\n  return result;\n}\n\nconsole.log(MoveZeroEnd([0, 1, 2, 0, 3, 4, 0]));\n"
  },
  {
    "path": "DAY25/Questions.md",
    "content": "# DAY - 25\n\n1.  **Find the Frequency of Each Element in an Array**\n\n    Calculate the frequency of each element in the array.\n\n    - **Input: [1, 2, 2, 3, 1, 4, 5, 1]**\n    - **Output: {1: 3, 2: 2, 3: 1, 4: 1, 5: 1}**\n\n2.  **Check Palindrome**\n\n    Determine if a string reads the same backward as forward.\n\n    - **Input: \"madam\"**\n    - **Output: \"Palindrome\"**\n\n3.  **Count Words in a String**\n\n    Count the number of words in a sentence.\n\n    - **Input: \"I love programming\"**\n    - **Output: 3**\n"
  },
  {
    "path": "DAY25/Solutions.js",
    "content": "//* Find the Frequency of Each Element in an Array\n\nfunction FindFrequencyofElements(arr) {\n  let frequency = {};\n\n  for (let num of arr) {\n    if (frequency[num]) {\n      frequency[num]++;\n    } else {\n      frequency[num] = 1;\n    }\n  }\n\n  return frequency;\n}\n\nconsole.log(FindFrequencyofElements([1, 2, 2, 3, 1, 4, 5, 1]));\n\n// ---------------------------------------------------------------------\n\n//*  Check Palindrome\n\nfunction checkPalindromString(str) {\n  let OriginalStr = str;\n  let reverseStr = \"\";\n\n  let ptrJ = str.length - 1;\n\n  for (let i = 0; i < str.length; i++) {\n    if (str.charAt(i) == str.charAt(ptrJ)) {\n      reverseStr = reverseStr + str.charAt(i);\n    }\n    ptrJ--;\n  }\n\n  if (reverseStr === OriginalStr) {\n    return `\"${OriginalStr}\" is a Palindrome`;\n  } else {\n    return `\"${OriginalStr}\" is not a Palindrome`;\n  }\n}\n\nconsole.log(checkPalindromString(\"madam\"));\n\n// ---------------------------------------------------------------------\n\n//*  Count Words in a String\n\nfunction FindWordsCount(str) {\n  return str.split(\" \").length;\n}\nconsole.log(FindWordsCount(\"I love programming\"));\n"
  },
  {
    "path": "DAY26/Questions.md",
    "content": "# DAY - 27\n\n1. **Longest Word in a Sentence**\n\n   Find the longest word in a given sentence.\n\n   - **Input: \"The quick brown fox\"**\n   - **Output: \"quick\"**\n\n2. **Find the First Non-Repeating Character**\n\n   Identify the first character that does not repeat in the string.\n\n   - **Input: \"swiss\"**\n   - **Output: \"w\"**\n\n3. **Find All Substrings of a String**\n\n   Print all possible substrings of a string.\n\n   - **Input: \"abc\"**\n   - **Output: [\"a\", \"b\", \"c\", \"ab\", \"bc\", \"abc\"]**\n"
  },
  {
    "path": "DAY26/Solutions.js",
    "content": "//*  Longest Word in a Sentence\n\nfunction LongestWord(sentence) {\n  let sentenceArr = sentence.split(\" \");\n\n  let MaxCount = 0;\n  let LongWord = \"\";\n\n  for (let i = 0; i < sentenceArr.length; i++) {\n    if (sentenceArr[i].length > MaxCount) {\n      MaxCount = sentenceArr[i].length;\n      LongWord = sentenceArr[i];\n    }\n  }\n  return LongWord;\n}\n\nconsole.log(LongestWord(\"The quick brown fox\"));\n\n// ----------------------------------------------------------------------------\n\n//*  Find the First Non-Repeating Character\n\nfunction NonRepeatingChar(str) {\n  let frequency = {};\n\n  let NRC = \"\";\n\n  for (let char of str) {\n    frequency[char] = (frequency[char] || 0) + 1;\n  }\n\n  for (let ch of str) {\n    if (frequency[ch] == 1) {\n      NRC = ch;\n      break;\n    }\n  }\n\n  return NRC;\n}\n\nconsole.log(NonRepeatingChar(\"swiss\"));\n\n// ----------------------------------------------------------------------------\n\n//*  Find All Substrings of a String\n\nfunction PrintAllSubstrings(str) {\n  let result = [];\n\n  for (let i = 0; i < str.length; i++) {\n    for (let j = i + 1; j <= str.length; j++) {\n      result.push(str.substring(i, j));\n    }\n  }\n\n  return result;\n}\n\nfunction PrintAllSubstrings2(str) {\n  let result = [];\n\n  // add all single chat at once\n  for (let i = 0; i < str.length; i++) {\n    result.push(str.charAt(i));\n  }\n\n  // Add substrings of length and above in sequence\n  for (let i = 2; i <= str.length; i++) {\n    for (let j = 0; j <= str.length - i; j++) {\n      result.push(str.substring(j, j + i));\n    }\n  }\n\n  return result;\n}\n\n// console.log(PrintAllSubstrings(\"abc\"));\nconsole.log(PrintAllSubstrings2(\"abc\"));\n"
  },
  {
    "path": "DAY27/Questions.md",
    "content": "# DAY 27\n\n1. **Check Anagrams**\n\n   Determine if two strings are anagrams of each other.\n\n   - **Input: \"listen\", \"silent\"**\n   - **Output: \"Anagrams\"**\n\n2. **Check if Two Strings are Rotations of Each Other**\n\n   Check if one string is a rotation of another.\n\n   NOTE : the order of characters matters in rotations.\n\n   - **Input: \"abcd\", \"cdab\"**\n   - **Output: \"Yes\"**\n\n3. **Remove All Non-Alphabetic Characters**\n\n   Remove all characters that are not letters.\n\n   - **Input: \"abc123!@#\"**\n   - **Output: \"abc\"**\n"
  },
  {
    "path": "DAY27/Solutions.js",
    "content": "//*  Check Anagrams\n\n/*\n    - An anagram string refers to a pair of strings that contain the exact same characters in the same frequency, but their order can be different. \n    - Essentially, one string can be rearranged to form the other.\n\n    - If the two input strings are identical to each other then, they are called \"Trivial Anagrams\"\n\n*/\n\nfunction CheckAnagrams(str1, str2) {\n  if (str1.length !== str2.length) {\n    return \"Not Anagrams\";\n  } else if (str1 === str2) {\n    return \"Trivial Anagrams\";\n  }\n\n  // Sort and compare\n  let sortedStr1 = str1.split(\"\").sort().join(\"\");\n  let sortedStr2 = str2.split(\"\").sort().join(\"\");\n\n  return sortedStr1 === sortedStr2 ? \"Anagrams\" : \"Not Anagrams\";\n}\n\nconsole.log(CheckAnagrams(\"listen\", \"silent\"));\n\n// --------------------------------------------------------------------------\n\n//* Check if Two Strings Have the Same Set of Characters\n\n/*\n  - If str2 is a rotation of str1, then appending str1 to itself will contain str2 as a substring.\n*/\n\nfunction ValidRotationStrings(str1, str2) {\n  if (str1.length !== str2.length) {\n    return \"NO\";\n  } else if (str1 === str2) {\n    return \"YES\";\n  }\n\n  let concatenated = str1 + str1;\n\n  return concatenated.includes(str2) ? \"YES\" : \"NO\";\n}\n\nconsole.log(ValidRotationStrings(\"abcdd\", \"cdab\"));\n\n// --------------------------------------------------------------------------\n\n//* Remove All Non-Alphabetic Characters\n\nfunction RemoveNonAlphabets(str) {\n  return str.replace(/[^a-zA-Z]/g, \"\");\n}\n\nconsole.log(RemoveNonAlphabets(\"abc123!@#\"));\n"
  },
  {
    "path": "DAY28/Questions.md",
    "content": "# DAY - 28\n\n1. **Find Duplicate Characters in a String**\n\n   Identify all characters that appear more than once in a string.\n\n   - **Input: \"programming\"**\n   - **Output: [\"r\", \"g\", \"m\"]**\n\n2. **Count Vowels and Consonants**\n\n   Count the number of vowels and consonants in a string.\n\n   - **Input: \"hello\"**\n   - **Output: Vowels: 2, Consonants: 3**\n\n3. **Matrix Addition**\n\n   Add two matrices of the same dimensions.\n\n   - **Input:**\n\n   ```\n   A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]]\n   ```\n\n   - **Output:**\n\n   ```\n   [[6, 8], [10, 12]]\n   ```\n"
  },
  {
    "path": "DAY28/Solutions.js",
    "content": "//* Find Duplicate Characters in a String\n\nfunction FindDuplicatesChars(str) {\n  let result = [];\n\n  for (let i = 0; i < str.length; i++) {\n    let char = str.charAt(i);\n    let count = 0;\n\n    for (let j = 0; j < str.length; j++) {\n      if (char === str.charAt(j)) {\n        count++;\n      }\n    }\n    if (count > 1 && !result.includes(char)) {\n      result.push(char);\n    }\n  }\n\n  console.log(result);\n}\n\nFindDuplicatesChars(\"programming\");\n\n// -----------------------------------------------------------------------\n\n//* Count Vowels and Consonants\n\nfunction CountVowelsAndConsonants(str) {\n  let StrLen = str.length;\n  let Vowels = 0;\n\n  for (let i = 0; i < StrLen; i++) {\n    let char = str.charAt(i).toLowerCase();\n\n    if (\n      char === \"a\" ||\n      char === \"e\" ||\n      char === \"i\" ||\n      char === \"o\" ||\n      char === \"u\"\n    ) {\n      Vowels++;\n    }\n  }\n\n  console.log(`Vowels:${Vowels} and Consonants: ${StrLen - Vowels}`);\n}\n\nCountVowelsAndConsonants(\"hello\");\n\n// ----------------------------------------------------------------------\n\n//* Matrix Addition\n\n/*\n  - To perform Addition, both matrices should have same no.of elements in row and column respectively.\n\n  - Matrix.length => No.of rows in the matrix\n  - Matrix[0].length => No.of columns in the first row\n*/\n\nfunction MatrixAddition(matrixA, matrixB) {\n  if (\n    matrixA.length !== matrixB.length ||\n    matrixA[0].length !== matrixB[0].length\n  ) {\n    return \"Two Matrices size must be same to perform Addition.\";\n  }\n\n  let result = [];\n\n  for (let i = 0; i < matrixA.length; i++) {\n    let row = [];\n\n    for (let j = 0; j < matrixA[i].length; j++) {\n      row.push(matrixA[i][j] + matrixB[i][j]);\n    }\n\n    result.push(row);\n  }\n\n  return result;\n}\n\n// Sample Matrices\n\nlet matA = [\n  [1, 2],\n  [3, 4],\n];\n\nlet matB = [\n  [5, 6],\n  [7, 8],\n];\n\nconsole.log(MatrixAddition(matA, matB));\n"
  },
  {
    "path": "DAY29/Questions.md",
    "content": "# DAY - 29\n\n1. **Matrix Multiplication**\n\n   Multiply two matrices if the number of columns in the first matrix equals the number of rows in the second.\n\n   - **Input:**\n\n   ```\n   A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]]\n   ```\n\n   - **Output:**\n\n   ```\n   [[19, 22], [43, 50]]\n   ```\n\n2. **Search an Element in a Matrix**\n\n   Search for a given element in a matrix and return its position.\n\n   - **Input:**\n\n   ```\n   A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], Target = 5\n   ```\n\n   - **Output:**\n\n   ```\n   Position: (1, 1) (0-based index)\n   ```\n\n3. **Matrix Transpose**\n\n   Find the transpose of a matrix (convert rows to columns and vice versa).\n\n   - **Input:**\n\n   ```\n   A = [[1, 2, 3], [4, 5, 6]]\n   ```\n\n   - **Output:**\n\n   ```\n   [[1, 4], [2, 5], [3, 6]]\n   ```\n"
  },
  {
    "path": "DAY29/Solutions.js",
    "content": "//* Matrix Multipication\n\n/*\n    # Matrix Multiplication Rules:\n    - The no.of rows in the matrixA should be equal to the no.of columns matrixB.\n    - The no.of columns in the matrixA should be equal to the no.of rows in the matrixB.\n*/\n\nfunction MatrixMultiplication(matrixA, matrixB) {\n  if (matrixA[0].length !== matrixB.length) {\n    return \"Invalid Inputs, for this Question\";\n  }\n\n  let rowSize = matrixA.length;\n  let columnSize = matrixB[0].length;\n  let commonSize = matrixB.length;\n\n  let result = [];\n\n  for (let i = 0; i < rowSize; i++) {\n    let row = [];\n\n    for (let j = 0; j < columnSize; j++) {\n      let sum = 0;\n\n      for (let k = 0; k < commonSize; k++) {\n        sum += matrixA[i][k] * matrixB[k][j];\n      }\n      row.push(sum);\n    }\n    result.push(row);\n  }\n\n  return result;\n}\n\nlet MatA = [\n  [1, 2],\n  [3, 4],\n];\n\nlet MatB = [\n  [5, 6],\n  [7, 8],\n];\n\nconsole.log(MatrixMultiplication(MatA, MatB));\n\n//----------------------------------------------------------------\n\n//* Search an Element in a Matrix\n\nfunction SearchElementInMatrix(Matrix, target) {\n  for (let i = 0; i < Matrix.length; i++) {\n    for (let j = 0; j < Matrix[i].length; j++) {\n      if (Matrix[i][j] === target) {\n        return `Element is found at ${i} row, ${j} column`;\n      }\n    }\n  }\n  return \"Element Not Found!\";\n}\n\nlet MatrixA = [\n  [1, 2, 3],\n  [4, 5, 6],\n  [7, 8, 9],\n];\n\nconsole.log(SearchElementInMatrix(MatrixA, 7));\n\n// --------------------------------------------------------------\n\n//* Matrix Transpose\n\n/*\n    - If a matrix A has dimensions 𝑚×𝑛 (with 𝑚 rows and 𝑛 columns), its transpose 𝐴^𝑇 will have dimensions 𝑛×𝑚 (with 𝑛 rows and 𝑚 columns). \n    - In the transpose matrix, the element at position 𝐴[𝑖][𝑗] in the original matrix becomes 𝐴^𝑇[𝑗][𝑖]\n*/\n\nfunction MatrixTranspose(matrix) {\n  let rowSize = matrix.length;\n  let columnSize = matrix[0].length;\n\n  let TransposeMatrix = [];\n\n  for (let i = 0; i < columnSize; i++) {\n    let row = [];\n    for (let j = 0; j < rowSize; j++) {\n      row.push(matrix[j][i]);\n    }\n\n    TransposeMatrix.push(row);\n  }\n  return TransposeMatrix;\n}\n\nlet Matrix = [\n  [1, 2, 3],\n  [4, 5, 6],\n];\n\nconsole.log(MatrixTranspose(Matrix));\n"
  },
  {
    "path": "DAY30/Questions.md",
    "content": "# DAY - 30\n\n1. **Object Keys and Values**\n\n   Print all the keys and values of an object.\n\n- **Input:**\n\n  ```\n  let\n  ```\n\n- **Output:**\n\n  ```\n  Keys: [\"name\", \"age\", \"city\"], Values: [\"John\", 25, \"New York\"]\n  ```\n\n2. **Merge Two Objects**\n\n   Combine the properties of two objects into one.\n\n- **Input:**\n\n  ```\n  let obj1 = { name: \"John\", age: 25 };\n  let obj2 = { city: \"New York\", country: \"USA\" };\n  ```\n\n- **Output:**\n\n  ```\n  { name: \"John\", age: 25, city: \"New York\", country: \"USA\" }\n  ```\n\n3. **Swap Keys and Values**\n\n   Create a new object where the keys and values are swapped.\n\n- **Input:**\n  ```\n  let obj = { name: \"John\", age: 25, city: \"New York\" };\n  ```\n- Output:\n  ```\n  { John: \"name\", 25: \"age\", \"New York\": \"city\" }\n  ```\n"
  },
  {
    "path": "DAY30/Solutions.js",
    "content": "//* Object Keys and Values\n\nlet obj = { name: \"John\", age: 25, city: \"New York\" };\nlet obj1 = { name: \"John\", age: 25 };\nlet obj2 = { city: \"New York\", country: \"USA\" };\n\n// ------------------------------------------------------------------------------------------\n\nfunction PrintKeysValues(Obj) {\n  console.log(\"Keys : \", Object.keys(Obj));\n  console.log(\"Values: \", Object.values(Obj));\n}\n\nPrintKeysValues(obj);\n\n// -------------------------------------------------------------\n\n//* Merge two Objects\n\nfunction MergeObjects(Obj1, Obj2) {\n  return Object.assign({}, Obj1, Obj2);\n}\n\nconsole.log(MergeObjects(obj1, obj2));\n\n// -------------------------------------------------------------\n\n//* Swap Keys and Values\n\nfunction SwapKeysValues(Obj) {\n  let result = {};\n\n  for (key in Obj) {\n    result[Obj[key]] = key;\n  }\n\n  return result;\n}\n\nconsole.log(SwapKeysValues(obj));\n"
  },
  {
    "path": "DAY31/Questions.md",
    "content": "# DAY - 31\n\n1. **Compare Two Objects**\n\n   Check if two objects have the same keys and values.\n\n- **Input:**\n\n  ```\n  let obj1 = { a: 1, b: 2, c: 3 };\n  let obj2 = { a: 1, b: 2, c: 3 };\n  ```\n\n- **Output:** true\n\n2. **Convert an Array of Objects to a Single Object**\n\n   Create an object where each element of the array becomes a property.\n\n- **Input:**\n\n  ```\n  let arr = [\n  { id: \"a\", value: 1 },\n  { id: \"b\", value: 2 },\n  { id: \"c\", value: 3 },\n  ];\n  ```\n\n- **Output:**\n\n  ```\n  { a: 1, b: 2, c: 3 }\n  ```\n\n3. **Group Objects by a Property**\n\n   Group an array of objects by a specified property.\n\n- **Input:**\n\n  ```\n  let arr = [\n  { category: \"fruit\", name: \"apple\" },\n  { category: \"fruit\", name: \"banana\" },\n  { category: \"vegetable\", name: \"carrot\" },\n  ];\n  ```\n\n- **Output:**\n\n  ```\n  {\n  fruit: [{ category: \"fruit\", name: \"apple\" }, { category: \"fruit\", name: \"banana\" }],\n  vegetable: [{ category: \"vegetable\", name: \"carrot\" }]\n  }\n  ```\n"
  },
  {
    "path": "DAY31/Solutions.js",
    "content": "let obj1 = { a: 1, b: 2, c: 3 };\nlet obj2 = { a: 1, b: 2, c: 3 };\n\nlet arr1 = [\n  { id: \"a\", value: 1 },\n  { id: \"b\", value: 2 },\n  { id: \"c\", value: 3 },\n];\n\nlet arr2 = [\n  { category: \"fruit\", name: \"apple\" },\n  { category: \"fruit\", name: \"banana\" },\n  { category: \"vegetable\", name: \"carrot\" },\n];\n\n// -----------------------------------------------------------------\n\n//*  Compare Two Objects\nfunction CompareTwoObjects(Obj1, Obj2) {\n  if (Object.keys(Obj1).length !== Object.keys(Obj2)) {\n    return false;\n  }\n\n  for (let key in Obj1) {\n    if (Obj1[key] !== Obj2[key]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nconsole.log(CompareTwoObjects(obj1, obj2));\n\n// --------------------------------------------------------------------\n\n//*  Convert an Array of Objects to a Single Object\n\nfunction ConvertToObject(arr) {\n  let result = {};\n\n  for (let i = 0; i < arr.length; i++) {\n    result[arr[i].id] = arr[i].value;\n  }\n\n  return result;\n}\n\nfunction ConvertToObject2(arr) {\n  let result = arr.map((item) => [item.id, item.value]);\n\n  // console.log(result);\n\n  result = Object.fromEntries(result);\n\n  return result;\n}\n\nconsole.log(ConvertToObject(arr1));\n// console.log(ConvertToObject2(arr1));\n\n// --------------------------------------------------------------------\n\n//* Group Objects by Property\n\nfunction GroupObjects(arr) {\n  let Grouped = {};\n\n  for (let i = 0; i < arr.length; i++) {\n    let key = arr[i].category;\n\n    if (!Grouped[key]) {\n      Grouped[key] = [];\n    }\n    Grouped[key].push(arr[i]);\n  }\n\n  return Grouped;\n}\n\nfunction GroupObjects2(arr) {\n  return arr.reduce((Grouped, item) => {\n    let key = item.category;\n\n    if (!Grouped[key]) {\n      Grouped[key] = [];\n    }\n\n    Grouped[key].push(item);\n    return Grouped;\n  }, {});\n}\n\nconsole.log(GroupObjects(arr2));\n// console.log(GroupObjects2(arr2));\n"
  },
  {
    "path": "DAY32/Questions.md",
    "content": "# DAY - 32\n\n1.  **Clone an Object**\n\n    Create a shallow copy of an object.\n\n    - **Input:**\n\n    ```\n    let obj = { name: \"John\", age: 25, city: \"New York\" };\n    ```\n\n    - **Output:**\n\n    ```\n    { name: \"John\", age: 25, city: \"New York\" }\n    ```\n\n2.  **Flatten a Nested Object**\n\n    Convert a deeply nested object into a single-level object.\n\n    - **Input:**\n\n    ```\n    let obj = { a: 1, b: { c: 2, d: { e: 3 } } };\n    ```\n\n    - **Output:**\n\n    ```\n    { a: 1, \"b.c\": 2, \"b.d.e\": 3 }\n    ```\n\n3.  **Sum of N Natural Numbers using Recursion**\n\n    Write a Program to Find the Sum of N Natural Numbers using Recursion\n\n    - **Input:**\n\n    ```\n    Enter a number: 5\n    ```\n\n    - **Output:**\n\n    ```\n    The sum of the first 5 natural numbers is: 15\n    ```\n"
  },
  {
    "path": "DAY32/Solutions.js",
    "content": "let obj1 = { name: \"John\", age: 25, city: \"New York\" };\n\nlet obj2 = { a: 1, b: { c: 2, d: { e: 3 } } };\n\n// -----------------------------------------------------------------\n//*  Clone an Object\n\nfunction CloneObject(Obj) {\n  // using spread operator\n  let ObjCopy1 = { ...Obj };\n\n  // using Object.assign(target, obj)\n  let ObjCopy2 = Object.assign({}, Obj);\n\n  return ObjCopy2;\n}\n\nconsole.log(CloneObject(obj1));\n\n// -----------------------------------------------------------------\n\n//*  Flatten a Nested Object\n\nfunction FlattenNestedObject(Obj) {\n  let result = {};\n\n  let keysToProcess = Object.entries(Obj);\n\n  while (keysToProcess.length > 0) {\n    // get the first key value pair\n    let [currentkey, value] = keysToProcess.shift();\n\n    if (typeof value === \"object\" && value !== null) {\n      // If the value is an object, iterate over its keys\n      for (let subkey in value) {\n        let newkey = `${currentkey}.${subkey}`; // flatten the key\n        keysToProcess.push([newkey, value[subkey]]);\n      }\n    } else {\n      // If it's not an object, add it to the result\n      result[currentkey] = value;\n    }\n  }\n\n  return result;\n}\n\nconsole.log(FlattenNestedObject(obj2));\n\n// ----------------------------------------------------------------\n\n//*  Sum of N Natural Numbers using Recursion\n\nfunction SumOfNRecursion(N) {\n  // Base condition\n  if (N === 1) {\n    return 1;\n  }\n\n  // recurrence relation\n  return N + SumOfNRecursion(N - 1);\n}\n\nconsole.log(SumOfNRecursion(5));\n"
  },
  {
    "path": "DAY33/Questions.md",
    "content": "# DAY - 33\n\n1. **Factorial of a Number Using Recursion**\n\n   The factorial of a number is the product of all positive integers less than or equal to the number.\n\n   - **Input: n = 5**\n   - **Output: 120 (since 5!=5×4×3×2×1)**\n\n2. **Calculates the Power of a Number Using Recursion**\n\n   Write a Program that Calculates the Power of a Number Using Recursion\n\n   - **Input: base = 2, exponent = 3**\n   - **Output: 8 (since 2^3 => 2 x 2 x 2 = 8)**\n\n3. **Fibonacci Series Using Recursion**\n\n   The Fibonacci series is a sequence where each number is the sum of the two preceding ones. The sequence starts with 0 and 1. This program calculates the nth Fibonacci number recursively.\n\n   - **Input: n = 5**\n   - **Output: 0, 1, 1, 2, 3**\n"
  },
  {
    "path": "DAY33/Solutions.js",
    "content": "//*  Factorial of a Number Using Recursion\n\nfunction FactorialRecursion(N) {\n  if (N === 1) {\n    return 1;\n  }\n\n  return N * FactorialRecursion(N - 1);\n}\n\nconsole.log(FactorialRecursion(5));\n\n// --------------------------------------------------------------------\n\n//*  Calculates the Power of a Number Using Recursion\n\nfunction PowerOfNum(base, exponent) {\n  if (exponent === 0) {\n    return 1;\n  }\n\n  return base * PowerOfNum(base, exponent - 1);\n}\n\nconsole.log(PowerOfNum(2, 3));\n\n// ---------------------------------------------------------------------\n\n//*  Fibonacci Series Using Recursion\n\nfunction FibonacciSeriesRecursion(n, series = []) {\n  // Base case: Series starts with 0\n  if (n == 0) {\n    return [0];\n  }\n\n  // Base case: Series for n = 1 is [0, 1]\n  if (n == 1) {\n    return [0, 1];\n  }\n\n  let prevSeries = FibonacciSeriesRecursion(n - 1, series);\n  let nextNum =\n    prevSeries[prevSeries.length - 1] + prevSeries[prevSeries.length - 2];\n  prevSeries.push(nextNum);\n\n  return prevSeries;\n}\n\nconsole.log(FibonacciSeriesRecursion(5));\n"
  },
  {
    "path": "DAY34/Questions.md",
    "content": "# DAY - 34\n\n1. **Check if a String is a Palindrome**\n\n   Check whether a given string is a palindrome using recursion.\n\n   - **Input: str = \"radar\"**\n   - **Output: true**\n\n2. **Find GCD of Two Numbers**\n\n   Calculate the greatest common divisor (GCD) of two numbers using recursion.\n\n   - **Input: a = 56, b = 98**\n   - **Output: 14**\n\n3. **Binary Representation of a Number**\n\n   Find the binary representation of a given number using recursion.\n\n   - **Input: num = 10**\n   - **Output: \"1010\"**\n"
  },
  {
    "path": "DAY34/Solutions.js",
    "content": "//*  Check if a String is a Palindrome\n\nfunction checkPlaindromeRecursion(str, start = 0, end = str.length - 1) {\n  // base case : Single character or empty string\n  if (start >= end) {\n    return \"true\";\n  }\n\n  if (str.charAt(start) !== str.charAt(end)) {\n    return false;\n  }\n\n  return checkPlaindromeRecursion(str, start + 1, end - 1);\n}\n\nconsole.log(checkPlaindromeRecursion(\"radar\"));\n\n// ----------------------------------------------------------------------\n\n//*  Find GCD of Two Numbers\n\nfunction FindGCDRecursion(num1, num2) {\n  if (num2 == 0) {\n    return num1;\n  }\n\n  return FindGCDRecursion(num2, num1 % num2);\n}\n\nconsole.log(FindGCDRecursion(56, 98));\n\n// ---------------------------------------------------------------------\n\n//*  Binary Representation of a Number\n\nfunction BinaryRepresentationRecursion(n) {\n  // base condition\n  if (n === 0) {\n    return \"\";\n  }\n\n  let quotient = Math.floor(n / 2);\n\n  let result = n % 2;\n\n  return BinaryRepresentationRecursion(quotient) + result;\n}\n\nconsole.log(BinaryRepresentationRecursion(10));\n"
  },
  {
    "path": "readme.md",
    "content": "# LogicBuilding101\n\n- Welcome to **LogicBuilding101**, a curated collection of **101+1 must-do problems** designed to build your programming logic from scratch.\n- This repository serves as a foundational resource for anyone who wants to sharpen their problem-solving skills before diving into Data Structures and Algorithms (DSA).\n\n## Overview\n\n- This repository is structured to take you on a journey from the basics of programming to slightly advanced concepts, focusing on logic-building exercises.\n- Over **34 days**, with a daily commitment of solving 3 problems, you can develop a strong programming foundation.\n\n### Problem Categories\n\n1. **Basic Math Problems**\n2. **Basic Patterns**\n3. **Intermediate Math Problems**\n4. **Medium Patterns**\n5. **Arrays**\n6. **Matrix**\n7. **Strings**\n8. **Objects**\n9. **Basic Recursion**\n\n### Why LogicBuilding101?\n\n- Develop **core programming skills**.\n- Understand basic and intermediate concepts of programming.\n- Lay a strong foundation for **DSA preparation**.\n- Practice a diverse set of problems from simple **math** to **recursion**.\n\n---\n\n## Repository Structure\n\nThe repository is divided into **daily problem sets**, with each day containing 3 problems:\n\n```\nLogicBuilding101/\n├── Day01/\n│   ├── Questions.md\n│   ├── Solutions.js\n├── Day02/\n│   ├── Questions.md\n│   ├── Solutions.js\n...\n├── Day34/\n│   ├── Questions.md\n│   ├── Solutions.js\n```\n\n### Questions File Structure\n\nEach Questions file contains:\n\n- **Problem Name**: The title of the problem.\n- **Description**: A detailed explanation of the problem.\n- **Input/Output**: Sample input and output examples.\n\n---\n\n## How to Use This Repo\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/upendhar10/LogicBuilding101.git\n   ```\n\n2. Start with Day 1 and progress at your own pace.\n\n3. Solve the problems in your preferred programming language.\n\n4. Check your logic and solutions with the provided examples.\n\n---\n\n## Acknowledgments\n\n- A huge thanks to the programming community for inspiring this project. Let's build a strong foundation together!\n\n- If you found this repo valuable, don't forget to **STAR** this repo. Thanks in advance!\n\n---\n\n## License\n\nThis project is licensed under the MIT License. Feel free to use and share!\n"
  }
]