Back
Close

Triangle wave graph

Statement

 Goal

The goal is to draw a triangle wave in a 2d graph, given that h is the height of the graph and w defines the horizontal range of the graph.

The wave should start from the middle left and proceed diagonally up to the top of the graph, then diagonally down, etc.
Note: amplitude = (h-1) / 2

The following rules should be applied:
1- h must be odd
2- w and h should be at least 1
If either rule is broken output should be: Invalid Input
Input
Line 1: Two space separated Integers, width w and height h
Line 2: Character fill to represent the wave
Line 3: Character empty to represent empty spaces
Output
h lines with a width of w that represents a triangle wave. Use fill for the wave and empty for the space.
or Invalid Input
Constraints
-100 ≤ w,h ≤ 100
Example
Input
7 7
*
.
Output
...*...
..*.*..
.*...*.
*.....*
.......
.......
.......

Game modes
Fastest, Shortest, Reverse

Test cases
Half Cycle Test
Input
7 7 * .
Output
...*... ..*.*.. .*...*. *.....* ....... ....... .......

Half Cycle Validator Validator
Input
31 31 *
Output
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Full Cycle Test
Input
25 13 *
Output
* * * * * * * * * * * * * * * * * * * * * * * * *

Full Cycle Validator Validator
Input
41 21 0 /
Output
//////////0////////////////////////////// /////////0/0///////////////////////////// ////////0///0//////////////////////////// ///////0/////0/////////////////////////// //////0///////0////////////////////////// /////0/////////0///////////////////////// ////0///////////0//////////////////////// ///0/////////////0/////////////////////// //0///////////////0////////////////////// /0/////////////////0///////////////////// 0///////////////////0///////////////////0 /////////////////////0/////////////////0/ //////////////////////0///////////////0// ///////////////////////0/////////////0/// ////////////////////////0///////////0//// /////////////////////////0/////////0///// //////////////////////////0///////0////// ///////////////////////////0/////0/////// ////////////////////////////0///0//////// /////////////////////////////0/0///////// //////////////////////////////0//////////

Invalid Width Test
Input
0 9 . ,
Output
Invalid Input

Invalid Width Validator Validator
Input
0 17 0 9
Output
Invalid Input

Invalid Height Test
Input
50 8 * v
Output
Invalid Input

Invalid Height Validator Validator
Input
1 4 8 5
Output
Invalid Input

1 Unit High Test
Input
5 1 ~ .
Output
~~~~~

1 Unit High Validator Validator
Input
22 1 _ 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