Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 1, 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 Multiple
Write a script to accept a positive number as command line argument and print the smallest multiple of the given number consists of digits 0 and 1.
For example:
For given number 55, the smallest multiple is 110 consisting of digits 0 and 1.
A common challenge in calling C functions from any language other than C or C++ is dealing with constants. In C these are usually implemented using #define pre-processor directives which are lost by the time the code is linked into a dynamic library. (In fact it is lost before the source is even compiled, since it is a pre-processor directive). For example, the libarchive library provides these constants in its header file for dealing with errors:
/* * Error codes: Use archive_errno() and archive_error_string() * to retrieve details. Unless specified otherwise, all functions * that return 'int' use these codes.*/
#defineARCHIVE_EOF1/* Found end of archive. */
#defineARCHIVE_OK0/* Operation was successful. */
#defineARCHIVE_RETRY (-10) /* Retry might succeed. */
#defineARCHIVE_WARN (-20) /* Partial success. *//* For example, if write_header "fails", then you can't push data. */
#defineARCHIVE_FAILED (-25) /* Current operation cannot complete. *//* But if write_header is "fatal," then this archive is dead and useless. */
#defineARCHIVE_FATAL (-30) /* No more operations are possible. */
Well some-days it would be nice to get a little advice, without asking for it, before one heads down a very long and in the end futile path.
Today that happened to me when I was starting down a path that I dreaded. Namely creating the 'response' test suite for all those S3 requests I have fixed up over the past few weeks. This type of programming ranges from so mind numbingly dull as to cause your ears to bleed to so incredibility repetitive that you consider that career change to line supervisor at the box factory.
Looking at the prospect of coveting some 70+ working S3 units tests by hand was obviously getting me down a little. It took me a good three or four days of rather mindless hacking and re-running just to to the 'request' tests.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 23, 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: The Survivor
There are 50 people standing in a circle in positions 1 to 50. The person standing at position 1 has a sword. He kills the next person i.e. standing at position 2 and passes 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.
This is sometimes called the Josephus Problem, named after Flavius Josephus, a Jewish historian of the 1st century who allegedly escaped collective suicide of defeated Jewish soldiers trapped by Roman soldiers by finding the right position to be the survivor.
Write a program to validate given Vehicle Identification Number (VIN).
I followed the description at Wikipedia. Sometimes, it wasn’t exactly clear whether the described rule should be valid everywhere or just in a part of the world; the rules also developed with time, so older vehicles can bear VINs that would be considered invalid for a modern car.
Most of the validation is implemented in a single subroutine validate_vin. It takes two parameters, $vin and $sold: the second one says where the car was sold. "North America" and "China" are two values that trigger a different behaviour of the validator.
Work on the Rakudo.js grant has been completed and now I'm add the stage where community feedback is needed. It would be super grateful for Your feedback. You can provide it in blog comments on this post.
The final grant status update is available HERE
November was the quietest month for me. I would give credit to the book Why We Sleep, gifted by Neil Bowers. I haven't finished reading the book yet but whatever I read so far made a big difference. A very big THANK YOU to Neil. I no longer do late nights, technically that means no work after midnight for me. However I do wake up early on weekends and finish the pending work. One more change, I noticed that I don't visit MetaCPAN very often. Earlier I used to checkout every 30 minutes during the day. But now I do it once every couple of days. Having done 160 Pull Requests in October, then doing only 51 Pull Requests in November feels so light. In fact I reached my monthly target of 50+ Pull Requests in the third week of November. Last one week was relaxing, I made conscious efforts not to look for Pull Request.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 9, 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.
I have really very little time to complete this blog post in time for the deadline. My explanations will be minimal, sorry about that.
Roman Calculator
Write a script that accepts two roman numbers and operation. It should then perform the operation on the give roman numbers and print the result.
Today's post proves that test suite, even one that uses canned data, requests and responses, is a very valuable asset to have about.
As I was charging though some 80 action calls copying the requests from my successful unit tests into my t/09_request.t test cases I ran into the odd real bug.
The first one I ran into was to do with the 'PutBucketLogging' action; My real unit test case would work with no problem but as I transferred this real world unit test into canned test cases I got a fail on some of the composed XML.
You want to get to know your data, questions like,
can they be broken down into a simple set of classes.
You don't know what these classes might be, so your
task is clustering and you reach for one of the
oldest clustering algorithms around k-means.
k-means is popular because it's simple to understand,
converges fast, works in higher dimensions
and gives you an answer.
It's also usually the wrong choice unless you've
already got nicely clustered data just waiting for you
to guess k, the most appropriate number of clusters
to answer your question. But it is a decent warm up
exercise in becoming friends with your data set.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 9, 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.
Garbled Message
The communication system of an office is broken and message received are not completely reliable. To send message Hello, it ended up sending these following:
H x l 4 !
c e - l o
z e 6 l g
H W l v R
q 9 m # o
Similarly, another day we received a message repeatedly like below:
I ending up in my last post with a test that was running but most of the tests where failing.
ok 1 - Call S3->CreateBucket from /home/scolesj/aws-sdk-perl/t/09_requests/s3-create-bucket.request
ok 2 - Got content eq from result
…
ok 11 - Got method eq PUT from result
I had a look at the request object I was getting back
I didn't notice much public discussion, but in the last month, Perl 5
development has moved to Github. The logistics of the move were mostly handled
by Todd Rinaldo although I'm sure there were other people helping.
The change involved moving the main development repository from
perl5.git.perl.org to https://github.com/Perl/perl5,
moving the issues from rt.perl.org to Github issues, renaming them in the
process, and fixing the code that used the hostnames or URLs for decisions.
The square secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right.
For example, the message is “The quick brown fox jumps over the lazy dog”.
Goodness Paws 30 and I am at least code compete as far as running through all of the different action found on S3. Now that leads me to a very important part.
I now have to do a little bit of back peddling and come up with a test suite for all the now fixed S3 actions. 90% of the bugs and fixes I have done so far on S3 have been for requests to the server not checking responses form the server.
Following on with this it makes sense that I test how things are sent to the server as well. I had a peek about in the test suite and except for a few of the basic actions there are no tests on request calls.
Some time ago I have created a small web project about Perl programming language. The site where you can execute Perl code online — PerlBanjo.com. (blog post about the release)
Today I'm happy to announce the new small project about Perl. This is the place with interactive coding tasks. You solve the task, enter the solution, system run it and tell you if it accept your submission. (PerlBanjo.com is used as a backend to run Perl code)
Now there are only several tasks. The source code for all the all tasks is hosted on GitHub, so anybody can propose a fix for the task or create the new task.