import java.util.*;

/*
 * They begin by taking turns reading from a list of starting numbers (your puzzle input).
 * Then, each turn consists of considering the most recently spoken number:
 * 
 * If that was the first time the number has been spoken, the current player says 0.
 * Otherwise, the number had been spoken before; the current player announces how many turns
 * apart the number is from when it was previously spoken.
 */

public class Memory
{
    public Memory ()
    {
        _theMemory = new HashMap<Long, Number>();
        _lastNumberSpoken = -1;
        _turn = 0;
    }

    public long getLastNumber ()
    {
        return _lastNumber;
    }

    public Long speakNumber (Long numb)
    {
        _lastNumberSpoken = numb;
        _turn++l

        Number count = _theMemory.get(numb);

        if (count == null)
            count = new Number();
        else
            count++;

        _theMemory.put(numb, count);

        return count;
    }

    public Long numberPresent (Long numb)
    {
        return -1;
    }

    private HashMap<Long, Number> _theMemory;
    private Long _lastNumberSpoken;
    private Long _turn;
}
@@ -533,40 +533,8 @@
 ();%0A
-        _lastNumberSpoken = -1;%0A
     
@@ -570,28 +570,26 @@
 lic 
-l
+L
 ong 
-getLast
+speak
 Number (
 )%0A  
@@ -584,16 +584,25 @@
 Number (
+Long numb
 )%0A    %7B%0A
@@ -609,23 +609,16 @@
         
-return 
 _lastNum
@@ -624,62 +624,179 @@
 mber
-;%0A    %7D%0A%0A    public Long speakNumber (Long numb)%0A    %7B
+Spoken = numb;%0A        _turn++;%0A%0A        Number theNumber = _theMemory.get(numb);%0A%0A        if (theNumber == null)%0A        theNumber = new Number(numb, count);%0A        else
 %0A   
@@ -804,33 +804,75 @@
     
-_last
+    the
 Number
-S
+.s
 poken
- = numb;
+();;%0A%0A        _theMemory.put(numb, theNumber);%0A
 %0A   
@@ -880,17 +880,101 @@
     
-_
+re
 turn
-++l%0A
+ theNumber.spokenTimes();%0A    %7D%0A%0A    public boolean firstTimeSpoken (Long number)%0A    %7B
 %0A   
@@ -985,21 +985,20 @@
  Number 
-count
+numb
  = _theM
@@ -1003,32 +1003,34 @@
 eMemory.get(numb
+er
 );%0A%0A        if (
@@ -1029,21 +1029,20 @@
     if (
-count
+numb
  == null
@@ -1059,28 +1059,19 @@
     
-count = new Number()
+return true
 ;%0A  
@@ -1097,25 +1097,109 @@
     
-count++;%0A%0A       
+return false;%0A    %7D%0A%0A    public Long getNumberOfTimesSpoken (Long number)%0A    %7B%0A        Number numb =
  _th
@@ -1210,47 +1210,120 @@
 ory.
-pu
+ge
 t(numb
-, count);%0A%0A        return count
+er);%0A%0A        if (numb == null)%0A            return 0;%0A        else%0A            return numb.spokenTimes()
 ;%0A  
@@ -1347,32 +1347,38 @@
 ong 
-numberPresent
+getNextNumber
  (Long 
-n
+lastN
 umb
+er
 )%0A  
@@ -1457,44 +1457,8 @@
 ry;%0A
-    private Long _lastNumberSpoken;%0A
     

Update Memory.java