Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

##Python 3.6, (削除) 110 (削除ここまで)(削除) 114 (削除ここまで) 112 bytes

Python 3.6, (削除) 110 (削除ここまで)(削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

##Python 3.6, (削除) 110 (削除ここまで)(削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

Python 3.6, (削除) 110 (削除ここまで)(削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

##Python 3.6, (削除) 110 (削除ここまで) (削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer Value Ink's Ruby answer.

##Python 3.6, (削除) 110 (削除ここまで) (削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

##Python 3.6, (削除) 110 (削除ここまで) (削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

added 163 characters in body
Source Link

##Python 3.6, (削除) 110 (削除ここまで) 114(削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{(h+1)%24-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

##Python 3.6, (削除) 110 (削除ここまで) 114 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{(h+1)%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

##Python 3.6, (削除) 110 (削除ここまで) (削除) 114 (削除ここまで) 112 bytes

from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))

This uses the new f-string formatting to save one byte (f'\n{h+1:2} ' vs '\n%2d '%(h+1).) You can change [sleep(9)] to 1 to save 8 bytes, but then it just spams the screen.

Saved one byte changing while 1:...;sleep 60 to while[sleep(60)]:..., thanks to TuukkaX.

I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(

Recovered one byte by only sleeping 9 seconds instead of 60.

Saved two bytes using a bit-fiddling to shorten (h+1)%24, borrowed from Value Ink's Ruby answer.

added 102 characters in body
Source Link
Loading
Hours mod 24
Source Link
Loading
added 95 characters in body
Source Link
Loading
save a byte
Source Link
Loading
Source Link
Loading

AltStyle によって変換されたページ (->オリジナル) /