Solutions

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
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
Project Euler 267: Billionaire

Project Euler 267: Billionaire

It has been a long while since I solved any Project Euler problem. For some reason I read an article about it and someone references Problem 267, so I decided to take a look at it, and it sucked me in. The problem reads

You are given a unique investment opportunity.

Starting with £1 of capital, you can choose a fixed proportion, f, of your capital to bet on a fair coin toss repeatedly for 1000 tosses.

Your return is double your bet for heads and you lose your bet for tails.

For example, if f = 1/4, for the first toss you bet £0.25, and if heads comes up you win £0.5 and so then have £1.5. You then bet £0.375 and if the second toss is tails, you have £1.125.

Choosing f to maximize your chances of having at least £1,000,000,000 after 1,000 flips, what is the chance that you become a billionaire?

All computations are assumed to be exact (no rounding), but give your answer rounded to 12 digits behind the decimal point in the form 0.abcdefghijkl.

 

Continue reading →

Posted by Kristian in Project Euler, 12 comments
Project Euler 146: Investigating a Prime Pattern

Project Euler 146: Investigating a Prime Pattern

In Problem 146 of Project Euler we are working with primes again, and some quite big ones even. The problem reads

The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10. The sum of all such integers n below one-million is 1242490.

What is the sum of all such integers n below 150 million?

At first I thought I could just make a sieve up to 150 million and then check if the numbers were contained in that. However, rereading the problem I realized I was completely wrong. So in a pure brute force solution we would need to check 150 million values of n and up to 13 numbers for each, since we both need to check that the given numbers are prime. But also that the odd numbers inbetween are not prime. So potentially we have to check 1950 million numbers for primality, which is a moderately expensive operation. Continue reading →

Posted by Kristian in Project Euler, 7 comments
Project Euler 145: How many reversible numbers are there below one-billion?

Project Euler 145: How many reversible numbers are there below one-billion?

In Problem 145 of Project Euler we move away from Geometry and over to number theory again, with a problem which reads

Some positive integers n have the property that the sum [ n + reverse(n) ] consists entirely of odd (decimal) digits. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such numbers reversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in either n or reverse(n).

There are 120 reversible numbers below one-thousand.

How many reversible numbers are there below one-billion (109)?

This one is insanely easy to write a brute force method and that is the first thing I did. However, as we shall see there is a more analytic approach to the problem as well. Continue reading →

Posted by Kristian in Project Euler, 5 comments