3112 (tuesday is gone, post for sonny vincent)

An dieser Stelle wird vermerkt, dass der Patient wach und voll orientiert war und weder eine formale noch eine inhaltliche Denkstörung vorlag. We switch to present. Stormy weather bringt dich in Bewegung. Daytime jobs are worth a bath in gold or chocolate, but we think beyond them. After some sucking years we move to the now. loneliness and isolation makes you become bitter, but no reason to stay that way. after learning comes practicing and inspiring, motivation of the other half of them. it’ s ‘they’, because its a grey mass. don’ t consider me claiming knowledge, I follow the path of learning for all my life. read between the lines and draw your conclusions. scars heal. it’ s just life. think for yourself, don’ t become a zombie. the red line is racism, sexism or homophobia. I know what I’ m talking about. experience is growing slowly, day by day and there is no single punch that brings the knock-out. it’ s more like chinese water torture. perhaps ask the greek or open a beer. bottom line: tomorrow becomes today. kindof mumbling: the human factor, the human factor. some words of the wise gary will end this for tuesday: if he tells you, you’ re a loser then he just don’ t understand. love.

3109 (dtest)

some ls-kind experiment

#!/bin/bash
#going through some tests with dirs
#todo basename $0, set scriptname from basename, switch case (if/elseif/else) ./dir/file
FILE=$1
DIR=`dirname $FILE`
FILES=`ls $DIR`

echo "Filename specified: $FILE"
echo "Parent directory: $DIR"

for f in $FILES; do
echo "- $f"
done

3107 (n-queen-problem, graphical)

graphical solution for the n-queen-problem in java

package nq2;

import java.util.Stack;
import comp102x.Canvas;
import comp102x.ColorImage;

public class NQueens {

    public static Stack<Integer> s = new Stack<Integer>();
    public static int n; 
    public static int total; 
    private static Canvas canvas;
    private static ColorImage board;
    private static int gridSize = 80;
    private static ColorImage queen = new ColorImage("/home/evemat/Dokumente/javaio/workspace/nq2/nq2/bq80.png");
    private static ColorImage wq = new ColorImage("/home/evemat/Dokumente/javaio/workspace/nq2/nq2/wq80.png");
    private static ColorImage[] queens;
    
    public NQueens(int size) {
        
        n = size;
        int iSize = gridSize*n;
        canvas = new Canvas(iSize+10, iSize+10);
        board = new ColorImage(iSize, iSize);
        queens = new ColorImage[n];
        for (int i = 0; i<iSize; i++)
            for (int j = 0; j<iSize; j++){
                int r = i/gridSize;
                int c = j/gridSize;
                if ((r+c)/2*2 == (r+c)) board.setRGB(i, j, 0, 0, 255);
                    else board.setRGB(i, j, 255, 255, 255);
                }
                
        for (int i=0; i<n; i++)
            queens[i] = new ColorImage(queen);
            
        canvas.add(board);
        displayI(wq, n+1, n+1);
    }
            
      //finds and prints out all solutions to the n-queens problem
    public static int solve(){
        
        int i = 0;   // i goes through each row to place a queen
        int x = 0;   // x goes through the columns within each row 
        total = 0;
    
        while ( i < n ) {        
            while (x < n) {
                moveI(wq, x, i);
                if(isConflict(i, x) == false){ 
                    s.push(x); // no conflict, push x
                    moveI(wq, n+1, n+1);
                    displayI(queens[i], x, i);
                    //was commented out
                    pause(200);
                    break; //break out of loop to next row
                }
                else 
                    x++;
            }
              
            if (s.isEmpty() == true) break;
              
            if (x >= n) {
                moveI(wq, n+1, n+1);
                x = s.pop() + 1;
                i--;
                removeI(queens[i]);
                //was commented out
                pause(200);
            }
            
            else {
                i++;
                x = 0;
            }
              
            if (s.size()==n){ 
                total++; 
                pause(200);
                System.out.println(total + ": " + s);
                //if (total == 1) printSolution(s);
                removeI(queens[n-1]);
                x = s.pop() + 1;
                i--;                    
            }
        } 
        return total; 
    }

    public static boolean isConflict(int row, int col){
        int diff = row-col;
        int sum = row+col;
        for (int i = 0; i < row; i++) {
            int t = s.get(i);
            if (t==col || i-t == diff || i+t == sum) return true;
          }
          return false;
    }
    
    private static void printSolution(Stack<Integer> s) {
        for (int i = 0; i < s.size(); i ++) {
            for (int j = 0; j < s.size(); j ++) {
                if (j == s.get(i))
                    System.out.print("Q ");
                else
                    System.out.print("* ");
            }//for
            System.out.println();
        }//for
        System.out.println();  
    }//printSolution()

    public static void displayI(ColorImage image, int x, int y){
      x = x * gridSize;
      y = y * gridSize;
      canvas.add(image, x, y);
    }
    
    public static void removeI(ColorImage image){
       canvas.remove(image);
    }
    
    public static void moveI(ColorImage image, int x, int y){
        image.setX(x*gridSize);
        image.setY(y*gridSize);
    }
  
