-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
692dc70
commit 13212d9
Showing
81 changed files
with
1,083 additions
and
719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
/templates | ||
.vscode | ||
.idea | ||
*.rst.src | ||
prepare-codeblocks.py | ||
prepare-toctree.py |
38 changes: 22 additions & 16 deletions
38
Exercism.io/Binary/README.md → Exercism.io/Binary/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
# Exercism.io\Binary | ||
Exercism.io\\Binary | ||
=================== | ||
|
||
## Description | ||
Description | ||
----------- | ||
|
||
Convert a binary number, represented as a string (e.g. `'101010'`), to its decimal equivalent using first principles. | ||
|
||
Implement binary to decimal conversion. Given a binary input string, your program should produce a decimal output. The program should handle invalid inputs. | ||
|
||
## Input | ||
Input | ||
----- | ||
|
||
A string representing a binary number. | ||
|
||
## Output | ||
Output | ||
------ | ||
|
||
An integer in base-10. | ||
|
||
## Sample Input/Output | ||
|
||
|Input|Output| | ||
|:-:|:-:| | ||
|0|0| | ||
|1|1| | ||
|10|2| | ||
|11|3| | ||
|11010|26| | ||
|000011111|31| | ||
|2|ArgumentError| | ||
|01201|ArgumentError| | ||
Sample Input/Output | ||
------------------- | ||
|
||
.. csv-table:: | ||
:header: "Input", "Output" | ||
|
||
"0", "0" | ||
"1", "1" | ||
"10", "2" | ||
"11", "3" | ||
"11010", "26" | ||
"000011111", "31" | ||
"2", "ArgumentError" | ||
"01201", "ArgumentError" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Solutions | ||
========= | ||
|
||
Crystal | ||
------- | ||
|
||
.. code-block:: crystal | ||
module Binary | ||
extend self | ||
def to_decimal(binary : String) : Int | ||
raise Exception.new if binary.chars.any? { |e| !['0', '1'].includes?(e) } | ||
dec = 0 | ||
binary.chars.reverse.each_with_index do |digit, index| | ||
dec += digit.to_i * (2 ** index) if digit == '1' | ||
end | ||
dec | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Solutions | ||
========= | ||
|
||
Crystal | ||
------- | ||
|
||
.. code-block:: crystal | ||
module RnaComplement | ||
def self.of_dna(dna : String) | ||
dna.gsub({'G' => 'C', | ||
'C' => 'G', | ||
'T' => 'A', | ||
'A' => 'U'}) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Kattis\\A Different Problem | ||
=========================== | ||
|
||
Description | ||
----------- | ||
|
||
Write a program that computes the difference between non-negative integers. | ||
|
||
Input | ||
----- | ||
|
||
Each line of the input consists of a pair of integers. Each integer is between `0` and `10`:superscript:`15` (inclusive). The input is terminated by end of file. | ||
|
||
Output | ||
------ | ||
|
||
For each pair of integers in the input, output one line, containing the absolute value of their difference. | ||
|
||
Sample Input/Output | ||
------------------- | ||
|
||
.. csv-table:: | ||
:header: "Input", "Output" | ||
|
||
"| 10 12 | ||
| 71293781758123 72784 | ||
| 1 12345677654321", "| 2 | ||
| 71293781685339 | ||
| 12345677654320" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Solutions | ||
========= | ||
|
||
Python 3 | ||
-------- | ||
|
||
.. code-block:: python | ||
while True: | ||
try: | ||
line = input() | ||
except EOFError: | ||
break | ||
a, b = map(int, line.split()) | ||
print(abs(a - b)) |
28 changes: 17 additions & 11 deletions
28
Kattis/A Real Challenge/README.md → Kattis/A Real Challenge/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
# Kattis\A Real Challenge | ||
Kattis\\A Real Challenge | ||
======================== | ||
|
||
## Description | ||
Description | ||
----------- | ||
|
||
Old MacDonald had a farm, and on that farm she had a square-shaped pasture, and on that pasture she had a cow that was prone to escape. So now Old MacDonald wants to set up a fence around the pasture. Given the area of the pasture, how long a fence does Old MacDonald need to buy? | ||
|
||
## Input | ||
Input | ||
----- | ||
|
||
The input consists of a single integer `a` (`1 ≤ a ≤ 10`<sup>`18`</sup>), the area in square meters of Old MacDonald’s pasture. | ||
The input consists of a single integer `a` (`1 ≤ a ≤ 10`:superscript:`18`), the area in square meters of Old MacDonald’s pasture. | ||
|
||
## Output | ||
Output | ||
------ | ||
|
||
Output the total length of fence needed for the pasture, in meters. The length should be accurate to an absolute or relative error of at most `10`<sup>`−6`</sup>. | ||
Output the total length of fence needed for the pasture, in meters. The length should be accurate to an absolute or relative error of at most `10`:superscript:`−6`. | ||
|
||
## Sample Input/Output | ||
Sample Input/Output | ||
------------------- | ||
|
||
|Input|Output| | ||
|:----:|:-----:| | ||
|16|16| | ||
|5|8.94427190999915878564| | ||
.. csv-table:: | ||
:header: Input, Output | ||
|
||
16, 16 | ||
5, 8.94427190999915878564 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Solutions | ||
========= | ||
|
||
Python 3 | ||
-------- | ||
|
||
.. code-block:: python | ||
from math import sqrt | ||
print(4 * sqrt(int(input().strip()))) | ||
Since the input is the area of the square we take the square root of the input and multiply by 4 which gives us the perimeter of the square. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
# Kattis\ABC | ||
Kattis\\ABC | ||
=========== | ||
|
||
## Description | ||
Description | ||
----------- | ||
|
||
You will be given three integers `A`, `B` and `C`. The numbers will not be given in that exact order, but we do know that `A` is less than `B` and `B` less than `C`. In order to make for a more pleasant viewing, we want to rearrange them in a given order. | ||
|
||
## Input | ||
Input | ||
----- | ||
|
||
The first line contains the three positive integers `A`, `B` and `C`, not necessarily in that order. The three numbers will be less than or equal to `100`. | ||
|
||
The second line contains three uppercase letters `A`, `B` and `C` (with no spaces between them) representing the desired order. | ||
|
||
## Output | ||
Output | ||
------ | ||
|
||
Output `A`, `B` and `C` in the desired order on a single line, separated by single spaces. | ||
|
||
## Sample Input/Output | ||
Sample Input/Output | ||
------------------- | ||
|
||
| Input | Output | | ||
|:---------------:|:--------:| | ||
| `1 5 3`<br>`ABC`| `1 3 5`| | ||
| `6 4 2`<br>`CAB`| `6 2 4`| | ||
.. csv-table:: | ||
:header: Input, Output | ||
|
||
"| 1 5 3 | ||
| ABC", 1 3 5 | ||
"| 6 4 2 | ||
| CAB", 6 2 4 |
Oops, something went wrong.