[ ✿ Challenge ✿ ] - Random Visual Pattern Generator╰╋┳╋┳╋┛┗┻╯ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 23

[ ✿ Challenge ✿ ] - Random Visual Pattern Generator╰╋┳╋┳╋┛┗┻╯

Who said only web codes can produce nice things in CodePlayground ? Two steps for this challenge : - First : look at the examples, analyse them to understand how they are built (look at edges also). I added some examples in the linked code, because they can be diiferently displayed, according to the system you're using to watch this challenge. And the ones inside the code are nicer (at least on my devices). - Then, write a code that can automatically and randomly create similar patterns, inputs being the height and width of the pattern to produce. Pattern example (Code playground ascii 128 characters)             Another :           The line spacing creates vertical gaps in the pattern here. Check the examples in this code, it displays better : https://code.sololearn.com/cDQABxQMALxh/#py All languages welcome !

25th Jan 2018, 2:39 PM
Cépagrave
Cépagrave - avatar
25 Answers
+ 9
Since I can't figure out a shortcut, Here are tons of if-else statements. Also, instead of using the ASCII numbers then converting it to characters, I've decided to use the character itself for clarity. I'm not sure if I got all possible cases. I think there's a possible broken line in the lower right corner. https://code.sololearn.com/WmF2CPYR1KEG/?ref=app
27th Jan 2018, 9:51 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
25th Jan 2018, 10:35 AM
LukArToDo
LukArToDo - avatar
+ 19
Nice The single line s are just for spacing, the pattern is symetrical using the double lines. I have made the code more generic in V2. https://code.sololearn.com/c3cbSGib6xb4/?ref=app
25th Jan 2018, 8:30 AM
Louis
Louis - avatar
+ 19
I have a form of narcissism, I just stare at the output of my code the whole time. ──────────────────── ─────╔╦═╦╗╔╦═╦╗───── ──╔═╦╬╣─╠╝╚╣─╠╬╦═╗── ──╚╦╝╠╬╗╠══╣╔╬╣╚╦╝── ───╠╦╩╩╣╠╦╦╣╠╩╩╦╣─── ───║╚═╗║║╚╝║║╔═╝║─── ───╠═╦╬╩╩══╩╩╬╦═╣─── ───╚═╝╠╗─╔╗─╔╣╚═╝─── ─────╔╣║╔╝╚╗║╠╗───── ─────╠╝╠╣──╠╣╚╣───── ─────╠╗╠╣──╠╣╔╣───── ─────╚╣║╚╗╔╝║╠╝───── ───╔═╗╠╝─╚╝─╚╣╔═╗─── ───╠═╩╬╦╦══╦╦╬╩═╣─── ───║╔═╝║║╔╗║║╚═╗║─── ───╠╩╦╦╣╠╩╩╣╠╦╦╩╣─── ──╔╩╗╠╬╝╠══╣╚╬╣╔╩╗── ──╚═╩╬╣─╠╗╔╣─╠╬╩═╝── ─────╚╩═╩╝╚╩═╩╝───── ────────────────────
26th Jan 2018, 8:38 AM
Louis
Louis - avatar
+ 16
@Cpasgrave Ok. I got it now! 😁 I will updated my code. Thank you for your comment 😊
25th Jan 2018, 11:13 AM
LukArToDo
LukArToDo - avatar
+ 15
29th Jan 2018, 8:17 AM
LukArToDo
LukArToDo - avatar
+ 13
https://code.sololearn.com/cEl5GmybaOe9/?ref=app
26th Jan 2018, 8:31 PM
David Ashton
David Ashton - avatar
+ 12
I have refactored the code to make it more generic. https://code.sololearn.com/c3cbSGib6xb4/?ref=app
25th Jan 2018, 6:24 PM
Louis
Louis - avatar
+ 11
One with my code (I hope it can be displayed here): ╭━┓╭┓┏╮╭━┳╮┏┳┳┓┏┓┏┓ ┃╭┻┻╋╯┣┛╭┫┣┛┃┣╯┃╰┛┃ ╰┛╭━╋┳┫┏┻╋┻┳┛╰┳╯┏━╯ ┏╮╰━╋┫┗┛┏┛╭╯┏━┫┏┻┳┓ ┗┫┏┳╋╋┓┏┻╮┣╮┣┓┃┣╮┣┫ ╭╯┃╰╋╯┗┫┏╯┃┃┗┛┃┗╋┫┃ ╰━╯╭┫╭╮┃┃┏╋╋━━┫┏╋┻┛ ╭━━╯╰┻┫┃┣╯╰╋┳┓┣┫┃┏┓ ┗━┓┏┓╭╯╰╯┏━┻┻╯┣╯╰┻┛ ╭━┫┣┛╰┳┳┳┻┳┓╭╮┃╭━┳┓ ┃┏╋╋┓╭┫┗╋┳╋┻╋╋┫┃╭╋┫ ┗┛┗┛╰╯╰━┛┗┻━┛╰╯╰┻┻┛
25th Jan 2018, 3:09 PM
Cépagrave
Cépagrave - avatar
+ 9
@Cpasgrave What font is that you are using, how do you generate it in Python?
25th Jan 2018, 4:58 PM
Louis
Louis - avatar
27th Jan 2018, 9:39 AM
🐙evil octopus
🐙evil octopus - avatar
26th Jan 2018, 12:22 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 8
I kept getting UnicodeEncodeError so I finally ran this to see what worked and what didn't for i in range(257): try: print(i, chr(i)) except: pass
26th Jan 2018, 10:05 PM
David Ashton
David Ashton - avatar
+ 7
@Louis Wow ! Another crazy beauty here ! Very clever code. Symmetry is a very good idea to solve the line-closing issue ! Not exactly the same idea as the chalenge, but wait ... it's actually much more fun to see differrent patterns !
25th Jan 2018, 1:21 PM
Cépagrave
Cépagrave - avatar
+ 7
Copyright : This is a pattern obtained with Louis's code ! ──────────────────── ──╔╗╔╗╔╗────╔╗╔╗╔╗── ─╔╝║╚╩╝╠═╗╔═╣╚╩╝║╚╗─ ─╠╦╬═╗─║╔╩╩╗║─╔═╬╦╣─ ─║╠╣╔╬╗╚╝──╚╝╔╬╗╠╣║─ ─╠╬╣╚╩╣╔╦╗╔╦╗╠╩╝╠╬╣─ ─║╚╣─╔╩╬╝╚╝╚╬╩╗─╠╝║─ ─╠╗╠═╝─╠╦╦╦╦╣─╚═╣╔╣─ ─╚╩╝──╔╝╠╩╩╣╚╗──╚╩╝─ ──╔╗─╔╩╦╩╗╔╩╦╩╗─╔╗── ──╚╝─╚╦╩╦╝╚╦╩╦╝─╚╝── ─╔╦╗──╚╗╠╦╦╣╔╝──╔╦╗─ ─╠╝╠═╗─╠╩╩╩╩╣─╔═╣╚╣─ ─║╔╣─╚╦╬╗╔╗╔╬╦╝─╠╗║─ ─╠╬╣╔╦╣╚╩╝╚╩╝╠╦╗╠╬╣─ ─║╠╣╚╬╝╔╗──╔╗╚╬╝╠╣║─ ─╠╩╬═╝─║╚╦╦╝║─╚═╬╩╣─ ─╚╗║╔╦╗╠═╝╚═╣╔╦╗║╔╝─ ──╚╝╚╝╚╝────╚╝╚╝╚╝── ────────────────────
25th Jan 2018, 3:05 PM
Cépagrave
Cépagrave - avatar
+ 7
Here is my code : https://code.sololearn.com/crVp492EOBi0/#py My code is long and messy, that's why I proposed this challenge. I would like to learn a way to solve this kind of puzzle in a more clever way (and shorter). Louis actually got a very nice and sharp idea : simmerty, and it's also looking very nice at the same time. Also his solution before making the symmetry is nice ! But still, if one of you has an idea how to solve the puzzle that comes with no symmetry, no spaces or lines in the pattern, and all lines closed, I would be happy to know. In my code, I had to add a part that goes back and corrects a previous character to make a nice and all connected grid. I could get it to need less corrections by producing things in this order: - the four corners - first then last columns (top down) - first then last lines (left to right) - then I fill columns from the second left to the before-last (top down) and problems happen while filling the before-last column : sometimes there are no connections to make either left, up or right. So I added some lines to my code, randomely choosing to correct a character up or left from the actual producing spot (adding a linking line to previous character). Well ... not sure it's easy to understand unless you try to make yours.
26th Jan 2018, 4:54 PM
Cépagrave
Cépagrave - avatar
27th Jan 2018, 9:18 AM
🐙evil octopus
🐙evil octopus - avatar
+ 7
Jonathan Pizarra made it !
27th Jan 2018, 10:06 AM
Cépagrave
Cépagrave - avatar
+ 6
@ LukArToDo Amazing ! Nice shapes and ideas. I love it. The first is the closest to the challenge, but : you have broken lines in it ; )
25th Jan 2018, 10:55 AM
Cépagrave
Cépagrave - avatar
+ 6
@Louis Narcissism deserved ! The patterns from your code remind me the beauty of persian carpets.
26th Jan 2018, 9:59 AM
Cépagrave
Cépagrave - avatar