Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
cd82975
Add EGE2022 module
SergeyZinkovich Mar 9, 2022
7dc450c
Add .vs folder into gitignore
tonichoff Mar 30, 2022
bb7bceb
EGE2022_05: Add robot task to N05
Rubik0n Jan 28, 2022
b54628b
EGE2022_05: Add existing tasks to N05
Rubik0n Jan 28, 2022
2ce199a
EGE2022_05: Add calculator task to N05
Rubik0n Jan 28, 2022
169a831
EGE2022_05: Add bold text for important stuff
Rubik0n Jan 28, 2022
b53c30d
EGE2022_05: Add binary number machine task to N05
Rubik0n Jan 28, 2022
eabb335
EGE2022_05: Add eight bit number task to N05
Rubik0n Jan 28, 2022
5bfa0f2
EGE2022_05: Add four digit number task to N05
Rubik0n Jan 28, 2022
1601eac
EGE2022_05: Add less or equal machine task to N05
Rubik0n Jan 28, 2022
dee1203
EGE2022_05: Add reverse bits machine task to N05
Rubik0n Jan 29, 2022
6d80832
EGE2022_05: Update gen.py file
Rubik0n Jan 29, 2022
798bd17
EGE2022_05: Move N05.py to EGE2022 folder
Rubik0n Apr 6, 2022
d1d4c77
EGE2022_05: Add Draftsman task to N05
Rubik0n Apr 6, 2022
85d940d
EGE2022_05: Improve Robot tasks
Rubik0n Apr 7, 2022
d3863be
EGE2022_05: Take Calculator task from EGE folder
Rubik0n Apr 8, 2022
048656a
EGE2022_05: Improve Calculator task
Rubik0n Apr 8, 2022
0290fc7
EGE2022_05: Fix FourDigitNumber task
Rubik0n Apr 10, 2022
e048c06
EGE2022_05: Improve ThreeDigitNumber and FourDigitNumber tasks
Rubik0n Apr 14, 2022
9968437
EGE2022_05: Expand FourDigitNumber task
Rubik0n Apr 15, 2022
449eec5
EGE2022_05: Add FiveDigitNumber task
Rubik0n Apr 22, 2022
a6ca2a3
EGE2022_05: Add NaturalNumber task
Rubik0n Apr 22, 2022
4bb8b15
EGE2022_05: Add FourDigitOddNumber task
Rubik0n Apr 22, 2022
446e2b4
EGE2022_05: Add RemainderOfDivision task
Rubik0n Apr 22, 2022
b4453e1
EGE2022_05: Fix BinaryNumberMachine task
Rubik0n Apr 23, 2022
ae94063
EGE2022_05: Expand LessOrEqualMachine task
Rubik0n Apr 23, 2022
7d6a5cc
EGE2022_05: Update binary symbol conversion tasks
Rubik0n Apr 24, 2022
fc06a93
EGE2022_05: Add TernaryNumber task
Rubik0n Apr 24, 2022
c838854
EGE2022_05: Expand EvenOddNumber task
Rubik0n Apr 24, 2022
7730973
EGE2022_05: Expand BitsSumRemainder task
Rubik0n Apr 24, 2022
b064959
EGE2022_05: Add tasks to gen.py
Rubik0n Apr 24, 2022
63306eb
EGE2022_05: Fix BinarySymbolConversion tasks
Rubik0n Apr 26, 2022
7394c54
EGE2022_05: Fix code style
Rubik0n Apr 27, 2022
eba9ebe
Merge branch 'EGE2022_05' into dev
tonichoff May 1, 2022
8cb5c4c
EGE2022_11: Create branch for generators for 11th task
Drokonor Mar 24, 2022
ba0a4bc
EGE2022_11: Add first generator: AmountOfInformationCars
Drokonor Mar 24, 2022
3983c74
EGE2022_11: Add 3 new tasks
Drokonor Mar 27, 2022
cdc09f2
EGE2022_11: Add Base class
Drokonor Apr 27, 2022
f923e3b
EGE2022_11: Fix minor errors
Drokonor Apr 28, 2022
c265e37
gen.py: Uncomment old problems
tonichoff May 1, 2022
7845452
Merge branch 'EGE2022_11' into dev
tonichoff May 1, 2022
d070f11
EGE2022_14: Add task N14
YaroslavDrozdovskiy May 1, 2022
77d0818
EGE2022_14: Add minor changes
YaroslavDrozdovskiy May 2, 2022
70b240b
Merge branch 'EGE2022_14' into dev
tonichoff May 2, 2022
94f9e08
EGE2022_14: Fix crash
tonichoff May 3, 2022
dc681dc
EGE2022_03: Add base
Rimuto Mar 17, 2022
40049eb
EGE2022_03: Replace if/else by classes
Rimuto Mar 31, 2022
de9cb3c
EGE2022_03: Replace vocabulary in the Products.py by dataclasses
Rimuto Mar 31, 2022
0de2eba
EGE2022_03: Fix warnings
Rimuto Mar 31, 2022
8dcb878
EGE2022_03: Replace png by base64
Rimuto Apr 2, 2022
7974faf
EGE2022_03: Fix bug
Rimuto Apr 2, 2022
b563bb6
EGE2022_03: Fix warning
Rimuto Apr 4, 2022
c1463ae
EGE2022_03: Fix bug
Rimuto Apr 7, 2022
39a6f5a
EGE2022_03: Update types of N03 problem
Rimuto Apr 21, 2022
44926a0
EGE2022_03: Improve readability
Rimuto Apr 21, 2022
5070d84
EGE2022_03: Clear comments
Rimuto Apr 21, 2022
a5783e2
EGE2022_03: Fix bug
Rimuto Apr 29, 2022
9a133a2
EGE2022_03: Improve readability
Rimuto May 2, 2022
d98b7af
EGE2022_03: Delete extra .html file. Rename file N03.py. Clean code i…
tonichoff May 5, 2022
d7f282e
Merge branch 'EGE2022_3' into dev
tonichoff May 5, 2022
0624133
EGE2022_07: Add image transfer task
nixtaxe Apr 27, 2022
735cb3a
EGE2022_07: Change text formatting
nixtaxe Apr 27, 2022
18e9f53
EGE2022_07: Move variant related data to generator
nixtaxe Apr 27, 2022
8de92c9
EGE2022_07: Add base class for logging data classes
nixtaxe Apr 27, 2022
dbf122d
EGE2022_07: Change image transfer class name to image transfer time
nixtaxe Apr 27, 2022
32638d3
EGE2022_07: Add text transfer time task
nixtaxe Apr 27, 2022
1e4d22b
EGE2022_07: Add text transfer data length task
nixtaxe Apr 28, 2022
e18887d
EGE2022_07: Add text file resize diff task
nixtaxe Apr 28, 2022
9da69ff
EGE2022_07: Add text file resize symbols n task
nixtaxe Apr 28, 2022
b28e443
EGE2022_07: Add image storage size task
nixtaxe Apr 28, 2022
98a87c3
EGE2022_07: Add image storage palette task
nixtaxe Apr 28, 2022
a7fb96c
EGE2022_07: Add image storage resize palette task
nixtaxe Apr 28, 2022
ad93a2b
EGE2022_07: Fix range in bigger encoding bits for text data
nixtaxe Apr 28, 2022
0f28fc5
EGE2022_07: Fix kilobyte sizes
nixtaxe Apr 30, 2022
da015e1
EGE2022_07: Fix palette calculation
nixtaxe Apr 30, 2022
2c379b9
EGE2022_07: Add extra data variant to image storage palette
nixtaxe Apr 30, 2022
7e74365
EGE2022_07: Fix image data bigger bits random generation
nixtaxe Apr 30, 2022
6e6325c
EGE2022_07: Add unstaged deletions
nixtaxe Apr 30, 2022
85fc149
EGE2022_07: Add image storage pictures n task
nixtaxe Apr 30, 2022
eb22e38
EGE2022_07: Add image pictures n for period task
nixtaxe Apr 30, 2022
4c7a1bf
EGE2022_07: Add image storage pictures n palette task
nixtaxe Apr 30, 2022
46ae35b
EGE2022_07: Add image storage dpi size task
nixtaxe May 4, 2022
01a9884
EGE2022_07: Add image storage dpi resize task
nixtaxe May 4, 2022
be43541
EGE2022_07: Add newline at end of file
nixtaxe May 4, 2022
a3abb7f
EGE2022_07: Add space after opening and before closing brackets
nixtaxe May 4, 2022
a2c2304
EGE2022_07: Remove commented code
nixtaxe May 4, 2022
a214a95
EGE2022_07: Fix names of variables by expanding the words
nixtaxe May 4, 2022
f33af47
EGE2022_07: Fix inches width and height naming
nixtaxe May 4, 2022
b410a8d
EGE2022_07: Fix palette range to remove extra large numbers
nixtaxe May 4, 2022
8796036
EGE2022_07: Fix daily time task seconds
nixtaxe May 4, 2022
4c6b87b
EGE2022_07: Fix word form in text transfer time task
nixtaxe May 4, 2022
b8cd525
EGE2022_07: Fix symbols per page variant in text transfer time task
nixtaxe May 4, 2022
ebad2f7
EGE2022_07: Fix calculation accuracy in text file resize symbols n task
nixtaxe May 4, 2022
4be8f21
EGE2022_07: Fix palette in image storage dpi resize
nixtaxe May 5, 2022
6a3fa2d
EGE2022_07: Fix seconds word in image storage pictures n for period task
nixtaxe May 5, 2022
5f7275c
EGE2022_07: Add problem in gen.py
tonichoff May 5, 2022
134e0d9
Merge branch 'EGE2022_07' into dev
tonichoff May 5, 2022
e006e11
EGE2022_06: Add SumOfTwoLinearFunctions, ArithmeticProgression, TwoLi…
pototckaia Apr 18, 2022
9b60a6f
EGE2022_06: Add InputTwoLinearFunctions and input int in Prog
pototckaia Apr 18, 2022
8c789f2
EGE2022_06: Add N06 to gen.py
pototckaia May 5, 2022
18a095f
Merge branch 'EGE2022_06' into dev
tonichoff May 5, 2022
c9b5bb4
EGE2022_08: Add CellEncoding tasks
LuckThemAll Apr 26, 2022
184fa26
EGE2022_08: Add BlackWhiteBalls task
LuckThemAll Apr 26, 2022
47d5561
EGE2022_08: Add Pencils task
LuckThemAll Apr 26, 2022
ca91cc8
EGE2022_08: Add VasyaMarks task
LuckThemAll Apr 26, 2022
b218652
EGE2022_08: Add BlackWhiteBalls2 task
LuckThemAll Apr 28, 2022
717c096
EGE2022_08: Add Pencils2 task
LuckThemAll Apr 28, 2022
69cc292
EGE2022_08: Add WordCount2 tasks
LuckThemAll Apr 28, 2022
d953cf2
EGE2022_08: Update wordCount task
LuckThemAll Apr 28, 2022
a4d7fd9
EGE2022_08: Add LightPanel task
LuckThemAll May 4, 2022
d11b90a
EGE2022_08: Add SignalRockets task
LuckThemAll May 4, 2022
24aacbe
EGE2022_08: Add WordsWithRestrictions task
LuckThemAll May 4, 2022
8638ce6
EGE2022_08: Add LetterCombinatorics task
LuckThemAll May 4, 2022
cc235c8
EGE2022_08: Add WordEncoding tasks
LuckThemAll May 4, 2022
fb5e92e
EGE2022_08: Refactor
LuckThemAll May 4, 2022
6031ed8
EGE2022_08: Update WordEncoding task
LuckThemAll May 4, 2022
1213722
EGE2022_08: Update WordEncoding task
LuckThemAll May 4, 2022
c6d0509
EGE2022_08: Refactor
LuckThemAll May 4, 2022
6adda5f
EGE2022_08: Revert gen.py
LuckThemAll May 4, 2022
56544c9
EGE2022_08: Refactor
LuckThemAll May 4, 2022
02320c9
EGE2022_08: Fix shanon tasks
LuckThemAll May 4, 2022
aaa4461
EGE2022_08: Refactor
LuckThemAll May 4, 2022
a3edd26
EGE2022_08: Fix comments
LuckThemAll May 5, 2022
fb048fd
EGE2022_08: Rename file with generators. Add generators call in gen.py
tonichoff May 5, 2022
85170d6
EGE2022_08: Remove brackets from text in WordCount2 problem
tonichoff May 5, 2022
0844428
Merge branch 'EGE2022_08' into dev
tonichoff May 5, 2022
0b06149
Add new gen_2022.py file for EGE2022 problems
tonichoff May 5, 2022
0bf2699
EGE2022_18: Add base for RobotExecuter problem
tonichoff May 17, 2022
13b823a
EGE2022_18: Add answer calculating for RobotExecuter
tonichoff May 18, 2022
20730f1
EGE2022_18: Add RobotExecuter generator
tonichoff May 18, 2022
6af3266
Merge branch 'EGE2022_18_RobotExecuter' into dev
tonichoff May 18, 2022
ccc2465
RussianModules: Add num_times and num_stones methods in NumText
tonichoff May 8, 2022
e93bb05
EGE2022: Add base for HeapGame based problems
tonichoff May 8, 2022
c3b6a3a
EGE2022: Fix names generation in HeapGame based problems
tonichoff May 8, 2022
4f657c3
EGE2022_19: Add N19 problem for one heap game
tonichoff May 8, 2022
ddf34d1
EGE2022: Add base for TwoHeapGame based problems. Remake OneHeapGame …
tonichoff May 14, 2022
fcc2836
EGE2022_19: Add N19 problem for two heap game
tonichoff May 14, 2022
8e5dc2c
EGE2022_19: Add MinimalHeapSize problem generator
tonichoff May 18, 2022
2ae71dd
Merge branch 'WinStrategy' into dev
tonichoff May 18, 2022
f2e66fd
EGE2022_24: Add problems about files containing three different symbols
tonichoff May 22, 2022
d8f57e7
Merge branch 'EGE2022_24' into dev
tonichoff May 22, 2022
7d351e8
EGE2022_17: Add positive integer number processing problems
tonichoff May 23, 2022
b230080
Merge branch 'EGE2022_17' into dev
tonichoff May 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ t.xhtml
t.py
.venv
.idea
.vs
Binary file added EGE/Extra Files/ER-db.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
220 changes: 220 additions & 0 deletions EGE/Gen/EGE2022/HeapProblem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
from ...GenBase import DirectInput
from ...Russian import join_comma_and, alphabet
from ...RussianModules import Names, NumText

