There are a number of plants in a garden. Each of these plants has been treated with some amount of pesticide. After each day, if any plant has more pesticide than the plant on its left, being weaker than the left one, it dies. You are given the initial values of the pesticide in each of the plants. Print the number of days after which no plant dies, i.e. the time after which there are…

A left rotation operation on an array shifts each of the array’s elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2]. Given an array a of n integers and a number, d, perform d left rotations on the array. Return the updated array to be printed as a single line of space-separated integers. More information about this problem can be found…

It’s New Year’s Day and everyone’s in line for the Wonderland rollercoaster ride! There are a number of people queued up, and each person wears a sticker indicating their initial position in the queue. Initial positions increment by 1 from 1 at the front of the line to n at the back. Any person in the queue can bribe the person directly in front of them to swap positions. If two people swap positions, they…

You are given a square grid with some cells open (.) and some blocked (X). Your playing piece can move along any row or column until it reaches the edge of the grid or a blocked cell. Given a grid, a start and an end position, determine the number of moves it will take to get to the end position. For example, you are given a grid with sides n=3 described as follows:. . ..…

Lilah has a string, s , of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a’s in the first n letters of Lilah’s infinite string. For example, if the string s=’abcac’ and n=10, the substring we consider is ‘abcacabcac’ , the first 10 characters of her infinite string. There are occurrences 4 of a in the substring. More information about this ‘problem’ can…

John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are socks n=7 with colors ar=[1,2,1,2,1,3,2] . There is one pair of color and one of color . There are three odd socks left, one of each color. The…

Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly n steps. For every step he took, he noted if it was an U uphill, , or a D downhill, step. Gary’s hikes start and end at sea level and each step up or down represents a unit change in altitude. We define the following terms: A mountain is a…

Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use only whole words available in the magazine. He cannot use substrings…

RaspberryPi is a well established tiny-pc which is worldwide used for prototyping as well as mini DYI projects. In this tutorial we will explain step-by-step how to setup the raspberryPI with a touchscreen and install some useful libraries for writing simple and nice GUI applications. PS: For sure there are several other libraries that can be used to write graphical applications such as QT etc.. Requirements: RaspberryPI 3 Model B RaspberryPI 3 7” Touchscreen Display…

In this tutorial, a simple but useful data buffering/streaming algorithm is presented. It is not optimal but easy to understand and modify according to your needs… This library assumes that we need to use a big amount of data in a memory limited system. The library handles the all the data transferring procedure in a way that the user is able to easily get the amount of data without worrying about the buffering complexity. …

Windows CMD (Command Line) supports an easy way to automate some task. This can be archived by creating *.bat files and edit them using a simple text editor. The syntax is something that can be found easily by searching. Below is a simple script which can be used to schedule the execution of applications in a sequential way. It means that the .bat script will wait for the X application to finish before it executes…

The purpose of this application is just for fun. It started initially by figuring out a way to fake skype that you are in front of your PC but also to randomly create a picture. The application takes control of your mouse and start drawing random pixels in the main area of the window thus generating mouse position and click events. Below is a sample picture as well as the binary: