I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

User talk:PureFox

From Rosetta Code


Hello. I noticed you added Kotlin example for Emirp primes and couple other pages. In case you're interested, I pulled all Kotlin code into a repository on github https://github.com/dkandalov/rosettacode-kotlin Dmitry Kandalov 15/12/2016

comment about "Four is the number of letters in the ..."[edit]

Addressing the possible sentence length difference, are you keeping the commas in the never-ending sentence intact (after display the count and the word)?   -- Gerard Schildberger (talk) 15:34, 12 September 2017 (UTC)

By the way, I changed the   name   of the task   --- it had a typo that I missed (many times) of the first word.

The old name was:

  Fours is the number of letters in the ...

The new name is:

  Four is the number of letters in the ...

I also will be changing the requirement about showing the total number of characters of the sentence.
The change will be to show the sentence length after each display, and because you already did that, you won't have to change your Kotlin entry.

Thanks for entering your Kotlin entry.   -- Gerard Schildberger (talk) 15:34, 12 September 2017 (UTC)

Hi Gerard,

Yes, as far as I can see, the commas are being counted when computing the sentence length and this seems to be borne out by the sentence lengths being the same for N == 201.

I will re-run my version of the (REXX) program and post the complete never-ending sentence at the talk page of that Rosetta Code task.

No, I meant, are the commas   left   in the never-ending sentence, that is, are the commas still in the never-ending sentence.   I couldn't tell if the removal of the commas are from removing them from a word, or from the never-ending sentence.   -- Gerard Schildberger (talk)

I wondered whether there might be a difference in the spelling of the numbers (or ordinals) somewhere but I haven't been able to find one. So, for the moment at least, I'm baffled!

Yes, a difference in the spelling either the number (the length of a word),   or the ordinal number (of the location of the word) may be the cause of the difference.   I'll re-run a modified version of the (REXX) program and post the first 2,100 or so   2,202   words of the never-ending sentence at the talk page of that Rosetta Code task;   hopefully, we should be able to visually determine the difference(s).   -- Gerard Schildberger (talk) 19:21, 12 September 2017 (UTC)
Thanks Gerard. After studying your print-out I've realized what the problem was, namely a simple misunderstanding on my part. I was thinking previously that the 'sentence' was all words up to and including the 'N'th but, of course, it's all words up to and including the next comma if the 'N'th word doesn't end with a comma. In the case of the 201st and 2,202nd words it just so happened that those words did end with a copy and so our sentence lengths were in agreement.
Yuppers, I made sure that the number chosen actually pointed to a word (a spelled ordinal number) that ended in a comma, which would make it (I had hoped) easier to find the problem of the differences in the lengths of the never-ending sentence.   -- Gerard Schildberger (talk) 00:14, 13 September 2017 (UTC)
Anyway, it was easy to fix and our two entries are now in total agreement. --PureFox (talk) 00:05, 13 September 2017 (UTC)

Incidentally, I've altered the preamble to the Kotlin entry now that you've made sentence length part of the task for all values of N.

Yes, thanks to you, I didn't even realized that I used an incorrect phrasing of that requirement.   It was fortunate that you went ahead and adhered to what I had intended.   You must be a seer.   -- Gerard Schildberger (talk) 19:21, 12 September 2017 (UTC)

Thanks for the recent addition of this and some other interesting tasks. --PureFox (talk) 17:48, 12 September 2017 (UTC)

I've got quite a few more in the pipeline, now that I've recovered ... from not being at my best.   -- Gerard Schildberger (talk) 19:21, 12 September 2017 (UTC)

comment about "abbreviations, automatic[edit]

Thanks for finding that error in the table (file) that holds various language names for the days-of-the-week.

