Condense these page numbers!
C++11, 451 * 80% * 75% * 50% = 135.3 bytes
Saved 9 bytes thanks to @kirbyfan64sos.
Saved 19 bytes thanks to @JosephMalle and @cat.
Saved 11 bytes thanks to @pinkfloydx33.
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#define T string
#define P append
using namespace std;T f(vector<int>v){sort(v.begin(),v.end());T r=to_T(v[0]);int b=1;int m=v[0];for(int i=1;i<=v.size();i++){if(i!=v.size()&&v[i]==v[i-1]+1){if(!b){m=v[i-1];}b=1;}else{if(b){T s=to_T(v[i-1]);r.P("-").P(s.substr(s.size()-(v[i-1]-m==1?1:log10(v[i-1]-m)),s.size()));}if(i!=v.size()){r.P(", ").P(to_T(v[i]));}b=0;}}return r;}
This qualifies for all the bonuses.
Sample parameter test and result:
In: [1, 2, 3, 4, 5]
Out: 1-5
In: [3, 4, 5, 9, 10, 11, 12]
Out: 3-5, 9-12
In: [149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160]
Out: 149-60
In: [1, 2, 3, 4]
Out: 1-4
In: [109, 110, 111, 112, 113]
Out: 109-3
In: [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
Out: 19-9
Ruby, 120 118 * 0.8 * 0.75 * 0.5 = 35.4 bytes
Takes command-line arguments as input (commas are okay); prints one range per line to standard output.
c=(b=(a=$*.map(&:to_i).sort).map &:succ)-a
puts (a-b).map{|m|(m<n=c.shift-1)?"#{m}-#{m<0?n:n%10**"#{n-m-1}".size}":m}
With whitespace/comments:
c=(
b=(
# a is the sorted input
a=$*.map(&:to_i).sort
# b is the set of successors of elements of a
).map &:succ
# c=b-a is the set of not-quite-least upper bounds of our ranges
)-a
# a-b is the set of greatest lower bounds of our ranges
puts (a-b).map {|m|
# for each range [m,n], if there are multiple elements
(m < n = c.shift-1) ?
# yield the range, abbreviating n appropriately if positive
"#{m}-#{m<0 ? n : n % 10 ** "#{n-m-1}".size}" :
# in the one-element case, just yield that
m
}
Test cases
$ ruby homework.rb 1, 2, 3, 4, 5
1-5
$ ruby homework.rb 3, 4, 5, 9, 10, 11, 12
3-5
9-2
$ ruby homework.rb 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160
149-60
$ ruby homework.rb 1 2 3 4
1-4
$ ruby homework.rb 109, 110, 111, 112, 113
109-3
$ ruby homework.rb 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
19-9
Features not covered by test cases
Unordered input & single-element ranges:
$ ruby homework.rb 2 17 19 22 0 1 8 20 18
0-2
8
17-0
22
Negative ranges (not possible to abbreviate the larger number with these):
$ ruby homework.rb -17 -18 -19 -20 -21
-21--17
Abbreviation of arbitrary numbers of digits (ordinary bash expansion used for the input here):
$ ruby homework.rb {1234567..1235467} 2345999 2346000 2346001
1234567-467
2345999-1
Javascript ES6, 229 * 80% * 75% * 50% = 68.7 bytes
Test Input
I'm using the following test data:
var A1=[
5,6,7, // => 5-7 # (a) group pages
2,3, // => 2-3,5-7 # (b) must be properly sorted
-9,-8,-7, // => -10--8 # (c) allow negative numbers
29,30,31,32, // => 29-2 # (d) lower last digit implies increasing the 10s place
9,10,11,12, // => 9-11 # NOT 9-2
36,37,38,39,40,41,42,43,44,45,46,47,
// => 36-47 # NOT 36-7
99,100,101,102, // => 99-102 # NOT 99-2
109,110,111,112, // => 109-2 # NOT 109-12
],
// more tests, not specified in the question
A2=[
120,124, // => 120,124 # (e) handle single pages
],
A3=[
135,136,135 // => 135-6 # (f) handle duplicates
];
Basic: 229 bytes
This version satisfies the requirements of the question (a) with all bonuses (c,d,e), but hangs on single pages. It can also handle duplicates(f). It handles negative pages down to -10,000, which can be easily increased with (large) loss of speed.
F=(a)=>{var R=[],i=NaN,l,u;a.map(x=>R[1e4+x]=x);R.concat('').map(x=>(i!=i&&(l=x,u=l-1),i=0,u=(x+="")-u-1?l=console.log(l+'-'+(u>0?(l.length-u.length||(z=>{for(;l[i]==u[i];i++);})(),u.length-i-2||u-l>9||i++,u.slice(i)):u))||x:x))}
F(A1.concat(A3)) --> -9--7 2-3 5-7 9-12 29-2 36-47 99-102 109-2 135-136
(The output above shows spaces instead of actual newlines for brevity)
Single pages: 233 bytes
This slightly longer version additionally satisfies (e) and displays single pages as a range with equal lower and upper limits
G=(a)=>{var R=[],i=NaN,l,u;a.map(x=>R[1e4+x]=x);R.concat('').map(x=>(i!=i&&(l=x,u=l-1),i=0,u=(x+="")-u-1?l=console.log(l+'-'+(u-l&u>0?(l.length-u.length||(z=>{for(;l[i]==u[i];i++);})(),u.length-i-2||u-l>9||i++,u.slice(i)):u))||x:x))}
G(A1.concat(A2,A3)) --> -9--7 2-3 5-7 9-12 29-2 36-47 99-102 109-2 120-120 124-124