Пример #1
0
 def test_write(self):
     self.check(20.14, "double")
     self.check('@', "char")
     self.check('String white a "', "String")
     self.check([1, 2, 3, 4], "int[]")
     self.check([[20.14]], "double[][]")
     self.check([[[]]], "boolean[][][]")
     self.check(False, "boolean")
     self.check([["Jon Snow"],['The "Little Finger"']], "String[][]")
     with self.assertRaises(tc.UnsupportedType):
         tc.write({}, "dict")
Пример #2
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"))
Пример #3
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"))
Пример #4
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"))
Пример #5
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"))
Пример #6
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"))
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"))
Пример #8
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[]"))
Пример #9
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

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

    result = ZigZag.longestZigZag(sequence)
    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)

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

    result = XMarksTheSpot.countArea(board)
    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)

        s = reader.next("String")

    result = Ropestring.makerope(s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Пример #12
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"))
Пример #13
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"))
Пример #14
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"))
Пример #15
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[]"))
Пример #16
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        number = reader.next("int")

    result = DigitHoles.numHoles(number)
    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"))
Пример #18
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

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

    result = OneHandSort.sortShelf(target)
    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)

        s = reader.next("String")

    result = RepeatStringEasy.maximalLength(s)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #20
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"))
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"))
Пример #22
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"))
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"))
Пример #24
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        picture = reader.next("String[]")
        reader.next()
        maxStrokes = reader.next("int")

    result = MiniPaint.leastBad(picture, maxStrokes)
    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[]")
        reader.next()
        b = reader.next("int[]")

    result = SetPartialOrder.compareSets(a, b)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "String"))
Пример #26
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"))
Пример #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)
    
        R = reader.next("int")
        reader.next()
        C = reader.next("int")

    result = PublicTransit.minimumLongestDistance(R, C)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #29
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        room = reader.next("int")
        reader.next()
        size = reader.next("int")

    result = XYZCoder.countWays(room, size)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #30
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"))
Пример #31
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")
        reader.next()
        H = reader.next("int")
        reader.next()
        M = reader.next("long")

    result = BearPaints.maxArea(W, H, M)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "long"))
Пример #32
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        treeCount = reader.next("int")
        reader.next()
        width = reader.next("int")
        reader.next()
        height = reader.next("int")
        reader.next()
        distance = reader.next("int")

    result = BackyardTrees.countWays(treeCount, width, height, distance)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #33
0
def main():
    import topcoder as tc
    with open(sys.argv[1], "r") as fi:
        input = fi.read()
        reader = tc.Reader(input)

        E = reader.next("int")
        reader.next()
        EM = reader.next("int")
        reader.next()
        M = reader.next("int")
        reader.next()
        MH = reader.next("int")
        reader.next()
        H = reader.next("int")

    result = ProblemSetsEasy.maxSets(E, EM, M, MH, H)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #34
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[]")
        reader.next()
        Y = reader.next("int[]")
        reader.next()
        R = reader.next("int[]")
        reader.next()
        x1 = reader.next("int")
        reader.next()
        y1 = reader.next("int")
        reader.next()
        x2 = reader.next("int")
        reader.next()
        y2 = reader.next("int")

    result = CirclesCountry.leastBorders(X, Y, R, x1, y1, x2, y2)
    with open(sys.argv[2], "w") as fo:
        fo.write(tc.write(result, "int"))
Пример #35
0
 def check(self, value, type):
     self.assertTrue(
         deep_equals(tc.Reader(tc.write(value, type)).next(type), value))