C# method (137137 122 bytes)
Requires using System.Linq
adding 19 bytes, included in the 137122:
bool C(float t,string r){var p=0f;return,float -p>rp=0)=>r.Split('=').Aggregate(t,(f,s)=>f-(s==""?p:p=1/float.Parse(s)));<-p;
Expanded version:
bool Check(float time, string road)
{
, varfloat pacepace=0) ==> 0f;
return -pace > road.Split('=')
.Aggregate(time, (f, s) => f - (
s == ""
? pace
: pace = 1 / float.Parse(s)));
} < -pace;
The road
string is split on the =
character. Depending on whether a string is the resulting array is empty, the aggregate function sets the pace
variable for the segment (denoting the time it takes to travel a single =
) and subtracts it from the time supplied. This will do one too many substractions (for the final road segment), so instead of comparing to 0
, we compare to -pace