Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
McLarenCollege / cinemaHallIfElse.md
Last active December 21, 2021 11:06
Exercise Name : Cinema Hall If-Else

A cinema is showing movie to childeren (age < 18) for free and charging adults (age >= 18) with $10 per ticket.

Write if-else statements to print the following messages according to the given age.

For adults print the following messages to the console:

Please pay $10.
Please proceed to the cinema hall.

For children print the following message to the console:

@McLarenCollege
McLarenCollege / partyTime.md
Last active December 21, 2021 11:00
Party Time

Given the details of Anu's birthday write a boolean expression to check if its Party Time (Anu's birthday) by comparing it with the details for the given day.

Note: You can assume that the given year will always be greater than Anu's Birth Year.

CODE TEMPLATE


let anuBirthDay = 26;
let anuBirthMonth = "August";
let anuBirthYear = 1986;
@McLarenCollege
McLarenCollege / setupInstructionsFoundationsCourse.md
Last active July 14, 2022 12:23
Set Up Instructions for Foundations Course

Set Up Instructions

  • Complete the set up by or before the deadline mentioned in the enrollment email

  • If you have any problem in the set up you must tell us on Discord along with a clear description of the problem.

1. Set Up VSCode and Nodejs

  • Watch this video to setup Github and other things and make sure to use your first and last name in your GitHub Profile.
  • Please install the appropriate version of VSCode on your computer.
  • Install NodeJS on your computer.

for Windows

@McLarenCollege
McLarenCollege / zipIt.md
Last active October 6, 2022 11:58
Exercise : Zip It

Zip It

Write a function called zipIt that accepts two already sorted arrays and returns a new array which contains all the elements present in both the arrays in a sorted order.

  • Note: Do not use a sorting algorithm

Eg.

zipIt([1,5,9,10], [2,4,7])
@McLarenCollege
McLarenCollege / boxesInRowsWithoutMax.js
Last active May 12, 2021 10:54
Boxes in Rows without calculating max
function boxesRows(boxes) {
let result = [];
while (1) {
let count = 0;
let zeroBoxCount = 0;
for (let i = 0; i < boxes.length; i++) {
if (boxes[i] > 0) {
boxes[i]--;
count++;
} else {
@McLarenCollege
McLarenCollege / boxesRowsSolution.js
Created May 12, 2021 08:57
Practice Challenge 9 Boxes Rows Solution
function boxesRows(boxes){
let result=[];
let max=0;
// find the maximum number
for(let i=0;i<boxes.length;i++){
if(boxes[i]>max){
max=boxes[i];
}
}
// push zeros in the result array equal to the max number
@McLarenCollege
McLarenCollege / boxesInRows.md
Last active March 17, 2022 09:23
Count the number of boxes in each row

There is an array of boxes where each element of an array represents the number of boxes stacked on top of each other in that column. For eg. boxes=[4,1,2,3,2,1].

This is a row of boxes where the first column of boxes has 4 boxes stacked on top of each other. The second column has 1 box, the third column has 2 boxes stacked on top of each other and the fourth column has 3 boxes stacked on top of each other and so on. So the boxes look like this:

              B
              B     B
 B B B B
@McLarenCollege
McLarenCollege / bubbleSortAlgorithm.md
Last active September 28, 2022 05:51
Exercise : Bubble Sort Algorithm

Write a function that sorts a given array using the Bubble Sort Algorithm and returns the sorted Array. For eg.

bubbleSort([1,5,3,0])

should return [0,1,3,5]

bubbleSort([-1,0,-5,5,8])

should return [-5,-1,0,5,8]

@McLarenCollege
McLarenCollege / bubbleSortAlgorithm.md
Last active September 29, 2022 07:44
Exercise : Bubble Sort Steps

Bubble Sort Algorithm

Stepwise Implementation of the Bubble Sort Algorithm

If the input is [6,2,9,5,1,3] the steps are:

compare 6 and 2 - swap
compare 6 and 9 - no change
@McLarenCollege
McLarenCollege / anagram.md
Last active May 10, 2021 07:19
Anagram Part 2

Practice Challenge #6

Anagram Part 2

This challenge is an extension of the previous Anagram challenge which was done on Day 3.(Link to Previous Challenge).

Using the .sort() method and .indexOf() method to solve this problem is not very efficient(Why?). We shall now redo the problem using a more efficient method of creating Objects.

Problem Statement

  • Write a function that accepts two strings and checks whether the first string is an anagram of the second string. If yes, the function returns true , else it returns false. The case(upper/lower)of the character MATTERS.
  • You need to create an Object for each of the strings and then compare the two Objects for equality.
  • The keys of the Object will be the characters in the string and the value will be the frequency of the character.