I have corrected the 89th line of that file that holds the (older style) Azerbaijani [Azeri] language (for the name of Saturday.

You don't have to re-run the Kotlin language entry if you don't want to.   Hopefully, that should be the last duplicate in that names file.
-- Gerard Schildberger (talk) 01:42, 19 September 2017 (UTC)

Thanks for correcting that line, Gerard. I thought I'd re-run the Kotlin program for the sake of good order and also remove the pre-amble which is no longer relevant. However, I haven't changed the code itself as it does no harm to allow for this possibility and prevents the program from entering an infinite loop.
I had thought of make that one of the task's requirements, but I thought it might be too complicated for this general task.   But looking back, it would've caught three errors in the file.   -- Gerard Schildberger (talk) 23:22, 19 September 2017 (UTC)
Incidentally, following the correction to the Cantonese line, I think your minimum length should now be 12 rather than 13. --PureFox (talk) 21:45, 19 September 2017 (UTC)
Yes, I'll update my correction.   -- Gerard Schildberger (talk) 23:22, 19 September 2017 (UTC)

Go solutions: panic, gofmt[edit]

I see you've added a number of missing Go solutions recently which is excellent.

I have however noticed you have tendency to use panic for error reporting which is a bad practice in Go and should be avoided in examples IMO. At a minimum I'd suggest using log.Fatal in future examples, and ideally that would only appear in the main function, other functions returning an error value as is idiomatic in Go. (Of course, idiomatic uses of panic, such as when detecting unrecoverable programming errors, are quite reasonable.)

Also, when I work on Go solutions here I tend to just copy-paste between my editor and Rosetta's edit web form which preserves the "standard" Go formatting of gofmt (actually goimports for me). I noticed your code uses four space indenting instead of gofmt's tabs==eight spaces which causes your Go solutions to look different from the majority of Go code on this site and elsewhere.

Just a little nitpicking :) —dchapes (talk | contribs) 18:57, 20 June 2018 (UTC)

Yes, you're right that I've been over-using 'panic' in my solutions and I'll try to avoid that in future.
Even though I have a number of issues with 'go fmt' (including the use of tabs rather than spaces), I have in fact been running it on my more recent solutions for the sake of uniformity. However, the one thing I cannot stomach is the use of 8 space tabs for indenting and, since there doesn't appear to be a way to change the tab length in the WikiMedia software, I've had to replace tab characters with (my preferred) 4 spaces before posting.
Although 'go fmt' uses tabs, I don't actually think there is any requirement that these be fixed at 8 spaces because Rob Pike himself stated about a year ago:
"The indent character is tab, whose width is your decision. That's in large part why the indent character is tab: to let you choose how much to indent."
So, if you don't mind, I'll be sticking to my 4 spaces when posting on this site whilst accepting the other strictures of 'go fmt'.
Incidentally, it's good to see that Go has at least 3 active contributors, which is two more than most other languages can boast. As a relative newcomer to the language, it helps me a lot to study other people's solutions.--PureFox (talk) 23:20, 20 June 2018 (UTC)

Mayan numerals[edit]

I like your rendering of Mayan numerals.   You know how to draw a cartouche.   Kudos.     -- Gerard Schildberger (talk) 22:57, 16 January 2019 (UTC)

Thanks Gerard. An interesting task for me as I knew zilch before about Mayan numerals.
I've seen the discussions on how best to display the cartouches but I'm relaxed about using the 'traditional' box drawing characters as, whatever one does, it will be sure not to display properly in some browser or platform.--PureFox (talk) 16:45, 20 January 2019 (UTC)

cuban primes[edit]

Could you update your cuban primes entry?     I had a typo in the requirements, it should be 200 cuban primes to be listed, not 100.     -- Gerard Schildberger (talk) 14:18, 1 February 2019 (UTC)

Sure, I've just attended to it.--PureFox (talk) 14:59, 1 February 2019 (UTC)
Thanks a lot.   Sorry that I missed that typo.   But the good news is that only one language entry (solution) needed to be changed.     -- Gerard Schildberger (talk) 15:03, 1 February 2019 (UTC)

Chemical Calculator[edit]

Haha, sorry for misleading you with my python solution! I still have issues with my Nim solution. It also lacks eval. Typed Nim should be quicker than Python, but my solution is worse. Maybe I will copy yours! --ChristerNilsson (talk) 14:44, 20 March 2019 (UTC)

No problem, Christer:) Your original Python solution (and my Go translation of it) were on the verbose side and I knew I'd run into problems with the lack of eval if I tried to use RE to simplify the parsing. So I thought I'd try and write something from scratch which turned out to be quite easy once I'd come up with a way to evaluate any parenthesized parts of the formula.--PureFox (talk) 15:20, 20 March 2019 (UTC)



