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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import task12
import task11
import battleship
import task6
import task3_5
import task2
import task1
from .output_place_ships import *
from .attack_boards import *
import os
import sys
import builtins
import importlib
from pathlib import Path
home = str(Path.home())
def import_path(path):
module_name = path.replace(home, "").replace(
"src" + os.sep, "").strip(os.sep)
print(module_name)
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
return module
board3 = [[False, False, False], [False, False, False], [False, False, False]]
board10 = [[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False],
[False, False, False, False, False, False, False, False, False, False]]
board0 = []
output = ""
input_list = []
input_index = 0
def myprint(*args, **kwargs):
global output
output += " ".join(str(arg) for arg in args) + "\n"
def myinput(prompt):
global input_index
response = input_list[input_index]
input_index += 1
return response
def intercept(func, inputs):
global output, input_index, input_list
input_list = inputs
output = ""
input_index = 0
original_print = builtins.print
original_input = builtins.input
builtins.print = myprint
builtins.input = myinput
func()
builtins.print = original_print
builtins.input = original_input
return output
def gogo_ask_coordinates():
task3_5.ask_coordinates(board3)