diff options
| author | mfoda <23182653+mfoda@users.noreply.github.com> | 2021-01-13 14:25:47 +0800 |
|---|---|---|
| committer | mfoda <23182653+mfoda@users.noreply.github.com> | 2021-01-13 14:25:47 +0800 |
| commit | 2fb8cd90100e6730a6bcf2edd46c6b13098b1812 (patch) | |
| tree | 0a9ebacb2bdf72419c9638ed6c77286334ecfee4 /challenge-001 | |
| parent | de8edf2133ef637e908abd42cc1843797ae14b7e (diff) | |
| download | perlweeklychallenge-club-2fb8cd90100e6730a6bcf2edd46c6b13098b1812.tar.gz perlweeklychallenge-club-2fb8cd90100e6730a6bcf2edd46c6b13098b1812.tar.bz2 perlweeklychallenge-club-2fb8cd90100e6730a6bcf2edd46c6b13098b1812.zip | |
Add mfoda-001-haxe
Diffstat (limited to 'challenge-001')
| -rw-r--r-- | challenge-001/mfoda/haxe/Ch1.hx | 12 | ||||
| -rw-r--r-- | challenge-001/mfoda/haxe/Ch2.hx | 17 |
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-001/mfoda/haxe/Ch1.hx b/challenge-001/mfoda/haxe/Ch1.hx new file mode 100644 index 0000000000..8c255d0c71 --- /dev/null +++ b/challenge-001/mfoda/haxe/Ch1.hx @@ -0,0 +1,12 @@ +using Lambda; +using StringTools; + +class Ch1 { + public static function main() { + var input = "Perl Weekly Challenge"; + var countE = input.split("").count(x -> x == "e"); + var replaced = input.replace("e", "E"); + + Sys.println('"$replaced" [replaced $countE]'); + } +}
\ No newline at end of file diff --git a/challenge-001/mfoda/haxe/Ch2.hx b/challenge-001/mfoda/haxe/Ch2.hx new file mode 100644 index 0000000000..2dceb7c411 --- /dev/null +++ b/challenge-001/mfoda/haxe/Ch2.hx @@ -0,0 +1,17 @@ +class Ch2 { + public static function main() { + function div(x, y) return x % y == 0; + var result = [ + for (i in 1...21) { + if (div(i,3) && div(i,5)) + "fizzbuzz"; + else if (div(i,3)) + "fizz"; + else if (div(i,5)) + "buzz"; + else '$i'; + } + ]; + Sys.println('${result.join("")}'); + } +}
\ No newline at end of file |
