Raku Challenge, Week 92, Issue 1

This week’s task has an interesting solution in Raku. So, here’s the task:

You are given two strings $A and $B. Write a script to check if the given strings are Isomorphic. Print 1 if they are otherwise 0.

This week’s task has an interesting solution in Raku. So, here’s the task:

You are given two strings $A and $B. Write a script to check if the given strings are Isomorphic. Print 1 if they are otherwise 0.

Gray code in Raku

Let us create a one-liner to generate the sequence of the so-called Gray code in the Raku programming language. This code is essentially a method of binary coding so that for each of the following integer number, you only change a single bit.

Let us create a one-liner to generate the sequence of the so-called Gray code in the Raku programming language. This code is essentially a method of binary coding so that for each of the following integer number, you only change a single bit.

A few more Raku challenges

1) From the given digits L, combine all possible numbers that are less than Y and that contain exactly X digits. 2) Write a function that from the given string returns the last word that matches the given regex.

1) From the given digits L, combine all possible numbers that are less than Y and that contain exactly X digits. 2) Write a function that from the given string returns the last word that matches the given regex.

Another Raku one-liner

Let me demonstrate another interesting one-liner that I find to be a good addition to my last years’s book Raku One-Liners. The task was inspired by this week’s problem from the Perl Weekly Challenge.

Let me demonstrate another interesting one-liner that I find to be a good addition to my last years’s book Raku One-Liners. The task was inspired by this week’s problem from the Perl Weekly Challenge.

Raku One-Liners — a free book

Let me announce the new book, Raku One-Liners. Electronic editionAmazon Kindle Paperback editionsAmazon.com, Amazon.de (and also on other local Amazon sites) The book is available in the PDF format for free. Paperback copies are available on Amazon. Download the Raku One-Liners book now N.B. As of today, the book is in the test mode, and … Continue reading “Raku One-Liners — a free book”

🎄 26/25. Overview of the Perl 6 One-Liner Advent Calendar 2018

The Perl 6 One-Liner Advent Calendar 2018 is over! Let’s make a quick overview of what we have covered so far. There were a few themes covered. First, some one-liners from the Perl 6 Calendar 2019 were explained in more detail. We looked at how to generate random passwords and random integers, how to print … Continue reading “🎄 26/25. Overview of the Perl 6 One-Liner Advent Calendar 2018”

🎄 25/25. Tips and ideas for the Perl 6 Golf code

Welcome to Day 25, the last day of the Perl 6 One-Liner Advent Calendar! Traditional advent calendars have only 24 entries, and our bonus post today will be dedicated to some tips and tricks that you can use in Perl 6 golf contest. There is a great site, code-golf.io, where you can try solving a … Continue reading “🎄 25/25. Tips and ideas for the Perl 6 Golf code”

🎄 24/25. Reading files with $*ARGFILES in Perl 6

Welcome to Day 24 of the Perl 6 One-Liner Advent Calendar! In the previous days, we were reading text files, so it would be logical to talk about $*ARGFILES, a built-in dynamic variable that may be handy when working with multiple input files. How do you read two or more files passed in the command-line? … Continue reading “🎄 24/25. Reading files with $*ARGFILES in Perl 6”

🎄 23/25. Calculating totals with Perl 6

Welcome to Day 23 of the Perl 6 One-Liner Advent Calendar! End of the year is the time when people evaluate there year results, and Perl 6 can help with that, too. Today, we’ll see a one-liner that calculates totals for the columns of a table. Here’s some sample data in a file: 100.20 303.50 … Continue reading “🎄 23/25. Calculating totals with Perl 6”

🎄 22/25. Reversing a file with Perl 6

Welcome to Day 22 of the Perl 6 One-Liner Advent Calendar! Today, we will continue working with files, and the goal for today is to create a one-liner to print the lines of a text file in reversed order (as tail -r does it). The first one-liner does the job with the STDIN stream: .say … Continue reading “🎄 22/25. Reversing a file with Perl 6”

🎄 21/25. Merging files horizontally in Perl 6

