User talk:Petelomax: Difference between revisions

m
 
(34 intermediate revisions by 8 users not shown)
Line 128:
printf(1,fmt,{last_updated,age,length(elements),elements[$]})</lang>
: before deciding that stuff just gets in the way. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 21:52, 24 March 2020 (UTC)
 
==Weather routing task - Windows file line separators==
 
Thanks for fixing the Go example so it can now read the data file on Windows using the usual line separator of "\r\n" for that platform. I've added a similar fix to the Wren example.
 
I tend to forget about poor old Windows as these days I'm 'Linux only'. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 19:19, 19 May 2020 (UTC)
 
 
== Isqrt (integer square root) of X ==
 
In your '''Phix''' entry, you have:
mpz q = mpz_init(1),
r = mpz_init(0),
t = mpz_init(0),
z = mpz_init_set(x)
where &nbsp; '''t''' &nbsp; is initialized to zero.
 
Is that a necessary thing to do?
 
'''t''' &nbsp; doesn't need to be initialized as it's set/defined later in the program.
::You must call mpz_init(), but quite right it makes no difference whether you explicitly specify 0 or not (the default anyway). --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])
 
Also, is the
!=0 then ?9/0
part of some semantic sugar that is needed to check for division by zero?
::Bit of an idiosyncracy, testing that the remainder is zero. Have replaced ?9/0 with crash("uh") which is bascially the same thing. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])
::And now replaced crash() with assert(). --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:41, 16 July 2020 (UTC)
 
I looked at the entry for &nbsp; [[Integer_roots#Phix]] &nbsp; and it appears that that
example (program) requires &nbsp; '''n''' &nbsp; to be an integer and is apparently not an "mpz" thingy.
::Ah, n is the nth root, you could make &nbsp; '''a''' &nbsp; an mpz and pass it directly to mpz_root(). I take it my comments on that page arrived after you made this post. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:20, 16 July 2020 (UTC)
I am not familiar at all with the '''Phix''' language, so I am most assuredly missing something.
::If you have a windows box you should give it a quick spin, though the linux version is a bit flakey (I think it needs kernel 5.3, and was broken on 5.0..5.2 at least) and the web version is ''still'' at the planning phase... --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])
 
 
The function mentioned in your link may be simpler and shorter, but the Rosetta Code task was
to implement an integer square root function as per the pseudocode. &nbsp; I wouldn't object
to you entering an alternative '''Phix''' version in the discussion page for this task. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 06:59, 16 July 2020 (UTC)
:: My intention was just to dissuade anyone from using isqrt() when they should really be using mpz_root(). I actually use rc and/or my local demo/rosetta directory myself quite often, to remind me how to do things. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])
 
By the way, the (draft) task has been changed, only the '''odd''' powers of seven are to be shown. &nbsp; I had
inadvertently left out the word &nbsp; '''odd'''. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 06:59, 16 July 2020 (UTC)
:: Page updated, thanks --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:16, 16 July 2020 (UTC)
 
== Issue in Pancake Numbers ==
Hi, your proposed solution in Phix for [[Pancake numbers]] appears to be wrong. It lists p(19) as 21, whereas A058986 lists it as 22. Worse yet, it seems every single solution on this page is just a translation of your algorithm.
I question this algorithm as a solution to begin with. It’s just a sequence of numbers that *happen* to agree with the first 19 known solutions. But there’s no much value here as an exercise for RC, as opposed to, say, exhaustive search for the solutions.
 
Can you give your feedback on [[Talk:Pancake numbers]]. I’d be tempted to just purge the page of any non actual solutions. [[User:Monarchdodra|Monarchdodra]] ([[User talk:Monarchdodra|talk]]) 13:01, 9 March 2021 (UTC)
 
: Good catch, page + talk updated. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 16:56, 9 March 2021 (UTC)
 
== Smallest power of 6 whose decimal expansion contains n ==
 
Hello Pete,<BR>I'm investigating the runtime problem.Runnig on TIO.RUN the same increase of a factor of ~10x after 100000<BR>I'm checking the mean power, when the string was found, and the mean power for the last 1024 checks.<BR>
One digit more > 3x power ( aka lenght of search string. runtime about 3x lenght * 3x count ~> 10x ) to find the search string.<BR>I've got no idea, how to speed up. [[User:Horsth|Horsth]] 11:21, 9 April 2021 (UTC)
<pre>
//power_Limit= 25000 -> used by strings 243,194,474. Generating time to power limit 0.859s
checking every 1024:
Generating all numerical strings up to power limit 6260 takes 0.056s
used by strings 15,252,500 ~ 16Mb
 