class Operation:
def __init__(self, value: int = 1):
self.value = value

class OneSideOperation(Operation):
def execute(self, lhs: int):
return eval(f"{lhs}{self.operator}{self.value}")

class TwoSideOperation(Operation):
def execute(self, lhs: int, rhs: int):
return eval(f"{lhs}{self.operator}{rhs}")

class Add(OneSideOperation):
def __init__(self, value: int = 1):
super().__init__(value)
self.operator = '+'

def __str__(self) -> str:
str_value = NumText.num_by_words(self.value, 0)
stone_word = NumText.num_stones(self.value).split()[1]
return f"добавить в кучу {str_value} {stone_word}"

class Remove(OneSideOperation):
def __init__(self, value: int = 1):
super().__init__(value)
self.operator = '-'

def __str__(self) -> str:
str_value = NumText.num_by_words(self.value, 0)
stone_word = NumText.num_stones(self.value).split()[1]
return f"убрать из кучи {str_value} {stone_word}"

class Multiply(OneSideOperation):
def __init__(self, value: int = 1):
super().__init__(value)
self.operator = '*'

def __str__(self) -> str:
str_value = NumText.num_by_words(self.value, 0)
times = NumText.num_times(self.value).split()[1]
return f"увеличить количество камней в куче в {str_value} {times}"

