package fr.notfound.domain;

import static java.lang.String.format;

import java.util.Objects;

import fr.notfound.meta.ValueType;

@ValueType
public class Board {
    
    public final String representation;

    public Board(String board) {
        this.representation = board;
    }
    
    public Board apply(Move move) {
        return new Board(format("%s + %s", toString(), move.toString()));
    }
    
    public int firstAvailable() {
        return representation.indexOf("1");
    }
    
    @Override public boolean equals(Object obj) {
        if (obj == null) return false;
        if (this == obj) return true;
        if (getClass() != obj.getClass()) return false;
        Board other = (Board)obj;
        return Objects.equals(representation, other.representation);
    }
    
    @Override public int hashCode() {
        return Objects.hashCode(representation);
    }
    
    @Override public String toString() {
        return "Board " + representation;
    }

    public static Board parse(String board) {
        return new Board(board);
    }

}

@@ -40,58 +40,214 @@
 tic 
-java.lang.String.format;%0A%0Aimport java.util.Objects
+com.google.common.collect.Lists.newArrayList;%0Aimport static java.lang.String.format;%0A%0Aimport java.util.List;%0Aimport java.util.Objects;%0Aimport java.util.regex.Pattern;%0A%0Aimport com.google.common.base.Splitter
 ;%0A%0Ai
@@ -642,32 +642,1167 @@
 1%22);%0A    %7D%0A    %0A
+    public int length() %7B%0A        return representation.length();%0A    %7D%0A    %0A    public List%3CMove%3E groups() %7B%0A        //Iterable%3CString%3E groupsOfOnes = Splitter.on(%220%22).omitEmptyStrings().split(representation);%0A        List%3CMove%3E groups = newArrayList();%0A        int currentGroupIndex = 0;%0A        int currentGroupSize = 0;%0A        boolean capturing = false;%0A        for (int i = 0; i %3C representation.length(); i++) %7B%0A            if (representation.charAt(i) == '1') %7B%0A                if (capturing) %7B%0A                    currentGroupSize += 1;%0A                %7D else %7B%0A                    capturing = true;%0A                    currentGroupIndex = i;%0A                    currentGroupSize = 1;%0A                %7D%0A                if (i == representation.length() - 1) %7B%0A                    groups.add(new Move(currentGroupIndex, currentGroupSize));%0A                %7D%0A            %7D else %7B%0A                if (capturing) %7B%0A                    capturing = false;%0A                    groups.add(new Move(currentGroupIndex, currentGroupSize));%0A                %7D%0A            %7D%0A            %0A        %7D%0A        %0A        return groups;%0A    %7D%0A    %0A
     @Override pu

add groups() method on Board : returns groups of sticks with position and size