LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-15-2021, 12:29 PM   #151
mimorek
Member
 
Registered: Feb 2013
Distribution: Debian (jessie)
Posts: 42

Rep: Reputation: Disabled

I am very impressed by the programs GazL and dogpatch uploaded. I find it very hard to comprehend; my knowledge of C/C++ is way too modest.
 
Old 05-16-2021, 07:38 AM   #152
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
If anyone is still interested, I've updated the code attached to
my previous post.

It's mostly clean-up after the refactoring for multi-threading, with some style clean-up and a few comments thrown in. I'm content with the code now, so I'm going to tag 4.6 "final".

It's been a fun little spare-time project for the last few weeks, so. a big "Thanks" to igadoter and dogpatch for bringing the challenge to our attention, and also to those like Astrogeek and Pan, who offered advice along the way.
 
Old 05-16-2021, 09:26 AM   #153
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by GazL View Post
Ok, here we go, I finally caught my white-whale.
my god, that is something I wanted to continue with, but you were faster.

Quote:
Originally Posted by GazL View Post
Code:
10091 results returned.
real	0m26.851s
user	1m39.975s
sys	0m0.010s
My laptop is not that powerful, so those with more beefy kit will likely get better results from the multithreading.
Code:
time ./circle -v -a -t4 -o /tmp/circle.out 44
...
4 solver threads will be used.  Please wait...

10091 results returned.

real	0m10.507s
user	0m38.760s
sys	0m0.000s
Code:
time ./circle -v -a -t20 -o /tmp/circle.out 44
....
10 solver threads will be used.  Please wait...

10091 results returned.

real	0m6.257s
user	0m39.484s
sys	0m0.020s
looks like something is wrong with the number of threads or at least I don't really understand it well.

Quote:
Originally Posted by GazL View Post
4.6 (final): reworked candidate bucket code into something a little nicer. Style clean-up, Added some comments.
from my side it is very well written.
 
Old 05-16-2021, 10:49 AM   #154
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by pan64 View Post
looks like something is wrong with the number of threads or at least I don't really understand it well.


from my side it is very well written.
Thankyou.


The amount of threads that it will use are limited by:
1) the hardcoded max in the program, which is 32.
2) the value specified by the user.
3) the amount of "jobs" (i.e. candidate pair seeds) the problem can be split into: you can see how many of these there are when -v is used (just above the line about number of threads).

If there are less jobs than the amount of threads specified it just starts that many threads rather than having others sit around with no work to do.

For example, the default 1-32 circle, can use at most 6 threads.

... which reminds me. One thing I realised the other day was that picking a seed value with the most candidates will potentially allow for an additional thread or two. I was going to do that but forgot. It's a small job, so I'll slap it in a 4.7, then finally, it will be "final".

update: done, and 4.7 uploaded.

Last edited by GazL; 05-16-2021 at 11:31 AM.
 
Old 05-21-2021, 06:06 PM   #155
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490

Original Poster
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
Quote:
Originally Posted by mimorek View Post
I am very impressed by the programs GazL and dogpatch uploaded. I find it very hard to comprehend; my knowledge of C/C++ is way too modest.
Thank you for your kind words. Appropriate that you give GazL top billing.

Here's my latest, version 1.4. It contains very few changes over 1.32. Reinstates make for WordRing and PalabraRing, and i think addresses those few remaining compiler warnings.

WonderRing_1.4.patch.txt

Calling it 1.4 rather than 1.33, because i don't anticipate another version anytime soon. Since i don't have a multi-core computer, probably won't even try to implement GazL's pthread logic.
 
2 members found this post helpful.
Old 05-22-2021, 10:37 PM   #156
mimorek
Member
 
Registered: Feb 2013
Distribution: Debian (jessie)
Posts: 42

Rep: Reputation: Disabled
Quote:
Originally Posted by dogpatch View Post
Here's my latest, version 1.4.
I think these are duplicates.
Code:
$ ./SquareRing 32 1 -aq 
1 8 28 21 4 32 17 19 30 6 3 13 12 24 25 11 5 31 18 7 29 20 16 9 27 22 14 2 23 26 10 15 
1 15 10 26 23 2 14 22 27 9 16 20 29 7 18 31 5 11 25 24 12 13 3 6 30 19 17 32 4 21 28 8
Quote:
Originally Posted by dogpatch View Post
Appropriate that you give GazL top billing.
I take it you're kidding.
 
Old 05-23-2021, 03:37 AM   #157
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by mimorek View Post
I think these are duplicates.
Code:
$ ./SquareRing 32 1 -aq 
1 8 28 21 4 32 17 19 30 6 3 13 12 24 25 11 5 31 18 7 29 20 16 9 27 22 14 2 23 26 10 15 
1 15 10 26 23 2 14 22 27 9 16 20 29 7 18 31 5 11 25 24 12 13 3 6 30 19 17 32 4 21 28 8
"mirror" is likely a more accurate term than "duplicate" for these: the sequence is unique, but a reversal.

Solving the "mirrors problem" was what drove the 3.x branch of my program's development and laid the groundwork for the multi-threading support that followed -- which kind of suggested itself and was just a natural evolution. I wish I could claim to have planned it from the outset, but if I did, I'd be lying.
 
2 members found this post helpful.
Old 05-25-2021, 07:04 PM   #158
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490

Original Poster
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
Quote:
Originally Posted by mimorek View Post
I think these are duplicates.
Code:
$ ./SquareRing 32 1 -aq 
1 8 28 21 4 32 17 19 30 6 3 13 12 24 25 11 5 31 18 7 29 20 16 9 27 22 14 2 23 26 10 15 
1 15 10 26 23 2 14 22 27 9 16 20 29 7 18 31 5 11 25 24 12 13 3 6 30 19 17 32 4 21 28 8
Yes, in my program mirrors (duplicates) are always generated. If you run it with option -o (ordered) it will still internally generate the mirrors (unlike GazL's code), but will not display or count them.

Quote:
Originally Posted by mimorek View Post
I take it you're kidding.
No, i openly acknowledge GazL's code to be superior.
 
Old 06-03-2021, 07:54 PM   #159
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490

Original Poster
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
The challenge long ago met, and looks like the thread is gracefully wound down. Will mark it as [SOLVED]. Many thanks to all who participated.
 
Old 06-05-2021, 06:57 AM   #160
mimorek
Member
 
Registered: Feb 2013
Distribution: Debian (jessie)
Posts: 42

Rep: Reputation: Disabled
I enjoyed this one too.
My thanks
 
  


Reply

Tags
circle, perfect square, programming challenge, ring, ring data type



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
damnit!!! i cant see what im typing.. fonts are squares iLLuSionZ Linux - Newbie 22 11-18-2003 03:36 PM
characters as squares in mozilla icyfire Linux - Software 4 09-18-2003 04:22 PM
white squares appear on screen saver? bongo.hickup Linux - Hardware 0 06-13-2003 03:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration