from models.validation_value import (CheckRequirements, NoLessThanZero,
                                     LessOneMillionOne)
from models.input_value import AskInput, IntInput
from models.happy_tickets_algorithm import HappyTickets

if __name__ == "__main__":
    start_number = IntInput(AskInput("Please, enter required number")).value()
    stop_number = IntInput(AskInput("Please, enter required number")).value()
    check_number = CheckRequirements(NoLessThanZero(), LessOneMillionOne())
    if check_number.passed(start_number) and check_number.passed(stop_number):
        new_happy_tickets_count = HappyTickets(start_number, stop_number)
        new_happy_tickets_count.get_happy_tickets()
        print(new_happy_tickets_count)
from models.input_value import AskInput
from models.palindrome_algorithm import Palindrome

if __name__ == "__main__":
    required_value = AskInput("Please, enter required value:").value()
    check_palindrome = Palindrome(required_value).is_palindrome()
    print(f"After checking, your palindrome is: {check_palindrome}")
Exemplo n.º 3
0
    SumTwoSides,
    LessZero,
    StringLength,
)

from models.input_value import AskInput, SplitInput
from models.execution import NewExecution

from models.triangles_algorithm import Triangle, TriangleList

if __name__ == "__main__":
    triangles_sorted = TriangleList()
    while True:
        triangle_data = SplitInput(
            AskInput(
                "Please, enter triangle name and size of sides \n"
                "Input format - 'name, side_a, side_b, side_c':")).value()
        checked_length = CheckRequirements(StringLength())
        checked_sides = CheckRequirements(SidesFloat(), SumTwoSides(),
                                          LessZero())
        if checked_length.passed(triangle_data) and checked_sides.passed(
                triangle_data[1], triangle_data[2], triangle_data[3]):
            new_triangle = Triangle(
                str(triangle_data[0]),
                float(triangle_data[1]),
                float(triangle_data[2]),
                float(triangle_data[3]),
            ).square_calculation()
            triangles_sorted.add_triangle(new_triangle)
        else:
            break
from models.validation_value import CheckRequirements, GreaterThanZero
from models.input_value import AskInput, IntInput

from models.chessboard_algorithm import Chessboard

if __name__ == "__main__":
    length_chessboard = IntInput(AskInput("Please, enter length")).value()
    width_chessboard = IntInput(AskInput("Please, enter width")).value()
    check_side = CheckRequirements(GreaterThanZero())

    if check_side.passed(length_chessboard) and check_side.passed(
            width_chessboard):
        new_chessboard = Chessboard(length_chessboard,
                                    width_chessboard).chessboard_building()
        for chessboard_line in new_chessboard:
            print(chessboard_line)
from models.validation_value import CheckRequirements, GreaterThanZero, LessOneMillion
from models.input_value import AskInput, IntInput
from models.digits2text_algorithm import TranslateInText

if __name__ == "__main__":
    required_number = IntInput(
        AskInput("Please, enter required number")).value()
    check_number = CheckRequirements(GreaterThanZero(), LessOneMillion())

    if check_number.passed(required_number):
        new_translation = TranslateInText(required_number).numbers_to_text()
        print(f"Converted value from number in text is: {new_translation}")
Exemplo n.º 6
0
from models.validation_value import (
    CheckRequirements,
    GreaterThanZero,
    LessOneHundred,
    IntArgs,
)
from models.input_value import AskInput, SplitInput
from models.fibonacci_algorithm import FibonacciRange, FibonacciLength


if __name__ == "__main__":
    required_number = SplitInput(AskInput("Please, enter fibonacci number")).value()
    check_required_number = CheckRequirements(
        IntArgs(),
        LessOneHundred(),
        GreaterThanZero()
    )
    if len(required_number) == 1:
        if check_required_number.passed((int(required_number[0]))):
            fibo_length = FibonacciLength(int(required_number[0])).length_calculation()
            print(f"You've got next fibonacci sequence: {fibo_length}")

    if len(required_number) == 2:
        if check_required_number.passed(int(required_number[0])
        and check_required_number.passed(int(required_number[1]))):
            fibo_range = FibonacciRange(
                int(required_number[0]),
                int(required_number[1])
            ).range_calculation()

        print(f"You've got next fibonacci sequence: {fibo_range}")
Exemplo n.º 7
0
 def side_validation(self) -> int:
     envelope_side = IntInput(AskInput(self._side)).value()
     check_side = CheckRequirements(GreaterThanZero(), LessOneHundred())
     if check_side.passed(envelope_side):
         return envelope_side
     raise SystemExit
Exemplo n.º 8
0
from models.validation_value import CheckRequirements, GreaterThanZero, LessOneMillion
from models.input_value import AskInput, IntInput
from models.numeric_sequence_algorithm import Sequence

if __name__ == "__main__":
    required_number = IntInput(
        AskInput("Please, enter sequence length")).value()
    required_square = IntInput(
        AskInput("Please, enter number in square")).value()
    check_number = CheckRequirements(GreaterThanZero(), LessOneMillion())

    if check_number.passed(required_number) and check_number.passed(
            required_square):
        new_sequence = Sequence(required_number,
                                required_square).sequence_calculation()
        print(f"Sequence has next elements: {new_sequence}")