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:

ImageI 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
* Copyright (c) Wightboy@wordpress.com
* All rights reserved.
import java.util.*;
import java.io.BufferedReader;import java.io.File;
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) {

BufferedReader Reader = null;
File file = new File("StationList.txt"); //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 = " ";
String Station = " ";
String temp = " ";
int StationLength = 0;

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

char[] Characters = new char[Length];

for( int i = 0; i< 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( "\\s+" , "" ); //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 < j; i++ ) {
x = 0; //counter
for( int k = 0; k < Length; k++ ) {
temp = "" + 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] + " does not contain any letters from " + Phrase ); //Then a station is found

} catch (IOException e) {



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

Please feel free to message me with your comments, about anything here!

Here is the output:

Please enter phrase:


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. 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!

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s