Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I found some major bugs in my code and also in 200_success's code200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm

x is marked as wrong output.

So in my code the line

    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }

is making all kind of troubles. When I wrote the code, I made a theoretical assumption which doesn't stand in practical usage. What I thought was that

enter image description here

If the hour hand travels 30° in 60 minutes, then it will travel 6° in 12 minutes. So after XX:12 the hour hand will move.

But in practical cases we assume that hour hand moves continuously after XX:00.

Also there are corner cases for 12:XX and 11:XX. As 12 - hourAsInt - 1 will give -ve or 00:XX value respectively.

I found some major bugs in my code and also in 200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm

x is marked as wrong output.

So in my code the line

    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }

is making all kind of troubles. When I wrote the code, I made a theoretical assumption which doesn't stand in practical usage. What I thought was that

enter image description here

If the hour hand travels 30° in 60 minutes, then it will travel 6° in 12 minutes. So after XX:12 the hour hand will move.

But in practical cases we assume that hour hand moves continuously after XX:00.

Also there are corner cases for 12:XX and 11:XX. As 12 - hourAsInt - 1 will give -ve or 00:XX value respectively.

I found some major bugs in my code and also in 200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm

x is marked as wrong output.

So in my code the line

    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }

is making all kind of troubles. When I wrote the code, I made a theoretical assumption which doesn't stand in practical usage. What I thought was that

enter image description here

If the hour hand travels 30° in 60 minutes, then it will travel 6° in 12 minutes. So after XX:12 the hour hand will move.

But in practical cases we assume that hour hand moves continuously after XX:00.

Also there are corner cases for 12:XX and 11:XX. As 12 - hourAsInt - 1 will give -ve or 00:XX value respectively.

added 86 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm 
  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm
    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }
    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }
  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm 
    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }
  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm
    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }
explained cases.
Source Link

I found some major bugs in my and also incode 200_success's code and also in 200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     1211:59 pm            00:59 pm x     11:59 pm x
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     0605:59 pm            06:59 pm  x     05:59 pm x
  11:02 am     0112:58 pm            01:58 pm  x     12:58 pm x
  12:59 am     1211:01 pm            -1:1 pm  x     11:01 pm x

x is marked as wrong output.

So in my code the line

    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }

is making all kind of troubles. When I wrote the code, I made a theoretical assumption which doesn't stand in practical usage. What I thought was that

enter image description here

If the hour hand travels 30° in 60 minutes, then it will travel 6° in 12 minutes. So after XX:12 the hour hand will move.

But in practical cases we assume that hour hand moves continuously after XX:00.

Also there are corner cases for 12:XX and 11:XX. As 12 - hourAsInt - 1 will give -ve or 00:XX value respectively.

I found some major bugs in my and also in 200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output
 
  12:01 am     12:59 pm            00:59 pm x     11:59 pm x
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     06:59 pm            06:59 pm       05:59 pm x
  11:02 am     01:58 pm            01:58 pm       12:58 pm x
  12:59 am     12:01 pm            -1:1 pm  x     11:01 pm x

x is marked as wrong output.

I found some major bugs in my code and also in 200_success's code. Since bug-determining and killing also a part of code-review I want to post this as an answer not as a comment. I think it's OK? right?

  Input        Correct output      My output      200_success's output [No bugs found]
 
  12:01 am     11:59 pm            00:59 pm x     11:59 pm 
  11:32 am     12:28 pm            00:28 pm x     12:28 pm
  12:34 am     11:26 pm            -1:26 pm x     11:26 pm
  06:01 am     05:59 pm            06:59 pm x     05:59 pm 
  11:02 am     12:58 pm            01:58 pm x     12:58 pm
  12:59 am     11:01 pm            -1:1 pm  x     11:01 pm 

x is marked as wrong output.

So in my code the line

    if(minuteAsInt < 12) {
        return (12 - hourAsInt) + "";
    }

is making all kind of troubles. When I wrote the code, I made a theoretical assumption which doesn't stand in practical usage. What I thought was that

enter image description here

If the hour hand travels 30° in 60 minutes, then it will travel 6° in 12 minutes. So after XX:12 the hour hand will move.

But in practical cases we assume that hour hand moves continuously after XX:00.

Also there are corner cases for 12:XX and 11:XX. As 12 - hourAsInt - 1 will give -ve or 00:XX value respectively.

added 66 characters in body
Source Link
Loading
Source Link
Loading