Five Letter Word Six Guesses

Been enjoying this little game over the past week or so and thought I would try my hand at it.

Short little exercise that took 3 days

Check it out here

Overthewire Bandit 24

A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.

C=32
for i in {0..282};
  do
    for j in $(seq 0 $(($C-1)));
    do
    k=$((i*$C+j+1000))
    if (( $k % 500 == 0 )) # show progress
    then
      echo $k
    fi

    echo $banditpass $k | nc localhost 30002 | grep -v Wrong | grep -v Exiting | grep -v checker &
  done

  while [ `jobs -r | wc -l | tr -d " "` >= $C ]; do
    sleep 1
  done
done

Working within the allowed number of parallel background jobs.

Project Euler – Problem 3

Problem 3:
The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

import math

pSieve = []
max = math.floor(math.sqrt( 600851475143 ))
l = 0
i=2;
while i ii ):
			break;
		if (i % pSieve[j] == 0): 
			found = True
			break;
		j+=1
	if found == False:
		pSieve.append(i)
		if (600851475143 % i == 0):
			l=i
	i+=1
print l

Update to quick one-liner Windows unzips

So this one is taken from https://blogs.msdn.microsoft.com/daiken/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget/

echo $zipfilename=$args[0]; $destination=$args[1];if(test-path($zipfilename)) {$shellApplication = new-object -com shell.application;$zipPackage = $shellApplication.NameSpace($zipfilename);$destinationFolder = $shellApplication.NameSpace($destination); $destinationFolder.CopyHere($zipPackage.Items()); };>unzip.ps1

powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File unzip.ps1 %FullPathToZip% %FullPathToTarget%

This was tested on PSv2.

Buildforge CRRBF1253I Process for id [] [B] died unexpectedly.

I kept getting Completed — Failed — Died and
CRRBF1253I Build Forge: Process for id [] [B] died unexpectedly.

After checking out http://www.ibm.com/support/docview.wss?uid=swg21634022 and
http://www.ibm.com/support/docview.wss?uid=swg21634022 there was still no solution in sight.

Finally I was able to solve the issue in my buildforge instance by disabling *sticky* in my inline libraries. I was also using .bset server and .bset buildserver. My theory is that some interaction between the sticky and the bset were conflicting.

Build Forge Agent Troubleshooting

Just in case some poor sap like me gets stuck with errors
connecting to Build Forge Agents:


320 AUTH AuthFail[*AuthUnknownUser,"username"]
com.buildforge.services.common.api.APIException:
CRRBF0158I: Unable to set user account to unknown account (builder)
at com.ibm.jas.mjc.server.refresh.AgentServerTestFiber.checkAuth(AgentServerTestFiber.java:431)

Some fixes..

sudo cp /etc/pam.d/login /etc/pam.d/bfagent
sudo /usr/local/bin/bfagent -s

Scrabble Problem

If I give you scrabble tiles and a dictionary, determine the valid words
from your collection of tiles.

package joshho;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;

public class Runner {
	ScrabbleSet set ;
	
	private class ScrabbleSet {
		char[] chars;
		public ScrabbleSet(String[] orig){
			chars = new char[orig.length];
			for(int i=0;i chars.length) return false;
			Arrays.sort(find);
			int s=0;
			for(int i=0;i chars[j]) continue;
					if(find[i] == chars[j]){
						s=j+1;
						break;
					}
					return false;
				}
			}
			return true;
		}
	}
	
	public void load(String y){
		set = new ScrabbleSet(y.split(" "));
	}

	public static void main(String[] args) throws IOException {
		args = new String[]{"Scrabble\\data\\english4000.dic",
				"g w x b d u t z q m o i e p o"};
		FileReader fr =  new FileReader(args[0]);
		BufferedReader br = new BufferedReader(fr);

		Runner r = new Runner();
		r.load(args[1]);
		System.out.println(args[1]);
		
		String line;
		while((line = br.readLine()) != null) {
			System.out.print(line+" ");
			System.out.println(r.set.checkWord(line.toCharArray()));
		}
		br.close();
		
		
	}

}

There’s probably a better way to do this, I am interested
to see what other solutions there are.

Zip with ANT on Windows command line

Short two liner for ANT zipping on Windows.

 

>build.xml echo ^<project^>^<zip destfile=^"zipFile.zip^" basedir=^"toBeZipped^" /^>^</project^>
ant

Because Windows doesn’t apparently have a zip command line.

Updated here for Windows without ANT.

Working with genrb and ICU4J

Wanting to use the messages in ICU4J, I was lead to believe one needed to run the command:

genrb root.txt

This produces root.res.
However using the following snippet results in the error message below:

UResourceBundle urb = UResourceBundle.getBundleInstance("Your package path","root");

>Data file yourPackagePath/root.res is corrupt - ICU data file error: Header authentication failed, please check if you have a valid ICU data file

Continued reading >

Cookie cannot be resolved to a type

“Cookie cannot be resolved to a type”

I swear I’ve seen this error like 5 times in eclipse now, and I have yet to learn my lesson.
If this error originates from a jsp file, your project doesn’t have a valid target webserver (in my case – tomcat).

So just make sure it’s configured correctly.

Thought I’d just leave this here,
because almost all top searches in google were useless to me.

Cheers.