1. Erste Version: JAVA, [2] + Evgeni Pavlidis


/************************************************
Grundlegende Algorithmen mit Java,
http://algorithmen-und-problemloesungen.de/
Copyright @2007-2008 by Doina Logofatu
************************************************/

import java.io.*;

public class Main {
private static final String FileOutputName = "nikolaus.out";

private int a[][] = { new int[] { 0, 1, 1, 0, 1 },
new int[] { 1, 0, 1, 0, 1 }, new int[] { 1, 1, 0, 1, 1 },
new int[] { 0, 0, 1, 0, 1 }, new int[] { 1, 1, 1, 1, 0 } };

private int b[] = new int[9];
private int sol = 0;
private PrintStream out;

Main(PrintStream out) {
this.out = out;
}

void run() {
back(1);
}

private void writeSol() {
for (int i = 0; i < 9; i++) {
out.print(b[i] + 1);
}
out.println();
}

void back(int k) {
int i;
if (9 == k)
writeSol();
else
for (i = 0; i < 5; i++)
if (a[i][b[k - 1]] == 1 && i != b[k - 1]) {
b[k] = i;
a[i][b[k - 1]] = 0;
a[b[k - 1]][i] = 0;
back(k + 1);
a[i][b[k - 1]] = 1;
a[b[k - 1]][i] = 1;
}
}

public static void main(String[] args) throws IOException {
PrintStream out = new PrintStream(System.out);
try {
new Main(out).run();
} finally {
out.close();
}
}
}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 291 House of Santa Claus
*
* @author Reichart Robert
*
* Status : Accepted
* Runtime: 0.100
*/

import java.util.*;

class Main{
public static void main(String... args){
int[] number = {123153452,
123453152,
125431532,
132543512,
135234512,
134521532,
152134532,
153213452,
154312532,
123154352,
125135432,
125435132,
135123452,
135432152,
134523512,
152354312,
153254312,
154321352,
123513452,
125134532,
132153452,
135125432,
135432512,
134532152,
152345312,
153452132,
154325312,
123543152,
125315432,
132154352,
135215432,
134512352,
134532512,
153123452,
153452312,
154352132,
123451352,
125345132,
132534512,
134512532,
152135432,
153125432,
154312352,
154352312};
Arrays.sort(number);
for (int i=0;i<number.length;i++){
System.out.println(number[i]);
}

}
}