Skip to main content
Commonmark migration
Source Link

#Java 8, 54 50 bytes

Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H-h+24)%24+(M-m+60)%60,H+M+2) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Explanation:

Try it here.

(h,m,H,M)-> // Method with four integer parameter and integer return-type Math.min( // Return the lowest of the following two: // The hours: (H-h // Second hours - first hours inputs +24) // +24 so we won't have negative numbers %24 // mod-24 to get the hours + // And add the minutes: (M-m // Second minutes - first minutes inputs +60) // +60 so we won't have negative numbers %60 // mod-60 to get the minutes ,H+M // And compare it to the second hours + second minutes inputs +2) // +2 for the added +24 and +60 to get the positive modulo arguments 

#Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H-h+24)%24+(M-m+60)%60,H+M+2) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Explanation:

Try it here.

(h,m,H,M)-> // Method with four integer parameter and integer return-type Math.min( // Return the lowest of the following two: // The hours: (H-h // Second hours - first hours inputs +24) // +24 so we won't have negative numbers %24 // mod-24 to get the hours + // And add the minutes: (M-m // Second minutes - first minutes inputs +60) // +60 so we won't have negative numbers %60 // mod-60 to get the minutes ,H+M // And compare it to the second hours + second minutes inputs +2) // +2 for the added +24 and +60 to get the positive modulo arguments 

Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H-h+24)%24+(M-m+60)%60,H+M+2) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Explanation:

Try it here.

(h,m,H,M)-> // Method with four integer parameter and integer return-type Math.min( // Return the lowest of the following two: // The hours: (H-h // Second hours - first hours inputs +24) // +24 so we won't have negative numbers %24 // mod-24 to get the hours + // And add the minutes: (M-m // Second minutes - first minutes inputs +60) // +60 so we won't have negative numbers %60 // mod-60 to get the minutes ,H+M // And compare it to the second hours + second minutes inputs +2) // +2 for the added +24 and +60 to get the positive modulo arguments 
Added explanation
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H+24-h)%24+(M+60-m)%60,2+H+M) 
(h,m,H,M)->Math.min((H-h+24)%24+(M-m+60)%60,H+M+2) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Try it here.Explanation:

Try it here.

(h,m,H,M)-> // Method with four integer parameter and integer return-type Math.min( // Return the lowest of the following two: // The hours: (H-h // Second hours - first hours inputs +24) // +24 so we won't have negative numbers %24 // mod-24 to get the hours + // And add the minutes: (M-m // Second minutes - first minutes inputs +60) // +60 so we won't have negative numbers %60 // mod-60 to get the minutes ,H+M // And compare it to the second hours + second minutes inputs +2) // +2 for the added +24 and +60 to get the positive modulo arguments 

#Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H+24-h)%24+(M+60-m)%60,2+H+M) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Try it here.

#Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H-h+24)%24+(M-m+60)%60,H+M+2) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Explanation:

Try it here.

(h,m,H,M)-> // Method with four integer parameter and integer return-type Math.min( // Return the lowest of the following two: // The hours: (H-h // Second hours - first hours inputs +24) // +24 so we won't have negative numbers %24 // mod-24 to get the hours + // And add the minutes: (M-m // Second minutes - first minutes inputs +60) // +60 so we won't have negative numbers %60 // mod-60 to get the minutes ,H+M // And compare it to the second hours + second minutes inputs +2) // +2 for the added +24 and +60 to get the positive modulo arguments 
added 4 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Java 8, 5454 50 bytes

(h,m,H,M)->Math.min(((H+24-h)%24)+(%24+(M+60-m)%60),2+H+M) 

Port of @KamilDrakari's C# answer (after I golfed 22 6 bytes).

Try it here.Try it here.

#Java 8, 54 bytes

(h,m,H,M)->Math.min(((H+24-h)%24)+((M+60-m)%60),2+H+M) 

Port of @KamilDrakari's C# answer (after I golfed 2 bytes).

Try it here.

#Java 8, 54 50 bytes

(h,m,H,M)->Math.min((H+24-h)%24+(M+60-m)%60,2+H+M) 

Port of @KamilDrakari's C# answer (after I golfed 2 6 bytes).

Try it here.

Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading