Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f711acc

Browse files
authored
Merge pull request #2 from TechnoBlogger14o3/'hackerrank-solutions'
'complete-set-of-10-days-of-hackerrank-solutions'
2 parents 2cc4f0a + 95598e9 commit f711acc

33 files changed

+1285
-0
lines changed

‎HackerRank-10-Days-Of-JavaScript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8c35da52b412e69fb64e14d1e0a8679969847434
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
/**
32+
* A line of code that prints "Hello, World!" on a new line is provided in the editor.
33+
* Write a second line of code that prints the contents of 'parameterVariable' on a new line.
34+
*
35+
* Parameter:
36+
* parameterVariable - A string of text.
37+
**/
38+
function greeting(parameterVariable) {
39+
// This line prints 'Hello, World!' to the console:
40+
console.log('Hello, World!');
41+
42+
console.log(parameterVariable)
43+
44+
}
45+
46+
function main() {
47+
const parameterVariable = readLine();
48+
49+
greeting(parameterVariable);
50+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
32+
/**
33+
* The variables 'firstInteger', 'firstDecimal', and 'firstString' are declared for you -- do not modify them.
34+
* Print three lines:
35+
* 1. The sum of 'firstInteger' and the Number representation of 'secondInteger'.
36+
* 2. The sum of 'firstDecimal' and the Number representation of 'secondDecimal'.
37+
* 3. The concatenation of 'firstString' and 'secondString' ('firstString' must be first).
38+
*
39+
* Parameter(s):
40+
* secondInteger - The string representation of an integer.
41+
* secondDecimal - The string representation of a floating-point number.
42+
* secondString - A string consisting of one or more space-separated words.
43+
**/
44+
function performOperation(secondInteger, secondDecimal, secondString) {
45+
// Declare a variable named 'firstInteger' and initialize with integer value 4.
46+
const firstInteger = 4;
47+
48+
// Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0.
49+
const firstDecimal = 4.0;
50+
51+
const firstString = 'HackerRank ';
52+
53+
console.log(firstInteger + parseInt(secondInteger))
54+
55+
console.log(firstDecimal + parseFloat(secondDecimal))
56+
57+
console.log(firstString + secondString)
58+
}
59+
60+
61+
62+
function main() {
63+
const secondInteger = readLine();
64+
const secondDecimal = readLine();
65+
const secondString = readLine();
66+
67+
performOperation(secondInteger, secondDecimal, secondString);
68+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
/**
32+
* Calculate the area of a rectangle.
33+
*
34+
* length: The length of the rectangle.
35+
* width: The width of the rectangle.
36+
*
37+
* Return a number denoting the rectangle's area.
38+
**/
39+
function getArea(length, width) {
40+
let area;
41+
area = length * width
42+
43+
return area;
44+
}
45+
46+
function getPerimeter(length, width) {
47+
let perimeter;
48+
perimeter = (length + width) * 2
49+
50+
return perimeter;
51+
}
52+
53+
54+
function main() {
55+
const length = +(readLine());
56+
const width = +(readLine());
57+
58+
console.log(getArea(length, width));
59+
console.log(getPerimeter(length, width));
60+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
/*
32+
* Create the function factorial here
33+
*/
34+
function factorial(n) {
35+
if (n === 0) return 1;
36+
else return n * factorial(n - 1)
37+
}
38+
39+
40+
function main() {
41+
const n = +(readLine());
42+
43+
console.log(factorial(n));
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
function main() {
32+
var a = readLine();
33+
console.log(Math.PI * a * a);
34+
console.log(2 * Math.PI * a);
35+
36+
try {
37+
// Attempt to redefine the value of constant variable PI
38+
PI = 0;
39+
// Attempt to print the value of PI
40+
console.log(PI);
41+
} catch(error) {
42+
console.error("You correctly declared 'PI' as a constant.");
43+
}
44+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
function getGrade(score) {
32+
let grade;
33+
if (score > 25 && score <= 30) grade = "A"
34+
else if (score > 20 && score <= 25) grade = "B"
35+
else if (score > 15 && score <= 20) grade = "C"
36+
else if (score > 10 && score <= 15) grade = "D"
37+
else if (score > 5 && score <= 10) grade = "E"
38+
else if (score >= 0 && score <= 5) grade = "F"
39+
return grade;
40+
}
41+
42+
43+
function main() {
44+
const score = +(readLine());
45+
46+
console.log(getGrade(score));
47+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
*
3+
* By Aman Shekhar
4+
*
5+
**/
6+
7+
'use strict';
8+
9+
process.stdin.resume();
10+
process.stdin.setEncoding('utf-8');
11+
12+
let inputString = '';
13+
let currentLine = 0;
14+
15+
process.stdin.on('data', inputStdin => {
16+
inputString += inputStdin;
17+
});
18+
19+
process.stdin.on('end', _ => {
20+
inputString = inputString.trim().split('\n').map(string => {
21+
return string.trim();
22+
});
23+
24+
main();
25+
});
26+
27+
function readLine() {
28+
return inputString[currentLine++];
29+
}
30+
31+
function getLetter(s) {
32+
let letter;
33+
switch (true) {
34+
case "aeiou".includes(s[0]):
35+
letter = "A"
36+
break;
37+
case "bcdfg".includes(s[0]):
38+
letter = "B"
39+
break;
40+
case "hjklm".includes(s[0]):
41+
letter = "C"
42+
break;
43+
default:
44+
letter = "D"
45+
break;
46+
}
47+
return letter;
48+
}
49+
50+
51+
function main() {
52+
const s = readLine();
53+
54+
console.log(getLetter(s));
55+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /