From 7110482dec6231637d1cc92b636d4e409729db3b Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 17:56:43 +0100 Subject: Perl solution for week 137, part 1 --- challenge-137/abigail/perl/ch-1.pl | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 challenge-137/abigail/perl/ch-1.pl diff --git a/challenge-137/abigail/perl/ch-1.pl b/challenge-137/abigail/perl/ch-1.pl new file mode 100644 index 0000000000..8c788fe38a --- /dev/null +++ b/challenge-137/abigail/perl/ch-1.pl @@ -0,0 +1,67 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-1.pl < input-file +# + +# +# The Gregorian calender cycles every 400 years. That is, every calender +# event, or sequence of calender events, repeats after 400 years. +# (This is because there are 97 leap days in a 400 year period, which +# means there are 146097 days in such a period, and 146097 days are +# exactly 20871 weeks). +# + +# +# In such a 400 year period, there are 71 long years. A long year +# starts or ends with a Thursday (a non-leap long year starts and +# ends with with a Thursday, a leap long year either starts with +# a Wednesday and ends with a Thursday, or starts with a Thursday, +# and end with a Friday). +# + +# +# Now, we could calculate the day of the week of Jan 1 and Dec 31, +# either using a module or some handrolled calculations, checking +# whether at least of those days is a Thursday. +# +# Or we could just list the 71 years in a 400 year period, and so +# some trivial arithmetic. +# +# Guess which method we're using. +# + +my @long_year_offsets = qw [ + 004 009 015 020 026 + 032 037 043 048 054 + 060 065 071 076 082 + 088 093 099 + 105 111 116 122 + 128 133 139 144 150 + 156 161 167 172 178 + 184 189 195 + 201 207 212 218 + 224 229 235 240 246 + 252 257 263 268 274 + 280 285 291 296 + 303 308 314 + 320 325 331 336 342 + 348 353 359 364 370 + 376 381 387 392 398 +]; + +say for grep {1900 <= $_ <= 2100} + map {my $fy = $_; map {$_ + $fy} @long_year_offsets} 1600, 2000; -- cgit From 4cb0f7b8bc788572a1ff715a58e88ad2635d3a9d Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 18:33:10 +0100 Subject: Test all numbers between 10 and 1000 --- challenge-137/abigail/t/ctest.ini | 13 + challenge-137/abigail/t/input-1-1 | 0 challenge-137/abigail/t/input-2-1 | 3 + challenge-137/abigail/t/input-2-2 | 991 +++++++++++++++++++++++++++++++++ challenge-137/abigail/t/output-1-1.exp | 36 ++ challenge-137/abigail/t/output-2-1.exp | 3 + challenge-137/abigail/t/output-2-2.exp | 991 +++++++++++++++++++++++++++++++++ 7 files changed, 2037 insertions(+) create mode 100644 challenge-137/abigail/t/ctest.ini create mode 100644 challenge-137/abigail/t/input-1-1 create mode 100644 challenge-137/abigail/t/input-2-1 create mode 100644 challenge-137/abigail/t/input-2-2 create mode 100644 challenge-137/abigail/t/output-1-1.exp create mode 100644 challenge-137/abigail/t/output-2-1.exp create mode 100644 challenge-137/abigail/t/output-2-2.exp diff --git a/challenge-137/abigail/t/ctest.ini b/challenge-137/abigail/t/ctest.ini new file mode 100644 index 0000000000..4a58fc7705 --- /dev/null +++ b/challenge-137/abigail/t/ctest.ini @@ -0,0 +1,13 @@ +# +# Configuration file for running tests, using ctest. +# See https://github.com/Abigail/Misc/blob/master/ctest +# + +[names] +1-1 = Fixed output +2-1 = Given examples +2-2 = Full input range + + +[1-1] +no_input = 1 diff --git a/challenge-137/abigail/t/input-1-1 b/challenge-137/abigail/t/input-1-1 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/challenge-137/abigail/t/input-2-1 b/challenge-137/abigail/t/input-2-1 new file mode 100644 index 0000000000..b44d4f58a0 --- /dev/null +++ b/challenge-137/abigail/t/input-2-1 @@ -0,0 +1,3 @@ +56 +57 +59 diff --git a/challenge-137/abigail/t/input-2-2 b/challenge-137/abigail/t/input-2-2 new file mode 100644 index 0000000000..0b5e4ce92b --- /dev/null +++ b/challenge-137/abigail/t/input-2-2 @@ -0,0 +1,991 @@ +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965 +966 +967 +968 +969 +970 +971 +972 +973 +974 +975 +976 +977 +978 +979 +980 +981 +982 +983 +984 +985 +986 +987 +988 +989 +990 +991 +992 +993 +994 +995 +996 +997 +998 +999 +1000 diff --git a/challenge-137/abigail/t/output-1-1.exp b/challenge-137/abigail/t/output-1-1.exp new file mode 100644 index 0000000000..69c7436f46 --- /dev/null +++ b/challenge-137/abigail/t/output-1-1.exp @@ -0,0 +1,36 @@ +1903 +1908 +1914 +1920 +1925 +1931 +1936 +1942 +1948 +1953 +1959 +1964 +1970 +1976 +1981 +1987 +1992 +1998 +2004 +2009 +2015 +2020 +2026 +2032 +2037 +2043 +2048 +2054 +2060 +2065 +2071 +2076 +2082 +2088 +2093 +2099 diff --git a/challenge-137/abigail/t/output-2-1.exp b/challenge-137/abigail/t/output-2-1.exp new file mode 100644 index 0000000000..bb0b1cf658 --- /dev/null +++ b/challenge-137/abigail/t/output-2-1.exp @@ -0,0 +1,3 @@ +0 +0 +0 diff --git a/challenge-137/abigail/t/output-2-2.exp b/challenge-137/abigail/t/output-2-2.exp new file mode 100644 index 0000000000..e290a9d2b0 --- /dev/null +++ b/challenge-137/abigail/t/output-2-2.exp @@ -0,0 +1,991 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +1 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +1 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 -- cgit From f1ea467485df825b48e023ae7efb9cc031e94e8a Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 18:34:09 +0100 Subject: Perl solution for week 137. part 2 --- challenge-137/abigail/perl/ch-2.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 challenge-137/abigail/perl/ch-2.pl diff --git a/challenge-137/abigail/perl/ch-2.pl b/challenge-137/abigail/perl/ch-2.pl new file mode 100644 index 0000000000..294272ec68 --- /dev/null +++ b/challenge-137/abigail/perl/ch-2.pl @@ -0,0 +1,30 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-2.pl < input-file +# + +# +# Note that the challenge says we can terminate the process of iterating +# if we have had 500 iterations. We will never hit that: for all numbers +# between 10 and 1000, we either reach a palindrome or exceed 10_000_000 +# long before hitting the 500th iteration (11 iterations is the maximum +# amount of iterations we need). So, we just won't bother tracking the +# number of iterations. +# + +sub l ($n) {$n >= 10_000_000 ? 1 : $n eq reverse ($n) ? 0 : l ($n + reverse $n)} +say l s/\n//r while <>; -- cgit From 289bed506e57873ce957f89ab7c4093bb032e482 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 19:00:06 +0100 Subject: AWK solutions for week 137 --- challenge-137/abigail/awk/ch-1.awk | 38 ++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/awk/ch-2.awk | 23 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 challenge-137/abigail/awk/ch-1.awk create mode 100644 challenge-137/abigail/awk/ch-2.awk diff --git a/challenge-137/abigail/awk/ch-1.awk b/challenge-137/abigail/awk/ch-1.awk new file mode 100644 index 0000000000..f0d29a5887 --- /dev/null +++ b/challenge-137/abigail/awk/ch-1.awk @@ -0,0 +1,38 @@ +#!/usr/bin/awk + +# +# See ../README.md +# + +# +# Run as: awk -f ch-1.awk +# + +BEGIN { + m = split ("1600 2000", start_years) + n = split ("004 009 015 020 026 " \ + "032 037 043 048 054 " \ + "060 065 071 076 082 " \ + "088 093 099 " \ + " 105 111 116 122 " \ + "128 133 139 144 150 " \ + "156 161 167 172 178 " \ + "184 189 195 " \ + " 201 207 212 218 " \ + "224 229 235 240 246 " \ + "252 257 263 268 274 " \ + "280 285 291 296 " \ + " 303 308 314 " \ + "320 325 331 336 342 " \ + "348 353 359 364 370 " \ + "376 381 387 392 398", long_year_offsets) + + for (j = 1; j <= m; j ++) { + for (i = 1; i <= n; i ++) { + year = start_years [j] + long_year_offsets [i] + if (1900 <= year && year <= 2100) { + print year + } + } + } +} diff --git a/challenge-137/abigail/awk/ch-2.awk b/challenge-137/abigail/awk/ch-2.awk new file mode 100644 index 0000000000..281b28dc55 --- /dev/null +++ b/challenge-137/abigail/awk/ch-2.awk @@ -0,0 +1,23 @@ +#!/usr/bin/awk + +# +# See ../README.md +# + +# +# Run as: awk -f ch-2.awk < input-file +# + +function reverse (str) { + x = "" + for (i = length (str); i != 0; i --) { + x = x substr (str, i, 1) + } + return x +} + +function ly (n) { + return n >= 10000000 ? 1 : n == reverse(n) ? 0 : ly(n + reverse(n)) +} + +{print ly($1)} -- cgit From df1b35e96d20b0fbbe887974cafb077b0b1209d9 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 19:36:57 +0100 Subject: Bash solutions for week 137 --- challenge-137/abigail/bash/ch-1.sh | 35 ++++++++++++++++++++++++++++++++++ challenge-137/abigail/bash/ch-2.sh | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 challenge-137/abigail/bash/ch-1.sh create mode 100644 challenge-137/abigail/bash/ch-2.sh diff --git a/challenge-137/abigail/bash/ch-1.sh b/challenge-137/abigail/bash/ch-1.sh new file mode 100644 index 0000000000..a3b12c9266 --- /dev/null +++ b/challenge-137/abigail/bash/ch-1.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# +# See ../README.md +# + +# +# Run as: bash ch-1.sh < input-file +# + +set -f + +start_years=(1600 2000) +m=${#start_years[@]} + +long_year_offsets=( 4 9 15 20 26 32 37 43 48 54 \ + 60 65 71 76 82 88 93 99 \ + 105 111 116 122 128 133 139 144 150 \ + 156 161 167 172 178 184 189 195 \ + 201 207 212 218 224 229 235 240 246 \ + 252 257 263 268 274 280 285 291 296 \ + 303 308 314 320 325 331 336 342 \ + 348 353 359 364 370 376 381 387 392 398) +n=${#long_year_offsets[@]} + + +for ((j = 0; j < m; j ++)) +do for ((i = 0; i < n; i ++)) + do year=$((${start_years[$j]} + ${long_year_offsets[$i]})) + if ((1900 <= year && year <= 2100)) + then echo $year + fi + done +done + diff --git a/challenge-137/abigail/bash/ch-2.sh b/challenge-137/abigail/bash/ch-2.sh new file mode 100644 index 0000000000..6776acf025 --- /dev/null +++ b/challenge-137/abigail/bash/ch-2.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# +# See ../README.md +# + +# +# Run as: bash ch-2.sh < input-file +# + +set -f +shopt -s extglob + +function reverse () { + local str=$1 + local len=${#str} + local rev="" + for ((i = len - 1; i >= 0; i --)) + do rev=$rev${str:$i:1} + done + reverse=$rev +} + +function ly () { + local n=$1 + reverse $n + local rev=${reverse/#+(0)/} + if ((n >= 10000000)) + then ly=1 + elif [[ $n = $rev ]] + then ly=0 + else ly $((n + rev)) + fi +} + +while read number +do ly $number + echo $ly +done -- cgit From dd6a1bfa4793a4da537a79ccbd70acf43141509a Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 20:16:15 +0100 Subject: C solutions for week 137 --- challenge-137/abigail/c/ch-1.c | 42 ++++++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/c/ch-2.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 challenge-137/abigail/c/ch-1.c create mode 100644 challenge-137/abigail/c/ch-2.c diff --git a/challenge-137/abigail/c/ch-1.c b/challenge-137/abigail/c/ch-1.c new file mode 100644 index 0000000000..de5f7df145 --- /dev/null +++ b/challenge-137/abigail/c/ch-1.c @@ -0,0 +1,42 @@ +# include +# include +# include + +/* + * See ../README.md + */ + +/* + * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o < input-file + */ + +short start_years [] = {1600, 2000}; +short long_year_offsets [] = { + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +}; + +int main (void) { + for (size_t i = 0; i < 2; i ++) { + for (size_t j = 0; j < 71; j ++) { + short year = start_years [i] + long_year_offsets [j]; + if (1900 <= year && year <= 2100) { + printf ("%d\n", year); + } + } + } +} diff --git a/challenge-137/abigail/c/ch-2.c b/challenge-137/abigail/c/ch-2.c new file mode 100644 index 0000000000..14f3efecf3 --- /dev/null +++ b/challenge-137/abigail/c/ch-2.c @@ -0,0 +1,37 @@ +# include +# include +# include + +/* + * See ../README.md + */ + +/* + * Run as: cc -o ch-2.o ch-2.c; ./ch-2.o < input-file + */ + +long reverse (long number) { + long reverse = 0; + while (number > 0) { + reverse *= 10; + reverse += number % 10; + number /= 10; + } + return reverse; +} + +short ly (long n) { + return n >= 10000000 ? 1 + : n == reverse (n) ? 0 + : ly (n + reverse (n)); +} + +int main (void) { + long n; + + while (scanf ("%ld", &n) == 1) { + printf ("%d\n", ly (n)); + } + + return (0); +} -- cgit From 774aa553d53dccf2c51f3ce6da319c45c7b398c1 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 20:43:32 +0100 Subject: Lua solutions for week 137 --- challenge-137/abigail/lua/ch-1.lua | 38 ++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/lua/ch-2.lua | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 challenge-137/abigail/lua/ch-1.lua create mode 100644 challenge-137/abigail/lua/ch-2.lua diff --git a/challenge-137/abigail/lua/ch-1.lua b/challenge-137/abigail/lua/ch-1.lua new file mode 100644 index 0000000000..152dca12ca --- /dev/null +++ b/challenge-137/abigail/lua/ch-1.lua @@ -0,0 +1,38 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-1.lua < input-file +-- + +local start_years = {1600, 2000} +local long_year_offsets = { + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +} + +for i = 1, #start_years do + for j = 1, #long_year_offsets do + local year = start_years [i] + long_year_offsets [j] + if 1900 <= year and year <= 2100 then + print (year) + end + end +end diff --git a/challenge-137/abigail/lua/ch-2.lua b/challenge-137/abigail/lua/ch-2.lua new file mode 100644 index 0000000000..1cfb4f84e9 --- /dev/null +++ b/challenge-137/abigail/lua/ch-2.lua @@ -0,0 +1,34 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-2.lua < input-file +-- + +function reverse (num) + local rev = 0 + while num > 0 do + rev = rev * 10 + rev = rev + (num % 10) + num = math . floor (num / 10) + end + return (rev) +end + + +function ly (n) + if n >= 10000000 + then return (1) + elseif n == reverse (n) + then return (0) + else return (ly (n + reverse (n))) + end +end + + +for number in io . lines () do + print (ly (tonumber (number))) +end -- cgit From 6e30de0aa5b931e7cef2cbff5dd53612c35bd993 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 21:03:55 +0100 Subject: Node.js solutions for week 137 --- challenge-137/abigail/node/ch-1.js | 40 ++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/node/ch-2.js | 30 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 challenge-137/abigail/node/ch-1.js create mode 100644 challenge-137/abigail/node/ch-2.js diff --git a/challenge-137/abigail/node/ch-1.js b/challenge-137/abigail/node/ch-1.js new file mode 100644 index 0000000000..a744551341 --- /dev/null +++ b/challenge-137/abigail/node/ch-1.js @@ -0,0 +1,40 @@ +#!/usr/local/bin/node + +// +// See ../README.md +// + +// +// Run as: node ch-1.js +// + + +let start_years = [1600, 2000] +let long_year_offsets = [ + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +] + + +start_years . forEach (start_year => { + long_year_offsets . forEach (offset => { + let year = start_year + offset + if (1900 <= year && year <= 2100) { + console . log (year) + } + }) +}) diff --git a/challenge-137/abigail/node/ch-2.js b/challenge-137/abigail/node/ch-2.js new file mode 100644 index 0000000000..75eef836c8 --- /dev/null +++ b/challenge-137/abigail/node/ch-2.js @@ -0,0 +1,30 @@ +#!/usr/local/bin/node + +// +// See ../README.md +// + +// +// Run as: node ch-2.js < input-file +// + +function reverse (num) { + let rev = 0 + while (num > 0) { + rev *= 10 + rev += num % 10 + num = Math . floor (num / 10) + } + return (rev) +} + +function ly (n) { + return n >= 10000000 ? 1 + : n == reverse (n) ? 0 + : ly (n + reverse (n)) +} + + require ('readline') +. createInterface ({input: process . stdin}) +. on ('line', num => console . log (ly (+num))) + -- cgit From 6d9e22bb702f40d07b0cf18439106eb0748e1b3c Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 1 Nov 2021 21:06:11 +0100 Subject: Fix "Run as" line --- challenge-137/abigail/bash/ch-1.sh | 2 +- challenge-137/abigail/c/ch-1.c | 2 +- challenge-137/abigail/lua/ch-1.lua | 2 +- challenge-137/abigail/perl/ch-1.pl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/challenge-137/abigail/bash/ch-1.sh b/challenge-137/abigail/bash/ch-1.sh index a3b12c9266..667fa0a54d 100644 --- a/challenge-137/abigail/bash/ch-1.sh +++ b/challenge-137/abigail/bash/ch-1.sh @@ -5,7 +5,7 @@ # # -# Run as: bash ch-1.sh < input-file +# Run as: bash ch-1.sh # set -f diff --git a/challenge-137/abigail/c/ch-1.c b/challenge-137/abigail/c/ch-1.c index de5f7df145..356b19321d 100644 --- a/challenge-137/abigail/c/ch-1.c +++ b/challenge-137/abigail/c/ch-1.c @@ -7,7 +7,7 @@ */ /* - * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o < input-file + * Run as: cc -o ch-1.o ch-1.c; ./ch-1.o */ short start_years [] = {1600, 2000}; diff --git a/challenge-137/abigail/lua/ch-1.lua b/challenge-137/abigail/lua/ch-1.lua index 152dca12ca..9f85c39fb4 100644 --- a/challenge-137/abigail/lua/ch-1.lua +++ b/challenge-137/abigail/lua/ch-1.lua @@ -5,7 +5,7 @@ -- -- --- Run as: lua ch-1.lua < input-file +-- Run as: lua ch-1.lua -- local start_years = {1600, 2000} diff --git a/challenge-137/abigail/perl/ch-1.pl b/challenge-137/abigail/perl/ch-1.pl index 8c788fe38a..573fc78007 100644 --- a/challenge-137/abigail/perl/ch-1.pl +++ b/challenge-137/abigail/perl/ch-1.pl @@ -14,7 +14,7 @@ use experimental 'lexical_subs'; # # -# Run as: perl ch-1.pl < input-file +# Run as: perl ch-1.pl # # -- cgit From 6b972ea8100cf12dfdc2f92dbf8ba66dc3c98725 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 00:40:03 +0100 Subject: Ruby solutions for week 137 --- challenge-137/abigail/ruby/ch-1.rb | 41 ++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/ruby/ch-2.rb | 30 ++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 challenge-137/abigail/ruby/ch-1.rb create mode 100644 challenge-137/abigail/ruby/ch-2.rb diff --git a/challenge-137/abigail/ruby/ch-1.rb b/challenge-137/abigail/ruby/ch-1.rb new file mode 100644 index 0000000000..c543cf3291 --- /dev/null +++ b/challenge-137/abigail/ruby/ch-1.rb @@ -0,0 +1,41 @@ +#!/usr/bin/ruby + +# +# See ../README.md +# + +# +# Run as: ruby ch-1.rb +# + + +start_years = [1600, 2000] +long_year_offsets = [ + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +] + +start_years . each do + | start_year | + long_year_offsets . each do + | offset | + year = start_year + offset + if 1900 <= year and year <= 2100 then + puts (year) + end + end +end diff --git a/challenge-137/abigail/ruby/ch-2.rb b/challenge-137/abigail/ruby/ch-2.rb new file mode 100644 index 0000000000..ed5b73c51f --- /dev/null +++ b/challenge-137/abigail/ruby/ch-2.rb @@ -0,0 +1,30 @@ +#!/usr/bin/ruby + +# +# See ../README.md +# + +# +# Run as: ruby ch-2.rb < input-file +# + +def reverse (num) + rev = 0 + while num > 0 do + rev *= 10 + rev += num % 10 + num /= 10 + end + return rev +end + +def ly (num) + return num >= 10000000 ? 1 + : num == reverse(num) ? 0 + : ly(num + reverse(num)) +end + +ARGF . each_line do + | number | + puts (ly(number . to_i)) +end -- cgit From fc52f6b569892b44d0f934ae795c199f2b7d3a53 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 00:41:39 +0100 Subject: Python solutions for week 137 --- challenge-137/abigail/python/ch-1.py | 36 ++++++++++++++++++++++++++++++++++++ challenge-137/abigail/python/ch-2.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 challenge-137/abigail/python/ch-1.py create mode 100644 challenge-137/abigail/python/ch-2.py diff --git a/challenge-137/abigail/python/ch-1.py b/challenge-137/abigail/python/ch-1.py new file mode 100644 index 0000000000..e7fe2c5b94 --- /dev/null +++ b/challenge-137/abigail/python/ch-1.py @@ -0,0 +1,36 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-1.py +# + + +start_years = [1600, 2000] +long_year_offsets = [ + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +] + +for start_year in start_years: + for offset in long_year_offsets: + year = start_year + offset + if 1900 <= year <= 2100: + print (year) diff --git a/challenge-137/abigail/python/ch-2.py b/challenge-137/abigail/python/ch-2.py new file mode 100644 index 0000000000..8e27559fbf --- /dev/null +++ b/challenge-137/abigail/python/ch-2.py @@ -0,0 +1,29 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-2.py < input-file +# + +import fileinput + +def reverse (num): + rev = 0 + while num > 0: + rev = rev * 10 + (num % 10) + num = num // 10 + return rev + + +def ly (num): + if num >= 10000000: + return 1 + if num == reverse (num): + return 0 + return ly (num + reverse (num)) + +for number in fileinput . input (): + print (ly (int (number))) -- cgit From 699ca8187ca34c2f1d41e40efdf055ba2e76606e Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 00:53:36 +0100 Subject: Improve Perl solution --- challenge-137/abigail/perl/ch-1.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/challenge-137/abigail/perl/ch-1.pl b/challenge-137/abigail/perl/ch-1.pl index 573fc78007..875aca99a4 100644 --- a/challenge-137/abigail/perl/ch-1.pl +++ b/challenge-137/abigail/perl/ch-1.pl @@ -44,6 +44,7 @@ use experimental 'lexical_subs'; # Guess which method we're using. # +my @start_years = qw [1600 2000] my @long_year_offsets = qw [ 004 009 015 020 026 032 037 043 048 054 @@ -64,4 +65,4 @@ my @long_year_offsets = qw [ ]; say for grep {1900 <= $_ <= 2100} - map {my $fy = $_; map {$_ + $fy} @long_year_offsets} 1600, 2000; + map {my $fy = $_; map {$_ + $fy} @long_year_offsets} @start_years -- cgit From 0caafd52c1ce972b7fea39b7817130a3cbd0ab55 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 13:07:05 +0100 Subject: Go solutions for week 137 --- challenge-137/abigail/go/ch-1.go | 44 ++++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/go/ch-2.go | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 challenge-137/abigail/go/ch-1.go create mode 100644 challenge-137/abigail/go/ch-2.go diff --git a/challenge-137/abigail/go/ch-1.go b/challenge-137/abigail/go/ch-1.go new file mode 100644 index 0000000000..2e6c515d0d --- /dev/null +++ b/challenge-137/abigail/go/ch-1.go @@ -0,0 +1,44 @@ +package main + +// +// See ../README.md +// + +// +// Run as: go run ch-1.go +// + +import ( + "fmt" +) + +func main () { + start_years := [] int {1600, 2000} + long_year_offsets := [] int { + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398, + } + + for _, start_year := range start_years { + for _, offset := range long_year_offsets { + year := start_year + offset + if 1900 <= year && year <= 2100 { + fmt . Println (year) + } + } + } +} diff --git a/challenge-137/abigail/go/ch-2.go b/challenge-137/abigail/go/ch-2.go new file mode 100644 index 0000000000..31815d21aa --- /dev/null +++ b/challenge-137/abigail/go/ch-2.go @@ -0,0 +1,40 @@ +package main + +// +// See ../README.md +// + +// +// Run as: go run ch-2.go < input-file +// + +import ( + "fmt" +) + +func reverse (num int) int { + rev := 0 + for num > 0 { + rev *= 10 + rev += num % 10 + num /= 10 + } + return rev +} + +func ly (n int) int { + if n >= 10000000 {return 1} + if n == reverse (n) {return 0} + return ly (n + reverse (n)) +} + +func main () { + for { + var num int + n, err := fmt . Scanf ("%d", &num) + if n != 1 || err != nil { + break + } + fmt . Println (ly (num)) + } +} -- cgit From db3e148ab096df5fdd3a8f70a9221a9b4c57c7da Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 13:27:35 +0100 Subject: bc solutions for week 137 --- challenge-137/abigail/bc/ch-1.bc | 93 +++++++++++++++++++++++++++++++++++++++ challenge-137/abigail/bc/ch-2.bc | 32 ++++++++++++++ challenge-137/abigail/t/ctest.ini | 3 ++ 3 files changed, 128 insertions(+) create mode 100644 challenge-137/abigail/bc/ch-1.bc create mode 100644 challenge-137/abigail/bc/ch-2.bc diff --git a/challenge-137/abigail/bc/ch-1.bc b/challenge-137/abigail/bc/ch-1.bc new file mode 100644 index 0000000000..5ca2539d46 --- /dev/null +++ b/challenge-137/abigail/bc/ch-1.bc @@ -0,0 +1,93 @@ +# +# See ../README.md +# + +# +# Run as: bc ch-1.bc +# + +s [ 0] = 1600 +s [ 1] = 2000 + +o [ 0] = 4 +o [ 1] = 9 +o [ 2] = 15 +o [ 3] = 20 +o [ 4] = 26 +o [ 5] = 32 +o [ 6] = 37 +o [ 7] = 43 +o [ 8] = 48 +o [ 9] = 54 +o [10] = 60 +o [11] = 65 +o [12] = 71 +o [13] = 76 +o [14] = 82 +o [15] = 88 +o [16] = 93 +o [17] = 99 +o [18] = 105 +o [19] = 111 +o [20] = 116 +o [21] = 122 +o [22] = 128 +o [23] = 133 +o [24] = 139 +o [25] = 144 +o [26] = 150 +o [27] = 156 +o [28] = 161 +o [29] = 167 +o [30] = 172 +o [31] = 178 +o [32] = 184 +o [33] = 189 +o [34] = 195 +o [35] = 201 +o [36] = 207 +o [37] = 212 +o [38] = 218 +o [39] = 224 +o [40] = 229 +o [41] = 235 +o [42] = 240 +o [43] = 246 +o [44] = 252 +o [45] = 257 +o [46] = 263 +o [47] = 268 +o [48] = 274 +o [49] = 280 +o [50] = 285 +o [51] = 291 +o [52] = 296 +o [53] = 303 +o [54] = 308 +o [55] = 314 +o [56] = 320 +o [57] = 325 +o [58] = 331 +o [59] = 336 +o [60] = 342 +o [61] = 348 +o [62] = 353 +o [63] = 359 +o [64] = 364 +o [65] = 370 +o [66] = 376 +o [67] = 381 +o [68] = 387 +o [69] = 392 +o [70] = 398 + +for (i = 0; i < 2; i ++) { + for (j = 0; j < 71; j ++) { + y = s [i] + o [j] + if (1900 <= y && y <= 2100) { + y + } + } +} + +quit diff --git a/challenge-137/abigail/bc/ch-2.bc b/challenge-137/abigail/bc/ch-2.bc new file mode 100644 index 0000000000..b0502d8f7a --- /dev/null +++ b/challenge-137/abigail/bc/ch-2.bc @@ -0,0 +1,32 @@ +# +# See ../README.md +# + +# +# Run as: bc ch-2.bc < input-file +# + +define r (n) { + v = 0 + while (n > 0) { + v *= 10 + v += n % 10 + n /= 10 + } + return (v) +} + + +define l (n) { + if (n >= 10000000) {return (1)} + if (n == r (n)) {return (0)} + return l (n + r (n)) +} + +while (1) { + n = read () + if (n == 0) {break} + l (n) +} + +quit diff --git a/challenge-137/abigail/t/ctest.ini b/challenge-137/abigail/t/ctest.ini index 4a58fc7705..6acd263bb3 100644 --- a/challenge-137/abigail/t/ctest.ini +++ b/challenge-137/abigail/t/ctest.ini @@ -11,3 +11,6 @@ [1-1] no_input = 1 + +[2-1,2-2/bc] +add_to_input = 0 -- cgit From a8de91a4ef028035393b22e79aecb3d4834e3271 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 14:02:33 +0100 Subject: Java solutions for week 137 --- challenge-137/abigail/java/ch-1.java | 42 ++++++++++++++++++++++++++++++++++++ challenge-137/abigail/java/ch-2.java | 34 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 challenge-137/abigail/java/ch-1.java create mode 100644 challenge-137/abigail/java/ch-2.java diff --git a/challenge-137/abigail/java/ch-1.java b/challenge-137/abigail/java/ch-1.java new file mode 100644 index 0000000000..f15167da39 --- /dev/null +++ b/challenge-137/abigail/java/ch-1.java @@ -0,0 +1,42 @@ +// +// See ../README.md +// + +// +// Run as: ln ch-1.java ch1.java; javac ch1.java; java ch1 +// + +import java.util.*; + +public class ch1 { + static int [] start_years = {1600, 2000}; + static int [] long_year_offsets = { + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398, + }; + + public static void main (String [] args) { + for (int start_year: start_years) { + for (int offset: long_year_offsets) { + int year = start_year + offset; + if (1900 <= year && year <= 2100) { + System . out . println (year); + } + } + } + } +} diff --git a/challenge-137/abigail/java/ch-2.java b/challenge-137/abigail/java/ch-2.java new file mode 100644 index 0000000000..20b8034d2b --- /dev/null +++ b/challenge-137/abigail/java/ch-2.java @@ -0,0 +1,34 @@ +// +// See ../README.md +// + +// +// Run as: ln ch-2.java ch2.java; javac ch2.java; java ch2 < input-file +// + +import java.util.*; + +public class ch2 { + static int reverse (int num) { + int rev = 0; + while (num > 0) { + rev *= 10; + rev += num % 10; + num /= 10; + } + return (rev); + } + + static int ly (int n) { + return n >= 10000000 ? 1 + : n == reverse (n) ? 0 + : ly (n + reverse (n)); + } + + public static void main (String [] args) { + Scanner scanner = new Scanner (System . in); + while (scanner . hasNextInt ()) { + System . out . println (ly (scanner . nextInt ())); + } + } +} -- cgit From 8d45c56c179f278b3fbaf631b67c0ae8a9e994f0 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 14:45:09 +0100 Subject: Tcl solutions for week 137 --- challenge-137/abigail/tcl/ch-1.tcl | 26 ++++++++++++++++++++++++++ challenge-137/abigail/tcl/ch-2.tcl | 27 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 challenge-137/abigail/tcl/ch-1.tcl create mode 100644 challenge-137/abigail/tcl/ch-2.tcl diff --git a/challenge-137/abigail/tcl/ch-1.tcl b/challenge-137/abigail/tcl/ch-1.tcl new file mode 100644 index 0000000000..b4b6db3ab5 --- /dev/null +++ b/challenge-137/abigail/tcl/ch-1.tcl @@ -0,0 +1,26 @@ +# +# See ../README.md +# + +# +# Run as: tclsh ch-1.tcl +# + +set start_years [list 1600 2000] +set long_year_offsets [list \ + 4 9 15 20 26 32 37 43 48 54 60 65 71 76 82 \ + 88 93 99 105 111 116 122 128 133 139 144 150 \ + 156 161 167 172 178 184 189 195 201 207 212 218 \ + 224 229 235 240 246 252 257 263 268 274 280 285 291 296 \ + 303 308 314 320 325 331 336 342 348 353 359 364 370 \ + 376 381 387 392 398 ] + + +foreach start_year $start_years { + foreach offset $long_year_offsets { + set year [expr $start_year + $offset] + if {1900 <= $year && $year <= 2100} { + puts $year + } + } +} diff --git a/challenge-137/abigail/tcl/ch-2.tcl b/challenge-137/abigail/tcl/ch-2.tcl new file mode 100644 index 0000000000..0c5c9ecfd8 --- /dev/null +++ b/challenge-137/abigail/tcl/ch-2.tcl @@ -0,0 +1,27 @@ +# +# See ../README.md +# + +# +# Run as: tclsh ch-2.tcl < input-file +# + +proc reverse num { + set rev 0 + while {$num > 0} { + set rev [expr $rev * 10] + set rev [expr $rev + [expr $num % 10]] + set num [expr $num / 10] + } + return $rev +} + +proc ly n { + if {$n >= 10000000} {return 1} + if {$n == [reverse $n]} {return 0} + return [ly [expr $n + [reverse $n]]] +} + +while {[gets stdin num] >= 0} { + puts [ly $num] +} -- cgit From 75d8c0ad0b6724039e865e1d6e61630575ada351 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 15:09:56 +0100 Subject: R solutions for week 137 --- challenge-137/abigail/r/ch-1.r | 36 ++++++++++++++++++++++++++++++++++++ challenge-137/abigail/r/ch-2.r | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 challenge-137/abigail/r/ch-1.r create mode 100644 challenge-137/abigail/r/ch-2.r diff --git a/challenge-137/abigail/r/ch-1.r b/challenge-137/abigail/r/ch-1.r new file mode 100644 index 0000000000..fecc7744fa --- /dev/null +++ b/challenge-137/abigail/r/ch-1.r @@ -0,0 +1,36 @@ +# +# See ../README.md +# + +# +# Run as: Rscript ch-1.r +# + +start_years <- c (1600, 2000) +long_year_offsets <- c ( + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 +) + +for (start_year in start_years) { + for (year in start_year + long_year_offsets) { + if (1900 <= year && year <= 2100) { + cat (year, "\n") + } + } +} + diff --git a/challenge-137/abigail/r/ch-2.r b/challenge-137/abigail/r/ch-2.r new file mode 100644 index 0000000000..07ea850321 --- /dev/null +++ b/challenge-137/abigail/r/ch-2.r @@ -0,0 +1,38 @@ +# +# See ../README.md +# + +# +# Run as: Rscript ch-2.r < input-file +# + +reverse <- function (num) { + rev <- 0 + while (num > 0) { + rev <- rev * 10 + rev <- rev + (num %% 10) + num <- num %/% 10 + } + return (rev) +} + +ly <- function (n) { + if (n >= 10000000) { + 1 + } else if (n == reverse (n)) { + 0 + } else { + ly (n + reverse (n)) + } +} + + +stdin <- file ('stdin', 'r') +repeat { + n <- readLines (stdin, n = 1) + if (length (n) == 0) { + break + } + n = as.integer (n) + cat (ly (n), "\n") +} -- cgit From 83c00ce954933e83073e4205e492201455209abe Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 2 Nov 2021 18:07:08 +0100 Subject: Scheme solutions for week 137 --- challenge-137/abigail/scheme/ch-1.scm | 33 +++++++++++++++++++++++++++++++++ challenge-137/abigail/scheme/ch-2.scm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 challenge-137/abigail/scheme/ch-1.scm create mode 100644 challenge-137/abigail/scheme/ch-2.scm diff --git a/challenge-137/abigail/scheme/ch-1.scm b/challenge-137/abigail/scheme/ch-1.scm new file mode 100644 index 0000000000..8d37395619 --- /dev/null +++ b/challenge-137/abigail/scheme/ch-1.scm @@ -0,0 +1,33 @@ +;;; +;;; See ../README.md +;;; + +;;; +;;; Run as: guile --no-auto-compile ch-1.scm +;;; + +(use-modules (ice-9 format)) + +(define start-years (list 1600 2000)) +(define long-year-offsets (list + 004 009 015 020 026 032 037 043 048 054 060 065 071 076 082 + 088 093 099 105 111 116 122 128 133 139 144 150 + 156 161 167 172 178 184 189 195 201 207 212 218 + 224 229 235 240 246 252 257 263 268 274 280 285 291 296 + 303 308 314 320 325 331 336 342 348 353 359 364 370 + 376 381 387 392 398 +)) + +(define (check-year start-year offset) + (define year (+ start-year offset)) + (if (and (<= 1900 year) (<= year 2100)) + (format #t "~d~%" year))) + + +(for-each + (lambda (start-year) + (for-each + (lambda (offset) + (check-year start-year offset)) + long-year-offsets)) + start-years) diff --git a/challenge-137/abigail/scheme/ch-2.scm b/challenge-137/abigail/scheme/ch-2.scm new file mode 100644 index 0000000000..dc17dee619 --- /dev/null +++ b/challenge-137/abigail/scheme/ch-2.scm @@ -0,0 +1,35 @@ +;;; +;;; See ../README.md +;;; + +;;; +;;; Run as: guile --no-auto-compile ch-2.scm +;;; + +(use-modules (ice-9 format)) + +(define (reverse num) + (define rev 0) + (while (> num 0) + (set! rev (* rev 10)) + (set! rev (+ rev (modulo num 10))) + (set! num (truncate (/ num 10))) + ) + rev +) + +(define (ly n) + (cond ((>= n 10000000) 1) + ((= n (reverse n)) 0) + (else (ly (+ n (reverse n)))))) + + +(define (main) + (define num (read)) + (if (not (eof-object? num)) + (begin + (format #t "~d~%" (ly num)) + (main)))) + + +(main) -- cgit From bb51fcbf0b671b63b348838e652d1367893d1ff0 Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 3 Nov 2021 13:55:53 +0100 Subject: Pacal solutions for week 137 --- challenge-137/abigail/pascal/ch-1.p | 52 +++++++++++++++++++++++++++++++++++++ challenge-137/abigail/pascal/ch-2.p | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 challenge-137/abigail/pascal/ch-1.p create mode 100644 challenge-137/abigail/pascal/ch-2.p diff --git a/challenge-137/abigail/pascal/ch-1.p b/challenge-137/abigail/pascal/ch-1.p new file mode 100644 index 0000000000..8a98408f26 --- /dev/null +++ b/challenge-137/abigail/pascal/ch-1.p @@ -0,0 +1,52 @@ +Program XXX; + +(* *) +(* See ../README.md *) +(* *) + +(* *) +(* Run as: fpc -och-1.out ch-1.p; ./ch-1.out < input-file *) +(* *) + +const + nr_of_start_years = 2; + nr_of_offsets = 71; + first_year = 1900; + last_year = 2100; + +var + start_years: Array [1 .. nr_of_start_years] of Integer = ( + 1600, 2000 + ); + long_year_offsets: Array [1 .. nr_of_offsets] of Integer = ( + 4, 9, 15, 20, 26, + 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, + 88, 93, 99, + 105, 111, 116, 122, + 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, + 184, 189, 195, + 201, 207, 212, 218, + 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, + 280, 285, 291, 296, + 303, 308, 314, + 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, + 376, 381, 387, 392, 398 + ); + year: Integer; + i, j: Integer; + +begin + for i := 1 to nr_of_start_years do begin + for j := 1 to nr_of_offsets do begin + year := start_years [i] + long_year_offsets [j]; + if (first_year <= year) and (year <= last_year) + then begin + writeln (year) + end + end + end +end. diff --git a/challenge-137/abigail/pascal/ch-2.p b/challenge-137/abigail/pascal/ch-2.p new file mode 100644 index 0000000000..00f2a424a4 --- /dev/null +++ b/challenge-137/abigail/pascal/ch-2.p @@ -0,0 +1,45 @@ +Program XXX; + +(* *) +(* See ../README.md *) +(* *) + +(* *) +(* Run as: fpc -och-2.out ch-2.p; ./ch-2.out < input-file *) +(* *) + +var + n: Longint; + +function reverse (num: Longint): Longint; + var + rev: Longint; + + begin + rev := 0; + while num > 0 do begin + rev := rev * 10; + rev := rev + (num mod 10); + num := num div 10; + end; + reverse := rev; + end; + + +function ly (num: Longint): integer; + begin + if num >= 10000000 then + ly := 1 + else if num = reverse (num) then + ly := 0 + else + ly := ly (num + reverse (num)) + end; + + +begin + while not eof do begin + readln (n); + writeln (ly (n)); + end +end. -- cgit From 1b32e48dbd84df6f39012c6c90e2b809df190e3b Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 3 Nov 2021 14:15:53 +0100 Subject: Fix link --- challenge-137/abigail/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-137/abigail/README.md b/challenge-137/abigail/README.md index b1b1f2b0ef..0707d1fbd5 100644 --- a/challenge-137/abigail/README.md +++ b/challenge-137/abigail/README.md @@ -21,7 +21,7 @@ ## Part 2 * [AWK](awk/ch-2.awk) -* [Bash](bash/ch-1.sh) +* [Bash](bash/ch-2.sh) * [Bc](bc/ch-2.bc) * [C](c/ch-2.c) * [Go](go/ch-2.go) -- cgit From 172d3d442f2e84abb4a29454124d00d50cdae72a Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 3 Nov 2021 17:41:34 +0100 Subject: Alternative Perl solution for week 137, part 1 --- challenge-137/abigail/README.md | 4 ++- challenge-137/abigail/perl/ch-1.pl | 7 ++-- challenge-137/abigail/perl/ch-1a.pl | 68 +++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 challenge-137/abigail/perl/ch-1a.pl diff --git a/challenge-137/abigail/README.md b/challenge-137/abigail/README.md index 0707d1fbd5..49fca86bcd 100644 --- a/challenge-137/abigail/README.md +++ b/challenge-137/abigail/README.md @@ -11,7 +11,9 @@ * [Lua](lua/ch-1.lua) * [Node.js](node/ch-1.js) * [Pascal](pascal/ch-1.p) -* [Perl](perl/ch-1.pl) +* Perl + * [Using loop-up](perl/ch-1.pl) + * [Using Doomsday values](perl/ch-1a.pl) * [Python](python/ch-1.py) * [R](r/ch-1.r) * [Ruby](ruby/ch-1.rb) diff --git a/challenge-137/abigail/perl/ch-1.pl b/challenge-137/abigail/perl/ch-1.pl index 875aca99a4..72e0efe0b4 100644 --- a/challenge-137/abigail/perl/ch-1.pl +++ b/challenge-137/abigail/perl/ch-1.pl @@ -36,15 +36,16 @@ use experimental 'lexical_subs'; # # Now, we could calculate the day of the week of Jan 1 and Dec 31, # either using a module or some handrolled calculations, checking -# whether at least of those days is a Thursday. +# whether at least of those days is a Thursday. # # Or we could just list the 71 years in a 400 year period, and so # some trivial arithmetic. # -# Guess which method we're using. +# We opt to use the latter method in this solution. +# For the former method, see ch-1a.pl. # -my @start_years = qw [1600 2000] +my @start_years = qw [1600 2000]; my @long_year_offsets = qw [ 004 009 015 020 026 032 037 043 048 054 diff --git a/challenge-137/abigail/perl/ch-1a.pl b/challenge-137/abigail/perl/ch-1a.pl new file mode 100644 index 0000000000..32d5f82a0b --- /dev/null +++ b/challenge-137/abigail/perl/ch-1a.pl @@ -0,0 +1,68 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-1a.pl +# + +# +# A year is a long year if the last day of the year is a Thursday, +# or if the last day of the year is a Friday, and the year is a +# leap year. +# +# To determine the day of the week of Dec 31, we first calculate the +# Doomsday value of the year: this is the day of the week of 4/4, +# 6/6, 8/8, 10/10, 12/12, 5/9, 9/5, 7/11, 11/7, Pi day, the last +# day of February, and January 3 (non leap years) or January 4 (leap years) +# +# Given the day of the week of Dec 12, it's trivial to calculate the +# day of the week of Dec 31. +# +# See also ch-1.pl for an alternative method to solve this. +# + +my $SUNDAY = 0; +my $MONDAY = 1; +my $TUESDAY = 2; +my $WEDNESDAY = 3; +my $THURSDAY = 4; +my $FRIDAY = 5; +my $SATURDAY = 6; + +# +# Given a year, return its "Doomsday" value. +# 0 -> Sunday, 6 -> Saturday +# +sub doomsday ($year) { + use integer; + my $anchor = ($TUESDAY, $SUNDAY, $FRIDAY, $WEDNESDAY) [($year / 100) % 4]; + my $y = $year % 100; + my $doomsday = ((($y / 12) + ($y % 12) + (($y % 12) / 4)) + $anchor) % 7; + $doomsday; +} + +sub is_leap ($year) { + ($year % 400 == 0) || ($year % 4 == 0) && ($year % 100 != 0) +} + +foreach my $year (1900 .. 2100) { + # + # Get the Doomsday value; this is the day of the week of December 12. + # Add 31, subtract 12 to get the day of the week of Dec 31. + # + my $doomsday = doomsday ($year); + my $dec_31 = ($doomsday - 12 + 31) % 7; + say $year if $dec_31 == $THURSDAY || $dec_31 == $FRIDAY && is_leap $year; +} -- cgit From d611eaafd3c04fb551287ac33cdd33d9afd2fe54 Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 3 Nov 2021 18:06:09 +0100 Subject: Alternative Node.js solution for week 137, part 1 --- challenge-137/abigail/README.md | 6 ++++-- challenge-137/abigail/node/ch-1a.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 challenge-137/abigail/node/ch-1a.js diff --git a/challenge-137/abigail/README.md b/challenge-137/abigail/README.md index 49fca86bcd..b6288d452d 100644 --- a/challenge-137/abigail/README.md +++ b/challenge-137/abigail/README.md @@ -9,10 +9,12 @@ * [Go](go/ch-1.go) * [Java](java/ch-1.java) * [Lua](lua/ch-1.lua) -* [Node.js](node/ch-1.js) +* Node.js + * [Using look-up](node/ch-1.js) + * [Using Doomsday values](node/ch-1a.js) * [Pascal](pascal/ch-1.p) * Perl - * [Using loop-up](perl/ch-1.pl) + * [Using look-up](perl/ch-1.pl) * [Using Doomsday values](perl/ch-1a.pl) * [Python](python/ch-1.py) * [R](r/ch-1.r) diff --git a/challenge-137/abigail/node/ch-1a.js b/challenge-137/abigail/node/ch-1a.js new file mode 100644 index 0000000000..e0e8d46341 --- /dev/null +++ b/challenge-137/abigail/node/ch-1a.js @@ -0,0 +1,37 @@ +#!/usr/local/bin/node + +// +// See ../README.md +// + +// +// Run as: node ch-1a.js < input-file +// + +let SUNDAY = 0 +let MONDAY = 1 +let TUESDAY = 2 +let WEDNESDAY = 3 +let THURSDAY = 4 +let FRIDAY = 5 +let SATURDAY = 6 + +function doomsday (year) { + let anchor = [TUESDAY, SUNDAY, FRIDAY, WEDNESDAY] + [Math . floor (year / 100) % 4] + let y = year % 100 + let doomsday = ((Math . floor (y / 12) + (y % 12) + + Math . floor ((y % 12) / 4)) + anchor) % 7 + return (doomsday) +} + +function is_leap (year) { + return ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) +} + +for (year = 1900; year <= 2100; year ++) { + let dec_31 = (doomsday (year) + 31 - 12) % 7 + if (dec_31 == THURSDAY || dec_31 == FRIDAY && is_leap (year)) { + console . log (year) + } +} -- cgit From 5362ea1e68eb51ac1b71bd5409246440b7a37f51 Mon Sep 17 00:00:00 2001 From: Abigail Date: Thu, 4 Nov 2021 14:31:57 +0100 Subject: Erlang solution for week 137, part 1 --- challenge-137/abigail/README.md | 1 + challenge-137/abigail/erlang/ch-1.erl | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 challenge-137/abigail/erlang/ch-1.erl diff --git a/challenge-137/abigail/README.md b/challenge-137/abigail/README.md index b6288d452d..6af7507c57 100644 --- a/challenge-137/abigail/README.md +++ b/challenge-137/abigail/README.md @@ -6,6 +6,7 @@ * [Bash](bash/ch-1.sh) * [Bc](bc/ch-1.bc) * [C](c/ch-1.c) +* [Erlang](c/ch-1.erl) * [Go](go/ch-1.go) * [Java](java/ch-1.java) * [Lua](lua/ch-1.lua) diff --git a/challenge-137/abigail/erlang/ch-1.erl b/challenge-137/abigail/erlang/ch-1.erl new file mode 100644 index 0000000000..dd612e4d0d --- /dev/null +++ b/challenge-137/abigail/erlang/ch-1.erl @@ -0,0 +1,41 @@ +% +% See ../README.md +% + +% +% Run as: ln ch-1.erl ch1.erl +% erl -compile ch1 +% erl -noshell -s ch1 main -s init stop +% + +-module (ch1). +-export ([main/0]). + + +long_year ([], _) -> ok; +long_year (_, []) -> ok; + +long_year ([Start], [Offset | Offsets]) -> + Year = Start + Offset, + if (1900 =< Year) and (Year =< 2100) -> io:fwrite ("~B~n", [Year]); + true -> ok + end, + long_year ([Start], Offsets); + +long_year ([Start | Starts], Offsets) -> + long_year ([Start], Offsets), + long_year (Starts, Offsets). + +main () -> + Start_years = [1600, 2000], + Long_year_offsets = [ + 4, 9, 15, 20, 26, 32, 37, 43, 48, 54, + 60, 65, 71, 76, 82, 88, 93, 99, + 105, 111, 116, 122, 128, 133, 139, 144, 150, + 156, 161, 167, 172, 178, 184, 189, 195, + 201, 207, 212, 218, 224, 229, 235, 240, 246, + 252, 257, 263, 268, 274, 280, 285, 291, 296, + 303, 308, 314, 320, 325, 331, 336, 342, + 348, 353, 359, 364, 370, 376, 381, 387, 392, 398 + ], + long_year (Start_years, Long_year_offsets). -- cgit From 896f286ee0b88f2a381b5a97cbbbd82bbf4712af Mon Sep 17 00:00:00 2001 From: Abigail Date: Thu, 4 Nov 2021 20:06:52 +0100 Subject: Link to blogs for week 137 --- challenge-133/abigail/blog.txt | 2 +- challenge-133/abigail/blog1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge-133/abigail/blog.txt b/challenge-133/abigail/blog.txt index db2d358210..347f6c08d1 100644 --- a/challenge-133/abigail/blog.txt +++ b/challenge-133/abigail/blog.txt @@ -1 +1 @@ -https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-133-1.html +https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-137-1.html diff --git a/challenge-133/abigail/blog1.txt b/challenge-133/abigail/blog1.txt index d67cf83760..543d11bcea 100644 --- a/challenge-133/abigail/blog1.txt +++ b/challenge-133/abigail/blog1.txt @@ -1 +1 @@ -https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-133-2.html +https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-137-2.html -- cgit