Anagrams

Post gaming related scripts
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

20 Jul 2017, 14:59

Yeah I saw some len4.txt ... when I tried it.
wl2.txt probably comes from the auto-complete thread I refered to recently. I think I renamed it for lazy typing :beard:
wolf_II wrote:I think when the permutation are taken care of I will get only 1/3 of the count, which equals your number .. looks promising :D

It would be nice if our numbers coincide, because we cannot easily calculate the correct number of anagrams. Getting the same result would be a nice inidcator. Although, since we discussed methods we might be biased to make similar mistakes ;)
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

20 Jul 2017, 15:18

Did you notice the last post on the previous page? I posted a fix to take care of permutations. And I got exactly 1/3 as I hoped. 1,105 :D
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

20 Jul 2017, 15:41

Happy days!
I was looking at it, thinking about how to avoid generating the permutations in the first place. It is a tricky one.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 06:43

version 2.07

Anagrams v2.07.zip
(13.78 KiB) Downloaded 25 times



This version is worth keeping. It contains all the features, all the fixes and works with up to 2 spaces (3-word solutions).
I plan to introduce some recursion next to deal with an arbitrary amount of spaces.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 06:59

version 2.08

Anagrams v2.08.zip
(13.79 KiB) Downloaded 24 times



Only two lines code have changed, one being the version number. :lol:
Now I need to do more testing.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 07:23

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



When I am comparing the results to Helgef's reference I suspect again some permutations interfering :(
Edit: I added Reference count to the table.
Edit2: I added missing relevant information.
Last edited by wolf_II on 21 Jul 2017, 08:01, edited 2 times in total.
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

21 Jul 2017, 07:28

When I am comparing the results to Helgef's reference I suspect again some permutations interfering

:think: Did you compare the number of results to the reference list?
Regarding the spinner, try to put

Code: [Select all] [Download] GeSHi © Codebox Plus

Gdip_SetSmoothingMode(pGraphics, 4)

after

Code: [Select all] [Download] GeSHi © Codebox Plus

; setup Gdip
[...]
pGraphics := Gdip_GraphicsFromHDC(hDC)

To my eyes it improves the quality of the dots.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 07:40

Re: smooth spinner
Thanks :thumbup:

I edited the table above.
I expect a problem with the previous candidates which are stored (in principle). Maybe Previous[] could be a static?
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

21 Jul 2017, 09:06

Quick answer, note that the so called reference list has not been verified to be free of duplicates, at least not by me. One could sort each line, D%A_Space%, and then sort with U option delimiter and `n.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 09:47

I see, thanks. I will write some diagnostic helper, this is unreliable to do manually.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

21 Jul 2017, 11:07

Here is the Diagnostics helper script. I manually produced 2.txt, ... 6.txt using the "Copy all items to clipboard" feature in Anagrams version 2.08. Those files are saved in a separate folder containg the "elevenplustwo.txt" and the following script. Then I ran the script.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Now I compare 2 sorted.txt with ref 2 sorted.txt and so on. My first observation when I compare 6 sorted.txt and ref 6 sorted: (used for brevity)

There are lines that all start with "el el " which come from Anagrams that are not present in the reference, all remaining differences are lines in the reference, but are missing from Anagrams output.

Needs further investigation, I just share my method here already, Maybe we can get an idea where to look next?

Edit: Second impression: all lines starting with "el el " are only present in Anagrams output, not present in the reference. 5 sorted.txt vs. ref 5 sorted.txt
Last edited by wolf_II on 21 Jul 2017, 11:20, edited 1 time in total.
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

21 Jul 2017, 11:20

Asuming your el el lines form valid anagrams, it seems there are missing anagrams in the so called reference :problem:
I will revisit my code later.
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

22 Jul 2017, 03:55

I know why I didn't get the el el sentences. It's because combinations() doesn't return any duplicates. My brute-force method needs two el's to produce a combination containing two el's. I have made a modification, but I'm not sure it will ever finish :lol:
Edit: It didn't finish :(
I peeked in on its progress (debug vars) and saw that it had found el el combinations, so I interrupted it, it had found ~19000 results, I took out the el el ones,

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus


My guess is that there shouldn't be any more el el sentences than those. I shall ponder if I can (easily) filter the brute force method such that it actually manages to finish.
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

22 Jul 2017, 12:47

Is it possible to get an output file for Input = foxtrot from your combine function? or maybe for input = go go go?
I'm looking for an easy short one, so analysing where the differences are should also be more straight forward. That's my hope at least.
I had a look at your function earlier on but I cant see how to get it to produce output into a file.

On the other hand, I might have reached the end of my ability to wrap my head around this topic. One more knot could cause permanent damage ;)
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

22 Jul 2017, 15:17

Well that was quick atleast,

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus


and

Code: [Select all] [Download] (Untitled.txt)GeSHi © Codebox Plus

go gogo

:D
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

22 Jul 2017, 16:15

Thanks for doing that. I only noticed that I am currently displaying the anagrams without sorting the words in each line. Should I sort the words as the last improvement and call it finished?
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

22 Jul 2017, 17:15

Sorting might look better, I guess it will be quick.
If you feel that it is finished, I would like to congratulate you on a job well done! It turned out to be a very nice app, and I had fun discussing it with you, thank you very much for your efforts and time. :salute: :bravo:
Also, I think you should include v.2 in the first post.

Cheers!
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

23 Jul 2017, 11:32

Thank you for your kind words and your massive help with this! :salute:
I will shortly post an updated version. I also like to add my new spinner that signals to the user when something is going on, rather than just disabling the controls in the GUI.
I will also update the first post.



version 2.09

Anagrams v2.09.zip
(14.6 KiB) Downloaded 33 times
wolf_II
Posts: 1580
Joined: 08 Feb 2015, 20:55

Re: Anagrams

23 Jul 2017, 15:04

Helgef wrote:If you feel that it is finished

I don't feel that the project is finished in a good way. More like: I am finished as I can not improve it further.
There still are some multi-word anagrams missing for sufficiently large inputs like eleven plus two.
There are plenty multi-word anagrams found and displayed, so that's a partial success.

More importantly: I feel like I should not be wasting any more of your precious time on this.
I can't thank you enough for your teaching, guidance and patience with me. And of course the time you spent. :beer:

I thoroughly enjoyed the experience. :dance: :superhappy: :wave:
Helgef
Posts: 2398
Joined: 17 Jul 2016, 01:02
Contact:

Re: Anagrams

23 Jul 2017, 16:03

I feel like I should not be wasting any more of your precious time on this.

You can not and you have not, I shall waste my own time, as I see fit ;)

2.09
My only critisism is that the mulit-word anagrams are dependent on the amount of spaces typed in the edit. It would be more intuitive, and user friendly, to have an optional count of how many words to have per line in the listview.
The default would be 1, which would show the one-word anagrams. So if I type elvenplustwo, and then select 3 words per line, I get the eleven plus two set. Basically, it would be the equivalent of how it is now if you type elevenplustwo and starts adding spaces after that. 1 space two words, 2 spaces three words ...

Cheers.


I do not see the spinner unless I make it parentless, as mentioned in the spinner thread. A very nice addition though.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 10 guests