From aebd1f94a8c50ef029b8956df3a05ba174f722fb Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Thu, 25 May 2023 11:31:10 +0200 Subject: feat(challenge-108/lubos-kolouch/perl,python/): Challenge 108 LK Perl Python --- challenge-108/lubos-kolouch/perl/ch-1.pl | 5 +++++ challenge-108/lubos-kolouch/perl/ch-2.pl | 19 +++++++++++++++++++ challenge-108/lubos-kolouch/python/ch-1.py | 7 +++++++ challenge-108/lubos-kolouch/python/ch-2.py | 15 +++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 challenge-108/lubos-kolouch/perl/ch-1.pl create mode 100644 challenge-108/lubos-kolouch/perl/ch-2.pl create mode 100644 challenge-108/lubos-kolouch/python/ch-1.py create mode 100644 challenge-108/lubos-kolouch/python/ch-2.py diff --git a/challenge-108/lubos-kolouch/perl/ch-1.pl b/challenge-108/lubos-kolouch/perl/ch-1.pl new file mode 100644 index 0000000000..0993ddc48b --- /dev/null +++ b/challenge-108/lubos-kolouch/perl/ch-1.pl @@ -0,0 +1,5 @@ +use Devel::Peek; + +my $var = "This is a variable"; +Dump($var); + diff --git a/challenge-108/lubos-kolouch/perl/ch-2.pl b/challenge-108/lubos-kolouch/perl/ch-2.pl new file mode 100644 index 0000000000..d54d0bd310 --- /dev/null +++ b/challenge-108/lubos-kolouch/perl/ch-2.pl @@ -0,0 +1,19 @@ +use Math::BigRat lib => 'GMP'; + +sub bell_number { + my $n = shift; + my @bell; + $bell[0][0] = Math::BigRat->bone; + for my $i (1 .. $n) { + $bell[$i][0] = $bell[$i-1][$i-1]; + for my $j (1 .. $i) { + $bell[$i][$j] = $bell[$i-1][$j-1] + $bell[$i][$j-1]; + } + } + return $bell[$n][0]; +} + +for my $n (0 .. 9) { + print bell_number($n), "\n"; +} + diff --git a/challenge-108/lubos-kolouch/python/ch-1.py b/challenge-108/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..f47d302d56 --- /dev/null +++ b/challenge-108/lubos-kolouch/python/ch-1.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import ctypes + +var = "This is a variable" +print(ctypes.cast(id(var), ctypes.c_void_p)) diff --git a/challenge-108/lubos-kolouch/python/ch-2.py b/challenge-108/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..91ed8edf69 --- /dev/null +++ b/challenge-108/lubos-kolouch/python/ch-2.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +def bell_number(n): + bell = [[0 for i in range(n+1)] for j in range(n+1)] + bell[0][0] = 1 + for i in range(1, n+1): + bell[i][0] = bell[i-1][i-1] + for j in range(1, i+1): + bell[i][j] = bell[i-1][j-1] + bell[i][j-1] + return bell[n][0] + + +for n in range(10): + print(bell_number(n)) -- cgit