diff --git a/.cgtest.full.php b/.cgtest.full.php index 7fafd382..9c753486 100644 --- a/.cgtest.full.php +++ b/.cgtest.full.php @@ -247,6 +247,7 @@ 'easy_com_are-the-clumps-normal', 'easy_com_artificial-emotional-intelligence', 'easy_com_ascii-art-the-drunken-bishop-algorithm', + 'easy_com_ascii-worms', 'easy_com_asteroids', 'easy_com_auto-pickup', 'easy_com_balanced-ternary-computer-encode', @@ -319,6 +320,7 @@ 'easy_com_graffiti-on-the-fence', 'easy_com_happy-numbers', 'easy_com_hidden-messages-in-images', + 'easy_com_histogram', 'easy_com_hooch-clash', 'easy_com_horse-racing-hyperduals', 'easy_com_how-high-up-does-the-beer-go', @@ -497,6 +499,7 @@ 'medium_com_ascii-art-with-logo-language-part-2', 'medium_com_ascii-cube', 'medium_com_ascii-graph', + 'medium_com_ascii-snakes', 'medium_com_assignments-are-boring', 'medium_com_a-coin-guessing-game', 'medium_com_a-story-to-go-in-circles', @@ -1078,4 +1081,4 @@ ], ], ]; -// Note: last puzzle added on 24.06.24: 'hard_com_simple-pascal-pl0-compiler', +// Note: last puzzle added on 24.07.09: 'easy_com_histogram', diff --git a/.tests/expected/easy_com_ascii-worms_e01.txt b/.tests/expected/easy_com_ascii-worms_e01.txt new file mode 100644 index 00000000..fe988f56 --- /dev/null +++ b/.tests/expected/easy_com_ascii-worms_e01.txt @@ -0,0 +1,6 @@ + __ _____ _____ +| | | | +| | | | | | +| | | | | | +| | | | | | +|_____|_____|__| diff --git a/.tests/expected/easy_com_ascii-worms_e02.txt b/.tests/expected/easy_com_ascii-worms_e02.txt new file mode 100644 index 00000000..4d0dfbc5 --- /dev/null +++ b/.tests/expected/easy_com_ascii-worms_e02.txt @@ -0,0 +1,3 @@ + _ ___ +| | | +|___|_| diff --git a/.tests/expected/easy_com_ascii-worms_e03.txt b/.tests/expected/easy_com_ascii-worms_e03.txt new file mode 100644 index 00000000..bfe3d69f --- /dev/null +++ b/.tests/expected/easy_com_ascii-worms_e03.txt @@ -0,0 +1,9 @@ + _____ ___________ ___________ +| | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +|___________|___________|_____| diff --git a/.tests/expected/easy_com_ascii-worms_e04.txt b/.tests/expected/easy_com_ascii-worms_e04.txt new file mode 100644 index 00000000..d610344a --- /dev/null +++ b/.tests/expected/easy_com_ascii-worms_e04.txt @@ -0,0 +1,16 @@ + _ ___ ___ ___ ___ ___ ___ ___ _ +| | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | +|___|___|___|___|___|___|___|___| diff --git a/.tests/expected/easy_com_histogram_e01.txt b/.tests/expected/easy_com_histogram_e01.txt new file mode 100644 index 00000000..c2754bad --- /dev/null +++ b/.tests/expected/easy_com_histogram_e01.txt @@ -0,0 +1,53 @@ + +----------------------------------------------------------------------------------------------------+ +A | |100.00% + +----------------------------------------------------------------------------------------------------+ +B |0.00% + + +C |0.00% + + +D |0.00% + + +E |0.00% + + +F |0.00% + + +G |0.00% + + +H |0.00% + + +I |0.00% + + +J |0.00% + + +K |0.00% + + +L |0.00% + + +M |0.00% + + +N |0.00% + + +O |0.00% + + +P |0.00% + + +Q |0.00% + + +R |0.00% + + +S |0.00% + + +T |0.00% + + +U |0.00% + + +V |0.00% + + +W |0.00% + + +X |0.00% + + +Y |0.00% + + +Z |0.00% + + diff --git a/.tests/expected/easy_com_histogram_e02.txt b/.tests/expected/easy_com_histogram_e02.txt new file mode 100644 index 00000000..fe785083 --- /dev/null +++ b/.tests/expected/easy_com_histogram_e02.txt @@ -0,0 +1,53 @@ + +----+ +A | |3.85% + +----+ +B | |3.85% + +----+ +C | |3.85% + +----+ +D | |3.85% + +----+ +E | |3.85% + +----+ +F | |3.85% + +----+ +G | |3.85% + +----+ +H | |3.85% + +----+ +I | |3.85% + +----+ +J | |3.85% + +----+ +K | |3.85% + +----+ +L | |3.85% + +----+ +M | |3.85% + +----+ +N | |3.85% + +----+ +O | |3.85% + +----+ +P | |3.85% + +----+ +Q | |3.85% + +----+ +R | |3.85% + +----+ +S | |3.85% + +----+ +T | |3.85% + +----+ +U | |3.85% + +----+ +V | |3.85% + +----+ +W | |3.85% + +----+ +X | |3.85% + +----+ +Y | |3.85% + +----+ +Z | |3.85% + +----+ diff --git a/.tests/expected/easy_com_histogram_e03.txt b/.tests/expected/easy_com_histogram_e03.txt new file mode 100644 index 00000000..0eb7a3ca --- /dev/null +++ b/.tests/expected/easy_com_histogram_e03.txt @@ -0,0 +1,53 @@ + +----------+ +A | |10.00% + +----------+ +B |0.00% + +----------+ +C | |10.00% + +----------+ +D | |10.00% + +----------+ +E | |10.00% + +----------+ +F |0.00% + +--------------------+ +G | |20.00% + +--------------------+ +H |0.00% + +----------+ +I | |10.00% + +----------+ +J |0.00% + + +K |0.00% + + +L |0.00% + +----------+ +M | |10.00% + +----------+ +N | |10.00% + +----------+ +O | |10.00% + +----------+ +P |0.00% + + +Q |0.00% + + +R |0.00% + + +S |0.00% + + +T |0.00% + + +U |0.00% + + +V |0.00% + + +W |0.00% + + +X |0.00% + + +Y |0.00% + + +Z |0.00% + + diff --git a/.tests/expected/easy_com_histogram_e04.txt b/.tests/expected/easy_com_histogram_e04.txt new file mode 100644 index 00000000..7b8a77fe --- /dev/null +++ b/.tests/expected/easy_com_histogram_e04.txt @@ -0,0 +1,53 @@ + +--------+ +A | |7.86% + +-+------+ +B | |0.81% + +-+--+ +C | |4.34% + +----++ +D | |5.15% + +-----+----+ +E | |10.30% + +-+--------+ +F | |0.81% + +-+ +G | |0.81% + +-+ +H |0.27% + +-----------+ +I | |11.38% + +-----------+ +J |0.00% + + +K |0.00% + +------+ +L | |5.96% + +-----++ +M | |4.61% + +-----+-+ +N | |6.50% + +-------++ +O | |7.86% + +---+----+ +P | |2.98% + +-+-+ +Q | |1.36% + +-+----+ +R | |5.96% + +-----++ +S | |4.88% + +-----+---+ +T | |8.67% + +--------++ +U | |7.86% + +-+------+ +V | |0.81% + +-+ +W |0.00% + +-+ +X | |0.81% + +-+ +Y |0.00% + + +Z |0.00% + + diff --git a/.tests/expected/medium_com_ascii-snakes_e01.txt b/.tests/expected/medium_com_ascii-snakes_e01.txt new file mode 100644 index 00000000..95e2350a --- /dev/null +++ b/.tests/expected/medium_com_ascii-snakes_e01.txt @@ -0,0 +1,8 @@ ++-+ +| | +| +-----+ ++-----+ | + +--+ | + | +--+ + | | + +-+ diff --git a/.tests/expected/medium_com_ascii-snakes_e02.txt b/.tests/expected/medium_com_ascii-snakes_e02.txt new file mode 100644 index 00000000..23bbe218 --- /dev/null +++ b/.tests/expected/medium_com_ascii-snakes_e02.txt @@ -0,0 +1,8 @@ ++-++----+ +| || ++ | +| || || | +| || || | +| || || | +| || || | +| ++ || | ++----++-+ diff --git a/.tests/expected/medium_com_ascii-snakes_e03.txt b/.tests/expected/medium_com_ascii-snakes_e03.txt new file mode 100644 index 00000000..86f8dac2 --- /dev/null +++ b/.tests/expected/medium_com_ascii-snakes_e03.txt @@ -0,0 +1,8 @@ ++-+ +-------+ +| | +-----+ | +| |+-------+| | +| || +---+ || | +| ++ |+--+ || | ++----+| +--+| | + | +---+ | + +-------+ diff --git a/.tests/expected/medium_com_ascii-snakes_e04.txt b/.tests/expected/medium_com_ascii-snakes_e04.txt new file mode 100644 index 00000000..6043a893 --- /dev/null +++ b/.tests/expected/medium_com_ascii-snakes_e04.txt @@ -0,0 +1,10 @@ ++-+ +----+ +| | | ++ | +| | +--------+ || +-----+ +| | | +--------++-----+ | +| | | +--++-----------+ | +| | +--+ || +-----------+ +| |+----+| || |+-------+ +| || ++ || || || +---+ | +| ++ || ++ || ++ | | +--+ ++----++----++----+ +----+ diff --git a/.tests/input/easy_com_ascii-worms_i01.txt b/.tests/input/easy_com_ascii-worms_i01.txt new file mode 100644 index 00000000..6ec87485 --- /dev/null +++ b/.tests/input/easy_com_ascii-worms_i01.txt @@ -0,0 +1,3 @@ +2 +5 +4 diff --git a/.tests/input/easy_com_ascii-worms_i02.txt b/.tests/input/easy_com_ascii-worms_i02.txt new file mode 100644 index 00000000..2ca3cd52 --- /dev/null +++ b/.tests/input/easy_com_ascii-worms_i02.txt @@ -0,0 +1,3 @@ +1 +2 +2 diff --git a/.tests/input/easy_com_ascii-worms_i03.txt b/.tests/input/easy_com_ascii-worms_i03.txt new file mode 100644 index 00000000..ce1fb854 --- /dev/null +++ b/.tests/input/easy_com_ascii-worms_i03.txt @@ -0,0 +1,3 @@ +5 +8 +4 diff --git a/.tests/input/easy_com_ascii-worms_i04.txt b/.tests/input/easy_com_ascii-worms_i04.txt new file mode 100644 index 00000000..a577c5f5 --- /dev/null +++ b/.tests/input/easy_com_ascii-worms_i04.txt @@ -0,0 +1,3 @@ +1 +15 +15 diff --git a/.tests/input/easy_com_histogram_i01.txt b/.tests/input/easy_com_histogram_i01.txt new file mode 100644 index 00000000..f70f10e4 --- /dev/null +++ b/.tests/input/easy_com_histogram_i01.txt @@ -0,0 +1 @@ +A diff --git a/.tests/input/easy_com_histogram_i02.txt b/.tests/input/easy_com_histogram_i02.txt new file mode 100644 index 00000000..2f811561 --- /dev/null +++ b/.tests/input/easy_com_histogram_i02.txt @@ -0,0 +1 @@ +A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. diff --git a/.tests/input/easy_com_histogram_i03.txt b/.tests/input/easy_com_histogram_i03.txt new file mode 100644 index 00000000..909f24a0 --- /dev/null +++ b/.tests/input/easy_com_histogram_i03.txt @@ -0,0 +1 @@ +Coding game diff --git a/.tests/input/easy_com_histogram_i04.txt b/.tests/input/easy_com_histogram_i04.txt new file mode 100644 index 00000000..1b376877 --- /dev/null +++ b/.tests/input/easy_com_histogram_i04.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/.tests/input/event_winter-challenge-2023-q03_i04.txt b/.tests/input/event_winter-challenge-2023-q03_i04.txt index d646394f..7257b6fb 100644 --- a/.tests/input/event_winter-challenge-2023-q03_i04.txt +++ b/.tests/input/event_winter-challenge-2023-q03_i04.txt @@ -1,2 +1,2 @@ -[[5,6,3,7,7,5,7,1,7,1],[1,3,2,5,2,6,4,3,4,0],[2,5,1,0,0,4,6,5,5,4],[6,2,6,6,0,4,4,5,3,2],[3,7,7,6,5,4,6,6,4,7],[5,3,4,2,2,6,2,0,3,5],[3,6,7,0,6,1,1,1,3,6],[7,6,3,4,5,7,1,4,0,2],[2,2,6,6,2,2,4,1,7,5],[2,4,6,7,4,5,2,1,7,3]] -[{"pattern":[4,4,0,3],"result":7},{"pattern":[5,5,4,1],"result":6},{"pattern":[3,2,2,5],"result":1},{"pattern":[5,7,4,0],"result":6},{"pattern":[0,7,2,7],"result":1},{"pattern":[7,4,7,6],"result":1},{"pattern":[1,1,6,3],"result":5},{"pattern":[4,5,6,6],"result":6},{"pattern":[0,0,2,4],"result":3},{"pattern":[2,6,1,3],"result":6},{"pattern":[0,1,3,7],"result":3},{"pattern":[5,5,6,3],"result":7},{"pattern":[2,7,0,7],"result":4},{"pattern":[2,4,0,0],"result":0},{"pattern":[4,5,3,7],"result":1},{"pattern":[6,7,6,6],"result":7},{"pattern":[2,0,3,7],"result":2},{"pattern":[6,1,6,0],"result":7},{"pattern":[5,2,4,2],"result":0},{"pattern":[7,0,4,3],"result":6},{"pattern":[1,1,1,7],"result":5},{"pattern":[1,4,1,0],"result":6},{"pattern":[4,2,0,5],"result":0},{"pattern":[4,6,4,1],"result":6},{"pattern":[7,1,0,7],"result":6},{"pattern":[2,4,5,5],"result":7},{"pattern":[7,4,2,4],"result":2},{"pattern":[1,6,6,6],"result":1},{"pattern":[0,4,3,7],"result":1},{"pattern":[6,6,7,1],"result":4},{"pattern":[6,4,1,6],"result":1},{"pattern":[7,5,7,3],"result":4},{"pattern":[7,2,0,1],"result":6},{"pattern":[2,1,3,2],"result":3},{"pattern":[6,0,4,7],"result":0},{"pattern":[2,0,6,1],"result":7},{"pattern":[6,0,0,6],"result":4},{"pattern":[3,2,0,2],"result":6},{"pattern":[7,0,2,7],"result":5},{"pattern":[1,2,5,7],"result":2},{"pattern":[6,4,4,6],"result":0},{"pattern":[5,6,1,3],"result":7},{"pattern":[7,1,1,6],"result":7},{"pattern":[0,1,1,4],"result":2},{"pattern":[6,5,1,1],"result":5},{"pattern":[6,0,7,3],"result":5},{"pattern":[5,3,3,6],"result":1},{"pattern":[2,1,4,2],"result":7},{"pattern":[3,1,4,4],"result":1},{"pattern":[3,4,6,7],"result":6},{"pattern":[3,2,4,7],"result":4},{"pattern":[3,1,7,7],"result":0},{"pattern":[6,6,1,2],"result":4},{"pattern":[5,5,3,1],"result":0},{"pattern":[0,1,0,1],"result":0},{"pattern":[0,2,1,3],"result":1},{"pattern":[2,5,2,5],"result":4},{"pattern":[4,5,4,5],"result":4},{"pattern":[5,3,0,5],"result":2},{"pattern":[0,2,6,7],"result":3},{"pattern":[4,7,2,3],"result":4},{"pattern":[0,1,3,5],"result":4},{"pattern":[6,3,0,3],"result":0},{"pattern":[3,4,7,3],"result":4},{"pattern":[6,4,0,3],"result":2},{"pattern":[6,2,1,0],"result":5},{"pattern":[0,5,6,0],"result":1},{"pattern":[5,1,0,1],"result":1},{"pattern":[4,0,1,3],"result":1},{"pattern":[3,1,5,1],"result":1},{"pattern":[2,2,6,2],"result":2},{"pattern":[2,5,1,0],"result":3},{"pattern":[7,2,5,0],"result":2},{"pattern":[4,2,2,2],"result":0},{"pattern":[5,4,7,3],"result":0},{"pattern":[1,3,5,2],"result":1},{"pattern":[6,7,1,7],"result":1},{"pattern":[0,2,4,4],"result":1},{"pattern":[3,3,2,4],"result":6},{"pattern":[1,0,4,1],"result":7},{"pattern":[4,0,7,3],"result":6},{"pattern":[6,6,2,7],"result":6},{"pattern":[5,1,7,2],"result":6},{"pattern":[1,1,1,5],"result":2},{"pattern":[6,0,7,6],"result":6},{"pattern":[7,0,3,4],"result":2},{"pattern":[4,4,3,1],"result":5},{"pattern":[4,5,4,7],"result":1},{"pattern":[6,7,2,5],"result":2},{"pattern":[2,2,4,7],"result":7},{"pattern":[5,2,2,1],"result":5},{"pattern":[3,1,1,7],"result":4},{"pattern":[1,4,3,7],"result":1},{"pattern":[7,4,3,6],"result":7},{"pattern":[0,7,2,4],"result":2},{"pattern":[2,2,6,4],"result":0},{"pattern":[2,6,3,1],"result":0},{"pattern":[5,6,1,1],"result":3},{"pattern":[6,3,5,3],"result":6},{"pattern":[7,1,1,3],"result":2},{"pattern":[0,0,5,6],"result":5},{"pattern":[6,7,4,4],"result":2},{"pattern":[3,0,7,6],"result":4},{"pattern":[6,2,0,4],"result":1},{"pattern":[0,2,5,5],"result":1},{"pattern":[2,2,7,1],"result":0},{"pattern":[4,5,7,2],"result":1},{"pattern":[7,4,4,1],"result":6},{"pattern":[6,2,0,7],"result":0},{"pattern":[7,0,3,1],"result":1},{"pattern":[1,1,0,6],"result":3},{"pattern":[2,6,5,4],"result":5},{"pattern":[4,5,1,7],"result":7},{"pattern":[5,5,3,7],"result":0},{"pattern":[1,5,4,1],"result":6},{"pattern":[7,0,4,4],"result":7},{"pattern":[7,1,7,7],"result":6},{"pattern":[... +[[1,0,4,1,4,7],[5,4,3,3,7,0],[1,0,5,2,7,6],[2,0,1,7,2,1],[3,2,0,5,1,2],[4,7,0,6,4,0]] +[{"pattern":[4,7,7,0],"result":7},{"pattern":[1,0,2,0],"result":5},{"pattern":[4,3,0,5],"result":7},{"pattern":[1,7,0,5],"result":7},{"pattern":[1,0,5,4],"result":2},{"pattern":[0,4,4,3],"result":3},{"pattern":[3,3,5,2],"result":7},{"pattern":[2,0,7,0],"result":7},{"pattern":[0,5,0,1],"result":4},{"pattern":[2,7,7,2],"result":3},{"pattern":[4,1,3,3],"result":2},{"pattern":[5,2,1,7],"result":7},{"pattern":[7,2,5,1],"result":4},{"pattern":[2,0,3,2],"result":3},{"pattern":[3,2,4,7],"result":1},{"pattern":[1,2,4,0],"result":7},{"pattern":[5,1,6,4],"result":7}] diff --git a/.tests/input/event_winter-challenge-2023-q03_i05.txt b/.tests/input/event_winter-challenge-2023-q03_i05.txt index 00e95ce7..7257b6fb 100644 --- a/.tests/input/event_winter-challenge-2023-q03_i05.txt +++ b/.tests/input/event_winter-challenge-2023-q03_i05.txt @@ -1,2 +1,2 @@ -[[3,1,0,5,7,0,7,2,2,2,5,2],[2,7,7,6,4,3,5,3,2,5,2,4],[7,6,0,1,1,3,7,2,2,6,1,7],[5,2,6,1,1,5,3,5,5,5,5,7],[6,2,1,5,5,6,1,0,3,5,4,6],[0,7,2,7,1,6,6,0,0,6,0,3],[1,4,6,2,7,2,3,1,4,1,6,4],[6,3,0,5,7,7,3,3,6,1,0,1],[1,1,3,6,3,1,6,6,1,6,4,2],[3,6,1,6,0,1,1,2,6,5,3,4],[3,5,1,6,0,3,2,2,0,7,0,3],[0,7,2,7,0,2,4,4,4,5,3,5]] -[{"pattern":[1,6,1,1],"result":6},{"pattern":[0,1,4,2],"result":2},{"pattern":[3,6,1,6],"result":3},{"pattern":[1,6,7,2],"result":2},{"pattern":[1,5,2,7],"result":7},{"pattern":[0,5,7,6],"result":3},{"pattern":[4,6,3,0],"result":0},{"pattern":[0,3,6,4],"result":0},{"pattern":[6,6,1,2],"result":7},{"pattern":[7,6,0,1],"result":4},{"pattern":[6,5,0,7],"result":2},{"pattern":[7,0,4,3],"result":5},{"pattern":[3,7,5,3],"result":0},{"pattern":[6,0,3,1],"result":4},{"pattern":[2,6,2,1],"result":5},{"pattern":[2,6,5,5],"result":3},{"pattern":[0,1,6,1],"result":5},{"pattern":[0,1,0,3],"result":6},{"pattern":[1,2,2,2],"result":0},{"pattern":[1,3,1,5],"result":7},{"pattern":[2,3,7,3],"result":4},{"pattern":[1,4,6,3],"result":7},{"pattern":[6,4,5,3],"result":2},{"pattern":[1,1,3,6],"result":1},{"pattern":[0,3,0,2],"result":7},{"pattern":[7,2,3,5],"result":1},{"pattern":[3,5,0,6],"result":5},{"pattern":[2,0,4,4],"result":2},{"pattern":[3,5,1,0],"result":2},{"pattern":[0,7,3,5],"result":6},{"pattern":[6,4,1,1],"result":5},{"pattern":[6,4,0,1],"result":1},{"pattern":[5,5,0,3],"result":3},{"pattern":[2,4,1,7],"result":4},{"pattern":[6,1,5,5],"result":4},{"pattern":[4,3,1,3],"result":6},{"pattern":[3,6,6,1],"result":7},{"pattern":[0,6,4,1],"result":6},{"pattern":[1,5,5,6],"result":0},{"pattern":[3,1,3,3],"result":5},{"pattern":[5,7,6,3],"result":3},{"pattern":[7,1,2,7],"result":1},{"pattern":[2,7,6,2],"result":0},{"pattern":[1,1,1,1],"result":6},{"pattern":[5,5,3,5],"result":4},{"pattern":[7,6,5,2],"result":3},{"pattern":[0,0,1,4],"result":5},{"pattern":[1,6,2,7],"result":5},{"pattern":[3,5,0,7],"result":3},{"pattern":[6,0,1,6],"result":7},{"pattern":[7,2,5,3],"result":7},{"pattern":[6,1,1,5],"result":6},{"pattern":[6,2,0,5],"result":1},{"pattern":[1,1,3,2],"result":7},{"pattern":[7,2,7,7],"result":3},{"pattern":[6,0,6,0],"result":5},{"pattern":[1,4,3,6],"result":6},{"pattern":[5,2,6,2],"result":4},{"pattern":[1,6,1,0],"result":0},{"pattern":[2,7,7,6],"result":2},{"pattern":[5,3,7,2],"result":0},{"pattern":[3,5,3,7],"result":7},{"pattern":[7,7,3,1],"result":4},{"pattern":[2,5,5,2],"result":2},{"pattern":[1,7,5,7],"result":5},{"pattern":[6,1,5,1],"result":3},{"pattern":[6,2,0,7],"result":5},{"pattern":[1,0,6,0],"result":3},{"pattern":[0,3,0,0],"result":4},{"pattern":[6,0,2,6],"result":4},{"pattern":[5,7,6,4],"result":4},{"pattern":[1,0,7,7],"result":2},{"pattern":[5,5,7,1],"result":0},{"pattern":[4,1,6,1],"result":7},{"pattern":[5,3,6,1],"result":1},{"pattern":[5,2,2,4],"result":3},{"pattern":[2,5,2,6],"result":2},{"pattern":[4,2,3,4],"result":3},{"pattern":[3,3,6,6],"result":6},{"pattern":[4,6,0,3],"result":7},{"pattern":[1,6,1,6],"result":4},{"pattern":[1,1,5,5],"result":7},{"pattern":[3,4,0,3],"result":4},{"pattern":[6,1,1,6],"result":0},{"pattern":[2,1,7,2],"result":6},{"pattern":[1,0,6,4],"result":1},{"pattern":[0,7,4,5],"result":3},{"pattern":[6,1,2,6],"result":0},{"pattern":[5,3,7,0],"result":3},{"pattern":[1,3,6,1],"result":2},{"pattern":[2,2,5,5],"result":2},{"pattern":[0,3,3,5],"result":5},{"pattern":[7,3,1,6],"result":5},{"pattern":[0,7,1,4],"result":6},{"pattern":[0,5,3,6],"result":2},{"pattern":[2,7,5,7],"result":2},{"pattern":[3,2,2,2],"result":1},{"pattern":[2,2,3,2],"result":0},{"pattern":[7,0,5,3],"result":4},{"pattern":[5,4,6,0],"result":6},{"pattern":[6,6,2,3],"result":3},{"pattern":[3,0,1,3],"result":1},{"pattern":[3,1,2,7],"result":1},{"pattern":[5,6,1,6],"result":1},{"pattern":[7,2,4,6],"result":7},{"pattern":[5,1,7,2],"result":4},{"pattern":[1,6,6,5],"result":1},{"pattern":[2,2,4,4],"result":1},{"pattern":[5,7,4,6],"result":6},{"pattern":[3,1,0,1],"result":5},{"pattern":[6,1,6,6],"result":2},{"pattern":[7,7,6,0],"result":3},{"pattern":[6,3,6,0],"result":4},{"pattern":[3,2,2,4],"result":0},{"pattern":[2,6,2,0... +[[1,0,4,1,4,7],[5,4,3,3,7,0],[1,0,5,2,7,6],[2,0,1,7,2,1],[3,2,0,5,1,2],[4,7,0,6,4,0]] +[{"pattern":[4,7,7,0],"result":7},{"pattern":[1,0,2,0],"result":5},{"pattern":[4,3,0,5],"result":7},{"pattern":[1,7,0,5],"result":7},{"pattern":[1,0,5,4],"result":2},{"pattern":[0,4,4,3],"result":3},{"pattern":[3,3,5,2],"result":7},{"pattern":[2,0,7,0],"result":7},{"pattern":[0,5,0,1],"result":4},{"pattern":[2,7,7,2],"result":3},{"pattern":[4,1,3,3],"result":2},{"pattern":[5,2,1,7],"result":7},{"pattern":[7,2,5,1],"result":4},{"pattern":[2,0,3,2],"result":3},{"pattern":[3,2,4,7],"result":1},{"pattern":[1,2,4,0],"result":7},{"pattern":[5,1,6,4],"result":7}] diff --git a/.tests/input/medium_com_ascii-snakes_i01.txt b/.tests/input/medium_com_ascii-snakes_i01.txt new file mode 100644 index 00000000..f681861e --- /dev/null +++ b/.tests/input/medium_com_ascii-snakes_i01.txt @@ -0,0 +1 @@ +DRRDLD diff --git a/.tests/input/medium_com_ascii-snakes_i02.txt b/.tests/input/medium_com_ascii-snakes_i02.txt new file mode 100644 index 00000000..6ae3f231 --- /dev/null +++ b/.tests/input/medium_com_ascii-snakes_i02.txt @@ -0,0 +1 @@ +DDDRUUURDDD diff --git a/.tests/input/medium_com_ascii-snakes_i03.txt b/.tests/input/medium_com_ascii-snakes_i03.txt new file mode 100644 index 00000000..2cf3dad1 --- /dev/null +++ b/.tests/input/medium_com_ascii-snakes_i03.txt @@ -0,0 +1 @@ +DDRURRDLDRRUUULL diff --git a/.tests/input/medium_com_ascii-snakes_i04.txt b/.tests/input/medium_com_ascii-snakes_i04.txt new file mode 100644 index 00000000..bee2435a --- /dev/null +++ b/.tests/input/medium_com_ascii-snakes_i04.txt @@ -0,0 +1 @@ +DDDDRURDRUULURRRURDRRDLLLLDDRURRDR diff --git a/CHANGELOG.md b/CHANGELOG.md index 2db83bc0..4314c471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- More test cases added. -- `note` configuration option added to the per language section. +- Nothing yet. ### Changed @@ -20,6 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nothing yet. +## [v1.16.0](https://github.com/tbali0524/cgtest/releases/v1.16.0) - 2024-07-20 + +### Added + +- Seperate build and running times are displayed in with `--stats`. Note: some compilers combine build and run steps into a single invocation. +- `note` configuration option added to the per language section. +- Default `dart` and `go` config updated to separate build and run steps. +- More test cases added. + ## [v1.15.0](https://github.com/tbali0524/cgtest/releases/v1.15.0) - 2024-03-09 ### Added diff --git a/README.md b/README.md index 55581e46..f720940e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A multi-language offline batch test runner for `CodinGame` (or other) solo I/O p by Bálint Tóth ([TBali](https://www.codingame.com/profile/08e6e13d9f7cad047d86ec4d10c777500155033)) -_The repository also contains __6100+__ test cases for __810+__ `CodinGame` puzzles and __730+__ puzzle statements._ +_The repository also contains __6300+__ test cases for __860+__ `CodinGame` puzzles and __760+__ puzzle statements._ ## Intro diff --git a/cgtest.php b/cgtest.php index b0036a39..27843358 100644 --- a/cgtest.php +++ b/cgtest.php @@ -18,9 +18,10 @@ // Yes, this is a spaghetti code, I know... Don't look at it. // I wanted a zero-dependency, single file script. // So I skipped using OOP, and - as code repetition is low - even functions. +// And the code grew organically a bit larger than I originally planned. // -------------------------------------------------------------------- // init counters, start global timer -$version = 'v1.16.0-dev'; +$version = 'v1.16.0'; $zeroLanguageStat = [ 'countLanguages' => 0, 'countSkippedLanguages' => 0, @@ -37,12 +38,14 @@ 'countFailedTests' => 0, 'countSkippedTests' => 0, 'countDeletedFiles' => 0, - 'startTime' => 0, - 'spentTime' => 0, + 'startTime' => 0, // hrtime(true) in nanosec + 'timeSpent' => 0, // in microsec + 'timeBuilding' => 0, // in microsec + 'timeRunning' => 0, // in microsec ]; $languageStats = []; $languageStats['totals'] = $zeroLanguageStat; -$languageStats['totals']['startTime'] = hrtime(true); +$languageStats['totals']['startTime'] = intval(hrtime(true)); $languageStats['unique'] = $zeroLanguageStat; $zeroPuzzleStat = [ 'countFailedFiles' => 0, @@ -226,9 +229,9 @@ 'sourceExtension' => '.dart', 'codinGameVersion' => 'Dart SDK version: 2.16.2', 'versionCommand' => 'dart --version', - 'buildCommand' => '', - 'runCommand' => 'dart %s', - 'cleanPatterns' => [], + 'buildCommand' => 'dart compile exe -o %b%p_%l.exe %s', + 'runCommand' => '%b%p_%l.exe', + 'cleanPatterns' => ['%b%p_%l.exe'], ], 'f#' => [ 'sourcePath' => 'f#/', @@ -245,9 +248,9 @@ 'sourceExtension' => '.go', 'codinGameVersion' => 'go version go1.18.1', 'versionCommand' => 'go version', - 'buildCommand' => '', - 'runCommand' => 'go run %s', - 'cleanPatterns' => [], + 'buildCommand' => 'go build -o %b%p_%l.exe %s', + 'runCommand' => '%b%p_%l.exe', + 'cleanPatterns' => ['%b%p_%l.exe'], ], 'groovy' => [ 'sourcePath' => 'groovy/', @@ -1029,7 +1032,7 @@ // main loop: tests run by language foreach ($config['languages'] as $language) { $languageStats[$language] = $zeroLanguageStat; - $languageStats[$language]['startTime'] = hrtime(true); + $languageStats[$language]['startTime'] = intval(hrtime(true)); ++$languageStats[$language]['countLanguages']; if ($noConfig and !$config['lang-versions']) { break; @@ -1442,7 +1445,10 @@ } $execOutput = []; $execResultCode = 0; + $startTime = intval(hrtime(true)); $execResult = exec($buildCommandFull, $execOutput, $execResultCode); + $timeBuilding = intdiv((intval(hrtime(true)) - $startTime), 1000); + $languageStats[$language]['timeBuilding'] += $timeBuilding; if (($execResult === false) or ($execResultCode != 0)) { $buildSuccessful = false; echo $warnTag . 'Build unsuccessful for source: ' @@ -1485,7 +1491,6 @@ $countTestsForFile = 0; $countSkippedTestsForFile = 0; $idxTest = 0; - $spentTimePuzzle = 0; // -------------------------------------------------------------------- // loop: for each test case for the puzzle while (true) { @@ -1619,8 +1624,10 @@ } $execOutput = []; $execResultCode = 0; - $testStartTime = hrtime(true); + $testStartTime = intval(hrtime(true)); $execResult = exec($runCommandFull, $execOutput, $execResultCode); + $timeRunning = intdiv((intval(hrtime(true)) - $testStartTime), 1000); + $languageStats[$language]['timeRunning'] += $timeRunning; if (($execResult === false) or (!is_null($execResultCode) and ($execResultCode != 0))) { echo $errorTag . 'Execution unsuccessful for source: ' . $ansiWarn . $sourceFullFileName . $ansiReset . PHP_EOL; @@ -1629,7 +1636,7 @@ $puzzleStats[$puzzleName]['failedTests'] |= (1 << $idxTest); continue; } - $spentTimeTestCase = (hrtime(true) - $testStartTime) / 1000000000; + $spentTimeTestCase = $timeRunning / 1000000; if ( (($config['slowThreshold'] ?? 0) > 0) and ($spentTimeTestCase >= ($config['slowThreshold'] ?? 0)) @@ -1641,7 +1648,6 @@ 'time' => $spentTimeTestCase, ]; } - $spentTimePuzzle += $spentTimeTestCase; // -------------------------------------------------------------------- // read and process test output (replace CRLF with LF, remove trailing LF) if (!file_exists($outputFullFileName)) { @@ -1723,7 +1729,8 @@ } } } - $languageStats[$language]['spentTime'] = hrtime(true) - $languageStats[$language]['startTime']; + $languageStats[$language]['timeSpent'] = + intdiv(intval(hrtime(true)) - $languageStats[$language]['startTime'], 1000); } // -------------------------------------------------------------------- // process stats per unique puzzle @@ -1760,7 +1767,7 @@ ++$languageStats['unique']['countPassedFiles']; } } -$languageStats['totals']['spentTime'] = hrtime(true) - $languageStats['totals']['startTime']; +$languageStats['totals']['timeSpent'] = intdiv(hrtime(true) - $languageStats['totals']['startTime'], 1000); // -------------------------------------------------------------------- // print slow test runs if ($config['verbose'] and (($config['slowThreshold'] ?? 0) > 0) and (count($slowTests) > 0)) { @@ -1780,22 +1787,22 @@ // -------------------------------------------------------------------- // print per language stats if (!$noConfig and $config['stats'] and ($languageStats['totals']['countLanguages'] > 0)) { - $cleanHeader1 = ''; - $cleanHeader2 = ''; - $cleanHeader3 = ''; + $separator = '-------+------------+------+'; + $header1 = ' | |Direc-|'; + $header2 = ' | Language |tories|'; if ($config['clean']) { - $cleanHeader1 = '-------+'; - $cleanHeader2 = 'Deleted|'; - $cleanHeader3 = ' files |'; + $separator .= '------+------+-------+'; + $header1 .= ' Puzzles |Deleted|'; + $header2 .= ' Total|NoEval| files |'; + } else { + $separator .= '------+------+------+------+------+------+------+------+------+-------+-------+-------+'; + $header1 .= ' Puzzle solutions (source files) | Test cases | Time spent |'; + $header2 .= ' Total|NoEval| Fail | Skip | Lines| Total|NoEval| Fail | Skip | Build | Run | Total |'; } $emptyTag = str_repeat(' ', 7); - $separator = '-------+------------+------+------+------+------+------+------+------+------+------+------+-------+' - . $cleanHeader1; echo $separator . PHP_EOL; - echo ' | |Direc-| Puzzle solutions (source files) | Test cases | |' - . $cleanHeader2 . PHP_EOL; - echo ' | Language |tories| Total|NoEval| Fail | Skip | Lines| Total|NoEval| Fail | Skip | Time |' - . $cleanHeader3 . PHP_EOL; + echo $header1 . PHP_EOL; + echo $header2 . PHP_EOL; echo $separator . PHP_EOL; foreach ($languageStats as $language => $stat) { if (($language == 'totals') or ($language == 'unique')) { @@ -1806,26 +1813,41 @@ } else { $status = $passTag; } - $msgCountDirectories = str_pad(substr(strval($stat['countDirectories']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountFiles = str_pad(substr(strval($stat['countFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountRunOnlyFiles = str_pad(substr(strval($stat['countRunOnlyFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountFailedFiles = str_pad(substr(strval($stat['countFailedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountSkippedFiles = str_pad(substr(strval($stat['countSkippedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountLines = str_pad(substr(strval($stat['countLines']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountTests = str_pad(substr(strval($stat['countTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountRunOnlyTests = str_pad(substr(strval($stat['countRunOnlyTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountFailedTests = str_pad(substr(strval($stat['countFailedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountSkippedTests = str_pad(substr(strval($stat['countSkippedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgTime = str_pad(number_format($stat['spentTime'] / 1000000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT); - $msgCountDeletedFiles = ''; - $msgLanguageSkipped = ''; if ($stat['countSkippedLanguages'] > 0) { $status = $warnTag; - $msgLanguageSkipped = $ansiYellow . ' skipped.' . $ansiReset; + $msgLanguageSkipped = $ansiYellow . 'skip' . $ansiReset; + } else { + $msgLanguageSkipped = ''; } + $msgCountDirectories = str_pad(substr(strval($stat['countDirectories']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountFiles = str_pad(substr(strval($stat['countFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountRunOnlyFiles = str_pad(substr(strval($stat['countRunOnlyFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msg = '|' . str_pad(substr(strval($language), 0, 12), 12) + . '|' . $msgCountDirectories + . '|' . $msgCountFiles + . '|' . $msgCountRunOnlyFiles + . '|'; if ($config['clean']) { $msgCountDeletedFiles = str_pad(strval($stat['countDeletedFiles']), 7, ' ', STR_PAD_LEFT) . '|'; + $msg .= $msgCountDeletedFiles . $msgLanguageSkipped; } else { + $msgCountFailedFiles = str_pad(substr(strval($stat['countFailedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountSkippedFiles = str_pad(substr(strval($stat['countSkippedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountLines = str_pad(substr(strval($stat['countLines']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountTests = str_pad(substr(strval($stat['countTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountRunOnlyTests = str_pad(substr(strval($stat['countRunOnlyTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountFailedTests = str_pad(substr(strval($stat['countFailedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountSkippedTests = str_pad(substr(strval($stat['countSkippedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + if ($stat['timeBuilding'] > 0) { + $msgTimeBuilding = + str_pad(number_format($stat['timeBuilding'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) . 's'; + } else { + $msgTimeBuilding = ' - '; + } + $msgTimeRunning = str_pad(number_format($stat['timeRunning'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) + . 's'; + $msgTimeSpent = str_pad(number_format($stat['timeSpent'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) + . 's'; if (($stat['countFiles'] == 0) and !$config['lang-versions']) { $msgCountFiles = $ansiYellowInv . $msgCountFiles . $ansiReset; $status = $warnTag; @@ -1850,59 +1872,71 @@ $msgCountFailedTests = $ansiRedInv . $msgCountFailedTests . $ansiReset; $status = $failTag; } + $msg .= $msgCountFailedFiles + . '|' . $msgCountSkippedFiles + . '|' . $msgCountLines + . '|' . $msgCountTests + . '|' . $msgCountRunOnlyTests + . '|' . $msgCountFailedTests + . '|' . $msgCountSkippedTests + . '|' . $msgTimeBuilding + . '|' . $msgTimeRunning + . '|' . $msgTimeSpent + . '|' . $msgLanguageSkipped; } - echo $status - . '|' . str_pad(substr(strval($language), 0, 12), 12) - . '|' . $msgCountDirectories - . '|' . $msgCountFiles - . '|' . $msgCountRunOnlyFiles - . '|' . $msgCountFailedFiles - . '|' . $msgCountSkippedFiles - . '|' . $msgCountLines - . '|' . $msgCountTests - . '|' . $msgCountRunOnlyTests - . '|' . $msgCountFailedTests - . '|' . $msgCountSkippedTests - . '|' . $msgTime - . 's|' . $msgCountDeletedFiles . $msgLanguageSkipped . PHP_EOL; + echo $status . $msg . PHP_EOL; } // -------------------------------------------------------------------- // total stats echo $separator . PHP_EOL; if ($languageStats['totals']['countLanguages'] > 1) { $stat = $languageStats['totals']; + $msgLanguageSkipped = ''; $msgCountLanguages = str_pad(strval($stat['countLanguages']), 2, ' ', STR_PAD_LEFT) . ' language' . ($stat['countLanguages'] > 1 ? 's' : ' '); $msgCountDirectories = str_pad(substr(strval($stat['countDirectories']), 0, 6), 6, ' ', STR_PAD_LEFT); $msgCountFiles = str_pad(substr(strval($stat['countFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); $msgCountRunOnlyFiles = str_pad(substr(strval($stat['countRunOnlyFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountFailedFiles = str_pad(substr(strval($stat['countFailedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountSkippedFiles = str_pad(substr(strval($stat['countSkippedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountLines = str_pad(substr(strval($stat['countLines']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountTests = str_pad(substr(strval($stat['countTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountRunOnlyTests = str_pad(substr(strval($stat['countRunOnlyTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountFailedTests = str_pad(substr(strval($stat['countFailedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgCountSkippedTests = str_pad(substr(strval($stat['countSkippedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgTime = str_pad(number_format($stat['spentTime'] / 1000000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT); - $msgCountDeletedFiles = ''; - if ($config['clean']) { - $msgCountDeletedFiles = str_pad(strval($stat['countDeletedFiles']), 7, ' ', STR_PAD_LEFT) . '|'; - } - $msgLanguageSkipped = ''; - echo 'Total: ' - . '|' . $msgCountLanguages + $msg = 'Total: ' + . '|' . str_repeat(' ', 12) . '|' . $msgCountDirectories . '|' . $msgCountFiles . '|' . $msgCountRunOnlyFiles - . '|' . $msgCountFailedFiles - . '|' . $msgCountSkippedFiles - . '|' . $msgCountLines - . '|' . $msgCountTests - . '|' . $msgCountRunOnlyTests - . '|' . $msgCountFailedTests - . '|' . $msgCountSkippedTests - . '|' . $msgTime - . 's|' . $msgCountDeletedFiles . $msgLanguageSkipped . PHP_EOL; + . '|'; + if ($config['clean']) { + $msgCountDeletedFiles = str_pad(strval($stat['countDeletedFiles']), 7, ' ', STR_PAD_LEFT) . '|'; + $msg .= $msgCountDeletedFiles . $msgLanguageSkipped; + } else { + $msgCountFailedFiles = str_pad(substr(strval($stat['countFailedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountSkippedFiles = str_pad(substr(strval($stat['countSkippedFiles']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountLines = str_pad(substr(strval($stat['countLines']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountTests = str_pad(substr(strval($stat['countTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountRunOnlyTests = str_pad(substr(strval($stat['countRunOnlyTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountFailedTests = str_pad(substr(strval($stat['countFailedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + $msgCountSkippedTests = str_pad(substr(strval($stat['countSkippedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); + if ($stat['timeBuilding'] > 0) { + $msgTimeBuilding = + str_pad(number_format($stat['timeBuilding'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) . 's'; + } else { + $msgTimeBuilding = ' - '; + } + $msgTimeRunning = str_pad(number_format($stat['timeRunning'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) + . 's'; + $msgTimeSpent = str_pad(number_format($stat['timeSpent'] / 1000000, 1, '.', ''), 6, ' ', STR_PAD_LEFT) + . 's'; + $msg .= $msgCountFailedFiles + . '|' . $msgCountSkippedFiles + . '|' . $msgCountLines + . '|' . $msgCountTests + . '|' . $msgCountRunOnlyTests + . '|' . $msgCountFailedTests + . '|' . $msgCountSkippedTests + . '|' . $msgTimeBuilding + . '|' . $msgTimeRunning + . '|' . $msgTimeSpent + . '|' . $msgLanguageSkipped; + } + echo $msg . PHP_EOL; if (!$config['clean']) { // -------------------------------------------------------------------- // unique puzzle stats @@ -1916,7 +1950,6 @@ $msgCountRunOnlyTests = str_pad(substr(strval($stat['countRunOnlyTests']), 0, 6), 6, ' ', STR_PAD_LEFT); $msgCountFailedTests = str_pad(substr(strval($stat['countFailedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); $msgCountSkippedTests = str_pad(substr(strval($stat['countSkippedTests']), 0, 6), 6, ' ', STR_PAD_LEFT); - $msgTime = str_repeat(' ', 7); $msgCountDeletedFiles = ''; $msgLanguageSkipped = ''; echo 'Unique:' @@ -1931,8 +1964,7 @@ . '|' . $msgCountRunOnlyTests . '|' . $msgCountFailedTests . '|' . $msgCountSkippedTests - . '|' . $msgTime - . '|' . $msgCountDeletedFiles . $msgLanguageSkipped . PHP_EOL; + . '| | | |' . PHP_EOL; } echo $separator . PHP_EOL; } @@ -2035,7 +2067,7 @@ . ' test' . (count($slowTests) > 1 ? 's' : '') . ' taking longer than ' . $ansiInfo . ($config['slowThreshold'] ?? 0) . $ansiReset . ' seconds.' . PHP_EOL; } -$timeStr = number_format($languageStats['totals']['spentTime'] / 1000000000, 1, '.', ''); +$timeStr = number_format($languageStats['totals']['timeSpent'] / 1000000, 1, '.', ''); echo $infoTag . 'Time spent: ' . $ansiInfo . $timeStr . $ansiReset . ' seconds.' . PHP_EOL . PHP_EOL; if (!$config['dry-run']) { if ($languageStats['totals']['countPassedTests'] != $languageStats['totals']['countTests']) { diff --git a/statements/easy_com_ascii-worms.txt b/statements/easy_com_ascii-worms.txt new file mode 100644 index 00000000..d5ceab35 --- /dev/null +++ b/statements/easy_com_ascii-worms.txt @@ -0,0 +1,55 @@ +ASCII Worms + +easy_com_ascii-worms +https://www.codingame.com/training/easy/ascii-worms +https://www.codingame.com/contribute/view/9291062e2f7b19f6821a28906a8ed60059751 + +A contribution by ajaiy +Approved by NicknamedTwice,a7a_2,DeanTheMachine + +Goal +As a fun computer project for the holidays, you are given the task to draw ASCII art - worms to be specific. But you are only given their thickness, the coil length and the number of turns they make. However, you don't really want to slave away on your computer typing patterns of underscores and vertical bars, so you decide to make a program do it - it's a computer project anyways. + +All worms start at the top-left and take up length lines of text (excluding the top of the worm, which is formed using underscores) + +For example, if the thickness is 2, the coil length is 5, and the number of turns is 4, you should get: + + __ _____ _____ +| | | | +| | | | | | +| | | | | | +| | | | | | +|_____|_____|__| + +Input +Line 1: The worm thickness +Line 2: Coil length of the worm +Line 3: Number of turns made by the worm + +Output +The worm made in ASCII art according to the inputs given. + +Constraints +All the inputs are natural numbers. +length >= 2 + +Example + +Input +2 +5 +4 + +Output + __ _____ _____ +| | | | +| | | | | | +| | | | | | +| | | | | | +|_____|_____|__| + +Difficulty +Easy + +Tags +Ascii Art, String manipulation diff --git a/statements/easy_com_histogram.txt b/statements/easy_com_histogram.txt new file mode 100644 index 00000000..063b0164 --- /dev/null +++ b/statements/easy_com_histogram.txt @@ -0,0 +1,146 @@ +Histogram + +easy_com_histogram +https://www.codingame.com/training/easy/histogram +https://www.codingame.com/contribute/view/944617febd934bd70084f61c9e9dd435dd658 + +A contribution by Ribak +Approved by DeanTheMachine,vexilla72,Drunkey + +Goal +You have to print the horizontal histogram of occurrences of letters from the given texts. We only want the letters from A-Z and a-z. Letters of different cases are treated as the same letter when counting. +The histogram shows the percentages. + +You have to write the histogram with the letters A to Z on the Y axis and the percentages on the X axis. +The values are rounded to 2 decimal places. +The lengths of the histogram bars are rounded to the nearest integer. For example, a value of 4.85 would have 5 blank spaces, while a 0.4 would have 0. + + +------------------------------------+ +A | |36.36% + +------------------------------------+ +B |0.00% + + +C |0.00% + +---------+ +D | |9.09% + +---------+ +E |0.00% + +------------------+ +F | |18.18% + +---------+--------+ +G | |9.09% + +---------+ +H |0.00% + + +I |0.00% + + +J |0.00% + + +K |0.00% + + +L |0.00% + + +M |0.00% + + +N |0.00% + + +O |0.00% + + +P |0.00% + + +Q |0.00% + + +R |0.00% + +------------------+ +S | |18.18% + +------------------+ +T |0.00% + + +U |0.00% + +---------+ +V | |9.09% + +---------+ +W |0.00% + + +X |0.00% + + +Y |0.00% + + +Z |0.00% + + + +Input +A string S for the text. + +Output +A histogram of percentages of occurrences of letters in S. + +Constraints +S contains at least one letter. +1 ≤ length of S ≤ 1000 + +Example + +Input +A + +Output + +----------------------------------------------------------------------------------------------------+ +A | |100.00% + +----------------------------------------------------------------------------------------------------+ +B |0.00% + + +C |0.00% + + +D |0.00% + + +E |0.00% + + +F |0.00% + + +G |0.00% + + +H |0.00% + + +I |0.00% + + +J |0.00% + + +K |0.00% + + +L |0.00% + + +M |0.00% + + +N |0.00% + + +O |0.00% + + +P |0.00% + + +Q |0.00% + + +R |0.00% + + +S |0.00% + + +T |0.00% + + +U |0.00% + + +V |0.00% + + +W |0.00% + + +X |0.00% + + +Y |0.00% + + +Z |0.00% + + + +Difficulty +Easy + +Tags +Ascii Art, Arrays diff --git a/statements/medium_com_ascii-snakes.txt b/statements/medium_com_ascii-snakes.txt new file mode 100644 index 00000000..5b43aeee --- /dev/null +++ b/statements/medium_com_ascii-snakes.txt @@ -0,0 +1,74 @@ +ASCII Snakes + +medium_com_ascii-snakes +https://www.codingame.com/training/medium/ascii-snakes +https://www.codingame.com/contribute/view/967058f3b1b639c2c775eafef64ff388c1f03 + +A contribution by ajaiy +Approved by _vcxl,DeanTheMachine,Edjy + +Goal +This puzzle is the second part of the ASCII series. The prequel to this puzzle is "ASCII Worms", where you have to print a worm using ASCII characters. + +After a ten-minute coding montage, you successfully get the program working. You now paste the worms and submit. It worked! A "Go to Next Assignment" button appears, and you happily click on it. How bad could the next one be? This time, you have to print ASCII snakes! + +Goal: +Your aim is to draw an ASCII snake, given the moves it makes, in the form of U, D, L, R, which signify Up, Down, Left, Right respectively. The snake starts at the top-left. + +Example: +For example, if the input is "DRRDLD", then the snake would be: + ++-+ +| | +| +-----+ ++-----+ | + +--+ | + | +--+ + | | + +-+ + +The snake is composed of 3x2 ASCII rectangles. + + ++-+ +-+ +-+ +-+ <- ASCII rectangle +| | | | | | | | (3*2) +| +---+ | is composed of ++-------+ | + --- + | + +-- --- --+ + + +All vertical lines, horizontal lines, and intersections are represented by |, -, and + respectively. All trailing spaces should be trimmed off. + +Stuck on where to start? Here's a little hint for you; watch this video and see if you can get the idea for the solution: https://www.youtube.com/watch?v=qAf9axsyijY + +(Special thanks to @Woega for the idea) + +Input +Line 1: The message which specifies the directions of the snake + +Output +The ASCII snake made using the given message + +Constraints +length(message) <= 50 + +Example + +Input +DRRDLD + +Output ++-+ +| | +| +-----+ ++-----+ | + +--+ | + | +--+ + | | + +-+ + +Difficulty +Medium + +Tags +Conditions, Ascii Art, String manipulation, 2D array