Submit | All submissions | Best solutions | Back to list |
URJC2_F - Fractals |
What is a fractal? According to wikipedia: A fractal is a mathematical set that exhibits a repeating pattern displayed at every scale.
We are interested in developing a solution and create some fractals! This time we are interested on creating the ”H” fractal. The process to create it is as follows:
- At scale 1, you have the ”H-H” string.
- At scale 2, you will copy the strings into four corners, each copy separated by a single space (row and column-wise).
- You must connect the vertical copies with the pipe character or ’|’ and the horizontal copies with a dash character ’-’ between the pipes that connect the vertical copies (see the samples as clarification).
- At scale 3 and further, you will repeat the step done on scale 2. Thus generating the fractal.
Input
You will receive a single integer N denoting the scale of the H fractal we want to generate.
Output
You must output the generated H fractal as described above, in addition, the generated fractal MUST NOT have trailing spaces, this means that, after the last non-whitespace character of each row is printed, there must be nothing else but a newline written as output.
Example
Input 1: 1 Output 1: H-H
Input 2: 2 Output 2: H-H H-H |---| H-H H-H
Input 3: 3 Output 3: H-H H-H H-H H-H |---| |---| H-H|H-H H-H|H-H |-------| H-H|H-H H-H|H-H |---| |---| H-H H-H H-H H-H
Constraints
1 ≤ N ≤ 10
Added by: | david_8k |
Date: | 2017-03-29 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own Problem |
hide comments
2021-10-17 02:50:21
Easy fractal Problem. Mind that Empty char (ASCII 0) must be print as Space (ASCII 32). And spaces followed after lines shouldn't be printed. Comparetion of this problem is really tight. Thanks for setting the problem. |
|
2020-07-14 19:11:58 Shubham Jadhav
beauty |
|
2019-07-05 02:09:50 :D
Interesting, judge accepts both solution with newline after the last line and solution that doesn't print it. Normally that's an issue in exact judge tasks like this. Nice problem btw. |
|
2018-12-05 17:30:39
Really enjoyed..pattern is beautiful . Last edit: 2018-12-06 12:29:49 |
|
2017-10-18 20:35:40 Simes
@nadstratosfer. The vertical bars don't extend just one row into the smaller clones, they extend until they meet a horizontal bar. If you fancy creating another fractal, take a look at ULM02. Last edit: 2017-10-18 20:44:21 |
|
2017-10-07 02:47:07
hodobox: Doesn't work on spojtoolkit. Statement doesn't mention that we need to modify the last row of the upper clones and the first row of the lower clones like in case 3 (the protruding pipe in H-H|H-H). Anyway the judge refuses both this version and the one as per statement. Here's case 5 as per my WA code: https://pastebin.com/rB60sGNe . Please let me know how it's different from the expected one. Edit after AC: correct case 5 for those struggling: https://pastebin.com/9i0FG5Zc . Last edit: 2017-10-31 17:54:04 |
|
2017-10-06 20:35:33
I don't understand how the example differs from the statement? It seems clear to me and got AC. Spojtoolkit for more outputs if you need. Last edit: 2017-10-06 20:36:43 |
|
2017-10-01 13:52:27
[Angry rant removed after AC] Thanks Simes! Last edit: 2017-10-31 17:50:20 |
|
2017-05-16 16:29:11 Shubham Jadhav
can someone give the output for n=4??? |