Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Dashboard https://apply.microverse.

org/application/dashboard
https://apply.microverse.org/application/coding-challenges/
unlock
The Microverse Coding Challenges
The next step in your admission process is to test your coding skills with
our JavaScript Coding Challenges.
To get accepted into Microverse, you'll need to know basic HTML and
JavaScript. If you already have a little coding experience and are familiar
with HTML, then you can likely get by just fine. However, if you have no
coding experience, please join Microverse Level Up to learn the basics
with other applicants from across the world before moving forward.
BEFORE YOU START
1. You can submit the challenges as many times as you want with
absolutely no penalty.
2. If you have some experience with coding challenges, then you are
ready to try our challenges now. Feel free to use this JavaScript
Cheatsheet to help you with syntax.
3. If you are new to solving coding challenges, you might want to try
some practice challenges inside Microverse Level Up.
4. Set aside 4 hours of total focus to work on the Admissions
Challenges. If you have the time, you can move to the next page
now. Otherwise, we recommend scheduling time on your calendar
to come back later.
5. Please answer this quiz to self-assess your knowledge of web
technologies, GitHub, Git and pair programming basics. For the
questions that you miss, we will help you identify the content to
review. Don’t worry about your result because it will NOT be
considered in your application process.
I’m available for the next 4 hours and will submit my results once I’m
done.

Click to start the coding challenge.

Complete the Coding Challenges


Alright, let’s get started with the Coding Challenges! You’ll have 4 hours
to read through the instructions, complete the challenges, and submit
them to us.
INSTRUCTIONS FOR THE CHALLENGES

1. You’ll solve the 4 Coding Challenges in HackerRank using


JavaScript.
2. You may use any online documentation or reference (e.g., MDN,
Stack Overflow) as long as you are not looking directly for the
solution to the challenge. You may also use this JS Cheatsheet to
help you with syntax.
3. The first challenge, “Solve Me First”, serves to explain how
HackerRank works. Take a moment to watch this 7-minute video
explaining how HackerRank works.
4. Each challenge has pre-populated code to help you get started. You
don't need to touch or understand it to solve the challenges, but if
you're curious, here's an explanation of STDIN and STDOUT.
5. You may have to switch the language to JavaScript in HackerRank
manually. Watch this short video to learn how to do it.
‍Note: HackerRank lists this option as "JavaScript (Node.js)", but
you don't need to know Node.js to solve them; basic, vanilla
JavaScript will be all that you will need.
6. Use the “Run Code” button to see if your code passes the basic or
custom tests. Use the “Submit Code” button to see if your code
passes all test cases, including edge cases.
7. Once you're done with the four challenges (or the 4 hours are up),
come back to this page to submit your results.

Note: If you fail some of the tests, you can always go back to modify your

solution by clicking on “Open in editor” and submitting it again. We don’t

care how many times you submit your code in HackerRank, so feel free to

keep trying until you get it right. Even if you weren’t able to pass all the

test cases, you should still submit them so that we can recommend ways

to improve before you try again.


SIGN UP & COMPLETE THE CHALLENGES

Sign up, enter our contest, and complete the JavaScript challenges on
HackerRank using the button below. When you’re done, come back to
submit the challenges and continue with your application.

Sign up on HackerRank

I have completed all the challenges that I could on HackerRank.

HackerRank Microverse Application Challenges


https://www.hackerrank.com/contests/microverse-fast-track/challenges

Challenge 1 → Solve Me First


https://www.hackerrank.com/contests/microverse-fast-track/challenges/
solve-me-first/submissions/code/1350567880
process.stdin.on('data', function (data) {
input_stdin += data;
});

process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});

function readLine() {
return input_stdin_array[input_currentline++];
}

function solveMeFirst(a, b) {
// Hint: Type return a+b below
return a + b;
}

