RodionGork's blog

By RodionGork, 10 years ago, In English

I found this "ancient" computer game browsing through an old book:

Player is controlling the rocket approaching the Moon. Current height and speed are reported along with the mass of remaining fuel.

Player can specify how many fuel should be fed to engines for each next 10-seconds period.

The goal is to land the rocket with the speed not exceeding safe small value (say, 10 m/s).

Crash landing of the rocket

The physics is obvious enough. New height and speed are reported each 10 seconds, so the height is decreased by roughly speed * 10 sec and speed is changed also according to gravity and working engines.

I liked the idea and readily converted it into exercise for my site and also added javascript "demo" to play it:

Game demo and more thorough explanations

Then I started playing the game myself... Well, it appeared tricky!!!

Sometimes I burned too much fuel before reaching the surface, the rocket lost the speed (or even started climbing up), then began free falling and crashed.

And sometimes I was too hesitant to burn the fuel in time so I crashed with tanks still containing more fuel than I could use (because burning rate is limited by 100 kg / second).

So I came to the question which I currently could not answer:

Which algorithm could help to calculate optimal burning rate settings (for a chain of 10-second periods) so that the rocket lands with safe speed and, additionally, maximum possible fuel left?

Full text and comments »

  • Vote: I like it
  • +30
  • Vote: I do not like it

By RodionGork, 10 years ago, translation, In English

M.Gardner in some of his books describes the puzzle: there is a set of squares, each divided into 4 triangular sectors — and these triangles are painted in 3 colors. There exists 24 different squares and it is possible to arrange them into 6*4 rectangle, so that:

  • all triangles touching the border of the rectangle have the same color;
  • each two neighbor squares have triangles of the same color on their common edge.

To make it more clear, here is an illustration of the solution:

MacMahon 24 squares solution

You can try to play with the puzzle at this page.

Gardner told that the author is Percy Alexander MacMahon.

Though it is not easy to find solution at once, there exist many of them. Gardner wrote that some of his readers counted analytically and other with the help of computer the number about 12 thousands.

This phrase made me curious how to write a program to count these solutions.

I have no other idea except to play with puzzle and find out some "laws" about placing some specific squares — and then to write brute-force limited with these laws. But it looks complicated.

So my question is whether there exist easier methods to limit the brute-force or some more cunning approaches?

Full text and comments »

  • Vote: I like it
  • +23
  • Vote: I do not like it

By RodionGork, 10 years ago, In English

Four months ago I asked about existence of algorithmic solution for "Color Cubes" game.

Now I created the challenge based on this game — the goal is to gain maximum points:

Color Cubes challenge

Click to see problem statements and live demo

Rules of the game are described in this exercise and here is also small playable demo to get better idea.

Here are current stats — you see that during last three days only three participants submitted successful solutions. Perhaps you will decide to join? Be sure, it requires only 10-15 minutes to write the simple code producing answer good enough to be submitted!

Challenge is not limited by any dead-line and no solution is going to be posted officially (though no one is restricted from discussing approaches)

Full text and comments »

  • Vote: I like it
  • +40
  • Vote: I do not like it

By RodionGork, history, 10 years ago, In English

Update

PLEASE NOTE this post have become slightly outdated. Nowadays we have more automated process. So I have just remove outdated technical details and added more contemporary links.

Uptodate info:

Here is the E-maxx site in English: https://e-maxx-eng.appspot.com

And still here is github project with article sources: https://github.com/e-maxx-eng/e-maxx-eng

To contribute one just needs to create PR in github, so generally one even may work in github web-interface for the whole process. Detailed instructions are here https://e-maxx-eng.appspot.com/contrib.html

Older text follows below


Preface

Non-zero amount of users have suggested translating E-Maxx Algo to English. As far as I know some people even started translating in their blogs, though I'm not aware of any attempt seeing great advance and evolution.

This comment suggested to attempt to do this in collaborative manner using github.

I've created a project and pushed few files here. My idea is that we can write or improve articles in Markdown format (you know it since it is used in posts/comments on CF) using pull-requests here (at least at beginning).

The results are converted HTML pages and hosted at the google appengine website.

Remaining is removed to decrease bewilderment

Full text and comments »

  • Vote: I like it
  • +73
  • Vote: I do not like it

By RodionGork, 10 years ago, In English

I was somewhat surprised to learn that besides Pi Day celebrated on the 14-th of March we have Pi Approximation Day celebrated today, on the 22-th of July.

Don't be surprised, both link lead to the same page.

I'm curious, whether it is possible to invent the day for another well-known approximation 355 / 113? Well... It could be the 113-th minute of the 355-th day of the year — something closer to astronomic time notation...

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

By RodionGork, 10 years ago, translation, In English

How to generate combinations of K elements chosen from the set of size N where some elements are duplicates? For example:

[1, 1, 2, 3, 3, 3]
choosing subsets of size 3 we have:
[1, 1, 2]
[1, 1, 3]
[1, 2, 3]
[1, 3, 3]
[2, 3, 3]
[3, 3, 3]

Somewhat clumsy algorithm could be derived from simple generation of combinations without repetitions — however its "clumsiness" make me hesitating and I'm interested whether more nice approach exists. Regretfully "Combinations with Repetitions" on the web mostly refer to another problem (if I got it right) where the number of repetitions for each element is unbounded.

Thanks in advance for hints / links!

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By RodionGork, 11 years ago, In English

CodeAbbey — is the site which I'm building in my spare time. It is basically a problem set targeted for beginner programmers.

Hope you'll like its archaic design yelling "bring back the internet of mid 90-s!!!" — just a joke, probably I'll be able to improve it in future :)

Functionality is after the manner of ProjectEuler:

  • user reads the problem statement;
  • along with it he/she receives input data (usually randomized);
  • these data should be processed (so usually user will write some program) to get answer;
  • answer is submitted along with source code (this is optional) and checked by server.

Users are ranked according to number of problems solved (more precisely according to sum of points gained for these problems).

After solving the problem one can see other people's solutions, and probably, can learn something from them.

Among the recent additions there were two new classes of problems — brainfuck puzzles which require user to submit valid brainfuck code which is tested on server — and challenges for which users can gain less or more points depending on how optimal the answer is.

I would be glad to receive ideas / suggestions or criticism — and even more I would be glad to cooperate in some way with authors of programming related blogs or people who like inventing problems and puzzles.

Full text and comments »

  • Vote: I like it
  • +74
  • Vote: I do not like it

By RodionGork, 11 years ago, In English

Sorry if this was already announced here, but two great events are at hand and probably some users are still unaware:

Google Code Jam 2014 — Qualification round starts on April 11 and is 27 hours long so people from any timezone can participate.

TopCoder Open 2014 / Algorithm — initial rounds are taking place on 5-th, 12-th and 26-th of April.

TopCoder Open 2014 / Marathon — first round starts on 9-th of April.

Full text and comments »

  • Vote: I like it
  • +49
  • Vote: I do not like it

By RodionGork, 11 years ago, translation, In English

Congratulations to all enthusiasts of Java!

Code sample:

List<Widget> widgets = ... ;
int sum = widgets.stream()
    .filter(MyClass::isRed)
    .mapToInt(w -> w.getWeight())
    .sum();

public static boolean isRed(Widget w) {
    return w.getColor() == RED;
}

Lambdas and references to methods — and moreover — the tons of strange and not easy to understand things — inside classes like Stream, Collector, Consumer, BiConsumer etc. :)

Full text and comments »

  • Vote: I like it
  • +77
  • Vote: I do not like it