diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2023-05-23 21:19:34 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2023-05-23 21:19:34 +0200 |
| commit | 889859b18e16b8adb5e11986d63f29e80de2e4ef (patch) | |
| tree | 3bd44b970b19223fdbfed7aab137ef49b3d7fd01 /challenge-105 | |
| parent | a0378812481339d92fae9464fbd9e98bcca04ff5 (diff) | |
| download | perlweeklychallenge-club-889859b18e16b8adb5e11986d63f29e80de2e4ef.tar.gz perlweeklychallenge-club-889859b18e16b8adb5e11986d63f29e80de2e4ef.tar.bz2 perlweeklychallenge-club-889859b18e16b8adb5e11986d63f29e80de2e4ef.zip | |
feat(challenge-105,107/lubos-kolouch/perl,python/): Challenges 105, 107 LK Perl Python
Diffstat (limited to 'challenge-105')
| -rw-r--r-- | challenge-105/lubos-kolouch/perl/ch-1.pl | 10 | ||||
| -rw-r--r-- | challenge-105/lubos-kolouch/perl/ch-2.pl | 14 | ||||
| -rw-r--r-- | challenge-105/lubos-kolouch/python/ch-1.pl | 6 | ||||
| -rw-r--r-- | challenge-105/lubos-kolouch/python/ch-2.py | 15 |
4 files changed, 45 insertions, 0 deletions
diff --git a/challenge-105/lubos-kolouch/perl/ch-1.pl b/challenge-105/lubos-kolouch/perl/ch-1.pl new file mode 100644 index 0000000000..985223e7ec --- /dev/null +++ b/challenge-105/lubos-kolouch/perl/ch-1.pl @@ -0,0 +1,10 @@ +use strict; +use warnings; + +sub nth_root { + my ( $n, $k ) = @_; + return sprintf( "%.2f", $k**( 1 / $n ) ); +} + +print nth_root( 5, 248832 ); # Output: 12.00 +print nth_root( 5, 34 ); # Output: 2.02 diff --git a/challenge-105/lubos-kolouch/perl/ch-2.pl b/challenge-105/lubos-kolouch/perl/ch-2.pl new file mode 100644 index 0000000000..2c84eb42de --- /dev/null +++ b/challenge-105/lubos-kolouch/perl/ch-2.pl @@ -0,0 +1,14 @@ +use strict; +use warnings; + +sub name_game { + my $name = shift; + my $rest_of_name = substr $name, 1; + print "$name, $name, bo-b$rest_of_name,\n"; + print "Bonana-fanna fo-f$rest_of_name\n"; + print "Fee fi mo-m$rest_of_name\n"; + print "$name!\n"; +} + +name_game('Katie') + ; # Output: Katie, Katie, bo-batie, Bonana-fanna fo-fatie, Fee fi mo-matie, Katie! diff --git a/challenge-105/lubos-kolouch/python/ch-1.pl b/challenge-105/lubos-kolouch/python/ch-1.pl new file mode 100644 index 0000000000..7dd834b6d4 --- /dev/null +++ b/challenge-105/lubos-kolouch/python/ch-1.pl @@ -0,0 +1,6 @@ +def nth_root(n: int, k: float) -> float: + return round(k ** (1/n), 2) + +print(nth_root(5, 248832)) # Output: 12.0 +print(nth_root(5, 34)) # Output: 2.02 + diff --git a/challenge-105/lubos-kolouch/python/ch-2.py b/challenge-105/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..bb4858f939 --- /dev/null +++ b/challenge-105/lubos-kolouch/python/ch-2.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def name_game(name: str) -> None: + rest_of_name = name[1:] + print(f"{name}, {name}, bo-b{rest_of_name},") + print(f"Bonana-fanna fo-f{rest_of_name}") + print(f"Fee fi mo-m{rest_of_name}") + print(f"{name}!") + + +name_game( + "Katie" +) # Output: Katie, Katie, bo-batie, Bonana-fanna fo-fatie, Fee fi mo-matie, Katie! |
