@@ -4,7 +4,7 @@ Create an implementation of the affine cipher, an ancient encryption system crea
|
||||
|
||||
The affine cipher is a type of monoalphabetic substitution cipher.
|
||||
Each character is mapped to its numeric equivalent, encrypted with a mathematical function and then converted to the letter relating to its new numeric value.
|
||||
Although all monoalphabetic ciphers are weak, the affine cipher is much stronger than the atbash cipher, because it has many more keys.
|
||||
Although all monoalphabetic ciphers are weak, the affine cipher is much stronger than the Atbash cipher, because it has many more keys.
|
||||
|
||||
[//]: # " monoalphabetic as spelled by Merriam-Webster, compare to polyalphabetic "
|
||||
|
||||
@@ -18,10 +18,10 @@ E(x) = (ai + b) mod m
|
||||
|
||||
Where:
|
||||
|
||||
- `i` is the letter's index from `0` to the length of the alphabet - 1
|
||||
- `i` is the letter's index from `0` to the length of the alphabet - 1.
|
||||
- `m` is the length of the alphabet.
|
||||
For the Roman alphabet `m` is `26`.
|
||||
- `a` and `b` are integers which make the encryption key
|
||||
For the Latin alphabet `m` is `26`.
|
||||
- `a` and `b` are integers which make up the encryption key.
|
||||
|
||||
Values `a` and `m` must be _coprime_ (or, _relatively prime_) for automatic decryption to succeed, i.e., they have number `1` as their only common factor (more information can be found in the [Wikipedia article about coprime integers][coprime-integers]).
|
||||
In case `a` is not coprime to `m`, your program should indicate that this is an error.
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# Instructions
|
||||
|
||||
Your task is to, given a target word and a set of candidate words, to find the subset of the candidates that are anagrams of the target.
|
||||
Given a target word and one or more candidate words, your task is to find the candidates that are anagrams of the target.
|
||||
|
||||
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
|
||||
A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`.
|
||||
|
||||
The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
|
||||
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`.
|
||||
The anagram set is the subset of the candidate set that are anagrams of the target (in any order).
|
||||
Words in the anagram set should have the same letter case as in the candidate set.
|
||||
The target word and candidate words are made up of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
|
||||
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `"StoP"` is not an anagram of `"sTOp"`.
|
||||
The words you need to find should be taken from the candidate words, using the same letter case.
|
||||
|
||||
Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`.
|
||||
Given the target `"stone"` and the candidate words `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, and `"Seton"`, the anagram words you need to find are `"tones"`, `"notes"`, and `"Seton"`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Instructions
|
||||
|
||||
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
|
||||
Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.
|
||||
|
||||
The Atbash cipher is a simple substitution cipher that relies on transposing all the letters in the alphabet such that the resulting alphabet is backwards.
|
||||
The first letter is replaced with the last letter, the second with the second-last, and so on.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
".meta/zcl_atbash_cipher.clas.abap"
|
||||
]
|
||||
},
|
||||
"blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.",
|
||||
"blurb": "Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.",
|
||||
"source": "Wikipedia",
|
||||
"source_url": "https://en.wikipedia.org/wiki/Atbash"
|
||||
}
|
||||
|
||||
@@ -1,29 +1,3 @@
|
||||
# Instructions
|
||||
|
||||
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
|
||||
|
||||
Take any positive integer n.
|
||||
If n is even, divide n by 2 to get n / 2.
|
||||
If n is odd, multiply n by 3 and add 1 to get 3n + 1.
|
||||
Repeat the process indefinitely.
|
||||
The conjecture states that no matter which number you start with, you will always reach 1 eventually.
|
||||
|
||||
Given a number n, return the number of steps required to reach 1.
|
||||
|
||||
## Examples
|
||||
|
||||
Starting with n = 12, the steps would be as follows:
|
||||
|
||||
0. 12
|
||||
1. 6
|
||||
2. 3
|
||||
3. 10
|
||||
4. 5
|
||||
5. 16
|
||||
6. 8
|
||||
7. 4
|
||||
8. 2
|
||||
9. 1
|
||||
|
||||
Resulting in 9 steps.
|
||||
So for input n = 12, the return value would be 9.
|
||||
Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture.
|
||||
|
||||
28
exercises/practice/collatz-conjecture/.docs/introduction.md
Normal file
28
exercises/practice/collatz-conjecture/.docs/introduction.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Introduction
|
||||
|
||||
One evening, you stumbled upon an old notebook filled with cryptic scribbles, as though someone had been obsessively chasing an idea.
|
||||
On one page, a single question stood out: **Can every number find its way to 1?**
|
||||
It was tied to something called the **Collatz Conjecture**, a puzzle that has baffled thinkers for decades.
|
||||
|
||||
The rules were deceptively simple.
|
||||
Pick any positive integer.
|
||||
|
||||
- If it's even, divide it by 2.
|
||||
- If it's odd, multiply it by 3 and add 1.
|
||||
|
||||
Then, repeat these steps with the result, continuing indefinitely.
|
||||
|
||||
Curious, you picked number 12 to test and began the journey:
|
||||
|
||||
12 ➜ 6 ➜ 3 ➜ 10 ➜ 5 ➜ 16 ➜ 8 ➜ 4 ➜ 2 ➜ 1
|
||||
|
||||
Counting from the second number (6), it took 9 steps to reach 1, and each time the rules repeated, the number kept changing.
|
||||
At first, the sequence seemed unpredictable — jumping up, down, and all over.
|
||||
Yet, the conjecture claims that no matter the starting number, we'll always end at 1.
|
||||
|
||||
It was fascinating, but also puzzling.
|
||||
Why does this always seem to work?
|
||||
Could there be a number where the process breaks down, looping forever or escaping into infinity?
|
||||
The notebook suggested solving this could reveal something profound — and with it, fame, [fortune][collatz-prize], and a place in history awaits whoever could unlock its secrets.
|
||||
|
||||
[collatz-prize]: https://mathprize.net/posts/collatz-conjecture/
|
||||
@@ -14,6 +14,6 @@
|
||||
]
|
||||
},
|
||||
"blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.",
|
||||
"source": "An unsolved problem in mathematics named after mathematician Lothar Collatz",
|
||||
"source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem"
|
||||
"source": "Wikipedia",
|
||||
"source_url": "https://en.wikipedia.org/wiki/Collatz_conjecture"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Instructions
|
||||
|
||||
Write a function that returns the earned points in a single toss of a Darts game.
|
||||
Calculate the points scored in a single toss of a Darts game.
|
||||
|
||||
[Darts][darts] is a game where players throw darts at a [target][darts-target].
|
||||
|
||||
@@ -16,7 +16,7 @@ In our particular instance of the game, the target rewards 4 different amounts o
|
||||
The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1.
|
||||
Of course, they are all centered at the same point — that is, the circles are [concentric][] defined by the coordinates (0, 0).
|
||||
|
||||
Write a function that given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), returns the correct amount earned by a dart landing at that point.
|
||||
Given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), calculate the correct score earned by a dart landing at that point.
|
||||
|
||||
## Credit
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
".meta/zcl_darts.clas.abap"
|
||||
]
|
||||
},
|
||||
"blurb": "Write a function that returns the earned points in a single toss of a Darts game.",
|
||||
"blurb": "Calculate the points scored in a single toss of a Darts game.",
|
||||
"source": "Inspired by an exercise created by a professor Della Paolera in Argentina"
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
# Instructions
|
||||
|
||||
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
|
||||
Calculate the number of grains of wheat on a chessboard.
|
||||
|
||||
There once was a wise servant who saved the life of a prince.
|
||||
The king promised to pay whatever the servant could dream up.
|
||||
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
|
||||
One grain on the first square of a chess board, with the number of grains doubling on each successive square.
|
||||
A chessboard has 64 squares.
|
||||
Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time.
|
||||
|
||||
There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).
|
||||
Write code that calculates:
|
||||
|
||||
Write code that shows:
|
||||
|
||||
- how many grains were on a given square, and
|
||||
- the number of grains on a given square
|
||||
- the total number of grains on the chessboard
|
||||
|
||||
6
exercises/practice/grains/.docs/introduction.md
Normal file
6
exercises/practice/grains/.docs/introduction.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Introduction
|
||||
|
||||
There once was a wise servant who saved the life of a prince.
|
||||
The king promised to pay whatever the servant could dream up.
|
||||
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
|
||||
One grain on the first square of a chessboard, with the number of grains doubling on each successive square.
|
||||
@@ -15,5 +15,5 @@
|
||||
},
|
||||
"blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.",
|
||||
"source": "The CodeRanch Cattle Drive, Assignment 6",
|
||||
"source_url": "https://coderanch.com/wiki/718824/Grains"
|
||||
"source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains"
|
||||
}
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
# Instructions
|
||||
|
||||
Calculate the Hamming Distance between two DNA strands.
|
||||
Calculate the Hamming distance between two DNA strands.
|
||||
|
||||
Your body is made up of cells that contain DNA.
|
||||
Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells.
|
||||
In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime!
|
||||
|
||||
When cells divide, their DNA replicates too.
|
||||
Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information.
|
||||
If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred.
|
||||
This is known as the "Hamming Distance".
|
||||
|
||||
We read DNA using the letters C,A,G and T.
|
||||
We read DNA using the letters C, A, G and T.
|
||||
Two strands might look like this:
|
||||
|
||||
GAGCCTACTAACGGGAT
|
||||
CATCGTAATGACGGCCT
|
||||
^ ^ ^ ^ ^ ^^
|
||||
|
||||
They have 7 differences, and therefore the Hamming Distance is 7.
|
||||
|
||||
The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :)
|
||||
They have 7 differences, and therefore the Hamming distance is 7.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
|
||||
12
exercises/practice/hamming/.docs/introduction.md
Normal file
12
exercises/practice/hamming/.docs/introduction.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Introduction
|
||||
|
||||
Your body is made up of cells that contain DNA.
|
||||
Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells.
|
||||
In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime!
|
||||
|
||||
When cells divide, their DNA replicates too.
|
||||
Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information.
|
||||
If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred.
|
||||
This is known as the "Hamming distance".
|
||||
|
||||
The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :)
|
||||
@@ -13,7 +13,7 @@
|
||||
".meta/zcl_hamming.clas.abap"
|
||||
]
|
||||
},
|
||||
"blurb": "Calculate the Hamming difference between two DNA strands.",
|
||||
"blurb": "Calculate the Hamming distance between two DNA strands.",
|
||||
"source": "The Calculating Point Mutations problem at Rosalind",
|
||||
"source_url": "https://rosalind.info/problems/hamm/"
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
},
|
||||
"blurb": "Determine whether a given year is a leap year.",
|
||||
"source": "CodeRanch Cattle Drive, Assignment 3",
|
||||
"source_url": "https://coderanch.com/t/718816/Leap"
|
||||
"source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap"
|
||||
}
|
||||
|
||||
12
exercises/practice/phone-number/.docs/introduction.md
Normal file
12
exercises/practice/phone-number/.docs/introduction.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Introduction
|
||||
|
||||
You've joined LinkLine, a leading communications company working to ensure reliable connections for everyone.
|
||||
The team faces a big challenge: users submit phone numbers in all sorts of formats — dashes, spaces, dots, parentheses, and even prefixes.
|
||||
Some numbers are valid, while others are impossible to use.
|
||||
|
||||
Your mission is to turn this chaos into order.
|
||||
You'll clean up valid numbers, formatting them appropriately for use in the system.
|
||||
At the same time, you'll identify and filter out any invalid entries.
|
||||
|
||||
The success of LinkLine's operations depends on your ability to separate the useful from the unusable.
|
||||
Are you ready to take on the challenge and keep the connections running smoothly?
|
||||
@@ -13,7 +13,7 @@
|
||||
".meta/zcl_raindrops.clas.abap"
|
||||
]
|
||||
},
|
||||
"blurb": "Convert a number to a string, the content of which depends on the number's factors.",
|
||||
"blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.",
|
||||
"source_url": "https://en.wikipedia.org/wiki/Fizz_buzz",
|
||||
"source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division."
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Instructions
|
||||
|
||||
Your task is determine the RNA complement of a given DNA sequence.
|
||||
Your task is to determine the RNA complement of a given DNA sequence.
|
||||
|
||||
Both DNA and RNA strands are a sequence of nucleotides.
|
||||
|
||||
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**).
|
||||
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**).
|
||||
|
||||
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**).
|
||||
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**).
|
||||
|
||||
Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement:
|
||||
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
{
|
||||
"blurb": "Given a DNA strand, return its RNA Complement Transcription.",
|
||||
"authors": ["ajborla"],
|
||||
"contributors": [
|
||||
"blurb": "Given a DNA strand, return its RNA complement.",
|
||||
"authors": [
|
||||
"ajborla"
|
||||
],
|
||||
"contributors": [],
|
||||
"files": {
|
||||
"solution": ["zcl_rna_transcription.clas.abap"],
|
||||
"test": ["zcl_rna_transcription.clas.testclasses.abap"],
|
||||
"example": [".meta/zcl_rna_transcription.clas.abap"]
|
||||
"solution": [
|
||||
"zcl_rna_transcription.clas.abap"
|
||||
],
|
||||
"test": [
|
||||
"zcl_rna_transcription.clas.testclasses.abap"
|
||||
],
|
||||
"example": [
|
||||
".meta/zcl_rna_transcription.clas.abap"
|
||||
]
|
||||
},
|
||||
"source": "Hyperphysics",
|
||||
"source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
In this exercise, you're going to implement a program that determines the state of a [tic-tac-toe][] game.
|
||||
(_You may also know the game as "noughts and crosses" or "Xs and Os"._)
|
||||
|
||||
The games is played on a 3×3 grid.
|
||||
The game is played on a 3×3 grid.
|
||||
Players take turns to place `X`s and `O`s on the grid.
|
||||
The game ends when one player has won by placing three of marks in a row, column, or along a diagonal of the grid, or when the entire grid is filled up.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user