Better late than never!
JavaScript (ES6), 98 97 bytes
Saved 1 byte thanks to Neil
Takes the list of guests l
and the party time h
in currying syntax (l)(h)
. Expects a trailing linebreak on the list. Returns a space-separated list of names such as Lisa Bob
.
l=>h=>l.replace(/(.* )(.*)\n/g,(_,a,b)=>(t-=T(b))<0?a:'',t=(T=h=>eval(h.replace(/:/,'*60+')))(h))
Formatted and commented
l => h => // given a list of guests l and a party time h
l.replace( // for each guest in l:
/(.* )(.*)\n/g, // extract the name a and arrival time b
(_, a, b) => // subtract the arrival time from the time counter
(t -= T(b)) < 0 ? // if the result is negative:
a // the guest is late: keep the name
: // else:
'', // the guest is on time: remove this entry
t = ( // initialize the time counter t
T = h => // define T():
eval( // a function that takes either a time
h.replace(/:/, '*60+') // in hh:mm format or an amount of minutes
) // and returns an amount of minutes
)(h) // call it with the party time
) // end of replace()
Demo
let f =
l=>h=>l.replace(/(.* )(.*)\n/g,(_,a,b)=>(t-=T(b))<0?a:'',t=(T=h=>eval(h.replace(/:/,'*60+')))(h))
console.log(f(`Kevin 13:02
Ruby 5
Sam 3
Lisa 6
Bob 12
`)('13:15'))
PHP, 118 98 95 91 bytes
while($n=$argv[++$i])$i&1?$p=$n:($t=($f=strtotime)($n)?:$t+60*$n)<=$f(end($argv))?:print$p;
takes input from command line arguments (you may interprete that as lines separated by spaces if you like); prints names without a delimiter. Run with -r
or test it online.
edit 1: saved 20 bytes with direct printing
edit 2: saved 3 bytes by removing the delimiter
edit 3: saved 4 bytes by exploiting that plain integers are no valid dates for strtotime
breakdown
while($n=$argv[++$i]) # loop through arguments, skip [0]
$i&1 # if index is odd
? $p=$n # then assign name to $p
: ($t= # else $t =
($f=strtotime)($n) # if $n is a valid time, parse it
?:$t+60*$n # else add $n minutes to current $t
)<=$f(end($argv)) # if $t <= parsed party start
? # then do nothing
:print$p; # else print name
c, 178 bytes
main(c,o,d,e,g,O,l,f,x,y)char**o,d[80],*O,*l,*f;{for(sscanf(o[2],"%d:%d",&e,&g),x=e*60+g,l=";",f=o[1];O=strtok(f,l);f=0)(y=sscanf(O,"%s%d:%d",d,&e,&g)^2?e*60+g:y+e)>x?puts(d):0;}
Try it online