This repository contains solutions to TypeScript programming problems. Each problem is implemented as a separate TypeScript file and can be executed individually using Node.js and TypeScript.
Find the difference between the largest and second largest numbers in an array.
Calculate the sum of all prime numbers in an array.
Remove duplicate values from an array and calculate the sum of the unique elements.
Find the missing number in a sequence using the formula:
n × (n + 1) / 2 - sumOfArray
Count how many times each number appears in an array.
Return only the elements that appear more than once in an array.
Print all unique characters from a string and count them.
Generate and print all possible permutations of a string.
Generate a random password containing:
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character
Remove all special characters from a string.
Remove all vowels from a string.
Check whether a given string is a valid binary number.
Extract numeric values from a paragraph and calculate the final discounted price.
Break down a given amount into the minimum number of currency notes.
Determine the number of 5-mark and 10-mark questions required to make the total marks.
Google Docs containing all TypeScript programs (in sequential order):
Link:
Install the following before running the programs:
- Node.js
- TypeScript
- ts-node
- prompt-sync (for programs that require user input)
Clone the repository:
git clone https://github.com/zafir0-0/Typescript_problem_solving.gitGo to the project directory:
cd Typescript_problem_solvingInstall dependencies:
npm installIf TypeScript is not installed globally:
npm install -g typescriptInstall ts-node:
npm install -g ts-nodeInstall prompt-sync:
npm install prompt-syncnpx ts-node filename.tsExample:
npx ts-node 02_Sum_Of_Prime_Numbers.tsCompile:
tsc filename.tsRun:
node filename.jsExample:
tsc 02_Sum_Of_Prime_Numbers.ts
node 02_Sum_Of_Prime_Numbers.js- TypeScript
- Node.js
- ts-node
- prompt-sync