Welcome to Day 21 of the Perl 6 One-Liner Advent Calendar! Only a few days left until the end of this season of advent calendars, so let’s pack as many things as possible in the remaining days, and today we’ll merge a few files into a single file 🙂 Our today’s goal is to take … Continue reading “🎄 21/25. Merging files horizontally in Perl 6”

🎄 20/25. Using command-line options in Perl 6 one-liners

Welcome to Day 20 of the Perl 6 One-Liner Advent Calendar! So far, we created about 25 different one-liners, but never talked about the command-line options that the Rakudo Perl 6 compiler offers to us. -e The first option to know when working with (Rakudo) Perl 6 is -e. It takes a string with your Perl 6 one-liner … Continue reading “🎄 20/25. Using command-line options in Perl 6 one-liners”

🎄 19/25. Using map and Seq to compute the value of π in Perl 6

Welcome to Day 19 of the Perl 6 One-Liner Advent Calendar! Today, we will be computing the value of π using two different methods. The goal of this blog post is to play with different approaches to generate numeric sequences. Pre-party Of course, in Perl 6 you don’t need to calculate the value of π … Continue reading “🎄 19/25. Using map and Seq to compute the value of π in Perl 6”

🎄 18/25. Renaming files with Perl 6

Welcome to Day 18 of the Perl 6 One-Liner Advent Calendar! Today, there will be a true one-liner, in the sense that you run it from the terminal as a devops. Our task is to rename all the files passed in the command-line arguments and give the files sequential numbers in the preferred format. Here … Continue reading “🎄 18/25. Renaming files with Perl 6”

🎄 17/25. Playing with prime numbers in Perl 6

Welcome to Day 17 of the Perl 6 One-Liner Advent Calendar! Today, we’ll have two one-liners, both generating some prime numbers. Part 1 First, let us solve Problem 7 of Project Euler, where you need to print the 10001st number (having the first being 2). Perl 6 is good at prime numbers, as it has … Continue reading “🎄 17/25. Playing with prime numbers in Perl 6”

🎄 16/25. Distance between two points in Perl 6

Welcome to Day 16 of the Perl 6 One-Liner Advent Calendar! Today, we’ll solve a simple problem and will find the distance between two points on a surface. Here’s an illustration to help to formulate the task. Our goal is to find the distance between the points A and B. To make the answer more … Continue reading “🎄 16/25. Distance between two points in Perl 6”

🎄 15/25. Playing with Fibonacci numbers in Perl 6

Welcome to Day 15 of the Perl 6 One-Liner Advent Calendar! Today, there will be two one-liners, and they both generate Fibonacci numbers. Yes, most likely, you never used such numbers in real code, and, again, most likely, you solved many educating problems with them. Nevertheless, today, let’s solve the Problem 25 of the Project … Continue reading “🎄 15/25. Playing with Fibonacci numbers in Perl 6”

🎄 14/25. Another solution of yesterday’s problem

Welcome to Day 14 of the Perl 6 One-Liner Advent Calendar! Today, we are presenting another solution of the problem we were solving yesterday. The task was to count all Sundays that fall on the first of the month in the XX century. Yesterday, we just scanned through all the days in the whole century, … Continue reading “🎄 14/25. Another solution of yesterday’s problem”

🎄 13/25. How many days in the century match the condition?

Welcome to Day 13 of the Perl 6 One-Liner Advent Calendar! Today’s one-liner will be quite long, and it would be better to write it in two lines, but it will show a very nice feature of Perl 6’s Date objects: it can be easily used in a range. Today, we are solving Problem 19 … Continue reading “🎄 13/25. How many days in the century match the condition?”

🎄 12/25. What’s behind 0.1+0.2 in Perl 6

Welcome to Day 12/25 of this year’s Perl 6 One-Liner Advent Calendar! Today, we will examine a one-liner that computes a zero. say 0.1 + 0.2 – 0.3 If you are familiar with programming, you know well that as soon as you start using floating-point arithmetic, you loose precision, and you can face the small … Continue reading “🎄 12/25. What’s behind 0.1+0.2 in Perl 6”