Posts Tagged ‘Programming’

How do hash functions work?

Connect Four - Thumbnail

Everybody who has written a noticeable amount of Java code should know the method hashCode(). But most beginners have difficulties to understand the significance of this little method. The following article gives you one small example with some impressions how much hash functions influence execution time. Connect four Connect Four [...] is a two-player game [...]

Check x-in-a-row for board games

Moves of the queen in chess

In board games, you have quite often the situation that you want to check something in different directions. Most of the time, the implementation I see for situations like this is very redundant and prone to off-by-one errors. Some simple ideas can improve the quality of codes (code that is easier to understand and less [...]

How to sort with Java

Java Thumbnail

Sorting is a very basic task that every programmer should be able to solve. In Python, you have sort and sorted. In C++, you can use operator overloading. I’ll now tell you how to do basic sorting with Java. I will not write about natural language sorting or language-aware sorting. This is only about simple [...]

Tribonacci-Folge

Folgende Aufgabe gab es (sinngemäß) für das Modul „Programmieren“ im zweiten Übungsblatt 2012: Sei eine Folge und definiert durch: . Ich werde im folgenden mal kurz mögliche Lösungen in Python (und eine in Java) vorstellen. Python hat bei solchen Aufgaben den Vorteil, dass es viel kompakter ist und Ganzzahlen beliebig groß werden können. Händische Lösung [...]

Project Euler: Problem 35

Leonhard Euler

The task in Problem 35 of Project Euler is: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. How many circular primes [...]

Project Euler: Problem 33

Leonhard Euler

The task in Problem 33 of Project Euler is: The fraction is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that , which is correct, is obtained by cancelling the 9s. We shall consider fractions like, , to be trivial examples. There are exactly four non-trivial examples of [...]

What is the best programming language?

A fair test - cartoon - thumb

There is no such thing as a best programming language. Sorry about that, I’ve just thought it would be a catchy title. I would rather choose my tools after I know the problem I have to solve. Some programming languages are very good at some tasks. I don’t know any that is very good at [...]