Search mean last
string power mean Delta time
power
0 9.00 0.01 0.000
1024 46.62 46.65 0.002
2048 94.98 143.40 0.018
3072 111.74 145.27 0.017
4096 120.09 145.16 0.017
5120 125.31 146.17 0.017
6144 129.45 150.19 0.018
7168 131.38 142.94 0.017
8192 133.10 145.11 0.017
9216 134.22 143.21 0.016
10240 142.94 221.43 0.052
11264 170.38 444.83 0.156
12288 193.64 449.45 0.159
13312 213.66 453.99 0.164
14336 230.34 447.23 0.161
15360 245.28 454.43 0.169
.....
98304 421.65 466.58 0.170
99328 422.18 473.67 0.172
100352 426.05 801.41 0.656
101376 436.00 1410.97 1.561
102400 446.06 1441.35 1.671
103424 455.71 1421.37 1.607
104448 465.18 1421.69 1.600
...
117760 573.58 1397.76 1.458
118784 580.85 1416.78 1.511
119808 588.16 1436.94 1.566
mean power 589.35
 
real 0m44,996s
</pre>
: Note sure what to make of "mean power". All I did to test mine was save the last thing found, then use gmp to independently generate that power of 6 and prove that final digit string did indeed occur somewhere in it. I transpiled it to JavaScript (am actively working on that technology and have not yet released it) and that took 13mins 10s for the 10,000,000 run, 35s for a 1,000,000 run. AH: have you just fixed this now? --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 16:35, 9 April 2021 (UTC)
::Hello Pete,<BR>now I understand, how you solved the task.Your version of PHIX takes 1m14s on my computer.<BR>I translate the principle into pascal with a small optimization to jump over the first already found numbers.Especially for many digits it brings a speedup.11s downto 9s for 10,000,000 aka 7 decimal digits
 
==congrats==
 
Congratulations on singlehandedly occupying the top slot in Rank Languages by Popularity - I raise a metaphorical glass to you. :-)
 
:Thanks!
 
Also thank you for pointing out my typo in Self Hosting Compiler #Quackery.
 