class AddOther(TwoSideOperation):
def __init__(self):
super().__init__()
self.operator = '+'

def __str__(self) -> str:
return "добавить столько камней, сколько их в данный момент в другой куче"

class Move:
def __init__(self, operations) -> None:
self.operations = operations

def __str__(self) -> str:
return join_comma_and([str(op) for op in self.operations])

def make(self, lhs: int, rhs: int = None) -> int:
for operation in self.operations:
if isinstance(operation, OneSideOperation):
lhs = operation.execute(lhs)
elif isinstance(operation, TwoSideOperation):
if rhs is None:
rhs = 0
lhs = operation.execute(lhs, rhs)
return lhs

class HeapProblem(DirectInput):
def _generate_game(self):
self._generate_names()
self._generate_moves()
self._generate_final_size()

def _generate_names(self) -> list:
names = self.rnd.pick_n(2, self.rnd.shuffle(Names.male + Names.female))
self.first_player = names[0]
self.second_player = names[1]

def _generate_text(self):
self.text = self._get_intro_statement()
self.text += " " + self._get_move_statement()
self.text += " " + self._get_example_statement()
self.text += " У каждого игрока, чтобы делать ходы, есть неограниченное количество камней."
self.text += " " + self._get_end_statement()
self.text += self._get_win_statement()
self.text += self._get_strategy_statement()
self.text += self._get_task_statement()

