[ / / / / / / / / / / / / / ] [ dir / abdl / agatha / animu / leftpol / orbg / strek / v4c / zoo ][Options][ watchlist ]

/prog/ - Programming

Programming board
You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Name
Email
Subject
Comment *
File
Select/drop/paste files here
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 361ac4a9621e572⋯.png (71.24 KB, 1232x811, 1232:811, proofs.png) (h) (u)

[–]

c29764 (2) No.4943>>4946 [Watch Thread][Show All Posts]

Managed to do this challenge. The way the code works is to make a table of equations describing the FSM to match the numbers, and then algebraically reduces it down to a single term. The regexes it produces are longer than they need to be but they work. Simple solution but took a lot of thinking to get there.

Here it is in action for n = 5:

0 = 0(0) | 2(1)
1 = 0(1) | 3(0)
2 = 1(0) | 3(1)
3 = 1(1) | 4(0)
4 = 2(0) | 4(1)

0 = 0(0) | 2(1)
1 = 0(1) | 3(0)
2 = 1(0) | 3(1)
3 = 1(1) | 4(1*0)
4 = 2(0)

0 = 0(0) | 2(1)
1 = 0(1) | 3(0)
2 = 1(0) | 3(1)
3 = 1(1) | 2(01*0)

0 = 0(0) | 2(1)
1 = 0(1) | 3(0)
2 = 1(0) | 3(1)
3 = 1(1) | 2(01*0)

0 = 0(0) | 2(1)
1 = 0(1) | 1(10) | 2(01*00)
2 = 1((0|11)) | 2(01*01)

0 = 0(0) | 2((01*01)*1)
1 = 0(1) | 2((01*01)*01*00)
2 = 1((10)*(0|11))

0 = 0(0) | 1((10)*(0|11)(01*01)*1)
1 = 0(1) | 1((10)*(0|11)(01*01)*01*00)

0 = 0(0) | 1(((10)*(0|11)(01*01)*01*00)*(10)*(0|11)(01*01)*1)
1 = 0(1)

0 = 0((0|1((10)*(0|11)(01*01)*01*00)*(10)*(0|11)(01*01)*1))

regex: ^(0|1((10)*(0|11)(01*01)*01*00)*(10)*(0|11)(01*01)*1)+$

c77506 (1) No.4946>>4949

>>4943 (OP)

I tried that website and got frustrated by how long it takes to submit a solution. 90% of the time it failed to communicate with the server after waiting about a minute.


c29764 (2) No.4949

>>4946

Works all right for me. Maybe your internet's shit.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
2 replies | 0 images | 2 UIDs | Page ???
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / abdl / agatha / animu / leftpol / orbg / strek / v4c / zoo ][ watchlist ]