-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-6.html
130 lines (105 loc) · 3.04 KB
/
index-6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="Problem Solving">
<title>Coding Assisement</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<h2>6. Problem Solving</h2>
<!-- ====== write code -->
<div class="Que">
<p>Que.1 Find the Smaller Angle</p>
<pre>
var Minimal_Angle = (h, m) =>
{
// Calculate angle made by hour hand with respect to 12 o'clock
let hourAngle = (h % 12) * 30 + m / 2;
// Calculate angle made by minute hand with respect to 12 o'clock
let minuteAngle = m * 6;
// Calculate absolute difference between two angles
let angleDiff = Math.abs(hourAngle - minuteAngle);
// Take smaller angle between two possible angles
let angle = Math.min(angleDiff, 360 - angleDiff);
// Return minimal angle
return angle;
};
</pre>
<p>Que.2 Check whether the year is Leap year or not.</p>
<pre>
var Check_Leap = (year) =>
{
// Check if the year is divisible by 4
if (year % 4 === 0) {
// If the year is divisible by 100 and not divisible by 400, it is not a leap year
if (year % 100 === 0 && year % 400 !== 0) {
return "Non Leap Year";
} else {
// Otherwise, it is a leap year
return "Leap Year";
}
} else {
// If the year is not divisible by 4, it is not a leap year
return "Non Leap Year";
}
};
</pre>
<p>Que.3 Perfect Number Check.</p>
<pre>
var Perfect_Check = (N) =>
{
// Find the divisors of the number and add them
let sum = 0;
let M = 1;
// loop through all divisors of the number
while(N>=M) {
if (N % M === 0) {
sum += M;
}
M++;
}
// Check if the sum of divisors is equal to the input number
if (sum === N) {
return "YES";
} else {
return "NO";
}
};
</pre>
<p>Que.4 Reverse a Number.</p>
<pre>
var Reverse_Number = (N) =>
{
// Initialize a variable to store the reversed number
let reversedNumber = 0;
// Loop through the digits of the number and reverse them
while (N > 0) {
let remainder = N % 10;
reversedNumber = reversedNumber * 10 + remainder;
N = Math.floor(N / 10);
}
// Return the reversed number
return reversedNumber;
};
</pre>
<p>Que.5 Substring Check.</p>
<pre>
var Substring_Check = (S1, S2) =>
{
if (S1.includes(S2)) {
return "YES";
} else {
return "NO";
}
};
</pre>
</div>
<div class="container">
<div class="row"><a href="./index-5.html">Back</a></div>
<div class="row"><a href="./index-7.html">Next</a></div>
</div>
</body>
</html>