extract data from the list

0

I made a few attempts, but I'm still picking up what I added in the code.

How can I make this limitation within the code that results in the closing below? I lacked logic on how to implement reading data from text file.

Here you have 4 if 4 (10 dozen).

  • Example1:

if they are drawn: 1,3,5,6,8,9 out of the 10 I have a block or several.

  • Example2:

let's assume another draw that I missed two dozen 12 and 19 type: 1,3,5,6,12,19 in this case I only hit 4 out of 10, if you look for those 4 dozens in the closing below, I have at least that set or a block.

********************************************
resultado a ser alcançado
********************************************

total dezenas: 10
conjunto 6
garantia 4
para acerto 4

01 02 03 04 05 06,
01 02 03 05 07 09,
01 02 03 06 07 08,
01 02 03 06 09 10,
01 02 04 06 07 10,
01 02 04 07 08 09,
01 02 05 07 08 10,
01 03 04 05 07 10,
01 03 04 05 08 09,
01 03 05 06 08 10,
01 04 06 08 09 10,
01 05 06 07 09 10,
02 03 04 06 08 09,
02 03 04 07 09 10,
02 03 05 08 09 10,
02 04 05 06 07 09,
02 04 05 06 08 10,
03 04 06 07 08 10,
03 05 06 07 08 09,
04 05 07 08 09 10,

to facilitate I'm posting

lista.txt

01  02  03  04  05  06,
01  02  03  04  05  07,
01  02  03  04  05  08,
01  02  03  04  05  09,
01  02  03  04  05  10,
01  02  03  04  06  07,
01  02  03  04  06  08,
01  02  03  04  06  09,
01  02  03  04  06  10,
01  02  03  04  07  08,
01  02  03  04  07  09,
01  02  03  04  07  10,
01  02  03  04  08  09,
01  02  03  04  08  10,
01  02  03  04  09  10,
01  02  03  05  06  07,
01  02  03  05  06  08,
01  02  03  05  06  09,
01  02  03  05  06  10,
01  02  03  05  07  08,
01  02  03  05  07  09,
01  02  03  05  07  10,
01  02  03  05  08  09,
01  02  03  05  08  10,
01  02  03  05  09  10,
01  02  03  06  07  08,
01  02  03  06  07  09,
01  02  03  06  07  10,
01  02  03  06  08  09,
01  02  03  06  08  10,
01  02  03  06  09  10,
01  02  03  07  08  09,
01  02  03  07  08  10,
01  02  03  07  09  10,
01  02  03  08  09  10,
01  02  04  05  06  07,
01  02  04  05  06  08,
01  02  04  05  06  09,
01  02  04  05  06  10,
01  02  04  05  07  08,
01  02  04  05  07  09,
01  02  04  05  07  10,
01  02  04  05  08  09,
01  02  04  05  08  10,
01  02  04  05  09  10,
01  02  04  06  07  08,
01  02  04  06  07  09,
01  02  04  06  07  10,
01  02  04  06  08  09,
01  02  04  06  08  10,
01  02  04  06  09  10,
01  02  04  07  08  09,
01  02  04  07  08  10,
01  02  04  07  09  10,
01  02  04  08  09  10,
01  02  05  06  07  08,
01  02  05  06  07  09,
01  02  05  06  07  10,
01  02  05  06  08  09,
01  02  05  06  08  10,
01  02  05  06  09  10,
01  02  05  07  08  09,
01  02  05  07  08  10,
01  02  05  07  09  10,
01  02  05  08  09  10,
01  02  06  07  08  09,
01  02  06  07  08  10,
01  02  06  07  09  10,
01  02  06  08  09  10,
01  02  07  08  09  10,
01  03  04  05  06  07,
01  03  04  05  06  08,
01  03  04  05  06  09,
01  03  04  05  06  10,
01  03  04  05  07  08,
01  03  04  05  07  09,
01  03  04  05  07  10,
01  03  04  05  08  09,
01  03  04  05  08  10,
01  03  04  05  09  10,
01  03  04  06  07  08,
01  03  04  06  07  09,
01  03  04  06  07  10,
01  03  04  06  08  09,
01  03  04  06  08  10,
01  03  04  06  09  10,
01  03  04  07  08  09,
01  03  04  07  08  10,
01  03  04  07  09  10,
01  03  04  08  09  10,
01  03  05  06  07  08,
01  03  05  06  07  09,
01  03  05  06  07  10,
01  03  05  06  08  09,
01  03  05  06  08  10,
01  03  05  06  09  10,
01  03  05  07  08  09,
01  03  05  07  08  10,
01  03  05  07  09  10,
01  03  05  08  09  10,
01  03  06  07  08  09,
01  03  06  07  08  10,
01  03  06  07  09  10,
01  03  06  08  09  10,
01  03  07  08  09  10,
01  04  05  06  07  08,
01  04  05  06  07  09,
01  04  05  06  07  10,
01  04  05  06  08  09,
01  04  05  06  08  10,
01  04  05  06  09  10,
01  04  05  07  08  09,
01  04  05  07  08  10,
01  04  05  07  09  10,
01  04  05  08  09  10,
01  04  06  07  08  09,
01  04  06  07  08  10,
01  04  06  07  09  10,
01  04  06  08  09  10,
01  04  07  08  09  10,
01  05  06  07  08  09,
01  05  06  07  08  10,
01  05  06  07  09  10,
01  05  06  08  09  10,
01  05  07  08  09  10,
01  06  07  08  09  10,
02  03  04  05  06  07,
02  03  04  05  06  08,
02  03  04  05  06  09,
02  03  04  05  06  10,
02  03  04  05  07  08,
02  03  04  05  07  09,
02  03  04  05  07  10,
02  03  04  05  08  09,
02  03  04  05  08  10,
02  03  04  05  09  10,
02  03  04  06  07  08,
02  03  04  06  07  09,
02  03  04  06  07  10,
02  03  04  06  08  09,
02  03  04  06  08  10,
02  03  04  06  09  10,
02  03  04  07  08  09,
02  03  04  07  08  10,
02  03  04  07  09  10,
02  03  04  08  09  10,
02  03  05  06  07  08,
02  03  05  06  07  09,
02  03  05  06  07  10,
02  03  05  06  08  09,
02  03  05  06  08  10,
02  03  05  06  09  10,
02  03  05  07  08  09,
02  03  05  07  08  10,
02  03  05  07  09  10,
02  03  05  08  09  10,
02  03  06  07  08  09,
02  03  06  07  08  10,
02  03  06  07  09  10,
02  03  06  08  09  10,
02  03  07  08  09  10,
02  04  05  06  07  08,
02  04  05  06  07  09,
02  04  05  06  07  10,
02  04  05  06  08  09,
02  04  05  06  08  10,
02  04  05  06  09  10,
02  04  05  07  08  09,
02  04  05  07  08  10,
02  04  05  07  09  10,
02  04  05  08  09  10,
02  04  06  07  08  09,
02  04  06  07  08  10,
02  04  06  07  09  10,
02  04  06  08  09  10,
02  04  07  08  09  10,
02  05  06  07  08  09,
02  05  06  07  08  10,
02  05  06  07  09  10,
02  05  06  08  09  10,
02  05  07  08  09  10,
02  06  07  08  09  10,
03  04  05  06  07  08,
03  04  05  06  07  09,
03  04  05  06  07  10,
03  04  05  06  08  09,
03  04  05  06  08  10,
03  04  05  06  09  10,
03  04  05  07  08  09,
03  04  05  07  08  10,
03  04  05  07  09  10,
03  04  05  08  09  10,
03  04  06  07  08  09,
03  04  06  07  08  10,
03  04  06  07  09  10,
03  04  06  08  09  10,
03  04  07  08  09  10,
03  05  06  07  08  09,
03  05  06  07  08  10,
03  05  06  07  09  10,
03  05  06  08  09  10,
03  05  07  08  09  10,
03  06  07  08  09  10,
04  05  06  07  08  09,
04  05  06  07  08  10,
04  05  06  07  09  10,
04  05  06  08  09  10,
04  05  07  08  09  10,
04  06  07  08  09  10,
05  06  07  08  09  10,