I just saw that you translated my Rust code to Go in the Sandpile task. This is the first time anyone "used" my code like that, so this made me quite happy. Thank you! :) - Nemin (talk) 21:52, 24 August 2019 (UTC)

Hey, thanks to you for adding an interesting new task! It's not something I knew anything about previously but your Rust code was nice and clear so I thought I'd just do a straight translation. It's working well :) --PureFox (talk) 23:23, 24 August 2019 (UTC)

agreeing statistics[edit]

I quite relieved that our numbers (totals) match concerning the Rosetta Code task "Fraction reduction".   I was afraid that my code may have missed something and I'd have to re-examine the REXX code to see what is causing the difference.   I know the "five-digit" fractions took my program a wee bit of time to complete,   that is why I made it an optional part of the task.   I don't think I'll try to complete the "six-digit" fractions,   but I'm hoping that somebody will try.     -- Gerard Schildberger (talk) 17:27, 3 September 2019 (UTC)

Yes, I'm relieved as well as it's so easy to make a blunder with this kind of task! I have some ideas about quickening up the Go solution but it will need to be considerably faster to be worthwhile tackling the six-digit fractions. Thanks for posting another interesting task. --PureFox (talk) 18:04, 3 September 2019 (UTC)
I've rewritten it and it's now about 5 times faster than before but probably still not enough to bring the six-digit fractions within reasonable reach. Further improvements may be possible - I'll keep thinking about it. --PureFox (talk) 19:51, 3 September 2019 (UTC)
I've rewritten the REXX version twice, and each time it cut the run time in half.   I can modify the   hasDup   function further,   but it would make the program so not idiomatic, and difficult to read and/or understand.   The gain would be around (maybe) 2% speed reduction,   and it probably wouldn't be worth the ugliness of the code.     -- Gerard Schildberger (talk) 21:04, 3 September 2019 (UTC)
A 4 x speedup for your REXX entry is great. No such luck in my case and I think it's as quick as I can get it. However, I've just acquired a new machine which reduces the runtime for 5-digits to under 25 seconds and has enabled me to process the 6-digit case in about 15.5 minutes. Not as many 'positives' (9778) as I'd have expected so hopefully some-one else will be able to provide an independent check that the stats are correct.--PureFox (talk) 11:16, 6 September 2019 (UTC)

humorous epigraph[edit]

The last time I included an epigraph   (in a Rosetta Code task preamble)   it garnered some push-back.   This time, the epigraph is humorous and more befitting the Rosetta Code task   (complete with a smiley face).     -- Gerard Schildberger (talk) 21:12, 3 September 2019 (UTC)

I don't think you'll get any push-back this time. Made me smile anyway :) --PureFox (talk) 11:17, 6 September 2019 (UTC)
Yeah, I thought it was one of the most amusing little ditty, and of course, to the point of the Rosetta Code task.     -- Gerard Schildberger (talk) 20:09, 6 September 2019 (UTC)

a tank qew[edit]

Again, many thanks for your civility and helpfulness.   A teeny-tiny wee bit of information sure went a long way in clearing this kerfuffle up.   I'm embarrassed how many times I looked at the gosh-darned (pardon my language) output and I didn't see what you saw.   It didn't help the situation that the output (result) was correct (as far as the result), but not the input (field).     -- Gerard Schildberger (talk) 19:21, 29 November 2019 (UTC)

This last go-'round is beginning to seriously task my will to suffer.     -- Gerard Schildberger (talk) 19:44, 29 November 2019 (UTC)

The phenomenon of peoples' minds interpreting the same thing differently   (seeing what it wants to see)   is called   pareidolia.

--- How's that for a six-bit word?       -- Gerard Schildberger (talk) 19:33, 29 November 2019 (UTC)

Haven't come across that word before which looks to be of Greek origin. I'll have to try and build it into my Go examples - make a change from emojis :) --PureFox (talk) 10:40, 30 November 2019 (UTC)

your (Go) comment about the unprimeable task's goals[edit]

