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

added 57 characters in body
Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) (削除) 209 (削除ここまで) 208(削除) 208 (削除ここまで) 201 bytes

import time,random
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=random.random()<.5;n+=i;pchoice('.!'[i],end=''');n+=i<'#';p(end=i);"*5)
p('\nSuccessf'\nSuccess rate is %d{n*20} percent (%d{n}/5)'%(n*20,n)')

Try it online! Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

-7 bytes, thanks to Erik the Outgolfer

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) (削除) 209 (削除ここまで) 208 bytes

import time,random
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=random.random()<.5;n+=i;p('.!'[i],end='');"*5)
p('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) (削除) 209 (削除ここまで) (削除) 208 (削除ここまで) 201 bytes

import time,random
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=random.choice('.!');n+=i<'#';p(end=i);"*5)
p(f'\nSuccess rate is {n*20} percent ({n}/5)')

Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

-7 bytes, thanks to Erik the Outgolfer

added 5 characters in body
Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) 209(削除) 209 (削除ここまで) 208 bytes

import time,random as r
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=r;i=random.randintrandom(0,1);n+=i;p<.5;n+=i;p('.!'[i],end='');"*5)
p('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online! Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) 209 bytes

import time,random as r
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=r.randint(0,1);n+=i;p('.!'[i],end='');"*5)
p('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで) (削除) 216 (削除ここまで) (削除) 209 (削除ここまで) 208 bytes

import time,random
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=random.random()<.5;n+=i;p('.!'[i],end='');"*5)
p('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

added 13 characters in body
Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 3, (削除) 221 (削除ここまで) 220(削除) 220 (削除ここまで)(削除) 216 (削除ここまで) 209 bytes

import time,random as r
printp=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
for _ in rangeexec(5):time"time.sleep(2);i=r.randint(0,1);n+=i;print;n+=i;p('.!'[i],end='');"*5)
printp('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online! Try it online!

TimeoutTiming doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Python 3, (削除) 221 (削除ここまで) 220 bytes

import time,random as r
print('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
for _ in range(5):time.sleep(2);i=r.randint(0,1);n+=i;print('.!'[i],end='')
print('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online!

Timeout doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Python 3, (削除) 221 (削除ここまで) (削除) 220 (削除ここまで)(削除) 216 (削除ここまで) 209 bytes

import time,random as r
p=print
p('Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:')
n=0
exec("time.sleep(2);i=r.randint(0,1);n+=i;p('.!'[i],end='');"*5)
p('\nSuccess rate is %d percent (%d/5)'%(n*20,n))

Try it online!

Timing doesn't work in TIO, but works in console. (TIO outputs at the end of execution)

Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63
Loading

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