forked from matthewdeanmartin/kata-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
41 lines (33 loc) · 1.44 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding=utf-8
"""
You are on an infinite grid of squares, sort of like New York City.
Walk in any direction, N, S, E, W. At intersections, pick a route at random, but not doubling back.
On average how long will it take to get back to the starting point?
How often does it fail to return to the starting point after x iterations?
"""
from __future__ import print_function, unicode_literals, absolute_import
# configure logging for file and console output.
import logging
import os.path
if os.path.isfile("log.txt"):
os.remove("log.txt")
logging.basicConfig(filename='log.txt',level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler())
# strongly discourage using console input and output.
# You can make testable code full of input and print statements, but it introduces
# unnecessary complexity. See kata on testing input and print with fakes and spies.
def input(*args, **kwargs):
raise TypeError("Don't use input, log or get input from function arguments.")
def raw_input(*args, **kwargs):
raise TypeError("Don't use raw_input, either, log or get input from function arguments.")
def run():
"""
Main entry point for your application.
"""
pass
# the functions/classes you write here should have no print or input statements.
if __name__ == "__main__" or __name__ == "builtins":
# Need an environment to run this?
# https://repl.it/languages/python3
logging.info("The application is starting.")
run()