Working with Lists and Conditionals – React

It is a dark summer morning in the Twin Cities of Minneapolis and St. Paul. The official temperature is 75 degrees Fahrenheit and the humidity 98%. Yesterday the forecast for the day was for thunderstorms all day today. When we have severe thunderstorms I prefer to read a magazine and keep all computers powered down. So far I have not heard rumble so I decided to attempt to write this post before things get ugly and I have to switch tasks.

My wife has let me know that the thunderstorms have arrived! Will pick up when they are done. OK, I am back. The thunderstorms lasted about an hour. It seems that the rest of the day will be fine. Continue reading “Working with Lists and Conditionals – React”

Robot in a Grid

This past weekend my wife and I spent time looking for protein-rich groceries. We were attempting to get those and additional items for a few families that wish to stay in lockdown despite the governor of Minnesota starting to relax the lockdown. The current orders went into effect last Saturday April 18, 2020 at midnight. Among the main items is that people in the state can go golfing and shooting in open ranges. Both Saturday and Sunday were sunny days. We could tell for the number of cars and people walking the dogs, jogging and just strolling that many people took advantage of the new rules.

On our side we will continue to try stay home as much as we can by limiting trips to the grocery stores and continue to use Jitsi to communicate more often with family and friends. Continue reading “Robot in a Grid”

Compose Ranges

It is a rather cold spring day in the Twin Cities of Minneapolis and St. Paul. I believe there is a winter storm warning for today all day. This morning when I got up, there was a thin coating of snow on roofs and lawns. The roads seem to just be wet. One way or the other my wife and I are not planning on going out. We are under lockdown due to the Wuhan virus (also known as COVID-19) pandemic.

Besides work I have been taking a few courses, reading technical documents, reading non-technical stuff and watching the news. As of today April 12, 2020 in Dakota County, MN (I live in the city of Apple Valley which is in Dakota County) the total number of deaths attributed to the pandemic in

Dakota County is 4 which represents 0.001% of the population. The previous count of 3 held for several weeks. In the USA the total number of deaths is 20,411 which represent 0.006% of the population of about 330 million. Seems like in this area we are doing well. No matter which city or country you live in, please keep social distancing and do not leave home unless it is needed. In order to beat the pandemic we all need to follow social distancing until a vaccine is available or until the CDC (do not trust unofficial sources) informs us that it is safe for people that have antibodies for them to resume normal activities. Continue reading “Compose Ranges”

Graph Breadth First Search

I had to add a few paragraphs before finishing this post. My wife called me to go up to have lunch. During the COVID-19 pandemic, during the workweek, I help my wife with some lunch items just like I do on weekends. Today I made open face toasts with avocado; simple and delicious.

First take a couple ripe avocados, cut them in half and remove the pits. Then peel them. Leave them alone until the toasts are ready (about 3 to 4 minutes).

Today I used four slices of brioche bread that we purchased at Trader Joe’s a week ago. If you are not familiar with brioche, it is fluffy and somewhat sweet. Our bread loaf has been used and is still sitting in the refrigerator.

I pulled out our panini press (a.k.a. Breville Smart Grill & Griddle) and set it to start warming up to 400 F. Any electric grill, waffle maker or plain pan can be used as a substitute for a panini press. Continue reading “Graph Breadth First Search”

Graph Multiple Costs

Due to the Corona Virus or COVID-19 the entire world is experiencing situations that we have never seen before. The Internet, TV and other news sources are full of reports. Some of them have good and valuable information while most are just opinions which have no scientific background. We should seek information from reliable sources and when possible check our findings against multiple reliable sources and use common sense, which as we know is not the most common of the senses.

Yesterday evening I started this post and wrote about two pages regarding COVID-19. Today started reading it and decided to delete them with the exception of the first sentence. There is already too much information out there. Please stay home. If you need to go out for groceries, please keep social distance. Healthcare facilities are already taking care of more patients that they were designed for. Continue reading “Graph Multiple Costs”

A or B

Over the weekend I watched the YouTube video “Dealing with Negative Comments | AMA #3 – Ask Me Anything with Lex Fridman”. I have watched a few of his videos. I do enjoy them to the point that I have subscribed to them. There is one in which Lex interviews Donald Knuth and other where he interviews Andrew Ng. Both videos are over an hour so I will watch them over the weekend.

If you are interested in getting information about Lex Fridman you can find it here or there.

I picked the challenge “A or B” from HackerRank after receiving an email message. I guess that if you solve a few of their problems they like you to continue visiting their site and solving additional challenges. I like to work on one or two a week. I believe it is the only way to learn and / or refresh material. Continue reading “A or B”

Shuffle Array – Java

Every work day when quitting time approaches (around 05:00 PM) I check my to-do list. One thing I had for the day was to check is there is a method in a Java class to shuffle the contents of an array. This is a nice mechanism to have in your toolbox. For example, if you want to load a binary tree search (BST) and the data is sorted, the tree will basically load like a linked list. In a BST you can typically find an element in O(log(n)). But if the elements were inserted sorted, the search is performed in O(n) which is slower than O(log(n)). In such cases you can just shuffle the array and then load the BST. Continue reading “Shuffle Array – Java”

Binary Tree Sum

In this post we will develop a couple methods to collect some information from a binary tree. The first method will be the base, and the second will be an enhancement of the first.

The first requirement is:  given a binary tree with double values, compute the sum of all nodes in the tree.

The second requirement is:  given a binary tree with double values, compute the sum of all nodes whose values are in a specified range (e.g., [ 10.0 : 15.0 ]). Continue reading “Binary Tree Sum”

The Full Counting Sort

306 Subscribers

Today I decided to solve a HackerRank problem. Randomly I selected The Full Counting Sort. If interested read the requirements. I read the requirements and decided to give it a try.

Based on my experience with this problem you might want to follow my advice. Work on the algorithm and make sure it passes the two sample test cases. Once you are done, submit your solution. If you have a valid approach then chances are that your solution will fail test #5, it will time out. I generated up to three different versions of the countSort() function. I could not get past test #5 because it would time out. I spent time reading the discussions and they did not make much sense. I even bought test #5 for some hackos. By the way, the test includes 1,000,000 strings which I could not download no matter how many times I tried. With this problem do not purchase test #5. You will not be able to run it. Continue reading “The Full Counting Sort”

Sum of Two

I received a notification via email that Nicholas White had put a new video in YouTube. If you are interested, the video is named Google Coding Interview Question – Sum of Two. I enjoy working on problems. Try to get a few each week.

Let’s skip the chit chat and go directly to this problem. The statement for the problem follows:

You have two integer arrays a and b, and an integer target value v.

Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v.

Return true if such a pair exists, otherwise return false. Continue reading “Sum of Two”