# comma_remover.py
# author: Eric Hayes - [email protected]
# March 2017

# remove comments from csv file, replace missing values with -100000

import stdio

while stdio.isEmpty() == False:
    s = stdio.readLine()
    output = ""

    for i in range(0, len(s)):

        if i < len(s) - 1:
            if s[i] == ',' and s[i + 1] == ',':
                # insert -100000 at index s[i]
                output = "".join((output, " -100000"))
            else:
                output = "".join((output, s[i]))

        elif i == len(s) - 1 and s[i] == ',':
            # insert -100000 at index s[i]
            output = "".join((output, " -100000"))

    # replace comma with empty string
    output = output.replace(',', ' ')

    stdio.writeln(output)
Example #2
0
# kamasutra.py
#-----------------------------------------------------------------------

import stdio
import sys

# Accept two strings as command-line arguments to be used as key
# strings in a Kama Sutra cipher. Then repeatedly read a line from
# standard input, encode it using the cipher, and write the result
# to standard output.

top = sys.argv[1]
bot = sys.argv[2]

while stdio.hasNextLine():
    line = stdio.readLine()
    for c in line:
        if top.find(c) >= 0:
            stdio.write(bot[top.find(c)])
        elif bot.find(c) >= 0:
            stdio.write(top[bot.find(c)])
        else:
            stdio.write(c)
    stdio.writeln()

#-----------------------------------------------------------------------

# python kamasutra.py THEQUICKBROWNFOX FXJMPSVLAZYDG
# MEET AT ELEVEN
# QJJF BF JKJCJG
# Ctrl-d
Example #3
0
# vertex, separated by the delimiter. Then repeatedly read a
# destination vertex from standard input, and write the shortest path
# from the source index to the destination index.

ommand-line arguments file, delimiter, and s. The file 
# contains a graph expressed using delimiter Read data from
# file to create a graph
file = sys.argv[1]
delimiter = sys.argv[2]
s = sys.argv[3]

graph = Graph(file, delimiter)
pf = PathFinder(graph, s)

while stdio.hasNextLine():
    t = stdio.readLine()
    if pf.hasPathTo(t):
        distance = pf.distanceTo(t)
        for v in pf.pathTo(t):
            stdio.writeln('   ' + v)
        stdio.writeln('distance: ' + str(distance))

#-----------------------------------------------------------------------

# python separation.py routes.txt " " JFK
# LAX   
#    JFK
#    ORD
#    PHX
#    LAX
# distance: 3
Example #4
0

def new_speed(speed, delta_t, acc):
    velocity = speed + acc * delta_t
    return velocity


def new_position(position, delta_t, new_speed):
    new_pos = position + new_speed * delta_t
    return new_pos


####################################################################

while not stdio.isEmpty():
    body = stdio.readLine()
    body = body.split()
    # aufgrund von unterschiedlichen eingabedateien müssen ggf. fehler
    # umgangen werden
    try:
        # erstelle für jeden Körper ein eigenes Dictionary
        # und füge dies in die Liste der Körper (bodies) ein.
        body_dict = {
            # position und geschwindigkeit als vektoren
            "position": np.array([body[0], body[1]], dtype='f'),
            "speed": np.array([body[2], body[3]], dtype='f'),
            "mass": float(body[4]),
            "filename": body[5],
            "force": np.array([0, 0], dtype='f'),
            "acceleration": np.array([0, 0], dtype='f'),
        }