function main() {
var a = parseInt(readLine());
var b = parseInt(readLine());;
var res = solveMeFirst(a, b);
console.log(res);
}
After submit: https://www.hackerrank.com/contests/microverse-fast-
track/challenges/solve-me-first/submissions/code/1350612095

Challenge 2 → Grading Students


https://www.hackerrank.com/contests/microverse-fast-track/challenges/
grading/submissions/code/1350567539
Reference of this video : https://www.youtube.com/watch?
v=fEEkWN3EnYw
'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';


let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});

process.stdin.on('end', function() {
inputString = inputString.split('\n');

main();
});

function readLine() {
return inputString[currentLine++];
}

/*
* Complete the 'gradingStudents' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY grades as parameter.
*/

function gradingStudents(grades) {
// Write your code here
for(let i = 0; i < grades.length; i++){
if((grades[i] >= 38) && ((((grades[i] % 5) == 3) || ((grades[i] %
5) == 4)))){
grades[i] = grades[i] + (5 - (grades[i] % 5));
}
}
return grades;
}

function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

const gradesCount = parseInt(readLine().trim(), 10);

let grades = [];


for (let i = 0; i < gradesCount; i++) {
const gradesItem = parseInt(readLine().trim(), 10);
grades.push(gradesItem);
}
const result = gradingStudents(grades);
ws.write(result.join('\n') + '\n');
ws.end();
}

Challenge 3 Sales By Match


https://www.hackerrank.com/contests/microverse-fast-track/challenges/
sock-merchant
'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';


let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});

process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});

function readLine() {
return inputString[currentLine++];
}

/*
* Complete the 'sockMerchant' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER n
* 2. INTEGER_ARRAY ar
*/

function sockMerchant(n, ar) {


// Write your code here
let hash = {};
ar.forEach((element)=>{
hash[element] =0;
})
ar.forEach((element)=>{
hash[element] +=1;
})
let x = (Object.values(hash));
let y = x.map((element) =>{
return Math.floor(element/2)
})
let z = y.reduce((previous, current)=>{
return previous+current;
},0)
return z;
}

function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
const n = parseInt(readLine().trim(), 10);

const ar = readLine().replace(/\s+$/g, '').split(' ').map(arTemp =>


parseInt(arTemp, 10));

const result = sockMerchant(n, ar);

ws.write(result + '\n');

ws.end();
}
https://www.hackerrank.com/contests/microverse-fast-track/challenges/
sock-merchant/submissions/code/1350607945

https://www.hackerrank.com/contests/microverse-fast-track/challenges
Referred this code: https://dev.to/hokagedemehin/counting-valleys-
hackerrank-solution-javascript-2cd8
'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});

process.stdin.on('end', function() {
inputString = inputString.split('\n');

main();
});

function readLine() {
return inputString[currentLine++];
}

/*
* Complete the 'countingValleys' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER steps
* 2. STRING path
*/
function countingValleys(steps, path) {
// Write your code here
let strArr = path.split('')
let count = 0
let result = 0
for(let i=0; i<steps; i++){
if(count == 0 && strArr[i].toLowerCase() == 'd'){
count -= 1
result += 1
} else if(strArr[i].toLowerCase() == 'd'){
count -= 1
} else {
count += 1
}
}
return result
}
function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

const steps = parseInt(readLine().trim(), 10);

const path = readLine();

const result = countingValleys(steps, path);

ws.write(result + '\n');

ws.end();
}
After submit https://www.hackerrank.com/contests/microverse-fast-
track/challenges/counting-valleys/submissions/code/1350611989

After all the challenges over, Went back to the submission


https://apply.microverse.org/application/coding-challenges/submit-the-
coding-challenges → submit the user name of Hackerrank, challenges done, how many
test case passed, Whether you go through the levelups how many levels we went… Such
types of questions asked then we need to submit.
https://apply.microverse.org/application/coding-challenges/results-
passed
This shows completed Coding challenges..

marcooquendoc@gmail.com Marco from Ecuador.

You might also like