At work I've been acting as quality control on our public documents, to make sure that they are WCAG 2.0 compliant. Given the length of some of these documents there tend to be issues, and so I record the issues and the pages they occur on.
The challenge: Given a string input, output a count of all distinct pages within the string.
Rules:
- Input will consist of of a non-empty string containing the pages, page ranges, and the issue. Multiple pages and page ranges are guaranteed to be separated by commas
,
.
pgs 810-812, 897, 1043, 1047, 1219, 1308, 1317, 1323 restructure reading boxes
pgs 810-812,897,1043, 1047,1219, 1308, 1317, 1323 restructure reading boxes
Both of the above are possible valid inputs.
- This input can be multiple lines, with each line representing a different issue.
pgs 810-812, 897, 1043, 1047, 1219, 1308, 1317, 1323 restructure reading boxes
pgs 816, 819, 826, 827, 829, 853, 861, 866, 885, 1043, 1142, 1143, 1164 table needs to be read as table or figure
You can take a multiline input as a list of strings, with each item in the list being a line. The output is still based on the entirety of the list.
The input format is not necessarily
pgs <page numbers> <issue>
.Both
pg 1324 read all
andRead all
are valid inputs.If the string consists of only
<Issue>
, this represents that the document is a single page, and thus the output would be1
(no matter how many lines of input there are). If there is more than one page, you are guaranteed to not have this format as a line of the input.
Test Cases:
Input:
------
pgs 810-812, 897, 1043, 1047, 1219, 1308, 1317, 1323 restructure reading boxes
Output:
-------
10
Input:
------
pgs 587,897, 936, 939,946, 1308 single figure
pgs 810-812, 897, 1043, 1047, 1219,1308,1317, 1323 restructure reading boxes
Output:
-------
14
Input:
------
pgs 824, 873, 941-943, 1032, 1034, 1036-1040, 1055, 1071, 1153, 1154, 1228 figures as figures
pgs 1036-1040 Color Contrast for negative balance numbers does not meet WGAC 2.0 guidelines
pg 1324 read all
Output:
-------
18
Input:
------
Incorrect Reading Order
Output:
-------
1
Input:
------
Incorrect Reading Order
Pg 1 Read Table as Table
Pgs 1 Color Contrast for negative balance numbers does not meet WGAC 2.0 guidelines
Output:
-------
1
This is code-golf, so shortest answer in bytes wins.
a,b-c,d
; adding acount unique
and removing the other characters does not, in my estimation, make it different enough, but the community is welcome to override that. \$\endgroup\$