注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 匿名 于 2021-9-10 15:43 编辑
# Throughout this interview, we'll write code to analyze a simple server process uptime log. These logs are
# much simplified, and are just strings of space separated 0's and 1's. The log is a string of binary
# digits (e.g. "0 0 1 0"). Each digit corresponds to 1 hour of the server running:
#
# "1" = <crashed>, "down" // server process crashed during the hour
# "0" = <didn't crash>, "up" // server process did not crash during the hour
#
# EXAMPLE: A server with log "0 0 1 0" ran for 4 hours and its process crashed during hour #3
#
# hour: |1|2|3|4|
# log : |0|0|1|0|
# ^
# |
# down during hour #3
#
# We can *permanently remove* a server at the beginning of any hour during its operation. A server
# is on the network until it is removed. Note that a server stays POWERED ON after removal, it's
# just not on the network.
#
# Write a function get_best_removal_times, that takes the file's contents as a parameter,
# and returns an array of best removal hours for every valid server log in that file.
# Note: that logs can span 1 or many lines.
# Again, you should use tests to demonstrate that your solution is correct.
# ## Example
# get_best_removal_times("BEGIN BEGIN \nBEGIN 1 1 BEGIN 0 0\n END 1 1 END BEGIN")
# should return an array: [2]
|