This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simulate(n: int, propagation_flags: list) -> int: | |
steps = 0 | |
expecting_events: int = 0 | |
for i in range(1, n + 1): | |
if propagation_flags[i - 1]: | |
steps += expecting_events | |
expecting_events += 1 | |
steps += 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implements an event dispatch loop similar to the mainloop in tkinter. The EventDispatcher is NOT asyncronous but should be thread safe.""" | |
# TODO: async variant, test thread safety | |
from collections import deque | |
from logging import Logger, getLogger | |
from queue import PriorityQueue | |
from random import randint | |
from time import sleep, time_ns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from builtin.io import _dup | |
from memory import UnsafePointer, memcpy | |
from sys import os_is_windows, external_call | |
@value | |
struct stdin: | |
"""A read only file handle to the stdin stream.""" | |
alias file_descriptor = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cool Mojo Calculator | |
from types.input.input import input | |
def is_float(given_string: String) -> Bool: | |
# Given a string, go through each character and check if it is a digit or a dot. | |
for i in range(len(given_string)): | |
# If the character is a dot, check if it is the last character in the string. | |
if given_string[i] == "." and i == len(given_string) - 1: | |
return False | |
# Normal case, check if the character is a digit or a dot. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 as builder | |
FROM python:3.10.7 | |
# Create a user to run the application | |
RUN apt-get update && \ | |
apt-get -y install sudo | |
RUN useradd -ms /bin/bash docker && echo "docker:docker" | chpasswd && adduser docker sudo |