Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
McLarenCollege / Anagrams-part-2.md
Last active November 28, 2022 09:38
Exercise : Anagrams Part 2

Write a function that accepts two strings and checks if the first string is an anagram of the second string. If they are anagrams it returns true, otherwise it returns false. The case(upper/lower) of the characters DOES NOT MATTER.

function checkAnagram(word1, word2){
 // write your code here
}
console.log(checkAnagram("silent", "liSten")); // true
console.log(checkAnagram("stressed", "DesertsS")); // true
@McLarenCollege
McLarenCollege / FunctionTraceFooBar.js
Last active October 12, 2021 03:41
Exercise Name : Function Trace Foo Bar
//FUNCTION TRACE 3
// Requirements: Create a trace output file showing each function call
// including parameter values, and each return value. You should be able
// to step through with pen and paper - do not run the code on your computer
// Tip: To refresh your memory of how to write trace output, see this gist:
// https://gist.github.com/McLarenCollege/e276ecc7dc3485a483be469f61dfd671
function foo(koo, y) {
if ((koo % 3) !== 0) {

Number to Google

Time allocated: 1 hour

Create a function that takes an array of numbers and returns a string.

  • 0 Repeat the previously decrypted value
    • The next number after 0 denotes number of repetitions to be done.
  • 1, 2, 3, 4 = g, o, l, e
  • 5 Convert previous letter to uppercase.

Sorted Linked List Part 2

Allowed Time: 25 mins

In this challenge you will be modifying the Sorted Linked List that you wrote in previous challenge. Add a constructor which takes a comparator function as a parameter and use it for creating the sorted list.

Example

let scores = new SortedLinkedList((a, b) => b - a); // passing comparator function here

Columnar Cipher

Allowed Time: 1hr 30 mins

The columnar cipher is a transposition cipher that works like this.

Start with a secret message:

msg = "Meet me by the lake at midnight. Bring shovel."
class LinkedList {
linkedList;
unshift() {
}
}
function unshift(linkedList, studentName) {
@McLarenCollege
McLarenCollege / Day - 161: Water Height.md
Last active June 16, 2020 03:01
One of the final 16 challenges

Water Height

Time Allowed: 45 minutes

A series of blocks are squeezed between two walls in descending order, then water is poured in. Create a function which takes the block heights and the volume of water, and returns the height of the water.

For example, findWaterHeight([200, 150, 100], 100) should return 175

@McLarenCollege
McLarenCollege / Day - 160: Merge all Given Linked Lists.md
Last active June 15, 2020 08:13
One of the 16 final challenges

Merge Linked Lists

Allowed Time: 1hr 15 mins

Create a function which will merge any number of sorted linked lists. For example:

let listA = {
value : 2,
 next: {

Stems and Leaves

In statistics a stem-and-leaf plot is a graphical representation of values distribution in a dataset, usually implemented for a small set of values. In this exercise we'll build a simple plot for positive integer values following the steps below.

  1. You must separate each value in two parts: the stem, equal to all number digits but last and the leaf, equal to the last digit. For numbers in range 0-9 you must add a "0" at the start.

Examples:

  • 4872: stem is "487", leaf is "2".
  • 429: stem is "42", leaf is "9".
  • 85: stem is "8", leaf is "5".

Return the Sum of Two Numbers

When two numbers are added together, the strange Lunar arithmetic is used on the Moon. The Lunar sum of two numbers is not determined by the sum of their individual digits, but by the highest digit of the two taken into account at each step, in columnar form.

2  4  6  +
3  1  7  =
--------
3  4  7