絶対に遅れるよりはましです!


12

あなたのプログラム/機能などは2つの入力を取ります。最初は、私のパーティーに誰がいつ来たかのリストです。例:

Kevin 13:02  
Ruby 5  
Sam 3  
Lisa 6  
Bob 12  

どういう意味ですか?つまり、ケビンは最初に(13:02、24時間で)私のパーティーに到着し、5分後にルビー、3分後にサム、6分後にリサ、12分後に最後のボブに到着しました。

2番目の入力は、パーティーの開始時です。例:

13:15

(24時間)。出力は、遅れた人のリストでなければなりません(正確に時間通りに誰でも結構です。)計算例(例えば、これらを出力しないでください)

Kevin 13:02
Ruby 13:07
Sam 13:10
Lisa 13:16
Bob 13:28

リサとボブは後13:15に到着したので、このプログラムは「リサ、ボブ」と印刷する必要があります。

入力の前提

  • 入力1は常に名前(正規表現 [A-Z][a-z]*)、スペース、24時間形式の形式になりますhours:minutes最初の行のでは、次の行では名前、スペース、正の整数(分数)になります。 。常に少なくとも1行あります。
  • 必要に応じて、改行ではなく他の文字で入力1を使用できます。
  • 入力2は次の形式になります hours:minutes
  • 必要に応じて、任意の文字で区切られた1つの文字列として入力を受け取ることができます。これはオプションです。
  • 日のクロスオーバーを心配しないでください。私のパーティーは二度としない23:59

出力ルール

  • 出力は、関数の戻り値またはSTDINやファイルなどにエコーされる文字列です。文字列または配列/リストを返す必要があります。
    • 文字列を返す場合、それは、英数字以外の区切り文字で区切られた、遅れた各人でなければなりません(順序は関係ありません)。
    • 配列/リストを返す場合、遅れた全員のリストでなければなりません。

2
厳密な入力形式は必要ですか?たとえば、最初の入力はリストのリストで、各リストは2つのデータ項目を含む「行」になりますか?
ジョナサンアラン

「入力1は常に名前になります(regex [A-Z][a-z]*)」これは、名前が空であることを示唆していますか?
ハイパーニュートリノ

2
「はい、厳密な入力形式が必要です」という意味だったと思います。
ジョナサンアラン

2
厳密な入力形式により、この課題はそれほど面白くなりません
ルイスMendo

3
「私のパーティーは11:59以降になることはありません。」という意味23:59ですか?
tsh

回答:


3

MATL、31バイト

jYb1L&)1&)XUYs1440/0whwYO+jYO>)

最初の入力では、改行の代わりにスペースが使用されます(チャレンジで許可されます)。

出力では、区切り文字として改行が使用されます。

オンラインでお試しください!

説明

j       % Input first string
Yb      % Split at spaces. Gives cell array of strings
1L&)    % Separate into subarrays with odd and even indices. Odd are names, even
        % are time and increments in minutes
1&)     % Separate the subarray of even indices into first entry and remaining
        % entries. The first is a string representing the time of first arrival,
        % the rest are strings representing increments in minutes
XU      % Convert strings representing increments into the actual numbers
Ys      % Cumulative sum
1440/   % Divide by 1440 (number of minutes in a day)
0wh     % Prepend a 0
w       % Swap. Bring the string with time of first arrival to the top
YO      % Convert to serial date number. Fractional part indicates time
+       % Add. This gives all arrivals as serial date numbers
j       % Input second string
YO      % Convert to serial date number
>       % Less than?, element-wise
)       % Index: select the names for which the comparison gave true
        % Implicitly display

6

JavaScript(ES6)、98 97バイト

ニールのおかげで1バイト節約

構文をカリー化するlhに、ゲストのリストとパーティーの時間を取ります(l)(h)。リストの末尾に改行が必要です。などの名前のスペース区切りリストを返しますLisa Bob

l=>h=>l.replace(/(.* )(.*)\n/g,(_,a,b)=>(t-=T(b))<0?a:'',t=(T=h=>eval(h.replace(/:/,'*60+')))(h))

フォーマットおよびコメント

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()

デモ

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'))


