<s> import bisect <EOL> import sys <EOL> HAYSTACK = [ <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:8> , <NUM_LIT:12> , <NUM_LIT:15> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:30> ] <EOL> NEEDLES = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:30> , <NUM_LIT> ] <EOL> ROW_FMT = '<STR_LIT>' <EOL> def demo ( bisect_fn ) : <EOL> for needle in reversed ( NEEDLES ) : <EOL> position = bisect_fn ( HAYSTACK , needle ) <EOL> offset = position * '<STR_LIT>' <EOL> print ( ROW_FMT . format ( needle , position , offset ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if sys . argv [ - <NUM_LIT:1> ] == '<STR_LIT:left>' : <EOL> bisect_fn = bisect . bisect_left <EOL> else : <EOL> bisect_fn = bisect . bisect <EOL> print ( '<STR_LIT>' , bisect_fn . __name__ ) <EOL> print ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( '<STR_LIT>' % n for n in HAYSTACK ) ) <EOL> demo ( bisect_fn ) </s>
