added the code
This commit is contained in:
commit
7c03f6017e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
pattern.txt
|
5
input.txt
Normal file
5
input.txt
Normal file
@ -0,0 +1,5 @@
|
||||
She works automatically. Only has half a mind on the task. Transported by rhythm and monotony, she wanders off, drifts away, loses herself in the sequences she types, the numbers she records, the codes behind the keys; the figures she transcribes. Microprocessing. She hears, but she isn't listening. She sees, but she does not watch. Pattern recognition without consciousness.
|
||||
|
||||
Tactile vibrations on taut membranes. "A rich couple comes into the post office and reveals to the young woman, or at least confirms, the existence of another world; coded, multiple tele grams, signed with pseudonyms. It is hard to tell who is who anymore, or what anything means. Instead of a rigid line composed of well-determined segments, telegraphy now forms a supple flow marked by quanta that are like so many little seg mentations-in-progress grasped at the moment of their birth, as · on a moonbeam, or on an intensive scale." Wired to an undernet of imperceptible connections and lines, she decrypts and encodes, switching and swapping in the exchange. Letters to digits, words to keys, voice to fingers, faces to anonymous characters. The telephone becomes an "extension of ear and voice that is a kind of extra sensory perception." There are samples in her ear, voices in her head, snippets of overheard conversation, moments of unknown, disconnected lives, "invisible voices conducted through the tips of her fingers."
|
||||
|
||||
Poised as an interface between man and the world, she is also wired to a network of digital machines: typists connected to QWERTY alphabets, bodies shaped by the motion of the keys, one hundred words a minute, viral speed. Thousands of opera tors, relays, calls, exchanges humming in virtual conjunction, learning the same phrases, flipping the same switches, repeating the same responses, pushing plugs into the answering jacks, maybe two hundred, three hundred times an hour. She has "a fingertip mastery of the ringing, listening, dial, and other keys on her key shelf; of the row or rows of cords for making con nections; of the location and meaning of all parts of the honey combed formation of jacks and trunks for recording, for switch ing, for toll circuits, for tandem, for information..." It becomes second nature. It grows on her. "Having done this stuff a few hundred thousand times, you become quite good at it. In fact you're plugging, and connecting, and disconnecting ten, twenty, forty cords at a time." After a while these processes become "quite satisfying in a way, rather like weaving on an upright loom."
|
92
overunder.py
Executable file
92
overunder.py
Executable file
@ -0,0 +1,92 @@
|
||||
import linecache
|
||||
import textwrap
|
||||
import sys
|
||||
from sys import exit
|
||||
|
||||
class LeavingProgram(Exception):
|
||||
pass
|
||||
|
||||
def parse(program):
|
||||
cmds = program.split(',')
|
||||
splitted_cmds = []
|
||||
for cmd in cmds:
|
||||
splitted = cmd.split()
|
||||
splitted_cmds.append(splitted)
|
||||
return splitted_cmds
|
||||
|
||||
def tokenize(s):
|
||||
return s.split()
|
||||
|
||||
def repl():
|
||||
while True:
|
||||
try:
|
||||
val = eval(parse(input('> ')))
|
||||
if val is not None:
|
||||
print(val)
|
||||
except LeavingProgram:
|
||||
break
|
||||
|
||||
text = None
|
||||
line_number = 0
|
||||
last_index = 0
|
||||
|
||||
def eval(cmds):
|
||||
global text
|
||||
global line_number
|
||||
global last_index
|
||||
global pattern
|
||||
|
||||
for cmd in cmds:
|
||||
if cmd == []:
|
||||
line_number += 1
|
||||
last_index = 0
|
||||
|
||||
elif cmd[0] == 'load':
|
||||
contents = open('input.txt').read()
|
||||
text = textwrap.wrap(contents, 60, break_long_words=True)
|
||||
print('\n'.join(text))
|
||||
line_number = 0
|
||||
last_index = 0
|
||||
|
||||
elif cmd[0] == 'show':
|
||||
print(text[line_number])
|
||||
|
||||
elif cmd[0] == 'under':
|
||||
current_line = text[line_number]
|
||||
char_number = int(cmd[1]) - 1
|
||||
char_list = list(current_line)
|
||||
|
||||
x=range(last_index, char_number + last_index + 1)
|
||||
for time in x:
|
||||
if time < len(char_list):
|
||||
char_list[time] = u'\u21e2'
|
||||
|
||||
last_index += char_number + 1
|
||||
|
||||
joined = ''.join(char_list)
|
||||
text[line_number] = joined
|
||||
|
||||
elif cmd[0] == 'over':
|
||||
last_index += int(cmd[1])
|
||||
|
||||
elif cmd[0] == 'pattern':
|
||||
|
||||
pattern = text[0:line_number + 1]
|
||||
print('\n'.join(pattern))
|
||||
|
||||
elif cmd[0] == 'save':
|
||||
pattern = text[0:line_number + 1]
|
||||
pattern_file = open('pattern.txt', 'w')
|
||||
pattern_file.write('\n'.join(pattern))
|
||||
pattern_file.close()
|
||||
print('Your pattern has been saved in the pattern.txt file.')
|
||||
|
||||
elif cmd[0] == 'quit':
|
||||
print('Come back soon!')
|
||||
raise LeavingProgram()
|
||||
else:
|
||||
joined = ' '.join(cmd)
|
||||
print('Did not understand command {}'.format(joined))
|
||||
|
||||
if __name__ == '__main__':
|
||||
repl()
|
Loading…
Reference in New Issue
Block a user