C# console and libraries for problems asked in a live coding interview or a technical assessment.
Run the solution and a console will appear. Enter a command according to menu to run the corresponding problem.
An xUnit Test Project for testing libraries in AssortedProblem Solution. A good test suite can help us refactor quicker and in a less stressful manner. TDD (Test Driven Development) can help and force us to design well factored software iteratively, backed by tests to help future work as it arrives.
Console app for coderbyte technical assessment or similar.
- FizzBuzz
- Palindrome
- Palindrome Level
- Anagram
- Tree Dictionary: Existance
- Tree Dictionary: Print
- Codeland
- Find Intersection
- Questions Marks
- Coderbyte
- First Factorial
- Longest Word
- Min Window Substring
- Tree Constructor
- Bracket Matcher
- Bracket Combinations
- Plus Minus
- Mini-Max Sum
- Time Conversion
- Lonely Integer
- Diagonal Difference
- Counting Sort 1
- Zig Zag Sequence
- Tower Breakers
- Caesar Cipher
- Grid Challenge
- Recursive Digit Sum
- New Year Chaos
- Merge Two Sorted Linked Lists
- Queue
- Balanced Brackets
- Simple Text Editor
https://www.hackerrank.com/challenges/fizzbuzz/problem
Print each number from 1 to 100 on a new line.
For each multiple of 3, print "Fizz" instead of the number.
For each multiple of 5, print "Buzz" instead of the number.
For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
Implemented in FizzBuzz library and is called by the console app.
Tested by FizzBuzzUnitTest in the xUnit Test Project.
A word, verse, or sentence (such as "Able was I ere I saw Elba") or a number (such as 1881) that reads the same backward or forward (Merriam-Webster). It ignores spaces and punctuation marks. Empty string is a palindrome.
Determine whether the input is a palindrome or not. Implement both case sensitive and case insensitive. Assume there is no punctuation mark from the input.
Implemented in Palindrome library and is called by the console app.
Tested by PalindromeUnitTest in the xUnit Test Project.
Calculate the palindrome level of the input (case insensitive).
- Example "dam madam mad":
- dammadammad: a palindrome, count 1
- dammad: a palindrome, count 2
- dam: not a palindrome
- Thus, "dam madam mad" is palindrome level 2.
- Second Example "tattattattat":
- tattattattat: a palindrome, count 1
- tattat: a palindrome, count 2
- tat: a palindrome, count 3
- ta: not a palindrome
- Thus, "tattattattat" is palindrome level 3.
- Third Example "ab":
- ab: not a palindrome
- Thus, "ab" is palindrome level 0.
- Notes:
- No need to check the next ones if the current one is not a palindrome
- If the number of characters is odd but not one, the next one checked is the first half + 1
- If the number of characters is even, the next one checked is the first half
- If the number of character is one, the next one checked is empty string
Implemented in Palindrome library and is called by the console app.
Tested by PalindromeUnitTest in the xUnit Test Project.
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase. (Wikipedia)
Determine whether the two inputs are anagrams (case sensitive).
Implemented in Anagram library and is called by the console app.
Tested by AnagramUnitTest in the xUnit Test Project.
Tree dictionary stores collection of words in a form of tree.
- First Example
This tree dictionary stores words "add", "all", and "aztec" in a form of tree.
a - d - d
|
l - l
|
z - t - e - c
- Second Example
This tree dictionary stores words "add", "ally", "alter", "code", "debug", and "decode" in a form of tree.
a - d - d
| |
| l - l - y
| |
| t - e - r
|
c - o - d - e
|
d - e - b - u - g
|
c - o - d - e
Notice that by adding "ally" to dictionary tree, the word "all" is automatically included. This is also true for substrings of those 6 words starting with index 0.
Also notice that the word "ac" is not included in the tree dictionary.
Create a function to find whether a string exists in a tree dictionary. Assume there would be at least one character in tree dictionary. Assume only lowercase characters are used.
Implemented in TreeDictionary library.
Tested by TreeDictionaryUnitTest in the xUnit Test Project.
Make a function to return the string of a tree dictionary like shown in Tree Dictionary: Existance problem. It is recommended to use string builder.
Implemented in TreeDictionary library.
Tested by TreeDictionaryUnitTest in the xUnit Test Project.
https://coderbyte.com/editor/Codeland%20Username%20Validation:Csharp
Create username validation according to the following rules:
- The username is between 4 and 25 characters.
- It must start with a letter.
- It can only contain letters, numbers, and the underscore character.
- It cannot end with an underscore character.
Implemented in Codeland library.
Tested by CodelandUnitTest in the xUnit Test Project.
https://coderbyte.com/information/Find%20Intersection
Find intersection within an array of number strings. Open coderbyte page for details.
Implemented in Intersection library.
Tested by IntersectionUnitTest in the xUnit Test Project.
https://coderbyte.com/editor/Questions%20Marks:Csharp
Implemented in QuestionsMarks library.
Tested by QuestionsMarksUnitTest in the xUnit Test Project.
Use git checkout {commit hash}
to open related challenge. Code is located in CoderbyteConsoleApp/Program.cs Use git checkout master
to return.
https://coderbyte.com/information/First%20Factorial
git checkout a4e1f39ebc323681af7ea4d7853485dbe6d79c9f
https://coderbyte.com/information/Longest%20Word
git checkout b214b1602fd713377793178f0d1f834c18d7c852
https://coderbyte.com/information/Min%20Window%20Substring
git checkout 3c14c6068f63a1f3358e430a5901c0e98f2148a6
https://coderbyte.com/information/Tree%20Constructor
git checkout a459715d113e3d412a680e9b405b8583cb7edffe
https://coderbyte.com/information/Bracket%20Matcher
git checkout 0eabd0c37a557498fde47e89a95fb0858f1a7e2c
https://coderbyte.com/information/Bracket%20Combinations
git checkout f77e26f79dcb62a6ca31a8e985b8e5ba4840e24a
https://www.hackerrank.com/challenges/one-week-preparation-kit-plus-minus/problem
git checkout e382716943a5c7b8e64446b9b644e0c6913ea7d7
https://www.hackerrank.com/challenges/one-week-preparation-kit-mini-max-sum/problem
git checkout 375c53ed96ab4c1d2b3e12ae5afa861cc767a320
https://www.hackerrank.com/challenges/one-week-preparation-kit-time-conversion/problem
git checkout 4b9a7c01ac922942f8a8310ea20e660c2359fc32
https://www.hackerrank.com/challenges/one-week-preparation-kit-lonely-integer/problem
git checkout 61ae226403864cdf018bff2ca792ea4fae8fee77
https://www.hackerrank.com/challenges/one-week-preparation-kit-diagonal-difference/problem
git checkout 20ff199efff9a4d61a8447bf2e93c05db161620c
https://www.hackerrank.com/challenges/one-week-preparation-kit-countingsort1/problem
git checkout 3ebaa1536fc419bcf08423278c4a3b0d90726fc4
https://www.hackerrank.com/challenges/one-week-preparation-kit-zig-zag-sequence/problem
git checkout 5a6c531c5c01d37dd92b483a132d15c47438b3e9
https://www.hackerrank.com/challenges/one-week-preparation-kit-tower-breakers-1/problem
Assuming P1 and P2 both play optimally,
- If height of tower is 1, P2 always win because P1 unable to move.
- If number of tower is even, P2 always win because P2 can mimic P1 moves until P1 inevitably run out of moves.
- If number of tower is odd, P1 always win because P1 first move will be reducing a tower to height of 1, effectively making it an even tower game. P1 mimics P2 moves until P2 inevitably run out of moves.
git checkout 74be9fea213609ef30c3aaa2b43991ed2878adc9
https://www.hackerrank.com/challenges/one-week-preparation-kit-caesar-cipher-1/problem
git checkout 1d43050cf4eeeee6d99c0c6feb56ec65563a41c1
https://www.hackerrank.com/challenges/one-week-preparation-kit-grid-challenge/problem
git checkout ae3111cdda6661408ab7926f10cda918484009a6
https://www.hackerrank.com/challenges/one-week-preparation-kit-recursive-digit-sum/problem
git checkout 4ba9d31308b7b6228ab4e4faa2997c25bd5a5ca4
https://www.hackerrank.com/challenges/one-week-preparation-kit-new-year-chaos/problem
git checkout ef62694d28776f92895f3bd0769e8e25cd7bf5e4
https://www.hackerrank.com/challenges/one-week-preparation-kit-merge-two-sorted-linked-lists/problem
git checkout 19752d5312aa8304c6d713c45142a94c500c4d67
https://www.hackerrank.com/challenges/one-week-preparation-kit-queue-using-two-stacks/problem
git checkout b9e7a6dbb6d5bdf82e4cf13735497933b0cc2238
https://www.hackerrank.com/challenges/one-week-preparation-kit-balanced-brackets/problem
git checkout beafb9bbddfeae661ca75ca364f2e290e0e0d059
https://www.hackerrank.com/challenges/one-week-preparation-kit-simple-text-editor/problem
git checkout f05229d72fb64dcb16820b34c77615817bb8028b