Skip to content

Instantly share code, notes, and snippets.

@santteegt
Last active January 31, 2018 21:03
Show Gist options
  • Save santteegt/39c31e1241b2e69e63b372856347e518 to your computer and use it in GitHub Desktop.
Save santteegt/39c31e1241b2e69e63b372856347e518 to your computer and use it in GitHub Desktop.
ConsultaPopularEcuador2018 using Java8 & lambda programming
import com.sun.javafx.binding.StringFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.stream.IntStream;
/**
* Created by santteegt on 31/01/2018.
*/
public class ConsultaEcuador2018 {
public static void main(String []args) {
List<String> votes = new ArrayList<>(Arrays.asList("?", "?", "?", "?", "?", "?", "?"));
IntStream.range(1, votes.size()+1)
.mapToObj(n -> ((n > 1) && (votes.size()-1) % n == 0 ?
String.format("En la pregunta %d vota NO", n):
String.format("En la pregunta %d vota SI", n))
).forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment