From 15e394ba428c287eb6619018af86770db1db4819 Mon Sep 17 00:00:00 2001 From: mfoda <23182653+mfoda@users.noreply.github.com> Date: Wed, 13 Jan 2021 13:17:18 +0800 Subject: Add ch-1 in nim --- challenge-001/mfoda/README | 1 + challenge-001/mfoda/nim/ch1.nim | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 challenge-001/mfoda/README create mode 100644 challenge-001/mfoda/nim/ch1.nim diff --git a/challenge-001/mfoda/README b/challenge-001/mfoda/README new file mode 100644 index 0000000000..3aefec5aa9 --- /dev/null +++ b/challenge-001/mfoda/README @@ -0,0 +1 @@ +Solution by mfoda diff --git a/challenge-001/mfoda/nim/ch1.nim b/challenge-001/mfoda/nim/ch1.nim new file mode 100644 index 0000000000..e7a7eb721a --- /dev/null +++ b/challenge-001/mfoda/nim/ch1.nim @@ -0,0 +1,13 @@ +#[ + Write a script to replace the character ‘e’ with ‘E’ in the string ‘Perl Weekly Challenge’. + Also print the number of times the character ‘e’ is found in the string. +]# + +import strutils, strformat + +let + input = "Perl Weekly Challenge" + countE= input.count("e") + replaced = input.replace("e", "E") + +echo &"'{replaced}' [{countE} replaced]" \ No newline at end of file -- cgit