Problem Statement
A description of the problem can be found on Hackerrank.
Solution
Minimum result if always greater then a given count of pairs.
I created solution in:
All solutions are also available on my GitHub.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import java.util.*; public class MinimumDraws { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int tests = stdin.nextInt(); for(int i = 0; i < tests; i++) { System.out.println(stdin.nextInt() + 1); } stdin.close(); } } |
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 |
'use strict'; const processData = input => { console.log(input.split('\n').slice(1).map(i => parseInt(i) + 1).join('\n')); }; process.stdin.resume(); process.stdin.setEncoding("ascii"); var _input = ""; process.stdin.on("data", input => _input += input); process.stdin.on("end", () => processData(_input)); |
Scala
1 2 3 4 5 6 7 8 |
import scala.io.Source object MinimumDraws extends App { val lines = Source.stdin.getLines() val pairs = lines.drop(1).map(_.toInt) val draws = pairs.map(_ + 1) println(draws.mkString("\n")) } |
Ruby
1 2 3 4 5 6 |
tests = gets.chomp.to_i tests.times do pairs = gets.chomp.to_i result = pairs + 1 puts result end |