def _get_strategy_statement(self) -> str:
return """
Будем говорить, что игрок имеет выигрышную стратегию, если он может выиграть при любых ходах противника.
Описать стратегию игрока — значит, описать, какой ход он должен сделать в любой ситуации, которая
ему может встретиться при различной игре противника. В описание выигрышной стратегии <b>не следует</b>
включать ходы играющего по этой стратегии игрока, не являющиеся для него безусловно выигрышными,
т.е. не являющиеся выигрышными независимо от игры противника.
"""

class OneHeapPoblem(HeapProblem):
def _generate_final_size(self):
self.final_size = self.rnd.in_range(28, 76)

def _generate_moves(self) -> list:
self.moves = [ Move([ Add(1) ]) ]
type = self.rnd.get(4)
if type == 0:
self.moves.append(Move([ Add(self.rnd.in_range(2, 5))]))
self.moves.append(Move([ Multiply(self.rnd.in_range(2, 5))]))
elif type == 1:
self.moves.append(Move([ Multiply(self.rnd.in_range(2, 5))]))
elif type == 2:
self.moves.append(Move([
Multiply(self.rnd.in_range(2, 3)),
Remove(self.rnd.in_range(1, 4))
]))
elif type == 3:
self.moves.append(Move([
Multiply(self.rnd.in_range(2, 3)),
Add(self.rnd.in_range(1, 4))
]))

