RSSAmplifier

Blog

RabbitFarm

Adam Russell's Journal

rabbitfarm.comRSS feed ↗40 posts

Latest posts

<!DOCTYPE html>

The Weekly Challenge 383 (Prolog Solutions) The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Similar List You are given three list of strings. Write a script to find out if the first two list are similar with the help the third list. The third list contains the similar words map. Our solution is short and will be contained in a…

<!DOCTYPE html>

Similar and Nearest but in No Way Clearest The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Similar List You are given three list of strings. Write a script to find out if the first two list are similar with the help the third list. The third list contains the similar words map. The code can be contained in a single file which has…

<body>

NetBSD/MacPPC 9.4 Installation on a QEMU emulated PowerPC Macintosh Summary Apple last used PowerPC chips about twenty years ago, then transitioned to Intel based chips until 2020 with the introduction of ARM based systems. For many years the older PowerPC based systems could be inexpensively purchased on the used market. As time continues to pass these are increasingly rare to find at all, much…

<h3 class='likesectionHead' id='lets-count-all-of-our-nice-strings'><a id='x1-1000'></a>Let’s Count All of Our Nice Strings</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Counter Integers You are given a string containing only lower case English letters and digits. Write a script to replace every non-digit character with a space and then return all the distinct integers left. The code can be contained in a single file which has the following…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 328 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Replace all ? You are given a string containing only lower case English letters and ?. Write a script to replace all ? in the given string so that the string doesn’t contain consecutive repeating characters. Our solution is short and will be contained in a single file that has the…

<h3 class='likesectionHead' id='a-good-string-is-irreplaceable'><a id='x1-1000'></a>A Good String Is Irreplaceable</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Replace all ? You are given a string containing only lower case English letters and ?. Write a script to replace all ? in the given string so that the string doesn’t contain consecutive repeating characters. The core of the solution is contained in a single subroutine. The resulting…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 327 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Missing Integers You are given an array of n integers. Write a script to find all the missing integers in the range 1..n in the given array. Our solution is short and will be contained in a single file that has the following structure. "ch-1.p" 1 ≡ ⟨ missing integers 2 ⟩ ◇ This…

<h3 class='likesectionHead' id='missing-integers-dont-make-me-mad-just-disappointed'><a id='x1-1000'></a>Missing Integers Don’t Make Me MAD, Just Disappointed</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Missing Integers You are given an array of n integers. Write a script to find all the missing integers in the range 1..n in the given array. The core of the solution is contained in a single subroutine. The resulting code can be contained in a single file. "ch-1.pl" 1 ≡ use v5.40; ⟨…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 326 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Day of the Year You are given a date in the format YYYY-MM-DD. Write a script to find day number of the year that the given date represent. Our solution is short, it involves just a couple of computations, and will be contained in a single file that has the following structure.…

<h3 class='likesectionHead' id='the-day-we-decompress'><a id='x1-1000'></a>The Day We Decompress</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Day of the Year You are given a date in the format YYYY-MM-DD. Write a script to find day number of the year that the given date represent. The core of the solution is contained in a main loop. The resulting code can be contained in a single file. "ch-1.pl" 1 ≡ use v5.40; ⟨ compute…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 325 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Consecutive One You are given a binary array containing only 0 or/and 1. Write a script to find out the maximum consecutive 1 in the given array. Our solution is short and will be contained in a single file that has the following structure. "ch-1.p" 1 ≡ ⟨ state of the count 2 ⟩ ⟨…

<h3 class='likesectionHead' id='consecutive-search-for-discount-prices'><a id='x1-1000'></a>Consecutive Search for Discount Prices</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Consecutive One You are given a binary array containing only 0 or/and 1. Write a script to find out the maximum consecutive 1 in the given array. The core of the solution is contained in a main loop. The resulting code can be contained in a single file. "ch-1.pl" 1 ≡ use v5.40; ⟨…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 324 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: 2D Array You are given an array of integers and two integers $r and $c. Write a script to create two dimension array having $r rows and $c columns using the given array. Our solution is short and will be contained in a single file that has the following structure. "ch-1.p" 1 ≡ ⟨…

