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.

## 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

## 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 →

## 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

fto 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.

## Making decisions under uncertainty in everyday life

Everyday I (and probably everyone else) am faced with decisions that we have to make, some of them are small, some of them are big. At least for me there are two aspects governing the decisions I want to make. I want to make the best decision and I am making the decisions without knowing everything. This is exactly what stochastic optimization and what I work with in my daily job.

But now I have found a really good example from real life which I am facing often and which have some really interesting characteristics. It involves something I know that several people have been thinking about when walking in a city: How can we come from point A to point B in the most effective way.

I wont be getting into details of how to formulate any of this in a mathematical setting. You can find lots of text books on that. I just want to introduce you to some of the concepts and ideas of it. Continue reading →

## Taking a break

If you are following my blog regularly, you will know that I usually posts once a week on Saturday. However, nothing new has been posted the last couple of weeks. I just wanted to let you know that the site has not been abandoned or anything like that. However, I do have a lot of things going on right now and only 24 hours per day, and that meant I had to stop doing something. Posting on my blog was one of the things.

I will pick it up again someday, I know I will. I will also try to come up with a few different other posts and topics. I already have one idea which you will see in a few weeks I hope.

## 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 integernfor which the numbersn^{2}+1,n^{2}+3,n^{2}+7,n^{2}+9,n^{2}+13, andn^{2}+27 are consecutive primes is 10. The sum of all such integersnbelow one-million is 1242490.

What is the sum of all such integersnbelow 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 →

## 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 integersnhave 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 numbersreversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in eithernor reverse(n).

There are 120 reversible numbers below one-thousand.

How many reversible numbers are there below one-billion (10^{9})?

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 →

## UVa Online Judge New Platform

We at MathBlog have written about a couple of problems from the UVa Online Judge. The current UVa OJ platform is almost 7 years old, and so the UVa OJ team thinks it’s time for an upgrade. They intend to build the platform up from scratch, but to do that, they need funding. Therefore, they’ve set up a campaign, located here, where you can donate and help fund the project. Note that MathBlog is not affiliated with UVa Online Judge in any way.

There are 6 days left of the campaign, so we encourage you to let others know, and perhaps even donate yourself.

Again, here is the campaign, and here is the main UVa OJ website.

## Project Euler 144: Investigating multiple reflections of a laser beam.

Problem 144 of Project Euler is once again a geometry problem, just like the previous. However, it is completely different. The problem reads

In laser physics, a “white cell” is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out.

The specific white cell we will be considering is an ellipse with the equation 4x^{2}+y^{2}= 100

The section corresponding to -0.01≤x≤+0.01 at the top is missing, allowing the light to enter and exit through the hole.

The light beam in this problem starts at the point (0.0,10.1) just outside the white cell, and the beam first impacts the mirror at (1.4,-9.6).

Each time the laser beam hits the surface of the ellipse, it follows the usual law of reflection “angle of incidence equals angle of reflection.” That is, both the incident and reflected beams make the same angle with the normal line at the point of incidence.

In the figure on the left, the red line shows the first two points of contact between the laser beam and the wall of the white cell; the blue line shows the line tangent to the ellipse at the point of incidence of the first bounce.

The slopemof the tangent line at any point (x,y) of the given ellipse is:m= -4x/y

The normal line is perpendicular to this tangent line at the point of incidence.

The animation on the right shows the first 10 reflections of the beam.

How many times does the beam hit the internal surface of the white cell before exiting?