    public static void pause(int sleepTime){
        try {
            Thread.sleep(sleepTime);
        }catch (InterruptedException e) {
            System.err.println("Error in running animation!");
            System.exit(-1);
        }
    }

    public void demo() {
        //NQueens nQ = new NQueens(n);

        int number = solve();
        System.out.println("There are " + number + " solutions to the " + n + "-queens problem.");
    }
	public static void main (String[] args)
	{
	int ein = 0;
	ein = eingabe.readInt ("anzahl queens:");
	NQueens nQ = new NQueens (ein);
	nQ.demo();
	}
}

3105 (array histogram special case max 3)

public class hist
{
    
    public static int[] histogram (int [][] arrayA)
    {  // nested for loop to go through the array.
        int max = 0;
       for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{

               if ( arrayA[row][col]> max )
				{
                   max = arrayA[row][col];
            	}
        	}
    	}
	System.out.println("max:"+max);
    int histA[] = new int [max+1];
	int lauf = 0;
	for (lauf=0;lauf<max+1;lauf++)
	{
    for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{
				if (arrayA[row][col] == lauf)
				{
					histA[lauf]++;
				}
               //histA[arrayA[row][col]]++;
            }
        }
	}
        //System.out.println(histA);
        return histA;
    }
	public static void main (String[]args)
    {
        // declearing and initializing a 2D array.
        int [][] arrayA = {{0,1,2},{3,0,2},{3,3,0}};
		int erg[]={};
        erg = histogram(arrayA);
		for (int i = 0; i<=3; i++)
		{
			System.out.println(i+":"+erg[i]);
		}

    }
}

3103 (promotion, fellows)

item no
https://courses.edx.org/certificates/35e679b8e0fd4d56a660a3be3c9d1630?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base%3Bbq1UXR60Tja2yOnKqfIRoA%3D%3D 1
https://courses.edx.org/certificates/86822b6b06d243cf8b6ca1cf411dd655?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base%3Bbq1UXR60Tja2yOnKqfIRoA%3D%3D 2
https://www.serverproject.de/ 3
https://www.linkedin.com/in/matthias-evering-08824b9b/ 4
https://configedit.wordpress.com/ 0

3101 (some convertingtools)

4 javapieces int_to_bin/bin_to_int/int_to_hex/hex_to_int

int_to_bin

class dec_bin
{
public static String b0(int n) {

        if (n == 0) return "0";
        if (n == 1) return "1";
        
        return b0(n / 2) + (n % 2);
}
public static void main (String[] args)
{
int ein=0;
String erg="";
ein=eingabe.readInt("Integer:");
erg= b0(ein);
System.out.println(erg);
}
}

bin_to_int

class bin_dec
{
public static void main (String[] args)
{
String ein = "";
int foo=0;
ein=eingabe.readString("String(bin):");
foo = Integer.parseInt(ein, 2);
System.out.println(foo);
}
}

int_to_hex

class dec_hex
{
public static String intToHexStr(int i){
    return "0x"+String.format("%2s", Integer.toHexString(i)).replace(' ', '0');
}
public static void main (String[] args)
{
int ein=0;
String erg="";
ein=eingabe.readInt("Integer:");
erg=intToHexStr(ein);
System.out.println(erg);
}
}

hex_to_int

class hex_dec
{
public static void main (String[] args)
{
String ein = "";
String foo="";
String bar="";
int value=0;
ein=eingabe.readString("String(hex):");
foo=ein.substring(0,2);
if (foo.equals("0x")) { bar = ein.substring(2); }
else { bar = ein; }
value = Integer.parseInt(bar, 16);
System.out.println(value);
}
}

3097

drei 3D-arrays bilden eine entwicklung ueber die zeit ab. the values were coincidentally chosen (random), ausser des startpunktes einer 2D-nullkoordinate.

class time
{
	//main method, arguments may be passed on commandline execution
	public static void main(String args[])
	{
		// declare and initialize 4D array
		int arr[][][][] = {
								{
									{ {0,0,0},{2,6,6},{7,4,2} },
									{ {0,0,0},{9,6,2},{9,1,3} },
									{ {0,0,0},{4,5,6},{2,5,2} }
								},
								{
									{ {0,4,2},{2,6,1},{9,3,1} },
									{ {3,7,9},{9,6,2},{0,1,5} },
									{ {5,8,4},{4,7,6},{6,5,2} }
								},
								{
									{ {7,5,2},{2,6,2},{6,5,5} },
									{ {6,8,9},{7,5,2},{8,5,9} },
									{ {2,8,5},{3,7,7},{4,5,8} }
								}
							};
		// print time array in four nested for-loops
		for (int l = 0; l<3; l++)		
		{	
			//print 3D-element number
			System.out.println(l);
			for (int i=0; i< 3 ; i++)
			{
				for (int j=0; j < 3 ; j++)
				{
					for (int k=0; k < 3; k++)
					{
						//print element
						System.out.print(arr[l][i][j][k] + " ");
					}
					//print whitespaces
					System.out.print("     ");
				}
				//newline
				System.out.println();
			}
		}
	}
}