Ad
  • Custom User Avatar

    "The Lift never changes direction until there are no more people wanting to get on/off in the direction it is already travelling"
    I'm not a native speaker. I understood that because in that test case there are people on last floor all wanting to go down lift should continue go up
    final int[][] queues2 = { new int[0], // 0 new int[0], // 1 new int[]{4,4,4,4}, // 2 new int[0], // 3 new int[]{2,2,2,2}, // 4 new int[0], // 5 new int[]{0,2,4,4,2,2,4,4,2,0} last floor has plenty of people waiting to go down. that's why in my solution lift goes there first. and in my solution i think i don't take those 2's cause lift is going up not down. so i first take down people from higest floor and when lift passes by the floor in down direction and is empty i take down those 2's.

  • Custom User Avatar

    final int[][] queues2 = {
    new int[0], // 0
    new int[0], // 1
    new int[]{4,4,4,4}, // 2
    new int[0], // 3
    new int[]{2,2,2,2}, // 4
    new int[0], // 5
    new int[]{0,2,4,4,2,2,4,4,2,0},
    array lengths differed, expected.length=7 actual.length=10; arrays first differed at element [3]; expected:<2> but was:<4> capacity is 2; why 2 expected. lift goes up picks up people on floor 2 than they go off on floor 4 then continue go up to flooor 6 and then goes down but stops at floor 4 again cause there are people waiting to go down even if lift is fuull

  • Custom User Avatar

    final int[][] queues2 = {
    new int[0], // 0
    new int[0], // 1
    new int[]{4,4,4,4}, // 2
    new int[0], // 3
    new int[]{2,2,2,2}, // 4
    new int[0], // 5
    new int[]{0,2,4,4,2,2,4,4,2,0},
    capacity 2
    array lengths differed, expected.length=7 actual.length=10; arrays first differed at element [3]; expected:<2> but was:<4> why it expected 2 when lift should go up till the end and on the way down stop if someone waiting to go down even if it is full so it should stop at 4. it goes first to 2 picks up then to 4 then to 6 and then has stop at 4 cause there are people there waiting to go to floor 2?

  • Custom User Avatar

    i rewrote solution from the scratch and now i don't get this problem. i still have problem with time run out. but now those tests are working with totally different solution.Thank you for the link. I will read it.

  • Custom User Avatar

    randomTests
    Log
    input :4542814
    result :4542481
    input :71723
    result :71372
    input :760
    Hi
    result :721
    expected:<706> but was:<721>
    Stack Trace
    Completed in 107ms
    extendedTests
    Log
    input :513
    result :441
    input :351
    result :315
    input :315
    result :271
    expected:<153> but was:<271>
    Stack Trace
    Completed in 62ms
    Completed in 426ms

    in my IDE i get correct results with same tests and same code

  • Custom User Avatar

    i have passed all tests. i pasted code from debugger here and it worked. i thought i had same code here.

  • Custom User Avatar

    The folly of Mr Pong
    While Mrs Pong is away visiting her sister, Mr Pong has foolishly set up a ping pong table in his lounge room, and invites his neighbour Mr Ping over for a friendly ping pong session.

    When Mr Ping hits the ping pong ball, the ping pong ball goes ping.

    When Mr Pong hits the ping pong ball, the ping pong ball goes pong.

    Unfortunately, not every hit goes where it was meant to...

    Sometimes the ping pong ball hits the net, or bounces off a wall, or it ricochets off Mrs Pong's rather expensive porcelain collection, a light fitting, or various pieces of lounge furniture, before finally coming to rest on the floor. When that happens there are all kinds of bad noises.

    Example
    A typical rally may sound like this:

    ping-pong-ping-pong-ping-pong-ping-pong-dong-tang-bing-tink-donk-donk-donk

    Mr Ping served
    There were several good returns
    Mr Pong hits a bad shot which broke the handle off his wife's 2nd favourite teacup. Oops.
    Kata Task
    Who scored the most points?

    Input
    The sounds of one or more rallies.

    Output
    The name of the winning player: ping or pong

    Notes
    To score a point the same player must both serve and win the rally.
    Whoever picks the ball off the floor will serve next. It's random.
    A bad noise is anything other than ping or pong.
    A bad noise means whoever hit the ball last hit a bad shot.
    For some unknown reason all noises are 4 lowercase characters, and delimited by -
    If scores are even, then the winner is the player who did NOT hit the final bad shot.
    There are no double hits.
    The final rally always ends with the ball on the floor.
    All input is valid.

  • Custom User Avatar

    Random test #10: 'pong-ping-pong-ping-boof-bink-doof-ping-smak-bong-ping-pong-ping-pong-ping-pong-ping-pong-ping-pong-flap-funk'. Expected = ping
    [pong, ping, pong, ping, boof, bink, doof, ping, smak, bong, ping, pong, ping, pong, ping, pong, ping, pong, ping, pong, flap, funk]
    ping :1
    pong :2

    same thing here. ping and pong scores are 1 and 2 correctly in my solution.

  • Custom User Avatar

    Random test #4: 'pong-donk-pong-ping-pong-ping-pong-ping-pong-flap-poof-doof-pong-ping-pong-ping-pong-ping-pong-ping-pong-ping-bong-poof-voom-pong-ping-pong-ping-klak-wizz-ping-pong-ping-pong-ping-pong-ping-pong-ping-pong-zoom-zoom'. Expected = pong
    [pong, donk, pong, ping, pong, ping, pong, ping, pong, flap, poof, doof, pong, ping, pong, ping, pong, ping, pong, ping, pong, ping, bong, poof, voom, pong, ping, pong, ping, klak, wizz, ping, pong, ping, pong, ping, pong, ping, pong, ping, pong, zoom, zoom]
    ping :2
    pong :2
    why did it expect pong. because of such tests i cannot pass attempt even though my solution is working.