def _get_intro_statement(self) -> str:
return f"""
Два игрока, {self.first_player} и {self.second_player}, играют в следующую игру. Перед игроками лежит куча камней.
Игроки ходят по очереди, первый ход делает {self.first_player}."""

def _get_move_statement(self) -> str:
statement = "За один ход игрок может: "
statements_number = len(self.moves)
for i in range(statements_number):
statement += f"<p><b>{self.moves[i]} (действие {alphabet[i]})</b>"
if i < statements_number - 1:
statement += " или"
elif i == statements_number - 1:
statement += "."
statement += "</p>"
return statement

def _get_example_statement(self) -> str:
example_count = self.rnd.in_range(10, 15)
heap_str = join_comma_and([ str(move.make(example_count)) for move in self.moves ])
return f"""
Например, имея кучу из {example_count} камней, за один ход можно получить кучу из {heap_str} камней."""

def _get_end_statement(self) -> str:
return f"""
Игра завершается в тот момент, когда количество камней в куче становится не менее {self.final_size}."""

def _get_win_statement(self) -> str:
return f"""
Победителем считается игрок, сделавший последний ход, т.е. первым получивший кучу, в которой будет
{self.final_size} или больше камней. В начальный момент в куче было S камней; 1 &lt;= S &lt;= {self.final_size - 1}."""

class TwoHeapProblem(HeapProblem):
def _generate_game(self):
super()._generate_game()
self.first_heap_size = self.rnd.in_range(2, 27)

def _generate_final_size(self):
self.final_size = self.rnd.in_range(28, 76)

def _generate_moves(self) -> list:
self.moves = [ Move([ Add(1) ]) ]
type = self.rnd.get(2)
if type == 0:
self.moves.append(Move([ Multiply(self.rnd.in_range(2, 4))]))
elif type == 1:
self.moves.append(Move([ AddOther() ]))

def _get_intro_statement(self) -> str:
return f"""
Два игрока, {self.first_player} и {self.second_player}, играют в следующую игру. Перед лежит дву кучи камней.
Игроки ходят по очереди, первый ход делает {self.first_player}."""

def _get_move_statement(self) -> str:
statement = "За один ход игрок может в одной из куч (по своему выбору): "
statements_number = len(self.moves)
for i in range(statements_number):
statement += f"<p><b>{self.moves[i]} (действие {alphabet[i]})</b>"
if i < statements_number - 1:
statement += " или"
elif i == statements_number - 1:
statement += "."
statement += "</p>"
return statement

def _get_example_statement(self) -> str:
example_heaps = [ self.rnd.in_range(10, 15), self.rnd.in_range(10, 15) ]
example_stone_words = [ NumText.num_stones(heap).split()[1] for heap in example_heaps ]

start_pos = f"({example_heaps[0]}, {example_heaps[1]})"

statement = f"""
Например, пусть в одной из куч {example_heaps[0]} {example_stone_words[0]}, а в другой
{example_heaps[1]} {example_stone_words[1]}; такую позицию мы будем обозначать {start_pos}.
За один ход из позиции {start_pos} можно получить любую из четырёх позиций: """

positions = []
indices = range(2)
for heap_number in indices:
for move in self.moves:
new_position = [ example_heaps[i] for i in indices ]
new_position[heap_number] = move.make(new_position[heap_number], new_position[(heap_number + 1) % 2])
positions.append(new_position)

statement += ', '.join([ '(' + str(p[0]) + ', ' + str(p[1]) + ')' for p in positions]) + '.'
return statement

def _get_end_statement(self) -> str:
return f"""
Игра завершается в тот момент, когда суммарное количество камней в кучах становится не менее {self.final_size}."""

def _get_win_statement(self) -> str:
return f"""
Победителем считается игрок, сделавший последний ход, то есть первым получивший позицию, в которой в кучах будет {self.final_size} или больше камней.
В начальный момент в первой куче было {self.first_heap_size} камней, во второй куче — S камней; 1 &lt;= S &lt;= {self.final_size - 1}."""

Loading