This repository contains solutions to all 6 questions of Assignment 4 using plain JavaScript.
All inputs are taken using prompt() and outputs are displayed using alert() as required.
- q1.html → Digit Gatekeeper
- q2.html → Roll-Seed Lock
- q3.html → Mirror Corridor
- q4.html → Fare Calculator
- q5.html → Skipping Numbers
- q6.html → Contest Score Judge
- Loop through all numbers from L to R
- Check divisibility by K
- Ensure number does not contain digit 0
- Calculate sum of digits and check if it is prime
- Perform 3 transformations:
- If even → divide by 2 and add seed
- If odd → multiply by 3 and subtract seed
- Check:
- Final number is 3-digit
- Middle digit equals seed
- Iterate from X = 0 to 100000
- Check if:
- N + X is palindrome
- N + X is divisible by K
- Return smallest valid X
- Calculate base fare
- Apply conditions:
- Late penalty
- Distance surcharge
- Seed adjustment
- Round result to nearest multiple of 5
- Add numbers from 1 onwards
- Skip numbers divisible by (seed + 2)
- Stop when sum ≥ N
- Compute score using formula:
- score = 3a + b - 2c
- Apply:
- Negative → set to 0
- Penalty if total submissions > 50
- Determine PASS or FAIL
- Loops (
for,while) - Conditional statements (
if-else) - Functions
- String manipulation
- Math operations
- JavaScript built-in methods
- Most problems run in O(n) time
- Efficient for given constraints (up to 10⁶)
- Open any
.htmlfile in a browser - Enter inputs when prompted
- Output will be shown using alert
- No hardcoding is used
- All inputs are dynamic
- Follows assignment instructions strictly
Akanksha