賢い解決策!+1。は遠い....... :(
Arjun

動作しません(.*) (.*)\nか?
ニール

@Neilデフォルトでは貪欲なので、最初の(.*)行は行全体に一致します。
アーナルド

次に、スペースは何に一致しますか?
ニール

@ニールああ、ごめん、あなたは正しい。
アーナルド

6

PHP、118 98 95 91バイト

while($n=$argv[++$i])$i&1?$p=$n:($t=($f=strtotime)($n)?:$t+60*$n)<=$f(end($argv))?:print$p;

コマンドライン引数から入力を受け取ります(必要に応じて、スペースで区切られた行として解釈できます)。区切り文字なしで名前を出力します。-rまたはで実行オンラインで、オンラインでテストします

編集1:ダイレクト印刷で20バイトを保存
編集2:区切り文字を削除して3バイトを保存
編集3:プレーン整数が有効な日付ではないことを利用して4バイトを保存strtotime

壊す

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


5

JavaScript ES6、185バイト

l=>t=>l.split`
`.map(p=>p.split` `).map((p,i,a)=>[p[0],i?d(a[0][1])+a.slice(1,i+1).reduce((a,p)=>a+=+p[1],0)*6e4:(d=x=>Date.parse(`2017T${x}`))(p[1])]).filter(p=>p[1]>d(t)).map(p=>p[0])

オンラインでお試しください!

const f = l=>t=>l.split`
`.map(p=>p.split` `).map((p,i,a)=>[p[0],i?d(a[0][1])+a.slice(1,i+1).reduce((a,p)=>a+=+p[1],0)*6e4:(d=x=>Date.parse(`2017T${x}`))(p[1])]).filter(p=>p[1]>d(t)).map(p=>p[0])


console.log(f('Kevin 13:02\nRuby 5\nSam 3\nLisa 6\nBob 12')('13:15'))


仕様からわかる限り、入力フォームはより厳密かもしれません。
ジョナサンアラン

今は正しいと思います。
-powelles

うん-入力の厳密さについても質問しました。
ジョナサンアラン

...実際には、入力に時間があるはずであり、オフセットではないはずですf('Kevin 13:02\nRuby 5\nSam 3...
ジョナサンアラン

1
@JonathanAllanありがとう。今手に入れた。
powelles

4

PowerShellの215の 196 180バイト

param($a,$b)$x,[array]$a=$a-split',';$z=@{};$i,$j=-split$x;$z[$i]=($y=date $j);0..($a.count-1)|%{$i,$j=-split$a[$_];$z[$i]=($y=$y|% *es $j)};($z|% *or|?{$_.value-gt(date $b)}).Name

オンラインでお試しください!

この約3分の1は入力の解析であるため、さらにどれだけゴルフを進めることができるかわかりません。

入力を受け取り、$a名前と回/分のカンマ区切りの文字列として、及び$bとしてhh:mm文字列として。まず、私たち-split $aには,、最初に結果を格納$xし、へ、残り$aの明示的な再キャストで、$aなどarray(SOループが後で正しく動作していること)。私たちは私たちのハッシュテーブルの初期化$z、設定を$iして$jあることを$x -split空白にし、設定$z[$i]するdateのを$j(に保存された$y後に使用するため)。

次に、残りのをループします$a。繰り返しごとに、同様のことを行います- -splitホワイトスペースの文字列$zは、現在の位置をはるかに超える分になるように適切なインデックスを設定します。これは、の代わりにを使用して、短いプロパティ名のトリックを使用していくつかのバイトを節約します。|% *es $j.AddMinutes($j)

最後に、.GetEnumerator()ハッシュテーブルの(ここでもトリックを使用して)私たちは、Where-Objectでこれらのエントリを選択しvalueますその-greater t$b(すなわち、彼らはパーティーに遅れています)。次に、そのを選択します.Name。出力は暗黙の配列としてであり、デフォルトではWrite-Outputその間に改行が挿入されます。

[配列]が物であることを思い出させてくれたブリアンティストに感謝します。そして、短縮されたプロパティ名のヒントのための束。


私は、この最小限の読み込みとテストをした認める、しかし、あなたはできなかっただけでやりますか$x,[array]$a=$a-split','
-briantist

1
@briantistはい、ありがとう。複数の割り当てでコンマ演算子を使用する方法を探し続けましたが、うまくいきませんでした。私はそれ[array]が有効なキャストであることを完全に忘れていました。ハハ。ゴルフが多すぎると思う。
AdmBorkBork

私はモバイルですので、テストするのは難しいでしょうが、メソッド構文の良い候補だGetEnumeratorと思いますAddMinutes%
-briantist

@briantistうん。さらに16を保存します。ありがとう!
AdmBorkBork

4

パイソン2140148、 144のバイト

t,h,n=map(str.split,input().replace(':','').split(';')),100,0
for a,v in t[:-1]:
 n+=int(v)
 if n%h/60:n=n/h*h+n%h%60+h
 if`n`>t[-1][0]:print a,

オンラインでお試しください!

入力フォーマット:

'Kevin 13:02;Ruby 5;Sam 3;Lisa 6;Bob 12;13:15'

微小なオーバーフローを正しく処理しません'Kevin 13:47;Ruby 5;Sam 3;Lisa 6;Bob 12;14:00'。リサとボブはまだ遅れていますが、何も印刷しません。
L3viathan

1
そうそう。グリッチがありました!それを修正しました。ありがとうございます!
Keerthana Prabhakaran


3

CJam、66 54 58 54 51 49 46バイト

{{':/60b}:K~)rSrKs++q+S/2/z~:i[{1$+}*]2$+$@#>}

入力1はSTDINを介して与えられ、入力2はスタック上の文字列として与えられます。出力はスタック上の配列です。入力1の区切り文字はスペースです。たとえば、Kevin 13:02 Ruby 5 Sam 3 Lisa 6 Bob 12です。

スタックトレース:

         e# Stack:               | "13:15"
{        e# Define K and run it:
  ':/    e#   Split on colon:    | ["13" "15"]
  60b    e#   From base 60:      | 795
}:K~     e# End def
)        e# Increment:           | 796
r        e# Read token:          | 796 "Kevin"
S        e# Push space:          | 796 "Kevin" " "
r        e# Read another token:  | 796 "Kevin" " " "13:02"
K        e# K()                  | 796 "Kevin" " " 782
s        e# Convert to string:   | 796 "Kevin" " " "782"
++       e# Add together:        | 796 "Kevin 782"
q        e# Read rest of input:  | 796 "Kevin 782" " Ruby 5 Sam 3 Lisa 6 Bob 12"
+        e# Add together:        | 796 "Kevin 782 Ruby 5 Sam 3 Lisa 6 Bob 12"
S/       e# Split on spaces:     | 796 ["Kevin" "782" "Ruby" "5" "Sam" "3" "Lisa" "6" "Bob" "12"]
2/       e# Group by 2:          | 796 [["Kevin" "782"] ["Ruby" "5"] ["Sam" "3"] ["Lisa" "6"] ["Bob" "12"]]
z        e# Transpose:           | 796 [["Kevin" "Ruby" "Sam" "Lisa" "Bob"] ["782" "5" "3" "6" "12"]]
~        e# Unpack:              | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] ["782" "5" "3" "6" "12"]
:i       e# Convert all to int:  | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] [782 5 3 6 12]
[{1$+}*] e# Accumulate:          | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] [782 787 790 796 808]
2$       e# Copy back element:   | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] [782 787 790 796 808] 796
+        e# Add into array:      | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] [782 787 790 796 808 796]
$        e# Sort:                | 796 ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] [782 787 790 796 796 808]
#        e# Find index:          | ["Kevin" "Ruby" "Sam" "Lisa" "Bob"] 3
>        e# Slice:               | ["Lisa" "Bob"]

説明:

  • プロシージャKは、時刻hh:mmと深夜0時からの経過時間を表す数値との間で変換します。
  • 最初の人を読み、彼らの時間をK(彼らの時間)に置き換えます。次に、これを入力の前に追加します。
  • 次に、いくつかの文字列操作を実行して、名前のリストと時間のリストを取得します。 [782 5 3 6 12]
  • このリストを蓄積することにより、 [782 787 790 796 808]、が得。これは、誰もが来た時間を示します。
  • 誰が遅れているかを見つける最も簡単な方法は、開始時刻を配列に挿入してから、並べ替えて、あるべき場所に配置することです。次に、インデックスを見つけて配置場所を特定し、そのインデックスから名前のリストをスライスします。

2

JavaScript、 285 283バイト

構文をカリー化するipに、ゲストのリストとパーティーの時間を取ります(i)(p)。などの名前のコンマ区切りリストを返しますLisa,Bob

i=>p=>{n=i.split`
`,a=new Date(0,0,0,...n[0].split` `[1].split`:`),y=new Date(0,0,0,...p.split`:`),t=[a];w=a;n.slice(1).map((j,k,l)=>{h=l[k].split` `[1]*6e4;t.push(new Date(w.getTime()+h));w=new Date(w.getTime()+h)});return n.filter((j,k,l)=>t[k]>y).map(j=>j.split` `[0]).join()}

私はそれがかなり長く、現在のところかなりのマージンで最後の場所にあることを知っていますが、それは私が思い付くことができるものです。

f=i=>p=>{n=i.split`
`,a=new Date(0,0,0,...n[0].split` `[1].split`:`),y=new Date(0,0,0,...p.split`:`),t=[a];w=a;n.slice(1).map((j,k,l)=>{h=l[k].split` `[1]*6e4;t.push(new Date(w.getTime()+h));w=new Date(w.getTime()+h)});return n.filter((j,k,l)=>t[k]>y).map(j=>j.split` `[0]).join()}

console.log(f(`Kevin 13:02
Ruby 5
Sam 3
Lisa 6
Bob 12
`)('13:15'))


2

C#269 267バイト


ゴルフ

(l,t)=>{var h=System.DateTime.MinValue;var s=System.DateTime.ParseExact(t,"HH:mm",null);var o="";foreach(var p in l.Split('\n')){var i=p.Split(' ');h=h.Ticks<1?System.DateTime.ParseExact(i[1],"HH:mm",null):h.AddMinutes(int.Parse(i[1]));if(h>s)o+=i[0]+" ";}return o;};

非ゴルフ

( l, t ) => {
   var h = System.DateTime.MinValue;
   var s = System.DateTime.ParseExact( t, "HH:mm", null );
   var o = "";

   foreach( var p in l.Split( '\n' ) ) {
      var i = p.Split( ' ' );

      h = h.Ticks < 1
         ? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )
         : h.AddMinutes( int.Parse( i[ 1 ] ) );

      if( h > s )
         o += i[ 0 ] + " ";
   }

   return o;
};

読めないゴルフ

( l, t ) => {
   // var to check the time of arrival
   var h = System.DateTime.MinValue;

   // var to store the start time of the party
   var s = System.DateTime.ParseExact( t, "HH:mm", null );

   // var with the names of those who arrived late
   var o = "";

   // Cycle through which line
   foreach( var p in l.Split( '\n' ) ) {
      // Split the name and time
      var i = p.Split( ' ' );

      // Check if the time of arrival still has the initial value
      h = h.Ticks < 1

         // If so, grab the time of the first person
         //   Expects to have a time format of 'hh:mm'
         ? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )

         // Otherwise, add the difference to the var
         : h.AddMinutes( int.Parse( i[ 1 ] ) );

      // Check if the current time is later than the party start time
      if( h > s )

         // If so, add the name to the list
         o += i[ 0 ] + " ";
   }

   // Return the names of the persons who arrived late
   return o;
};

完全なコード

using System;
using System.Collections.Generic;

namespace Namespace {
   class Program {
      static void Main( String[] args ) {
         Func<String, String, String> f = ( l, t ) => {
            var h = System.DateTime.MinValue;
            var s = System.DateTime.ParseExact( t, "HH:mm", null );
            var o = "";

            foreach( var p in l.Split( '\n' ) ) {
               var i = p.Split( ' ' );

               h = h.Ticks < 1
                  ? System.DateTime.ParseExact( i[ 1 ], "HH:mm", null )
                  : h.AddMinutes( int.Parse( i[ 1 ] ) );

               if( h > s )
                  o += i[ 0 ] + " ";
            }

            return o;
         };

         List<KeyValuePair<String, String>>
            testCases = new List<KeyValuePair<String, String>> {
               new KeyValuePair<String, String>(
                  "Kevin 13:02\nRuby 5\nSam 3\nLisa 6\nBob 12",
                  "13:15"
               ),
               new KeyValuePair<String, String>(
                  "Kevin 13:15\nRuby 5\nSam 3\nLisa 6\nBob 12",
                  "13:15"
               ),
            };

         foreach( KeyValuePair<String, String> testCase in testCases ) {
            Console.WriteLine( $" Input:\n{testCase.Key}\n\n{testCase.Value}\n\nOutput:\n{f( testCase.Key, testCase.Value )}\n" );
         }

         Console.ReadLine();
      }
   }
}

リリース

  • V1.1 - - 2 bytes-おかげVisualMelon
  • v1.0の - 269 bytes-初期ソリューション。

ノート

  • 出力形式:名前をスペースで区切って出力します

using D=System.DateTime;ディレクティブを追加することで、数バイトを節約できます(vars を置き換えることを忘れないでください!)。このコードを完全に明確にするために、ラムダパラメータの型を実際に提供する必要があります(つまり(string l,string f))。また、「(正確に時間通りに誰でも結構です。」)のように(1バイトの節約!)h>sではなく、わずかなバグがあると思いますh>=s。できますかh.Ticks<1?nullable DateTimeはを使用するよりも安くなるかもしれDateTime.Minませんが、ここでは完全な意味を確認していません。using句を使用すると、機能する==D.Minはずです。
VisualMelon

使用については、それでラムダ式を引き出すことができるとは思わない。mid-codeに追加できないと確信しています明示的なラムダ型は、他の人がそれをしているのを見たことがない別のことであり、私はそれで行った-それが違法である場合、そう言うが、MODでさえ何も言っていない、多分それは大丈夫ですか?h>s私はそれをします。h.Ticks<1これも。
auhmaan

私たちが許可しているusingsと確信していますし、ラムダなどでは、メタでこれを明示的に言っているものは見つかりませんが、この質問はそれが許可されていることを強く示唆しています。明示的なパラメーターの種類が必要であるという合理的なコンセンサスがあります(私はしっかりと支持していることを付け加えるべきです)。ちなみに、MODはPPCGの独自のルールを強制するのではなく、物事をSEの観点から守るためのものです。
VisualMelon

私は反対ちょっとねusings、多分2つのブロックに1つずつ追加すること-それゆえ私は、私は解決策としての機能をやってのける可能性を疑うことを言って、私はそれは完全なコードが必要になることを感じるだろう主な理由は、usingsおよびのために別のものをラムダ関数?コンセンサスについてはFunc<...> f = ...;、完全な名前を指定する必要がありますSystem.Func<...> f = ...;
-auhmaan

string sラムダとusingを混在させたくない場合は、適切な名前の関数(C#7(6?私は覚えていない)構文でのみ追加)を使用する方が良いかもしれません。
VisualMelon

2

CJam43 41バイト

q~':/60b:Y;Sf/()':/60b+a\+{)iT+:TY>{;}|}%

オンラインでお試しください!

説明

q~        e# Read and eval all input.

':/       e# Split the start time on colons.
60b       e# Convert the result from base 60, to get the start time in minutes.
:Y;       e# Store this time in variable Y, and discard it from the stack.

Sf/       e# Split each string in the guest list on spaces.
(         e# Pull out the first guest from the list.
)         e# Pull out the time from the guest.
':/60b+   e# Convert the time to a number of minutes (same way as before), then add it back
          e#   to the guest.
a\+       e# Add the guest back to the start of the guest list.

          e# At this point, the first guest has his/her arrival time in minutes, and everyone
          e#  else still has their original number.

{         e# Apply this block to each guest:
 )i       e#  Pull out the number and cast it to an integer.
 T+       e#  Add the value of variable T to it (T is initially 0).
 :T       e#  Store the result back into T.
 Y>{;}|   e#  If the resulting number of minutes is not after the start time, delete the 
          e#    guest's name.
}%        e# (end of block)

          e# Implicit output.

