Skip to content

Instantly share code, notes, and snippets.

@CoGrammarCodeReview
CoGrammarCodeReview / Minesweeper.txt
Created August 6, 2021 12:52
Minesweeper Challenge for Mock Interviews
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
@CoGrammarCodeReview
CoGrammarCodeReview / Morse Code Challenge
Created March 11, 2022 17:26
Morse Code Challenge HyperionDev Coding Night
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
@CoGrammarCodeReview
CoGrammarCodeReview / Disarium
Last active May 26, 2022 16:44
Disarium challenge
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.
@CoGrammarCodeReview
CoGrammarCodeReview / stackChallenge.txt
Last active August 2, 2022 12:37
Stack challenge
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.
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.
@CoGrammarCodeReview
CoGrammarCodeReview / PascalTriangle
Last active August 31, 2022 15:48
Pascal Triangle Challenge
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
@CoGrammarCodeReview
CoGrammarCodeReview / RGB-To-Hex.txt
Last active August 29, 2023 21:57
RGB to HEX conversion
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.