aboutsummaryrefslogtreecommitdiff
path: root/challenge-116
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-06-13 21:14:34 +0200
committerAbigail <abigail@abigail.be>2021-06-13 21:14:34 +0200
commit7e7b2cab61dcef029b71bd066bf6b5e3a71011af (patch)
treec59db29ec40c06bef679a896618fc3dbbbe4b977 /challenge-116
parent3fe9fba9c9d2ec298020988b59ddf16dade7285f (diff)
downloadperlweeklychallenge-club-7e7b2cab61dcef029b71bd066bf6b5e3a71011af.tar.gz
perlweeklychallenge-club-7e7b2cab61dcef029b71bd066bf6b5e3a71011af.tar.bz2
perlweeklychallenge-club-7e7b2cab61dcef029b71bd066bf6b5e3a71011af.zip
Rename make_chain to make_sequence
Diffstat (limited to 'challenge-116')
-rw-r--r--challenge-116/abigail/awk/ch-1.awk8
-rw-r--r--challenge-116/abigail/bash/ch-1.sh8
-rw-r--r--challenge-116/abigail/lua/ch-1.lua8
-rw-r--r--challenge-116/abigail/node/ch-1.js8
-rw-r--r--challenge-116/abigail/perl/ch-1.pl10
-rw-r--r--challenge-116/abigail/python/ch-1.py8
-rw-r--r--challenge-116/abigail/ruby/ch-1.rb8
7 files changed, 29 insertions, 29 deletions
diff --git a/challenge-116/abigail/awk/ch-1.awk b/challenge-116/abigail/awk/ch-1.awk
index 14f6a2ee56..5e0379efb8 100644
--- a/challenge-116/abigail/awk/ch-1.awk
+++ b/challenge-116/abigail/awk/ch-1.awk
@@ -8,15 +8,15 @@
# Run as: awk -f ch-1.awk < input-file
#
-function make_chain (string, start) {
+function make_sequence (string, start) {
if (start == string) {
return start
}
if (1 == index (string, start)) {
tail = substr (string, length (start) + 1)
- result = make_chain(tail, start + 1)
+ result = make_sequence(tail, start + 1)
if (result == "") {
- result = make_chain(tail, start - 1)
+ result = make_sequence(tail, start - 1)
}
if (result == "") {
return ""
@@ -28,7 +28,7 @@ function make_chain (string, start) {
{
for (i = 1; i <= length ($1); i ++) {
- result = make_chain($1, substr ($1, 1, i))
+ result = make_sequence($1, substr ($1, 1, i))
if (result != "") {
print result
next
diff --git a/challenge-116/abigail/bash/ch-1.sh b/challenge-116/abigail/bash/ch-1.sh
index 8aed90c969..20e1cb726c 100644
--- a/challenge-116/abigail/bash/ch-1.sh
+++ b/challenge-116/abigail/bash/ch-1.sh
@@ -12,7 +12,7 @@ set -f
out=""
-function make_chain () {
+function make_sequence () {
local string=$1
local start=$2
if [[ "$string" = "$start" ]]
@@ -22,12 +22,12 @@ function make_chain () {
if [[ $string =~ ^$start ]]
then local tail=${string:${#start}}
- make_chain $tail $((start + 1))
+ make_sequence $tail $((start + 1))
if [[ $out =~ ^. ]]
then out=$start,$out
return
fi
- make_chain $tail $((start - 1))
+ make_sequence $tail $((start - 1))
if [[ $out =~ ^. ]]
then out=$start,$out
return
@@ -41,7 +41,7 @@ function make_chain () {
while read string
do for ((i = 1; i <= ${#string}; i ++))
do start=${string:0:$i}
- make_chain $string $start
+ make_sequence $string $start
if [[ $out =~ ^. ]]
then echo $out
break
diff --git a/challenge-116/abigail/lua/ch-1.lua b/challenge-116/abigail/lua/ch-1.lua
index df551a2e46..fadad776fa 100644
--- a/challenge-116/abigail/lua/ch-1.lua
+++ b/challenge-116/abigail/lua/ch-1.lua
@@ -8,17 +8,17 @@
-- Run as: lua ch-1.lua < input-file
--
-function make_chain (string, start)
+function make_sequence (string, start)
if string == start
then return start
end
if string : find ("^" .. start)
then tail = string : sub (#start + 1, -1)
- result = make_chain (tail, tostring (tonumber (start) + 1))
+ result = make_sequence (tail, tostring (tonumber (start) + 1))
if result ~= nil
then return start .. "," .. result
end
- result = make_chain (tail, tostring (tonumber (start) - 1))
+ result = make_sequence (tail, tostring (tonumber (start) - 1))
if result ~= nil
then return start .. "," .. result
end
@@ -29,7 +29,7 @@ end
for line in io . lines () do
for i = 1, #line do
start = line : sub (1, i)
- result = make_chain (line, start)
+ result = make_sequence (line, start)
if result ~= nil
then print (result)
goto end_main
diff --git a/challenge-116/abigail/node/ch-1.js b/challenge-116/abigail/node/ch-1.js
index e4bcb1961e..364e7a4206 100644
--- a/challenge-116/abigail/node/ch-1.js
+++ b/challenge-116/abigail/node/ch-1.js
@@ -12,14 +12,14 @@
. createInterface ({input: process . stdin})
. on ('line', line => main (line))
-function make_chain (string, start) {
+function make_sequence (string, start) {
if (string == start) {
return [start]
}
if (0 == string . indexOf (start)) {
let tail = string . substr (start . length)
- let result = make_chain (tail, (+ start + 1) . toString ()) ||
- make_chain (tail, (+ start - 1) . toString ())
+ let result = make_sequence (tail, (+ start + 1) . toString ()) ||
+ make_sequence (tail, (+ start - 1) . toString ())
if (result) {
result . unshift (start)
return result
@@ -32,7 +32,7 @@ function make_chain (string, start) {
function main (line) {
for (let i = 1; i <= line . length; i ++) {
let start = line . substr (0, i)
- let result = make_chain (line, start)
+ let result = make_sequence (line, start)
if (result) {
console . log (result . join (","))
break
diff --git a/challenge-116/abigail/perl/ch-1.pl b/challenge-116/abigail/perl/ch-1.pl
index 6fbf27a906..84b92de83d 100644
--- a/challenge-116/abigail/perl/ch-1.pl
+++ b/challenge-116/abigail/perl/ch-1.pl
@@ -29,19 +29,19 @@ use experimental 'lexical_subs';
#
# Note the running time is O (N), despite recursing twice. This is
# because there is no number X such that X + 1 and X - 1 are the same
-# number. Hence, in at least one of the recursive make_chain calls the
+# number. Hence, in at least one of the recursive make_sequence calls the
# 'start' will not match the beginning of 'string'.
#
-sub make_chain ($string, $start) {
+sub make_sequence ($string, $start) {
if ($string eq $start) {
return [$start]
}
if (index ($string, $start) == 0) {
my $tail = substr $string, length $start;
my $rest;
- if (($rest = make_chain ($tail, $start + 1)) ||
- ($rest = make_chain ($tail, $start - 1))) {
+ if (($rest = make_sequence ($tail, $start + 1)) ||
+ ($rest = make_sequence ($tail, $start - 1))) {
push @$rest => $start;
return $rest;
}
@@ -56,7 +56,7 @@ INPUT: while (<>) {
#
# Try to make a chain with each possible start.
#
- my $result = make_chain $_, substr $_, 0, $i;
+ my $result = make_sequence $_, substr $_, 0, $i;
if ($result) {
say join "," => reverse @$result;
next INPUT;
diff --git a/challenge-116/abigail/python/ch-1.py b/challenge-116/abigail/python/ch-1.py
index 795d4ecabd..b988189564 100644
--- a/challenge-116/abigail/python/ch-1.py
+++ b/challenge-116/abigail/python/ch-1.py
@@ -10,14 +10,14 @@
import fileinput
-def make_chain (string, start):
+def make_sequence (string, start):
if string == start:
return [start]
if 0 == string . find (start):
tail = string [len (start) :]
- result = make_chain (tail, str (int (start) + 1)) or \
- make_chain (tail, str (int (start) - 1))
+ result = make_sequence (tail, str (int (start) + 1)) or \
+ make_sequence (tail, str (int (start) - 1))
if result:
return [start] + result
@@ -27,7 +27,7 @@ def make_chain (string, start):
for line in fileinput . input ():
line = line . strip ()
for i in range (0, len (line)):
- result = make_chain (line, line [0 : i + 1])
+ result = make_sequence (line, line [0 : i + 1])
if result:
print ("," . join (result))
break
diff --git a/challenge-116/abigail/ruby/ch-1.rb b/challenge-116/abigail/ruby/ch-1.rb
index a8e5c0d824..dfd15809e5 100644
--- a/challenge-116/abigail/ruby/ch-1.rb
+++ b/challenge-116/abigail/ruby/ch-1.rb
@@ -8,14 +8,14 @@
# Run as: ruby ch-1.rb < input-file
#
-def make_chain (string, start)
+def make_sequence (string, start)
if string == start
then return [start]
end
if 0 == string . index(start)
then tail = string [start . length, string . length]
- result = make_chain(tail, (start . to_i + 1) . to_s) ||
- make_chain(tail, (start . to_i - 1) . to_s)
+ result = make_sequence(tail, (start . to_i + 1) . to_s) ||
+ make_sequence(tail, (start . to_i - 1) . to_s)
if result
then return result . unshift (start)
end
@@ -29,7 +29,7 @@ ARGF . each_line do
line . strip!
for i in 1 .. line . length do
start = line [0, i]
- result = make_chain(line, start)
+ result = make_sequence(line, start)
if result
then puts (result . join (","))
break