← 返回 stripe 的题目列表Dataset Validation Problem
类型:online_judge
Dataset Validation Problem
You are given a string representing a CSV dataset. Each line contains 6 columns:
col1, col2, col3, col4, col5, col6
Your task is to process each row (excluding the header), and determine whether the row is VERIFIED or NOT VERIFIED based on the following rules.
Rules for a row to be considered VERIFIED:
No Empty Fields:
All 6 fields must be present and non-empty.
Fields with only whitespace count as empty.
Column 5 Length Constraint:
The length of col5 (after stripping whitespace) must be between 5 and 31 characters (inclusive).
Forbidden Words in col2:
col2 must NOT contain any of the following forbidden words (case-insensitive):
"company", "firm", "co.", "corporation", "group"
col2 Word Match with col4 or col5:
Split col2, col4, and col5 into lowercase words by whitespace.
Remove the words "LLC" and "Inc" from comparison.
col2 must share at least 50% of its words with either col4 or col5.
Word match is case-insensitive and based on string equality.
Input:
A single multi-line string in CSV format. For example:
data = '''
col1,col2,col3,col4,col5,col6
a,land water,c,d,land water LLC,f
a,Good Company,c,d,land water,f
a,b,c,d,e,f
1,2,3,,5,6
'''
Output:
For each row (excluding the header), print one line in the format:
`VERIFIED: <col2_value>`
or
`NOT VERIFIED: <col2_value>`
Output lines should maintain the order of rows in the input.
Example Output:
VERIFIED: land water
NOT VERIFIED: Good Company
NOT VERIFIED: b
NOT VERIFIED: 2
Explanation:
Row 1: Passes all checks → VERIFIED
Row 2: col2 contains forbidden word "Company" → NOT VERIFIED
Row 3: col5 is too short (only 1 character) → NOT VERIFIED
Row 4: col4 is empty → NOT VERIFIED
Example
Input
col1,col2,col3,col4,col5,col6
a,land water,c,d,land water LLC,f
a,Good Company,c,d,land water,f
a,b,c,d,e,f
1,2,3,,5,6