***********************//*******************

Java code

package br.teste;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LerArquivoTxT {

    ArrayList<String[]> lista = new ArrayList<>();
    ArrayList<String[]> novaLista = new ArrayList<>();

    public void LerArquivo(){

        try {
            FileReader fr = new FileReader("C:/Conteudo/listaIII.txt");
            BufferedReader br = new BufferedReader(fr);
            String temp;

            while ((temp = br.readLine()) != null) { 
                lista.add(temp.split(";"));
                compararLista(lista);

            }
        } catch (FileNotFoundException ex) {
            System.out.println("Arquivo nao encontrado!");
        } catch (IOException ex) {
            Logger.getLogger(LerArquivoTxT.class.getName()).log(Level.SEVERE, null, ex);
        }

        lista.forEach(a -> System.out.println(Arrays.toString(a)));
    }

    // METODO PARA COMPARA OS CONJUNTOS
    public void compararLista(ArrayList<String[]> lista) {        

        for(int i = 0; i < lista.size(); i++) {            
            for(int j = i + 1; j < lista.size(); j++) {
                if(lista.get(i).equals(lista.get(j))){
                    lista.remove(j);
                    j--;                    
                }
            }
        }

    }

    // SALVAR O ARQUIVO EM DISCO
    public void SalvarResumoDaLista(ArrayList<String[]> lista) throws IOException {
        try {

            FileOutputStream arquivo = new FileOutputStream("C:/Conteudo/RESUMO.txt");
            ObjectOutputStream gravador = new ObjectOutputStream(arquivo);
            gravador.writeObject(lista);
            gravador.close();
            arquivo.close();            
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {

        LerArquivoTxT lista = new LerArquivoTxT();
        lista.LerArquivo();

        ArrayList<String[]> lista2 = null;
        try {
            lista.SalvarResumoDaLista(lista2);
        } catch (IOException ex) {
            System.out.println("Conteudo salvo com sucesso!");
        }        
    }
}
    
asked by anonymous 21.03.2018 / 13:52

0 answers