PROBLEM 81
Medium

Smart Alarm

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#81

Given weekday `day` and vacation flag 0/1. Alarm is 7:00 on weekdays, 9:00 on weekends, and 10:00 on vacation.

EXAMPLE

Example

Input
6 0
Output
9:00

LIMITS

Constraints

1 ≤ day ≤ 7; vacation ∈ {0,1}
📖
LEARN Theory for this problem
+

### Smart Alarm

JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.

💡
NEED HELP? Hints
+

['Write the formula using named intermediate values if it contains more than one operation.', 'Separate input parsing, result computation, and output into distinct steps so errors are easier to spot.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [d, v] = input.trim().split(/\s+/).filter(Boolean).map(Number);
if ((v) === (1)) {
    console.log("10:00");
} else {
    if (d >= 6) {
        console.log("9:00");
    } else {
        console.log("7:00");
    }
}