From 889859b18e16b8adb5e11986d63f29e80de2e4ef Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Tue, 23 May 2023 21:19:34 +0200 Subject: feat(challenge-105,107/lubos-kolouch/perl,python/): Challenges 105, 107 LK Perl Python --- challenge-105/lubos-kolouch/perl/ch-1.pl | 10 ++++++++++ challenge-105/lubos-kolouch/perl/ch-2.pl | 14 ++++++++++++++ challenge-105/lubos-kolouch/python/ch-1.pl | 6 ++++++ challenge-105/lubos-kolouch/python/ch-2.py | 15 +++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 challenge-105/lubos-kolouch/perl/ch-1.pl create mode 100644 challenge-105/lubos-kolouch/perl/ch-2.pl create mode 100644 challenge-105/lubos-kolouch/python/ch-1.pl create mode 100644 challenge-105/lubos-kolouch/python/ch-2.py (limited to 'challenge-105') 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! -- cgit