This is a part of Perl Weekly Challenge(PWC) #052 and the followings are related to my solution. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email) if possible, before reading my blog post.
Do tell me if I am wrong or you strongly oppose my statements!
I register a free account on blogs.perl.org . The process is surprisingly easy but I am a bit nervous that my posts are put along those of experienced coders on the frontpage of blogs.perl.org .
Spoiler Alert: This weekly challenge deadline is due in several days (October 4, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Smallest Positive Number Bits
You are given unsorted list of integers @N.
Write a script to find out the smallest positive number missing.
Well back to the PAWs game again. This is one group of actions that has really got me distracted.
In my last post I manged to get 'SubscribeToShard' to work with my stream decoder though it is really just beta code for now. What first go me distracted was reading along in the Amazon doc I saw a bit about streaming an audio file.
Well the last time I worked on this sort of stream was in the dieing days of the last century??
This got me thinking and I went downstairs and dusted off my good old 2201 and fired it up thinking it might come in useful. Next I had to find some 'C' code and files I had from that time that I think I had on on 3.5 floppy in my upstairs closet.
Well I found the disks and once my HP Pavilion booted up I found that the disks where sill readable and still compiled. Well step one and two done.
As I started learning Perl I found out that there is a collection of Perl modules for bioinformatics tasks and it is called BioPerl. Intrigued I decided to try to use it for a simple task as it would help me in learning Perl. So the next question was: what task should I choose? Maybe download file with biological sequences, parse it and filter according some criteria? Thinking about this further I made a choice. I will work with sequences of infamous coronavirus which is more precisely named as SARS-CoV-2!
Spikes of coronaviruses – why are they so important?
Spoiler Alert: This weekly challenge deadline is due in a couple of days (September 27, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Count Set Bits
You are given a positive number $N.
Write a script to count the total number of set bits of the binary representations of all numbers from 1 to $N and return $total_count_set_bit % 1000000007.
As we take another lap around the k-Means race trace,
the Porsche 914-2 and Volvo 142E
are still neck and neck.
This time we'll try a straight-forward normalisation
that linearly scales all values to the range [0,1]
and see if they still end up in the same cluster.
I think in my last post I said this is going to be a very short series well I think I am wrong on that count.
When I last posted on the Kinesis 'SubscribeToShard' action I discovered that it is returning a 'application/vnd.amazon.eventstream' and that lead me down a very deep rabbit hole that got me well sidetracked.
Well to start out I had to figure out what AWS was returning when it was sending 'vnd.amason.eventstream' I eventually found that here Event Stream Encoding
Ok time to take the way-back machine to my first play-dates with computers, assembling GIS data from an Amdahl mainframe that was spooling a 9inch tape directly to my Unitron 2000
over a 330 baud modem, Then taking the various bits, and putting them back together so I could draw pretty maps on this;
Spoiler Alert: This weekly challenge deadline is due in a few days (September 20, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Leader Element
You are given an array @A containing distinct integers.
Write a script to find all leader elements in the array @A. Print (0) if none found.
An element is leader if it is greater than all the elements to its right side.
There are signatures in Raku, core Perl 5, Moose, Dios and lot of other modules. With KBOS I tried to find out how optimal signatures would look like to me. My objectives are: 3. easy to parse with the eye, 2. concise syntax and 1. delegates as much work as possible into the background so I have to write the least amount of code.
Hi. The current version of perlmodules.net was made in 2013/2014 with AngularJS, it is hard to update and so I’m starting a remake of the site.
Apart from an aesthetic makeover, it will be built with Vue.js/nuxt.js in order to allow the site to be indexed by all search engines. New features and ways of viewing the data may be added.
It will still use Mojolicious, but will use PostgreSQL instead of (the current site’s) MySQL, DBIx::Class instead of Rose::DB::Object, plus also Minion, RxJS, and will be open-sourced.
Help from the community will be very welcome. If anyone wants to join the discussion, please join our IRC channel, at irc://irc.freenode.net/#perlmodules.net
Looking back at my last month performance, I get mixed feelings. I feel bad that I only submitted 7 Pull Requests. It is not that I didn't try to up the number. I noticed some of my past Pull Request disappearing from GitHub. It is affecting my Pull Request Stats. I keep all contributions record under my GitHub profile. It gives me sense of accomplishments.
The best part of last month was that I finally started taking part in The Weekly Challenge. Not only just code contributions but also blogged about it. It was possible because of help by fellow Team PWC member, Ryan Thompson.
What am I looking forward in the month of March? Well, I am looking forward to celebrate the completion of one year of "Perl Weekly Challenge" on 25th March 2020.
In my last report, I mentioned about my Dad's health. I am happy to announce that he is doing better and no longer dependent on others.
Let's take a quick look through last month main activities.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (September 13, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Fibonacci Sum
You are given a positive integer $N.
Write a script to find out the smallest combination of Fibonacci Numbers required to get $N on addition.
You are NOT allowed to repeat a number. Print 0 if none found.
*{; no strict 'refs'; \*{ "${pkg}::type" } } = sub () { $type };
push @{; no strict 'refs'; \@{ "${pkg}::ISA" } }, __PACKAGE__;
# ... and so on
I really don’t feel like I have anything to add but I suppose it may not be obvious that the point of this exercise is to surgically limit the lifting of the refs stricture to just the desired symbolic dereference (without leaking it even as far as any other part of the expression) – in the most compact form possible.
I also suppose I ought to expand on it by way of explanation for the less travelled in the dustier corners of Perl 5 syntax:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on Aug. 16, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task #1: Prime Sum
I’ve written a Raku program to solve this task, but it is unfortunately a bit buggy: it works in most cases, but there are a few rare cases where it doesn’t find the minimum number of prime numbers whose summation gives you the target number. I certainly don’t want to publish here a program which I know to be faulty in some cases, and I no longer have time before the deadline to fix it. So, I’ll skip this task for now.
Another great Perl software that I find very useful is Monitorix.
Monitorix is FOSS lightweight system monitoring designed to monitor as many services and system resources as possible.
The tl;dr is that it works really well for monitoring stand alone machines- which is what I used it for. It's tracks all sorts of metrics with minimal configuration by me, and with packages for most distros its trivial to install and update.
There are 50 people standing in a circle in position 1 to 50. The person standing at position 1 has a sword. He kills the next person i.e. standing at position 2 and pass on the sword to the immediate next i.e. person standing at position 3. Now the person at position 3 does the same and it goes on until only one survives.
Write a script to find out the survivor.
I tried two different approaches to the problem.
The first one uses an array of living people and a variable $sword that stores the index of the person holding the sword. In each iteration of the loop, the next person is removed from the array, and the sword is passed to the next person.
The “next person” has a special cyclic meaning: at the end of the array, the sword must return to the beginning. This is achieved by using the modulo operator %. Note that we use it twice, once to find the person to kill, and once to find the person to pass the sword to—and each case uses a different array size in the modulo operation, as killing a person changes the size of the array.