示例#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)
示例#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"))
示例#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"))
示例#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"))
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"))
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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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[]"))
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"))
示例#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"))
示例#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[]"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))
示例#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"))