問題文
function solution(rules, requests)を書いてください。入出力はJSON値です。入力配列やオブジェクトを変更しないでください。外部ライブラリ・ネットワーク・非同期関数は使えません。 rules:{effect,subject,action,resource}[]; requests:{subject,action,resource}[]. A rule matches when each field is '*' or an exact case-sensitive match. Any matching 'deny' overrides every allow. Otherwise allow if a matching 'allow' exists, deny by default. Ignore other effects. Rule order does not matter. Return booleans in request order. 入力範囲:各入力配列は最大50,000項目、文字列は最大1,000文字です。数値は有限値で、整数と整数の合算結果はJavaScriptの安全な整数範囲内です。その他の型と有効性は上記の規則に従います。
入出力例
例 1
関数の引数
[
[
{
"effect": "allow",
"subject": "alice",
"action": "*",
"resource": "*"
}
],
[
{
"subject": "alice",
"action": "read",
"resource": "file"
},
{
"subject": "bob",
"action": "read",
"resource": "file"
}
]
]戻り値
[ true, false ]
例 2
関数の引数
[
[
{
"effect": "allow",
"subject": "*",
"action": "*",
"resource": "*"
},
{
"effect": "deny",
"subject": "alice",
"action": "*",
"resource": "*"
}
],
[
{
"subject": "alice",
"action": "read",
"resource": "file"
},
{
"subject": "bob",
"action": "read",
"resource": "file"
}
]
]戻り値
[ false, true ]
例 3
関数の引数
[
[
{
"effect": "deny",
"subject": "bob",
"action": "*",
"resource": "*"
},
{
"effect": "allow",
"subject": "*",
"action": "*",
"resource": "*"
}
],
[
{
"subject": "alice",
"action": "read",
"resource": "file"
}
]
]戻り値
[ true ]