This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NO GENERATIVE AI SUCH AS CHATGPT, BARD, BINGCHAT ETC. IS ALLOWED! | |
SOLUTIONS ARE MEANT TO BE YOUR OWN ATTEMPT AT THE PROBLEM AND PLAGIARISM USING CODE SNIPPETS FROM ONLINE IS NOT ALLOWED! | |
You will be required to also leave comments that clearly explain how your code works. | |
------------------------------------------------------------------------------------------------------------------------- | |
PROBLEM STATEMENT: | |
Create a function that takes the RGB values of a colour and converts it to the corresponding HEX value for that colour. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a function that returns the sum of the Nth row of a Pascal triangle. The function should take an integer N as the argument. | |
N is for the number of rows. | |
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. Below are the first few rows of the Pascal's triangle: | |
1 | |
1 1 | |
1 2 1 | |
1 3 3 1 | |
1 4 6 4 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a function that, given a string with at least three characters, returns an array of its: | |
Length. | |
First character. | |
Last character. | |
Middle character, if the string has an odd number of characters. Middle TWO characters, if the string has an even number of characters. | |
Index of the second occurrence of the second character in the format "@ index #" and "not found" if the second character | |
doesn't occur again. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A stack machine processes instructions by pushing and popping values to an internal stack. A simple example of this is a calculator. | |
The argument passed to run(instructions) will always be a string containing a series of instructions. | |
The instruction set of the calculator will be this: | |
+: Pop the last 2 values from the stack, add them, and push the result onto the stack. | |
-: Pop the last 2 values from the stack, subtract the lower one from the topmost one, and push the result. | |
*: Pop the last 2 values, multiply, and push the result. | |
/: Pop the last 2 values, divide the topmost one by the lower one, and push the result. | |
DUP: Duplicate (not double) the top value on the stack. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disarium Challenge | |
A Disarium is defined as a number whose: | |
Sum of its digits powered with their respective position is equal to the original number | |
Your Task: | |
You are totally obsessed with whether a number is a Disarium or not. You have such a compelling desire to fulfil the Disarium itch | |
that you refuse to read any non-disarium numbered pages in any given book. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For this challenge, you will be required to build a Morse code encryptor and decrypter. You can use any langauge of your choosing | |
to complete the challenge. | |
Morse code is a method used in telecommunication to encode text characters as standardized sequences of two different signal durations, | |
called dots and dashes, or dits and dahs. Morse code is named after Samuel Morse, one of the inventors of the telegraph. | |
You can find a table of Morse code characters here: | |
https://morsedecoder.com/ | |
Please note that for the purpose of this exercise, where there is a space between words, you should use "/" to separate words in your |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This challenge is based on the game Minesweeper. | |
Create a function that takes a grid of # and -, | |
where each hash (#) represents a mine and each dash | |
(-) represents a mine-free spot. Return an array where | |
each dash is replaced by a digit indicating the number | |
of mines immediately adjacent to the spot | |
(horizontally, vertically, and diagonally). | |
Examples |