<h3 class='likesectionHead' id='two-dimensional-xor-not'><a id='x1-1000'></a>Two Dimensional XOR Not?</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: 2D Array You are given an array of integers and two integers $r and $c. Write a script to create two dimension array having $r rows and $c columns using the given array. The core of the solution is contained in a main loop. The resulting code can be contained in a single file.…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 323 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Increment Decrement You are given a list of operations. Write a script to return the final value after performing the given operations in order. The initial value is always 0. Our solution will be contained in a single file that has the following structure. "ch-1.p" 1 ≡ ⟨ update…

<h3 class='likesectionHead' id='incremental-taxation'><a id='x1-1000'></a>Incremental Taxation</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Increment Decrement You are given a list of operations. Write a script to return the final value after performing the given operations in order. The initial value is always 0. Let’s entertain ourselves with an over engineered solution! We’ll use Parse::Yapp to handle incrementing…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 322 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1:String Format You are given a string and a positive integer. Write a script to format the string, removing any dashes, in groups of size given by the integer. The first group can be smaller than the integer but should have at least one character. Groups should be separated by dashes.…

<h3 class='likesectionHead' id='ordered-format-array'><a id='x1-1000'></a>Ordered Format Array</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: String Format You are given a string and a positive integer. Write a script to format the string, removing any dashes, in groups of size given by the integer. The first group can be smaller than the integer but should have at least one character. Groups should be separated by…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 321 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Distinct Average You are given an array of numbers with even length. Write a script to return the count of distinct average. The average is calculate by removing the minimum and the maximum, then average of the two. Our solution will be pretty short, contained in just a single file…

<h3 class='likesectionHead' id='back-to-a-unique-evaluation'><a id='x1-1000'></a>Back to a Unique Evaluation</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Distinct Average You are given an array of numbers with even length. Write a script to return the count of distinct average. The average is calculate by removing the minimum and the maximum, then average of the two. Our solution will be pretty short, contained in just a single file…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 320 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Maximum Count You are given an array of integers. Write a script to return the maximum between the number of positive and negative integers. Zero is neither positive nor negative. Our solution will be pretty short, contained in just a single file that has the following structure.…

<h3 class='likesectionHead' id='summit-of-count-deviation'><a id='x1-1000'></a>Summit of Count Deviation</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Maximum Count You are given an array of integers. Write a script to return the maximum between the number of positive and negative integers. Zero is neither positive nor negative. Our solution will be pretty short, contained in just a single file that has the following structure.…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 319 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Word Count You are given a list of words containing alphabetic characters only. Write a script to return the count of words either starting with a vowel or ending with a vowel. Our solution will be pretty short, contained in just a single file that has the following structure.…

<h3 class='likesectionHead' id='in-the-count-of-common'><a id='x1-1000'></a>In the Count of Common</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Word Count You are given a list of words containing alphabetic characters only. Write a script to return the count of words either starting with a vowel or ending with a vowel. Our solution will be pretty short, contained in just a single file that has the following structure.…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 318 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Group Position You are given a string of lowercase letters. Write a script to find the position of all groups in the given string. Three or more consecutive letters form a group. Return “” if none found. We can do this in a single predicate which uses maplist to get the groupings…

<h3 class='likesectionHead' id='group-position-reversals'><a id='x1-1000'></a>Group Position Reversals</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Group Position You are given a string of lowercase letters. Write a script to find the position of all groups in the given string. Three or more consecutive letters form a group. Return “” if none found. Here’s our one subroutine, this problem requires very little code. ⟨ groupings…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 317 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Acronyms You are given an array of words and a word. Write a script to return true if concatenating the first letter of each word in the given array matches the given word, return false otherwise. We can do this in a single predicate which uses maplist to get the first character…

