Skip to content

Commit 79f454f

Browse files
committed
- Added template for Challenge 071.
1 parent 83a806a commit 79f454f

File tree

179 files changed

+515
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+515
-0
lines changed

challenge-071/3ter/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by 3ter.

challenge-071/aaron-rowe/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Aaron Rowe.

challenge-071/aaron-sherman/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Aaron Sherman.

challenge-071/abigail/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Abigail

challenge-071/adam-russell/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Adam Russell

challenge-071/ailbhe-tweedie/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Ailbhe Tweedie

challenge-071/alex-daniel/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Alex Daniel.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Alexander Karelas

challenge-071/alicia-bielsa/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Alicia Beilsa.

challenge-071/andrezgz/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Andrezgz

challenge-071/anton-fedotov/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Anton Fedotov.

challenge-071/antonio-gamiz/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Antonio Gamiz

challenge-071/arne-sommer/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Arne Sommer.

challenge-071/arpad-toth/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Arpad Toth

challenge-071/ash/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Andrew Shitov

challenge-071/athanasius/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Athanasius

challenge-071/aubrey-quarcoo/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Aubrey Quarcoo

challenge-071/ben-davies/README.md

Lines changed: 11 additions & 0 deletions

challenge-071/bill-palmer/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Bill Palmer.

challenge-071/bob-kleemann/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Bob Kleemann

challenge-071/bob-lied/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Bob Lied.

challenge-071/brtastic/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Bartosz Jarzyna.

challenge-071/bruno-ramos/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Bruno Ramos.

challenge-071/burkhard-nickels/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Burkhard Nickels.

challenge-071/bwva/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution(s) by bwva (Bruce Van Allen)

challenge-071/cheok-yin-fung/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Cheok-Yin Fung.

challenge-071/cliveholloway/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Clive Holloway

challenge-071/colin-crain/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Colin Crain.

challenge-071/craig/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Craig.

challenge-071/creewick/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Creewick.

challenge-071/cristian-heredia/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Cristina Heredia.

challenge-071/daniel-mantovani/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Daniel Mantovani

challenge-071/daniel-mita/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Daniel Mita

challenge-071/darren-bottin/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Darren Bottin.

challenge-071/dave-cross/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Dave Cross

challenge-071/dave-jacoby/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Dave Jacoby

challenge-071/david-kayal/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by David Kayal

challenge-071/denis-yurashku/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Denis Yurashku.

challenge-071/donald-hunter/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Donald Hunter.

challenge-071/doug-schrag/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Doug Schrag

challenge-071/dracos/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Matthew Somerville.

challenge-071/duane-powell/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Duane Powell.

challenge-071/duncan-c-white/README

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
Task 1: "Character Swapping
2+
3+
You are given a string $S of size $N.
4+
5+
You are also given swap count $C and offset $O such that $C >= 1, $O >=
6+
1, $C <= $O and $C + $O <= $N.
7+
8+
Write a script to perform character swapping like below:
9+
10+
for i = 1 to $C
11+
S[ i % N ] <=> S[ (i + O) % N ]
12+
13+
Example 1
14+
15+
Input:
16+
$S = 'perlandraku'
17+
$C = 3
18+
$O = 4
19+
20+
01234567890
21+
perlandraku
22+
23+
Character Swapping:
24+
swap 1: pos 1 and 5: e <=> n = pnrlaedraku
25+
swap 2: pos 2 and 6: r <=> d = pndlaerraku
26+
swap 3: pos 3 and 7: l <=> r = pndraerlaku
27+
28+
Output:
29+
pndraerlaku
30+
"
31+
32+
My notes: ok. none of $i % N (for i=1..$C) needs the % N
33+
given that $C + $O <= $N and min $O is 1. So that becomes:
34+
35+
for i = 1 to $C
36+
S[ i ] <=> S[ (i + O) % N ]
37+
38+
and the only one of the (i + O) % N expressions that may need
39+
the % N part is i=C, when C+O == N. Of course i + O increments
40+
so pre-calculate it, and set it back to 0 hit it hits N.
41+
42+
43+
Task 2: "Gray Code Sequence
44+
45+
You are given an integer 2 <= $N <= 5.
46+
47+
Write a script to generate $N-bit gray code sequence.
48+
49+
2-bit Gray Code Sequence: [0, 1, 3, 2]
50+
51+
To generate the 3-bit Gray code sequence from the 2-bit Gray code sequence,
52+
follow the step below:
53+
54+
2-bit Gray Code sequence: [0, 1, 3, 2]
55+
56+
Binary form of the sequence a) S1 = [00, 01, 11, 10]
57+
58+
Reverse of S1 b) S2 = [10, 11, 01, 00]
59+
60+
Prefix all entries of S1 with '0' c) S1 = [000, 001, 011, 010]
61+
62+
Prefix all entries of S2 with '1' d) S2 = [110, 111, 101, 100]
63+
64+
Concatenate S1 and S2 gives 3-bit Gray Code sequence
65+
e) [000, 001, 011, 010, 110, 111, 101, 100]
66+
67+
Now convert them back to decimal:
68+
69+
3-bit Gray Code sequence [0, 1, 3, 2, 6, 7, 5, 4]
70+
71+
Example
72+
73+
Input: N = 4
74+
Output: [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8]
75+
"
76+
77+
My notes: ok. However, there's no point in taking the original N-1-bit gray
78+
code sequence, converting it to binary, prepending zeroes and converting it
79+
back to decimal - because leading zeroes don't change the decimal numbers.
80+
So the first half of the N-bit gray code sequence is simply the N-1-bit gray
81+
code sequence.

