INNER CODE UNIT · Python
pe049395/IMC-Prosperity-2024 · submissions/round5.py:17
def print(self, *objects: Any, sep: str = " ", end: str = "\n") -> None:
self.logs += sep.join(map(str, objects)) + end
def flush(self, state: TradingState, orders: dict[Symbol, list[Order]], conversions: int, trader_data: str) -> None:
base_length = len(self.to_json([
self.compress_state(state, ""),
self.compress_orders(orders),
conversions,
"",
"",
]))
# We truncate state.traderData, trader_data, and self.logs to the same max. length to fit the log limit
max_item_length = (self.max_log_length - base_length) // 3
print(self.to_json([
self.compress_state(state, self.truncate(state.traderData, max_item_length)),
self.compress_orders(orders),