<h3 class='likesectionHead' id='acronyms-among-friends'><a id='x1-1000'></a>Acronyms Among Friends</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Acronyms You are given an array of words and a word. Write a script to return true if concatenating the first letter of each word in the given array matches the given word, return false otherwise. Here’s our one subroutine, this problem requires very little code. ⟨ acronyms 1 ⟩≡ sub…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 316 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Circular You are given a list of words. Write a script to find out whether the last character of each word is the first character of the following word. We can do this in a single predicate which recursively examines the list of words, which we’ll take as a list of character code…

<h3 class='likesectionHead' id='going-around-in-sequential-circles'><a id='x1-1000'></a>Going Around in Sequential Circles</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Circular You are given a list of words. Write a script to find out whether the last character of each word is the first character of the following word. This seems straightforward enough. One question is whether we need to only consider the words in their given order. We’ll assume…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 315 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Find Words You are given a list of words and a character. Write a script to return the index of word in the list where you find the given character. This can be done with a basic predicate with findall. Or we can use maplist! maplist is more fun in my opinion, so we’ll go with that.…

<h3 class='likesectionHead' id='finding-a-third-of-the-words'><a id='x1-1000'></a>Finding a Third of the Words</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Find Words You are given a list of words and a character. Write a script to return the index of word in the list where you find the given character. This can be done in essentially one line. Rather than write a true Perl one-liner for the command line though, we’ll package this into…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 314 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Equal Strings You are given three strings. You are allowed to remove the rightmost character of a string to make all equals. Write a script to return the number of operations to make it equal otherwise -1. The approach we’ll take is to pop off the last letter of each and compare the…

<h3 class='likesectionHead' id='equally-sorted'><a id='x1-1000'></a>Equally Sorted</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Equal Strings You are given three strings. You are allowed to remove the rightmost character of a string to make all equals. Write a script to return the number of operations to make it equal otherwise -1. The fact that we’re give exactly three strings makes things slightly easier.…

<h3 class='likesectionHead' id='reverse-broken-keys-for-letters'><a id='x1-1000'></a>Reverse Broken Keys for Letters</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Broken Keys You have a broken keyboard which sometimes type a character more than once. You are given a string and actual typed string. Write a script to find out if the actual typed string is meant for the given string. What we’re faced with here is a problem of removing…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 312 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Minimum Time You are given a typewriter with lowercase english letters a to z arranged in a circle. Typing a character takes 1 sec. You can move pointer one character clockwise or anti-clockwise. The pointer initially points at a. Write a script to return minimum time it takes to…

<h3 class='likesectionHead' id='minimum-time-in-the-box'><a id='x1-1000'></a>Minimum Time in the Box</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Minimum Time You are given a typewriter with lowercase english letters a to z arranged in a circle. Typing a character takes 1 sec. You can move pointer one character clockwise or anti-clockwise. The pointer initially points at a. Write a script to return minimum time it takes to…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 311 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Upper Lower You are given a string consists of english letters only. Write a script to convert lower case to upper and upper case to lower in the given string. GNU Prolog defines a predicate lower_upper/2 which does pretty much what this problem is asking for. We could also just use…

<h3 class='likesectionHead' id='lower-the-upper-sums'><a id='x1-1000'></a>Lower the Upper Sums!</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Upper Lower You are given a string consists of english letters only. Write a script to convert lower case to upper and upper case to lower in the given string. The complete solution is contained in one file that has a simple structure. "ch-1.pl" 1 ≡ ⟨ preamble 2 ⟩ ⟨ upper lower…

<h3 class='likesectionHead' id='the-weekly-challenge-prolog-solutions'><a id='x1-1000'></a>The Weekly Challenge 310 (Prolog Solutions)</h3>

The examples used here are from the weekly challenge problem statement and demonstrate the working solution. Part 1: Arrays Intersection You are given a list of array of integers. Write a script to return the common elements in all the arrays. Let’s define a predicate that can be called via maplist. This will just wrap member and be used to return a list of common elements. We’ll also remove…