challenge-071/e-choroba/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by E. Choroba.

challenge-071/eddy-hs/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Eddy HS

challenge-071/fabrizio-poggi/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Fabrizio Poggi.

challenge-071/feng-chang/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Feng Chang.

challenge-071/finanalyst/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Richard Hainsworth, aka finanalyst

challenge-071/finley/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Finley

challenge-071/fjwhittle/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Francis Whittle

challenge-071/fred-zinn/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Fred Zinn

challenge-071/freddie-b/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Freddie B
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Giuseppe Di Terlizzi.

challenge-071/guillermo-ramos/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Guillermo Ramos.

challenge-071/gustavo-chaves/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Gustavo Chaves

challenge-071/hauke-d/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Hauke Dämpfling.

challenge-071/ianrifkin/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Ian Rifkin.

challenge-071/izifresh/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by izifresh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Jacques Guinnebault.

challenge-071/jaime/README

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Task #1
2+
3+
Write a script to display months from the year 1900 to 2019 where you
4+
find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday.
5+
6+
## Solution
7+
8+
Months that contain five full weekends have 31 days and start on a Friday. Use `cal` to display March 2019 as an example.
9+
10+
```
11+
#$ cal -h -m 3 2019 # cal is a UNIX utility
12+
March 2019
13+
Su Mo Tu We Th Fr Sa
14+
1 2
15+
3 4 5 6 7 8 9
16+
10 11 12 13 14 15 16
17+
17 18 19 20 21 22 23
18+
24 25 26 27 28 29 30
19+
31
20+
```
21+
22+
The solution runs `cal` and displays months that match this unique
23+
layout.
24+
25+
# Task #2
26+
27+
Write a script that can wrap the given paragraph at a specified column
28+
using the greedy algorithm.
29+
30+
A simple way to do word wrapping is to use a greedy algorithm that
31+
puts as many words on a line as possible, then moving on to the next
32+
line to do the same until there are no more words left to place. This
33+
method is used by many modern word processors, such as OpenOffice.org
34+
Writer and Microsoft Word[citation needed]. This algorithm always uses
35+
the minimum possible number of lines but may lead to lines of widely
36+
varying lengths. The following pseudocode implements this algorithm:
37+
38+
```
39+
SpaceLeft := LineWidth
40+
for each Word in Text
41+
if (Width(Word) + SpaceWidth) > SpaceLeft
42+
insert line break before Word in Text
43+
SpaceLeft := LineWidth - Width(Word)
44+
else
45+
SpaceLeft := SpaceLeft - (Width(Word) + SpaceWidth)
46+
```
47+
48+
Where LineWidth is the width of a line, SpaceLeft is the remaining
49+
width of space on the line to fill, SpaceWidth is the width of a
50+
single space character, Text is the input text to iterate over and
51+
Word is a word in this text.
52+
53+
## Solution
54+
55+
The solution follows the recommended pseudocode. Minor improvements
56+
avoid trailing whitespace.
57+
58+
The script uses `Text::ParseWords::shellwords` from the standard
59+
library to extract chunks of words from `<STDIN>`.

challenge-071/jaldhar-h-vyas/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solution by Jaldhar H. Vyas

0 commit comments

Comments
 (0)