# Yakult Competition

Yakult, the probiotic dairy product made by fermenting a mixture of skimmed milk with a special strain of the bacterium Lactobacillus casei Shirota, are running a competition.

If you don’t use the London Underground, you’re probably unaware of it, but here’s the poster advertising it:

I found the station that contains NO letters from the word MACKEREL by staring at a London Underground map with my girlfriend.

But seeing as there’s a new puzzle everyday, I wanted a quicker way to find which stations contain NO letters from Yakult’s word of the day.

So, being a programmer, albeit a poor one according to two of my lecturers, I wrote a Java program to solve the puzzles for me.

I first needed a list of all London Underground stations, the maps handed out at Underground stations has a list on the back so I simply typed them up.

(Not really, DTFC did, thank you very much http://uk.answers.yahoo.com/question/index?qid=20061002011752AAA7sTU

Though DTFC gives 318 stations, where as TFL states there are 270 stations being served http://www.tfl.gov.uk/corporate/modesoftransport/londonunderground/1608.aspx

So I figured having more stations is the better option.)

Now for the code:

```
/*
* 19/02/2014
*
*
*/
import java.util.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileWriter;
import java.util.Arrays;

public class Yak {

public static void main(String[] args) {

File file = new File(&quot;StationList.txt&quot;); //Reads in a text file containing all Underground stations

try {
int j = 0;
int x = 0;
int Length = 0;
int lineLength = 0;
String[] Stations = new String[318];
Scanner scanner = new Scanner(file);
Scanner scanner2 = new Scanner(System.in);
String Phrase = &quot; &quot;;
String Station = &quot; &quot;;
String temp = &quot; &quot;;
int StationLength = 0;

System.out.println( &quot;Please enter phrase: &quot; );
Phrase = scanner2.nextLine();       //Stores the phrase
Length = Phrase.length();

char[] Characters = new char[Length];

for( int i = 0; i&lt; Length; i++ ) {
Characters[i] = Phrase.charAt( i ); //Loops through the phrase and stores each character
}

while( scanner.hasNextLine()) { //Read every line of the stations file
String line = scanner.nextLine();
line = line.replaceAll( &quot;\\s+&quot; , &quot;&quot; ); //Get rid of all spaces
line = line.toLowerCase();  //Turn to lower case
lineLength = line.length();
Stations[j] = line;  //Add each station to an array
j = j + 1;  //To count how many stations there are
}

for( int i = 0; i &lt; j; i++ ) {
x = 0; //counter
for( int k = 0; k &lt; Length; k++ ) {
temp = &quot;&quot; + Characters[k]; //Put single character in a string
if( Stations[i].contains( temp )) { //Check if the station contains the string

} else {
x = x + 1; //If it doesn't add one to counter
}
if( x == Length ) { //If the counter is the same as the length of the phrase
System.out.println( Stations[i] + &quot; does not contain any letters from &quot; + Phrase ); //Then a station is found
}
}

}
} catch (IOException e) {
e.printStackTrace();
}

}
}

&amp;nbsp;

```

This may not be the most efficient way to solve this program, but it works!

Here is the output:

mackerel

The station that contains no letters from mackerel is *******

I wouldn’t want to spoil your fun in completing the puzzle 😉

## 3 thoughts on “Yakult Competition”

1. Laurence says:

cat tubelist.txt | grep -iv [mackeral]

2. Eva says:

I’m obsessed with these! I’ve seen three so far but not this one. Where was this poster? I’ll have a think about it and comment later!

3. Pingback: Solving the ‘Yakult Problem’ in Python |