2

ルア、 211の 206バイト

私にとって今年の最初のコードゴルフは、まだゴルフができるはずです。

編集:の短縮形を使用して5バイトを保存しました string.match

function f(l,T)m=T.match
r=function(X)return
m(X,"^%d+")*3600+60*m(X,"%d+$")end
T=r(T)z={}y=0
for i=1,#l do
h=m(l[i],"%d.*")h=i>1 and y+h*60or r(h)y=h
z[#z+1]=h>T and m(l[i],"%u%l*")or nil
end return z end

説明

function f(l,T)                         -- declare the function f(list,partyTime)
  r=function(X)                         -- declare a function r that convert hh:mm in seconds
    return X:match("^%d+")*3600         -- return the sum of seconds the hours
          +60*X:match("%d+$")           -- and in the seconds
  end                                   
  T=r(T)                                -- convert the partyTime in seconds
  z={}                                  -- create the shameList for late partygoers
  y=0                                   -- y will keep us updated on the second count
  for i=1,#l                            -- iterate over l
  do                                    
    h=l[i]:match("%d.*")                -- h is a shorthand for the time of arrival
    h=i>1                               -- if we're on the second line at least
        and y+h*60                      -- update h with the time of arrival in second
      or r(h)                           -- else use r()(for the first partygoer only)
    y=h                                 -- update our reference for adding time
    z[#z+1]=h>T                         -- if the last partygoer was late
                and l[i]:match("%u%l*") -- add its name to the shameList
              or nil                    -- else, don't do anything
  end                                   
  return z                              -- return the shameList
end                                 

このコードを試してみたい場合は、次のスニペットを使用できます

function f(l,T)r=function(X)return
X:match("^%d+")*3600+60*X:match("%d+$")end
T=r(T)z={}y=0
for i=1,#l do
h=l[i]:match("%d.*")h=i>1 and y+h*60or r(h)y=h
z[#z+1]=h>T and l[i]:match("%u%l*")or nil
end return z end

retour = f({"Kevin 13:02","Ruby 5","Sam 3","Lisa 6","Bob 12"},"13:15")
for i=1,#retour
do
  print(retour[i])
end

2

Java、346 304 284 275バイト

  • -9バイト、@ KevinCruijssenのおかげ
void g(int m,String[]n,String[]a,int M){for(int i=0;i<n.length;i++)if((M+=i>0?p(a[i]):0)>m)System.out.print(n[i]);}
int p(String n){return new Short(n);}
int h(String t){return p(t.split(":")[0])*60+p(t.split(":")[1]);}
void f(String[]n,String[]a,String b){g(h(b),n,a,h(a[0]));}

詳細な ライブ

public static void g(int m, String[] n, String[] a, int M)
{
    for(int i = 0; i < n.length; i++)
    {
        if((M += i>0 ? p(a[i]) : 0) > m)
        {
            System.out.println(n[i]);
        }
    } 
}

public static int p(String n)
{
    return Integer.parseInt(n);
}

public static int h(String t)
{
    return p(t.split(":")[0])*60+p(t.split(":")[1]);
}

public static void f(String[] n, String[] a, String b)
{
    g(h(b),n,a,h(a[0]));
}

1
素敵なゴルフ(Java用)String[] n,との間にスペースが必要String[] aですか?
Programmer5000

@ programmer5000いいえ、時間変数も削除し、分として累積しました。
Khaled.K

1
あなたは置き換えることができInteger.parseInt(n)new Short(n)。そして挑戦のコメントに基づいて、LisaBobあなたが変更できるように、また、有効な出力であるprintlnprint
ケビンクルーイッセン

1

バッチ、163バイト

@set/pp=
@set/ap=%p::=*60+%
:l
@set g=
@set/pg=
@if "%g%"=="" exit/b
@set t=%g:* =%
@set/ap-=%t::=*60+%
@for %%g in (%g%)do @(if %p% lss 0 echo %%g)&goto l

STDINで入力を受け取ります。最初の行はパーティーの開始時刻、次にゲストのリストです。@Arnauldのトリックを使用して、hh:mmを分に変換します。

このためのバッチの優先入力は、一連のコマンドラインパラメーター(パーティの時間から開始し、次に各ゲストと時間を個別の引数として)になります。これには129バイトしかかかりません。

@set p=%1
@set/ap=%p::=*60+%
:l
@set t=%3
@set/ap-=%t::=*60+%
@if %p% lss 0 echo %2
@shift
@shift
@if not "%2"=="" goto l

1

Groovy、121バイト

{g,t->y={Date.parse('hh:mm',it)};u=y(t);d=y(g.remove(0)[1]);g.find{z=it[1];use(groovy.time.TimeCategory){d+z.minutes}>u}}

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.