diff options
| -rw-r--r-- | challenge-036/daniel-mita/README | 1 | ||||
| l--------- | challenge-036/daniel-mita/raku | 1 | ||||
| -rw-r--r-- | challenge-045/rage311/perl5/ch-1.pl | 36 | ||||
| -rw-r--r-- | challenge-045/rage311/perl5/ch-2.pl | 18 | ||||
| -rw-r--r-- | challenge-045/rage311/rust/ch-1.rs | 47 |
5 files changed, 101 insertions, 2 deletions
diff --git a/challenge-036/daniel-mita/README b/challenge-036/daniel-mita/README deleted file mode 100644 index 37339f491f..0000000000 --- a/challenge-036/daniel-mita/README +++ /dev/null @@ -1 +0,0 @@ -Solution by Daniel Mita diff --git a/challenge-036/daniel-mita/raku b/challenge-036/daniel-mita/raku deleted file mode 120000 index 8cba8ab541..0000000000 --- a/challenge-036/daniel-mita/raku +++ /dev/null @@ -1 +0,0 @@ -perl6
\ No newline at end of file diff --git a/challenge-045/rage311/perl5/ch-1.pl b/challenge-045/rage311/perl5/ch-1.pl new file mode 100644 index 0000000000..907212fa4e --- /dev/null +++ b/challenge-045/rage311/perl5/ch-1.pl @@ -0,0 +1,36 @@ +#!/usr/bin/env perl + +use 5.030; +use strict; +use warnings; + +my @input = split //, <<>> =~ s/\s+//gr; + +my @words; +$words[$_ % 8] .= $input[$_] for 0..$#input; + +say join ' ', @words; + + +__DATA__ + +TASK #1 +Square Secret Code + +The squate secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right. + +For example, the message is “The quick brown fox jumps over the lazy dog”. + +Then the message would be laid out as below: + +thequick +brownfox +jumpsove +rthelazy +dog + +The code message would be as below: + +tbjrd hruto eomhg qwpe unsl ifoa covz kxey + +Write a script that accepts a message from command line and prints the equivalent coded message. diff --git a/challenge-045/rage311/perl5/ch-2.pl b/challenge-045/rage311/perl5/ch-2.pl new file mode 100644 index 0000000000..63ee327642 --- /dev/null +++ b/challenge-045/rage311/perl5/ch-2.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl + +use 5.030; +use strict; +use warnings; + +die "Unable to open file: $!" unless + open my $fh, '<', $0; +print while <$fh>; + +__DATA__ + +TASK #2 +Source Dumper + +Write a script that dumps its own source code. For example, say, the script name is ch-2.pl then the following command should returns nothing. + +$ perl ch-2.pl | diff - ch-2.pl diff --git a/challenge-045/rage311/rust/ch-1.rs b/challenge-045/rage311/rust/ch-1.rs new file mode 100644 index 0000000000..49651487aa --- /dev/null +++ b/challenge-045/rage311/rust/ch-1.rs @@ -0,0 +1,47 @@ +/* TASK #1 + * Square Secret Code + * + * The squate secret code mechanism first removes any space from the original message. Then it lays + * down the message in a row of 8 columns. The coded message is then obtained by reading down the + * columns going left to right. + * + * For example, the message is “The quick brown fox jumps over the lazy dog”. + * + * Then the message would be laid out as below: + * + * thequick + * brownfox + * jumpsove + * rthelazy + * dog + * + * The code message would be as below: + * + * tbjrd hruto eomhg qwpe unsl ifoa covz kxey + * + * Write a script that accepts a message from command line and prints the equivalent coded message. + * + * + * Executing program and output: + * + * $ echo 'the quick brown fox jumps over the lazy dog' | ./ch-1 + * tbjrd hruto eomhg qwpe unsl ifoa covz kxey + */ + +use std::io::{self, Read}; + +fn main() -> io::Result<()> { + let mut buffer = String::new(); + io::stdin().read_to_string(&mut buffer)?; + buffer = buffer.split_whitespace().collect(); + + let mut final_words: Vec<String> = vec!["".to_string(); 8]; + + for i in 0..buffer.len() { + final_words[i % 8].push(buffer.chars().nth(i).unwrap()); + } + + println!("{}", final_words.join(" ")); + + Ok(()) +} |
