Ejemplo n.º 1
0
 def test_read_boolean(self):
     reader = tc.Reader("true")
     flag = reader.next("boolean")
     self.assertEqual(flag, True)
     reader = tc.Reader("false")
     flag = reader.next("boolean")
     self.assertEqual(flag, False)
Ejemplo n.º 2
0
 def test_read_string_error(self):
     reader = tc.Reader('"Eddard Stark')
     with self.assertRaises(tc.ReadError):
         name = reader.next("String")
     reader = tc.Reader('Eddard Stark"')
     with self.assertRaises(tc.ReadError):
         name = reader.next("String")
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)
    
        d = reader.next("int[]")

    result = RandomPancakeStackDiv2.expectedDeliciousness(d)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "double"))
Ejemplo n.º 4
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")

    result = Ropestring.makerope(s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 5
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        ciphertext = reader.next("long")

    result = Hexspeak.decode(ciphertext)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 6
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        b = reader.next("int[]")

    result = DivisibleSetDiv2.isPossible(b)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 7
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        a = reader.next("int[]")

    result = PrivateD2party.getsz(a)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 8
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        S = reader.next("long")

    result = LastDigit.findX(S)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "long"))
Ejemplo n.º 9
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        floor = reader.next("String[]")

    result = ChessFloor.minimumChanges(floor)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 10
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        keys = reader.next("int[]")

    result = Xylophone.countKeys(keys)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 11
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        board = reader.next("String[]")

    result = XMarksTheSpot.countArea(board)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 12
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")

    result = SquareScoresDiv2.getscore(s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 13
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        x = reader.next("int[]")

    result = MutaliskEasy.minimalAttacks(x)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 14
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)
    
        w = reader.next("int[]")

    result = BearDartsDiv2.count(w)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "long"))
Ejemplo n.º 15
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")

    result = RepeatStringEasy.maximalLength(s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 16
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        board = reader.next("String[]")

    result = EightRooks.isCorrect(board)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 17
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        N = reader.next("int")

    result = PageNumbers.getCounts(N)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int[]"))
Ejemplo n.º 18
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)
    
        a = reader.next("int[]")

    result = CombiningSlimes.maxMascots(a)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 19
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        name = reader.next("String")

    result = Initials.getInitials(name)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 20
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        board = reader.next("String[]")

    result = FallingSand.simulate(board)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String[]"))
Ejemplo n.º 21
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        field = reader.next("String[]")

    result = BuildingRoads.destroyRocks(field)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 22
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        board = reader.next("String[]")

    result = BichromeBoard.ableToDraw(board)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 23
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        p = reader.next("int[]")
        reader.next()
        x = reader.next("int[]")

    result = SubtreeSum.getSum(p, x)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 24
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        initial = reader.next("String")
        reader.next()
        target = reader.next("String")

    result = ABBA.canObtain(initial, target)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 25
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)
    
        s = reader.next("String")
        reader.next()
        k = reader.next("int")

    result = Drbalance.lesscng(s, k)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 26
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")
        reader.next()
        k = reader.next("int")

    result = CorruptedMessage.reconstructMessage(s, k)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 27
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        a = reader.next("int[]")
        reader.next()
        b = reader.next("int[]")

    result = Cdgame.rescount(a, b)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Ejemplo n.º 28
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")
        reader.next()
        t = reader.next("String")

    result = InfiniteString.equal(s, t)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 29
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        s = reader.next("String")
        reader.next()
        k = reader.next("int")

    result = Cyclemin.bestmod(s, k)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Ejemplo n.º 30
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        h = reader.next("int[]")
        reader.next()
        s = reader.next("String[]")

    result = LiveConcert.maxHappiness(h, s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))