Skip to main content
Code Review

Return to Question

added 87 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Desired Feedback

The input is read in line by line from stdin.

Input Format

The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the input for each test case is as follows:

The first line contains an integer, N, the number of (x,y) pairs in the test case. The N subsequent lines each contain two space-separated integers describing the respective x and y values for each ordered pair.

Constraints

  • \1ドル \le T \le 5\$
  • \2ドル \le N \le 100\$
  • \0ドル \le x, y \le 500\$

x and y are both integers.

Output Format

On a new line for each test case, print YES if the set of ordered pairs represent a valid function, or NO if they do not.

Sample Input

2 
3 
1 1 
2 2 
3 3 
4 
1 2 
2 4 
3 6 
4 8 

Sample Output

YES 
YES

Full problem statement

I'm looking for feedback regarding ways this could be: more concise/clean, more idiomatic Haskell, or if there are algorithmic/mathematical tricks I missed that could further simplify the computation.

Problem Description

The input is read in line by line from stdin.

Input Format

The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the input for each test case is as follows:

The first line contains an integer, N, the number of (x,y) pairs in the test case. The N subsequent lines each contain two space-separated integers describing the respective x and y values for each ordered pair.

Constraints

1 ≤ T ≤ 5

2 ≤ N ≤ 100

0 ≤ x, y ≤ 500

x and y are both integers.

Output Format

On a new line for each test case, print YES if the set of ordered pairs represent a valid function, or NO if they do not.

Sample Input

2
3
1 1
2 2
3 3
4
1 2
2 4
3 6
4 8

Sample Output

YES
YES

Full problem statement: https://www.hackerrank.com/contests/lambda-calculi-march-2016/challenges/functions-or-not

Code

Desired Feedback

I'm looking for feedback regarding ways this could be: more concise/clean, more idiomatic Haskell, or if there are algorithmic/mathematical tricks I missed that could further simplify the computation.

Problem Description

The input is read in line by line from stdin.

Input Format

The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the input for each test case is as follows:

The first line contains an integer, N, the number of (x,y) pairs in the test case. The N subsequent lines each contain two space-separated integers describing the respective x and y values for each ordered pair.

Constraints

1 ≤ T ≤ 5

2 ≤ N ≤ 100

0 ≤ x, y ≤ 500

x and y are both integers.

Output Format

On a new line for each test case, print YES if the set of ordered pairs represent a valid function, or NO if they do not.

Sample Input

2
3
1 1
2 2
3 3
4
1 2
2 4
3 6
4 8

Sample Output

YES
YES

Full problem statement: https://www.hackerrank.com/contests/lambda-calculi-march-2016/challenges/functions-or-not

Code

The input is read in line by line from stdin.

Input Format

The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the input for each test case is as follows:

The first line contains an integer, N, the number of (x,y) pairs in the test case. The N subsequent lines each contain two space-separated integers describing the respective x and y values for each ordered pair.

Constraints

  • \1ドル \le T \le 5\$
  • \2ドル \le N \le 100\$
  • \0ドル \le x, y \le 500\$

x and y are both integers.

Output Format

On a new line for each test case, print YES if the set of ordered pairs represent a valid function, or NO if they do not.

Sample Input

2 
3 
1 1 
2 2 
3 3 
4 
1 2 
2 4 
3 6 
4 8 

Sample Output

YES 
YES

Full problem statement

I'm looking for feedback regarding ways this could be: more concise/clean, more idiomatic Haskell, or if there are algorithmic/mathematical tricks I missed that could further simplify the computation.

deleted 33 characters in body
Source Link
Der Kommissar
  • 20.2k
  • 4
  • 70
  • 158

1 ≤ T ≤ 51 ≤ T ≤ 5

2 ≤ 2 ≤ N ≤ 100 ≤ 100

0 ≤ x, y ≤ 5000 ≤ x, y ≤ 500

1 ≤ T ≤ 51 ≤ T ≤ 5

2 ≤ 2 ≤ N ≤ 100 ≤ 100

0 ≤ x, y ≤ 5000 ≤ x, y ≤ 500

1 ≤ T ≤ 5

2 ≤ N ≤ 100

0 ≤ x, y ≤ 500

added 4 characters in body
Source Link
Josiah
  • 391
  • 2
  • 13
Source Link
Josiah
  • 391
  • 2
  • 13
Loading
lang-hs

AltStyle によって変換されたページ (->オリジナル) /