HackerRank: Kangaroo

HackerRank: Kangaroo

Everybody loves a kangaroo right? Except maybe if you are Australian! Anyway in this post we shall talk both about snakes and mammals, or more specific Python and Kangaroos. I have started on learning a bit of Python and using HackerRank to learn my ways around. I have been solving a few puzzles by now.  The ones I have solved so far, are no where near the complexity of Project Euler. Apart from the fact that quite a few of the project euler problems are actually represented at HackerRank, but with more test cases, so you have to write the code a little more generically. But more about that later, because I will likely solve a few of the Project Euler problems in Python while learning it.

Anyway, the first problem I solved, which might be worth spending a minute or two about, is the problem called Kangaroo.

The short description of the problem is as follows

There are two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. Given the starting locations and movement rates for each kangaroo, can you determine if they’ll ever land at the same location at the same time?

Input Format
A single line of four space-separated integers denoting the respective values of x1, v1, x2 and v2

Note: The two kangaroos must land at the same location after making the same number of jumps.

Continue reading →

Posted by Kristian in HackerRank, 0 comments
Shenzhen I/O – Passive Infrared Sensor

Shenzhen I/O – Passive Infrared Sensor

I think we are at problem number 7 in Shezhen I/O where we are asked to help a security company design a passive infrared sensor that will trigger an alarm between a given time interval, if there is too much activity. We are given a problem where were have the a simple sensor input and a simple alarm output. We also have a simple input giving us time. Further more we have 2 xbus inputs giving us the on and off times. The problem description is simple enough, if the timer is between the on and off time (loop) and the sensor reading is 20 or higher we should trigger the alarm. Just like the signals here tells us

Shenzhen IO - Passive Infrared Sensor - signals Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O – Harmonic Maximization Engine

Shenzhen I/O – Harmonic Maximization Engine

By now we are veterans in making cheap electronic gadgets for the company. And now they want us to make a Harmonic Maximization Engine! That sounds cool.

When we look at the specifications we are supposed to copy the audio-in to audio out as long as the maximize is not high.

If the maximize input is high then we should apply the following algorithm

AUDIO_OUT = (AUDIO_IN – 50) x 4 + 50

As it is given to us in the manual. This gives us the following signals for verification

Shenzhen IO - harmonic maximization engine - signals Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O – Drinking Game Scorekeeper

Shenzhen I/O – Drinking Game Scorekeeper

Joe have been out drinking again. This time with Baron Von Schnapps. I don’t say this was a serious game. However, it resulted in yet another deal for us. So good job Joe on landing electronics, bad job for your liver. However, they want to promote their drink with a small game. And we are to make a drinking Game Scorekeeper to help them with that.

He might not remember the exact rules, but we are given two inputs called point and foul. As well as a display with a non-blocking xbus input. And if they trigger point, we should increment the display with one. If we get a foul we should subtract 2. However, we should never show less than zero on the display. Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O: Animated Esports Sign

Shenzhen I/O: Animated Esports Sign

I think Joe has been out drinking with some friends. At least he landed us the fourth deal. We are to make an animated esports sign for one of the famous stars in the world.

The board has 5 simple outputs and we are supposed to generate signals that looks like

Animated Esports Sign - signals Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Reverse Polish Notation

Reverse Polish Notation

One of the most popular pages on mathblog is the infix to postfix converter. When I realized that –  I decided it was worth diving a little more into what postfix or Reverse Polish Notation as it is better known is. Reverse Polish Notation is a mathematical notation which is functioning very well in a stack based implementation. In Reverse Polish Notation the operators follow their operands, in contrast to Polish Notation, in which operators precede their operands. One of the main benefits of Reverse Polish Notation is the fact that it does not rely on parentheses to evaluate the expression – as long as each operator has a  fixed number of operands. Continue reading →

Posted by Kristian in Math, 0 comments
Shenzhen I/O: Diagnostic Pulse Generator

Shenzhen I/O: Diagnostic Pulse Generator

The third task we get is playing solitaire, but ignoring that the third programming puzzle we get is that we need to test some manufacturing equipment. We can do that by building a diagnostic pulse generator that sends a pulsing signal to the output whenever we hold a button.

The board looks like this where the button is a simple input. When it goes high we should generate a pulse to the pulse output with a certain characteristic. Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O: Control Signal Amplifier

Shenzhen I/O: Control Signal Amplifier

In our second assignment we are asked to build a signal amplifier as a replacement for a control signal amplifier factory module that got eeeehhhh smashed…. but don’t worry, no one was hurt much. This task is in my opinion still as close as we get to a tutorial in this game as we ever will. The signal amplifier is pretty simple. We will take the input signal from a simple input, multiply it by 2 and send it to the simple output pin.

Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O: Fake Surveillance Camera

Shenzhen I/O: Fake Surveillance Camera

The very first challenge we get in Shenzhen IO is to make some LEDs blink on a fake security camera. We have just been hired by Shenzhen Longteng Electronics CO. Ltd and we are taking on an old project we are taking over from a guy who quit. The camera has two LEDs called “active” and “network” and we should design and code the solution to make them blink in this pattern

Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
Shenzhen I/O

Shenzhen I/O

Is your biggest dream to move to china and program cheap electronic devices? Mine is not. However you now get the chance to play a video game where you do just that. Shenzhen I/O is a programming puzzle game created by Zachatronics where you solve puzzles through programming and designing embedded electronic circuits. I got hooked on it when I saw my favorite youtuber Scott Manley play it. You should go watch him some time, he is excellent both at making fun Kerbal Space Program videos, but also his scientific explanations are awesome. Continue reading →

Posted by Kristian in Shenzhen IO, 0 comments
This site uses cookies.