+ 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 Respostas
+ 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
I hope it is better now ๐Ÿ˜Š https://code.sololearn.com/cdwZ3K4KCvgp/?ref=app
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