I ran into the FizzBuzz challenge at HackerRank (https://www.hackerrank.com/challenges/fizzbuzz?h_r=internal-search).
If you are interested take a look at the specified URL.
It was interesting the following statement: Write a solution (or reduce an existing one) so it has as few characters as possible.
It seems to me that the practice of writing cryptic code should not be encouraged. That code needs to be maintained and in most cases modified. That said, given specific requirements, if needed very compact but efficient and well documented code is required in some cases. Continue reading “FizzBuzz”
I chose the following challenge from LeetCode: https://leetcode.com/problems/construct-the-rectangle/ and gave it a try.
f interested please follow the link to get the requirements.
The following is a screen capture of the console using the sample data:
area: 4 = [L: 2 W: 2]
Please note that the challenge only requires the method constructRectangle(). The test cases were generated by me.
Additional output from the console for additional tests follows: Continue reading “Construct the Rectangle”
Received via email a message regarding the following HackerRank challenge: https://www.hackerrank.com/challenges/symmetric-difference?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
I liked that a refresher / tutorial preceded the actual challenge.
If interested use the above mentioned link and read the requirements.
Following is a screen capture from the Python console from the Spider 3 IDE: Continue reading “Symmetric Difference”
What a humbling experience. Picked up at random a challenge at LeetCode (https://leetcode.com/problems/bitwise-and-of-numbers-range/)
The requirements are quite brief and one can easily determine what is required:
“Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4”.
I got a piece of paper and jotted down the following: Continue reading “Bitwise AND of Numbers Range”
Received an email from HackerRank to solve a Tuples challenge: https://www.hackerrank.com/challenges/python-tuples?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
If interested take a look at the requirements.
After reading the requirements, using the Spyder 3.1.0 IDE I came up with a solution which did not have a need for the first line from the Sample Input. The Sample input follows: Continue reading “Tuples”
This challenge comes courtesy of LeetCode: https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
The challenge is rated medium difficulty. At this time there have been 96,122 accepted solutions from 334,885 submissions. If you decide to tackle the challenge make sure you read it a few times.
On my first pass (which I did not submit) I missed the word ‘distinct’ from the requirements ;o(
On purpose, my solution completely ignores the fact that the list is ‘sorted’. If this would have been work or a contest I would have taken such requirement into consideration :o)
Continue reading “Remove Duplicates from Sorted List II”
It seems to me that LeetCode (https://leetcode.com/) has more complex challenges than HackerRank (https://www.hackerrank.com/domains?h_r=logo). Their approach to testing the solutions is different. They not only test for correctness but they also check for execution time.
In the next few weeks will concentrate in solving challenges from LeetCode. I will also try to get to weekend competitions if they are relatively early in the day (I am a morning person).
If interested take a look at the requirements for this challenge using the following link: https://leetcode.com/problems/word-pattern/ Continue reading “Word Pattern”
Received a message from HackerRank to solve the following challenge: https://www.hackerrank.com/challenges/python-lists?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign ranked easy.
After listing some basic operations on lists the requirements for the challenge are listed. Continue reading “Lists”
Seems like in the past couple weeks I have been getting up earlier than usual. I decided to complete the remaining introduction Python challenges at HackerRank. If you are interested please take a look at the following URL: https://www.hackerrank.com/domains/python/py-introduction
For these challenges I decided to use Spyder 3 IDE. I am using: Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] Continue reading “Last Python Intro Challenges”
I received an email message with a HackerRank challenge. If interested the simple challenge is located at the following URL: https://www.hackerrank.com/challenges/python-integers-come-in-all-sizes?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
The challenge is quite simple when using Python. Since Python 3 the distinction between integers, long integers and unlimited size integers is gone. In Python 3 an integer could probably take all the virtual memory in your machine ;o). Continue reading “Integers Come in All Sizes”