This question evaluates proficiency in parsing and filtering structured data by interpreting Unix-like permission strings and extracting filenames based on permission semantics.
You are given a list of file metadata records. Each record contains:
owner
(string): the username who owns the file
permission
(string): a Unix-like permission string of length 9, representing
owner/group/others
permissions in order, e.g.
rwxr-xr--
filename
(string)
A file is considered read-only if no user category has write permission, i.e., the permission string contains no w character anywhere.
Return the list of filenames that are read-only.
{ owner, permission, filename }
.
permission
is always exactly 9 characters and consists only of
r
,
w
,
x
, and
-
.
Input records:
{owner: "alice", permission: "r--r--r--", filename: "a.txt"}
{owner: "bob", permission: "rw-r--r--", filename: "b.txt"}
{owner: "carl", permission: "r-xr-xr-x", filename: "c.sh"}
Output:
["a.txt", "c.sh"]