I noticed that in Josephus problem, you listed Quackery amongst the unclassified. FYI, I would classify it as "sliding queue". [[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 07:39, 6 June 2021 (UTC)
 
:Have reclassified it, thanks. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 12:47, 9 June 2021 (UTC)
==example for LiveCode==
Hello, Pete. I’m Dick.
 
While making my first wiki contribution, I mistakenly deleted the LUA entry. I apologize for causing you work, and thank you for doing it.
 
I meant to delete the previous code for LiveCode because it does not address the task at hand. The old code fails to apply pattern matching beyond just exactly matching the file’s extension.
 
Talk:Walk a directory/Recursively contains a restatement of the task:
 
Walk a given directory tree, calling a function for every filename which matches a given wildcard, UNIX glob, or regex pattern (whichever is easiest for the given language).
 
The old code therefor adds noise to Rosetta Code, reducing the signal-to-noise ratio, degrading rather than enhancing the value of the site.
 
But my concern seems to me to be way below the thoughts of the contributors to the Talk. It hasn’t been updated since 2017. Do you still advise me to seek counsel there about this edit?
 
:No problem, everyone has to start somewhere. First, you can safely assume that if you reply on your talk page then whoever wrote a message there has that page on their watchlist and will get an email notification, just as you will when I post this reply (unless you unchecked "Watch this page" when you made this post). Also, all updates appear on [[Special:RecentChanges]] so I, and any moderators, would see any change to the talk page alongside changes to the task page, and of course that is how I spotted yours. It is not a case of "getting permission" or usually even agreement, but a statement of "why I did it" (brief being better). Please pay attention to the "Summary:" when you edit. You left it as <nowiki>‎{{header|LiveCode}}</nowiki> which is not any kind of crime but often not any kind of help either (that '''and''' five more words being best). When such an explanation will not fit in the summary and does not belong being left permanently on the task page, it belongs on the talk page, even unread. Not every change needs all that, but when I delete someone elses code it is only being civil to explain myself. It is quite helpful to show the output, so when you do update [[Walk a directory/Recursively]] I'll expect to see that. I'll add that the above attempt does not actually explain to me what you fixed, different output probably would. Lastly you need to learn to sign your comments by adding <nowiki>--~~~~</nowiki>. Any further questions? --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 14:18, 17 November 2021 (UTC)
thanks for the advice, Pete. My every attempt to edit the Summary failed to produce a lasting result. What's the trick?
<nowiki>--~~~~</nowiki>
:The summary only ever appears on the History/Recent Changes reports and are fine for [[Walk a directory/Recursively]]. Also I used <nowiki><</nowiki>nowiki<nowiki>></nowiki> to show you what <nowiki>--~~~~</nowiki> should look like when you type it, but you should only key the 2+4 characters shown and omit the nowiki tags. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 17:57, 30 November 2021 (UTC)
Thanks again, Pete. Is there a basic training document you recommend? --Dick Kriesel 23:23, 30 November 2021 (UTC)
 
==Update to D for Bézier intersections==
You might like to know there was a bug in the translated-from D code that I kind of knew about but it actually shows up if you merely divide the tol by 10. It previously appeared in the Modula-2 code (which is similar to the D) and I used the same crude remedy. I figure crude remedies probably are best, anyway, when you are working in floating point. --[[User:Chemoelectric|Chemoelectric]] ([[User talk:Chemoelectric|talk]]) 12:33, 7 June 2023 (UTC)
 
If one really, really, really wanted to isolate the intersections BTW, go about it this way: implicitize one curve in exact arithmetic. Plug in the other in exact arithmetic. Break the quartic into square-free polynomials, in exact arithmetic. Now you can isolate the roots into intervals, exactly, and also know their multiplicities. :) --[[User:Chemoelectric|Chemoelectric]] ([[User talk:Chemoelectric|talk]]) 12:38, 7 June 2023 (UTC)
 
==I wrote a Phix==
I wrote a second implementation of [[Bézier_curves/Intersections]] in Phix. It uses "unique" in a way I think will function correctly enough but about which it will do no harm if you come up with a more "fuzzy" alternative. :) (I’m thinking of writing a Scheme implementation that does essentially what the "unique" does but does it by making endpoint checks a separate matter. [If two floating point numbers are equal, for instance because copied from the same source, they are equal, no matter what talking heads say!] Also adding an absolute tolerance besides the flatness tolerance. And then moving on to Bézier clipping, because I’ve never completed an implementation of intersections using that. Or implementing my algorithm but for cubics, as a side project.) --[[User:Chemoelectric|Chemoelectric]] ([[User talk:Chemoelectric|talk]]) 11:38, 12 June 2023 (UTC)
:Yes, unique() only eliminates binary-exact [nested/all] floats, so I'd just write any such "fuzzy" filtering like this:
sequence t_pairs = unique (find_intersections (p, q, flatness_tolerance))
for i=length(tpairs) to 2 by -1 do
if fuzzy(tpairs[i],tpairs[i-1]) then t_pairs[i..i] = {} end if
end for
:<small>(Obviously the "by -1" ensures that deleting t_pairs[i] does not mess up any subsequent indexing.)</small><br>
:Note there may also be some cases where the natural sort order (on which unique is based) is not good enough, such as {{0.51,0.71}, {0.515,800}, {0.52,0.71}} where the first and last are "fuzzy-same" but the middle one clearly ain't. Rounding things before throwing them at unique() might perhaps prove better, or a full inner "j=i-1 to 1 by -1" might be needed, or maybe even replace unique() with a couple of sorts, first eliminating t_pairs sorted by X then doing the same sorted by Y. --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 16:41, 12 June 2023 (UTC)
::Since you have clearly now actually used Phix, there is a semi-related short [https://docs.google.com/forms/d/e/1FAIpQLSecar5T7_wDKkn2oG1yTPC3twBM6G5FtkR2BrMjOWlUUcdDyw/viewform survey] (as announced to me on [https://openeuphoria.org/forum/137884.wc?last_id=137926 this thread]) I thought I might invite you to fill out if interested, no worries if not. --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 03:37, 15 June 2023 (UTC)
 
==Legacy view==
I've just switched back to the 14-year-old legacy view, what a relvelation! The final trigger point was that stupid ''(really stupid)'' thing it does with the sidebar, whereby as you scroll (mousewheel) down and it hits the bottom, it scrolls the right panel a smidge and jumps the side panel all the way back up to match it, ''very annoying''. With the old style it all works so much more smoothly. Anyway, happy new year! --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 23:56, 1 January 2024 (UTC)
7,794

edits