I had thought of making some optional requirements (for extra credit or whatever),   but I thought what I eventually come up with was challenging (tough) enough.   I based this on how long me and my REXX program had to struggle with the (somewhat fast) testing for primeness, and other concerns.   (How I wish REXX had a BIF for testing for primeness:   an   isPrime   function).   That would've made the job of creating a new and respectively moderate Rosetta Code task a lot easier,   and also judging how easy (programming wise) a task should be   (say, for most computer programming languages, if not all).   I won't embarrass myself on how long I labored on this task;   one problem was in the wording of the   (or should I say, a)   definition.   I used   a   version that didn't mention that the number had to be composite,   and I stumbled into also generating   weaker   primes   (not to be confused with   weak   primes).   This didn't show up until I stress tested the REXX program in searching for higher unprimeable numbers,   and I just   could not   figure out where the problem was.   This lead to a loss of even more hair   (that I can't afford to lose by pulling it out).   Thank gawd that I had a source that I could reference which had more unprimeable numbers listed and I deduced where the error lay.     -- Gerard Schildberger (talk) 19:50, 1 December 2019 (UTC)

By the way, when I can't see through the fog of some Rosetta Code task's requirements (or algorithms), my first go-to is PL/I, which normally is not present, but has the closest syntax to REXX.   My first major computer programming language was FORTRAN (back when it was all caps), my second language was PL/I.   I can hardly recognize Fortran code anymore.   My third language was GPSS (used for simulation of such things as bank teller queues, highway traffic, planes landing/taking off, etc.   I practically melted my brain in trying to program various scenarios.   All ya do is describe the queue and how people (or things) react, and "it" magically tells ya what ya want (or need) to know.   ... Any-a-ways ...   My second go-to on RC is Go   (a proper and fitting name for a programming language in this case),   it usually is the (for me) the clearest to understand.     -- Gerard Schildberger (talk) 19:50, 1 December 2019 (UTC)

I think I should take a respite from working on Rosetta Code   (et al),   it seems a way bit too toxic at this point,   and I have other hobbies to tend to.   (Never argue with someone who buys ink by the barrel).   I have an extensive library of over 2,500 railroad books (and some steam books), and it's index (descriptions, contents, bibliography, description of the book, ...)   needs a bit of loving attention before it hopefully finds a new home in some RR museum.   I might as well as labor on something that I enjoy and gives me bliss.   Lately, it's been like pushing a chain up hill with Rosetta Code   (cosmetic updates for readability, esthetics, and clarity).   There's way too much ego to contend and hassle with.   My other labor of love is a fancy-dancy, slicer-dicer, all-in-one (interactive, command-line) calculator that has over 1,500 functions in it, and also includes plotting (X, X/Y scatter plots, vertical and horizontal histograms, also supports plotting to all types of terminals/consoles/printers), multiple-argument functions (very much like APL), and many forms of columnar displaying of the output.   Just the documentation (which is quite abbreviated) is over twenty thousand lines.   I've been borrowing stuff from it for almost all of my various Rosetta Code tasks (that're appropriate for this site).   Only a couple of thousand to go   (just teasing).     -- Gerard Schildberger (talk) 19:50, 1 December 2019 (UTC)

Also, by the way, thanks for finding an oversight of mine concerning the unprimeable task  (25 vs. 35).   Another case of not seeing the obvious.   It was at one time, 25,   and I changed it to 35,   but the change was done on my other computer, and it never crossed over (walked over by using a USB stick) to my "work" computer.   My other computer is an air-gap computer, a virgin (by internet standards).     -- Gerard Schildberger (talk) 19:50, 1 December 2019 (UTC)

I'm pleased in a way that you didn't add a stretch goal as these tend to turn into an 'arms race' between the faster languages (and Pascal always wins!).
As you say, tasks involving prime numbers can be a problem when you don't have an isPrime function built-in. Go is in the same boat as REXX here as we don't have anything specifically for numbers up to 64 bits. We do have the ProbablyPrime() method for big integers which is said to be 100% accurate for numbers up to 2^64 (via the Bailee-PSW test) but big integers are unpleasant to use which is why I normally opt for simpler algorithms when the numbers involved are not too large.
My first languages were Algol 60 and Fortran (I've never used PL/I) but I can't remember much about either now. After years of programming in the .NET and JVM languages, the relative simplicity of Go is refreshing (it more or less forces you to write clear, easily maintainable code) and it's good to know that you find it one of the clearer languages to understand yourself :)
There is rather a lot of nit-picking on RC which probably puts people off from adding new tasks. Nevertheless I hope you'll continue to find the time (aside from your other hobbies) to add some more yourself as I always find them interesting and in some cases (the 'rare numbers' one for example) very challenging.
I know you don't always see eye to eye with Thundergnat but I think you'll probably agree that (together with Paddy3118) he does a good job of administering the site, stamping hard on spammers and, of course, adding some interesting tasks himself. --PureFox (talk) 23:17, 1 December 2019 (UTC)
I'd wish he spend more time on removing vanity tags.   He was good along pretty good one day or so at those removals, but he stopped short after removing (mainly) one user who was really polluting one particular computer programming language.   Once vanity tags start showing up, it's hard (if not impossible) to make changes to the code (example) without either making a change that the original author disagrees with, or adding your own vanity tag   (I changed this),   which compounds the problem.   I'd remove them myself, but that can start an ugly and/or dirty edit war real fast, with a lot of name calling and such stuff.       --- Oh yeah?   Well, your mama codes in COBOL!       Spammers are (to me), not that much of a problem, but like rats, if you don't get rid of them early, they soon multiply and everybody has to deal with the rat poop.     -- Gerard Schildberger (talk) 23:56, 1 December 2019 (UTC)
I have some really interesting thoughts about what Rosetta Code tasks that could be entered.   I was "saving" them for later, as it involves something that someone entered on the newsgroup "alt.math.recreational"   --- or ---   "alt.comp",   I forget which.   It was in the same vein as Rosetta Code,   present a problem and have people find algorithms to find a solution.   You WOULD NOT believe the crap that one particular fellow had to endure   (the site is not moderated), more or less what Rosetta Code has (as far as behavior goes).   The last go-round I had at Rosetta Code, one particular fellow was really making a pain of himself.   He has been permanently banned,   but he has returned under several different names, changing his aliases every few months.   And that fellow was doing some pretty bad (destructive) things before he was warned several times before the banning.   Sure, there are RC administrators, but most newsgroups monitor their sites, mainly to stop the spam for illegal drugs, magic crystals, answer books, hateful/racial speechifying, etc.,   and also, really bad and or offense behavior.   Any-a-ways, I have two such problems in mind for Rosetta Code   (and I'm really surprised that no one has introduced them here on RC).   I don't feel the time is right to introduce them yet,   I still feel Rosetta Code needs to have some maturity in dealing with people who don't agree with their (righteous) opinions.   Well, that's my take on it.   I don't know if you ever looked up Rosetta Code on Wikipedia, but someone (long ago) entered an entry on Wikipedia, and it was being voted on for removal as (apparently) somebody's nose was out of joint and didn't think it had enough merit to warrant an entry.   I got involved and I keep updating the RC entry with vital statistics to show how many updates/edits/entries there are, along with the number of programming solutions and the large number of computer programming languages.   The one guy that got permanently banned arrived there and really barfed up the Rosetta Code entry.   It took a bit of work to re-establish the RC entry such that it was usable again.   That guy hung around longer than a fart in a phone booth.     -- Gerard Schildberger (talk) 23:56, 1 December 2019 (UTC)

Not many phone booths around anymore, like dial telephones.   But I digress, once again.     -- Gerard Schildberger (talk) 23:56, 1 December 2019 (UTC)

Possible reason for weather routing discrepancy[edit]

The discrepancy in Weather_Routing#Wren might be mutateTimeSlices iterating i from 0..len-1 vs 1..len, worth trying? --Pete Lomax (talk) 10:54, 17 May 2020 (UTC)

Thanks Pete. I thought I'd picked up all the 1-based to 0-based stuff but I definitely missed that one! There's still a very slight discrepancy - Julia ends up with 283.69787966870734 compared to Wren's 283.67745997075 minutes though this might be due to the former using float32 accuracy throughout whereas Wren (of necessity, there's no choice) uses float64.
Anyway, I've started work now on a Go translation (I think I'll stick with float64 as casting everything to float32 is a pig) and I imagine this means that a Phix translation is now imminent?
Incidentally, I've just noticed that the Cartesian/Polar conversions are never called and neither is the closestPoint function so no need to bother translating those. --PureFox (talk) 13:16, 17 May 2020 (UTC)

Wren sub categories.[edit]

Hi, You created categories for popular words hat are specific to a particular language, i.r. sort for the Wren languah. Would you move such and rename them to Wren/Sort , allowing other languages to not b blocked if they want to do similar.
Thanks. --Paddy3118 (talk) 09:23, 24 May 2020 (UTC)

Well I checked the three names I've used so far: fmt, str and sort (plus several others I'm planning) to make sure that there were no other categories with similar names before I used them and (surprisingly) there were not. This may because most languages will already have this stuff in their standard libraries and so won't have to write it from scratch.
However, I have no objection to prefixing everything with 'Wren/' and think in fact it would be a good idea. I'm not sure whether moving the pages though is the best solution as the original page will then redirect to the new one and nobody will be able to use it without orphaning the new page.
What I propose instead is to recreate the new pages from scratch and change the libheaders in the 60 or so tasks involved to link to those pages. I'll then blank the original pages and tell you when I've done it so you can delete them (presumably you need admin privileges for that).
Although this might sound tedious, I'm going to have to re-examine these tasks (and all the others) done in Wren anyway to see what other repetitive stuff is in there and would be best moved to a separate library. Primality checking and factorization are obvious candidates as I'm constantly copying and pasting the same routines here.
Anyway let me know if you agree with this proposal and I'll get on with it straightaway. --PureFox (talk) 13:47, 24 May 2020 (UTC)
Great. I will delete the pages when told. Thanks a lot. (I just thought that if another language were doing similar...) 👍--Paddy3118 (talk) 02:54, 25 May 2020 (UTC)
Phew! Done all that so the old pages (and their associated talk pages) can now be safely deleted.
Here's a list so you can easily find them:
Although it doesn't really matter, I decided in the end to use a prefix of 'Wren-' rather than 'Wren/' as I wanted to keep the module name lower case (the convention in Wren) and I thought it just looked better :) --PureFox (talk) 11:14, 25 May 2020 (UTC)
Incidentally, I realize that using the 'Wren-" prefix means the modules won't show up as Wren sub-categories though that's good, AFAIC, as I'd prefer people to think of them as libraries rather than sub-categories. Even better they shouldn't show up in the count of tasks completed in Rosetta Code/Rank languages by popularity which, of course, they're not.--PureFox (talk) 13:14, 25 May 2020 (UTC)

Isqrt (integer square root) of X‎‎[edit]

Thanks for speedily updating those two computer programs and output   (by just using the odd powers of seven).   I had overlooked the omission of that word, and I didn't realize until I saw a couple of outputs, and I wondered why are those output sections so large?   When I'm in a hurry and scroll too fast and I can overlook what I'm scrolling through.   Thanks to your speedy updates,   I could remove the pink Noticebox fairly quickly.     -- Gerard Schildberger (talk) 11:38, 16 July 2020 (UTC)

No problem, Gerard, just a minor alteration was needed. Incidentally, I'm glad this task came up as it reminded me that I needed to add an integer square root method to my Wren BigInt class. This algorithm looks ideal as it's non-recursive, uses only integer arithmetic and is reasonably fast so I'm going to look at adding that today. Thanks. --PureFox (talk) 14:19, 16 July 2020 (UTC)

Primes which sum of digits is 25[edit]

Just a small comment, to figure out, how slow an AMD 2200G is.

Your go version takes
 go version go1.16.2 linux/amd64 (installed today) 
There are 1,525,142 primes whose digits sum to 25 and include no zeros.

Took 31.330058446s

only counting
    if rem == 0 {
        b := p[len(p)-1]
        if b == '1' || b == '3' || b == '7' || b == '9' {
            z := new(big.Int)
            z.SetString(p, 10)
            if z.ProbablyPrime(1) {
    } else {
There are 16,499,120 primes whose digits sum to 25 and include no zeros.

Took 4.980341373s

I couldn't compile the cpp version.
I only wanted to know, if generating the possible combinations = 1291 and than create the permutations could be faster for generating the numbers. Horsth 17:55, 29 March 2021 (UTC)

On a 'counting only' basis, the Go example runs in about 3.7 seconds on my machine which is an Intel Core i7-8565U.
The C++ example should compile with a line such as this: g++ -std=c++11 -O3 sum25.cpp -lgmp -o sum25. --PureFox (talk) 18:23, 29 March 2021 (UTC)