aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-024/noud/perl6/ch-1.p63
-rw-r--r--challenge-024/noud/perl6/ch-2.p630
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-024/noud/perl6/ch-1.p6 b/challenge-024/noud/perl6/ch-1.p6
new file mode 100644
index 0000000000..b234361f67
--- /dev/null
+++ b/challenge-024/noud/perl6/ch-1.p6
@@ -0,0 +1,3 @@
+# Create a smallest script in terms of size that on execution doesn’t throw any
+# error. The script doesn’t have to do anything special. You could even come up
+# with smallest one-liner.
diff --git a/challenge-024/noud/perl6/ch-2.p6 b/challenge-024/noud/perl6/ch-2.p6
new file mode 100644
index 0000000000..be27520626
--- /dev/null
+++ b/challenge-024/noud/perl6/ch-2.p6
@@ -0,0 +1,30 @@
+# Create a script to implement full text search functionality using Inverted
+# Index. According to wikipedia:
+#
+# In computer science, an inverted index (also referred to as a postings file
+# or inverted file) is a database index storing a mapping from content, such as
+# words or numbers, to its locations in a table, or in a document or a set of
+# documents (named in contrast to a forward index, which maps from documents to
+# content). The purpose of an inverted index is to allow fast full-text
+# searches, at a cost of increased processing when a document is added to the
+# database.
+
+sub MAIN(+@files) {
+ my %inv_index;
+
+ for @files -> $file {
+ for $file.IO.words.unique -> $word {
+ if %inv_index{$word}:exists {
+ %inv_index{$word} = ($file, |(%inv_index{$word}));
+ } else {
+ %inv_index{$word} = ($file);
+ }
+ }
+ }
+
+ for %inv_index.kv -> $k, $v {
+ "$k: $v".say;
+ }
+}
+
+