From 4924dd02645b52a0711d3284011e3584c3fe83d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Mon, 11 Aug 2025 18:05:26 -0700 Subject: [PATCH] Data update --- .gitignore | 5 + Conf/lang.yaml | 25 +- Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt | 1 + Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml | 2 + Lang/ALGOL-60/Factorial | 1 - Lang/ALGOL-68/Date-manipulation | 1 + ...stribution-of-0-digits-in-factorial-series | 1 + Lang/ALGOL-68/Factorial | 1 - Lang/ALGOL-68/Knapsack-problem-Continuous | 1 + Lang/ALGOL-68/Word-wheel | 1 + Lang/ALGOL-W/Factorial | 1 - Lang/ALGOL-W/Knapsack-problem-Continuous | 1 + Lang/ANSI-BASIC/AKS-test-for-primes | 1 + Lang/ANSI-BASIC/Old-Russian-measure-of-length | 1 + Lang/APL/Monte-Carlo-methods | 1 + Lang/ARM-Assembly/00-LANG.txt | 39 +- Lang/ASIC/Old-Russian-measure-of-length | 1 + Lang/AWK/100-doors | 1 - Lang/AWK/Factorial-primes | 1 + Lang/AWK/Soloways-recurring-rainfall | 1 + Lang/Ada/Almkvist-Giullera-formula-for-pi | 1 + Lang/Ada/Biorhythms | 1 + Lang/Ada/Boyer-Moore-string-search | 1 + Lang/Ada/Calkin-Wilf-sequence | 1 + Lang/Ada/Camel-case-and-snake-case | 1 + Lang/Ada/Canonicalize-CIDR | 1 + Lang/Ada/Deepcopy | 1 + Lang/Ada/Factorions | 1 + Lang/Ada/Find-duplicate-files | 1 + Lang/Ada/Harmonic-series | 1 + Lang/Ada/Knapsack-problem-Bounded | 1 + Lang/Ada/Levenshtein-distance-Alignment | 1 + Lang/Ada/Long-literals-with-continuations | 1 + Lang/Ada/Longest-increasing-subsequence | 1 + Lang/Ada/Machine-code | 1 + Lang/Ada/Minimal-steps-down-to-1 | 1 + Lang/Ada/Naming-conventions | 1 + .../Read-a-file-character-by-character-UTF8 | 1 + Lang/Ada/Test-integerness | 1 + Lang/Ada/Total-circles-area | 1 + Lang/Ada/Twos-complement | 1 + Lang/Ada/Vector | 1 + Lang/Adina/00-LANG.txt | 13 + Lang/Adina/00-META.yaml | 2 + Lang/Adina/100-doors | 1 + Lang/Adina/Even-or-odd | 1 + Lang/Adina/Hello-world-Text | 1 + Lang/Adina/Loops-For | 1 + Lang/Adina/Tree-traversal | 1 + Lang/Agena/00-LANG.txt | 4 +- Lang/Agena/AKS-test-for-primes | 1 + ...ficient-and-perfect-number-classifications | 1 + Lang/Agena/Abundant-odd-numbers | 1 + .../Arbitrary-precision-integers-included- | 1 + Lang/Agena/Attractive-numbers | 1 + Lang/Agena/Disarium-numbers | 1 + Lang/Agena/Factorial | 1 + Lang/Agena/Factorial-primes | 1 + Lang/Agena/Giuga-numbers | 1 + Lang/Agena/Goldbachs-comet | 1 + .../Horners-rule-for-polynomial-evaluation | 1 + Lang/Agena/Humble-numbers | 1 + Lang/Agena/JSON | 1 + Lang/Agena/Jacobsthal-numbers | 1 + Lang/Agena/Jewels-and-stones | 1 + Lang/Agena/Kaprekar-numbers | 1 + Lang/Agena/Mian-Chowla-sequence | 1 + Lang/Agena/Pernicious-numbers | 1 + Lang/Agena/Pisano-period | 1 + Lang/Agena/Primality-by-trial-division | 1 + .../Sequence-of-primes-by-trial-division | 1 + Lang/Agena/Smarandache-prime-digital-sequence | 1 + Lang/Agena/Soloways-recurring-rainfall | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + Lang/Agena/Time-a-function | 1 + Lang/Agena/Totient-function | 1 + Lang/Agena/Unprimeable-numbers | 1 + Lang/Agena/Van-Eck-sequence | 1 + Lang/Agena/Van-der-Corput-sequence | 1 + Lang/Agena/Wagstaff-primes | 1 + Lang/Agena/Wieferich-primes | 1 + Lang/Agena/Yellowstone-sequence | 1 + Lang/Apple/00-LANG.txt | 12 + Lang/Apple/00-META.yaml | 2 + Lang/Apple/Averages-Arithmetic-mean | 1 + Lang/Apple/Averages-Pythagorean-means | 1 + Lang/Apple/Catamorphism | 1 + Lang/Apple/Dot-product | 1 + Lang/Apple/Factorial | 1 + Lang/Apple/Factors-of-an-integer | 1 + Lang/Apple/Filter | 1 + Lang/Apple/ISBN13-check-digit | 1 + Lang/Aria/00-LANG.txt | 15 + Lang/Aria/00-META.yaml | 2 + Lang/Aria/99-bottles-of-beer | 1 + Lang/Aria/Hello-world-Text | 1 + Lang/ArkScript/00-LANG.txt | 43 ++ Lang/ArkScript/00-META.yaml | 2 + Lang/ArkScript/100-doors | 1 + Lang/ArkScript/99-bottles-of-beer | 1 + Lang/ArkScript/A+B | 1 + Lang/ArkScript/Abbreviations-easy | 1 + Lang/ArkScript/Ackermann-function | 1 + Lang/ArkScript/Apply-a-callback-to-an-array | 1 + Lang/ArkScript/Arithmetic-Complex | 1 + Lang/ArkScript/Arithmetic-Integer | 1 + Lang/ArkScript/Array-concatenation | 1 + Lang/ArkScript/Array-length | 1 + Lang/ArkScript/Ascending-primes | 1 + Lang/ArkScript/Associative-array-Creation | 1 + Lang/ArkScript/Associative-array-Iteration | 1 + Lang/ArkScript/Balanced-brackets | 1 + Lang/ArkScript/Boolean-values | 1 + Lang/ArkScript/Calculating-the-value-of-e | 1 + Lang/ArkScript/Call-a-function | 1 + Lang/ArkScript/Call-an-object-method | 1 + Lang/ArkScript/Catamorphism | 1 + Lang/ArkScript/Check-that-file-exists | 1 + Lang/ArkScript/Closures-Value-capture | 1 + Lang/ArkScript/Comments | 1 + Lang/ArkScript/Compound-data-type | 1 + Lang/ArkScript/Concurrent-computing | 1 + Lang/ArkScript/Conditional-structures | 1 + Lang/ArkScript/Conways-Game-of-Life | 1 + Lang/ArkScript/Copy-a-string | 1 + Lang/ArkScript/Currying | 1 + Lang/ArkScript/Delete-a-file | 1 + Lang/ArkScript/Empty-directory | 1 + Lang/ArkScript/Empty-program | 1 + Lang/ArkScript/Empty-string | 1 + Lang/ArkScript/Enforced-immutability | 1 + Lang/ArkScript/Even-or-odd | 1 + Lang/ArkScript/Extend-your-language | 1 + Lang/ArkScript/Fibonacci-sequence | 1 + Lang/ArkScript/FizzBuzz | 1 + Lang/ArkScript/Flatten-a-list | 1 + Lang/ArkScript/Function-definition | 1 + Lang/ArkScript/Hello-world-Line-printer | 1 + Lang/ArkScript/Hello-world-Newline-omission | 1 + Lang/ArkScript/Hello-world-Text | 1 + Lang/ArkScript/Infinity | 1 + Lang/ArkScript/Integer-sequence | 1 + Lang/ArkScript/Literals-Floating-point | 1 + Lang/ArkScript/Literals-Integer | 1 + Lang/ArkScript/Literals-String | 1 + Lang/ArkScript/Logical-operations | 1 + Lang/ArkScript/Munchausen-numbers | 1 + Lang/ArkScript/N-queens-problem | 1 + Lang/ArkScript/Null-object | 1 + Lang/ArkScript/Program-termination | 1 + Lang/ArkScript/Read-entire-file | 1 + Lang/ArkScript/Reverse-a-string | 1 + Lang/ArkScript/Semordnilap | 1 + Lang/ArkScript/Shell-one-liner | 1 + Lang/ArkScript/Short-circuit-evaluation | 1 + Lang/ArkScript/Show-ASCII-table | 1 + Lang/ArkScript/Sleep | 1 + Lang/ArkScript/Sorting-algorithms-Quicksort | 1 + Lang/ArkScript/String-append | 1 + Lang/ArkScript/String-case | 1 + Lang/ArkScript/String-concatenation | 1 + Lang/ArkScript/String-interpolation-included- | 1 + Lang/ArkScript/String-length | 1 + Lang/ArkScript/String-matching | 1 + Lang/ArkScript/String-prepend | 1 + Lang/ArkScript/Sum-and-product-of-an-array | 1 + Lang/ArkScript/Sum-digits-of-an-integer | 1 + Lang/ArkScript/Sum-of-a-series | 1 + Lang/ArkScript/Sum-of-squares | 1 + Lang/ArkScript/User-input-Text | 1 + Lang/ArkScript/Write-entire-file | 1 + Lang/AutoLISP/100-doors | 1 + Lang/AutoLISP/Babbage-problem | 1 + Lang/AutoLISP/Balanced-brackets | 1 + Lang/AutoLISP/Entropy | 1 + Lang/AutoLISP/Entropy-Narcissist | 1 + Lang/AutoLISP/Largest-proper-divisor-of-n | 1 + Lang/AutoLISP/The-Twelve-Days-of-Christmas | 1 + .../Arbitrary-precision-integers-included- | 1 + Lang/BBC-BASIC/Multi-dimensional-array | 1 + Lang/Ballerina/Comments | 1 + Lang/Bc/Anti-primes | 1 + Lang/Bc/Arithmetic-derivative | 1 + Lang/Bc/Department-numbers | 1 + Lang/Bc/Fairshare-between-two-and-more | 1 + Lang/Bc/Variables | 1 + Lang/Beeswax/00-LANG.txt | 2 +- Lang/C-sharp/Camel-case-and-snake-case | 1 + Lang/C-sharp/Cistercian-numerals | 1 + Lang/C-sharp/M-bius-function | 1 + Lang/C-sharp/Vogels-approximation-method | 1 + Lang/CBASIC/Factorial | 1 + Lang/CJam/00-LANG.txt | 8 + Lang/CJam/00-META.yaml | 2 + Lang/COBOL/Soloways-recurring-rainfall | 1 + Lang/Calcscript/00-LANG.txt | 10 + Lang/Calcscript/00-META.yaml | 2 + Lang/Common-Lisp/Wieferich-primes | 1 + Lang/Component-Pascal/100-doors | 1 - Lang/Computer-zero-Assembly/00-LANG.txt | 4 +- Lang/Convex/00-LANG.txt | 6 + Lang/Convex/00-META.yaml | 2 + Lang/Crystal/Department-numbers | 1 + Lang/Crystal/Parsing-RPN-calculator-algorithm | 1 + Lang/Crystal/Rot-13 | 1 + .../Singly-linked-list-Element-definition | 1 + .../Singly-linked-list-Element-insertion | 1 + Lang/Crystal/Soloways-recurring-rainfall | 1 + Lang/Crystal/String-interpolation-included- | 1 + Lang/Dart/AVL-tree | 1 + Lang/Dart/Boyer-Moore-string-search | 1 + Lang/Dart/Break-OO-privacy | 1 + Lang/Dart/Continued-fraction | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/Dart/Dijkstras-algorithm | 1 + Lang/Dart/Floyd-Warshall-algorithm | 1 + Lang/Dart/Parse-an-IP-Address | 1 + Lang/Dart/Tonelli-Shanks-algorithm | 1 + Lang/Draco/Anti-primes | 1 + Lang/DuckDB/00-LANG.txt | 4 + Lang/DuckDB/00-META.yaml | 2 + Lang/DuckDB/100-doors | 1 + Lang/DuckDB/99-bottles-of-beer | 1 + Lang/DuckDB/A+B | 1 + Lang/DuckDB/ABC-problem | 1 + Lang/DuckDB/Anagrams | 1 + Lang/DuckDB/Anonymous-recursion | 1 + Lang/DuckDB/Arithmetic-Complex | 1 + Lang/DuckDB/Arithmetic-Integer | 1 + Lang/DuckDB/Arithmetic-geometric-mean | 1 + Lang/DuckDB/Arithmetic-numbers | 1 + Lang/DuckDB/Array-concatenation | 1 + Lang/DuckDB/Array-length | 1 + Lang/DuckDB/Arrays | 1 + Lang/DuckDB/Associative-array-Creation | 1 + Lang/DuckDB/Associative-array-Iteration | 1 + Lang/DuckDB/Associative-array-Merging | 1 + Lang/DuckDB/Averages-Arithmetic-mean | 1 + Lang/DuckDB/Averages-Mean-angle | 1 + Lang/DuckDB/Averages-Mean-time-of-day | 1 + Lang/DuckDB/Averages-Mode | 1 + Lang/DuckDB/Averages-Pythagorean-means | 1 + Lang/DuckDB/Babbage-problem | 1 + Lang/DuckDB/Benfords-law | 1 + Lang/DuckDB/Bin-given-limits | 1 + Lang/DuckDB/Binary-digits | 1 + Lang/DuckDB/Bioinformatics-base-count | 1 + Lang/DuckDB/Bitwise-IO | 1 + Lang/DuckDB/Bitwise-operations | 1 + Lang/DuckDB/CSV-data-manipulation | 1 + Lang/DuckDB/Call-a-function | 1 + .../Cartesian-product-of-two-or-more-lists | 1 + Lang/DuckDB/Case-sensitivity-of-identifiers | 1 + Lang/DuckDB/Catalan-numbers | 1 + Lang/DuckDB/Catalan-numbers-Pascals-triangle | 1 + Lang/DuckDB/Check-that-file-exists | 1 + Lang/DuckDB/Collections | 1 + Lang/DuckDB/Combinations | 1 + Lang/DuckDB/Combinations-with-repetitions | 1 + Lang/DuckDB/Compare-a-list-of-strings | 1 + Lang/DuckDB/Compare-length-of-two-strings | 1 + Lang/DuckDB/Compound-data-type | 1 + Lang/DuckDB/Conditional-structures | 1 + .../Convert-seconds-to-compound-duration | 1 + Lang/DuckDB/Copy-a-string | 1 + Lang/DuckDB/Count-occurrences-of-a-substring | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/DuckDB/Cumulative-standard-deviation | 1 + Lang/DuckDB/Currency | 1 + Lang/DuckDB/Day-of-the-week | 1 + Lang/DuckDB/Define-a-primitive-data-type | 1 + Lang/DuckDB/Detect-division-by-zero | 1 + Lang/DuckDB/Determinant-and-permanent | 1 + ...ne-if-a-string-has-all-the-same-characters | 1 + ...mine-if-a-string-has-all-unique-characters | 1 + .../Determine-if-a-string-is-collapsible | 1 + Lang/DuckDB/Determine-if-a-string-is-numeric | 1 + .../Determine-if-a-string-is-squeezable | 1 + Lang/DuckDB/Determine-sentence-type | 1 + Lang/DuckDB/Digital-root | 1 + Lang/DuckDB/Diversity-prediction-theorem | 1 + Lang/DuckDB/Documentation | 1 + Lang/DuckDB/Dot-product | 1 + Lang/DuckDB/Dynamic-variable-names | 1 + Lang/DuckDB/Element-wise-operations | 1 + Lang/DuckDB/Empty-string | 1 + Lang/DuckDB/Entropy | 1 + Lang/DuckDB/Enumerations | 1 + Lang/DuckDB/Equilibrium-index | 1 + Lang/DuckDB/Euler-method | 1 + Lang/DuckDB/Eulers-constant-0.5772... | 1 + Lang/DuckDB/Eulers-identity | 1 + Lang/DuckDB/Evaluate-binomial-coefficients | 1 + Lang/DuckDB/Even-or-odd | 1 + Lang/DuckDB/Exponentiation-order | 1 + Lang/DuckDB/Extreme-floating-point-values | 1 + Lang/DuckDB/Factorial | 1 + Lang/DuckDB/Factors-of-an-integer | 1 + Lang/DuckDB/Fairshare-between-two-and-more | 1 + Lang/DuckDB/Feigenbaum-constant-calculation | 1 + Lang/DuckDB/Fibonacci-sequence | 1 + Lang/DuckDB/File-input-output | 1 + Lang/DuckDB/Filter | 1 + Lang/DuckDB/Find-limit-of-recursion | 1 + .../DuckDB/Find-the-last-Sunday-of-each-month | 1 + Lang/DuckDB/Five-weekends | 1 + Lang/DuckDB/Fixed-length-records | 1 + Lang/DuckDB/Flatten-a-list | 1 + Lang/DuckDB/Formatted-numeric-output | 1 + Lang/DuckDB/Forward-difference | 1 + Lang/DuckDB/Function-definition | 1 + Lang/DuckDB/Gamma-function | 1 + Lang/DuckDB/Gapful-numbers | 1 + .../DuckDB/Generate-lower-case-ASCII-alphabet | 1 + Lang/DuckDB/Generic-swap | 1 + Lang/DuckDB/Golden-ratio-Convergence | 1 + Lang/DuckDB/Gotchas | 1 + Lang/DuckDB/Greatest-common-divisor | 1 + Lang/DuckDB/Greatest-element-of-a-list | 1 + Lang/DuckDB/Greatest-subsequential-sum | 1 + Lang/DuckDB/HTTP | 1 + Lang/DuckDB/HTTPS | 1 + Lang/DuckDB/HTTPS-Authenticated | 1 + Lang/DuckDB/Hailstone-sequence | 1 + Lang/DuckDB/Harmonic-series | 1 + Lang/DuckDB/Hash-from-two-arrays | 1 + Lang/DuckDB/Hash-join | 1 + Lang/DuckDB/Haversine-formula | 1 + Lang/DuckDB/Hello-world-Text | 1 + Lang/DuckDB/Here-document | 1 + Lang/DuckDB/ISBN13-check-digit | 1 + Lang/DuckDB/Identity-matrix | 1 + ...he-characters-that-can-be-used-for-symbols | 1 + ...ne-all-the-lowercase-and-uppercase-letters | 1 + Lang/DuckDB/Increment-a-numerical-string | 1 + Lang/DuckDB/Infinity | 1 + Lang/DuckDB/Integer-comparison | 1 + Lang/DuckDB/Introspection | 1 + Lang/DuckDB/Inverted-index | 1 + Lang/DuckDB/Inverted-syntax | 1 + Lang/DuckDB/JSON | 1 + Lang/DuckDB/Jaro-similarity | 1 + Lang/DuckDB/Knuth-shuffle | 1 + .../DuckDB/Largest-int-from-concatenated-ints | 1 + Lang/DuckDB/Last-Friday-of-each-month | 1 + Lang/DuckDB/Leap-year | 1 + Lang/DuckDB/Left-factorials | 1 + Lang/DuckDB/Leonardo-numbers | 1 + Lang/DuckDB/Letter-frequency | 1 + Lang/DuckDB/Levenshtein-distance | 1 + Lang/DuckDB/List-comprehensions | 1 + Lang/DuckDB/Literals-Integer | 1 + Lang/DuckDB/Logical-operations | 1 + Lang/DuckDB/Longest-increasing-subsequence | 1 + Lang/DuckDB/Loops-Break | 1 + Lang/DuckDB/Loops-Do-while | 1 + Lang/DuckDB/Loops-Downward-for | 1 + Lang/DuckDB/Loops-For | 1 + Lang/DuckDB/Loops-For-with-a-specified-step | 1 + ...oops-Increment-loop-index-within-loop-body | 1 + Lang/DuckDB/Loops-N-plus-one-half | 1 + Lang/DuckDB/Loops-Nested | 1 + Lang/DuckDB/Loops-While | 1 + Lang/DuckDB/Loops-With-multiple-ranges | 1 + Lang/DuckDB/Luhn-test-of-credit-card-numbers | 1 + Lang/DuckDB/MD5 | 1 + Lang/DuckDB/Map-range | 1 + Lang/DuckDB/Matrix-multiplication | 1 + Lang/DuckDB/Matrix-transposition | 1 + Lang/DuckDB/Merge-and-aggregate-datasets | 1 + Lang/DuckDB/Metallic-ratios | 1 + Lang/DuckDB/Middle-three-digits | 1 + Lang/DuckDB/Monte-Carlo-methods | 1 + Lang/DuckDB/Nested-function | 1 + Lang/DuckDB/Nth | 1 + Lang/DuckDB/Nth-root | 1 + Lang/DuckDB/One-of-n-lines-in-a-file | 1 + Lang/DuckDB/Order-two-numerical-lists | 1 + Lang/DuckDB/Ordered-words | 1 + Lang/DuckDB/Palindrome-detection | 1 + Lang/DuckDB/Parameterized-SQL-statement | 1 + Lang/DuckDB/Pascals-triangle | 1 + Lang/DuckDB/Permutations | 1 + Lang/DuckDB/Permutations-Derangements | 1 + Lang/DuckDB/Pick-random-element | 1 + Lang/DuckDB/Primality-by-trial-division | 1 + Lang/DuckDB/Prime-decomposition | 1 + Lang/DuckDB/Probabilistic-choice | 1 + Lang/DuckDB/Proper-divisors | 1 + ...Pseudo-random-numbers-Middle-square-method | 1 + Lang/DuckDB/Random-numbers | 1 + Lang/DuckDB/Range-expansion | 1 + Lang/DuckDB/Range-extraction | 1 + Lang/DuckDB/Read-a-file-line-by-line | 1 + Lang/DuckDB/Reflection-List-methods | 1 + Lang/DuckDB/Reflection-List-properties | 1 + Lang/DuckDB/Remove-duplicate-elements | 1 + Lang/DuckDB/Rep-string | 1 + Lang/DuckDB/Repeat-a-string | 1 + Lang/DuckDB/Return-multiple-values | 1 + Lang/DuckDB/Reverse-a-string | 1 + Lang/DuckDB/Roots-of-unity | 1 + Lang/DuckDB/Run-length-encoding | 1 + Lang/DuckDB/Search-a-list-of-records | 1 + Lang/DuckDB/Set | 1 + Lang/DuckDB/Set-consolidation | 1 + Lang/DuckDB/Show-the-epoch | 1 + Lang/DuckDB/Sieve-of-Eratosthenes | 1 + .../Sort-an-array-of-composite-structures | 1 + Lang/DuckDB/Sort-numbers-lexicographically | 1 + Lang/DuckDB/Statistics-Basic | 1 + Lang/DuckDB/String-append | 1 + Lang/DuckDB/String-case | 1 + Lang/DuckDB/String-comparison | 1 + Lang/DuckDB/String-interpolation-included- | 1 + Lang/DuckDB/String-length | 1 + Lang/DuckDB/String-matching | 1 + Lang/DuckDB/String-prepend | 1 + .../Strip-a-set-of-characters-from-a-string | 1 + Lang/DuckDB/Strip-comments-from-a-string | 1 + ...odes-and-extended-characters-from-a-string | 1 + ...trip-whitespace-from-a-string-Top-and-tail | 1 + Lang/DuckDB/Substring | 1 + Lang/DuckDB/Sudoku | 1 + Lang/DuckDB/Sum-and-product-of-an-array | 1 + Lang/DuckDB/Sum-digits-of-an-integer | 1 + Lang/DuckDB/Sum-multiples-of-3-and-5 | 1 + Lang/DuckDB/Sum-of-a-series | 1 + Lang/DuckDB/Sum-of-squares | 1 + Lang/DuckDB/Symmetric-difference | 1 + Lang/DuckDB/Table-creation-Postal-addresses | 1 + Lang/DuckDB/Test-integerness | 1 + Lang/DuckDB/Text-processing-2 | 1 + Lang/DuckDB/Thue-Morse | 1 + Lang/DuckDB/Time-a-function | 1 + Lang/DuckDB/Tokenize-a-string | 1 + Lang/DuckDB/Top-rank-per-group | 1 + Lang/DuckDB/Trigonometric-functions | 1 + Lang/DuckDB/URL-decoding | 1 + Lang/DuckDB/UTF-8-encode-and-decode | 1 + Lang/DuckDB/Unix-ls | 1 + Lang/DuckDB/Variable-size-Get | 1 + Lang/DuckDB/Variable-size-Set | 1 + Lang/DuckDB/Vector-products | 1 + Lang/DuckDB/Zero-to-the-zero-power | 1 + Lang/DuckDB/Zig-zag-matrix | 1 + Lang/EasyLang/AKS-test-for-primes | 1 + .../EasyLang/Bitmap-Midpoint-circle-algorithm | 1 + Lang/EasyLang/Cholesky-decomposition | 1 + Lang/EasyLang/Currency | 1 + Lang/EasyLang/Death-Star | 1 + ...stribution-of-0-digits-in-factorial-series | 1 + Lang/EasyLang/Draw-a-sphere | 1 + Lang/EasyLang/EKG-sequence-convergence | 1 + .../Earliest-difference-between-prime-gaps | 1 + ...mentary-cellular-automaton-Infinite-length | 1 + .../Erd-s-Selfridge-categorization-of-primes | 1 + Lang/EasyLang/Faulhabers-formula | 1 + Lang/EasyLang/Faulhabers-triangle | 1 + Lang/EasyLang/Fibonacci-word-fractal | 1 + ...Find-Chess960-starting-position-identifier | 1 + Lang/EasyLang/Fraction-reduction | 1 + Lang/EasyLang/French-Republican-calendar | 1 + Lang/EasyLang/Function-prototype | 1 + Lang/EasyLang/Hash-from-two-arrays | 1 + Lang/EasyLang/Honeycombs | 1 + Lang/EasyLang/Hunt-the-Wumpus | 1 + Lang/EasyLang/Jacobsthal-numbers | 1 + Lang/EasyLang/Pascals-triangle-Puzzle | 1 + Lang/EasyLang/Straddling-checkerboard | 1 + Lang/EasyLang/Unicode-strings | 1 + Lang/Eiffel/Loops-For | 1 + Lang/Eiffel/Loops-Infinite | 1 + Lang/Elixir/Determinant-and-permanent | 1 + Lang/Elixir/K-d-tree | 1 + Lang/Elixir/Parse-an-IP-Address | 1 + Lang/Erlang/Determinant-and-permanent | 1 + Lang/Erlang/Floyd-Warshall-algorithm | 1 + Lang/Excel/Jacobi-symbol | 1 + Lang/Extended-Color-BASIC/00-LANG.txt | 7 + Lang/Extended-Color-BASIC/00-META.yaml | 2 + Lang/Extended-Color-BASIC/Arrays | 1 + Lang/Extended-Color-BASIC/Copy-a-string | 1 + Lang/Extended-Color-BASIC/Hello-world-Text | 1 + Lang/Extended-Color-BASIC/Loops-For | 1 + Lang/Extended-Color-BASIC/Quine | 1 + Lang/Extended-Color-BASIC/User-input-Text | 1 + Lang/F-Sharp/Long-multiplication | 1 - Lang/F-Sharp/Multiplicative-order | 1 + Lang/Factor/Best-shuffle | 1 + Lang/Fennel/00-LANG.txt | 7 +- ...ficient-and-perfect-number-classifications | 1 + Lang/Fennel/Factorial | 1 + Lang/Fennel/Factorial-primes | 1 + Lang/Fennel/Goldbachs-comet | 1 + .../Horners-rule-for-polynomial-evaluation | 1 + Lang/Fennel/Jacobsthal-numbers | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + Lang/Fennel/Time-a-function | 1 + Lang/Fennel/Yellowstone-sequence | 1 + Lang/Fortran/Associative-array-Merging | 1 + Lang/Fortran/Catalan-numbers-Pascals-triangle | 1 + Lang/Fortran/Chinese-zodiac | 1 + Lang/Fortran/Cyclotomic-polynomial | 1 + Lang/Fortran/Disarium-numbers | 1 + Lang/Fortran/Display-a-linear-combination | 1 + Lang/Fortran/EKG-sequence-convergence | 1 + Lang/Fortran/Egyptian-division | 1 + Lang/Fortran/French-Republican-calendar | 1 + .../Hofstadter-Figure-Figure-sequences | 1 + Lang/Fortran/Humble-numbers | 1 + Lang/Fortran/Jewels-and-stones | 1 + Lang/Fortran/Knapsack-problem-Bounded | 1 + Lang/Fortran/Knuths-power-tree | 1 + Lang/Fortran/McNuggets-problem | 1 + Lang/Fortran/Parse-an-IP-Address | 1 + Lang/Fortran/Pascals-triangle-Puzzle | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + Lang/Fortran/Totient-function | 1 + Lang/Fortran/Twos-complement | 1 + Lang/Free-Pascal-Lazarus/Abstract-type | 1 + Lang/Free-Pascal-Lazarus/Cistercian-numerals | 1 + Lang/Free-Pascal-Lazarus/Pancake-numbers | 1 + Lang/FreeBASIC/Babylonian-spiral | 1 + .../FreeBASIC/Bitcoin-public-point-to-address | 1 + .../Catmull-Clark-subdivision-surface | 1 + Lang/FreeBASIC/Color-quantization | 1 + Lang/FreeBASIC/Dominoes | 1 + Lang/FreeBASIC/Find-duplicate-files | 1 + ...est-left-truncatable-prime-in-a-given-base | 1 + ...rate-English-text-using-the-Greek-alphabet | 1 + Lang/Frink/Disarium-numbers | 1 + Lang/Frink/Happy-numbers | 1 + Lang/FuncSug/00-LANG.txt | 1 + Lang/FuncSug/00-META.yaml | 2 + Lang/FuncSug/GUI-component-interaction | 1 + .../GUI-enabling-disabling-of-controls | 1 + Lang/FuncSug/Hello-world-Text | 1 + Lang/FuncSug/Play-recorded-sounds | 1 + Lang/FuncSug/Simple-windowed-application | 1 + Lang/FuncSug/Simulate-input-Mouse | 1 + Lang/FuncSug/User-input-Graphical | 1 + Lang/FutureBasic/Arithmetic-Complex | 1 + Lang/FutureBasic/Averages-Mean-time-of-day | 1 + Lang/FutureBasic/Boyer-Moore-string-search | 1 + Lang/FutureBasic/CRC-32 | 1 + .../Carmichael-3-strong-pseudoprimes | 1 + Lang/FutureBasic/Deal-cards-for-FreeCell | 1 + Lang/FutureBasic/Demings-funnel | 1 + Lang/FutureBasic/Euler-method | 1 + Lang/FutureBasic/Find-limit-of-recursion | 1 + Lang/FutureBasic/Five-weekends | 1 + Lang/FutureBasic/Gamma-function | 1 + Lang/FutureBasic/Gaussian-elimination | 1 + .../Guess-the-number-With-feedback-player- | 1 + Lang/FutureBasic/Hamming-numbers | 1 + Lang/FutureBasic/Last-letter-first-letter | 1 + Lang/FutureBasic/Mayan-numerals | 1 + Lang/FutureBasic/Modular-inverse | 1 + Lang/FutureBasic/Monte-Carlo-methods | 1 + Lang/FutureBasic/Mutex | 1 + Lang/FutureBasic/Named-parameters | 1 + Lang/FutureBasic/Perfect-shuffle | 1 + Lang/FutureBasic/Sierpinski-pentagon | 1 + Lang/FutureBasic/Sleep | 1 + .../Sorting-algorithms-Insertion-sort | 1 + .../FutureBasic/Sorting-algorithms-Sleep-sort | 1 + Lang/FutureBasic/Stack-traces | 1 + Lang/FutureBasic/String-length | 1 + Lang/FutureBasic/Sum-of-a-series | 1 + Lang/FutureBasic/Sum-to-100 | 1 + Lang/FutureBasic/Tau-function | 1 + Lang/FutureBasic/Tau-number | 1 + Lang/FutureBasic/Word-wrap | 1 + Lang/FutureBasic/Yellowstone-sequence | 1 + Lang/FutureBasic/Zebra-puzzle | 1 + Lang/GW-BASIC/Old-Russian-measure-of-length | 1 + Lang/Go/Distance-and-Bearing | 1 + Lang/Goboscript/00-LANG.txt | 1 + Lang/Goboscript/00-META.yaml | 2 + Lang/Haskell/00-LANG.txt | 4 +- Lang/Haxe/Abstract-type | 1 + Lang/Haxe/Apply-a-callback-to-an-array | 1 + Lang/Haxe/Arrays | 1 + Lang/Haxe/Associative-array-Creation | 1 + Lang/Haxe/Associative-array-Iteration | 1 + Lang/Haxe/Binary-digits | 1 + Lang/Haxe/Boolean-values | 1 + Lang/Haxe/Call-an-object-method | 1 + Lang/Haxe/Character-codes | 1 + Lang/Haxe/Classes | 1 + Lang/Icon/00-LANG.txt | 6 +- Lang/Icon/Exponentiation-order | 1 + Lang/Icon/Jewels-and-stones | 1 + Lang/Icon/Loops-Wrong-ranges | 1 + Lang/Icon/Search-a-list-of-records | 1 + Lang/Icon/Sort-numbers-lexicographically | 1 + Lang/Icon/Tokenize-a-string-with-escaping | 1 + Lang/Icon/Tree-from-nesting-levels | 1 + Lang/Idris/Comments | 1 + Lang/Insitux/00-LANG.txt | 6 +- Lang/Janet/Comments | 1 + .../Aliquot-sequence-classifications | 1 + Lang/JavaScript/B-zier-curves-Intersections | 1 + Lang/JavaScript/Balanced-ternary | 1 + .../Bitcoin-public-point-to-address | 1 + Lang/JavaScript/Break-OO-privacy | 1 + .../Catmull-Clark-subdivision-surface | 1 + Lang/JavaScript/Checkpoint-synchronization | 1 + Lang/JavaScript/Continued-fraction | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/JavaScript/Deconvolution-1D | 1 + Lang/JavaScript/Deconvolution-2D+ | 1 + Lang/JavaScript/MD5 | 1 + Lang/JavaScript/Meissel-Mertens-constant | 1 + Lang/JavaScript/Parse-an-IP-Address | 1 + Lang/JavaScript/Pascals-triangle-Puzzle | 1 + Lang/JavaScript/Sokoban | 1 + Lang/JavaScript/Solve-a-Hopido-puzzle | 1 + Lang/JavaScript/Superpermutation-minimisation | 1 + Lang/JavaScript/Tarjan | 1 + Lang/Julia/OLE-automation | 1 + Lang/Julia/Simulate-input-Keyboard | 1 + .../Use-another-language-to-call-a-function | 1 + Lang/Kantalo/00-LANG.txt | 40 ++ Lang/Kantalo/00-META.yaml | 2 + Lang/Koka/00-LANG.txt | 2 +- Lang/Koka/A+B | 1 + Lang/Koka/Extend-your-language | 1 + Lang/Koka/Jump-anywhere | 1 + Lang/Koka/Letter-frequency | 1 + Lang/Koka/Loops-Break | 1 + Lang/Koka/Monads-Writer-monad | 1 + Lang/Kotlin/Boyer-Moore-string-search | 1 + Lang/Labyrinth/00-LANG.txt | 1 + Lang/Labyrinth/00-META.yaml | 2 + Lang/Liberty-BASIC/Hunt-the-Wumpus | 1 + Lang/Liberty-BASIC/Minesweeper-game | 1 + Lang/Liberty-BASIC/Snake | 1 + Lang/Logo/Sparkline-in-unicode | 1 + Lang/Lua/100-doors | 1 - Lang/Lua/Jacobsthal-numbers | 1 + Lang/Lua/Knapsack-problem-Bounded | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + .../Use-another-language-to-call-a-function | 1 + Lang/Lua/Wagstaff-primes | 1 + Lang/Lua/Wieferich-primes | 1 + Lang/Mathematica/ASCII-art-diagram-converter | 1 + Lang/Mathematica/Camel-case-and-snake-case | 1 + Lang/Mathematica/Erd-s-Nicolas-numbers | 1 + Lang/Mathematica/Parse-an-IP-Address | 1 + Lang/Mathematica/Tonelli-Shanks-algorithm | 1 + Lang/Mathematica/Vogels-approximation-method | 1 + Lang/Maxima/Array-length | 1 + Lang/Maxima/Delete-a-file | 1 + Lang/Maxima/Hash-from-two-arrays | 1 + Lang/Maxima/Real-constants-and-functions | 1 + Lang/Maxima/Regular-expressions | 1 + Lang/Maxima/Rename-a-file | 1 + Lang/Maxima/Sorting-algorithms-Stooge-sort | 1 + Lang/Maxima/Statistics-Basic | 1 + Lang/Maxima/Substring-Top-and-tail | 1 + Lang/Maxima/Superellipse | 1 + Lang/Maxima/Topic-variable | 1 + Lang/Maxima/Towers-of-Hanoi | 1 + Lang/Mn/00-LANG.txt | 7 + Lang/Mn/00-META.yaml | 2 + Lang/Mn/Factorial | 1 + Lang/Mn/Loops-While | 1 + Lang/Modula-2/AKS-test-for-primes | 1 + Lang/Modula-2/Cistercian-numerals | 1 + Lang/Mojo/Hunt-the-Wumpus | 1 + .../Old-Russian-measure-of-length | 1 + Lang/Nom/00-LANG.txt | 18 + Lang/Nom/00-META.yaml | 2 + Lang/Nom/Balanced-brackets | 1 + Lang/Nom/CSV-to-HTML-translation | 1 + Lang/Nom/Determine-if-a-string-is-numeric | 1 + Lang/Nom/Empty-string | 1 + Lang/Nom/Even-or-odd | 1 + Lang/Nom/Hello-world-Text | 1 + Lang/Nom/Input-loop | 1 + Lang/Nom/Odd-word-problem | 1 + Lang/Nom/Reverse-a-string | 1 + Lang/OCaml/Parse-an-IP-Address | 1 + Lang/OCaml/Sorting-algorithms-Sleep-sort | 1 + Lang/Objeck/Catalan-numbers-Pascals-triangle | 1 + Lang/Objeck/Disarium-numbers | 1 + Lang/Objeck/HTTPS-Client-authenticated | 1 + .../Objeck/Magic-squares-of-doubly-even-order | 1 + Lang/Objeck/Matrix-multiplication | 1 + .../Object-Pascal-Implementations/00-LANG.txt | 3 + .../00-META.yaml | 2 + Lang/Odin/Comments | 1 + Lang/OoRexx/Prime-decomposition | 1 + Lang/OxygenBasic/Josephus-problem | 1 + Lang/PARI-GP/Pell-numbers | 1 + Lang/PARI-GP/Tonelli-Shanks-algorithm | 1 + Lang/PHP/AKS-test-for-primes | 1 + Lang/PL-M/100-doors | 1 - Lang/Pascal-P/00-LANG.txt | 23 + Lang/Pascal-P/00-META.yaml | 2 + Lang/Pascal-P/Cistercian-numerals | 1 + Lang/Pascal-P/FizzBuzz | 1 + Lang/Pascal-P/Leonardo-numbers | 1 + Lang/Pascal-P/Levenshtein-distance | 1 + Lang/Pascal-P/M-bius-function | 1 + Lang/Pascal-P/Magic-constant | 1 + Lang/Pascal-P/Map-range | 1 + .../Ramer-Douglas-Peucker-line-simplification | 1 + Lang/PascalABC.NET/15-puzzle-solver | 1 + Lang/PascalABC.NET/Abbreviations-easy | 1 + Lang/PascalABC.NET/Abbreviations-simple | 1 + Lang/PascalABC.NET/Arithmetic-evaluation | 1 + Lang/PascalABC.NET/Bioinformatics-base-count | 1 + .../Case-sensitivity-of-identifiers | 1 + .../Combinations-with-repetitions | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/Pico-8/00-LANG.txt | 1 + Lang/Pico-8/00-META.yaml | 2 + Lang/Pico-8/Hello-world-Text | 1 + Lang/Pluto/00-LANG.txt | 41 ++ Lang/Pluto/00-META.yaml | 2 + Lang/Pluto/99-bottles-of-beer | 1 + Lang/Pluto/A+B | 1 + Lang/Pluto/ABC-problem | 1 + Lang/Pluto/AKS-test-for-primes | 1 + Lang/Pluto/Abelian-sandpile-model | 1 + Lang/Pluto/Abelian-sandpile-model-Identity | 1 + Lang/Pluto/Abstract-type | 1 + ...ficient-and-perfect-number-classifications | 1 + Lang/Pluto/Abundant-odd-numbers | 1 + Lang/Pluto/Achilles-numbers | 1 + Lang/Pluto/Ackermann-function | 1 + Lang/Pluto/Address-of-a-variable | 1 + Lang/Pluto/Almost-prime | 1 + Lang/Pluto/Anti-primes | 1 + Lang/Pluto/Approximate-equality | 1 + .../Arbitrary-precision-integers-included- | 1 + Lang/Pluto/Arithmetic-Complex | 1 + Lang/Pluto/Arithmetic-Integer | 1 + Lang/Pluto/Arithmetic-Rational | 1 + Lang/Pluto/Arithmetic-derivative | 1 + Lang/Pluto/Arithmetic-geometric-mean | 1 + Lang/Pluto/Array-concatenation | 1 + Lang/Pluto/Arrays | 1 + Lang/Pluto/Ascending-primes | 1 + Lang/Pluto/Associative-array-Creation | 1 + Lang/Pluto/Associative-array-Iteration | 1 + Lang/Pluto/Associative-array-Merging | 1 + Lang/Pluto/Attractive-numbers | 1 + Lang/Pluto/Averages-Arithmetic-mean | 1 + Lang/Pluto/Averages-Median | 1 + Lang/Pluto/Averages-Pythagorean-means | 1 + Lang/Pluto/Averages-Root-mean-square | 1 + Lang/Pluto/Balanced-brackets | 1 + Lang/Pluto/Base64-decode-data | 1 + Lang/Pluto/Bell-numbers | 1 + Lang/Pluto/Bitmap | 1 + Lang/Pluto/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Pluto/Bitmap-Midpoint-circle-algorithm | 1 + Lang/Pluto/Bitwise-operations | 1 + Lang/Pluto/CRC-32 | 1 + Lang/Pluto/Caesar-cipher | 1 + Lang/Pluto/Calkin-Wilf-sequence | 1 + Lang/Pluto/Call-a-foreign-language-function | 1 + .../Pluto/Call-a-function-in-a-shared-library | 1 + Lang/Pluto/Case-sensitivity-of-identifiers | 1 + Lang/Pluto/Casting-out-nines | 1 + Lang/Pluto/Collections | 1 + Lang/Pluto/Combinations | 1 + Lang/Pluto/Combinations-with-repetitions | 1 + Lang/Pluto/Command-line-arguments | 1 + Lang/Pluto/Comments | 1 + Lang/Pluto/Compare-length-of-two-strings | 1 + Lang/Pluto/Compiler-lexical-analyzer | 1 + Lang/Pluto/Conditional-structures | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + Lang/Pluto/Convert-decimal-number-to-rational | 1 + Lang/Pluto/Count-in-octal | 1 + Lang/Pluto/Count-the-coins | 1 + Lang/Pluto/Create-a-file | 1 + Lang/Pluto/Currying | 1 + Lang/Pluto/Delete-a-file | 1 + Lang/Pluto/Descending-primes | 1 + Lang/Pluto/Determine-if-a-string-is-numeric | 1 + Lang/Pluto/Disarium-numbers | 1 + Lang/Pluto/Display-a-linear-combination | 1 + ...stribution-of-0-digits-in-factorial-series | 1 + Lang/Pluto/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + Lang/Pluto/Doubly-linked-list-Traversal | 1 + Lang/Pluto/Dutch-national-flag-problem | 1 + Lang/Pluto/Euler-method | 1 + Lang/Pluto/Eulers-identity | 1 + Lang/Pluto/Even-or-odd | 1 + Lang/Pluto/Execute-a-system-command | 1 + Lang/Pluto/Factorial | 1 + Lang/Pluto/Factorial-primes | 1 + Lang/Pluto/Factorions | 1 + Lang/Pluto/Factors-of-an-integer | 1 + Lang/Pluto/Farey-sequence | 1 + Lang/Pluto/Feigenbaum-constant-calculation | 1 + Lang/Pluto/Fibonacci-sequence | 1 + Lang/Pluto/Filter | 1 + Lang/Pluto/FizzBuzz | 1 + Lang/Pluto/Floyd-Warshall-algorithm | 1 + Lang/Pluto/Formatted-numeric-output | 1 + Lang/Pluto/Function-definition | 1 + Lang/Pluto/Gamma-function | 1 + Lang/Pluto/Generate-lower-case-ASCII-alphabet | 1 + Lang/Pluto/Giuga-numbers | 1 + Lang/Pluto/Goldbachs-comet | 1 + Lang/Pluto/Greatest-common-divisor | 1 + Lang/Pluto/Greatest-element-of-a-list | 1 + Lang/Pluto/Hailstone-sequence | 1 + Lang/Pluto/Halt-and-catch-fire | 1 + Lang/Pluto/Hash-from-two-arrays | 1 + Lang/Pluto/Hello-world-Newline-omission | 1 + Lang/Pluto/Hello-world-Standard-error | 1 + Lang/Pluto/Hello-world-Text | 1 + Lang/Pluto/Higher-order-functions | 1 + .../Horners-rule-for-polynomial-evaluation | 1 + Lang/Pluto/Humble-numbers | 1 + Lang/Pluto/Increment-a-numerical-string | 1 + Lang/Pluto/Infinity | 1 + Lang/Pluto/JSON | 1 + Lang/Pluto/Jacobsthal-numbers | 1 + Lang/Pluto/Jewels-and-stones | 1 + Lang/Pluto/Josephus-problem | 1 + Lang/Pluto/Kaprekar-numbers | 1 + Lang/Pluto/Leap-year | 1 + Lang/Pluto/Literals-Floating-point | 1 + Lang/Pluto/Literals-Integer | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + Lang/Pluto/Loops-Break | 1 + Lang/Pluto/Loops-Continue | 1 + Lang/Pluto/Loops-Do-while | 1 + Lang/Pluto/Loops-Downward-for | 1 + Lang/Pluto/Loops-For | 1 + Lang/Pluto/Loops-For-with-a-specified-step | 1 + Lang/Pluto/Loops-Foreach | 1 + ...oops-Increment-loop-index-within-loop-body | 1 + Lang/Pluto/Loops-Infinite | 1 + Lang/Pluto/Loops-N-plus-one-half | 1 + Lang/Pluto/Loops-Nested | 1 + Lang/Pluto/Loops-While | 1 + Lang/Pluto/Loops-With-multiple-ranges | 1 + Lang/Pluto/Loops-Wrong-ranges | 1 + Lang/Pluto/Luhn-test-of-credit-card-numbers | 1 + Lang/Pluto/M-bius-function | 1 + Lang/Pluto/Machine-code | 1 + Lang/Pluto/Magic-squares-of-doubly-even-order | 1 + Lang/Pluto/Magic-squares-of-odd-order | 1 + Lang/Pluto/Magic-squares-of-singly-even-order | 1 + Lang/Pluto/Mian-Chowla-sequence | 1 + Lang/Pluto/Modular-inverse | 1 + Lang/Pluto/Multiplication-tables | 1 + Lang/Pluto/Mutual-recursion | 1 + Lang/Pluto/Named-parameters | 1 + Lang/Pluto/Narcissistic-decimal-number | 1 + Lang/Pluto/Nested-templated-data | 1 + Lang/Pluto/Non-decimal-radices-Convert | 1 + Lang/Pluto/Numerical-integration | 1 + Lang/Pluto/Old-Russian-measure-of-length | 1 + Lang/Pluto/Order-by-pair-comparisons | 1 + Lang/Pluto/Palindrome-detection | 1 + Lang/Pluto/Pancake-numbers | 1 + Lang/Pluto/Parsing-RPN-calculator-algorithm | 1 + Lang/Pluto/Pascals-triangle-Puzzle | 1 + Lang/Pluto/Perfect-shuffle | 1 + Lang/Pluto/Permutations | 1 + Lang/Pluto/Pernicious-numbers | 1 + Lang/Pluto/Pick-random-element | 1 + Lang/Pluto/Pisano-period | 1 + Lang/Pluto/Power-set | 1 + Lang/Pluto/Primality-by-trial-division | 1 + Lang/Pluto/Priority-queue | 1 + Lang/Pluto/Read-a-file-line-by-line | 1 + Lang/Pluto/Rename-a-file | 1 + Lang/Pluto/Repeat-a-string | 1 + Lang/Pluto/Reverse-a-string | 1 + Lang/Pluto/Reverse-words-in-a-string | 1 + Lang/Pluto/Roman-numerals-Encode | 1 + Lang/Pluto/Roots-of-a-quadratic-function | 1 + Lang/Pluto/Roots-of-unity | 1 + Lang/Pluto/Rot-13 | 1 + Lang/Pluto/Runge-Kutta-method | 1 + Lang/Pluto/Self-numbers | 1 + Lang/Pluto/Semordnilap | 1 + .../Sequence-of-primes-by-trial-division | 1 + Lang/Pluto/Set | 1 + Lang/Pluto/Set-consolidation | 1 + .../Singly-linked-list-Element-definition | 1 + .../Singly-linked-list-Element-insertion | 1 + Lang/Pluto/Singly-linked-list-Traversal | 1 + Lang/Pluto/Sleep | 1 + Lang/Pluto/Smarandache-prime-digital-sequence | 1 + Lang/Pluto/Soloways-recurring-rainfall | 1 + Lang/Pluto/Sort-an-integer-array | 1 + Lang/Pluto/Stack | 1 + Lang/Pluto/String-interpolation-included- | 1 + Lang/Pluto/String-length | 1 + Lang/Pluto/Sum-digits-of-an-integer | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + Lang/Pluto/Symmetric-difference | 1 + Lang/Pluto/System-time | 1 + Lang/Pluto/Tau-function | 1 + Lang/Pluto/Tau-number | 1 + Lang/Pluto/Terminal-control-Clear-the-screen | 1 + Lang/Pluto/Terminal-control-Coloured-text | 1 + Lang/Pluto/Terminal-control-Cursor-movement | 1 + .../Pluto/Terminal-control-Cursor-positioning | 1 + Lang/Pluto/Terminal-control-Dimensions | 1 + ...inal-control-Display-an-extended-character | 1 + Lang/Pluto/Terminal-control-Hiding-the-cursor | 1 + Lang/Pluto/Terminal-control-Inverse-video | 1 + Lang/Pluto/Terminal-control-Preserve-screen | 1 + ...Terminal-control-Ringing-the-terminal-bell | 1 + Lang/Pluto/Terminal-control-Unicode-output | 1 + Lang/Pluto/Test-integerness | 1 + Lang/Pluto/Time-a-function | 1 + Lang/Pluto/Total-circles-area | 1 + Lang/Pluto/Totient-function | 1 + Lang/Pluto/Towers-of-Hanoi | 1 + Lang/Pluto/Trabb-Pardo-Knuth-algorithm | 1 + Lang/Pluto/UPC | 1 + Lang/Pluto/Unicode-strings | 1 + Lang/Pluto/Unprimeable-numbers | 1 + Lang/Pluto/User-input-Text | 1 + Lang/Pluto/Van-Eck-sequence | 1 + Lang/Pluto/Van-der-Corput-sequence | 1 + Lang/Pluto/Variadic-function | 1 + Lang/Pluto/Vector | 1 + Lang/Pluto/Vector-products | 1 + Lang/Pluto/Wagstaff-primes | 1 + Lang/Pluto/Wieferich-primes | 1 + Lang/Pluto/Y-combinator | 1 + Lang/Pluto/Yellowstone-sequence | 1 + Lang/Pluto/Zebra-puzzle | 1 + Lang/Pluto/Zero-to-the-zero-power | 1 + Lang/PowerShell/AKS-test-for-primes | 1 + Lang/PowerShell/M-bius-function | 1 + Lang/Prolog/100-prisoners | 1 + Lang/Prolog/Boolean-values | 1 + Lang/Prolog/Damm-algorithm | 1 + Lang/Prolog/Hello-world-Newline-omission | 1 + Lang/Prolog/ISBN13-check-digit | 1 + Lang/Prolog/Integer-comparison | 1 + Lang/Prolog/Iterated-digits-squaring | 1 + Lang/Prolog/Josephus-problem | 1 + Lang/Prolog/Magic-8-ball | 1 + Lang/Prolog/Old-Russian-measure-of-length | 1 + Lang/Prolog/Order-by-pair-comparisons | 1 + Lang/Prolog/Phrase-reversals | 1 + Lang/Prolog/Population-count | 1 + Lang/Prolog/RPG-attributes-generator | 1 + Lang/Prolog/SEDOLs | 1 + Lang/Prolog/Semordnilap | 1 + Lang/Prolog/Sort-three-variables | 1 + Lang/Prolog/Stem-and-leaf-plot | 1 + Lang/Prolog/String-concatenation | 1 + Lang/Prolog/Thue-Morse | 1 + Lang/Prolog/Topswops | 1 + Lang/Prolog/Trabb-Pardo-Knuth-algorithm | 1 + Lang/Prolog/Wireworld | 1 + Lang/Prolog/Zero-to-the-zero-power | 1 + Lang/Python/Ruth-Aaron-numbers | 1 + Lang/QB64/Trabb-Pardo-Knuth-algorithm | 1 + ...les-geometric-normalization-and-conversion | 1 + Lang/R/CUSIP | 1 + Lang/R/Continued-fraction | 1 + Lang/R/Cramers-rule | 1 + Lang/R/Curzon-numbers | 1 + Lang/R/Dijkstras-algorithm | 1 + Lang/R/Execute-HQ9+ | 1 + Lang/R/Factorial-primes | 1 + Lang/R/Fibonacci-n-step-number-sequences | 1 + Lang/R/Flipping-bits-game | 1 + Lang/R/Floyd-Warshall-algorithm | 1 + Lang/R/Fractran | 1 + Lang/R/Giuga-numbers | 1 + .../R/Greedy-algorithm-for-Egyptian-fractions | 1 + Lang/R/Humble-numbers | 1 + Lang/R/M-bius-function | 1 + Lang/R/Parse-an-IP-Address | 1 + Lang/R/Rename-a-file | 1 + Lang/R/Repunit-primes | 1 + Lang/R/Retrieve-and-search-chat-history | 1 + Lang/R/Shoelace-formula-for-polygonal-area | 1 + Lang/R/Soloways-recurring-rainfall | 1 + ...racter-string-based-on-change-of-character | 1 + Lang/R/String-interpolation-included- | 1 + Lang/R/String-matching | 1 + Lang/R/Substring-Top-and-tail | 1 + Lang/R/The-Name-Game | 1 + Lang/R/Tonelli-Shanks-algorithm | 1 + Lang/R/Wieferich-primes | 1 + Lang/R/Write-entire-file | 1 + Lang/REBOL/00-LANG.txt | 4 +- Lang/REBOL/9-billion-names-of-God-the-integer | 1 + Lang/REBOL/Ackermann-function | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + ...oops-Increment-loop-index-within-loop-body | 1 + Lang/REBOL/Loops-With-multiple-ranges | 1 + Lang/REBOL/Loops-Wrong-ranges | 1 + Lang/REBOL/Object-serialization | 1 + Lang/REBOL/Polyspiral | 1 + Lang/REBOL/SHA-1 | 1 + Lang/REBOL/SHA-256 | 1 + Lang/REBOL/Semordnilap | 1 + Lang/RISC-V-Assembly/00-LANG.txt | 72 +++ Lang/RISC-V-Assembly/Address-of-a-variable | 1 + Lang/RISC-V-Assembly/Arithmetic-Integer | 1 + Lang/RISC-V-Assembly/Binary-digits | 1 + Lang/RISC-V-Assembly/Hello-world-Newbie | 1 + Lang/RISC-V-Assembly/Include-a-file | 1 + Lang/Raku/Play-recorded-sounds | 1 + Lang/Red/Address-of-a-variable | 1 + Lang/Red/Arithmetic-Integer | 1 + Lang/Red/Arithmetic-evaluation | 1 + Lang/Red/Calendar | 1 + Lang/Red/Calendar---for-REAL-programmers | 1 + Lang/Red/Currying | 1 + Lang/Red/Five-weekends | 1 + Lang/Red/Logical-operations | 1 + Lang/Red/Parsing-RPN-calculator-algorithm | 1 + Lang/Red/Parsing-RPN-to-infix-conversion | 1 + Lang/Red/Parsing-Shunting-yard-algorithm | 1 + Lang/Red/Towers-of-Hanoi | 1 + Lang/Refal/Tokenize-a-string | 1 + Lang/Rhombus/00-LANG.txt | 5 + Lang/Rhombus/00-META.yaml | 2 + Lang/Rhombus/99-bottles-of-beer | 1 + .../Arbitrary-precision-integers-included- | 1 + Lang/Rhombus/Caesar-cipher | 1 + Lang/Rhombus/Factorial | 1 + Lang/Rhombus/Fibonacci-sequence | 1 + Lang/Rhombus/FizzBuzz | 1 + Lang/Rhombus/Guess-the-number-With-feedback | 1 + Lang/Rhombus/Hello-world-Text | 1 + Lang/Rhombus/Inheritance-Single | 1 + Lang/Rhombus/Polymorphism | 1 + Lang/Rhombus/Rot-13 | 1 + Lang/Ring/Compare-a-list-of-strings | 1 + Lang/Ring/Wagstaff-primes | 1 + Lang/Run-BASIC/Josephus-problem | 1 + Lang/Rust/Break-OO-privacy | 1 + Lang/Rust/Camel-case-and-snake-case | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/Rust/Cyclops-numbers | 1 + Lang/Rust/Deconvolution-1D | 1 + Lang/Rust/Deconvolution-2D+ | 1 + Lang/Rust/Determine-if-two-triangles-overlap | 1 + Lang/Rust/Duffinian-numbers | 1 + Lang/Rust/Elliptic-curve-arithmetic | 1 + Lang/Rust/Faulhabers-triangle | 1 + Lang/Rust/Fractran | 1 + Lang/Rust/Humble-numbers | 1 + Lang/Rust/Knapsack-problem-Bounded | 1 + Lang/Rust/Mayan-calendar | 1 + Lang/Rust/Meissel-Mertens-constant | 1 + Lang/Rust/Modular-arithmetic | 1 + Lang/Rust/Multiple-regression | 1 + Lang/Rust/Ramanujan-primes-twins | 1 + Lang/Rust/Singleton | 1 + Lang/Rust/Sokoban | 1 + Lang/Rust/Substitution-cipher | 1 + Lang/Rust/Tree-datastructures | 1 + Lang/Rust/UPC | 1 + Lang/Rust/War-card-game | 1 + .../S-BASIC/Sorting-algorithms-Insertion-sort | 1 + Lang/SETL/Monte-Carlo-methods | 1 + Lang/SETL/Tokenize-a-string | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/Scala/Tonelli-Shanks-algorithm | 1 + Lang/Scala/UPC | 1 + Lang/Scheme/Own-digits-power-sum | 1 + Lang/Scheme/Pick-random-element | 1 + Lang/SequenceL/00-LANG.txt | 2 +- Lang/Swift/AVL-tree | 1 + Lang/Swift/Boyer-Moore-string-search | 1 + Lang/Swift/Chaocipher | 1 + ...ithmetic-G-matrix-ng-continued-fraction-n- | 1 + Lang/Swift/Floyd-Warshall-algorithm | 1 + Lang/Swift/K-d-tree | 1 + Lang/Swift/Parse-an-IP-Address | 1 + Lang/TAV/00-LANG.txt | 46 ++ Lang/TAV/00-META.yaml | 2 + Lang/TAV/A+B | 1 + Lang/TAV/Ackermann-function | 1 + Lang/TAV/Anagrams | 1 + Lang/TAV/Arithmetic-Integer | 1 + Lang/TAV/Array-concatenation | 1 + Lang/TAV/Array-length | 1 + Lang/TAV/Associative-array-Iteration | 1 + Lang/TAV/Averages-Root-mean-square | 1 + Lang/TAV/Character-codes | 1 + Lang/TAV/Command-line-arguments | 1 + Lang/TAV/Conditional-structures | 1 + Lang/TAV/Copy-a-string | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/TAV/Empty-string | 1 + Lang/TAV/Factorial | 1 + Lang/TAV/Fibonacci-sequence | 1 + Lang/TAV/Formatted-numeric-output | 1 + Lang/TAV/Greatest-element-of-a-list | 1 + Lang/TAV/Guess-the-number-With-feedback | 1 + Lang/TAV/HTTPS | 1 + Lang/TAV/Halt-and-catch-fire | 1 + Lang/TAV/Hello-world-Graphical | 1 + Lang/TAV/Hello-world-Text | 1 + Lang/TAV/Letter-frequency | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + Lang/TAV/Loops-Break | 1 + Lang/TAV/Loops-Do-while | 1 + Lang/TAV/Loops-Downward-for | 1 + Lang/TAV/Loops-For | 1 + Lang/TAV/Loops-Infinite | 1 + Lang/TAV/Loops-N-plus-one-half | 1 + Lang/TAV/Loops-While | 1 + Lang/TAV/Multiplication-tables | 1 + Lang/TAV/Ordered-words | 1 + Lang/TAV/Permutations | 1 + Lang/TAV/Real-constants-and-functions | 1 + Lang/TAV/Reverse-a-string | 1 + Lang/TAV/Semordnilap | 1 + Lang/TAV/Simple-windowed-application | 1 + Lang/TAV/Stack | 1 + Lang/TAV/String-length | 1 + Lang/TAV/Tic-tac-toe | 1 + Lang/TAV/Tokenize-a-string | 1 + Lang/TAV/Window-creation | 1 + Lang/TAV/Word-frequency | 1 + Lang/Tcl/M-bius-function | 1 + Lang/Ursalang/Loops-Break | 1 + Lang/Ursalang/Loops-While | 1 + Lang/V-(Vlang)/Compile-time-calculation | 1 + Lang/V-(Vlang)/Inheritance-Multiple | 1 + Lang/V-(Vlang)/Inheritance-Single | 1 + Lang/V-(Vlang)/Metaprogramming | 1 + Lang/Vyxal/00-LANG.txt | 3 + Lang/Vyxal/00-META.yaml | 2 + Lang/Vyxal/Factorial | 1 + Lang/Vyxal/FizzBuzz | 1 + Lang/XBasic/AKS-test-for-primes | 1 + Lang/XBasic/Josephus-problem | 1 + Lang/XPL0/AKS-test-for-primes | 1 + Lang/XPL0/Cistercian-numerals | 1 + Lang/YAMLScript/00-LANG.txt | 11 +- Lang/YAMLScript/Best-shuffle | 1 + Lang/YAMLScript/Conways-Game-of-Life | 1 + Lang/YAMLScript/Dragon-curve | 1 + Lang/YAMLScript/Even-or-odd | 1 + Lang/YAMLScript/Integer-comparison | 1 + Lang/YAMLScript/JortSort | 1 + Lang/YAMLScript/Knuth-shuffle | 1 + Lang/YAMLScript/Munching-squares | 1 + Lang/YAMLScript/Next-highest-int-from-digits | 1 + .../One-dimensional-cellular-automata | 1 + Lang/YAMLScript/Quickselect-algorithm | 1 + Lang/YAMLScript/Sparkline-in-unicode | 1 + ...Terminal-control-Ringing-the-terminal-bell | 1 + Lang/YAMLScript/Undefined-values | 1 + Lang/YAMLScript/Van-der-Corput-sequence | 1 + Lang/YAMLScript/Xiaolin-Wus-line-algorithm | 1 + Lang/YAMLScript/Yellowstone-sequence | 1 + Lang/YAMLScript/Zig-zag-matrix | 1 + Lang/Zig/24-game-Solve | 1 + Lang/Zig/AVL-tree | 1 + Lang/Zig/Abelian-sandpile-model | 1 + Lang/Zig/Abelian-sandpile-model-Identity | 1 + Lang/Zig/Arrays | 1 + Lang/Zig/Associative-array-Creation | 1 + Lang/Zig/Associative-array-Iteration | 1 + Lang/Zig/Base64-decode-data | 1 + Lang/Zig/Bifid-cipher | 1 + Lang/Zig/Boolean-values | 1 + Lang/Zig/Boyer-Moore-string-search | 1 + Lang/Zig/Break-OO-privacy | 1 + Lang/Zig/Camel-case-and-snake-case | 1 + Lang/Zig/Cholesky-decomposition | 1 + Lang/Zig/Cumulative-standard-deviation | 1 + Lang/Zig/Cyclops-numbers | 1 + Lang/Zig/Deconvolution-1D | 1 + Lang/Zig/Determinant-and-permanent | 1 + Lang/Zig/Eertree | 1 + ...Elliptic-Curve-Digital-Signature-Algorithm | 1 + Lang/Zig/Elliptic-curve-arithmetic | 1 + Lang/Zig/Evolutionary-algorithm | 1 + Lang/Zig/Factors-of-an-integer | 1 + Lang/Zig/Farey-sequence | 1 + Lang/Zig/Gray-code | 1 + Lang/Zig/K-d-tree | 1 + Lang/Zig/Knapsack-problem-0-1 | 1 + Lang/Zig/Knights-tour | 1 + Lang/Zig/Loops-Nested | 1 + Lang/Zig/M-bius-function | 1 + Lang/Zig/Main-step-of-GOST-28147-89 | 1 + Lang/Zig/Modular-arithmetic | 1 + Lang/Zig/Modular-inverse | 1 + Lang/Zig/Parse-an-IP-Address | 1 + Lang/Zig/Permutations-by-swapping | 1 + Lang/Zig/Stern-Brocot-sequence | 1 + Lang/Zig/Sudoku | 1 + Lang/Zig/Tarjan | 1 + Lang/Zig/Tree-datastructures | 1 + Lang/Zig/Verhoeff-algorithm | 1 + Lang/Zig/Vigen-re-cipher-Cryptanalysis | 1 + Lang/Zig/Vogels-approximation-method | 1 + Lang/Zig/War-card-game | 1 + Task/100-doors/AWK/100-doors-1.awk | 17 - Task/100-doors/AWK/100-doors-2.awk | 14 - Task/100-doors/Adina/100-doors-1.adina | 16 + Task/100-doors/Adina/100-doors-2.adina | 17 + Task/100-doors/ArkScript/100-doors-1.ark | 21 + Task/100-doors/ArkScript/100-doors-2.ark | 4 + Task/100-doors/AutoLISP/100-doors.l | 18 + Task/100-doors/Component-Pascal/100-doors.pas | 26 - Task/100-doors/DuckDB/100-doors.duckdb | 19 + Task/100-doors/Haskell/100-doors-3.hs | 13 +- Task/100-doors/Haskell/100-doors-4.hs | 7 +- Task/100-doors/Haskell/100-doors-5.hs | 1 + Task/100-doors/Lua/100-doors.lua | 11 - Task/100-doors/PL-M/100-doors.plm | 55 -- Task/100-doors/REBOL/100-doors-2.rebol | 28 +- Task/100-doors/REBOL/100-doors-3.rebol | 6 + Task/100-prisoners/Prolog/100-prisoners.pro | 43 ++ .../PascalABC.NET/15-puzzle-solver.pas | 3 + Task/2048/EasyLang/2048.easy | 2 +- Task/24-game-Solve/Zig/24-game-solve.zig | 273 ++++++++++ Task/24-game/FutureBasic/24-game.basic | 2 +- Task/24-game/Rust/24-game.rs | 12 +- .../9-billion-names-of-god-the-integer.rebol | 101 ++++ .../ALGOL-68/99-bottles-of-beer.alg | 18 +- .../Aria/99-bottles-of-beer.aria | 48 ++ .../ArkScript/99-bottles-of-beer.ark | 24 + .../DuckDB/99-bottles-of-beer-1.duckdb | 13 + .../DuckDB/99-bottles-of-beer-2.duckdb | 21 + .../Pluto/99-bottles-of-beer.pluto | 12 + .../Rhombus/99-bottles-of-beer.rhombus | 13 + Task/A+B/Agena/a+b.agena | 12 +- Task/A+B/ArkScript/a+b.ark | 9 + Task/A+B/DuckDB/a+b-1.duckdb | 5 + Task/A+B/DuckDB/a+b-2.duckdb | 2 + Task/A+B/Koka/a+b.koka | 32 ++ Task/A+B/Pluto/a+b.pluto | 2 + Task/A+B/TAV/a+b.tav | 6 + Task/ABC-problem/DuckDB/abc-problem.duckdb | 45 ++ Task/ABC-problem/Pluto/abc-problem.pluto | 25 + .../ANSI-BASIC/aks-test-for-primes.basic | 79 +++ .../Agena/aks-test-for-primes.agena | 89 ++++ .../EasyLang/aks-test-for-primes.easy | 43 ++ .../FutureBasic/aks-test-for-primes.basic | 1 - .../Modula-2/aks-test-for-primes.mod2 | 119 +++++ .../PHP/aks-test-for-primes.php | 80 +++ .../Pluto/aks-test-for-primes.pluto | 90 ++++ .../PowerShell/aks-test-for-primes.psh | 84 ++++ .../REXX/aks-test-for-primes-2.rexx | 18 +- .../XBasic/aks-test-for-primes.basic | 84 ++++ .../XPL0/aks-test-for-primes.xpl0 | 105 ++++ .../ascii-art-diagram-converter.math | 86 ++++ Task/AVL-tree/Dart/avl-tree.dart | 221 ++++++++ Task/AVL-tree/Swift/avl-tree.swift | 243 +++++++++ Task/AVL-tree/Zig/avl-tree.zig | 268 ++++++++++ .../ArkScript/abbreviations-easy.ark | 54 ++ .../PascalABC.NET/abbreviations-easy.pas | 26 + .../PascalABC.NET/abbreviations-simple.pas | 51 ++ .../abelian-sandpile-model-identity.pluto | 79 +++ .../Zig/abelian-sandpile-model-identity.zig | 126 +++++ .../Julia/abelian-sandpile-model.jl | 214 ++++---- .../Pluto/abelian-sandpile-model.pluto | 80 +++ .../Zig/abelian-sandpile-model.zig | 136 +++++ .../Free-Pascal-Lazarus/abstract-type-1.pas | 60 +++ .../Free-Pascal-Lazarus/abstract-type-2.pas | 32 ++ Task/Abstract-type/Haxe/abstract-type-1.haxe | 44 ++ .../abstract-type-2.haxe} | 0 Task/Abstract-type/Pluto/abstract-type.pluto | 34 ++ Task/Abstract-type/REBOL/abstract-type.rebol | 2 +- ...t-and-perfect-number-classifications.agena | 21 + ...-and-perfect-number-classifications.fennel | 21 + ...t-and-perfect-number-classifications.pluto | 26 + ...ent-and-perfect-number-classifications.pro | 25 +- .../ALGOL-68/abundant-odd-numbers.alg | 30 +- .../Agena/abundant-odd-numbers.agena | 52 ++ .../Pluto/abundant-odd-numbers.pluto | 35 ++ ...tory.rebol => accumulator-factory-1.rebol} | 3 + .../REBOL/accumulator-factory-2.rebol | 25 + .../Pluto/achilles-numbers.pluto | 63 +++ .../ArkScript/ackermann-function.ark | 8 + .../Pluto/ackermann-function.pluto | 13 + .../REBOL/ackermann-function-1.rebol | 7 + .../REBOL/ackermann-function-2.rebol | 16 + .../TAV/ackermann-function.tav | 11 + .../Pluto/address-of-a-variable.pluto | 6 + .../REXX/address-of-a-variable.rexx | 19 +- .../RISC-V-Assembly/address-of-a-variable.asm | 128 +++++ .../Red/address-of-a-variable.red | 17 + Task/Align-columns/ALGOL-68/align-columns.alg | 33 +- .../aliquot-sequence-classifications.js | 81 +++ .../Ada/almkvist-giullera-formula-for-pi.ada | 94 ++++ Task/Almost-prime/Icon/almost-prime-1.icon | 2 +- Task/Almost-prime/Pluto/almost-prime.pluto | 26 + Task/Amb/Ada/{amb.ada => amb-1.ada} | 0 Task/Amb/Ada/amb-2.ada | 78 +++ .../PL-I-80/amicable-pairs-1.pli | 47 -- ...micable-pairs-2.pli => amicable-pairs.pli} | 4 +- Task/Anagrams/DuckDB/anagrams.duckdb | 20 + Task/Anagrams/TAV/anagrams.tav | 38 ++ ...s-geometric-normalization-and-conversion.r | 23 + .../DuckDB/anonymous-recursion.duckdb | 11 + Task/Anti-primes/Bc/anti-primes.bc | 18 + Task/Anti-primes/Draco/anti-primes.draco | 29 ++ Task/Anti-primes/Lua/anti-primes-2.lua | 2 +- Task/Anti-primes/Pluto/anti-primes.pluto | 32 ++ .../apply-a-callback-to-an-array.ark | 8 + .../Haxe/apply-a-callback-to-an-array.haxe | 10 + .../Pluto/approximate-equality.pluto | 16 + ...bitrary-precision-integers-included-.agena | 25 + ...bitrary-precision-integers-included-.basic | 11 + ...trary-precision-integers-included-.bracmat | 2 +- ...arbitrary-precision-integers-included-.nim | 4 +- ...bitrary-precision-integers-included-.pluto | 10 + ...trary-precision-integers-included-.rhombus | 5 + .../EasyLang/archimedean-spiral.easy | 4 +- .../ArkScript/arithmetic-complex.ark | 30 ++ .../DuckDB/arithmetic-complex.duckdb | 86 ++++ .../FutureBasic/arithmetic-complex.basic | 71 +++ .../Pluto/arithmetic-complex.pluto | 15 + .../REXX/arithmetic-complex.rexx | 67 ++- .../ArkScript/arithmetic-integer.ark | 10 + .../DuckDB/arithmetic-integer.duckdb | 3 + .../Elena/arithmetic-integer.elena | 16 +- .../Haxe/arithmetic-integer.haxe | 25 +- .../Pascal/arithmetic-integer.pas | 4 +- .../Pluto/arithmetic-integer.pluto | 13 + .../RISC-V-Assembly/arithmetic-integer.asm | 146 ++++++ .../Red/arithmetic-integer.red | 42 ++ .../TAV/arithmetic-integer.tav | 11 + .../Zig/arithmetic-integer.zig | 33 +- .../Pluto/arithmetic-rational.pluto | 12 + .../REXX/arithmetic-rational.rexx | 71 ++- .../Bc/arithmetic-derivative.bc | 25 + .../Pluto/arithmetic-derivative.pluto | 20 + .../ALGOL-68/arithmetic-evaluation.alg | 41 +- .../Elena/arithmetic-evaluation.elena | 38 +- .../PascalABC.NET/arithmetic-evaluation.pas | 127 +++++ ...aluation.pl => arithmetic-evaluation-1.pl} | 0 .../Perl/arithmetic-evaluation-2.pl | 49 ++ .../Red/arithmetic-evaluation.red | 113 +++++ .../ALGOL-68/arithmetic-geometric-mean.alg | 2 +- .../DuckDB/arithmetic-geometric-mean-1.duckdb | 12 + .../DuckDB/arithmetic-geometric-mean-2.duckdb | 14 + .../Pluto/arithmetic-geometric-mean.pluto | 10 + .../DuckDB/arithmetic-numbers.duckdb | 70 +++ .../ArkScript/array-concatenation.ark | 4 + .../DuckDB/array-concatenation.duckdb | 4 + .../Elena/array-concatenation.elena | 2 +- .../Pluto/array-concatenation.pluto | 12 + .../TAV/array-concatenation.tav | 3 + Task/Array-length/ArkScript/array-length.ark | 2 + Task/Array-length/DuckDB/array-length.duckdb | 1 + .../M2000-Interpreter/array-length.m2000 | 35 -- Task/Array-length/Maxima/array-length.maxima | 4 + Task/Array-length/TAV/array-length.tav | 1 + Task/Array-length/Tcl/array-length-1.tcl | 1 + Task/Array-length/Tcl/array-length-2.tcl | 1 + Task/Array-length/Tcl/array-length-3.tcl | 5 + Task/Array-length/Tcl/array-length-4.tcl | 2 + Task/Array-length/Tcl/array-length-5.tcl | 1 + Task/Array-length/Tcl/array-length-6.tcl | 5 + Task/Array-length/Tcl/array-length-7.tcl | 10 + Task/Array-length/Tcl/array-length.tcl | 13 - Task/Arrays/BBC-BASIC/arrays.basic | 5 + Task/Arrays/DuckDB/arrays.duckdb | 9 + Task/Arrays/Elena/arrays-5.elena | 6 +- Task/Arrays/Extended-Color-BASIC/arrays.basic | 4 + Task/Arrays/Haxe/arrays.haxe | 22 + Task/Arrays/Pluto/arrays.pluto | 8 + Task/Arrays/REXX/arrays.rexx | 74 +-- Task/Arrays/Unicon/arrays-1.unicon | 1 + Task/Arrays/Unicon/arrays-2.unicon | 6 + Task/Arrays/Unicon/arrays-3.unicon | 3 + Task/Arrays/Zig/arrays-1.zig | 32 ++ Task/Arrays/Zig/arrays-2.zig | 21 + .../ArkScript/ascending-primes.ark | 24 + .../Pluto/ascending-primes.pluto | 24 + .../ArkScript/associative-array-creation.ark | 6 + .../associative-array-creation-1.duckdb | 6 + .../associative-array-creation-2.duckdb | 5 + .../associative-array-creation-3.duckdb | 1 + .../associative-array-creation-4.duckdb | 3 + .../associative-array-creation-5.duckdb | 1 + .../associative-array-creation-6.duckdb | 1 + .../associative-array-creation-7.duckdb | 1 + .../associative-array-creation-8.duckdb | 1 + .../Haxe/associative-array-creation.haxe | 7 + .../Pluto/associative-array-creation.pluto | 25 + .../REXX/associative-array-creation-1.rexx | 10 - .../REXX/associative-array-creation-2.rexx | 27 - .../REXX/associative-array-creation.rexx | 54 ++ .../associative-array-creation-2.sh | 1 - ...ion-1.sh => associative-array-creation.sh} | 0 .../Zig/associative-array-creation-1.zig | 18 + .../Zig/associative-array-creation-2.zig | 23 + .../ArkScript/associative-array-iteration.ark | 9 + .../DuckDB/associative-array-iteration.duckdb | 108 ++++ .../Elena/associative-array-iteration-1.elena | 18 - ...lena => associative-array-iteration.elena} | 0 .../Haxe/associative-array-iteration.haxe | 18 + .../Pluto/associative-array-iteration.pluto | 19 + .../REXX/associative-array-iteration.rexx | 128 ++--- .../TAV/associative-array-iteration.tav | 24 + .../Tcl/associative-array-iteration-1.tcl | 21 +- .../Tcl/associative-array-iteration-2.tcl | 19 +- .../Tcl/associative-array-iteration-3.tcl | 2 + .../Tcl/associative-array-iteration-4.tcl | 16 + .../Tcl/associative-array-iteration-5.tcl | 16 + .../Zig/associative-array-iteration-1.zig | 30 ++ .../Zig/associative-array-iteration-2.zig | 30 ++ .../DuckDB/associative-array-merging-1.duckdb | 4 + .../DuckDB/associative-array-merging-2.duckdb | 11 + .../DuckDB/associative-array-merging-3.duckdb | 11 + .../Fortran/associative-array-merging.f | 94 ++++ .../Pluto/associative-array-merging.pluto | 11 + .../REXX/associative-array-merging.rexx | 111 ++-- .../Agena/attractive-numbers.agena | 28 ++ .../Lua/attractive-numbers.lua | 9 +- .../Pluto/attractive-numbers.pluto | 40 ++ .../Apple/averages-arithmetic-mean.apple | 2 + .../DuckDB/averages-arithmetic-mean.duckdb | 3 + .../Elena/averages-arithmetic-mean.elena | 8 +- .../Pluto/averages-arithmetic-mean.pluto | 4 + .../DuckDB/averages-mean-angle.duckdb | 13 + .../DuckDB/averages-mean-time-of-day.duckdb | 17 + .../averages-mean-time-of-day.basic | 70 +++ .../Elena/averages-median.elena | 6 +- .../Pluto/averages-median.pluto | 17 + .../DuckDB/averages-mode-1.duckdb | 10 + .../DuckDB/averages-mode-2.duckdb | 1 + .../DuckDB/averages-mode-3.duckdb | 10 + .../DuckDB/averages-mode-4.duckdb | 1 + .../DuckDB/averages-mode-5.duckdb | 15 + .../DuckDB/averages-mode-6.duckdb | 2 + Task/Averages-Mode/Elena/averages-mode.elena | 2 +- .../Apple/averages-pythagorean-means.apple | 12 + .../DuckDB/averages-pythagorean-means.duckdb | 11 + .../Pluto/averages-pythagorean-means.pluto | 11 + .../EasyLang/averages-root-mean-square.easy | 7 +- .../Elena/averages-root-mean-square.elena | 2 +- .../Pluto/averages-root-mean-square.pluto | 7 + .../TAV/averages-root-mean-square.tav | 10 + .../averages-simple-moving-average.elena | 16 +- .../JavaScript/b-zier-curves-intersections.js | 162 ++++++ .../AutoLISP/babbage-problem.l | 54 ++ .../DuckDB/babbage-problem-1.duckdb | 3 + .../DuckDB/babbage-problem-2.duckdb | 9 + .../Elena/babbage-problem.elena | 2 +- .../EasyLang/babylonian-spiral.easy | 43 +- .../FreeBASIC/babylonian-spiral.basic | 92 ++++ .../ArkScript/balanced-brackets.ark | 24 + .../AutoLISP/balanced-brackets.l | 12 + .../Elena/balanced-brackets.elena | 10 +- .../Nom/balanced-brackets.num | 19 + .../Pluto/balanced-brackets.pluto | 36 ++ .../JavaScript/balanced-ternary.js | 203 ++++++++ .../Pluto/base64-decode-data.pluto | 4 + .../Zig/base64-decode-data.zig | 86 ++++ Task/Bell-numbers/Pluto/bell-numbers.pluto | 32 ++ Task/Benfords-law/DuckDB/benfords-law.duckdb | 22 + Task/Bernoulli-numbers/R/bernoulli-numbers.r | 12 +- .../REXX/bernoulli-numbers.rexx | 184 +++++-- Task/Best-shuffle/Elena/best-shuffle.elena | 4 +- Task/Best-shuffle/Factor/best-shuffle.factor | 26 + Task/Best-shuffle/YAMLScript/best-shuffle.ys | 44 ++ Task/Bifid-cipher/Zig/bifid-cipher.zig | 164 ++++++ .../DuckDB/bin-given-limits-1.duckdb | 24 + .../DuckDB/bin-given-limits-2.duckdb | 14 + .../DuckDB/binary-digits-1.duckdb | 2 + .../DuckDB/binary-digits-2.duckdb | 22 + Task/Binary-digits/Elena/binary-digits.elena | 2 +- Task/Binary-digits/Haxe/binary-digits.haxe | 15 + ...inary-digits.icon => binary-digits-1.icon} | 0 Task/Binary-digits/Icon/binary-digits-2.icon | 12 + .../RISC-V-Assembly/binary-digits.asm | 185 +++++++ .../DuckDB/bioinformatics-base-count.duckdb | 18 + .../bioinformatics-base-count.pas | 14 + Task/Biorhythms/Ada/biorhythms.ada | 65 +++ Task/Biorhythms/EasyLang/biorhythms.easy | 4 +- .../bitcoin-public-point-to-address.basic | 142 ++++++ .../bitcoin-public-point-to-address.js | 52 ++ .../bitmap-b-zier-curves-quadratic.easy | 6 +- .../bitmap-bresenhams-line-algorithm.pluto | 27 + .../bitmap-midpoint-circle-algorithm.easy | 27 + .../Julia/bitmap-midpoint-circle-algorithm.jl | 6 +- .../bitmap-midpoint-circle-algorithm.pluto | 33 ++ Task/Bitmap/Pluto/bitmap.pluto | 23 + Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb | 8 + Task/Bitwise-IO/DuckDB/bitwise-io-2.duckdb | 13 + .../ALGOL-68/bitwise-operations-1.alg | 16 +- .../DuckDB/bitwise-operations-1.duckdb | 5 + .../DuckDB/bitwise-operations-2.duckdb | 5 + .../Elena/bitwise-operations.elena | 20 +- .../Icon/bitwise-operations.icon | 2 + .../Pluto/bitwise-operations.pluto | 20 + .../ArkScript/boolean-values.ark | 14 + Task/Boolean-values/Haxe/boolean-values.haxe | 8 + Task/Boolean-values/Prolog/boolean-values.pro | 2 + Task/Boolean-values/Zig/boolean-values.zig | 15 + .../Ada/boyer-moore-string-search.ada | 63 +++ .../Dart/boyer-moore-string-search.dart | 80 +++ .../boyer-moore-string-search.basic | 55 ++ .../Kotlin/boyer-moore-string-search.kts | 50 ++ .../Swift/boyer-moore-string-search.swift | 59 +++ .../Zig/boyer-moore-string-search.zig | 71 +++ .../Dart/break-oo-privacy.dart | 38 ++ .../JavaScript/break-oo-privacy.js | 54 ++ .../Break-OO-privacy/Rust/break-oo-privacy.rs | 62 +++ .../Break-OO-privacy/Zig/break-oo-privacy.zig | 88 ++++ .../Brownian-tree/EasyLang/brownian-tree.easy | 30 +- .../Bulls-and-cows/Elena/bulls-and-cows.elena | 14 +- Task/Bulls-and-cows/J/bulls-and-cows-1.j | 2 +- Task/CRC-32/FutureBasic/crc-32.basic | 46 ++ Task/CRC-32/Pluto/crc-32.pluto | 5 + Task/CRC-32/R/crc-32.r | 1 + .../DuckDB/csv-data-manipulation-1.duckdb | 5 + .../DuckDB/csv-data-manipulation-2.duckdb | 4 + .../DuckDB/csv-data-manipulation-3.duckdb | 6 + .../Nom/csv-to-html-translation-1.num | 85 ++++ .../Nom/csv-to-html-translation-2.num | 14 + Task/CUSIP/R/cusip.r | 25 + Task/Caesar-cipher/Elena/caesar-cipher.elena | 8 +- Task/Caesar-cipher/Pluto/caesar-cipher.pluto | 20 + .../Rhombus/caesar-cipher.rhombus | 25 + .../ArkScript/calculating-the-value-of-e.ark | 22 + .../calendar---for-real-programmers-1.elena | 57 +++ .../calendar---for-real-programmers-2.elena | 146 ++++++ .../calendar---for-real-programmers.elena | 161 ------ .../Red/calendar---for-real-programmers.red | 52 ++ Task/Calendar/Red/calendar.red | 52 ++ .../Ada/calkin-wilf-sequence.ada | 110 ++++ .../Pluto/calkin-wilf-sequence.pluto | 47 ++ .../call-a-foreign-language-function-1.pluto | 18 + .../call-a-foreign-language-function-2.pluto | 10 + .../call-a-function-in-a-shared-library.pluto | 19 + .../ArkScript/call-a-function-1.ark | 4 + .../ArkScript/call-a-function-2.ark | 3 + .../ArkScript/call-a-function-3.ark | 6 + .../ArkScript/call-a-function-4.ark | 6 + .../ArkScript/call-a-function-5.ark | 3 + .../ArkScript/call-a-function-6.ark | 4 + .../ArkScript/call-a-function-7.ark | 8 + .../DuckDB/call-a-function-1.duckdb | 5 + .../DuckDB/call-a-function-2.duckdb | 1 + .../Elena/call-a-function-1.elena | 4 +- .../ArkScript/call-an-object-method.ark | 17 + .../Elena/call-an-object-method.elena | 2 +- .../Haxe/call-an-object-method.haxe | 13 + .../Ada/camel-case-and-snake-case.ada | 114 +++++ .../C-sharp/camel-case-and-snake-case.cs | 87 ++++ .../camel-case-and-snake-case.math | 85 ++++ .../Rust/camel-case-and-snake-case.rs | 93 ++++ .../Zig/camel-case-and-snake-case.zig | 134 +++++ .../Ada/canonicalize-cidr.ada | 105 ++++ .../carmichael-3-strong-pseudoprimes.basic | 41 ++ ...sian-product-of-two-or-more-lists-1.duckdb | 2 + ...sian-product-of-two-or-more-lists-2.duckdb | 8 + .../case-sensitivity-of-identifiers-1.duckdb | 3 + .../case-sensitivity-of-identifiers-2.duckdb | 2 + .../case-sensitivity-of-identifiers.elena | 2 +- .../case-sensitivity-of-identifiers.pas | 8 + .../case-sensitivity-of-identifiers.pluto | 13 + .../Pluto/casting-out-nines.pluto | 30 ++ .../catalan-numbers-pascals-triangle-1.duckdb | 20 + .../catalan-numbers-pascals-triangle-2.duckdb | 8 + .../catalan-numbers-pascals-triangle.f | 64 +++ .../catalan-numbers-pascals-triangle.objeck | 23 + Task/Catalan-numbers/00-META.yaml | 2 +- .../DuckDB/catalan-numbers.duckdb | 30 ++ Task/Catamorphism/Apple/catamorphism-1.apple | 2 + Task/Catamorphism/Apple/catamorphism-2.apple | 2 + Task/Catamorphism/Apple/catamorphism-3.apple | 2 + Task/Catamorphism/ArkScript/catamorphism.ark | 7 + Task/Catamorphism/Elena/catamorphism.elena | 2 +- .../catmull-clark-subdivision-surface.basic | 250 +++++++++ .../catmull-clark-subdivision-surface.js | 255 ++++++++++ Task/Chaocipher/Swift/chaocipher.swift | 84 ++++ .../Elena/character-codes.elena | 4 +- .../Character-codes/Haxe/character-codes.haxe | 7 + Task/Character-codes/TAV/character-codes.tav | 2 + .../ArkScript/check-that-file-exists.ark | 4 + .../DuckDB/check-that-file-exists.duckdb | 2 + .../Elena/check-that-file-exists.elena | 8 +- .../JavaScript/checkpoint-synchronization.js | 47 ++ Task/Chinese-zodiac/Fortran/chinese-zodiac.f | 62 +++ .../EasyLang/cholesky-decomposition.easy | 19 + .../Zig/cholesky-decomposition.zig | 64 +++ Task/Chowla-numbers/REXX/chowla-numbers.rexx | 13 +- .../Circular-primes/REXX/circular-primes.rexx | 14 +- .../C-sharp/cistercian-numerals.cs | 141 ++++++ .../cistercian-numerals.pas | 151 ++++++ .../Modula-2/cistercian-numerals.mod2 | 132 +++++ .../Pascal-P/cistercian-numerals.pas | 131 +++++ .../XPL0/cistercian-numerals.xpl0 | 104 ++++ Task/Classes/Elena/classes.elena | 2 +- Task/Classes/Haxe/classes-1.haxe | 14 + .../classes-3.hs => Haxe/classes-2.haxe} | 0 .../ArkScript/closures-value-capture.ark | 13 + .../Elena/closures-value-capture.elena | 2 +- Task/Collections/DuckDB/collections.duckdb | 11 + Task/Collections/Phix/collections-1.phix | 3 +- Task/Collections/Phix/collections-2.phix | 3 +- Task/Collections/Pluto/collections.pluto | 13 + .../FreeBASIC/color-quantization.basic | 194 +++++++ Task/Color-wheel/EasyLang/color-wheel.easy | 37 +- .../combinations-with-repetitions.duckdb | 49 ++ .../combinations-with-repetitions.pas | 8 + .../Pluto/combinations-with-repetitions.pluto | 15 + Task/Combinations/DuckDB/combinations.duckdb | 22 + Task/Combinations/Elena/combinations.elena | 4 +- Task/Combinations/Pluto/combinations.pluto | 10 + .../Elena/comma-quibbling-1.elena | 2 +- .../Pluto/command-line-arguments.pluto | 1 + .../TAV/command-line-arguments.tav | 3 + Task/Comments/ArkScript/comments.ark | 4 + Task/Comments/Ballerina/comments.ballerina | 10 + Task/Comments/Idris/comments.idris | 9 + Task/Comments/Janet/comments.janet | 7 + Task/Comments/Odin/comments.odin | 17 + Task/Comments/Pluto/comments.pluto | 9 + .../DuckDB/compare-a-list-of-strings-1.duckdb | 2 + .../DuckDB/compare-a-list-of-strings-2.duckdb | 2 + .../DuckDB/compare-a-list-of-strings-3.duckdb | 16 + .../Elena/compare-a-list-of-strings.elena | 6 +- .../Ring/compare-a-list-of-strings.ring | 57 +++ ...gs.tcl => compare-a-list-of-strings-1.tcl} | 0 .../Tcl/compare-a-list-of-strings-2.tcl | 23 + .../compare-length-of-two-strings-1.duckdb | 8 + .../compare-length-of-two-strings-2.duckdb | 2 + .../compare-length-of-two-strings-3.duckdb | 6 + .../Pluto/compare-length-of-two-strings.pluto | 43 ++ Task/Compile-time-calculation/00-TASK.txt | 2 +- .../V-(Vlang)/compile-time-calculation.v | 15 + .../Pluto/compiler-lexical-analyzer.pluto | 258 ++++++++++ ...hose-factors-are-all-substrings-of-k.basic | 23 +- .../ArkScript/compound-data-type.ark | 14 + .../DuckDB/compound-data-type.duckdb | 1 + .../ArkScript/concurrent-computing.ark | 9 + ...computing.rs => concurrent-computing-1.rs} | 0 .../Rust/concurrent-computing-2.rs | 15 + .../Rust/concurrent-computing-3.rs | 26 + .../ArkScript/conditional-structures.ark | 20 + .../DuckDB/conditional-structures-1.duckdb | 1 + .../DuckDB/conditional-structures-2.duckdb | 1 + .../DuckDB/conditional-structures-3.duckdb | 1 + .../Pluto/conditional-structures.pluto | 29 ++ .../TAV/conditional-structures-1.tav | 4 + .../TAV/conditional-structures-2.tav | 5 + .../TAV/conditional-structures-3.tav | 1 + ...-ascending-or-descending-differences.basic | 3 +- .../C++/constrained-genericity-1.cpp | 13 + ...icity.cpp => constrained-genericity-2.cpp} | 4 +- ...metic-construct-from-rational-number-1.jl} | 0 ...hmetic-construct-from-rational-number-2.jl | 21 + ...metic-construct-from-rational-number.pluto | 39 ++ ...tic-g-matrix-ng-continued-fraction-n-.dart | 157 ++++++ ...metic-g-matrix-ng-continued-fraction-n-.js | 150 ++++++ ...metic-g-matrix-ng-continued-fraction-n-.pl | 194 +++++++ ...metic-g-matrix-ng-continued-fraction-n-.rs | 201 ++++++++ ...ic-g-matrix-ng-continued-fraction-n-.scala | 123 +++++ ...ic-g-matrix-ng-continued-fraction-n-.swift | 155 ++++++ .../Dart/continued-fraction.dart | 20 + .../JavaScript/continued-fraction.js | 35 ++ .../Continued-fraction/R/continued-fraction.r | 24 + .../REXX/continued-fraction-3.rexx | 26 +- .../convert-decimal-number-to-rational.pluto | 8 + ...onvert-seconds-to-compound-duration.duckdb | 18 + .../ArkScript/conways-game-of-life.ark | 68 +++ .../Elena/conways-game-of-life.elena | 10 +- .../YAMLScript/conways-game-of-life.ys | 42 ++ .../Copy-a-string/ArkScript/copy-a-string.ark | 7 + .../Copy-a-string/DuckDB/copy-a-string.duckdb | 40 ++ .../Extended-Color-BASIC/copy-a-string.basic | 7 + Task/Copy-a-string/TAV/copy-a-string.tav | 6 + .../Count-in-octal/Pluto/count-in-octal.pluto | 5 + .../count-occurrences-of-a-substring.duckdb | 6 + .../ALGOL-68/count-the-coins-1.alg | 3 +- .../Pluto/count-the-coins.pluto | 28 ++ Task/Cramers-rule/R/cramers-rule.r | 12 + .../Create-a-file/Pluto/create-a-file-1.pluto | 2 + .../Create-a-file/Pluto/create-a-file-2.pluto | 4 + ...-a-two-dimensional-array-at-runtime.duckdb | 38 ++ ...a-two-dimensional-array-at-runtime-1.elena | 6 +- ...a-two-dimensional-array-at-runtime-2.elena | 8 +- ...te-a-two-dimensional-array-at-runtime.rexx | 143 ++++-- ...ate-a-two-dimensional-array-at-runtime.tav | 3 + Task/Cuban-primes/REXX/cuban-primes.rexx | 12 +- .../cumulative-standard-deviation.duckdb | 7 + .../Zig/cumulative-standard-deviation.zig | 21 + Task/Currency/DuckDB/currency.duckdb | 17 + Task/Currency/EasyLang/currency.easy | 81 +++ Task/Currying/ArkScript/currying.ark | 7 + Task/Currying/Pluto/currying.pluto | 4 + Task/Currying/Red/currying.red | 36 ++ Task/Curzon-numbers/R/curzon-numbers.r | 18 + .../Curzon-numbers/V-(Vlang)/curzon-numbers.v | 10 +- Task/Cyclops-numbers/Rust/cyclops-numbers.rs | 171 +++++++ Task/Cyclops-numbers/Zig/cyclops-numbers.zig | 185 +++++++ .../Fortran/cyclotomic-polynomial.f | 213 ++++++++ Task/Damm-algorithm/Prolog/damm-algorithm.pro | 27 + ...{date-format.rebol => date-format-1.rebol} | 0 Task/Date-format/REBOL/date-format-2.rebol | 1 + .../ALGOL-68/date-manipulation.alg | 237 +++++++++ .../DuckDB/day-of-the-week-1.duckdb | 8 + .../DuckDB/day-of-the-week-2.duckdb | 11 + .../DuckDB/day-of-the-week-3.duckdb | 10 + .../FutureBasic/deal-cards-for-freecell.basic | 143 ++++++ Task/Death-Star/EasyLang/death-star.easy | 62 +++ .../JavaScript/deconvolution-1d.js | 27 + .../Deconvolution-1D/Rust/deconvolution-1d.rs | 39 ++ .../Deconvolution-1D/Zig/deconvolution-1d.zig | 54 ++ .../JavaScript/deconvolution-2d+.js | 329 ++++++++++++ .../Rust/deconvolution-2d+.rs | 359 +++++++++++++ Task/Deepcopy/Ada/deepcopy.ada | 16 + .../define-a-primitive-data-type.duckdb | 1 + .../Elena/define-a-primitive-data-type.elena | 8 +- Task/Delegates/Elena/delegates-1.elena | 2 +- Task/Delegates/Elena/delegates-2.elena | 6 +- .../Delete-a-file/ArkScript/delete-a-file.ark | 8 + .../Delete-a-file/Maxima/delete-a-file.maxima | 5 + Task/Delete-a-file/Pluto/delete-a-file.pluto | 5 + .../FutureBasic/demings-funnel.basic | 88 ++++ .../Bc/department-numbers.bc | 7 + .../Crystal/department-numbers.cr | 1 + .../Pluto/descending-primes.pluto | 11 + .../DuckDB/detect-division-by-zero.duckdb | 8 + Task/Determinant-and-permanent/00-TASK.txt | 3 +- .../C++/determinant-and-permanent.cpp | 180 ++++--- .../DuckDB/determinant-and-permanent.duckdb | 63 +++ .../Elixir/determinant-and-permanent.ex | 52 ++ .../Erlang/determinant-and-permanent.erl | 52 ++ .../Zig/determinant-and-permanent.zig | 86 ++++ ...-string-has-all-the-same-characters.duckdb | 38 ++ ...-a-string-has-all-unique-characters.duckdb | 38 ++ ...etermine-if-a-string-is-collapsible.duckdb | 16 + .../determine-if-a-string-is-numeric.duckdb | 22 + .../Nom/determine-if-a-string-is-numeric.num | 67 +++ .../determine-if-a-string-is-numeric.pluto | 9 + .../determine-if-a-string-is-numeric-1.tcl | 3 + .../determine-if-a-string-is-numeric-2.tcl | 17 + .../Tcl/determine-if-a-string-is-numeric.tcl | 1 - ...determine-if-a-string-is-squeezable.duckdb | 18 + .../determine-if-two-triangles-overlap.rs | 159 ++++++ .../DuckDB/determine-sentence-type.duckdb | 22 + Task/Digital-root/DuckDB/digital-root.duckdb | 26 + Task/Digital-root/Elena/digital-root.elena | 2 +- .../Dart/dijkstras-algorithm.dart | 179 +++++++ .../R/dijkstras-algorithm.r | 165 ++++++ .../Agena/disarium-numbers.agena | 34 ++ .../Fortran/disarium-numbers.f | 112 +++++ .../Frink/disarium-numbers.frink | 12 + .../Objeck/disarium-numbers.objeck | 29 ++ .../Pluto/disarium-numbers.pluto | 29 ++ Task/Disarium-numbers/R/disarium-numbers.r | 12 +- .../Fortran/display-a-linear-combination.f | 94 ++++ .../Pluto/display-a-linear-combination.pluto | 32 ++ .../Go/distance-and-bearing.go | 131 +++++ ...bution-of-0-digits-in-factorial-series.alg | 72 +++ ...ution-of-0-digits-in-factorial-series.easy | 33 ++ ...tion-of-0-digits-in-factorial-series.pluto | 70 +++ .../diversity-prediction-theorem.duckdb | 31 ++ .../DuckDB/documentation-1.duckdb | 4 + .../DuckDB/documentation-2.duckdb | 1 + .../DuckDB/documentation-3.duckdb | 3 + .../Unicon/documentation-1.unicon | 26 + .../Unicon/documentation-2.unicon | 6 + .../Unicon/documentation-3.unicon | 7 + .../Documentation/Unicon/documentation.unicon | 1 - Task/Dominoes/FreeBASIC/dominoes-1.basic | 202 ++++++++ Task/Dominoes/FreeBASIC/dominoes-2.basic | 44 ++ Task/Dot-product/Apple/dot-product.apple | 1 + Task/Dot-product/DuckDB/dot-product-1.duckdb | 1 + Task/Dot-product/DuckDB/dot-product-2.duckdb | 3 + Task/Dot-product/DuckDB/dot-product-3.duckdb | 7 + Task/Dot-product/DuckDB/dot-product-4.duckdb | 13 + Task/Dot-product/Elena/dot-product.elena | 2 +- .../Pluto/doubly-linked-list-definition.pluto | 18 + ...oubly-linked-list-element-definition.pluto | 9 + .../Pluto/doubly-linked-list-traversal.pluto | 24 + Task/Dragon-curve/EasyLang/dragon-curve.easy | 4 +- Task/Dragon-curve/YAMLScript/dragon-curve.ys | 29 ++ Task/Draw-a-pixel/GML/draw-a-pixel.gml | 3 +- .../Draw-a-sphere/EasyLang/draw-a-sphere.easy | 25 + .../Rust/duffinian-numbers.rs | 97 ++++ .../Pluto/dutch-national-flag-problem.pluto | 24 + .../DuckDB/dynamic-variable-names.duckdb | 1 + .../Elena/dynamic-variable-names.elena | 2 +- .../EasyLang/ekg-sequence-convergence.easy | 22 + .../Fortran/ekg-sequence-convergence.f | 168 +++++++ ...arliest-difference-between-prime-gaps.easy | 41 ++ ...rliest-difference-between-prime-gaps.basic | 2 +- Task/Eertree/Zig/eertree.zig | 181 +++++++ .../Fortran/egyptian-division.f | 69 +++ .../DuckDB/element-wise-operations-1.duckdb | 7 + .../DuckDB/element-wise-operations-2.duckdb | 58 +++ ...ry-cellular-automaton-infinite-length.easy | 34 ++ ...ptic-curve-digital-signature-algorithm.zig | 475 ++++++++++++++++++ .../Rust/elliptic-curve-arithmetic.rs | 211 ++++++++ .../Zig/elliptic-curve-arithmetic.zig | 187 +++++++ .../ArkScript/empty-directory.ark | 3 + .../ArkScript/empty-program-1.ark | 1 + .../ArkScript/empty-program-2.ark | 1 + Task/Empty-string/ArkScript/empty-string.ark | 5 + Task/Empty-string/DuckDB/empty-string.duckdb | 1 + Task/Empty-string/Elena/empty-string.elena | 4 +- Task/Empty-string/Nom/empty-string.num | 6 + Task/Empty-string/TAV/empty-string.tav | 5 + .../ArkScript/enforced-immutability.ark | 2 + .../AutoLISP/entropy-narcissist.l | 46 ++ Task/Entropy/AutoLISP/entropy.l | 40 ++ Task/Entropy/DuckDB/entropy.duckdb | 16 + Task/Entropy/Elena/entropy.elena | 2 +- Task/Enumerations/DuckDB/enumerations.duckdb | 1 + .../DuckDB/equilibrium-index.duckdb | 15 + .../Elena/equilibrium-index.elena | 2 +- .../Mathematica/erd-s-nicolas-numbers.math | 28 ++ ...-s-selfridge-categorization-of-primes.easy | 59 +++ Task/Euler-method/DuckDB/euler-method.duckdb | 26 + Task/Euler-method/EasyLang/euler-method.easy | 35 +- .../FutureBasic/euler-method.basic | 33 ++ Task/Euler-method/Pluto/euler-method.pluto | 25 + .../DuckDB/eulers-constant-0.5772....duckdb | 21 + .../REXX/eulers-constant-0.5772....rexx | 10 +- .../DuckDB/eulers-identity.duckdb | 16 + .../Pluto/eulers-identity.pluto | 3 + .../evaluate-binomial-coefficients.duckdb | 23 + Task/Even-or-odd/Adina/even-or-odd-1.adina | 4 + Task/Even-or-odd/Adina/even-or-odd-2.adina | 4 + Task/Even-or-odd/ArkScript/even-or-odd.ark | 5 + Task/Even-or-odd/DuckDB/even-or-odd-1.duckdb | 3 + Task/Even-or-odd/DuckDB/even-or-odd-2.duckdb | 1 + Task/Even-or-odd/Nom/even-or-odd.num | 8 + Task/Even-or-odd/Pluto/even-or-odd.pluto | 4 + Task/Even-or-odd/YAMLScript/even-or-odd.ys | 6 + .../Elena/evolutionary-algorithm.elena | 14 +- .../Icon/evolutionary-algorithm-2.icon | 8 +- .../Zig/evolutionary-algorithm.zig | 114 +++++ ...an-exception-thrown-in-a-nested-call.elena | 2 +- Task/Exceptions/C++/exceptions-1.cpp | 19 +- Task/Exceptions/C++/exceptions-2.cpp | 7 +- Task/Exceptions/C++/exceptions-3.cpp | 5 +- Task/Exceptions/C++/exceptions-4.cpp | 17 +- Task/Exceptions/C++/exceptions-5.cpp | 17 + Task/Exceptions/Lua/exceptions-2.lua | 6 +- Task/Exceptions/Lua/exceptions-3.lua | 10 +- Task/Exceptions/Lua/exceptions-4.lua | 10 +- Task/Exceptions/Phix/exceptions-3.phix | 0 .../Tcl/{exceptions.tcl => exceptions-1.tcl} | 0 Task/Exceptions/Tcl/exceptions-2.tcl | 26 + Task/Execute-HQ9+/R/execute-hq9+.r | 25 + .../Pluto/execute-a-system-command.pluto | 1 + .../DuckDB/exponentiation-order.duckdb | 6 + .../Icon/exponentiation-order.icon | 5 + .../ArkScript/extend-your-language.ark | 20 + .../Koka/extend-your-language.koka | 28 ++ .../extreme-floating-point-values-1.duckdb | 8 + .../extreme-floating-point-values-2.duckdb | 1 + .../Factorial-primes/AWK/factorial-primes.awk | 15 + .../Agena/factorial-primes.agena | 17 + .../Fennel/factorial-primes.fennel | 30 ++ .../Factorial-primes/Lua/factorial-primes.lua | 28 +- .../Pluto/factorial-primes.pluto | 20 + Task/Factorial-primes/R/factorial-primes.r | 29 ++ Task/Factorial/ALGOL-60/factorial.alg | 14 - Task/Factorial/ALGOL-68/factorial-1.alg | 5 - Task/Factorial/ALGOL-68/factorial-2.alg | 30 -- Task/Factorial/ALGOL-68/factorial-3.alg | 7 - Task/Factorial/ALGOL-W/factorial.alg | 15 - Task/Factorial/Agena/factorial.agena | 25 + Task/Factorial/Apple/factorial-1.apple | 2 + Task/Factorial/Apple/factorial-2.apple | 16 + Task/Factorial/CBASIC/factorial.basic | 19 + Task/Factorial/DuckDB/factorial-1.duckdb | 3 + Task/Factorial/DuckDB/factorial-2.duckdb | 3 + Task/Factorial/DuckDB/factorial-3.duckdb | 2 + Task/Factorial/Fennel/factorial.fennel | 18 + Task/Factorial/Mn/factorial.mn | 12 + Task/Factorial/Pluto/factorial.pluto | 30 ++ Task/Factorial/REXX/factorial-2.rexx | 37 +- Task/Factorial/Rhombus/factorial-1.rhombus | 5 + Task/Factorial/Rhombus/factorial-2.rhombus | 7 + Task/Factorial/TAV/factorial.tav | 14 + Task/Factorial/Vyxal/factorial-1.vyxal | 1 + Task/Factorial/Vyxal/factorial-2.vyxal | 1 + Task/Factorial/Vyxal/factorial-3.vyxal | 1 + Task/Factorions/Ada/factorions.ada | 64 +++ Task/Factorions/Pluto/factorions.pluto | 18 + Task/Factorions/R/factorions.r | 4 +- .../ALGOL-M/factors-of-an-integer.alg | 45 +- .../Apple/factors-of-an-integer.apple | 2 + .../DuckDB/factors-of-an-integer-1.duckdb | 8 + .../DuckDB/factors-of-an-integer-2.duckdb | 19 + .../Pluto/factors-of-an-integer.pluto | 5 + .../Zig/factors-of-an-integer.zig | 43 ++ .../Bc/fairshare-between-two-and-more.bc | 21 + .../fairshare-between-two-and-more.duckdb | 42 ++ .../Farey-sequence/Pluto/farey-sequence.pluto | 30 ++ Task/Farey-sequence/Zig/farey-sequence.zig | 92 ++++ .../EasyLang/faulhabers-formula.easy | 94 ++++ .../EasyLang/faulhabers-triangle.easy | 67 +++ .../Rust/faulhabers-triangle.rs | 171 +++++++ .../feigenbaum-constant-calculation.duckdb | 46 ++ .../feigenbaum-constant-calculation.pluto | 29 ++ .../REXX/feigenbaum-constant-calculation.rexx | 27 +- .../fibonacci-n-step-number-sequences-1.jl | 42 +- .../fibonacci-n-step-number-sequences-2.jl | 28 +- .../fibonacci-n-step-number-sequences-3.jl | 11 +- .../fibonacci-n-step-number-sequences-4.jl | 13 +- .../fibonacci-n-step-number-sequences-5.jl | 38 +- .../fibonacci-n-step-number-sequences-6.jl | 36 ++ .../fibonacci-n-step-number-sequences-2.pas | 30 +- .../R/fibonacci-n-step-number-sequences.r | 34 ++ .../ArkScript/fibonacci-sequence-1.ark | 6 + .../ArkScript/fibonacci-sequence-2.ark | 12 + .../DuckDB/fibonacci-sequence-1.duckdb | 11 + .../DuckDB/fibonacci-sequence-2.duckdb | 2 + .../DuckDB/fibonacci-sequence-3.duckdb | 1 + .../DuckDB/fibonacci-sequence-4.duckdb | 16 + .../Elena/fibonacci-sequence-1.elena | 2 +- .../Elena/fibonacci-sequence-2.elena | 28 +- .../Pluto/fibonacci-sequence.pluto | 11 + .../Rhombus/fibonacci-sequence-1.rhombus | 6 + .../Rhombus/fibonacci-sequence-2.rhombus | 14 + .../TAV/fibonacci-sequence-1.tav | 8 + .../TAV/fibonacci-sequence-2.tav | 11 + .../EasyLang/fibonacci-word-fractal.easy | 24 + .../Julia/fibonacci-word-fractal.jl | 26 +- .../DuckDB/file-input-output.duckdb | 1 + Task/File-size/Elena/file-size.elena | 4 +- Task/Filter/Apple/filter-1.apple | 2 + Task/Filter/Apple/filter-2.apple | 2 + Task/Filter/DuckDB/filter-1.duckdb | 13 + Task/Filter/DuckDB/filter-2.duckdb | 7 + Task/Filter/DuckDB/filter-3.duckdb | 1 + Task/Filter/DuckDB/filter-4.duckdb | 1 + Task/Filter/DuckDB/filter-5.duckdb | 1 + Task/Filter/DuckDB/filter-6.duckdb | 2 + Task/Filter/DuckDB/filter-7.duckdb | 3 + Task/Filter/Elena/filter-1.elena | 2 +- Task/Filter/Elena/filter-2.elena | 2 +- Task/Filter/Pluto/filter.pluto | 5 + ...chess960-starting-position-identifier.easy | 61 +++ ...hess960-starting-position-identifier.basic | 2 +- ...hess960-starting-position-identifier.basic | 2 +- .../Ada/find-duplicate-files.ada | 128 +++++ .../FreeBASIC/find-duplicate-files.basic | 73 +++ ...ft-truncatable-prime-in-a-given-base.basic | 127 +++++ ...eft-truncatable-prime-in-a-given-base.rexx | 18 +- .../DuckDB/find-limit-of-recursion.duckdb | 11 + .../FutureBasic/find-limit-of-recursion.basic | 8 + .../REXX/find-limit-of-recursion-1.rexx | 11 - .../REXX/find-limit-of-recursion-2.rexx | 10 - .../REXX/find-limit-of-recursion.rexx | 13 + .../find-the-last-sunday-of-each-month.duckdb | 14 + .../Elena/first-class-functions.elena | 2 +- .../Five-weekends/DuckDB/five-weekends.duckdb | 19 + .../FutureBasic/five-weekends.basic | 54 ++ Task/Five-weekends/Red/five-weekends.red | 36 ++ .../DuckDB/fixed-length-records.duckdb | 10 + Task/FizzBuzz/ArkScript/fizzbuzz.ark | 12 + Task/FizzBuzz/Gleam/fizzbuzz.gleam | 10 +- Task/FizzBuzz/J/fizzbuzz-1.j | 2 +- Task/FizzBuzz/J/fizzbuzz-10.j | 38 +- Task/FizzBuzz/J/fizzbuzz-11.j | 36 -- Task/FizzBuzz/J/fizzbuzz-3.j | 2 +- Task/FizzBuzz/J/fizzbuzz-4.j | 2 +- Task/FizzBuzz/J/fizzbuzz-5.j | 6 +- Task/FizzBuzz/J/fizzbuzz-6.j | 7 +- Task/FizzBuzz/J/fizzbuzz-7.j | 8 +- Task/FizzBuzz/J/fizzbuzz-8.j | 7 +- Task/FizzBuzz/J/fizzbuzz-9.j | 3 +- Task/FizzBuzz/Pascal-P/fizzbuzz.pas | 14 + Task/FizzBuzz/Pluto/fizzbuzz.pluto | 11 + Task/FizzBuzz/Rhombus/fizzbuzz.rhombus | 8 + Task/FizzBuzz/Uiua/fizzbuzz.uiua | 2 +- Task/FizzBuzz/Vyxal/fizzbuzz.vyxal | 1 + .../ArkScript/flatten-a-list.ark | 13 + .../DuckDB/flatten-a-list.duckdb | 9 + .../FutureBasic/flipping-bits-game.basic | 2 +- .../Flipping-bits-game/R/flipping-bits-game.r | 59 +++ .../Dart/floyd-warshall-algorithm.dart | 54 ++ .../Erlang/floyd-warshall-algorithm.erl | 54 ++ .../Pluto/floyd-warshall-algorithm.pluto | 51 ++ .../R/floyd-warshall-algorithm.r | 67 +++ .../Swift/floyd-warshall-algorithm.swift | 51 ++ .../DuckDB/formatted-numeric-output.duckdb | 1 + .../Pluto/formatted-numeric-output.pluto | 1 + .../TAV/formatted-numeric-output.tav | 2 + .../DuckDB/forward-difference.duckdb | 16 + .../EasyLang/fraction-reduction.easy | 80 +++ Task/Fractran/R/fractran.r | 25 + Task/Fractran/Rust/fractran.rs | 75 +++ .../EasyLang/french-republican-calendar.easy | 99 ++++ .../Fortran/french-republican-calendar.f | 338 +++++++++++++ .../ArkScript/function-definition.ark | 2 + .../DuckDB/function-definition-1.duckdb | 1 + .../DuckDB/function-definition-2.duckdb | 10 + .../Pluto/function-definition.pluto | 5 + .../EasyLang/function-prototype.easy | 31 ++ .../FuncSug/gui-component-interaction.funcsug | 26 + ...gui-enabling-disabling-of-controls.funcsug | 30 ++ .../DuckDB/gamma-function.duckdb | 30 ++ .../FutureBasic/gamma-function.basic | 35 ++ .../Gamma-function/Pluto/gamma-function.pluto | 12 + Task/Gamma-function/REXX/gamma-function.rexx | 15 +- .../DuckDB/gapful-numbers.duckdb | 32 ++ .../EasyLang/gaussian-elimination.easy | 26 +- .../FutureBasic/gaussian-elimination.basic | 106 ++++ ...enerate-lower-case-ascii-alphabet-1.duckdb | 2 + ...enerate-lower-case-ascii-alphabet-2.duckdb | 1 + .../generate-lower-case-ascii-alphabet.pluto | 4 + ...tial.icon => generator-exponential-1.icon} | 0 .../Icon/generator-exponential-2.icon | 9 + .../Tcl/generator-exponential-3.tcl | 2 +- Task/Generic-swap/DuckDB/generic-swap.duckdb | 5 + Task/Giuga-numbers/Agena/giuga-numbers.agena | 26 + .../Giuga-numbers/EasyLang/giuga-numbers.easy | 8 +- Task/Giuga-numbers/Pluto/giuga-numbers.pluto | 28 ++ Task/Giuga-numbers/R/giuga-numbers.r | 16 + .../Agena/goldbachs-comet.agena | 22 + .../Fennel/goldbachs-comet.fennel | 49 ++ Task/Goldbachs-comet/Lua/goldbachs-comet.lua | 6 +- .../Pluto/goldbachs-comet.pluto | 23 + .../DuckDB/golden-ratio-convergence.duckdb | 24 + Task/Gotchas/DuckDB/gotchas-1.duckdb | 1 + Task/Gotchas/DuckDB/gotchas-2.duckdb | 2 + Task/Gotchas/DuckDB/gotchas-3.duckdb | 1 + Task/Gotchas/DuckDB/gotchas-4.duckdb | 3 + Task/Gotchas/DuckDB/gotchas-5.duckdb | 1 + Task/Gotchas/DuckDB/gotchas-6.duckdb | 2 + Task/Gotchas/DuckDB/gotchas-7.duckdb | 3 + Task/Gotchas/DuckDB/gotchas-8.duckdb | 2 + Task/Gray-code/Zig/gray-code.zig | 64 +++ .../DuckDB/greatest-common-divisor.duckdb | 12 + .../Pluto/greatest-common-divisor.pluto | 8 + .../ALGOL-68/greatest-element-of-a-list.alg | 21 +- .../greatest-element-of-a-list-1.duckdb | 1 + .../greatest-element-of-a-list-2.duckdb | 1 + .../greatest-element-of-a-list-3.duckdb | 4 + .../Pluto/greatest-element-of-a-list.pluto | 2 + .../TAV/greatest-element-of-a-list.tav | 4 + .../DuckDB/greatest-subsequential-sum.duckdb | 32 ++ .../greedy-algorithm-for-egyptian-fractions.r | 46 ++ .../EasyLang/greyscale-bars-display.easy | 6 +- ...ess-the-number-with-feedback-player-.basic | 95 ++++ .../guess-the-number-with-feedback.rhombus | 49 ++ .../TAV/guess-the-number-with-feedback.tav | 42 ++ .../Guess-the-number/Tcl/guess-the-number.tcl | 2 +- Task/HTTP/DuckDB/http.duckdb | 4 + .../DuckDB/https-authenticated.duckdb | 15 + .../Objeck/https-client-authenticated.objeck | 7 + Task/HTTPS/DuckDB/https.duckdb | 4 + Task/HTTPS/TAV/https.tav | 4 + .../DuckDB/hailstone-sequence.duckdb | 27 + .../Pluto/hailstone-sequence.pluto | 26 + .../Pluto/halt-and-catch-fire.pluto | 1 + .../TAV/halt-and-catch-fire.tav | 1 + .../FutureBasic/hamming-numbers.basic | 42 ++ Task/Happy-numbers/00-META.yaml | 2 +- Task/Happy-numbers/Frink/happy-numbers.frink | 19 + ...appy-numbers.rexx => happy-numbers-1.rexx} | 0 Task/Happy-numbers/REXX/happy-numbers-2.rexx | 42 ++ Task/Harmonic-series/Ada/harmonic-series.ada | 41 ++ .../DuckDB/harmonic-series.duckdb | 21 + .../Common-Lisp/hash-from-two-arrays-3.lisp | 3 + .../DuckDB/hash-from-two-arrays.duckdb | 4 + .../EasyLang/hash-from-two-arrays.easy | 38 ++ .../Maxima/hash-from-two-arrays.maxima | 5 + .../Pluto/hash-from-two-arrays.pluto | 5 + .../Tcl/hash-from-two-arrays-2.tcl | 33 +- .../Tcl/hash-from-two-arrays-3.tcl | 10 + ...wo-arrays.sh => hash-from-two-arrays-1.sh} | 2 +- .../UNIX-Shell/hash-from-two-arrays-2.sh | 9 + Task/Hash-join/DuckDB/hash-join.duckdb | 21 + .../DuckDB/haversine-formula.duckdb | 7 + .../TAV/hello-world-graphical.tav | 16 + .../ArkScript/hello-world-line-printer.ark | 1 + .../RISC-V-Assembly/hello-world-newbie.asm | 59 +++ .../hello-world-newline-omission.ark | 1 + .../Pluto/hello-world-newline-omission.pluto | 1 + .../Prolog/hello-world-newline-omission.pro | 1 + .../Pluto/hello-world-standard-error.pluto | 1 + .../Adina/hello-world-text-1.adina | 1 + .../Adina/hello-world-text-2.adina | 2 + .../Aria/hello-world-text.aria | 3 + .../ArkScript/hello-world-text.ark | 1 + .../AutoLISP/hello-world-text.l | 2 +- .../DuckDB/hello-world-text.duckdb | 5 + .../hello-world-text.basic | 1 + .../FuncSug/hello-world-text-1.funcsug | 1 + .../FuncSug/hello-world-text-2.funcsug | 1 + .../Hello-world-Text/Nom/hello-world-text.num | 1 + .../Pico-8/hello-world-text-1.pico8 | 1 + .../Pico-8/hello-world-text-2.pico8 | 1 + .../Pluto/hello-world-text.pluto | 1 + .../Rhombus/hello-world-text.rhombus | 1 + .../Hello-world-Text/TAV/hello-world-text.tav | 3 + .../DuckDB/here-document-1.duckdb | 6 + .../DuckDB/here-document-2.duckdb | 4 + Task/Hex-words/R/hex-words.r | 12 +- .../Pluto/higher-order-functions.pluto | 2 + .../Hilbert-curve/EasyLang/hilbert-curve.easy | 9 +- .../hofstadter-figure-figure-sequences.f | 194 +++++++ Task/Home-primes/REXX/home-primes.rexx | 12 +- Task/Honeycombs/EasyLang/honeycombs.easy | 101 ++++ ...rners-rule-for-polynomial-evaluation.agena | 15 + ...ners-rule-for-polynomial-evaluation.fennel | 17 + ...rners-rule-for-polynomial-evaluation.pluto | 15 + ...ners-rule-for-polynomial-evaluation-2.rexx | 10 +- .../ALGOL-68/humble-numbers.alg | 8 +- .../Humble-numbers/Agena/humble-numbers.agena | 32 ++ Task/Humble-numbers/Fortran/humble-numbers.f | 81 +++ .../Humble-numbers/Pluto/humble-numbers.pluto | 31 ++ Task/Humble-numbers/R/humble-numbers.r | 16 + Task/Humble-numbers/Rust/humble-numbers.rs | 51 ++ .../EasyLang/hunt-the-wumpus.easy | 92 ++++ .../Liberty-BASIC/hunt-the-wumpus.basic | 272 ++++++++++ .../Hunt-the-Wumpus/Mojo/hunt-the-wumpus.mojo | 203 ++++++++ .../Apple/isbn13-check-digit.apple | 1 + .../DuckDB/isbn13-check-digit.duckdb | 17 + .../Prolog/isbn13-check-digit-1.pro | 12 + .../Prolog/isbn13-check-digit-2.pro | 11 + .../Prolog/isbn13-check-digit-3.pro | 12 + .../Prolog/isbn13-check-digit-4.pro | 12 + .../DuckDB/identity-matrix.duckdb | 20 + ...acters-that-can-be-used-for-symbols.duckdb | 27 + ...the-lowercase-and-uppercase-letters.duckdb | 19 + .../RISC-V-Assembly/include-a-file-1.asm | 8 + .../RISC-V-Assembly/include-a-file-2.asm | 152 ++++++ .../RISC-V-Assembly/include-a-file-3.asm | 44 ++ .../increment-a-numerical-string-1.duckdb | 1 + .../increment-a-numerical-string-2.duckdb | 1 + .../increment-a-numerical-string-3.duckdb | 1 + .../Pluto/increment-a-numerical-string.pluto | 4 + Task/Infinity/ArkScript/infinity.ark | 3 + Task/Infinity/DuckDB/infinity.duckdb | 1 + Task/Infinity/Pluto/infinity.pluto | 8 + .../V-(Vlang)/inheritance-multiple.v | 38 ++ .../Rhombus/inheritance-single.rhombus | 17 + .../V-(Vlang)/inheritance-single.v | 36 ++ Task/Input-loop/Nom/input-loop.num | 1 + .../DuckDB/integer-comparison.duckdb | 8 + .../Prolog/integer-comparison-1.pro | 14 + .../Prolog/integer-comparison-2.pro | 7 + .../YAMLScript/integer-comparison.ys | 8 + .../ArkScript/integer-sequence-1.ark | 4 + .../ArkScript/integer-sequence-2.ark | 5 + .../Introspection/DuckDB/introspection.duckdb | 10 + .../DuckDB/inverted-index.duckdb | 25 + .../DuckDB/inverted-syntax-1.duckdb | 1 + .../DuckDB/inverted-syntax-2.duckdb | 1 + .../DuckDB/inverted-syntax-3.duckdb | 1 + .../REXX/isqrt-integer-square-root-of-x.rexx | 9 +- .../Prolog/iterated-digits-squaring.pro | 36 ++ Task/JSON/Agena/json.agena | 28 ++ Task/JSON/DuckDB/json-1.duckdb | 1 + Task/JSON/DuckDB/json-2.duckdb | 1 + Task/JSON/DuckDB/json-3.duckdb | 1 + Task/JSON/Pluto/json.pluto | 30 ++ Task/JSON/REBOL/{json.rebol => json-1.rebol} | 4 +- Task/JSON/REBOL/json-2.rebol | 16 + Task/Jacobi-symbol/Excel/jacobi-symbol.excel | 34 ++ .../ALGOL-68/jacobsthal-numbers.alg | 2 +- .../Agena/jacobsthal-numbers.agena | 50 ++ .../EasyLang/jacobsthal-numbers.easy | 50 ++ .../Fennel/jacobsthal-numbers.fennel | 64 +++ .../Lua/jacobsthal-numbers.lua | 65 +++ .../Pluto/jacobsthal-numbers.pluto | 50 ++ .../DuckDB/jaro-similarity.duckdb | 6 + .../Agena/jewels-and-stones.agena | 10 + .../Fortran/jewels-and-stones.f | 90 ++++ .../Icon/jewels-and-stones.icon | 10 + .../Lua/jewels-and-stones.lua | 3 +- .../Pluto/jewels-and-stones.pluto | 12 + Task/JortSort/YAMLScript/jortsort.ys | 8 + .../OxygenBasic/josephus-problem.basic | 20 + .../Pluto/josephus-problem.pluto | 34 ++ .../Prolog/josephus-problem-1.pro | 15 + .../Prolog/josephus-problem-2.pro | 5 + .../QBasic/josephus-problem.basic | 16 +- ...problem-1.basic => josephus-problem.basic} | 0 .../Run-BASIC/josephus-problem-1.basic | 16 + .../josephus-problem-2.basic | 0 .../Wren/josephus-problem.wren | 2 +- .../XBasic/josephus-problem.basic | 21 + Task/Julia-set/EasyLang/julia-set.easy | 2 +- Task/Jump-anywhere/Koka/jump-anywhere.koka | 40 ++ Task/K-d-tree/Elixir/k-d-tree.ex | 262 ++++++++++ Task/K-d-tree/Swift/k-d-tree.swift | 203 ++++++++ Task/K-d-tree/Zig/k-d-tree.zig | 358 +++++++++++++ .../ALGOL-68/kaprekar-numbers.alg | 3 + .../Agena/kaprekar-numbers.agena | 42 ++ .../Pluto/kaprekar-numbers.pluto | 43 ++ .../Zig/knapsack-problem-0-1.zig | 109 ++++ .../Ada/knapsack-problem-bounded.ada | 143 ++++++ .../Fortran/knapsack-problem-bounded.f | 184 +++++++ .../Lua/knapsack-problem-bounded.lua | 180 +++++++ .../Rust/knapsack-problem-bounded.rs | 99 ++++ .../ALGOL-68/knapsack-problem-continuous.alg | 24 + .../ALGOL-W/knapsack-problem-continuous.alg | 38 ++ Task/Knights-tour/EasyLang/knights-tour.easy | 7 +- Task/Knights-tour/Zig/knights-tour.zig | 128 +++++ .../Knuth-shuffle/DuckDB/knuth-shuffle.duckdb | 63 +++ .../Knuth-shuffle/REBOL/knuth-shuffle-1.rebol | 4 + .../Knuth-shuffle/REBOL/knuth-shuffle-2.rebol | 48 ++ Task/Knuth-shuffle/REBOL/knuth-shuffle.rebol | 18 - .../Knuth-shuffle/YAMLScript/knuth-shuffle.ys | 8 + .../Fortran/knuths-power-tree.f | 379 ++++++++++++++ ...s-power-tree.py => knuths-power-tree-1.py} | 0 .../Python/knuths-power-tree-2.py | 57 +++ Task/Koch-curve/EasyLang/koch-curve.easy | 14 +- .../largest-int-from-concatenated-ints.duckdb | 18 + .../AutoLISP/largest-proper-divisor-of-n.l | 22 + .../C++/last-friday-of-each-month-3.cpp | 11 + .../DuckDB/last-friday-of-each-month.duckdb | 14 + .../last-letter-first-letter.basic | 88 ++++ Task/Leap-year/DuckDB/leap-year.duckdb | 2 + Task/Leap-year/Pluto/leap-year.pluto | 7 + .../DuckDB/left-factorials.duckdb | 43 ++ .../DuckDB/leonardo-numbers.duckdb | 27 + .../Pascal-P/leonardo-numbers.pas | 31 ++ .../DuckDB/letter-frequency-1.duckdb | 8 + .../DuckDB/letter-frequency-2.duckdb | 7 + .../Koka/letter-frequency.koka | 20 + .../Letter-frequency/TAV/letter-frequency.tav | 11 + .../Ada/levenshtein-distance-alignment.ada | 88 ++++ .../DuckDB/levenshtein-distance.duckdb | 5 + .../Pascal-P/levenshtein-distance.pas | 81 +++ .../DuckDB/list-comprehensions-1.duckdb | 7 + .../DuckDB/list-comprehensions-2.duckdb | 6 + .../DuckDB/list-comprehensions-3.duckdb | 4 + .../DuckDB/list-comprehensions-4.duckdb | 5 + .../DuckDB/list-comprehensions-5.duckdb | 1 + .../PascalABC.NET/list-comprehensions.pas | 2 +- .../ArkScript/literals-floating-point.ark | 3 + .../Pluto/literals-floating-point.pluto | 4 + .../REXX/literals-floating-point.rexx | 6 +- .../ArkScript/literals-integer.ark | 4 + .../DuckDB/literals-integer.duckdb | 1 + .../Pluto/literals-integer.pluto | 4 + .../ArkScript/literals-string.ark | 4 + .../ArkScript/logical-operations.ark | 9 + .../DuckDB/logical-operations.duckdb | 22 + .../Red/logical-operations.red | 14 + .../Ada/long-literals-with-continuations.ada | 34 ++ .../F-Sharp/long-multiplication.fs | 3 - Task/Long-primes/REXX/long-primes.rexx | 12 +- .../ALGOL-68/longest-common-subsequence.alg | 31 +- .../Ada/longest-increasing-subsequence.ada | 51 ++ .../longest-increasing-subsequence.duckdb | 31 ++ ...-over-multiple-arrays-simultaneously.pluto | 6 + ...-over-multiple-arrays-simultaneously.rebol | 10 + ...op-over-multiple-arrays-simultaneously.tav | 15 + Task/Loops-Break/DuckDB/loops-break.duckdb | 22 + Task/Loops-Break/Koka/loops-break.koka | 12 + Task/Loops-Break/Pluto/loops-break.pluto | 6 + Task/Loops-Break/TAV/loops-break-1.tav | 7 + Task/Loops-Break/TAV/loops-break-2.tav | 7 + Task/Loops-Break/Ursalang/loops-break.ursa | 12 + .../{loops-break.zig => loops-break-1.zig} | 0 Task/Loops-Break/Zig/loops-break-2.zig | 25 + .../Loops-Continue/Pluto/loops-continue.pluto | 8 + ...-continue.rebol => loops-continue-1.rebol} | 2 +- .../REBOL/loops-continue-2.rebol | 8 + .../DuckDB/loops-do-while.duckdb | 16 + .../Loops-Do-while/Pluto/loops-do-while.pluto | 4 + Task/Loops-Do-while/TAV/loops-do-while-1.tav | 6 + Task/Loops-Do-while/TAV/loops-do-while-2.tav | 6 + .../DuckDB/loops-downward-for-1.duckdb | 1 + .../DuckDB/loops-downward-for-2.duckdb | 14 + .../Pluto/loops-downward-for.pluto | 2 + .../TAV/loops-downward-for.tav | 6 + .../loops-for-with-a-specified-step-1.duckdb | 3 + .../loops-for-with-a-specified-step-2.duckdb | 8 + .../loops-for-with-a-specified-step.pluto | 2 + .../loops-for-with-a-specified-step.rebol | 3 +- Task/Loops-For/Adina/loops-for-1.adina | 6 + Task/Loops-For/Adina/loops-for-2.adina | 7 + Task/Loops-For/DuckDB/loops-for-1.duckdb | 3 + Task/Loops-For/DuckDB/loops-for-2.duckdb | 3 + Task/Loops-For/DuckDB/loops-for-3.duckdb | 3 + Task/Loops-For/Eiffel/loops-for.e | 17 + .../Extended-Color-BASIC/loops-for.basic | 6 + Task/Loops-For/Pluto/loops-for.pluto | 4 + Task/Loops-For/TAV/loops-for-1.tav | 4 + Task/Loops-For/TAV/loops-for-2.tav | 2 + Task/Loops-For/TAV/loops-for-3.tav | 4 + Task/Loops-Foreach/Pluto/loops-foreach.pluto | 6 + Task/Loops-Foreach/REBOL/loops-foreach.rebol | 8 +- ...-increment-loop-index-within-loop-body.arm | 18 +- ...crement-loop-index-within-loop-body.arturo | 16 +- ...-increment-loop-index-within-loop-body.ahk | 26 +- ...ncrement-loop-index-within-loop-body.basic | 24 +- ...-increment-loop-index-within-loop-body.cpp | 22 +- ...increment-loop-index-within-loop-body.lisp | 12 +- ...crement-loop-index-within-loop-body.duckdb | 33 ++ ...increment-loop-index-within-loop-body.icon | 2 +- ...-increment-loop-index-within-loop-body.ksh | 30 +- ...ent-loop-index-within-loop-body.lambdatalk | 84 ++-- ...ncrement-loop-index-within-loop-body.maple | 12 +- ...ncrement-loop-index-within-loop-body.pluto | 27 + ...ncrement-loop-index-within-loop-body.rebol | 50 ++ Task/Loops-Infinite/Eiffel/loops-infinite.e | 11 + .../Loops-Infinite/Pluto/loops-infinite.pluto | 1 + ...-infinite.rebol => loops-infinite-1.rebol} | 0 .../REBOL/loops-infinite-2.rebol | 1 + .../REBOL/loops-infinite-3.rebol | 1 + Task/Loops-Infinite/TAV/loops-infinite.tav | 2 + .../DuckDB/loops-n-plus-one-half.duckdb | 14 + .../Pluto/loops-n-plus-one-half.pluto | 4 + .../TAV/loops-n-plus-one-half-1.tav | 6 + .../TAV/loops-n-plus-one-half-2.tav | 6 + Task/Loops-Nested/DuckDB/loops-nested.duckdb | 50 ++ Task/Loops-Nested/Pluto/loops-nested.pluto | 18 + Task/Loops-Nested/REBOL/loops-nested.rebol | 2 +- Task/Loops-Nested/Zig/loops-nested.zig | 38 ++ Task/Loops-While/DuckDB/loops-while.duckdb | 15 + Task/Loops-While/Mn/loops-while.mn | 6 + Task/Loops-While/Pluto/loops-while.pluto | 5 + Task/Loops-While/REBOL/loops-while.rebol | 2 +- Task/Loops-While/TAV/loops-while.tav | 4 + Task/Loops-While/Ursalang/loops-while.ursa | 6 + Task/Loops-While/Zig/loops-while.zig | 11 +- .../DuckDB/loops-with-multiple-ranges.duckdb | 32 ++ ...ges.hs => loops-with-multiple-ranges-1.hs} | 0 .../Haskell/loops-with-multiple-ranges-2.hs | 30 ++ .../Haskell/loops-with-multiple-ranges-3.hs | 27 + .../Pluto/loops-with-multiple-ranges.pluto | 60 +++ .../REBOL/loops-with-multiple-ranges.rebol | 59 +++ .../C++/loops-wrong-ranges.cpp | 60 +-- .../Common-Lisp/loops-wrong-ranges.lisp | 34 +- .../Eiffel/loops-wrong-ranges.e | 24 +- .../Icon/loops-wrong-ranges.icon | 39 ++ .../Pluto/loops-wrong-ranges.pluto | 19 + .../Python/loops-wrong-ranges.py | 20 +- .../REBOL/loops-wrong-ranges.rebol | 30 ++ .../luhn-test-of-credit-card-numbers.duckdb | 43 ++ .../luhn-test-of-credit-card-numbers.pluto | 22 + .../C-sharp/m-bius-function.cs | 84 ++++ .../Pascal-P/m-bius-function.pas | 39 ++ .../Pluto/m-bius-function.pluto | 35 ++ .../PowerShell/m-bius-function.psh | 28 ++ Task/M-bius-function/R/m-bius-function.r | 28 ++ Task/M-bius-function/Tcl/m-bius-function.tcl | 42 ++ Task/M-bius-function/Zig/m-bius-function.zig | 84 ++++ Task/MD5/DuckDB/md5.duckdb | 1 + Task/MD5/JavaScript/md5.js | 149 ++++++ Task/MD5/REBOL/md5-1.rebol | 2 + Task/MD5/REBOL/md5-2.rebol | 2 + Task/MD5/REBOL/md5.rebol | 2 - Task/Machine-code/Ada/machine-code.ada | 68 +++ Task/Machine-code/Pluto/machine-code-1.pluto | 23 + Task/Machine-code/Pluto/machine-code-2.pluto | 19 + Task/Magic-8-ball/Prolog/magic-8-ball.pro | 13 + .../Pascal-P/magic-constant.pas | 35 ++ .../magic-squares-of-doubly-even-order.objeck | 43 ++ .../magic-squares-of-doubly-even-order.pluto | 29 ++ .../Pluto/magic-squares-of-odd-order.pluto | 28 ++ .../magic-squares-of-singly-even-order.pluto | 73 +++ .../Zig/main-step-of-gost-28147-89.zig | 218 ++++++++ .../EasyLang/mandelbrot-set.easy | 2 +- Task/Mandelbrot-set/Julia/mandelbrot-set-3.jl | 2 +- Task/Mandelbrot-set/Julia/mandelbrot-set-4.jl | 41 -- Task/Mandelbrot-set/Julia/mandelbrot-set-5.jl | 41 -- Task/Mandelbrot-set/Julia/mandelbrot-set-6.jl | 39 -- Task/Mandelbrot-set/Julia/mandelbrot-set-7.jl | 71 --- .../Python/mandelbrot-set-10.py | 124 ++++- .../Python/mandelbrot-set-11.py | 8 + .../Python/mandelbrot-set-12.py | 5 + .../Mandelbrot-set/Python/mandelbrot-set-5.py | 22 +- .../Mandelbrot-set/Python/mandelbrot-set-6.py | 22 +- .../Mandelbrot-set/Python/mandelbrot-set-7.py | 39 +- .../Mandelbrot-set/Python/mandelbrot-set-8.py | 49 +- .../Mandelbrot-set/Python/mandelbrot-set-9.py | 93 +++- Task/Map-range/DuckDB/map-range.duckdb | 9 + Task/Map-range/Pascal-P/map-range.pas | 14 + .../DuckDB/matrix-multiplication-1.duckdb | 7 + .../DuckDB/matrix-multiplication-2.duckdb | 16 + .../DuckDB/matrix-multiplication-3.duckdb | 39 ++ .../Objeck/matrix-multiplication.objeck | 8 + .../DuckDB/matrix-transposition-1.duckdb | 1 + .../DuckDB/matrix-transposition-2.duckdb | 22 + .../DuckDB/matrix-transposition-3.duckdb | 5 + Task/Mayan-calendar/Rust/mayan-calendar.rs | 121 +++++ .../FutureBasic/mayan-numerals.basic | 117 +++++ .../Fortran/mcnuggets-problem.f | 64 +++ .../JavaScript/meissel-mertens-constant.js | 135 +++++ .../REXX/meissel-mertens-constant.rexx | 23 +- .../Rust/meissel-mertens-constant.rs | 39 ++ .../merge-and-aggregate-datasets.duckdb | 32 ++ .../DuckDB/metallic-ratios-1.duckdb | 5 + .../DuckDB/metallic-ratios-2.duckdb | 24 + .../DuckDB/metallic-ratios-3.duckdb | 28 ++ .../V-(Vlang)/metaprogramming.v | 30 ++ .../Agena/mian-chowla-sequence.agena | 31 ++ .../Pluto/mian-chowla-sequence.pluto | 35 ++ .../DuckDB/middle-three-digits.duckdb | 22 + .../Haskell/miller-rabin-primality-test-3.hs | 15 + .../Liberty-BASIC/minesweeper-game.basic | 422 ++++++++++++++++ .../Ada/minimal-steps-down-to-1.ada | 108 ++++ Task/Modular-arithmetic/00-TASK.txt | 9 +- ...thmetic.lisp => modular-arithmetic-1.lisp} | 0 .../Common-Lisp/modular-arithmetic-2.lisp | 25 + .../Rust/modular-arithmetic.rs | 177 +++++++ .../Zig/modular-arithmetic.zig | 94 ++++ .../FutureBasic/modular-inverse.basic | 10 + .../Pluto/modular-inverse.pluto | 5 + Task/Modular-inverse/Zig/modular-inverse.zig | 29 ++ .../Koka/monads-writer-monad.koka | 47 ++ .../APL/monte-carlo-methods.apl | 1 + .../C++/monte-carlo-methods.cpp | 46 +- .../DuckDB/monte-carlo-methods.duckdb | 20 + .../FutureBasic/monte-carlo-methods.basic | 48 ++ .../SETL/monte-carlo-methods.setl | 21 + .../Motzkin-numbers/REXX/motzkin-numbers.rexx | 9 +- .../REXX/multi-base-primes.rexx | 13 +- .../BBC-BASIC/multi-dimensional-array-1.basic | 29 ++ .../BBC-BASIC/multi-dimensional-array-2.basic | 15 + .../Rust/multiple-regression.rs | 270 ++++++++++ .../Agena/multiplication-tables.agena | 5 +- .../Pluto/multiplication-tables.pluto | 13 + .../TAV/multiplication-tables.tav | 10 + .../F-Sharp/multiplicative-order.fs | 8 + Task/Munchausen-numbers/00-META.yaml | 1 + .../ArkScript/munchausen-numbers.ark | 30 ++ .../Munchausen-numbers/R/munchausen-numbers.r | 7 +- .../EasyLang/munching-squares.easy | 4 +- .../YAMLScript/munching-squares.ys | 14 + Task/Musical-scale/Java/musical-scale.java | 2 +- Task/Mutex/FutureBasic/mutex.basic | 19 + .../Pluto/mutual-recursion.pluto | 10 + .../ArkScript/n-queens-problem.ark | 32 ++ .../FutureBasic/named-parameters.basic | 9 + .../Icon/named-parameters.icon | 2 +- .../Pluto/named-parameters.pluto | 7 + .../Ada/naming-conventions-1.ada | 8 + .../Ada/naming-conventions-2.ada | 3 + .../Ada/naming-conventions-3.ada | 3 + .../ALGOL-68/narcissistic-decimal-number.alg | 88 ++-- .../Agena/narcissistic-decimal-number.agena | 10 +- ....lua => narcissistic-decimal-number-1.lua} | 0 .../Lua/narcissistic-decimal-number-2.lua | 59 +++ .../Pluto/narcissistic-decimal-number.pluto | 50 ++ .../DuckDB/nested-function.duckdb | 12 + .../Pluto/nested-templated-data.pluto | 20 + .../next-highest-int-from-digits.ys | 44 ++ .../Fortran/non-decimal-radices-convert.f | 5 +- .../Pluto/non-decimal-radices-convert.pluto | 7 + .../REXX/non-decimal-radices-convert.rexx | 14 +- Task/Nth-root/DuckDB/nth-root.duckdb | 20 + Task/Nth/DuckDB/nth.duckdb | 26 + Task/Null-object/ArkScript/null-object.ark | 5 + Task/Null-object/Tcl/null-object-2.tcl | 10 +- Task/Null-object/Tcl/null-object-3.tcl | 2 + Task/Null-object/Tcl/null-object-4.tcl | 5 + ...integration-gauss-legendre-quadrature-1.py | 188 +++---- ...tegration-gauss-legendre-quadrature-2.rexx | 30 +- .../Pluto/numerical-integration.pluto | 20 + .../REXX/numerical-integration.rexx | 62 ++- Task/OLE-automation/Julia/ole-automation.jl | 34 ++ .../C++/object-serialization.cpp | 16 +- .../EchoLisp/object-serialization-1.l | 10 +- .../Erlang/object-serialization.erl | 32 +- .../Objective-C/object-serialization.m | 18 +- .../Python/object-serialization.py | 12 +- .../REBOL/object-serialization.rebol | 84 ++++ .../Odd-word-problem/Nom/odd-word-problem.num | 23 + .../old-russian-measure-of-length.basic | 47 ++ .../ASIC/old-russian-measure-of-length.asic | 65 +++ .../old-russian-measure-of-length.basic | 2 +- .../Delphi/old-russian-measure-of-length.pas | 2 +- .../old-russian-measure-of-length.easy | 2 +- .../old-russian-measure-of-length.basic | 4 +- .../old-russian-measure-of-length.basic | 35 ++ .../old-russian-measure-of-length.gambas | 2 +- .../Go/old-russian-measure-of-length.go | 4 +- .../Kotlin/old-russian-measure-of-length.kts | 4 +- .../old-russian-measure-of-length.basic | 31 ++ .../Pluto/old-russian-measure-of-length.pluto | 35 ++ .../old-russian-measure-of-length-1.pro | 101 ++++ .../old-russian-measure-of-length-2.pro | 19 + .../old-russian-measure-of-length.basic | 2 +- .../R/old-russian-measure-of-length.r | 5 +- .../Ring/old-russian-measure-of-length.ring | 4 +- .../old-russian-measure-of-length.basic | 2 +- .../Wren/old-russian-measure-of-length.wren | 6 +- .../old-russian-measure-of-length.basic | 8 +- .../XPL0/old-russian-measure-of-length.xpl0 | 4 +- .../old-russian-measure-of-length.basic | 4 +- .../one-dimensional-cellular-automata.ys | 17 + .../DuckDB/one-of-n-lines-in-a-file.duckdb | 4 + .../Pluto/order-by-pair-comparisons.pluto | 37 ++ .../Prolog/order-by-pair-comparisons-1.pro | 12 + .../Prolog/order-by-pair-comparisons-2.pro | 15 + .../DuckDB/order-two-numerical-lists.duckdb | 3 + .../Ordered-words/DuckDB/ordered-words.duckdb | 20 + Task/Ordered-words/TAV/ordered-words.tav | 20 + .../Scheme/own-digits-power-sum.scm | 46 ++ ...ovan-sequence.jl => padovan-sequence-1.jl} | 2 +- .../Julia/padovan-sequence-2.jl | 1 + .../Phix/padovan-sequence-2.phix | 88 ++-- .../Phix/padovan-sequence-3.phix | 165 ++---- .../Phix/padovan-sequence-4.phix | 136 +++++ .../ALGOL-68/palindrome-detection.alg | 5 +- .../DuckDB/palindrome-detection.duckdb | 31 ++ .../Pluto/palindrome-detection.pluto | 7 + .../Free-Pascal-Lazarus/pancake-numbers.pas | 31 ++ ...-numbers.basic => pancake-numbers-1.basic} | 0 .../FreeBASIC/pancake-numbers-2.basic | 105 ++++ .../Julia/pancake-numbers-1.jl | 14 - ...ancake-numbers-2.jl => pancake-numbers.jl} | 0 .../Phix/pancake-numbers-4.phix | 90 ++++ .../Pluto/pancake-numbers-1.pluto | 22 + .../Pluto/pancake-numbers-2.pluto | 63 +++ .../Pluto/pancake-numbers-3.pluto | 51 ++ .../Pluto/pancake-numbers-4.pluto | 55 ++ .../Pancake-numbers/Ruby/pancake-numbers-1.rb | 26 + .../Pancake-numbers/Ruby/pancake-numbers-2.rb | 22 + Task/Pancake-numbers/Ruby/pancake-numbers.rb | 19 - .../Wren/pancake-numbers-1.wren | 11 +- .../Wren/pancake-numbers-3.wren | 86 ++++ .../Wren/pancake-numbers-4.wren | 91 ++++ .../DuckDB/parameterized-sql-statement.duckdb | 17 + .../Dart/parse-an-ip-address.dart | 128 +++++ .../Elixir/parse-an-ip-address.ex | 83 +++ .../Fortran/parse-an-ip-address.f | 320 ++++++++++++ .../JavaScript/parse-an-ip-address.js | 123 +++++ .../Mathematica/parse-an-ip-address.math | 100 ++++ .../OCaml/parse-an-ip-address.ml | 192 +++++++ .../R/parse-an-ip-address.r | 127 +++++ ...ip-address.rs => parse-an-ip-address-1.rs} | 0 .../Rust/parse-an-ip-address-2.rs | 354 +++++++++++++ .../Swift/parse-an-ip-address.swift | 187 +++++++ .../Zig/parse-an-ip-address.zig | 238 +++++++++ .../parsing-rpn-calculator-algorithm.cr | 26 + .../parsing-rpn-calculator-algorithm.pluto | 33 ++ .../Red/parsing-rpn-calculator-algorithm.red | 21 + .../Red/parsing-rpn-to-infix-conversion.red | 58 +++ .../Red/parsing-shunting-yard-algorithm.red | 90 ++++ .../EasyLang/pascals-triangle-puzzle.easy | 29 ++ .../Fortran/pascals-triangle-puzzle.f | 124 +++++ .../JavaScript/pascals-triangle-puzzle.js | 102 ++++ .../Pluto/pascals-triangle-puzzle.pluto | 19 + .../DuckDB/pascals-triangle.duckdb | 16 + .../pathological-floating-point-problems.alg | 35 +- ...athological-floating-point-problems-1.rexx | 15 - ...athological-floating-point-problems-2.rexx | 18 - ...athological-floating-point-problems-3.rexx | 13 - .../pathological-floating-point-problems.rexx | 51 ++ .../{pell-numbers.jl => pell-numbers-1.jl} | 0 Task/Pell-numbers/Julia/pell-numbers-2.jl | 2 + Task/Pell-numbers/PARI-GP/pell-numbers.parigp | 59 +++ Task/Perfect-numbers/00-TASK.txt | 2 +- .../FutureBasic/perfect-shuffle.basic | 81 +++ .../Pluto/perfect-shuffle.pluto | 45 ++ Task/Perlin-noise/EasyLang/perlin-noise.easy | 2 +- Task/Perlin-noise/Zig/perlin-noise.zig | 8 +- .../DuckDB/permutations-derangements.duckdb | 49 ++ .../Zig/permutations-by-swapping.zig | 50 ++ Task/Permutations/DuckDB/permutations.duckdb | 18 + Task/Permutations/Pluto/permutations.pluto | 6 + Task/Permutations/TAV/permutations-1.tav | 24 + Task/Permutations/TAV/permutations-2.tav | 28 ++ Task/Permutations/TAV/permutations-3.tav | 17 + Task/Permutations/TAV/permutations-4.tav | 44 ++ .../Agena/pernicious-numbers.agena | 32 ++ .../Pluto/pernicious-numbers.pluto | 38 ++ .../REXX/pernicious-numbers.rexx | 9 +- .../Prolog/phrase-reversals.pro | 20 + .../DuckDB/pick-random-element.duckdb | 9 + .../Pluto/pick-random-element.pluto | 4 + .../Scheme/pick-random-element.scm | 6 + ...-element.tcl => pick-random-element-1.tcl} | 0 .../Tcl/pick-random-element-2.tcl | 79 +++ .../Pierpont-primes/Python/pierpont-primes.py | 24 +- .../REXX/pierpont-primes-1.rexx | 11 +- .../REXX/pierpont-primes-2.rexx | 12 +- Task/Pisano-period/Agena/pisano-period.agena | 32 ++ Task/Pisano-period/Pluto/pisano-period.pluto | 42 ++ .../Plasma-effect/EasyLang/plasma-effect.easy | 4 +- .../FuncSug/play-recorded-sounds.funcsug | 30 ++ .../Raku/play-recorded-sounds.raku | 31 ++ .../EasyLang/plot-coordinate-pairs.easy | 10 +- .../M2000-Interpreter/polymorphism-1.m2000 | 6 - .../M2000-Interpreter/polymorphism-2.m2000 | 76 --- .../M2000-Interpreter/polymorphism-3.m2000 | 67 --- .../M2000-Interpreter/polymorphism.m2000 | 108 ++++ .../Rhombus/polymorphism-1.rhombus | 11 + .../Rhombus/polymorphism-2.rhombus | 13 + .../REXX/polynomial-long-division-2.rexx | 14 +- Task/Polyspiral/EasyLang/polyspiral.easy | 5 +- Task/Polyspiral/REBOL/polyspiral.rebol | 42 ++ .../Prolog/population-count.pro | 12 + Task/Power-set/Pluto/power-set.pluto | 9 + .../REXX/primality-by-wilsons-theorem.rexx | 12 +- .../ALGOL-68/primality-by-trial-division.alg | 20 +- .../Agena/primality-by-trial-division.agena | 13 + .../primality-by-trial-division-1.duckdb | 29 ++ .../primality-by-trial-division-2.duckdb | 18 + .../Pluto/primality-by-trial-division.pluto | 13 + .../REXX/primality-by-trial-division.rexx | 12 +- .../DuckDB/prime-decomposition.duckdb | 29 ++ .../OoRexx/prime-decomposition.rexx | 36 ++ .../Priority-queue/Pluto/priority-queue.pluto | 12 + .../DuckDB/probabilistic-choice.duckdb | 65 +++ .../EasyLang/problem-of-apollonius.easy | 5 +- .../ArkScript/program-termination.ark | 3 + .../DuckDB/proper-divisors.duckdb | 33 ++ ...random-numbers-middle-square-method.duckdb | 20 + .../EasyLang/pythagoras-tree.easy | 2 +- .../JavaScript/pythagoras-tree-2.js | 2 +- .../Quaternion-type/REXX/quaternion-type.rexx | 55 +- ...-definition.alg => queue-definition-1.alg} | 0 .../ALGOL-68/queue-definition-2.alg | 7 + .../YAMLScript/quickselect-algorithm.ys | 25 + Task/Quine/Extended-Color-BASIC/quine.basic | 1 + Task/Quine/REBOL/quine-1.rebol | 1 + Task/Quine/REBOL/quine-2.rebol | 14 + Task/Quine/REBOL/quine.rebol | 1 - .../Prolog/rpg-attributes-generator-1.pro | 16 + .../Prolog/rpg-attributes-generator-2.pro | 8 + .../Rust/ramanujan-primes-twins.rs | 121 +++++ .../REXX/ramanujans-constant.rexx | 7 +- ...er-douglas-peucker-line-simplification.pas | 94 ++++ .../REXX/random-number-generator-device-.rexx | 9 +- .../DuckDB/random-numbers.duckdb | 14 + Task/Random-numbers/REXX/random-numbers.rexx | 45 +- .../DuckDB/range-expansion.duckdb | 10 + .../DuckDB/range-extraction.duckdb | 43 ++ ...ead-a-file-character-by-character-utf8.ada | 21 + .../DuckDB/read-a-file-line-by-line.duckdb | 3 + .../Pluto/read-a-file-line-by-line-1.pluto | 8 + .../Pluto/read-a-file-line-by-line-2.pluto | 3 + .../read-a-specific-line-from-a-file.rebol | 4 +- .../ArkScript/read-entire-file.ark | 1 + .../real-constants-and-functions.maxima | 10 + .../TAV/real-constants-and-functions.tav | 13 + .../DuckDB/reflection-list-methods.duckdb | 14 + .../DuckDB/reflection-list-properties.duckdb | 1 + .../Maxima/regular-expressions.maxima | 5 + .../DuckDB/remove-duplicate-elements-1.duckdb | 1 + .../DuckDB/remove-duplicate-elements-2.duckdb | 1 + .../DuckDB/remove-duplicate-elements-3.duckdb | 6 + .../DuckDB/remove-duplicate-elements-4.duckdb | 1 + .../Rename-a-file/Maxima/rename-a-file.maxima | 5 + Task/Rename-a-file/Pluto/rename-a-file.pluto | 5 + Task/Rename-a-file/R/rename-a-file.r | 4 + Task/Rep-string/DuckDB/rep-string.duckdb | 36 ++ .../DuckDB/repeat-a-string-1.duckdb | 2 + .../DuckDB/repeat-a-string-2.duckdb | 1 + .../Pluto/repeat-a-string.pluto | 1 + Task/Repunit-primes/R/repunit-primes.r | 8 + .../R/retrieve-and-search-chat-history.r | 19 + .../DuckDB/return-multiple-values-1.duckdb | 4 + .../DuckDB/return-multiple-values-2.duckdb | 9 + .../ArkScript/reverse-a-string.ark | 3 + .../DuckDB/reverse-a-string.duckdb | 7 + .../Reverse-a-string/Nom/reverse-a-string.num | 1 + .../Pluto/reverse-a-string.pluto | 10 + .../Reverse-a-string/TAV/reverse-a-string.tav | 3 + .../reverse-words-in-a-string.pas | 32 +- .../Pluto/reverse-words-in-a-string.pluto | 16 + .../PascalABC.NET/roman-numerals-decode-1.pas | 49 +- .../Pluto/roman-numerals-encode.pluto | 3 + .../EasyLang/roots-of-a-function.easy | 7 +- .../Pluto/roots-of-a-quadratic-function.pluto | 44 ++ .../DuckDB/roots-of-unity.duckdb | 11 + .../Roots-of-unity/Pluto/roots-of-unity.pluto | 12 + .../Raku/rosetta-code-count-examples.raku | 2 +- ...rosetta-code-find-unimplemented-tasks.ring | 8 - ...a-code-rank-languages-by-popularity-1.raku | 2 +- Task/Rot-13/Crystal/rot-13.cr | 5 + Task/Rot-13/Lua/rot-13-1.lua | 2 + Task/Rot-13/Lua/rot-13-2.lua | 2 + Task/Rot-13/Pluto/rot-13.pluto | 14 + Task/Rot-13/Rhombus/rot-13.rhombus | 23 + Task/Rot-13/S-BASIC/rot-13.basic | 2 +- .../DuckDB/run-length-encoding-1.duckdb | 23 + .../DuckDB/run-length-encoding-2.duckdb | 1 + .../Pluto/runge-kutta-method.pluto | 30 ++ .../REXX/runge-kutta-method.rexx | 77 ++- .../Python/ruth-aaron-numbers.py | 104 ++++ Task/SEDOLs/Prolog/sedols-1.pro | 40 ++ Task/SEDOLs/Prolog/sedols-2.pro | 5 + Task/SEDOLs/Prolog/sedols-3.pro | 21 + Task/SHA-1/C++/sha-1-2.cpp | 100 ++-- Task/SHA-1/Hare/sha-1.hare | 12 +- Task/SHA-1/Haxe/sha-1.haxe | 2 +- Task/SHA-1/Java/sha-1.java | 114 ++--- Task/SHA-1/REBOL/sha-1-1.rebol | 1 + Task/SHA-1/REBOL/sha-1-2.rebol | 1 + Task/SHA-256/C++/sha-256-1.cpp | 18 +- Task/SHA-256/C++/sha-256-2.cpp | 136 ++--- Task/SHA-256/C/sha-256.c | 14 +- Task/SHA-256/FutureBasic/sha-256.basic | 2 +- Task/SHA-256/Haxe/sha-256.haxe | 2 +- Task/SHA-256/Java/sha-256.java | 158 +++--- Task/SHA-256/Perl/sha-256-2.pl | 192 +++---- Task/SHA-256/REBOL/sha-256.rebol | 1 + Task/SHA-256/Raku/sha-256-1.raku | 48 +- .../DuckDB/search-a-list-of-records-1.duckdb | 5 + .../DuckDB/search-a-list-of-records-2.duckdb | 2 + .../Icon/search-a-list-of-records.icon | 19 + Task/Self-numbers/Pluto/self-numbers.pluto | 83 +++ Task/Semordnilap/ArkScript/semordnilap.ark | 14 + Task/Semordnilap/AutoHotkey/semordnilap.ahk | 18 +- Task/Semordnilap/EchoLisp/semordnilap.l | 14 +- Task/Semordnilap/Eiffel/semordnilap-1.e | 128 ++--- Task/Semordnilap/Eiffel/semordnilap-2.e | 48 +- Task/Semordnilap/Forth/semordnilap.fth | 20 +- Task/Semordnilap/Julia/semordnilap.jl | 2 +- Task/Semordnilap/Ksh/semordnilap.ksh | 74 +-- Task/Semordnilap/Lasso/semordnilap.lasso | 26 +- Task/Semordnilap/Lua/semordnilap.lua | 23 +- Task/Semordnilap/NewLISP/semordnilap.l | 30 +- Task/Semordnilap/Perl/semordnilap.pl | 6 +- .../Phixmonti/semordnilap.phixmonti | 42 +- Task/Semordnilap/Pluto/semordnilap.pluto | 21 + Task/Semordnilap/Prolog/semordnilap.pro | 28 ++ Task/Semordnilap/Python/semordnilap-1.py | 2 +- Task/Semordnilap/R/semordnilap.r | 2 +- Task/Semordnilap/REBOL/semordnilap-1.rebol | 26 + Task/Semordnilap/REBOL/semordnilap-2.rebol | 25 + Task/Semordnilap/SNOBOL4/semordnilap.sno | 34 +- Task/Semordnilap/TAV/semordnilap.tav | 22 + Task/Semordnilap/Tcl/semordnilap.tcl | 8 +- Task/Semordnilap/VBScript/semordnilap.vb | 32 +- ...sequence-of-primes-by-trial-division.agena | 35 ++ ...sequence-of-primes-by-trial-division.pluto | 29 ++ .../sequence-of-primes-by-trial-division.rexx | 8 +- .../REXX/sequence-of-primorial-primes.rexx | 14 +- .../DuckDB/set-consolidation-1.duckdb | 1 + .../DuckDB/set-consolidation-2.duckdb | 17 + .../DuckDB/set-consolidation-3.duckdb | 61 +++ .../Pluto/set-consolidation.pluto | 38 ++ .../Wren/set-consolidation.wren | 2 +- Task/Set/DuckDB/set-1.duckdb | 5 + Task/Set/DuckDB/set-2.duckdb | 1 + Task/Set/DuckDB/set-3.duckdb | 1 + Task/Set/DuckDB/set-4.duckdb | 1 + Task/Set/DuckDB/set-5.duckdb | 1 + Task/Set/DuckDB/set-6.duckdb | 2 + Task/Set/DuckDB/set-7.duckdb | 2 + Task/Set/DuckDB/set-8.duckdb | 2 + Task/Set/DuckDB/set-9.duckdb | 1 + Task/Set/Pluto/set.pluto | 46 ++ .../ArkScript/shell-one-liner.ark | 1 + ... shoelace-formula-for-polygonal-area-1.jl} | 0 .../shoelace-formula-for-polygonal-area-2.jl | 10 + .../R/shoelace-formula-for-polygonal-area.r | 10 + .../ArkScript/short-circuit-evaluation.ark | 17 + .../ArkScript/show-ascii-table.ark | 15 + .../DuckDB/show-the-epoch.duckdb | 1 + .../EasyLang/sierpinski-arrowhead-curve.easy | 5 +- .../EasyLang/sierpinski-pentagon.easy | 7 +- .../FutureBasic/sierpinski-pentagon.basic | 77 +++ .../DuckDB/sieve-of-eratosthenes.duckdb | 20 + .../Odin/sieve-of-eratosthenes.odin | 44 +- .../EasyLang/simple-turtle-graphics.easy | 9 +- .../simple-windowed-application.funcsug | 7 + .../TAV/simple-windowed-application.tav | 23 + .../Julia/simulate-input-keyboard.jl | 85 ++++ .../FuncSug/simulate-input-mouse.funcsug | 16 + Task/Singleton/Rust/singleton.rs | 110 ++++ .../singly-linked-list-element-definition.cr | 7 + ...ingly-linked-list-element-definition.pluto | 7 + .../singly-linked-list-element-insertion.cr | 26 + ...singly-linked-list-element-insertion.pluto | 8 + .../Julia/singly-linked-list-traversal.jl | 9 +- .../Pluto/singly-linked-list-traversal.pluto | 14 + Task/Sleep/ArkScript/sleep.ark | 4 + Task/Sleep/FutureBasic/sleep.basic | 14 + Task/Sleep/Pluto/sleep.pluto | 5 + .../smarandache-prime-digital-sequence.alg | 16 +- .../smarandache-prime-digital-sequence.agena | 90 ++++ .../smarandache-prime-digital-sequence.pluto | 27 + Task/Snake/Liberty-BASIC/snake.basic | 191 +++++++ Task/Sokoban/JavaScript/sokoban.js | 130 +++++ Task/Sokoban/Rust/sokoban.rs | 173 +++++++ .../ALGOL-68/soloways-recurring-rainfall.alg | 2 +- .../AWK/soloways-recurring-rainfall.awk | 24 + .../Agena/soloways-recurring-rainfall.agena | 27 + .../COBOL/soloways-recurring-rainfall.cobol | 22 + .../Crystal/soloways-recurring-rainfall.cr | 20 + .../Pluto/soloways-recurring-rainfall.pluto | 14 + .../R/soloways-recurring-rainfall.r | 22 + .../JavaScript/solve-a-hopido-puzzle.js | 146 ++++++ .../Python/solve-a-numbrix-puzzle-1.py | 218 +++++--- ...rt-an-array-of-composite-structures.duckdb | 6 + .../Pluto/sort-an-integer-array.pluto | 2 + .../sort-an-outline-at-every-level.easy | 2 +- .../sort-numbers-lexicographically-1.duckdb | 7 + .../sort-numbers-lexicographically-2.duckdb | 1 + .../Icon/sort-numbers-lexicographically.icon | 9 + .../Prolog/sort-three-variables.pro | 9 + .../sorting-algorithms-insertion-sort.basic | 62 +++ .../sorting-algorithms-insertion-sort.basic | 36 ++ .../sorting-algorithms-quicksort.ark | 25 + .../sorting-algorithms-sleep-sort.basic | 21 + .../OCaml/sorting-algorithms-sleep-sort.ml | 6 + .../Julia/sorting-algorithms-stooge-sort.jl | 2 +- .../sorting-algorithms-stooge-sort.maxima | 14 + .../R/sorting-algorithms-stooge-sort.r | 20 +- .../Logo/sparkline-in-unicode-1.logo | 42 ++ .../Logo/sparkline-in-unicode-2.logo | 3 + .../YAMLScript/sparkline-in-unicode.ys | 14 + ...cter-string-based-on-change-of-character.r | 7 + .../REXX/square-form-factorization.rexx | 10 +- .../FutureBasic/stack-traces.basic | 14 + Task/Stack/OoRexx/stack.rexx | 3 + Task/Stack/Pluto/stack.pluto | 4 + Task/Stack/REXX/stack-1.rexx | 7 - Task/Stack/REXX/{stack-2.rexx => stack.rexx} | 4 +- Task/Stack/TAV/stack-1.tav | 6 + Task/Stack/TAV/stack-2.tav | 9 + .../DuckDB/statistics-basic.duckdb | 12 + .../Maxima/statistics-basic.maxima | 10 + .../Prolog/stem-and-leaf-plot.pro | 37 ++ .../Zig/stern-brocot-sequence.zig | 81 +++ .../EasyLang/straddling-checkerboard.easy | 73 +++ .../String-append/ArkScript/string-append.ark | 2 + .../DuckDB/string-append-1.duckdb | 8 + .../DuckDB/string-append-2.duckdb | 2 + Task/String-case/ArkScript/string-case.ark | 5 + Task/String-case/DuckDB/string-case.duckdb | 1 + .../DuckDB/string-comparison.duckdb | 10 + .../ArkScript/string-concatenation.ark | 6 + .../Prolog/string-concatenation.pro | 9 + .../Tcl/string-concatenation-3.tcl | 6 + .../string-interpolation-included-.ark | 4 + .../Crystal/string-interpolation-included-.cr | 6 + .../string-interpolation-included-.duckdb | 1 + .../string-interpolation-included-.pas | 2 +- .../string-interpolation-included-.pluto | 3 + .../R/string-interpolation-included-.r | 2 + .../String-length/ArkScript/string-length.ark | 1 + .../String-length/DuckDB/string-length.duckdb | 2 + .../FutureBasic/string-length.basic | 17 + Task/String-length/Pluto/string-length.pluto | 12 + Task/String-length/TAV/string-length.tav | 6 + Task/String-length/Wren/string-length-1.wren | 3 +- Task/String-length/Wren/string-length-2.wren | 3 +- Task/String-length/Wren/string-length-3.wren | 3 +- .../ArkScript/string-matching.ark | 6 + .../DuckDB/string-matching.duckdb | 17 + Task/String-matching/R/string-matching.r | 14 + .../ArkScript/string-prepend.ark | 3 + .../DuckDB/string-prepend-1.duckdb | 1 + .../DuckDB/string-prepend-2.duckdb | 1 + .../DuckDB/string-prepend-3.duckdb | 2 + ...p-a-set-of-characters-from-a-string.duckdb | 10 + .../strip-comments-from-a-string.duckdb | 16 + ...d-extended-characters-from-a-string.duckdb | 29 ++ ...itespace-from-a-string-top-and-tail.duckdb | 27 + .../Rust/substitution-cipher.rs | 25 + .../Maxima/substring-top-and-tail.maxima | 5 + .../R/substring-top-and-tail.r | 4 + Task/Substring/DuckDB/substring.duckdb | 20 + Task/Sudoku/DuckDB/sudoku.duckdb | 40 ++ Task/Sudoku/Zig/sudoku.zig | 104 ++++ .../ArkScript/sum-and-product-of-an-array.ark | 9 + .../DuckDB/sum-and-product-of-an-array.duckdb | 4 + .../Haskell/sum-and-product-of-an-array-2.hs | 12 +- .../REXX/sum-and-product-of-an-array.rexx | 25 +- .../ArkScript/sum-digits-of-an-integer.ark | 27 + .../DuckDB/sum-digits-of-an-integer.duckdb | 24 + ...ger.pas => sum-digits-of-an-integer-1.pas} | 0 .../sum-digits-of-an-integer-2.pas | 8 + .../Pluto/sum-digits-of-an-integer.pluto | 10 + .../DuckDB/sum-multiples-of-3-and-5.duckdb | 9 + .../ArkScript/sum-of-a-series.ark | 9 + .../DuckDB/sum-of-a-series-1.duckdb | 1 + .../DuckDB/sum-of-a-series-2.duckdb | 4 + .../DuckDB/sum-of-a-series-3.duckdb | 7 + .../DuckDB/sum-of-a-series-4.duckdb | 5 + .../FutureBasic/sum-of-a-series.basic | 12 + .../Sum-of-a-series/Tcl/sum-of-a-series-1.tcl | 5 +- ...ements-below-main-diagonal-of-matrix.agena | 28 ++ ...ments-below-main-diagonal-of-matrix.fennel | 27 + ...f-elements-below-main-diagonal-of-matrix.f | 27 + ...elements-below-main-diagonal-of-matrix.lua | 27 + ...ements-below-main-diagonal-of-matrix.pluto | 27 + .../ArkScript/sum-of-squares.ark | 16 + .../DuckDB/sum-of-squares-1.duckdb | 1 + .../DuckDB/sum-of-squares-2.duckdb | 5 + .../DuckDB/sum-of-squares-3.duckdb | 3 + .../DuckDB/sum-of-squares-4.duckdb | 8 + Task/Sum-to-100/EasyLang/sum-to-100.easy | 2 +- Task/Sum-to-100/FutureBasic/sum-to-100.basic | 118 +++++ Task/Superellipse/EasyLang/superellipse.easy | 5 +- Task/Superellipse/Maxima/superellipse.maxima | 7 + Task/Superellipse/Python/superellipse.py | 1 - .../superpermutation-minimisation.js | 61 +++ .../DuckDB/symmetric-difference.duckdb | 12 + .../Pluto/symmetric-difference.pluto | 10 + Task/System-time/Pluto/system-time.pluto | 1 + Task/System-time/REBOL/system-time.rebol | 3 +- .../table-creation-postal-addresses-1.duckdb | 7 + .../table-creation-postal-addresses-2.duckdb | 1 + .../table-creation-postal-addresses-3.duckdb | 7 + .../table-creation-postal-addresses-4.duckdb | 1 + Task/Tarjan/JavaScript/tarjan.js | 83 +++ Task/Tarjan/Zig/tarjan.zig | 200 ++++++++ .../FutureBasic/tau-function.basic | 39 ++ Task/Tau-function/Pluto/tau-function.pluto | 11 + Task/Tau-number/FutureBasic/tau-number.basic | 46 ++ Task/Tau-number/Pluto/tau-number.pluto | 13 + .../terminal-control-clear-the-screen.pluto | 3 + .../terminal-control-coloured-text.pluto | 16 + .../terminal-control-cursor-movement.pluto | 26 + .../terminal-control-cursor-positioning.pluto | 5 + .../Pluto/terminal-control-dimensions.pluto | 6 + ...ontrol-display-an-extended-character.pluto | 1 + .../terminal-control-hiding-the-cursor.pluto | 6 + .../terminal-control-inverse-video.pluto | 6 + .../terminal-control-preserve-screen.pluto | 10 + ...al-control-ringing-the-terminal-bell.pluto | 1 + ...minal-control-ringing-the-terminal-bell.ys | 2 + .../terminal-control-unicode-output.pluto | 10 + .../Test-integerness/Ada/test-integerness.ada | 49 ++ .../DuckDB/test-integerness-1.duckdb | 3 + .../DuckDB/test-integerness-2.duckdb | 16 + .../Pluto/test-integerness.pluto | 37 ++ .../DuckDB/text-processing-2-1.duckdb | 2 + .../DuckDB/text-processing-2-2.duckdb | 1 + .../DuckDB/text-processing-2-3.duckdb | 7 + .../DuckDB/text-processing-2-4.duckdb | 9 + .../DuckDB/text-processing-2-5.duckdb | 9 + .../DuckDB/text-processing-2-6.duckdb | 6 + Task/The-Name-Game/R/the-name-game.r | 20 + .../AutoLISP/the-twelve-days-of-christmas.l | 30 ++ Task/Thue-Morse/DuckDB/thue-morse-1.duckdb | 16 + Task/Thue-Morse/DuckDB/thue-morse-2.duckdb | 16 + Task/Thue-Morse/Prolog/thue-morse.pro | 15 + Task/Tic-tac-toe/TAV/tic-tac-toe.tav | 133 +++++ .../Agena/time-a-function.agena | 14 + .../DuckDB/time-a-function.duckdb | 21 + .../Fennel/time-a-function.fennel | 22 + Task/Time-a-function/Lua/time-a-function.lua | 2 +- .../Pluto/time-a-function.pluto | 14 + .../REXX/time-a-function-2.rexx | 43 +- .../Icon/tokenize-a-string-with-escaping.icon | 21 + .../DuckDB/tokenize-a-string.duckdb | 4 + .../Refal/tokenize-a-string.refal | 15 + .../SETL/tokenize-a-string.setl | 18 + .../TAV/tokenize-a-string.tav | 8 + .../Dart/tonelli-shanks-algorithm.dart | 122 +++++ .../Mathematica/tonelli-shanks-algorithm.math | 67 +++ .../PARI-GP/tonelli-shanks-algorithm.parigp | 123 +++++ .../R/tonelli-shanks-algorithm.r | 98 ++++ .../Scala/tonelli-shanks-algorithm.scala | 106 ++++ .../DuckDB/top-rank-per-group-1.duckdb | 14 + .../DuckDB/top-rank-per-group-2.duckdb | 6 + .../DuckDB/top-rank-per-group-3.duckdb | 3 + .../Maxima/topic-variable.maxima | 9 + Task/Topswops/Prolog/topswops.pro | 23 + Task/Total-circles-area/00-TASK.txt | 1 + .../Ada/total-circles-area.ada | 109 ++++ .../Pluto/total-circles-area-1.pluto | 51 ++ .../Pluto/total-circles-area-2.pluto | 72 +++ .../Agena/totient-function.agena | 46 ++ .../Fortran/totient-function.f | 54 ++ .../Lua/totient-function-2.lua | 23 +- .../Pluto/totient-function.pluto | 33 ++ .../Maxima/towers-of-hanoi.maxima | 8 + .../Pluto/towers-of-hanoi.pluto | 20 + Task/Towers-of-Hanoi/Red/towers-of-hanoi.red | 9 + .../Pluto/trabb-pardo-knuth-algorithm.pluto | 22 + .../Prolog/trabb-pardo-knuth-algorithm.pro | 26 + .../QB64/trabb-pardo-knuth-algorithm.qb64 | 26 + ...nglish-text-using-the-greek-alphabet.basic | 118 +++++ .../Rust/tree-datastructures.rs | 125 +++++ .../Zig/tree-datastructures.zig | 182 +++++++ .../Icon/tree-from-nesting-levels.icon | 46 ++ .../Adina/tree-traversal-1.adina | 63 +++ .../Adina/tree-traversal-2.adina | 68 +++ .../DuckDB/trigonometric-functions.duckdb | 22 + .../REXX/trigonometric-functions.rexx | 7 +- Task/Twos-complement/Ada/twos-complement.ada | 10 + .../Twos-complement/Fortran/twos-complement.f | 57 +++ Task/UPC/Pluto/upc.pluto | 110 ++++ Task/UPC/Rust/upc.rs | 161 ++++++ Task/UPC/Scala/upc.scala | 129 +++++ Task/URL-decoding/DuckDB/url-decoding.duckdb | 27 + .../DuckDB/utf-8-encode-and-decode.duckdb | 12 + .../YAMLScript/undefined-values.ys | 9 + Task/Unicode-strings/00-TASK.txt | 2 +- .../EasyLang/unicode-strings.easy | 14 + .../Pluto/unicode-strings.pluto | 26 + Task/Unix-ls/DuckDB/unix-ls.duckdb | 1 + .../Agena/unprimeable-numbers.agena | 101 ++++ .../Pluto/unprimeable-numbers.pluto | 97 ++++ .../REXX/unprimeable-numbers.rexx | 6 +- ...e-another-language-to-call-a-function-1.jl | 21 + ...e-another-language-to-call-a-function-2.jl | 17 + ...e-another-language-to-call-a-function-3.jl | 33 ++ ...e-another-language-to-call-a-function-4.jl | 19 + ...-another-language-to-call-a-function-1.lua | 24 + ...-another-language-to-call-a-function-2.lua | 205 ++++++++ ...-another-language-to-call-a-function-3.lua | 4 + .../FuncSug/user-input-graphical.funcsug | 10 + .../ArkScript/user-input-text.ark | 5 + .../user-input-text.basic | 4 + .../Pluto/user-input-text.pluto | 4 + .../Agena/van-eck-sequence.agena | 26 + .../Pluto/van-eck-sequence.pluto | 26 + .../Agena/van-der-corput-sequence.agena | 32 ++ .../Pluto/van-der-corput-sequence.pluto | 35 ++ .../YAMLScript/van-der-corput-sequence.ys | 18 + .../DuckDB/variable-size-get.duckdb | 50 ++ .../DuckDB/variable-size-set.duckdb | 34 ++ Task/Variables/Bc/variables.bc | 15 + .../Pluto/variadic-function.pluto | 10 + .../DuckDB/vector-products.duckdb | 17 + .../Pluto/vector-products.pluto | 19 + .../Vector-products/REXX/vector-products.rexx | 27 +- Task/Vector/Ada/vector.ada | 31 ++ Task/Vector/Pluto/vector.pluto | 31 ++ Task/Vector/REXX/vector.rexx | 31 +- .../Zig/verhoeff-algorithm.zig | 112 +++++ ...tribution-uniformity-chi-squared-test.rexx | 10 +- .../verify-distribution-uniformity-naive.rexx | 11 +- .../Zig/vigen-re-cipher-cryptanalysis.zig | 170 +++++++ .../C-sharp/vogels-approximation-method.cs | 117 +++++ .../vogels-approximation-method.math | 123 +++++ .../Zig/vogels-approximation-method.zig | 212 ++++++++ .../Agena/wagstaff-primes.agena | 36 ++ Task/Wagstaff-primes/Lua/wagstaff-primes.lua | 38 ++ .../Pluto/wagstaff-primes.pluto | 40 ++ .../Wagstaff-primes/Ring/wagstaff-primes.ring | 12 + Task/War-card-game/Rust/war-card-game.rs | 110 ++++ Task/War-card-game/Zig/war-card-game.zig | 155 ++++++ Task/Web-scraping/REBOL/web-scraping.rebol | 2 +- .../Agena/wieferich-primes.agena | 37 ++ .../Common-Lisp/wieferich-primes.lisp | 35 ++ .../Wieferich-primes/Lua/wieferich-primes.lua | 48 ++ .../Pluto/wieferich-primes.pluto | 24 + Task/Wieferich-primes/R/wieferich-primes.r | 10 + Task/Window-creation/TAV/window-creation.tav | 9 + Task/Wireworld/Prolog/wireworld.pro | 69 +++ Task/Word-frequency/TAV/word-frequency.tav | 34 ++ Task/Word-wheel/ALGOL-68/word-wheel.alg | 36 ++ Task/Word-wrap/FutureBasic/word-wrap.basic | 59 +++ .../ArkScript/write-entire-file.ark | 1 + .../Frink/write-entire-file.frink | 4 +- .../Odin/write-entire-file.odin | 15 +- Task/Write-entire-file/R/write-entire-file.r | 1 + .../YAMLScript/xiaolin-wus-line-algorithm.ys | 52 ++ Task/Y-combinator/Pluto/y-combinator.pluto | 14 + .../Agena/yellowstone-sequence.agena | 27 + .../Fennel/yellowstone-sequence.fennel | 45 ++ .../FutureBasic/yellowstone-sequence.basic | 33 ++ .../Pluto/yellowstone-sequence.pluto | 32 ++ .../REXX/yellowstone-sequence.rexx | 9 +- .../YAMLScript/yellowstone-sequence.ys | 24 + .../FutureBasic/zebra-puzzle.basic | 266 ++++++++++ Task/Zebra-puzzle/J/zebra-puzzle-1.j | 2 +- Task/Zebra-puzzle/Pluto/zebra-puzzle.pluto | 84 ++++ .../DuckDB/zero-to-the-zero-power.duckdb | 1 + .../Pluto/zero-to-the-zero-power.pluto | 1 + .../Prolog/zero-to-the-zero-power.pro | 1 + .../DuckDB/zig-zag-matrix.duckdb | 40 ++ .../YAMLScript/zig-zag-matrix.ys | 34 ++ 3073 files changed, 55820 insertions(+), 4408 deletions(-) create mode 100644 Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt create mode 100644 Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml delete mode 120000 Lang/ALGOL-60/Factorial create mode 120000 Lang/ALGOL-68/Date-manipulation create mode 120000 Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series delete mode 120000 Lang/ALGOL-68/Factorial create mode 120000 Lang/ALGOL-68/Knapsack-problem-Continuous create mode 120000 Lang/ALGOL-68/Word-wheel delete mode 120000 Lang/ALGOL-W/Factorial create mode 120000 Lang/ALGOL-W/Knapsack-problem-Continuous create mode 120000 Lang/ANSI-BASIC/AKS-test-for-primes create mode 120000 Lang/ANSI-BASIC/Old-Russian-measure-of-length create mode 120000 Lang/APL/Monte-Carlo-methods create mode 120000 Lang/ASIC/Old-Russian-measure-of-length delete mode 120000 Lang/AWK/100-doors create mode 120000 Lang/AWK/Factorial-primes create mode 120000 Lang/AWK/Soloways-recurring-rainfall create mode 120000 Lang/Ada/Almkvist-Giullera-formula-for-pi create mode 120000 Lang/Ada/Biorhythms create mode 120000 Lang/Ada/Boyer-Moore-string-search create mode 120000 Lang/Ada/Calkin-Wilf-sequence create mode 120000 Lang/Ada/Camel-case-and-snake-case create mode 120000 Lang/Ada/Canonicalize-CIDR create mode 120000 Lang/Ada/Deepcopy create mode 120000 Lang/Ada/Factorions create mode 120000 Lang/Ada/Find-duplicate-files create mode 120000 Lang/Ada/Harmonic-series create mode 120000 Lang/Ada/Knapsack-problem-Bounded create mode 120000 Lang/Ada/Levenshtein-distance-Alignment create mode 120000 Lang/Ada/Long-literals-with-continuations create mode 120000 Lang/Ada/Longest-increasing-subsequence create mode 120000 Lang/Ada/Machine-code create mode 120000 Lang/Ada/Minimal-steps-down-to-1 create mode 120000 Lang/Ada/Naming-conventions create mode 120000 Lang/Ada/Read-a-file-character-by-character-UTF8 create mode 120000 Lang/Ada/Test-integerness create mode 120000 Lang/Ada/Total-circles-area create mode 120000 Lang/Ada/Twos-complement create mode 120000 Lang/Ada/Vector create mode 100644 Lang/Adina/00-LANG.txt create mode 100644 Lang/Adina/00-META.yaml create mode 120000 Lang/Adina/100-doors create mode 120000 Lang/Adina/Even-or-odd create mode 120000 Lang/Adina/Hello-world-Text create mode 120000 Lang/Adina/Loops-For create mode 120000 Lang/Adina/Tree-traversal create mode 120000 Lang/Agena/AKS-test-for-primes create mode 120000 Lang/Agena/Abundant-deficient-and-perfect-number-classifications create mode 120000 Lang/Agena/Abundant-odd-numbers create mode 120000 Lang/Agena/Arbitrary-precision-integers-included- create mode 120000 Lang/Agena/Attractive-numbers create mode 120000 Lang/Agena/Disarium-numbers create mode 120000 Lang/Agena/Factorial create mode 120000 Lang/Agena/Factorial-primes create mode 120000 Lang/Agena/Giuga-numbers create mode 120000 Lang/Agena/Goldbachs-comet create mode 120000 Lang/Agena/Horners-rule-for-polynomial-evaluation create mode 120000 Lang/Agena/Humble-numbers create mode 120000 Lang/Agena/JSON create mode 120000 Lang/Agena/Jacobsthal-numbers create mode 120000 Lang/Agena/Jewels-and-stones create mode 120000 Lang/Agena/Kaprekar-numbers create mode 120000 Lang/Agena/Mian-Chowla-sequence create mode 120000 Lang/Agena/Pernicious-numbers create mode 120000 Lang/Agena/Pisano-period create mode 120000 Lang/Agena/Primality-by-trial-division create mode 120000 Lang/Agena/Sequence-of-primes-by-trial-division create mode 120000 Lang/Agena/Smarandache-prime-digital-sequence create mode 120000 Lang/Agena/Soloways-recurring-rainfall create mode 120000 Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/Agena/Time-a-function create mode 120000 Lang/Agena/Totient-function create mode 120000 Lang/Agena/Unprimeable-numbers create mode 120000 Lang/Agena/Van-Eck-sequence create mode 120000 Lang/Agena/Van-der-Corput-sequence create mode 120000 Lang/Agena/Wagstaff-primes create mode 120000 Lang/Agena/Wieferich-primes create mode 120000 Lang/Agena/Yellowstone-sequence create mode 100644 Lang/Apple/00-LANG.txt create mode 100644 Lang/Apple/00-META.yaml create mode 120000 Lang/Apple/Averages-Arithmetic-mean create mode 120000 Lang/Apple/Averages-Pythagorean-means create mode 120000 Lang/Apple/Catamorphism create mode 120000 Lang/Apple/Dot-product create mode 120000 Lang/Apple/Factorial create mode 120000 Lang/Apple/Factors-of-an-integer create mode 120000 Lang/Apple/Filter create mode 120000 Lang/Apple/ISBN13-check-digit create mode 100644 Lang/Aria/00-LANG.txt create mode 100644 Lang/Aria/00-META.yaml create mode 120000 Lang/Aria/99-bottles-of-beer create mode 120000 Lang/Aria/Hello-world-Text create mode 100644 Lang/ArkScript/00-LANG.txt create mode 100644 Lang/ArkScript/00-META.yaml create mode 120000 Lang/ArkScript/100-doors create mode 120000 Lang/ArkScript/99-bottles-of-beer create mode 120000 Lang/ArkScript/A+B create mode 120000 Lang/ArkScript/Abbreviations-easy create mode 120000 Lang/ArkScript/Ackermann-function create mode 120000 Lang/ArkScript/Apply-a-callback-to-an-array create mode 120000 Lang/ArkScript/Arithmetic-Complex create mode 120000 Lang/ArkScript/Arithmetic-Integer create mode 120000 Lang/ArkScript/Array-concatenation create mode 120000 Lang/ArkScript/Array-length create mode 120000 Lang/ArkScript/Ascending-primes create mode 120000 Lang/ArkScript/Associative-array-Creation create mode 120000 Lang/ArkScript/Associative-array-Iteration create mode 120000 Lang/ArkScript/Balanced-brackets create mode 120000 Lang/ArkScript/Boolean-values create mode 120000 Lang/ArkScript/Calculating-the-value-of-e create mode 120000 Lang/ArkScript/Call-a-function create mode 120000 Lang/ArkScript/Call-an-object-method create mode 120000 Lang/ArkScript/Catamorphism create mode 120000 Lang/ArkScript/Check-that-file-exists create mode 120000 Lang/ArkScript/Closures-Value-capture create mode 120000 Lang/ArkScript/Comments create mode 120000 Lang/ArkScript/Compound-data-type create mode 120000 Lang/ArkScript/Concurrent-computing create mode 120000 Lang/ArkScript/Conditional-structures create mode 120000 Lang/ArkScript/Conways-Game-of-Life create mode 120000 Lang/ArkScript/Copy-a-string create mode 120000 Lang/ArkScript/Currying create mode 120000 Lang/ArkScript/Delete-a-file create mode 120000 Lang/ArkScript/Empty-directory create mode 120000 Lang/ArkScript/Empty-program create mode 120000 Lang/ArkScript/Empty-string create mode 120000 Lang/ArkScript/Enforced-immutability create mode 120000 Lang/ArkScript/Even-or-odd create mode 120000 Lang/ArkScript/Extend-your-language create mode 120000 Lang/ArkScript/Fibonacci-sequence create mode 120000 Lang/ArkScript/FizzBuzz create mode 120000 Lang/ArkScript/Flatten-a-list create mode 120000 Lang/ArkScript/Function-definition create mode 120000 Lang/ArkScript/Hello-world-Line-printer create mode 120000 Lang/ArkScript/Hello-world-Newline-omission create mode 120000 Lang/ArkScript/Hello-world-Text create mode 120000 Lang/ArkScript/Infinity create mode 120000 Lang/ArkScript/Integer-sequence create mode 120000 Lang/ArkScript/Literals-Floating-point create mode 120000 Lang/ArkScript/Literals-Integer create mode 120000 Lang/ArkScript/Literals-String create mode 120000 Lang/ArkScript/Logical-operations create mode 120000 Lang/ArkScript/Munchausen-numbers create mode 120000 Lang/ArkScript/N-queens-problem create mode 120000 Lang/ArkScript/Null-object create mode 120000 Lang/ArkScript/Program-termination create mode 120000 Lang/ArkScript/Read-entire-file create mode 120000 Lang/ArkScript/Reverse-a-string create mode 120000 Lang/ArkScript/Semordnilap create mode 120000 Lang/ArkScript/Shell-one-liner create mode 120000 Lang/ArkScript/Short-circuit-evaluation create mode 120000 Lang/ArkScript/Show-ASCII-table create mode 120000 Lang/ArkScript/Sleep create mode 120000 Lang/ArkScript/Sorting-algorithms-Quicksort create mode 120000 Lang/ArkScript/String-append create mode 120000 Lang/ArkScript/String-case create mode 120000 Lang/ArkScript/String-concatenation create mode 120000 Lang/ArkScript/String-interpolation-included- create mode 120000 Lang/ArkScript/String-length create mode 120000 Lang/ArkScript/String-matching create mode 120000 Lang/ArkScript/String-prepend create mode 120000 Lang/ArkScript/Sum-and-product-of-an-array create mode 120000 Lang/ArkScript/Sum-digits-of-an-integer create mode 120000 Lang/ArkScript/Sum-of-a-series create mode 120000 Lang/ArkScript/Sum-of-squares create mode 120000 Lang/ArkScript/User-input-Text create mode 120000 Lang/ArkScript/Write-entire-file create mode 120000 Lang/AutoLISP/100-doors create mode 120000 Lang/AutoLISP/Babbage-problem create mode 120000 Lang/AutoLISP/Balanced-brackets create mode 120000 Lang/AutoLISP/Entropy create mode 120000 Lang/AutoLISP/Entropy-Narcissist create mode 120000 Lang/AutoLISP/Largest-proper-divisor-of-n create mode 120000 Lang/AutoLISP/The-Twelve-Days-of-Christmas create mode 120000 Lang/BBC-BASIC/Arbitrary-precision-integers-included- create mode 120000 Lang/BBC-BASIC/Multi-dimensional-array create mode 120000 Lang/Ballerina/Comments create mode 120000 Lang/Bc/Anti-primes create mode 120000 Lang/Bc/Arithmetic-derivative create mode 120000 Lang/Bc/Department-numbers create mode 120000 Lang/Bc/Fairshare-between-two-and-more create mode 120000 Lang/Bc/Variables create mode 120000 Lang/C-sharp/Camel-case-and-snake-case create mode 120000 Lang/C-sharp/Cistercian-numerals create mode 120000 Lang/C-sharp/M-bius-function create mode 120000 Lang/C-sharp/Vogels-approximation-method create mode 120000 Lang/CBASIC/Factorial create mode 100644 Lang/CJam/00-LANG.txt create mode 100644 Lang/CJam/00-META.yaml create mode 120000 Lang/COBOL/Soloways-recurring-rainfall create mode 100644 Lang/Calcscript/00-LANG.txt create mode 100644 Lang/Calcscript/00-META.yaml create mode 120000 Lang/Common-Lisp/Wieferich-primes delete mode 120000 Lang/Component-Pascal/100-doors create mode 100644 Lang/Convex/00-LANG.txt create mode 100644 Lang/Convex/00-META.yaml create mode 120000 Lang/Crystal/Department-numbers create mode 120000 Lang/Crystal/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Crystal/Rot-13 create mode 120000 Lang/Crystal/Singly-linked-list-Element-definition create mode 120000 Lang/Crystal/Singly-linked-list-Element-insertion create mode 120000 Lang/Crystal/Soloways-recurring-rainfall create mode 120000 Lang/Crystal/String-interpolation-included- create mode 120000 Lang/Dart/AVL-tree create mode 120000 Lang/Dart/Boyer-Moore-string-search create mode 120000 Lang/Dart/Break-OO-privacy create mode 120000 Lang/Dart/Continued-fraction create mode 120000 Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 120000 Lang/Dart/Dijkstras-algorithm create mode 120000 Lang/Dart/Floyd-Warshall-algorithm create mode 120000 Lang/Dart/Parse-an-IP-Address create mode 120000 Lang/Dart/Tonelli-Shanks-algorithm create mode 120000 Lang/Draco/Anti-primes create mode 100644 Lang/DuckDB/00-LANG.txt create mode 100644 Lang/DuckDB/00-META.yaml create mode 120000 Lang/DuckDB/100-doors create mode 120000 Lang/DuckDB/99-bottles-of-beer create mode 120000 Lang/DuckDB/A+B create mode 120000 Lang/DuckDB/ABC-problem create mode 120000 Lang/DuckDB/Anagrams create mode 120000 Lang/DuckDB/Anonymous-recursion create mode 120000 Lang/DuckDB/Arithmetic-Complex create mode 120000 Lang/DuckDB/Arithmetic-Integer create mode 120000 Lang/DuckDB/Arithmetic-geometric-mean create mode 120000 Lang/DuckDB/Arithmetic-numbers create mode 120000 Lang/DuckDB/Array-concatenation create mode 120000 Lang/DuckDB/Array-length create mode 120000 Lang/DuckDB/Arrays create mode 120000 Lang/DuckDB/Associative-array-Creation create mode 120000 Lang/DuckDB/Associative-array-Iteration create mode 120000 Lang/DuckDB/Associative-array-Merging create mode 120000 Lang/DuckDB/Averages-Arithmetic-mean create mode 120000 Lang/DuckDB/Averages-Mean-angle create mode 120000 Lang/DuckDB/Averages-Mean-time-of-day create mode 120000 Lang/DuckDB/Averages-Mode create mode 120000 Lang/DuckDB/Averages-Pythagorean-means create mode 120000 Lang/DuckDB/Babbage-problem create mode 120000 Lang/DuckDB/Benfords-law create mode 120000 Lang/DuckDB/Bin-given-limits create mode 120000 Lang/DuckDB/Binary-digits create mode 120000 Lang/DuckDB/Bioinformatics-base-count create mode 120000 Lang/DuckDB/Bitwise-IO create mode 120000 Lang/DuckDB/Bitwise-operations create mode 120000 Lang/DuckDB/CSV-data-manipulation create mode 120000 Lang/DuckDB/Call-a-function create mode 120000 Lang/DuckDB/Cartesian-product-of-two-or-more-lists create mode 120000 Lang/DuckDB/Case-sensitivity-of-identifiers create mode 120000 Lang/DuckDB/Catalan-numbers create mode 120000 Lang/DuckDB/Catalan-numbers-Pascals-triangle create mode 120000 Lang/DuckDB/Check-that-file-exists create mode 120000 Lang/DuckDB/Collections create mode 120000 Lang/DuckDB/Combinations create mode 120000 Lang/DuckDB/Combinations-with-repetitions create mode 120000 Lang/DuckDB/Compare-a-list-of-strings create mode 120000 Lang/DuckDB/Compare-length-of-two-strings create mode 120000 Lang/DuckDB/Compound-data-type create mode 120000 Lang/DuckDB/Conditional-structures create mode 120000 Lang/DuckDB/Convert-seconds-to-compound-duration create mode 120000 Lang/DuckDB/Copy-a-string create mode 120000 Lang/DuckDB/Count-occurrences-of-a-substring create mode 120000 Lang/DuckDB/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/DuckDB/Cumulative-standard-deviation create mode 120000 Lang/DuckDB/Currency create mode 120000 Lang/DuckDB/Day-of-the-week create mode 120000 Lang/DuckDB/Define-a-primitive-data-type create mode 120000 Lang/DuckDB/Detect-division-by-zero create mode 120000 Lang/DuckDB/Determinant-and-permanent create mode 120000 Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters create mode 120000 Lang/DuckDB/Determine-if-a-string-has-all-unique-characters create mode 120000 Lang/DuckDB/Determine-if-a-string-is-collapsible create mode 120000 Lang/DuckDB/Determine-if-a-string-is-numeric create mode 120000 Lang/DuckDB/Determine-if-a-string-is-squeezable create mode 120000 Lang/DuckDB/Determine-sentence-type create mode 120000 Lang/DuckDB/Digital-root create mode 120000 Lang/DuckDB/Diversity-prediction-theorem create mode 120000 Lang/DuckDB/Documentation create mode 120000 Lang/DuckDB/Dot-product create mode 120000 Lang/DuckDB/Dynamic-variable-names create mode 120000 Lang/DuckDB/Element-wise-operations create mode 120000 Lang/DuckDB/Empty-string create mode 120000 Lang/DuckDB/Entropy create mode 120000 Lang/DuckDB/Enumerations create mode 120000 Lang/DuckDB/Equilibrium-index create mode 120000 Lang/DuckDB/Euler-method create mode 120000 Lang/DuckDB/Eulers-constant-0.5772... create mode 120000 Lang/DuckDB/Eulers-identity create mode 120000 Lang/DuckDB/Evaluate-binomial-coefficients create mode 120000 Lang/DuckDB/Even-or-odd create mode 120000 Lang/DuckDB/Exponentiation-order create mode 120000 Lang/DuckDB/Extreme-floating-point-values create mode 120000 Lang/DuckDB/Factorial create mode 120000 Lang/DuckDB/Factors-of-an-integer create mode 120000 Lang/DuckDB/Fairshare-between-two-and-more create mode 120000 Lang/DuckDB/Feigenbaum-constant-calculation create mode 120000 Lang/DuckDB/Fibonacci-sequence create mode 120000 Lang/DuckDB/File-input-output create mode 120000 Lang/DuckDB/Filter create mode 120000 Lang/DuckDB/Find-limit-of-recursion create mode 120000 Lang/DuckDB/Find-the-last-Sunday-of-each-month create mode 120000 Lang/DuckDB/Five-weekends create mode 120000 Lang/DuckDB/Fixed-length-records create mode 120000 Lang/DuckDB/Flatten-a-list create mode 120000 Lang/DuckDB/Formatted-numeric-output create mode 120000 Lang/DuckDB/Forward-difference create mode 120000 Lang/DuckDB/Function-definition create mode 120000 Lang/DuckDB/Gamma-function create mode 120000 Lang/DuckDB/Gapful-numbers create mode 120000 Lang/DuckDB/Generate-lower-case-ASCII-alphabet create mode 120000 Lang/DuckDB/Generic-swap create mode 120000 Lang/DuckDB/Golden-ratio-Convergence create mode 120000 Lang/DuckDB/Gotchas create mode 120000 Lang/DuckDB/Greatest-common-divisor create mode 120000 Lang/DuckDB/Greatest-element-of-a-list create mode 120000 Lang/DuckDB/Greatest-subsequential-sum create mode 120000 Lang/DuckDB/HTTP create mode 120000 Lang/DuckDB/HTTPS create mode 120000 Lang/DuckDB/HTTPS-Authenticated create mode 120000 Lang/DuckDB/Hailstone-sequence create mode 120000 Lang/DuckDB/Harmonic-series create mode 120000 Lang/DuckDB/Hash-from-two-arrays create mode 120000 Lang/DuckDB/Hash-join create mode 120000 Lang/DuckDB/Haversine-formula create mode 120000 Lang/DuckDB/Hello-world-Text create mode 120000 Lang/DuckDB/Here-document create mode 120000 Lang/DuckDB/ISBN13-check-digit create mode 120000 Lang/DuckDB/Identity-matrix create mode 120000 Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols create mode 120000 Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters create mode 120000 Lang/DuckDB/Increment-a-numerical-string create mode 120000 Lang/DuckDB/Infinity create mode 120000 Lang/DuckDB/Integer-comparison create mode 120000 Lang/DuckDB/Introspection create mode 120000 Lang/DuckDB/Inverted-index create mode 120000 Lang/DuckDB/Inverted-syntax create mode 120000 Lang/DuckDB/JSON create mode 120000 Lang/DuckDB/Jaro-similarity create mode 120000 Lang/DuckDB/Knuth-shuffle create mode 120000 Lang/DuckDB/Largest-int-from-concatenated-ints create mode 120000 Lang/DuckDB/Last-Friday-of-each-month create mode 120000 Lang/DuckDB/Leap-year create mode 120000 Lang/DuckDB/Left-factorials create mode 120000 Lang/DuckDB/Leonardo-numbers create mode 120000 Lang/DuckDB/Letter-frequency create mode 120000 Lang/DuckDB/Levenshtein-distance create mode 120000 Lang/DuckDB/List-comprehensions create mode 120000 Lang/DuckDB/Literals-Integer create mode 120000 Lang/DuckDB/Logical-operations create mode 120000 Lang/DuckDB/Longest-increasing-subsequence create mode 120000 Lang/DuckDB/Loops-Break create mode 120000 Lang/DuckDB/Loops-Do-while create mode 120000 Lang/DuckDB/Loops-Downward-for create mode 120000 Lang/DuckDB/Loops-For create mode 120000 Lang/DuckDB/Loops-For-with-a-specified-step create mode 120000 Lang/DuckDB/Loops-Increment-loop-index-within-loop-body create mode 120000 Lang/DuckDB/Loops-N-plus-one-half create mode 120000 Lang/DuckDB/Loops-Nested create mode 120000 Lang/DuckDB/Loops-While create mode 120000 Lang/DuckDB/Loops-With-multiple-ranges create mode 120000 Lang/DuckDB/Luhn-test-of-credit-card-numbers create mode 120000 Lang/DuckDB/MD5 create mode 120000 Lang/DuckDB/Map-range create mode 120000 Lang/DuckDB/Matrix-multiplication create mode 120000 Lang/DuckDB/Matrix-transposition create mode 120000 Lang/DuckDB/Merge-and-aggregate-datasets create mode 120000 Lang/DuckDB/Metallic-ratios create mode 120000 Lang/DuckDB/Middle-three-digits create mode 120000 Lang/DuckDB/Monte-Carlo-methods create mode 120000 Lang/DuckDB/Nested-function create mode 120000 Lang/DuckDB/Nth create mode 120000 Lang/DuckDB/Nth-root create mode 120000 Lang/DuckDB/One-of-n-lines-in-a-file create mode 120000 Lang/DuckDB/Order-two-numerical-lists create mode 120000 Lang/DuckDB/Ordered-words create mode 120000 Lang/DuckDB/Palindrome-detection create mode 120000 Lang/DuckDB/Parameterized-SQL-statement create mode 120000 Lang/DuckDB/Pascals-triangle create mode 120000 Lang/DuckDB/Permutations create mode 120000 Lang/DuckDB/Permutations-Derangements create mode 120000 Lang/DuckDB/Pick-random-element create mode 120000 Lang/DuckDB/Primality-by-trial-division create mode 120000 Lang/DuckDB/Prime-decomposition create mode 120000 Lang/DuckDB/Probabilistic-choice create mode 120000 Lang/DuckDB/Proper-divisors create mode 120000 Lang/DuckDB/Pseudo-random-numbers-Middle-square-method create mode 120000 Lang/DuckDB/Random-numbers create mode 120000 Lang/DuckDB/Range-expansion create mode 120000 Lang/DuckDB/Range-extraction create mode 120000 Lang/DuckDB/Read-a-file-line-by-line create mode 120000 Lang/DuckDB/Reflection-List-methods create mode 120000 Lang/DuckDB/Reflection-List-properties create mode 120000 Lang/DuckDB/Remove-duplicate-elements create mode 120000 Lang/DuckDB/Rep-string create mode 120000 Lang/DuckDB/Repeat-a-string create mode 120000 Lang/DuckDB/Return-multiple-values create mode 120000 Lang/DuckDB/Reverse-a-string create mode 120000 Lang/DuckDB/Roots-of-unity create mode 120000 Lang/DuckDB/Run-length-encoding create mode 120000 Lang/DuckDB/Search-a-list-of-records create mode 120000 Lang/DuckDB/Set create mode 120000 Lang/DuckDB/Set-consolidation create mode 120000 Lang/DuckDB/Show-the-epoch create mode 120000 Lang/DuckDB/Sieve-of-Eratosthenes create mode 120000 Lang/DuckDB/Sort-an-array-of-composite-structures create mode 120000 Lang/DuckDB/Sort-numbers-lexicographically create mode 120000 Lang/DuckDB/Statistics-Basic create mode 120000 Lang/DuckDB/String-append create mode 120000 Lang/DuckDB/String-case create mode 120000 Lang/DuckDB/String-comparison create mode 120000 Lang/DuckDB/String-interpolation-included- create mode 120000 Lang/DuckDB/String-length create mode 120000 Lang/DuckDB/String-matching create mode 120000 Lang/DuckDB/String-prepend create mode 120000 Lang/DuckDB/Strip-a-set-of-characters-from-a-string create mode 120000 Lang/DuckDB/Strip-comments-from-a-string create mode 120000 Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string create mode 120000 Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail create mode 120000 Lang/DuckDB/Substring create mode 120000 Lang/DuckDB/Sudoku create mode 120000 Lang/DuckDB/Sum-and-product-of-an-array create mode 120000 Lang/DuckDB/Sum-digits-of-an-integer create mode 120000 Lang/DuckDB/Sum-multiples-of-3-and-5 create mode 120000 Lang/DuckDB/Sum-of-a-series create mode 120000 Lang/DuckDB/Sum-of-squares create mode 120000 Lang/DuckDB/Symmetric-difference create mode 120000 Lang/DuckDB/Table-creation-Postal-addresses create mode 120000 Lang/DuckDB/Test-integerness create mode 120000 Lang/DuckDB/Text-processing-2 create mode 120000 Lang/DuckDB/Thue-Morse create mode 120000 Lang/DuckDB/Time-a-function create mode 120000 Lang/DuckDB/Tokenize-a-string create mode 120000 Lang/DuckDB/Top-rank-per-group create mode 120000 Lang/DuckDB/Trigonometric-functions create mode 120000 Lang/DuckDB/URL-decoding create mode 120000 Lang/DuckDB/UTF-8-encode-and-decode create mode 120000 Lang/DuckDB/Unix-ls create mode 120000 Lang/DuckDB/Variable-size-Get create mode 120000 Lang/DuckDB/Variable-size-Set create mode 120000 Lang/DuckDB/Vector-products create mode 120000 Lang/DuckDB/Zero-to-the-zero-power create mode 120000 Lang/DuckDB/Zig-zag-matrix create mode 120000 Lang/EasyLang/AKS-test-for-primes create mode 120000 Lang/EasyLang/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/EasyLang/Cholesky-decomposition create mode 120000 Lang/EasyLang/Currency create mode 120000 Lang/EasyLang/Death-Star create mode 120000 Lang/EasyLang/Distribution-of-0-digits-in-factorial-series create mode 120000 Lang/EasyLang/Draw-a-sphere create mode 120000 Lang/EasyLang/EKG-sequence-convergence create mode 120000 Lang/EasyLang/Earliest-difference-between-prime-gaps create mode 120000 Lang/EasyLang/Elementary-cellular-automaton-Infinite-length create mode 120000 Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes create mode 120000 Lang/EasyLang/Faulhabers-formula create mode 120000 Lang/EasyLang/Faulhabers-triangle create mode 120000 Lang/EasyLang/Fibonacci-word-fractal create mode 120000 Lang/EasyLang/Find-Chess960-starting-position-identifier create mode 120000 Lang/EasyLang/Fraction-reduction create mode 120000 Lang/EasyLang/French-Republican-calendar create mode 120000 Lang/EasyLang/Function-prototype create mode 120000 Lang/EasyLang/Hash-from-two-arrays create mode 120000 Lang/EasyLang/Honeycombs create mode 120000 Lang/EasyLang/Hunt-the-Wumpus create mode 120000 Lang/EasyLang/Jacobsthal-numbers create mode 120000 Lang/EasyLang/Pascals-triangle-Puzzle create mode 120000 Lang/EasyLang/Straddling-checkerboard create mode 120000 Lang/EasyLang/Unicode-strings create mode 120000 Lang/Eiffel/Loops-For create mode 120000 Lang/Eiffel/Loops-Infinite create mode 120000 Lang/Elixir/Determinant-and-permanent create mode 120000 Lang/Elixir/K-d-tree create mode 120000 Lang/Elixir/Parse-an-IP-Address create mode 120000 Lang/Erlang/Determinant-and-permanent create mode 120000 Lang/Erlang/Floyd-Warshall-algorithm create mode 120000 Lang/Excel/Jacobi-symbol create mode 100644 Lang/Extended-Color-BASIC/00-LANG.txt create mode 100644 Lang/Extended-Color-BASIC/00-META.yaml create mode 120000 Lang/Extended-Color-BASIC/Arrays create mode 120000 Lang/Extended-Color-BASIC/Copy-a-string create mode 120000 Lang/Extended-Color-BASIC/Hello-world-Text create mode 120000 Lang/Extended-Color-BASIC/Loops-For create mode 120000 Lang/Extended-Color-BASIC/Quine create mode 120000 Lang/Extended-Color-BASIC/User-input-Text delete mode 120000 Lang/F-Sharp/Long-multiplication create mode 120000 Lang/F-Sharp/Multiplicative-order create mode 120000 Lang/Factor/Best-shuffle create mode 120000 Lang/Fennel/Abundant-deficient-and-perfect-number-classifications create mode 120000 Lang/Fennel/Factorial create mode 120000 Lang/Fennel/Factorial-primes create mode 120000 Lang/Fennel/Goldbachs-comet create mode 120000 Lang/Fennel/Horners-rule-for-polynomial-evaluation create mode 120000 Lang/Fennel/Jacobsthal-numbers create mode 120000 Lang/Fennel/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/Fennel/Time-a-function create mode 120000 Lang/Fennel/Yellowstone-sequence create mode 120000 Lang/Fortran/Associative-array-Merging create mode 120000 Lang/Fortran/Catalan-numbers-Pascals-triangle create mode 120000 Lang/Fortran/Chinese-zodiac create mode 120000 Lang/Fortran/Cyclotomic-polynomial create mode 120000 Lang/Fortran/Disarium-numbers create mode 120000 Lang/Fortran/Display-a-linear-combination create mode 120000 Lang/Fortran/EKG-sequence-convergence create mode 120000 Lang/Fortran/Egyptian-division create mode 120000 Lang/Fortran/French-Republican-calendar create mode 120000 Lang/Fortran/Hofstadter-Figure-Figure-sequences create mode 120000 Lang/Fortran/Humble-numbers create mode 120000 Lang/Fortran/Jewels-and-stones create mode 120000 Lang/Fortran/Knapsack-problem-Bounded create mode 120000 Lang/Fortran/Knuths-power-tree create mode 120000 Lang/Fortran/McNuggets-problem create mode 120000 Lang/Fortran/Parse-an-IP-Address create mode 120000 Lang/Fortran/Pascals-triangle-Puzzle create mode 120000 Lang/Fortran/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/Fortran/Totient-function create mode 120000 Lang/Fortran/Twos-complement create mode 120000 Lang/Free-Pascal-Lazarus/Abstract-type create mode 120000 Lang/Free-Pascal-Lazarus/Cistercian-numerals create mode 120000 Lang/Free-Pascal-Lazarus/Pancake-numbers create mode 120000 Lang/FreeBASIC/Babylonian-spiral create mode 120000 Lang/FreeBASIC/Bitcoin-public-point-to-address create mode 120000 Lang/FreeBASIC/Catmull-Clark-subdivision-surface create mode 120000 Lang/FreeBASIC/Color-quantization create mode 120000 Lang/FreeBASIC/Dominoes create mode 120000 Lang/FreeBASIC/Find-duplicate-files create mode 120000 Lang/FreeBASIC/Find-largest-left-truncatable-prime-in-a-given-base create mode 120000 Lang/FreeBASIC/Transliterate-English-text-using-the-Greek-alphabet create mode 120000 Lang/Frink/Disarium-numbers create mode 120000 Lang/Frink/Happy-numbers create mode 100644 Lang/FuncSug/00-LANG.txt create mode 100644 Lang/FuncSug/00-META.yaml create mode 120000 Lang/FuncSug/GUI-component-interaction create mode 120000 Lang/FuncSug/GUI-enabling-disabling-of-controls create mode 120000 Lang/FuncSug/Hello-world-Text create mode 120000 Lang/FuncSug/Play-recorded-sounds create mode 120000 Lang/FuncSug/Simple-windowed-application create mode 120000 Lang/FuncSug/Simulate-input-Mouse create mode 120000 Lang/FuncSug/User-input-Graphical create mode 120000 Lang/FutureBasic/Arithmetic-Complex create mode 120000 Lang/FutureBasic/Averages-Mean-time-of-day create mode 120000 Lang/FutureBasic/Boyer-Moore-string-search create mode 120000 Lang/FutureBasic/CRC-32 create mode 120000 Lang/FutureBasic/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/FutureBasic/Deal-cards-for-FreeCell create mode 120000 Lang/FutureBasic/Demings-funnel create mode 120000 Lang/FutureBasic/Euler-method create mode 120000 Lang/FutureBasic/Find-limit-of-recursion create mode 120000 Lang/FutureBasic/Five-weekends create mode 120000 Lang/FutureBasic/Gamma-function create mode 120000 Lang/FutureBasic/Gaussian-elimination create mode 120000 Lang/FutureBasic/Guess-the-number-With-feedback-player- create mode 120000 Lang/FutureBasic/Hamming-numbers create mode 120000 Lang/FutureBasic/Last-letter-first-letter create mode 120000 Lang/FutureBasic/Mayan-numerals create mode 120000 Lang/FutureBasic/Modular-inverse create mode 120000 Lang/FutureBasic/Monte-Carlo-methods create mode 120000 Lang/FutureBasic/Mutex create mode 120000 Lang/FutureBasic/Named-parameters create mode 120000 Lang/FutureBasic/Perfect-shuffle create mode 120000 Lang/FutureBasic/Sierpinski-pentagon create mode 120000 Lang/FutureBasic/Sleep create mode 120000 Lang/FutureBasic/Sorting-algorithms-Insertion-sort create mode 120000 Lang/FutureBasic/Sorting-algorithms-Sleep-sort create mode 120000 Lang/FutureBasic/Stack-traces create mode 120000 Lang/FutureBasic/String-length create mode 120000 Lang/FutureBasic/Sum-of-a-series create mode 120000 Lang/FutureBasic/Sum-to-100 create mode 120000 Lang/FutureBasic/Tau-function create mode 120000 Lang/FutureBasic/Tau-number create mode 120000 Lang/FutureBasic/Word-wrap create mode 120000 Lang/FutureBasic/Yellowstone-sequence create mode 120000 Lang/FutureBasic/Zebra-puzzle create mode 120000 Lang/GW-BASIC/Old-Russian-measure-of-length create mode 120000 Lang/Go/Distance-and-Bearing create mode 100644 Lang/Goboscript/00-LANG.txt create mode 100644 Lang/Goboscript/00-META.yaml create mode 120000 Lang/Haxe/Abstract-type create mode 120000 Lang/Haxe/Apply-a-callback-to-an-array create mode 120000 Lang/Haxe/Arrays create mode 120000 Lang/Haxe/Associative-array-Creation create mode 120000 Lang/Haxe/Associative-array-Iteration create mode 120000 Lang/Haxe/Binary-digits create mode 120000 Lang/Haxe/Boolean-values create mode 120000 Lang/Haxe/Call-an-object-method create mode 120000 Lang/Haxe/Character-codes create mode 120000 Lang/Haxe/Classes create mode 120000 Lang/Icon/Exponentiation-order create mode 120000 Lang/Icon/Jewels-and-stones create mode 120000 Lang/Icon/Loops-Wrong-ranges create mode 120000 Lang/Icon/Search-a-list-of-records create mode 120000 Lang/Icon/Sort-numbers-lexicographically create mode 120000 Lang/Icon/Tokenize-a-string-with-escaping create mode 120000 Lang/Icon/Tree-from-nesting-levels create mode 120000 Lang/Idris/Comments create mode 120000 Lang/Janet/Comments create mode 120000 Lang/JavaScript/Aliquot-sequence-classifications create mode 120000 Lang/JavaScript/B-zier-curves-Intersections create mode 120000 Lang/JavaScript/Balanced-ternary create mode 120000 Lang/JavaScript/Bitcoin-public-point-to-address create mode 120000 Lang/JavaScript/Break-OO-privacy create mode 120000 Lang/JavaScript/Catmull-Clark-subdivision-surface create mode 120000 Lang/JavaScript/Checkpoint-synchronization create mode 120000 Lang/JavaScript/Continued-fraction create mode 120000 Lang/JavaScript/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 120000 Lang/JavaScript/Deconvolution-1D create mode 120000 Lang/JavaScript/Deconvolution-2D+ create mode 120000 Lang/JavaScript/MD5 create mode 120000 Lang/JavaScript/Meissel-Mertens-constant create mode 120000 Lang/JavaScript/Parse-an-IP-Address create mode 120000 Lang/JavaScript/Pascals-triangle-Puzzle create mode 120000 Lang/JavaScript/Sokoban create mode 120000 Lang/JavaScript/Solve-a-Hopido-puzzle create mode 120000 Lang/JavaScript/Superpermutation-minimisation create mode 120000 Lang/JavaScript/Tarjan create mode 120000 Lang/Julia/OLE-automation create mode 120000 Lang/Julia/Simulate-input-Keyboard create mode 120000 Lang/Julia/Use-another-language-to-call-a-function create mode 100644 Lang/Kantalo/00-LANG.txt create mode 100644 Lang/Kantalo/00-META.yaml create mode 120000 Lang/Koka/A+B create mode 120000 Lang/Koka/Extend-your-language create mode 120000 Lang/Koka/Jump-anywhere create mode 120000 Lang/Koka/Letter-frequency create mode 120000 Lang/Koka/Loops-Break create mode 120000 Lang/Koka/Monads-Writer-monad create mode 120000 Lang/Kotlin/Boyer-Moore-string-search create mode 100644 Lang/Labyrinth/00-LANG.txt create mode 100644 Lang/Labyrinth/00-META.yaml create mode 120000 Lang/Liberty-BASIC/Hunt-the-Wumpus create mode 120000 Lang/Liberty-BASIC/Minesweeper-game create mode 120000 Lang/Liberty-BASIC/Snake create mode 120000 Lang/Logo/Sparkline-in-unicode delete mode 120000 Lang/Lua/100-doors create mode 120000 Lang/Lua/Jacobsthal-numbers create mode 120000 Lang/Lua/Knapsack-problem-Bounded create mode 120000 Lang/Lua/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/Lua/Use-another-language-to-call-a-function create mode 120000 Lang/Lua/Wagstaff-primes create mode 120000 Lang/Lua/Wieferich-primes create mode 120000 Lang/Mathematica/ASCII-art-diagram-converter create mode 120000 Lang/Mathematica/Camel-case-and-snake-case create mode 120000 Lang/Mathematica/Erd-s-Nicolas-numbers create mode 120000 Lang/Mathematica/Parse-an-IP-Address create mode 120000 Lang/Mathematica/Tonelli-Shanks-algorithm create mode 120000 Lang/Mathematica/Vogels-approximation-method create mode 120000 Lang/Maxima/Array-length create mode 120000 Lang/Maxima/Delete-a-file create mode 120000 Lang/Maxima/Hash-from-two-arrays create mode 120000 Lang/Maxima/Real-constants-and-functions create mode 120000 Lang/Maxima/Regular-expressions create mode 120000 Lang/Maxima/Rename-a-file create mode 120000 Lang/Maxima/Sorting-algorithms-Stooge-sort create mode 120000 Lang/Maxima/Statistics-Basic create mode 120000 Lang/Maxima/Substring-Top-and-tail create mode 120000 Lang/Maxima/Superellipse create mode 120000 Lang/Maxima/Topic-variable create mode 120000 Lang/Maxima/Towers-of-Hanoi create mode 100644 Lang/Mn/00-LANG.txt create mode 100644 Lang/Mn/00-META.yaml create mode 120000 Lang/Mn/Factorial create mode 120000 Lang/Mn/Loops-While create mode 120000 Lang/Modula-2/AKS-test-for-primes create mode 120000 Lang/Modula-2/Cistercian-numerals create mode 120000 Lang/Mojo/Hunt-the-Wumpus create mode 120000 Lang/Nascom-BASIC/Old-Russian-measure-of-length create mode 100644 Lang/Nom/00-LANG.txt create mode 100644 Lang/Nom/00-META.yaml create mode 120000 Lang/Nom/Balanced-brackets create mode 120000 Lang/Nom/CSV-to-HTML-translation create mode 120000 Lang/Nom/Determine-if-a-string-is-numeric create mode 120000 Lang/Nom/Empty-string create mode 120000 Lang/Nom/Even-or-odd create mode 120000 Lang/Nom/Hello-world-Text create mode 120000 Lang/Nom/Input-loop create mode 120000 Lang/Nom/Odd-word-problem create mode 120000 Lang/Nom/Reverse-a-string create mode 120000 Lang/OCaml/Parse-an-IP-Address create mode 120000 Lang/OCaml/Sorting-algorithms-Sleep-sort create mode 120000 Lang/Objeck/Catalan-numbers-Pascals-triangle create mode 120000 Lang/Objeck/Disarium-numbers create mode 120000 Lang/Objeck/HTTPS-Client-authenticated create mode 120000 Lang/Objeck/Magic-squares-of-doubly-even-order create mode 120000 Lang/Objeck/Matrix-multiplication create mode 100644 Lang/Object-Pascal-Implementations/00-LANG.txt create mode 100644 Lang/Object-Pascal-Implementations/00-META.yaml create mode 120000 Lang/Odin/Comments create mode 120000 Lang/OoRexx/Prime-decomposition create mode 120000 Lang/OxygenBasic/Josephus-problem create mode 120000 Lang/PARI-GP/Pell-numbers create mode 120000 Lang/PARI-GP/Tonelli-Shanks-algorithm create mode 120000 Lang/PHP/AKS-test-for-primes delete mode 120000 Lang/PL-M/100-doors create mode 100644 Lang/Pascal-P/00-LANG.txt create mode 100644 Lang/Pascal-P/00-META.yaml create mode 120000 Lang/Pascal-P/Cistercian-numerals create mode 120000 Lang/Pascal-P/FizzBuzz create mode 120000 Lang/Pascal-P/Leonardo-numbers create mode 120000 Lang/Pascal-P/Levenshtein-distance create mode 120000 Lang/Pascal-P/M-bius-function create mode 120000 Lang/Pascal-P/Magic-constant create mode 120000 Lang/Pascal-P/Map-range create mode 120000 Lang/Pascal-P/Ramer-Douglas-Peucker-line-simplification create mode 120000 Lang/PascalABC.NET/15-puzzle-solver create mode 120000 Lang/PascalABC.NET/Abbreviations-easy create mode 120000 Lang/PascalABC.NET/Abbreviations-simple create mode 120000 Lang/PascalABC.NET/Arithmetic-evaluation create mode 120000 Lang/PascalABC.NET/Bioinformatics-base-count create mode 120000 Lang/PascalABC.NET/Case-sensitivity-of-identifiers create mode 120000 Lang/PascalABC.NET/Combinations-with-repetitions create mode 120000 Lang/Perl/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 100644 Lang/Pico-8/00-LANG.txt create mode 100644 Lang/Pico-8/00-META.yaml create mode 120000 Lang/Pico-8/Hello-world-Text create mode 100644 Lang/Pluto/00-LANG.txt create mode 100644 Lang/Pluto/00-META.yaml create mode 120000 Lang/Pluto/99-bottles-of-beer create mode 120000 Lang/Pluto/A+B create mode 120000 Lang/Pluto/ABC-problem create mode 120000 Lang/Pluto/AKS-test-for-primes create mode 120000 Lang/Pluto/Abelian-sandpile-model create mode 120000 Lang/Pluto/Abelian-sandpile-model-Identity create mode 120000 Lang/Pluto/Abstract-type create mode 120000 Lang/Pluto/Abundant-deficient-and-perfect-number-classifications create mode 120000 Lang/Pluto/Abundant-odd-numbers create mode 120000 Lang/Pluto/Achilles-numbers create mode 120000 Lang/Pluto/Ackermann-function create mode 120000 Lang/Pluto/Address-of-a-variable create mode 120000 Lang/Pluto/Almost-prime create mode 120000 Lang/Pluto/Anti-primes create mode 120000 Lang/Pluto/Approximate-equality create mode 120000 Lang/Pluto/Arbitrary-precision-integers-included- create mode 120000 Lang/Pluto/Arithmetic-Complex create mode 120000 Lang/Pluto/Arithmetic-Integer create mode 120000 Lang/Pluto/Arithmetic-Rational create mode 120000 Lang/Pluto/Arithmetic-derivative create mode 120000 Lang/Pluto/Arithmetic-geometric-mean create mode 120000 Lang/Pluto/Array-concatenation create mode 120000 Lang/Pluto/Arrays create mode 120000 Lang/Pluto/Ascending-primes create mode 120000 Lang/Pluto/Associative-array-Creation create mode 120000 Lang/Pluto/Associative-array-Iteration create mode 120000 Lang/Pluto/Associative-array-Merging create mode 120000 Lang/Pluto/Attractive-numbers create mode 120000 Lang/Pluto/Averages-Arithmetic-mean create mode 120000 Lang/Pluto/Averages-Median create mode 120000 Lang/Pluto/Averages-Pythagorean-means create mode 120000 Lang/Pluto/Averages-Root-mean-square create mode 120000 Lang/Pluto/Balanced-brackets create mode 120000 Lang/Pluto/Base64-decode-data create mode 120000 Lang/Pluto/Bell-numbers create mode 120000 Lang/Pluto/Bitmap create mode 120000 Lang/Pluto/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Pluto/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Pluto/Bitwise-operations create mode 120000 Lang/Pluto/CRC-32 create mode 120000 Lang/Pluto/Caesar-cipher create mode 120000 Lang/Pluto/Calkin-Wilf-sequence create mode 120000 Lang/Pluto/Call-a-foreign-language-function create mode 120000 Lang/Pluto/Call-a-function-in-a-shared-library create mode 120000 Lang/Pluto/Case-sensitivity-of-identifiers create mode 120000 Lang/Pluto/Casting-out-nines create mode 120000 Lang/Pluto/Collections create mode 120000 Lang/Pluto/Combinations create mode 120000 Lang/Pluto/Combinations-with-repetitions create mode 120000 Lang/Pluto/Command-line-arguments create mode 120000 Lang/Pluto/Comments create mode 120000 Lang/Pluto/Compare-length-of-two-strings create mode 120000 Lang/Pluto/Compiler-lexical-analyzer create mode 120000 Lang/Pluto/Conditional-structures create mode 120000 Lang/Pluto/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Pluto/Convert-decimal-number-to-rational create mode 120000 Lang/Pluto/Count-in-octal create mode 120000 Lang/Pluto/Count-the-coins create mode 120000 Lang/Pluto/Create-a-file create mode 120000 Lang/Pluto/Currying create mode 120000 Lang/Pluto/Delete-a-file create mode 120000 Lang/Pluto/Descending-primes create mode 120000 Lang/Pluto/Determine-if-a-string-is-numeric create mode 120000 Lang/Pluto/Disarium-numbers create mode 120000 Lang/Pluto/Display-a-linear-combination create mode 120000 Lang/Pluto/Distribution-of-0-digits-in-factorial-series create mode 120000 Lang/Pluto/Doubly-linked-list-Definition create mode 120000 Lang/Pluto/Doubly-linked-list-Element-definition create mode 120000 Lang/Pluto/Doubly-linked-list-Traversal create mode 120000 Lang/Pluto/Dutch-national-flag-problem create mode 120000 Lang/Pluto/Euler-method create mode 120000 Lang/Pluto/Eulers-identity create mode 120000 Lang/Pluto/Even-or-odd create mode 120000 Lang/Pluto/Execute-a-system-command create mode 120000 Lang/Pluto/Factorial create mode 120000 Lang/Pluto/Factorial-primes create mode 120000 Lang/Pluto/Factorions create mode 120000 Lang/Pluto/Factors-of-an-integer create mode 120000 Lang/Pluto/Farey-sequence create mode 120000 Lang/Pluto/Feigenbaum-constant-calculation create mode 120000 Lang/Pluto/Fibonacci-sequence create mode 120000 Lang/Pluto/Filter create mode 120000 Lang/Pluto/FizzBuzz create mode 120000 Lang/Pluto/Floyd-Warshall-algorithm create mode 120000 Lang/Pluto/Formatted-numeric-output create mode 120000 Lang/Pluto/Function-definition create mode 120000 Lang/Pluto/Gamma-function create mode 120000 Lang/Pluto/Generate-lower-case-ASCII-alphabet create mode 120000 Lang/Pluto/Giuga-numbers create mode 120000 Lang/Pluto/Goldbachs-comet create mode 120000 Lang/Pluto/Greatest-common-divisor create mode 120000 Lang/Pluto/Greatest-element-of-a-list create mode 120000 Lang/Pluto/Hailstone-sequence create mode 120000 Lang/Pluto/Halt-and-catch-fire create mode 120000 Lang/Pluto/Hash-from-two-arrays create mode 120000 Lang/Pluto/Hello-world-Newline-omission create mode 120000 Lang/Pluto/Hello-world-Standard-error create mode 120000 Lang/Pluto/Hello-world-Text create mode 120000 Lang/Pluto/Higher-order-functions create mode 120000 Lang/Pluto/Horners-rule-for-polynomial-evaluation create mode 120000 Lang/Pluto/Humble-numbers create mode 120000 Lang/Pluto/Increment-a-numerical-string create mode 120000 Lang/Pluto/Infinity create mode 120000 Lang/Pluto/JSON create mode 120000 Lang/Pluto/Jacobsthal-numbers create mode 120000 Lang/Pluto/Jewels-and-stones create mode 120000 Lang/Pluto/Josephus-problem create mode 120000 Lang/Pluto/Kaprekar-numbers create mode 120000 Lang/Pluto/Leap-year create mode 120000 Lang/Pluto/Literals-Floating-point create mode 120000 Lang/Pluto/Literals-Integer create mode 120000 Lang/Pluto/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/Pluto/Loops-Break create mode 120000 Lang/Pluto/Loops-Continue create mode 120000 Lang/Pluto/Loops-Do-while create mode 120000 Lang/Pluto/Loops-Downward-for create mode 120000 Lang/Pluto/Loops-For create mode 120000 Lang/Pluto/Loops-For-with-a-specified-step create mode 120000 Lang/Pluto/Loops-Foreach create mode 120000 Lang/Pluto/Loops-Increment-loop-index-within-loop-body create mode 120000 Lang/Pluto/Loops-Infinite create mode 120000 Lang/Pluto/Loops-N-plus-one-half create mode 120000 Lang/Pluto/Loops-Nested create mode 120000 Lang/Pluto/Loops-While create mode 120000 Lang/Pluto/Loops-With-multiple-ranges create mode 120000 Lang/Pluto/Loops-Wrong-ranges create mode 120000 Lang/Pluto/Luhn-test-of-credit-card-numbers create mode 120000 Lang/Pluto/M-bius-function create mode 120000 Lang/Pluto/Machine-code create mode 120000 Lang/Pluto/Magic-squares-of-doubly-even-order create mode 120000 Lang/Pluto/Magic-squares-of-odd-order create mode 120000 Lang/Pluto/Magic-squares-of-singly-even-order create mode 120000 Lang/Pluto/Mian-Chowla-sequence create mode 120000 Lang/Pluto/Modular-inverse create mode 120000 Lang/Pluto/Multiplication-tables create mode 120000 Lang/Pluto/Mutual-recursion create mode 120000 Lang/Pluto/Named-parameters create mode 120000 Lang/Pluto/Narcissistic-decimal-number create mode 120000 Lang/Pluto/Nested-templated-data create mode 120000 Lang/Pluto/Non-decimal-radices-Convert create mode 120000 Lang/Pluto/Numerical-integration create mode 120000 Lang/Pluto/Old-Russian-measure-of-length create mode 120000 Lang/Pluto/Order-by-pair-comparisons create mode 120000 Lang/Pluto/Palindrome-detection create mode 120000 Lang/Pluto/Pancake-numbers create mode 120000 Lang/Pluto/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Pluto/Pascals-triangle-Puzzle create mode 120000 Lang/Pluto/Perfect-shuffle create mode 120000 Lang/Pluto/Permutations create mode 120000 Lang/Pluto/Pernicious-numbers create mode 120000 Lang/Pluto/Pick-random-element create mode 120000 Lang/Pluto/Pisano-period create mode 120000 Lang/Pluto/Power-set create mode 120000 Lang/Pluto/Primality-by-trial-division create mode 120000 Lang/Pluto/Priority-queue create mode 120000 Lang/Pluto/Read-a-file-line-by-line create mode 120000 Lang/Pluto/Rename-a-file create mode 120000 Lang/Pluto/Repeat-a-string create mode 120000 Lang/Pluto/Reverse-a-string create mode 120000 Lang/Pluto/Reverse-words-in-a-string create mode 120000 Lang/Pluto/Roman-numerals-Encode create mode 120000 Lang/Pluto/Roots-of-a-quadratic-function create mode 120000 Lang/Pluto/Roots-of-unity create mode 120000 Lang/Pluto/Rot-13 create mode 120000 Lang/Pluto/Runge-Kutta-method create mode 120000 Lang/Pluto/Self-numbers create mode 120000 Lang/Pluto/Semordnilap create mode 120000 Lang/Pluto/Sequence-of-primes-by-trial-division create mode 120000 Lang/Pluto/Set create mode 120000 Lang/Pluto/Set-consolidation create mode 120000 Lang/Pluto/Singly-linked-list-Element-definition create mode 120000 Lang/Pluto/Singly-linked-list-Element-insertion create mode 120000 Lang/Pluto/Singly-linked-list-Traversal create mode 120000 Lang/Pluto/Sleep create mode 120000 Lang/Pluto/Smarandache-prime-digital-sequence create mode 120000 Lang/Pluto/Soloways-recurring-rainfall create mode 120000 Lang/Pluto/Sort-an-integer-array create mode 120000 Lang/Pluto/Stack create mode 120000 Lang/Pluto/String-interpolation-included- create mode 120000 Lang/Pluto/String-length create mode 120000 Lang/Pluto/Sum-digits-of-an-integer create mode 120000 Lang/Pluto/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/Pluto/Symmetric-difference create mode 120000 Lang/Pluto/System-time create mode 120000 Lang/Pluto/Tau-function create mode 120000 Lang/Pluto/Tau-number create mode 120000 Lang/Pluto/Terminal-control-Clear-the-screen create mode 120000 Lang/Pluto/Terminal-control-Coloured-text create mode 120000 Lang/Pluto/Terminal-control-Cursor-movement create mode 120000 Lang/Pluto/Terminal-control-Cursor-positioning create mode 120000 Lang/Pluto/Terminal-control-Dimensions create mode 120000 Lang/Pluto/Terminal-control-Display-an-extended-character create mode 120000 Lang/Pluto/Terminal-control-Hiding-the-cursor create mode 120000 Lang/Pluto/Terminal-control-Inverse-video create mode 120000 Lang/Pluto/Terminal-control-Preserve-screen create mode 120000 Lang/Pluto/Terminal-control-Ringing-the-terminal-bell create mode 120000 Lang/Pluto/Terminal-control-Unicode-output create mode 120000 Lang/Pluto/Test-integerness create mode 120000 Lang/Pluto/Time-a-function create mode 120000 Lang/Pluto/Total-circles-area create mode 120000 Lang/Pluto/Totient-function create mode 120000 Lang/Pluto/Towers-of-Hanoi create mode 120000 Lang/Pluto/Trabb-Pardo-Knuth-algorithm create mode 120000 Lang/Pluto/UPC create mode 120000 Lang/Pluto/Unicode-strings create mode 120000 Lang/Pluto/Unprimeable-numbers create mode 120000 Lang/Pluto/User-input-Text create mode 120000 Lang/Pluto/Van-Eck-sequence create mode 120000 Lang/Pluto/Van-der-Corput-sequence create mode 120000 Lang/Pluto/Variadic-function create mode 120000 Lang/Pluto/Vector create mode 120000 Lang/Pluto/Vector-products create mode 120000 Lang/Pluto/Wagstaff-primes create mode 120000 Lang/Pluto/Wieferich-primes create mode 120000 Lang/Pluto/Y-combinator create mode 120000 Lang/Pluto/Yellowstone-sequence create mode 120000 Lang/Pluto/Zebra-puzzle create mode 120000 Lang/Pluto/Zero-to-the-zero-power create mode 120000 Lang/PowerShell/AKS-test-for-primes create mode 120000 Lang/PowerShell/M-bius-function create mode 120000 Lang/Prolog/100-prisoners create mode 120000 Lang/Prolog/Boolean-values create mode 120000 Lang/Prolog/Damm-algorithm create mode 120000 Lang/Prolog/Hello-world-Newline-omission create mode 120000 Lang/Prolog/ISBN13-check-digit create mode 120000 Lang/Prolog/Integer-comparison create mode 120000 Lang/Prolog/Iterated-digits-squaring create mode 120000 Lang/Prolog/Josephus-problem create mode 120000 Lang/Prolog/Magic-8-ball create mode 120000 Lang/Prolog/Old-Russian-measure-of-length create mode 120000 Lang/Prolog/Order-by-pair-comparisons create mode 120000 Lang/Prolog/Phrase-reversals create mode 120000 Lang/Prolog/Population-count create mode 120000 Lang/Prolog/RPG-attributes-generator create mode 120000 Lang/Prolog/SEDOLs create mode 120000 Lang/Prolog/Semordnilap create mode 120000 Lang/Prolog/Sort-three-variables create mode 120000 Lang/Prolog/Stem-and-leaf-plot create mode 120000 Lang/Prolog/String-concatenation create mode 120000 Lang/Prolog/Thue-Morse create mode 120000 Lang/Prolog/Topswops create mode 120000 Lang/Prolog/Trabb-Pardo-Knuth-algorithm create mode 120000 Lang/Prolog/Wireworld create mode 120000 Lang/Prolog/Zero-to-the-zero-power create mode 120000 Lang/Python/Ruth-Aaron-numbers create mode 120000 Lang/QB64/Trabb-Pardo-Knuth-algorithm create mode 120000 Lang/R/Angles-geometric-normalization-and-conversion create mode 120000 Lang/R/CUSIP create mode 120000 Lang/R/Continued-fraction create mode 120000 Lang/R/Cramers-rule create mode 120000 Lang/R/Curzon-numbers create mode 120000 Lang/R/Dijkstras-algorithm create mode 120000 Lang/R/Execute-HQ9+ create mode 120000 Lang/R/Factorial-primes create mode 120000 Lang/R/Fibonacci-n-step-number-sequences create mode 120000 Lang/R/Flipping-bits-game create mode 120000 Lang/R/Floyd-Warshall-algorithm create mode 120000 Lang/R/Fractran create mode 120000 Lang/R/Giuga-numbers create mode 120000 Lang/R/Greedy-algorithm-for-Egyptian-fractions create mode 120000 Lang/R/Humble-numbers create mode 120000 Lang/R/M-bius-function create mode 120000 Lang/R/Parse-an-IP-Address create mode 120000 Lang/R/Rename-a-file create mode 120000 Lang/R/Repunit-primes create mode 120000 Lang/R/Retrieve-and-search-chat-history create mode 120000 Lang/R/Shoelace-formula-for-polygonal-area create mode 120000 Lang/R/Soloways-recurring-rainfall create mode 120000 Lang/R/Split-a-character-string-based-on-change-of-character create mode 120000 Lang/R/String-interpolation-included- create mode 120000 Lang/R/String-matching create mode 120000 Lang/R/Substring-Top-and-tail create mode 120000 Lang/R/The-Name-Game create mode 120000 Lang/R/Tonelli-Shanks-algorithm create mode 120000 Lang/R/Wieferich-primes create mode 120000 Lang/R/Write-entire-file create mode 120000 Lang/REBOL/9-billion-names-of-God-the-integer create mode 120000 Lang/REBOL/Ackermann-function create mode 120000 Lang/REBOL/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/REBOL/Loops-Increment-loop-index-within-loop-body create mode 120000 Lang/REBOL/Loops-With-multiple-ranges create mode 120000 Lang/REBOL/Loops-Wrong-ranges create mode 120000 Lang/REBOL/Object-serialization create mode 120000 Lang/REBOL/Polyspiral create mode 120000 Lang/REBOL/SHA-1 create mode 120000 Lang/REBOL/SHA-256 create mode 120000 Lang/REBOL/Semordnilap create mode 120000 Lang/RISC-V-Assembly/Address-of-a-variable create mode 120000 Lang/RISC-V-Assembly/Arithmetic-Integer create mode 120000 Lang/RISC-V-Assembly/Binary-digits create mode 120000 Lang/RISC-V-Assembly/Hello-world-Newbie create mode 120000 Lang/RISC-V-Assembly/Include-a-file create mode 120000 Lang/Raku/Play-recorded-sounds create mode 120000 Lang/Red/Address-of-a-variable create mode 120000 Lang/Red/Arithmetic-Integer create mode 120000 Lang/Red/Arithmetic-evaluation create mode 120000 Lang/Red/Calendar create mode 120000 Lang/Red/Calendar---for-REAL-programmers create mode 120000 Lang/Red/Currying create mode 120000 Lang/Red/Five-weekends create mode 120000 Lang/Red/Logical-operations create mode 120000 Lang/Red/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Red/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Red/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Red/Towers-of-Hanoi create mode 120000 Lang/Refal/Tokenize-a-string create mode 100644 Lang/Rhombus/00-LANG.txt create mode 100644 Lang/Rhombus/00-META.yaml create mode 120000 Lang/Rhombus/99-bottles-of-beer create mode 120000 Lang/Rhombus/Arbitrary-precision-integers-included- create mode 120000 Lang/Rhombus/Caesar-cipher create mode 120000 Lang/Rhombus/Factorial create mode 120000 Lang/Rhombus/Fibonacci-sequence create mode 120000 Lang/Rhombus/FizzBuzz create mode 120000 Lang/Rhombus/Guess-the-number-With-feedback create mode 120000 Lang/Rhombus/Hello-world-Text create mode 120000 Lang/Rhombus/Inheritance-Single create mode 120000 Lang/Rhombus/Polymorphism create mode 120000 Lang/Rhombus/Rot-13 create mode 120000 Lang/Ring/Compare-a-list-of-strings create mode 120000 Lang/Ring/Wagstaff-primes create mode 120000 Lang/Run-BASIC/Josephus-problem create mode 120000 Lang/Rust/Break-OO-privacy create mode 120000 Lang/Rust/Camel-case-and-snake-case create mode 120000 Lang/Rust/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 120000 Lang/Rust/Cyclops-numbers create mode 120000 Lang/Rust/Deconvolution-1D create mode 120000 Lang/Rust/Deconvolution-2D+ create mode 120000 Lang/Rust/Determine-if-two-triangles-overlap create mode 120000 Lang/Rust/Duffinian-numbers create mode 120000 Lang/Rust/Elliptic-curve-arithmetic create mode 120000 Lang/Rust/Faulhabers-triangle create mode 120000 Lang/Rust/Fractran create mode 120000 Lang/Rust/Humble-numbers create mode 120000 Lang/Rust/Knapsack-problem-Bounded create mode 120000 Lang/Rust/Mayan-calendar create mode 120000 Lang/Rust/Meissel-Mertens-constant create mode 120000 Lang/Rust/Modular-arithmetic create mode 120000 Lang/Rust/Multiple-regression create mode 120000 Lang/Rust/Ramanujan-primes-twins create mode 120000 Lang/Rust/Singleton create mode 120000 Lang/Rust/Sokoban create mode 120000 Lang/Rust/Substitution-cipher create mode 120000 Lang/Rust/Tree-datastructures create mode 120000 Lang/Rust/UPC create mode 120000 Lang/Rust/War-card-game create mode 120000 Lang/S-BASIC/Sorting-algorithms-Insertion-sort create mode 120000 Lang/SETL/Monte-Carlo-methods create mode 120000 Lang/SETL/Tokenize-a-string create mode 120000 Lang/Scala/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 120000 Lang/Scala/Tonelli-Shanks-algorithm create mode 120000 Lang/Scala/UPC create mode 120000 Lang/Scheme/Own-digits-power-sum create mode 120000 Lang/Scheme/Pick-random-element create mode 120000 Lang/Swift/AVL-tree create mode 120000 Lang/Swift/Boyer-Moore-string-search create mode 120000 Lang/Swift/Chaocipher create mode 120000 Lang/Swift/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- create mode 120000 Lang/Swift/Floyd-Warshall-algorithm create mode 120000 Lang/Swift/K-d-tree create mode 120000 Lang/Swift/Parse-an-IP-Address create mode 100644 Lang/TAV/00-LANG.txt create mode 100644 Lang/TAV/00-META.yaml create mode 120000 Lang/TAV/A+B create mode 120000 Lang/TAV/Ackermann-function create mode 120000 Lang/TAV/Anagrams create mode 120000 Lang/TAV/Arithmetic-Integer create mode 120000 Lang/TAV/Array-concatenation create mode 120000 Lang/TAV/Array-length create mode 120000 Lang/TAV/Associative-array-Iteration create mode 120000 Lang/TAV/Averages-Root-mean-square create mode 120000 Lang/TAV/Character-codes create mode 120000 Lang/TAV/Command-line-arguments create mode 120000 Lang/TAV/Conditional-structures create mode 120000 Lang/TAV/Copy-a-string create mode 120000 Lang/TAV/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/TAV/Empty-string create mode 120000 Lang/TAV/Factorial create mode 120000 Lang/TAV/Fibonacci-sequence create mode 120000 Lang/TAV/Formatted-numeric-output create mode 120000 Lang/TAV/Greatest-element-of-a-list create mode 120000 Lang/TAV/Guess-the-number-With-feedback create mode 120000 Lang/TAV/HTTPS create mode 120000 Lang/TAV/Halt-and-catch-fire create mode 120000 Lang/TAV/Hello-world-Graphical create mode 120000 Lang/TAV/Hello-world-Text create mode 120000 Lang/TAV/Letter-frequency create mode 120000 Lang/TAV/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/TAV/Loops-Break create mode 120000 Lang/TAV/Loops-Do-while create mode 120000 Lang/TAV/Loops-Downward-for create mode 120000 Lang/TAV/Loops-For create mode 120000 Lang/TAV/Loops-Infinite create mode 120000 Lang/TAV/Loops-N-plus-one-half create mode 120000 Lang/TAV/Loops-While create mode 120000 Lang/TAV/Multiplication-tables create mode 120000 Lang/TAV/Ordered-words create mode 120000 Lang/TAV/Permutations create mode 120000 Lang/TAV/Real-constants-and-functions create mode 120000 Lang/TAV/Reverse-a-string create mode 120000 Lang/TAV/Semordnilap create mode 120000 Lang/TAV/Simple-windowed-application create mode 120000 Lang/TAV/Stack create mode 120000 Lang/TAV/String-length create mode 120000 Lang/TAV/Tic-tac-toe create mode 120000 Lang/TAV/Tokenize-a-string create mode 120000 Lang/TAV/Window-creation create mode 120000 Lang/TAV/Word-frequency create mode 120000 Lang/Tcl/M-bius-function create mode 120000 Lang/Ursalang/Loops-Break create mode 120000 Lang/Ursalang/Loops-While create mode 120000 Lang/V-(Vlang)/Compile-time-calculation create mode 120000 Lang/V-(Vlang)/Inheritance-Multiple create mode 120000 Lang/V-(Vlang)/Inheritance-Single create mode 120000 Lang/V-(Vlang)/Metaprogramming create mode 100644 Lang/Vyxal/00-LANG.txt create mode 100644 Lang/Vyxal/00-META.yaml create mode 120000 Lang/Vyxal/Factorial create mode 120000 Lang/Vyxal/FizzBuzz create mode 120000 Lang/XBasic/AKS-test-for-primes create mode 120000 Lang/XBasic/Josephus-problem create mode 120000 Lang/XPL0/AKS-test-for-primes create mode 120000 Lang/XPL0/Cistercian-numerals create mode 120000 Lang/YAMLScript/Best-shuffle create mode 120000 Lang/YAMLScript/Conways-Game-of-Life create mode 120000 Lang/YAMLScript/Dragon-curve create mode 120000 Lang/YAMLScript/Even-or-odd create mode 120000 Lang/YAMLScript/Integer-comparison create mode 120000 Lang/YAMLScript/JortSort create mode 120000 Lang/YAMLScript/Knuth-shuffle create mode 120000 Lang/YAMLScript/Munching-squares create mode 120000 Lang/YAMLScript/Next-highest-int-from-digits create mode 120000 Lang/YAMLScript/One-dimensional-cellular-automata create mode 120000 Lang/YAMLScript/Quickselect-algorithm create mode 120000 Lang/YAMLScript/Sparkline-in-unicode create mode 120000 Lang/YAMLScript/Terminal-control-Ringing-the-terminal-bell create mode 120000 Lang/YAMLScript/Undefined-values create mode 120000 Lang/YAMLScript/Van-der-Corput-sequence create mode 120000 Lang/YAMLScript/Xiaolin-Wus-line-algorithm create mode 120000 Lang/YAMLScript/Yellowstone-sequence create mode 120000 Lang/YAMLScript/Zig-zag-matrix create mode 120000 Lang/Zig/24-game-Solve create mode 120000 Lang/Zig/AVL-tree create mode 120000 Lang/Zig/Abelian-sandpile-model create mode 120000 Lang/Zig/Abelian-sandpile-model-Identity create mode 120000 Lang/Zig/Arrays create mode 120000 Lang/Zig/Associative-array-Creation create mode 120000 Lang/Zig/Associative-array-Iteration create mode 120000 Lang/Zig/Base64-decode-data create mode 120000 Lang/Zig/Bifid-cipher create mode 120000 Lang/Zig/Boolean-values create mode 120000 Lang/Zig/Boyer-Moore-string-search create mode 120000 Lang/Zig/Break-OO-privacy create mode 120000 Lang/Zig/Camel-case-and-snake-case create mode 120000 Lang/Zig/Cholesky-decomposition create mode 120000 Lang/Zig/Cumulative-standard-deviation create mode 120000 Lang/Zig/Cyclops-numbers create mode 120000 Lang/Zig/Deconvolution-1D create mode 120000 Lang/Zig/Determinant-and-permanent create mode 120000 Lang/Zig/Eertree create mode 120000 Lang/Zig/Elliptic-Curve-Digital-Signature-Algorithm create mode 120000 Lang/Zig/Elliptic-curve-arithmetic create mode 120000 Lang/Zig/Evolutionary-algorithm create mode 120000 Lang/Zig/Factors-of-an-integer create mode 120000 Lang/Zig/Farey-sequence create mode 120000 Lang/Zig/Gray-code create mode 120000 Lang/Zig/K-d-tree create mode 120000 Lang/Zig/Knapsack-problem-0-1 create mode 120000 Lang/Zig/Knights-tour create mode 120000 Lang/Zig/Loops-Nested create mode 120000 Lang/Zig/M-bius-function create mode 120000 Lang/Zig/Main-step-of-GOST-28147-89 create mode 120000 Lang/Zig/Modular-arithmetic create mode 120000 Lang/Zig/Modular-inverse create mode 120000 Lang/Zig/Parse-an-IP-Address create mode 120000 Lang/Zig/Permutations-by-swapping create mode 120000 Lang/Zig/Stern-Brocot-sequence create mode 120000 Lang/Zig/Sudoku create mode 120000 Lang/Zig/Tarjan create mode 120000 Lang/Zig/Tree-datastructures create mode 120000 Lang/Zig/Verhoeff-algorithm create mode 120000 Lang/Zig/Vigen-re-cipher-Cryptanalysis create mode 120000 Lang/Zig/Vogels-approximation-method create mode 120000 Lang/Zig/War-card-game delete mode 100644 Task/100-doors/AWK/100-doors-1.awk delete mode 100644 Task/100-doors/AWK/100-doors-2.awk create mode 100644 Task/100-doors/Adina/100-doors-1.adina create mode 100644 Task/100-doors/Adina/100-doors-2.adina create mode 100644 Task/100-doors/ArkScript/100-doors-1.ark create mode 100644 Task/100-doors/ArkScript/100-doors-2.ark create mode 100644 Task/100-doors/AutoLISP/100-doors.l delete mode 100644 Task/100-doors/Component-Pascal/100-doors.pas create mode 100644 Task/100-doors/DuckDB/100-doors.duckdb create mode 100644 Task/100-doors/Haskell/100-doors-5.hs delete mode 100644 Task/100-doors/Lua/100-doors.lua delete mode 100644 Task/100-doors/PL-M/100-doors.plm create mode 100644 Task/100-doors/REBOL/100-doors-3.rebol create mode 100644 Task/100-prisoners/Prolog/100-prisoners.pro create mode 100644 Task/15-puzzle-solver/PascalABC.NET/15-puzzle-solver.pas create mode 100644 Task/24-game-Solve/Zig/24-game-solve.zig create mode 100644 Task/9-billion-names-of-God-the-integer/REBOL/9-billion-names-of-god-the-integer.rebol create mode 100644 Task/99-bottles-of-beer/Aria/99-bottles-of-beer.aria create mode 100644 Task/99-bottles-of-beer/ArkScript/99-bottles-of-beer.ark create mode 100644 Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-1.duckdb create mode 100644 Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-2.duckdb create mode 100644 Task/99-bottles-of-beer/Pluto/99-bottles-of-beer.pluto create mode 100644 Task/99-bottles-of-beer/Rhombus/99-bottles-of-beer.rhombus create mode 100644 Task/A+B/ArkScript/a+b.ark create mode 100644 Task/A+B/DuckDB/a+b-1.duckdb create mode 100644 Task/A+B/DuckDB/a+b-2.duckdb create mode 100644 Task/A+B/Koka/a+b.koka create mode 100644 Task/A+B/Pluto/a+b.pluto create mode 100644 Task/A+B/TAV/a+b.tav create mode 100644 Task/ABC-problem/DuckDB/abc-problem.duckdb create mode 100644 Task/ABC-problem/Pluto/abc-problem.pluto create mode 100644 Task/AKS-test-for-primes/ANSI-BASIC/aks-test-for-primes.basic create mode 100644 Task/AKS-test-for-primes/Agena/aks-test-for-primes.agena create mode 100644 Task/AKS-test-for-primes/EasyLang/aks-test-for-primes.easy create mode 100644 Task/AKS-test-for-primes/Modula-2/aks-test-for-primes.mod2 create mode 100644 Task/AKS-test-for-primes/PHP/aks-test-for-primes.php create mode 100644 Task/AKS-test-for-primes/Pluto/aks-test-for-primes.pluto create mode 100644 Task/AKS-test-for-primes/PowerShell/aks-test-for-primes.psh create mode 100644 Task/AKS-test-for-primes/XBasic/aks-test-for-primes.basic create mode 100644 Task/AKS-test-for-primes/XPL0/aks-test-for-primes.xpl0 create mode 100644 Task/ASCII-art-diagram-converter/Mathematica/ascii-art-diagram-converter.math create mode 100644 Task/AVL-tree/Dart/avl-tree.dart create mode 100644 Task/AVL-tree/Swift/avl-tree.swift create mode 100644 Task/AVL-tree/Zig/avl-tree.zig create mode 100644 Task/Abbreviations-easy/ArkScript/abbreviations-easy.ark create mode 100644 Task/Abbreviations-easy/PascalABC.NET/abbreviations-easy.pas create mode 100644 Task/Abbreviations-simple/PascalABC.NET/abbreviations-simple.pas create mode 100644 Task/Abelian-sandpile-model-Identity/Pluto/abelian-sandpile-model-identity.pluto create mode 100644 Task/Abelian-sandpile-model-Identity/Zig/abelian-sandpile-model-identity.zig create mode 100644 Task/Abelian-sandpile-model/Pluto/abelian-sandpile-model.pluto create mode 100644 Task/Abelian-sandpile-model/Zig/abelian-sandpile-model.zig create mode 100644 Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-1.pas create mode 100644 Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-2.pas create mode 100644 Task/Abstract-type/Haxe/abstract-type-1.haxe rename Task/Abstract-type/{Haskell/abstract-type-6.hs => Haxe/abstract-type-2.haxe} (100%) create mode 100644 Task/Abstract-type/Pluto/abstract-type.pluto create mode 100644 Task/Abundant-deficient-and-perfect-number-classifications/Agena/abundant-deficient-and-perfect-number-classifications.agena create mode 100644 Task/Abundant-deficient-and-perfect-number-classifications/Fennel/abundant-deficient-and-perfect-number-classifications.fennel create mode 100644 Task/Abundant-deficient-and-perfect-number-classifications/Pluto/abundant-deficient-and-perfect-number-classifications.pluto create mode 100644 Task/Abundant-odd-numbers/Agena/abundant-odd-numbers.agena create mode 100644 Task/Abundant-odd-numbers/Pluto/abundant-odd-numbers.pluto rename Task/Accumulator-factory/REBOL/{accumulator-factory.rebol => accumulator-factory-1.rebol} (70%) create mode 100644 Task/Accumulator-factory/REBOL/accumulator-factory-2.rebol create mode 100644 Task/Achilles-numbers/Pluto/achilles-numbers.pluto create mode 100644 Task/Ackermann-function/ArkScript/ackermann-function.ark create mode 100644 Task/Ackermann-function/Pluto/ackermann-function.pluto create mode 100644 Task/Ackermann-function/REBOL/ackermann-function-1.rebol create mode 100644 Task/Ackermann-function/REBOL/ackermann-function-2.rebol create mode 100644 Task/Ackermann-function/TAV/ackermann-function.tav create mode 100644 Task/Address-of-a-variable/Pluto/address-of-a-variable.pluto create mode 100644 Task/Address-of-a-variable/RISC-V-Assembly/address-of-a-variable.asm create mode 100644 Task/Address-of-a-variable/Red/address-of-a-variable.red create mode 100644 Task/Aliquot-sequence-classifications/JavaScript/aliquot-sequence-classifications.js create mode 100644 Task/Almkvist-Giullera-formula-for-pi/Ada/almkvist-giullera-formula-for-pi.ada create mode 100644 Task/Almost-prime/Pluto/almost-prime.pluto rename Task/Amb/Ada/{amb.ada => amb-1.ada} (100%) create mode 100644 Task/Amb/Ada/amb-2.ada delete mode 100644 Task/Amicable-pairs/PL-I-80/amicable-pairs-1.pli rename Task/Amicable-pairs/PL-I-80/{amicable-pairs-2.pli => amicable-pairs.pli} (89%) create mode 100644 Task/Anagrams/DuckDB/anagrams.duckdb create mode 100644 Task/Anagrams/TAV/anagrams.tav create mode 100644 Task/Angles-geometric-normalization-and-conversion/R/angles-geometric-normalization-and-conversion.r create mode 100644 Task/Anonymous-recursion/DuckDB/anonymous-recursion.duckdb create mode 100644 Task/Anti-primes/Bc/anti-primes.bc create mode 100644 Task/Anti-primes/Draco/anti-primes.draco create mode 100644 Task/Anti-primes/Pluto/anti-primes.pluto create mode 100644 Task/Apply-a-callback-to-an-array/ArkScript/apply-a-callback-to-an-array.ark create mode 100644 Task/Apply-a-callback-to-an-array/Haxe/apply-a-callback-to-an-array.haxe create mode 100644 Task/Approximate-equality/Pluto/approximate-equality.pluto create mode 100644 Task/Arbitrary-precision-integers-included-/Agena/arbitrary-precision-integers-included-.agena create mode 100644 Task/Arbitrary-precision-integers-included-/BBC-BASIC/arbitrary-precision-integers-included-.basic create mode 100644 Task/Arbitrary-precision-integers-included-/Pluto/arbitrary-precision-integers-included-.pluto create mode 100644 Task/Arbitrary-precision-integers-included-/Rhombus/arbitrary-precision-integers-included-.rhombus create mode 100644 Task/Arithmetic-Complex/ArkScript/arithmetic-complex.ark create mode 100644 Task/Arithmetic-Complex/DuckDB/arithmetic-complex.duckdb create mode 100644 Task/Arithmetic-Complex/FutureBasic/arithmetic-complex.basic create mode 100644 Task/Arithmetic-Complex/Pluto/arithmetic-complex.pluto create mode 100644 Task/Arithmetic-Integer/ArkScript/arithmetic-integer.ark create mode 100644 Task/Arithmetic-Integer/DuckDB/arithmetic-integer.duckdb create mode 100644 Task/Arithmetic-Integer/Pluto/arithmetic-integer.pluto create mode 100644 Task/Arithmetic-Integer/RISC-V-Assembly/arithmetic-integer.asm create mode 100644 Task/Arithmetic-Integer/Red/arithmetic-integer.red create mode 100644 Task/Arithmetic-Integer/TAV/arithmetic-integer.tav create mode 100644 Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto create mode 100644 Task/Arithmetic-derivative/Bc/arithmetic-derivative.bc create mode 100644 Task/Arithmetic-derivative/Pluto/arithmetic-derivative.pluto create mode 100644 Task/Arithmetic-evaluation/PascalABC.NET/arithmetic-evaluation.pas rename Task/Arithmetic-evaluation/Perl/{arithmetic-evaluation.pl => arithmetic-evaluation-1.pl} (100%) create mode 100644 Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-2.pl create mode 100644 Task/Arithmetic-evaluation/Red/arithmetic-evaluation.red create mode 100644 Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-1.duckdb create mode 100644 Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-2.duckdb create mode 100644 Task/Arithmetic-geometric-mean/Pluto/arithmetic-geometric-mean.pluto create mode 100644 Task/Arithmetic-numbers/DuckDB/arithmetic-numbers.duckdb create mode 100644 Task/Array-concatenation/ArkScript/array-concatenation.ark create mode 100644 Task/Array-concatenation/DuckDB/array-concatenation.duckdb create mode 100644 Task/Array-concatenation/Pluto/array-concatenation.pluto create mode 100644 Task/Array-concatenation/TAV/array-concatenation.tav create mode 100644 Task/Array-length/ArkScript/array-length.ark create mode 100644 Task/Array-length/DuckDB/array-length.duckdb create mode 100644 Task/Array-length/Maxima/array-length.maxima create mode 100644 Task/Array-length/TAV/array-length.tav create mode 100644 Task/Array-length/Tcl/array-length-1.tcl create mode 100644 Task/Array-length/Tcl/array-length-2.tcl create mode 100644 Task/Array-length/Tcl/array-length-3.tcl create mode 100644 Task/Array-length/Tcl/array-length-4.tcl create mode 100644 Task/Array-length/Tcl/array-length-5.tcl create mode 100644 Task/Array-length/Tcl/array-length-6.tcl create mode 100644 Task/Array-length/Tcl/array-length-7.tcl delete mode 100644 Task/Array-length/Tcl/array-length.tcl create mode 100644 Task/Arrays/DuckDB/arrays.duckdb create mode 100644 Task/Arrays/Extended-Color-BASIC/arrays.basic create mode 100644 Task/Arrays/Haxe/arrays.haxe create mode 100644 Task/Arrays/Pluto/arrays.pluto create mode 100644 Task/Arrays/Unicon/arrays-1.unicon create mode 100644 Task/Arrays/Unicon/arrays-2.unicon create mode 100644 Task/Arrays/Unicon/arrays-3.unicon create mode 100644 Task/Arrays/Zig/arrays-1.zig create mode 100644 Task/Arrays/Zig/arrays-2.zig create mode 100644 Task/Ascending-primes/ArkScript/ascending-primes.ark create mode 100644 Task/Ascending-primes/Pluto/ascending-primes.pluto create mode 100644 Task/Associative-array-Creation/ArkScript/associative-array-creation.ark create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-1.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-2.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-3.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-4.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-5.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-6.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-7.duckdb create mode 100644 Task/Associative-array-Creation/DuckDB/associative-array-creation-8.duckdb create mode 100644 Task/Associative-array-Creation/Haxe/associative-array-creation.haxe create mode 100644 Task/Associative-array-Creation/Pluto/associative-array-creation.pluto delete mode 100644 Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx delete mode 100644 Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx create mode 100644 Task/Associative-array-Creation/REXX/associative-array-creation.rexx delete mode 100644 Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-2.sh rename Task/Associative-array-Creation/UNIX-Shell/{associative-array-creation-1.sh => associative-array-creation.sh} (100%) create mode 100644 Task/Associative-array-Creation/Zig/associative-array-creation-1.zig create mode 100644 Task/Associative-array-Creation/Zig/associative-array-creation-2.zig create mode 100644 Task/Associative-array-Iteration/ArkScript/associative-array-iteration.ark create mode 100644 Task/Associative-array-Iteration/DuckDB/associative-array-iteration.duckdb delete mode 100644 Task/Associative-array-Iteration/Elena/associative-array-iteration-1.elena rename Task/Associative-array-Iteration/Elena/{associative-array-iteration-2.elena => associative-array-iteration.elena} (100%) create mode 100644 Task/Associative-array-Iteration/Haxe/associative-array-iteration.haxe create mode 100644 Task/Associative-array-Iteration/Pluto/associative-array-iteration.pluto create mode 100644 Task/Associative-array-Iteration/TAV/associative-array-iteration.tav create mode 100644 Task/Associative-array-Iteration/Tcl/associative-array-iteration-3.tcl create mode 100644 Task/Associative-array-Iteration/Tcl/associative-array-iteration-4.tcl create mode 100644 Task/Associative-array-Iteration/Tcl/associative-array-iteration-5.tcl create mode 100644 Task/Associative-array-Iteration/Zig/associative-array-iteration-1.zig create mode 100644 Task/Associative-array-Iteration/Zig/associative-array-iteration-2.zig create mode 100644 Task/Associative-array-Merging/DuckDB/associative-array-merging-1.duckdb create mode 100644 Task/Associative-array-Merging/DuckDB/associative-array-merging-2.duckdb create mode 100644 Task/Associative-array-Merging/DuckDB/associative-array-merging-3.duckdb create mode 100644 Task/Associative-array-Merging/Fortran/associative-array-merging.f create mode 100644 Task/Associative-array-Merging/Pluto/associative-array-merging.pluto create mode 100644 Task/Attractive-numbers/Agena/attractive-numbers.agena create mode 100644 Task/Attractive-numbers/Pluto/attractive-numbers.pluto create mode 100644 Task/Averages-Arithmetic-mean/Apple/averages-arithmetic-mean.apple create mode 100644 Task/Averages-Arithmetic-mean/DuckDB/averages-arithmetic-mean.duckdb create mode 100644 Task/Averages-Arithmetic-mean/Pluto/averages-arithmetic-mean.pluto create mode 100644 Task/Averages-Mean-angle/DuckDB/averages-mean-angle.duckdb create mode 100644 Task/Averages-Mean-time-of-day/DuckDB/averages-mean-time-of-day.duckdb create mode 100644 Task/Averages-Mean-time-of-day/FutureBasic/averages-mean-time-of-day.basic create mode 100644 Task/Averages-Median/Pluto/averages-median.pluto create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-1.duckdb create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-2.duckdb create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-3.duckdb create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-4.duckdb create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-5.duckdb create mode 100644 Task/Averages-Mode/DuckDB/averages-mode-6.duckdb create mode 100644 Task/Averages-Pythagorean-means/Apple/averages-pythagorean-means.apple create mode 100644 Task/Averages-Pythagorean-means/DuckDB/averages-pythagorean-means.duckdb create mode 100644 Task/Averages-Pythagorean-means/Pluto/averages-pythagorean-means.pluto create mode 100644 Task/Averages-Root-mean-square/Pluto/averages-root-mean-square.pluto create mode 100644 Task/Averages-Root-mean-square/TAV/averages-root-mean-square.tav create mode 100644 Task/B-zier-curves-Intersections/JavaScript/b-zier-curves-intersections.js create mode 100644 Task/Babbage-problem/AutoLISP/babbage-problem.l create mode 100644 Task/Babbage-problem/DuckDB/babbage-problem-1.duckdb create mode 100644 Task/Babbage-problem/DuckDB/babbage-problem-2.duckdb create mode 100644 Task/Babylonian-spiral/FreeBASIC/babylonian-spiral.basic create mode 100644 Task/Balanced-brackets/ArkScript/balanced-brackets.ark create mode 100644 Task/Balanced-brackets/AutoLISP/balanced-brackets.l create mode 100644 Task/Balanced-brackets/Nom/balanced-brackets.num create mode 100644 Task/Balanced-brackets/Pluto/balanced-brackets.pluto create mode 100644 Task/Balanced-ternary/JavaScript/balanced-ternary.js create mode 100644 Task/Base64-decode-data/Pluto/base64-decode-data.pluto create mode 100644 Task/Base64-decode-data/Zig/base64-decode-data.zig create mode 100644 Task/Bell-numbers/Pluto/bell-numbers.pluto create mode 100644 Task/Benfords-law/DuckDB/benfords-law.duckdb create mode 100644 Task/Best-shuffle/Factor/best-shuffle.factor create mode 100644 Task/Best-shuffle/YAMLScript/best-shuffle.ys create mode 100644 Task/Bifid-cipher/Zig/bifid-cipher.zig create mode 100644 Task/Bin-given-limits/DuckDB/bin-given-limits-1.duckdb create mode 100644 Task/Bin-given-limits/DuckDB/bin-given-limits-2.duckdb create mode 100644 Task/Binary-digits/DuckDB/binary-digits-1.duckdb create mode 100644 Task/Binary-digits/DuckDB/binary-digits-2.duckdb create mode 100644 Task/Binary-digits/Haxe/binary-digits.haxe rename Task/Binary-digits/Icon/{binary-digits.icon => binary-digits-1.icon} (100%) create mode 100644 Task/Binary-digits/Icon/binary-digits-2.icon create mode 100644 Task/Binary-digits/RISC-V-Assembly/binary-digits.asm create mode 100644 Task/Bioinformatics-base-count/DuckDB/bioinformatics-base-count.duckdb create mode 100644 Task/Bioinformatics-base-count/PascalABC.NET/bioinformatics-base-count.pas create mode 100644 Task/Biorhythms/Ada/biorhythms.ada create mode 100644 Task/Bitcoin-public-point-to-address/FreeBASIC/bitcoin-public-point-to-address.basic create mode 100644 Task/Bitcoin-public-point-to-address/JavaScript/bitcoin-public-point-to-address.js create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Pluto/bitmap-bresenhams-line-algorithm.pluto create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/EasyLang/bitmap-midpoint-circle-algorithm.easy create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Pluto/bitmap-midpoint-circle-algorithm.pluto create mode 100644 Task/Bitmap/Pluto/bitmap.pluto create mode 100644 Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb create mode 100644 Task/Bitwise-IO/DuckDB/bitwise-io-2.duckdb create mode 100644 Task/Bitwise-operations/DuckDB/bitwise-operations-1.duckdb create mode 100644 Task/Bitwise-operations/DuckDB/bitwise-operations-2.duckdb create mode 100644 Task/Bitwise-operations/Pluto/bitwise-operations.pluto create mode 100644 Task/Boolean-values/ArkScript/boolean-values.ark create mode 100644 Task/Boolean-values/Haxe/boolean-values.haxe create mode 100644 Task/Boolean-values/Prolog/boolean-values.pro create mode 100644 Task/Boolean-values/Zig/boolean-values.zig create mode 100644 Task/Boyer-Moore-string-search/Ada/boyer-moore-string-search.ada create mode 100644 Task/Boyer-Moore-string-search/Dart/boyer-moore-string-search.dart create mode 100644 Task/Boyer-Moore-string-search/FutureBasic/boyer-moore-string-search.basic create mode 100644 Task/Boyer-Moore-string-search/Kotlin/boyer-moore-string-search.kts create mode 100644 Task/Boyer-Moore-string-search/Swift/boyer-moore-string-search.swift create mode 100644 Task/Boyer-Moore-string-search/Zig/boyer-moore-string-search.zig create mode 100644 Task/Break-OO-privacy/Dart/break-oo-privacy.dart create mode 100644 Task/Break-OO-privacy/JavaScript/break-oo-privacy.js create mode 100644 Task/Break-OO-privacy/Rust/break-oo-privacy.rs create mode 100644 Task/Break-OO-privacy/Zig/break-oo-privacy.zig create mode 100644 Task/CRC-32/FutureBasic/crc-32.basic create mode 100644 Task/CRC-32/Pluto/crc-32.pluto create mode 100644 Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb create mode 100644 Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb create mode 100644 Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb create mode 100644 Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num create mode 100644 Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num create mode 100644 Task/CUSIP/R/cusip.r create mode 100644 Task/Caesar-cipher/Pluto/caesar-cipher.pluto create mode 100644 Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus create mode 100644 Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark create mode 100644 Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-1.elena create mode 100644 Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-2.elena delete mode 100644 Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers.elena create mode 100644 Task/Calendar---for-REAL-programmers/Red/calendar---for-real-programmers.red create mode 100644 Task/Calendar/Red/calendar.red create mode 100644 Task/Calkin-Wilf-sequence/Ada/calkin-wilf-sequence.ada create mode 100644 Task/Calkin-Wilf-sequence/Pluto/calkin-wilf-sequence.pluto create mode 100644 Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-1.pluto create mode 100644 Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-2.pluto create mode 100644 Task/Call-a-function-in-a-shared-library/Pluto/call-a-function-in-a-shared-library.pluto create mode 100644 Task/Call-a-function/ArkScript/call-a-function-1.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-2.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-3.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-4.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-5.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-6.ark create mode 100644 Task/Call-a-function/ArkScript/call-a-function-7.ark create mode 100644 Task/Call-a-function/DuckDB/call-a-function-1.duckdb create mode 100644 Task/Call-a-function/DuckDB/call-a-function-2.duckdb create mode 100644 Task/Call-an-object-method/ArkScript/call-an-object-method.ark create mode 100644 Task/Call-an-object-method/Haxe/call-an-object-method.haxe create mode 100644 Task/Camel-case-and-snake-case/Ada/camel-case-and-snake-case.ada create mode 100644 Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs create mode 100644 Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math create mode 100644 Task/Camel-case-and-snake-case/Rust/camel-case-and-snake-case.rs create mode 100644 Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig create mode 100644 Task/Canonicalize-CIDR/Ada/canonicalize-cidr.ada create mode 100644 Task/Carmichael-3-strong-pseudoprimes/FutureBasic/carmichael-3-strong-pseudoprimes.basic create mode 100644 Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-1.duckdb create mode 100644 Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-2.duckdb create mode 100644 Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb create mode 100644 Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb create mode 100644 Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas create mode 100644 Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto create mode 100644 Task/Casting-out-nines/Pluto/casting-out-nines.pluto create mode 100644 Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb create mode 100644 Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-2.duckdb create mode 100644 Task/Catalan-numbers-Pascals-triangle/Fortran/catalan-numbers-pascals-triangle.f create mode 100644 Task/Catalan-numbers-Pascals-triangle/Objeck/catalan-numbers-pascals-triangle.objeck create mode 100644 Task/Catalan-numbers/DuckDB/catalan-numbers.duckdb create mode 100644 Task/Catamorphism/Apple/catamorphism-1.apple create mode 100644 Task/Catamorphism/Apple/catamorphism-2.apple create mode 100644 Task/Catamorphism/Apple/catamorphism-3.apple create mode 100644 Task/Catamorphism/ArkScript/catamorphism.ark create mode 100644 Task/Catmull-Clark-subdivision-surface/FreeBASIC/catmull-clark-subdivision-surface.basic create mode 100644 Task/Catmull-Clark-subdivision-surface/JavaScript/catmull-clark-subdivision-surface.js create mode 100644 Task/Chaocipher/Swift/chaocipher.swift create mode 100644 Task/Character-codes/Haxe/character-codes.haxe create mode 100644 Task/Character-codes/TAV/character-codes.tav create mode 100644 Task/Check-that-file-exists/ArkScript/check-that-file-exists.ark create mode 100644 Task/Check-that-file-exists/DuckDB/check-that-file-exists.duckdb create mode 100644 Task/Checkpoint-synchronization/JavaScript/checkpoint-synchronization.js create mode 100644 Task/Chinese-zodiac/Fortran/chinese-zodiac.f create mode 100644 Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy create mode 100644 Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig create mode 100644 Task/Cistercian-numerals/C-sharp/cistercian-numerals.cs create mode 100644 Task/Cistercian-numerals/Free-Pascal-Lazarus/cistercian-numerals.pas create mode 100644 Task/Cistercian-numerals/Modula-2/cistercian-numerals.mod2 create mode 100644 Task/Cistercian-numerals/Pascal-P/cistercian-numerals.pas create mode 100644 Task/Cistercian-numerals/XPL0/cistercian-numerals.xpl0 create mode 100644 Task/Classes/Haxe/classes-1.haxe rename Task/Classes/{Haskell/classes-3.hs => Haxe/classes-2.haxe} (100%) create mode 100644 Task/Closures-Value-capture/ArkScript/closures-value-capture.ark create mode 100644 Task/Collections/DuckDB/collections.duckdb create mode 100644 Task/Collections/Pluto/collections.pluto create mode 100644 Task/Color-quantization/FreeBASIC/color-quantization.basic create mode 100644 Task/Combinations-with-repetitions/DuckDB/combinations-with-repetitions.duckdb create mode 100644 Task/Combinations-with-repetitions/PascalABC.NET/combinations-with-repetitions.pas create mode 100644 Task/Combinations-with-repetitions/Pluto/combinations-with-repetitions.pluto create mode 100644 Task/Combinations/DuckDB/combinations.duckdb create mode 100644 Task/Combinations/Pluto/combinations.pluto create mode 100644 Task/Command-line-arguments/Pluto/command-line-arguments.pluto create mode 100644 Task/Command-line-arguments/TAV/command-line-arguments.tav create mode 100644 Task/Comments/ArkScript/comments.ark create mode 100644 Task/Comments/Ballerina/comments.ballerina create mode 100644 Task/Comments/Idris/comments.idris create mode 100644 Task/Comments/Janet/comments.janet create mode 100644 Task/Comments/Odin/comments.odin create mode 100644 Task/Comments/Pluto/comments.pluto create mode 100644 Task/Compare-a-list-of-strings/DuckDB/compare-a-list-of-strings-1.duckdb create mode 100644 Task/Compare-a-list-of-strings/DuckDB/compare-a-list-of-strings-2.duckdb create mode 100644 Task/Compare-a-list-of-strings/DuckDB/compare-a-list-of-strings-3.duckdb create mode 100644 Task/Compare-a-list-of-strings/Ring/compare-a-list-of-strings.ring rename Task/Compare-a-list-of-strings/Tcl/{compare-a-list-of-strings.tcl => compare-a-list-of-strings-1.tcl} (100%) create mode 100644 Task/Compare-a-list-of-strings/Tcl/compare-a-list-of-strings-2.tcl create mode 100644 Task/Compare-length-of-two-strings/DuckDB/compare-length-of-two-strings-1.duckdb create mode 100644 Task/Compare-length-of-two-strings/DuckDB/compare-length-of-two-strings-2.duckdb create mode 100644 Task/Compare-length-of-two-strings/DuckDB/compare-length-of-two-strings-3.duckdb create mode 100644 Task/Compare-length-of-two-strings/Pluto/compare-length-of-two-strings.pluto create mode 100644 Task/Compile-time-calculation/V-(Vlang)/compile-time-calculation.v create mode 100644 Task/Compiler-lexical-analyzer/Pluto/compiler-lexical-analyzer.pluto create mode 100644 Task/Compound-data-type/ArkScript/compound-data-type.ark create mode 100644 Task/Compound-data-type/DuckDB/compound-data-type.duckdb create mode 100644 Task/Concurrent-computing/ArkScript/concurrent-computing.ark rename Task/Concurrent-computing/Rust/{concurrent-computing.rs => concurrent-computing-1.rs} (100%) create mode 100644 Task/Concurrent-computing/Rust/concurrent-computing-2.rs create mode 100644 Task/Concurrent-computing/Rust/concurrent-computing-3.rs create mode 100644 Task/Conditional-structures/ArkScript/conditional-structures.ark create mode 100644 Task/Conditional-structures/DuckDB/conditional-structures-1.duckdb create mode 100644 Task/Conditional-structures/DuckDB/conditional-structures-2.duckdb create mode 100644 Task/Conditional-structures/DuckDB/conditional-structures-3.duckdb create mode 100644 Task/Conditional-structures/Pluto/conditional-structures.pluto create mode 100644 Task/Conditional-structures/TAV/conditional-structures-1.tav create mode 100644 Task/Conditional-structures/TAV/conditional-structures-2.tav create mode 100644 Task/Conditional-structures/TAV/conditional-structures-3.tav create mode 100644 Task/Constrained-genericity/C++/constrained-genericity-1.cpp rename Task/Constrained-genericity/C++/{constrained-genericity.cpp => constrained-genericity-2.cpp} (83%) rename Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Julia/{continued-fraction-arithmetic-construct-from-rational-number.jl => continued-fraction-arithmetic-construct-from-rational-number-1.jl} (100%) create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Julia/continued-fraction-arithmetic-construct-from-rational-number-2.jl create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Pluto/continued-fraction-arithmetic-construct-from-rational-number.pluto create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Dart/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.dart create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/JavaScript/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.js create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Perl/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.pl create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Rust/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.rs create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Scala/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.scala create mode 100644 Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Swift/continued-fraction-arithmetic-g-matrix-ng-continued-fraction-n-.swift create mode 100644 Task/Continued-fraction/Dart/continued-fraction.dart create mode 100644 Task/Continued-fraction/JavaScript/continued-fraction.js create mode 100644 Task/Continued-fraction/R/continued-fraction.r create mode 100644 Task/Convert-decimal-number-to-rational/Pluto/convert-decimal-number-to-rational.pluto create mode 100644 Task/Convert-seconds-to-compound-duration/DuckDB/convert-seconds-to-compound-duration.duckdb create mode 100644 Task/Conways-Game-of-Life/ArkScript/conways-game-of-life.ark create mode 100644 Task/Conways-Game-of-Life/YAMLScript/conways-game-of-life.ys create mode 100644 Task/Copy-a-string/ArkScript/copy-a-string.ark create mode 100644 Task/Copy-a-string/DuckDB/copy-a-string.duckdb create mode 100644 Task/Copy-a-string/Extended-Color-BASIC/copy-a-string.basic create mode 100644 Task/Copy-a-string/TAV/copy-a-string.tav create mode 100644 Task/Count-in-octal/Pluto/count-in-octal.pluto create mode 100644 Task/Count-occurrences-of-a-substring/DuckDB/count-occurrences-of-a-substring.duckdb create mode 100644 Task/Count-the-coins/Pluto/count-the-coins.pluto create mode 100644 Task/Cramers-rule/R/cramers-rule.r create mode 100644 Task/Create-a-file/Pluto/create-a-file-1.pluto create mode 100644 Task/Create-a-file/Pluto/create-a-file-2.pluto create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/DuckDB/create-a-two-dimensional-array-at-runtime.duckdb create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/TAV/create-a-two-dimensional-array-at-runtime.tav create mode 100644 Task/Cumulative-standard-deviation/DuckDB/cumulative-standard-deviation.duckdb create mode 100644 Task/Cumulative-standard-deviation/Zig/cumulative-standard-deviation.zig create mode 100644 Task/Currency/DuckDB/currency.duckdb create mode 100644 Task/Currency/EasyLang/currency.easy create mode 100644 Task/Currying/ArkScript/currying.ark create mode 100644 Task/Currying/Pluto/currying.pluto create mode 100644 Task/Currying/Red/currying.red create mode 100644 Task/Curzon-numbers/R/curzon-numbers.r create mode 100644 Task/Cyclops-numbers/Rust/cyclops-numbers.rs create mode 100644 Task/Cyclops-numbers/Zig/cyclops-numbers.zig create mode 100644 Task/Cyclotomic-polynomial/Fortran/cyclotomic-polynomial.f create mode 100644 Task/Damm-algorithm/Prolog/damm-algorithm.pro rename Task/Date-format/REBOL/{date-format.rebol => date-format-1.rebol} (100%) create mode 100644 Task/Date-format/REBOL/date-format-2.rebol create mode 100644 Task/Date-manipulation/ALGOL-68/date-manipulation.alg create mode 100644 Task/Day-of-the-week/DuckDB/day-of-the-week-1.duckdb create mode 100644 Task/Day-of-the-week/DuckDB/day-of-the-week-2.duckdb create mode 100644 Task/Day-of-the-week/DuckDB/day-of-the-week-3.duckdb create mode 100644 Task/Deal-cards-for-FreeCell/FutureBasic/deal-cards-for-freecell.basic create mode 100644 Task/Death-Star/EasyLang/death-star.easy create mode 100644 Task/Deconvolution-1D/JavaScript/deconvolution-1d.js create mode 100644 Task/Deconvolution-1D/Rust/deconvolution-1d.rs create mode 100644 Task/Deconvolution-1D/Zig/deconvolution-1d.zig create mode 100644 Task/Deconvolution-2D+/JavaScript/deconvolution-2d+.js create mode 100644 Task/Deconvolution-2D+/Rust/deconvolution-2d+.rs create mode 100644 Task/Deepcopy/Ada/deepcopy.ada create mode 100644 Task/Define-a-primitive-data-type/DuckDB/define-a-primitive-data-type.duckdb create mode 100644 Task/Delete-a-file/ArkScript/delete-a-file.ark create mode 100644 Task/Delete-a-file/Maxima/delete-a-file.maxima create mode 100644 Task/Delete-a-file/Pluto/delete-a-file.pluto create mode 100644 Task/Demings-funnel/FutureBasic/demings-funnel.basic create mode 100644 Task/Department-numbers/Bc/department-numbers.bc create mode 100644 Task/Department-numbers/Crystal/department-numbers.cr create mode 100644 Task/Descending-primes/Pluto/descending-primes.pluto create mode 100644 Task/Detect-division-by-zero/DuckDB/detect-division-by-zero.duckdb create mode 100644 Task/Determinant-and-permanent/DuckDB/determinant-and-permanent.duckdb create mode 100644 Task/Determinant-and-permanent/Elixir/determinant-and-permanent.ex create mode 100644 Task/Determinant-and-permanent/Erlang/determinant-and-permanent.erl create mode 100644 Task/Determinant-and-permanent/Zig/determinant-and-permanent.zig create mode 100644 Task/Determine-if-a-string-has-all-the-same-characters/DuckDB/determine-if-a-string-has-all-the-same-characters.duckdb create mode 100644 Task/Determine-if-a-string-has-all-unique-characters/DuckDB/determine-if-a-string-has-all-unique-characters.duckdb create mode 100644 Task/Determine-if-a-string-is-collapsible/DuckDB/determine-if-a-string-is-collapsible.duckdb create mode 100644 Task/Determine-if-a-string-is-numeric/DuckDB/determine-if-a-string-is-numeric.duckdb create mode 100644 Task/Determine-if-a-string-is-numeric/Nom/determine-if-a-string-is-numeric.num create mode 100644 Task/Determine-if-a-string-is-numeric/Pluto/determine-if-a-string-is-numeric.pluto create mode 100644 Task/Determine-if-a-string-is-numeric/Tcl/determine-if-a-string-is-numeric-1.tcl create mode 100644 Task/Determine-if-a-string-is-numeric/Tcl/determine-if-a-string-is-numeric-2.tcl delete mode 100644 Task/Determine-if-a-string-is-numeric/Tcl/determine-if-a-string-is-numeric.tcl create mode 100644 Task/Determine-if-a-string-is-squeezable/DuckDB/determine-if-a-string-is-squeezable.duckdb create mode 100644 Task/Determine-if-two-triangles-overlap/Rust/determine-if-two-triangles-overlap.rs create mode 100644 Task/Determine-sentence-type/DuckDB/determine-sentence-type.duckdb create mode 100644 Task/Digital-root/DuckDB/digital-root.duckdb create mode 100644 Task/Dijkstras-algorithm/Dart/dijkstras-algorithm.dart create mode 100644 Task/Dijkstras-algorithm/R/dijkstras-algorithm.r create mode 100644 Task/Disarium-numbers/Agena/disarium-numbers.agena create mode 100644 Task/Disarium-numbers/Fortran/disarium-numbers.f create mode 100644 Task/Disarium-numbers/Frink/disarium-numbers.frink create mode 100644 Task/Disarium-numbers/Objeck/disarium-numbers.objeck create mode 100644 Task/Disarium-numbers/Pluto/disarium-numbers.pluto create mode 100644 Task/Display-a-linear-combination/Fortran/display-a-linear-combination.f create mode 100644 Task/Display-a-linear-combination/Pluto/display-a-linear-combination.pluto create mode 100644 Task/Distance-and-Bearing/Go/distance-and-bearing.go create mode 100644 Task/Distribution-of-0-digits-in-factorial-series/ALGOL-68/distribution-of-0-digits-in-factorial-series.alg create mode 100644 Task/Distribution-of-0-digits-in-factorial-series/EasyLang/distribution-of-0-digits-in-factorial-series.easy create mode 100644 Task/Distribution-of-0-digits-in-factorial-series/Pluto/distribution-of-0-digits-in-factorial-series.pluto create mode 100644 Task/Diversity-prediction-theorem/DuckDB/diversity-prediction-theorem.duckdb create mode 100644 Task/Documentation/DuckDB/documentation-1.duckdb create mode 100644 Task/Documentation/DuckDB/documentation-2.duckdb create mode 100644 Task/Documentation/DuckDB/documentation-3.duckdb create mode 100644 Task/Documentation/Unicon/documentation-1.unicon create mode 100644 Task/Documentation/Unicon/documentation-2.unicon create mode 100644 Task/Documentation/Unicon/documentation-3.unicon delete mode 100644 Task/Documentation/Unicon/documentation.unicon create mode 100644 Task/Dominoes/FreeBASIC/dominoes-1.basic create mode 100644 Task/Dominoes/FreeBASIC/dominoes-2.basic create mode 100644 Task/Dot-product/Apple/dot-product.apple create mode 100644 Task/Dot-product/DuckDB/dot-product-1.duckdb create mode 100644 Task/Dot-product/DuckDB/dot-product-2.duckdb create mode 100644 Task/Dot-product/DuckDB/dot-product-3.duckdb create mode 100644 Task/Dot-product/DuckDB/dot-product-4.duckdb create mode 100644 Task/Doubly-linked-list-Definition/Pluto/doubly-linked-list-definition.pluto create mode 100644 Task/Doubly-linked-list-Element-definition/Pluto/doubly-linked-list-element-definition.pluto create mode 100644 Task/Doubly-linked-list-Traversal/Pluto/doubly-linked-list-traversal.pluto create mode 100644 Task/Dragon-curve/YAMLScript/dragon-curve.ys create mode 100644 Task/Draw-a-sphere/EasyLang/draw-a-sphere.easy create mode 100644 Task/Duffinian-numbers/Rust/duffinian-numbers.rs create mode 100644 Task/Dutch-national-flag-problem/Pluto/dutch-national-flag-problem.pluto create mode 100644 Task/Dynamic-variable-names/DuckDB/dynamic-variable-names.duckdb create mode 100644 Task/EKG-sequence-convergence/EasyLang/ekg-sequence-convergence.easy create mode 100644 Task/EKG-sequence-convergence/Fortran/ekg-sequence-convergence.f create mode 100644 Task/Earliest-difference-between-prime-gaps/EasyLang/earliest-difference-between-prime-gaps.easy create mode 100644 Task/Eertree/Zig/eertree.zig create mode 100644 Task/Egyptian-division/Fortran/egyptian-division.f create mode 100644 Task/Element-wise-operations/DuckDB/element-wise-operations-1.duckdb create mode 100644 Task/Element-wise-operations/DuckDB/element-wise-operations-2.duckdb create mode 100644 Task/Elementary-cellular-automaton-Infinite-length/EasyLang/elementary-cellular-automaton-infinite-length.easy create mode 100644 Task/Elliptic-Curve-Digital-Signature-Algorithm/Zig/elliptic-curve-digital-signature-algorithm.zig create mode 100644 Task/Elliptic-curve-arithmetic/Rust/elliptic-curve-arithmetic.rs create mode 100644 Task/Elliptic-curve-arithmetic/Zig/elliptic-curve-arithmetic.zig create mode 100644 Task/Empty-directory/ArkScript/empty-directory.ark create mode 100644 Task/Empty-program/ArkScript/empty-program-1.ark create mode 100644 Task/Empty-program/ArkScript/empty-program-2.ark create mode 100644 Task/Empty-string/ArkScript/empty-string.ark create mode 100644 Task/Empty-string/DuckDB/empty-string.duckdb create mode 100644 Task/Empty-string/Nom/empty-string.num create mode 100644 Task/Empty-string/TAV/empty-string.tav create mode 100644 Task/Enforced-immutability/ArkScript/enforced-immutability.ark create mode 100644 Task/Entropy-Narcissist/AutoLISP/entropy-narcissist.l create mode 100644 Task/Entropy/AutoLISP/entropy.l create mode 100644 Task/Entropy/DuckDB/entropy.duckdb create mode 100644 Task/Enumerations/DuckDB/enumerations.duckdb create mode 100644 Task/Equilibrium-index/DuckDB/equilibrium-index.duckdb create mode 100644 Task/Erd-s-Nicolas-numbers/Mathematica/erd-s-nicolas-numbers.math create mode 100644 Task/Erd-s-Selfridge-categorization-of-primes/EasyLang/erd-s-selfridge-categorization-of-primes.easy create mode 100644 Task/Euler-method/DuckDB/euler-method.duckdb create mode 100644 Task/Euler-method/FutureBasic/euler-method.basic create mode 100644 Task/Euler-method/Pluto/euler-method.pluto create mode 100644 Task/Eulers-constant-0.5772.../DuckDB/eulers-constant-0.5772....duckdb create mode 100644 Task/Eulers-identity/DuckDB/eulers-identity.duckdb create mode 100644 Task/Eulers-identity/Pluto/eulers-identity.pluto create mode 100644 Task/Evaluate-binomial-coefficients/DuckDB/evaluate-binomial-coefficients.duckdb create mode 100644 Task/Even-or-odd/Adina/even-or-odd-1.adina create mode 100644 Task/Even-or-odd/Adina/even-or-odd-2.adina create mode 100644 Task/Even-or-odd/ArkScript/even-or-odd.ark create mode 100644 Task/Even-or-odd/DuckDB/even-or-odd-1.duckdb create mode 100644 Task/Even-or-odd/DuckDB/even-or-odd-2.duckdb create mode 100644 Task/Even-or-odd/Nom/even-or-odd.num create mode 100644 Task/Even-or-odd/Pluto/even-or-odd.pluto create mode 100644 Task/Even-or-odd/YAMLScript/even-or-odd.ys create mode 100644 Task/Evolutionary-algorithm/Zig/evolutionary-algorithm.zig create mode 100644 Task/Exceptions/C++/exceptions-5.cpp create mode 100644 Task/Exceptions/Phix/exceptions-3.phix rename Task/Exceptions/Tcl/{exceptions.tcl => exceptions-1.tcl} (100%) create mode 100644 Task/Exceptions/Tcl/exceptions-2.tcl create mode 100644 Task/Execute-HQ9+/R/execute-hq9+.r create mode 100644 Task/Execute-a-system-command/Pluto/execute-a-system-command.pluto create mode 100644 Task/Exponentiation-order/DuckDB/exponentiation-order.duckdb create mode 100644 Task/Exponentiation-order/Icon/exponentiation-order.icon create mode 100644 Task/Extend-your-language/ArkScript/extend-your-language.ark create mode 100644 Task/Extend-your-language/Koka/extend-your-language.koka create mode 100644 Task/Extreme-floating-point-values/DuckDB/extreme-floating-point-values-1.duckdb create mode 100644 Task/Extreme-floating-point-values/DuckDB/extreme-floating-point-values-2.duckdb create mode 100644 Task/Factorial-primes/AWK/factorial-primes.awk create mode 100644 Task/Factorial-primes/Agena/factorial-primes.agena create mode 100644 Task/Factorial-primes/Fennel/factorial-primes.fennel create mode 100644 Task/Factorial-primes/Pluto/factorial-primes.pluto create mode 100644 Task/Factorial-primes/R/factorial-primes.r delete mode 100644 Task/Factorial/ALGOL-60/factorial.alg delete mode 100644 Task/Factorial/ALGOL-68/factorial-1.alg delete mode 100644 Task/Factorial/ALGOL-68/factorial-2.alg delete mode 100644 Task/Factorial/ALGOL-68/factorial-3.alg delete mode 100644 Task/Factorial/ALGOL-W/factorial.alg create mode 100644 Task/Factorial/Agena/factorial.agena create mode 100644 Task/Factorial/Apple/factorial-1.apple create mode 100644 Task/Factorial/Apple/factorial-2.apple create mode 100644 Task/Factorial/CBASIC/factorial.basic create mode 100644 Task/Factorial/DuckDB/factorial-1.duckdb create mode 100644 Task/Factorial/DuckDB/factorial-2.duckdb create mode 100644 Task/Factorial/DuckDB/factorial-3.duckdb create mode 100644 Task/Factorial/Fennel/factorial.fennel create mode 100644 Task/Factorial/Mn/factorial.mn create mode 100644 Task/Factorial/Pluto/factorial.pluto create mode 100644 Task/Factorial/Rhombus/factorial-1.rhombus create mode 100644 Task/Factorial/Rhombus/factorial-2.rhombus create mode 100644 Task/Factorial/TAV/factorial.tav create mode 100644 Task/Factorial/Vyxal/factorial-1.vyxal create mode 100644 Task/Factorial/Vyxal/factorial-2.vyxal create mode 100644 Task/Factorial/Vyxal/factorial-3.vyxal create mode 100644 Task/Factorions/Ada/factorions.ada create mode 100644 Task/Factorions/Pluto/factorions.pluto create mode 100644 Task/Factors-of-an-integer/Apple/factors-of-an-integer.apple create mode 100644 Task/Factors-of-an-integer/DuckDB/factors-of-an-integer-1.duckdb create mode 100644 Task/Factors-of-an-integer/DuckDB/factors-of-an-integer-2.duckdb create mode 100644 Task/Factors-of-an-integer/Pluto/factors-of-an-integer.pluto create mode 100644 Task/Factors-of-an-integer/Zig/factors-of-an-integer.zig create mode 100644 Task/Fairshare-between-two-and-more/Bc/fairshare-between-two-and-more.bc create mode 100644 Task/Fairshare-between-two-and-more/DuckDB/fairshare-between-two-and-more.duckdb create mode 100644 Task/Farey-sequence/Pluto/farey-sequence.pluto create mode 100644 Task/Farey-sequence/Zig/farey-sequence.zig create mode 100644 Task/Faulhabers-formula/EasyLang/faulhabers-formula.easy create mode 100644 Task/Faulhabers-triangle/EasyLang/faulhabers-triangle.easy create mode 100644 Task/Faulhabers-triangle/Rust/faulhabers-triangle.rs create mode 100644 Task/Feigenbaum-constant-calculation/DuckDB/feigenbaum-constant-calculation.duckdb create mode 100644 Task/Feigenbaum-constant-calculation/Pluto/feigenbaum-constant-calculation.pluto create mode 100644 Task/Fibonacci-n-step-number-sequences/Julia/fibonacci-n-step-number-sequences-6.jl create mode 100644 Task/Fibonacci-n-step-number-sequences/R/fibonacci-n-step-number-sequences.r create mode 100644 Task/Fibonacci-sequence/ArkScript/fibonacci-sequence-1.ark create mode 100644 Task/Fibonacci-sequence/ArkScript/fibonacci-sequence-2.ark create mode 100644 Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-1.duckdb create mode 100644 Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-2.duckdb create mode 100644 Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-3.duckdb create mode 100644 Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-4.duckdb create mode 100644 Task/Fibonacci-sequence/Pluto/fibonacci-sequence.pluto create mode 100644 Task/Fibonacci-sequence/Rhombus/fibonacci-sequence-1.rhombus create mode 100644 Task/Fibonacci-sequence/Rhombus/fibonacci-sequence-2.rhombus create mode 100644 Task/Fibonacci-sequence/TAV/fibonacci-sequence-1.tav create mode 100644 Task/Fibonacci-sequence/TAV/fibonacci-sequence-2.tav create mode 100644 Task/Fibonacci-word-fractal/EasyLang/fibonacci-word-fractal.easy create mode 100644 Task/File-input-output/DuckDB/file-input-output.duckdb create mode 100644 Task/Filter/Apple/filter-1.apple create mode 100644 Task/Filter/Apple/filter-2.apple create mode 100644 Task/Filter/DuckDB/filter-1.duckdb create mode 100644 Task/Filter/DuckDB/filter-2.duckdb create mode 100644 Task/Filter/DuckDB/filter-3.duckdb create mode 100644 Task/Filter/DuckDB/filter-4.duckdb create mode 100644 Task/Filter/DuckDB/filter-5.duckdb create mode 100644 Task/Filter/DuckDB/filter-6.duckdb create mode 100644 Task/Filter/DuckDB/filter-7.duckdb create mode 100644 Task/Filter/Pluto/filter.pluto create mode 100644 Task/Find-Chess960-starting-position-identifier/EasyLang/find-chess960-starting-position-identifier.easy create mode 100644 Task/Find-duplicate-files/Ada/find-duplicate-files.ada create mode 100644 Task/Find-duplicate-files/FreeBASIC/find-duplicate-files.basic create mode 100644 Task/Find-largest-left-truncatable-prime-in-a-given-base/FreeBASIC/find-largest-left-truncatable-prime-in-a-given-base.basic create mode 100644 Task/Find-limit-of-recursion/DuckDB/find-limit-of-recursion.duckdb create mode 100644 Task/Find-limit-of-recursion/FutureBasic/find-limit-of-recursion.basic delete mode 100644 Task/Find-limit-of-recursion/REXX/find-limit-of-recursion-1.rexx delete mode 100644 Task/Find-limit-of-recursion/REXX/find-limit-of-recursion-2.rexx create mode 100644 Task/Find-limit-of-recursion/REXX/find-limit-of-recursion.rexx create mode 100644 Task/Find-the-last-Sunday-of-each-month/DuckDB/find-the-last-sunday-of-each-month.duckdb create mode 100644 Task/Five-weekends/DuckDB/five-weekends.duckdb create mode 100644 Task/Five-weekends/FutureBasic/five-weekends.basic create mode 100644 Task/Five-weekends/Red/five-weekends.red create mode 100644 Task/Fixed-length-records/DuckDB/fixed-length-records.duckdb create mode 100644 Task/FizzBuzz/ArkScript/fizzbuzz.ark delete mode 100644 Task/FizzBuzz/J/fizzbuzz-11.j create mode 100644 Task/FizzBuzz/Pascal-P/fizzbuzz.pas create mode 100644 Task/FizzBuzz/Pluto/fizzbuzz.pluto create mode 100644 Task/FizzBuzz/Rhombus/fizzbuzz.rhombus create mode 100644 Task/FizzBuzz/Vyxal/fizzbuzz.vyxal create mode 100644 Task/Flatten-a-list/ArkScript/flatten-a-list.ark create mode 100644 Task/Flatten-a-list/DuckDB/flatten-a-list.duckdb create mode 100644 Task/Flipping-bits-game/R/flipping-bits-game.r create mode 100644 Task/Floyd-Warshall-algorithm/Dart/floyd-warshall-algorithm.dart create mode 100644 Task/Floyd-Warshall-algorithm/Erlang/floyd-warshall-algorithm.erl create mode 100644 Task/Floyd-Warshall-algorithm/Pluto/floyd-warshall-algorithm.pluto create mode 100644 Task/Floyd-Warshall-algorithm/R/floyd-warshall-algorithm.r create mode 100644 Task/Floyd-Warshall-algorithm/Swift/floyd-warshall-algorithm.swift create mode 100644 Task/Formatted-numeric-output/DuckDB/formatted-numeric-output.duckdb create mode 100644 Task/Formatted-numeric-output/Pluto/formatted-numeric-output.pluto create mode 100644 Task/Formatted-numeric-output/TAV/formatted-numeric-output.tav create mode 100644 Task/Forward-difference/DuckDB/forward-difference.duckdb create mode 100644 Task/Fraction-reduction/EasyLang/fraction-reduction.easy create mode 100644 Task/Fractran/R/fractran.r create mode 100644 Task/Fractran/Rust/fractran.rs create mode 100644 Task/French-Republican-calendar/EasyLang/french-republican-calendar.easy create mode 100644 Task/French-Republican-calendar/Fortran/french-republican-calendar.f create mode 100644 Task/Function-definition/ArkScript/function-definition.ark create mode 100644 Task/Function-definition/DuckDB/function-definition-1.duckdb create mode 100644 Task/Function-definition/DuckDB/function-definition-2.duckdb create mode 100644 Task/Function-definition/Pluto/function-definition.pluto create mode 100644 Task/Function-prototype/EasyLang/function-prototype.easy create mode 100644 Task/GUI-component-interaction/FuncSug/gui-component-interaction.funcsug create mode 100644 Task/GUI-enabling-disabling-of-controls/FuncSug/gui-enabling-disabling-of-controls.funcsug create mode 100644 Task/Gamma-function/DuckDB/gamma-function.duckdb create mode 100644 Task/Gamma-function/FutureBasic/gamma-function.basic create mode 100644 Task/Gamma-function/Pluto/gamma-function.pluto create mode 100644 Task/Gapful-numbers/DuckDB/gapful-numbers.duckdb create mode 100644 Task/Gaussian-elimination/FutureBasic/gaussian-elimination.basic create mode 100644 Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-1.duckdb create mode 100644 Task/Generate-lower-case-ASCII-alphabet/DuckDB/generate-lower-case-ascii-alphabet-2.duckdb create mode 100644 Task/Generate-lower-case-ASCII-alphabet/Pluto/generate-lower-case-ascii-alphabet.pluto rename Task/Generator-Exponential/Icon/{generator-exponential.icon => generator-exponential-1.icon} (100%) create mode 100644 Task/Generator-Exponential/Icon/generator-exponential-2.icon create mode 100644 Task/Generic-swap/DuckDB/generic-swap.duckdb create mode 100644 Task/Giuga-numbers/Agena/giuga-numbers.agena create mode 100644 Task/Giuga-numbers/Pluto/giuga-numbers.pluto create mode 100644 Task/Giuga-numbers/R/giuga-numbers.r create mode 100644 Task/Goldbachs-comet/Agena/goldbachs-comet.agena create mode 100644 Task/Goldbachs-comet/Fennel/goldbachs-comet.fennel create mode 100644 Task/Goldbachs-comet/Pluto/goldbachs-comet.pluto create mode 100644 Task/Golden-ratio-Convergence/DuckDB/golden-ratio-convergence.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-1.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-2.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-3.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-4.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-5.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-6.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-7.duckdb create mode 100644 Task/Gotchas/DuckDB/gotchas-8.duckdb create mode 100644 Task/Gray-code/Zig/gray-code.zig create mode 100644 Task/Greatest-common-divisor/DuckDB/greatest-common-divisor.duckdb create mode 100644 Task/Greatest-common-divisor/Pluto/greatest-common-divisor.pluto create mode 100644 Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-1.duckdb create mode 100644 Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-2.duckdb create mode 100644 Task/Greatest-element-of-a-list/DuckDB/greatest-element-of-a-list-3.duckdb create mode 100644 Task/Greatest-element-of-a-list/Pluto/greatest-element-of-a-list.pluto create mode 100644 Task/Greatest-element-of-a-list/TAV/greatest-element-of-a-list.tav create mode 100644 Task/Greatest-subsequential-sum/DuckDB/greatest-subsequential-sum.duckdb create mode 100644 Task/Greedy-algorithm-for-Egyptian-fractions/R/greedy-algorithm-for-egyptian-fractions.r create mode 100644 Task/Guess-the-number-With-feedback-player-/FutureBasic/guess-the-number-with-feedback-player-.basic create mode 100644 Task/Guess-the-number-With-feedback/Rhombus/guess-the-number-with-feedback.rhombus create mode 100644 Task/Guess-the-number-With-feedback/TAV/guess-the-number-with-feedback.tav create mode 100644 Task/HTTP/DuckDB/http.duckdb create mode 100644 Task/HTTPS-Authenticated/DuckDB/https-authenticated.duckdb create mode 100644 Task/HTTPS-Client-authenticated/Objeck/https-client-authenticated.objeck create mode 100644 Task/HTTPS/DuckDB/https.duckdb create mode 100644 Task/HTTPS/TAV/https.tav create mode 100644 Task/Hailstone-sequence/DuckDB/hailstone-sequence.duckdb create mode 100644 Task/Hailstone-sequence/Pluto/hailstone-sequence.pluto create mode 100644 Task/Halt-and-catch-fire/Pluto/halt-and-catch-fire.pluto create mode 100644 Task/Halt-and-catch-fire/TAV/halt-and-catch-fire.tav create mode 100644 Task/Hamming-numbers/FutureBasic/hamming-numbers.basic create mode 100644 Task/Happy-numbers/Frink/happy-numbers.frink rename Task/Happy-numbers/REXX/{happy-numbers.rexx => happy-numbers-1.rexx} (100%) create mode 100644 Task/Happy-numbers/REXX/happy-numbers-2.rexx create mode 100644 Task/Harmonic-series/Ada/harmonic-series.ada create mode 100644 Task/Harmonic-series/DuckDB/harmonic-series.duckdb create mode 100644 Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-3.lisp create mode 100644 Task/Hash-from-two-arrays/DuckDB/hash-from-two-arrays.duckdb create mode 100644 Task/Hash-from-two-arrays/EasyLang/hash-from-two-arrays.easy create mode 100644 Task/Hash-from-two-arrays/Maxima/hash-from-two-arrays.maxima create mode 100644 Task/Hash-from-two-arrays/Pluto/hash-from-two-arrays.pluto create mode 100644 Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-3.tcl rename Task/Hash-from-two-arrays/UNIX-Shell/{hash-from-two-arrays.sh => hash-from-two-arrays-1.sh} (92%) create mode 100644 Task/Hash-from-two-arrays/UNIX-Shell/hash-from-two-arrays-2.sh create mode 100644 Task/Hash-join/DuckDB/hash-join.duckdb create mode 100644 Task/Haversine-formula/DuckDB/haversine-formula.duckdb create mode 100644 Task/Hello-world-Graphical/TAV/hello-world-graphical.tav create mode 100644 Task/Hello-world-Line-printer/ArkScript/hello-world-line-printer.ark create mode 100644 Task/Hello-world-Newbie/RISC-V-Assembly/hello-world-newbie.asm create mode 100644 Task/Hello-world-Newline-omission/ArkScript/hello-world-newline-omission.ark create mode 100644 Task/Hello-world-Newline-omission/Pluto/hello-world-newline-omission.pluto create mode 100644 Task/Hello-world-Newline-omission/Prolog/hello-world-newline-omission.pro create mode 100644 Task/Hello-world-Standard-error/Pluto/hello-world-standard-error.pluto create mode 100644 Task/Hello-world-Text/Adina/hello-world-text-1.adina create mode 100644 Task/Hello-world-Text/Adina/hello-world-text-2.adina create mode 100644 Task/Hello-world-Text/Aria/hello-world-text.aria create mode 100644 Task/Hello-world-Text/ArkScript/hello-world-text.ark create mode 100644 Task/Hello-world-Text/DuckDB/hello-world-text.duckdb create mode 100644 Task/Hello-world-Text/Extended-Color-BASIC/hello-world-text.basic create mode 100644 Task/Hello-world-Text/FuncSug/hello-world-text-1.funcsug create mode 100644 Task/Hello-world-Text/FuncSug/hello-world-text-2.funcsug create mode 100644 Task/Hello-world-Text/Nom/hello-world-text.num create mode 100644 Task/Hello-world-Text/Pico-8/hello-world-text-1.pico8 create mode 100644 Task/Hello-world-Text/Pico-8/hello-world-text-2.pico8 create mode 100644 Task/Hello-world-Text/Pluto/hello-world-text.pluto create mode 100644 Task/Hello-world-Text/Rhombus/hello-world-text.rhombus create mode 100644 Task/Hello-world-Text/TAV/hello-world-text.tav create mode 100644 Task/Here-document/DuckDB/here-document-1.duckdb create mode 100644 Task/Here-document/DuckDB/here-document-2.duckdb create mode 100644 Task/Higher-order-functions/Pluto/higher-order-functions.pluto create mode 100644 Task/Hofstadter-Figure-Figure-sequences/Fortran/hofstadter-figure-figure-sequences.f create mode 100644 Task/Honeycombs/EasyLang/honeycombs.easy create mode 100644 Task/Horners-rule-for-polynomial-evaluation/Agena/horners-rule-for-polynomial-evaluation.agena create mode 100644 Task/Horners-rule-for-polynomial-evaluation/Fennel/horners-rule-for-polynomial-evaluation.fennel create mode 100644 Task/Horners-rule-for-polynomial-evaluation/Pluto/horners-rule-for-polynomial-evaluation.pluto create mode 100644 Task/Humble-numbers/Agena/humble-numbers.agena create mode 100644 Task/Humble-numbers/Fortran/humble-numbers.f create mode 100644 Task/Humble-numbers/Pluto/humble-numbers.pluto create mode 100644 Task/Humble-numbers/R/humble-numbers.r create mode 100644 Task/Humble-numbers/Rust/humble-numbers.rs create mode 100644 Task/Hunt-the-Wumpus/EasyLang/hunt-the-wumpus.easy create mode 100644 Task/Hunt-the-Wumpus/Liberty-BASIC/hunt-the-wumpus.basic create mode 100644 Task/Hunt-the-Wumpus/Mojo/hunt-the-wumpus.mojo create mode 100644 Task/ISBN13-check-digit/Apple/isbn13-check-digit.apple create mode 100644 Task/ISBN13-check-digit/DuckDB/isbn13-check-digit.duckdb create mode 100644 Task/ISBN13-check-digit/Prolog/isbn13-check-digit-1.pro create mode 100644 Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro create mode 100644 Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro create mode 100644 Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro create mode 100644 Task/Identity-matrix/DuckDB/identity-matrix.duckdb create mode 100644 Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb create mode 100644 Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb create mode 100644 Task/Include-a-file/RISC-V-Assembly/include-a-file-1.asm create mode 100644 Task/Include-a-file/RISC-V-Assembly/include-a-file-2.asm create mode 100644 Task/Include-a-file/RISC-V-Assembly/include-a-file-3.asm create mode 100644 Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-1.duckdb create mode 100644 Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-2.duckdb create mode 100644 Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-3.duckdb create mode 100644 Task/Increment-a-numerical-string/Pluto/increment-a-numerical-string.pluto create mode 100644 Task/Infinity/ArkScript/infinity.ark create mode 100644 Task/Infinity/DuckDB/infinity.duckdb create mode 100644 Task/Infinity/Pluto/infinity.pluto create mode 100644 Task/Inheritance-Multiple/V-(Vlang)/inheritance-multiple.v create mode 100644 Task/Inheritance-Single/Rhombus/inheritance-single.rhombus create mode 100644 Task/Inheritance-Single/V-(Vlang)/inheritance-single.v create mode 100644 Task/Input-loop/Nom/input-loop.num create mode 100644 Task/Integer-comparison/DuckDB/integer-comparison.duckdb create mode 100644 Task/Integer-comparison/Prolog/integer-comparison-1.pro create mode 100644 Task/Integer-comparison/Prolog/integer-comparison-2.pro create mode 100644 Task/Integer-comparison/YAMLScript/integer-comparison.ys create mode 100644 Task/Integer-sequence/ArkScript/integer-sequence-1.ark create mode 100644 Task/Integer-sequence/ArkScript/integer-sequence-2.ark create mode 100644 Task/Introspection/DuckDB/introspection.duckdb create mode 100644 Task/Inverted-index/DuckDB/inverted-index.duckdb create mode 100644 Task/Inverted-syntax/DuckDB/inverted-syntax-1.duckdb create mode 100644 Task/Inverted-syntax/DuckDB/inverted-syntax-2.duckdb create mode 100644 Task/Inverted-syntax/DuckDB/inverted-syntax-3.duckdb create mode 100644 Task/Iterated-digits-squaring/Prolog/iterated-digits-squaring.pro create mode 100644 Task/JSON/Agena/json.agena create mode 100644 Task/JSON/DuckDB/json-1.duckdb create mode 100644 Task/JSON/DuckDB/json-2.duckdb create mode 100644 Task/JSON/DuckDB/json-3.duckdb create mode 100644 Task/JSON/Pluto/json.pluto rename Task/JSON/REBOL/{json.rebol => json-1.rebol} (81%) create mode 100644 Task/JSON/REBOL/json-2.rebol create mode 100644 Task/Jacobi-symbol/Excel/jacobi-symbol.excel create mode 100644 Task/Jacobsthal-numbers/Agena/jacobsthal-numbers.agena create mode 100644 Task/Jacobsthal-numbers/EasyLang/jacobsthal-numbers.easy create mode 100644 Task/Jacobsthal-numbers/Fennel/jacobsthal-numbers.fennel create mode 100644 Task/Jacobsthal-numbers/Lua/jacobsthal-numbers.lua create mode 100644 Task/Jacobsthal-numbers/Pluto/jacobsthal-numbers.pluto create mode 100644 Task/Jaro-similarity/DuckDB/jaro-similarity.duckdb create mode 100644 Task/Jewels-and-stones/Agena/jewels-and-stones.agena create mode 100644 Task/Jewels-and-stones/Fortran/jewels-and-stones.f create mode 100644 Task/Jewels-and-stones/Icon/jewels-and-stones.icon create mode 100644 Task/Jewels-and-stones/Pluto/jewels-and-stones.pluto create mode 100644 Task/JortSort/YAMLScript/jortsort.ys create mode 100644 Task/Josephus-problem/OxygenBasic/josephus-problem.basic create mode 100644 Task/Josephus-problem/Pluto/josephus-problem.pluto create mode 100644 Task/Josephus-problem/Prolog/josephus-problem-1.pro create mode 100644 Task/Josephus-problem/Prolog/josephus-problem-2.pro rename Task/Josephus-problem/Quite-BASIC/{josephus-problem-1.basic => josephus-problem.basic} (100%) create mode 100644 Task/Josephus-problem/Run-BASIC/josephus-problem-1.basic rename Task/Josephus-problem/{Quite-BASIC => Run-BASIC}/josephus-problem-2.basic (100%) create mode 100644 Task/Josephus-problem/XBasic/josephus-problem.basic create mode 100644 Task/Jump-anywhere/Koka/jump-anywhere.koka create mode 100644 Task/K-d-tree/Elixir/k-d-tree.ex create mode 100644 Task/K-d-tree/Swift/k-d-tree.swift create mode 100644 Task/K-d-tree/Zig/k-d-tree.zig create mode 100644 Task/Kaprekar-numbers/Agena/kaprekar-numbers.agena create mode 100644 Task/Kaprekar-numbers/Pluto/kaprekar-numbers.pluto create mode 100644 Task/Knapsack-problem-0-1/Zig/knapsack-problem-0-1.zig create mode 100644 Task/Knapsack-problem-Bounded/Ada/knapsack-problem-bounded.ada create mode 100644 Task/Knapsack-problem-Bounded/Fortran/knapsack-problem-bounded.f create mode 100644 Task/Knapsack-problem-Bounded/Lua/knapsack-problem-bounded.lua create mode 100644 Task/Knapsack-problem-Bounded/Rust/knapsack-problem-bounded.rs create mode 100644 Task/Knapsack-problem-Continuous/ALGOL-68/knapsack-problem-continuous.alg create mode 100644 Task/Knapsack-problem-Continuous/ALGOL-W/knapsack-problem-continuous.alg create mode 100644 Task/Knights-tour/Zig/knights-tour.zig create mode 100644 Task/Knuth-shuffle/DuckDB/knuth-shuffle.duckdb create mode 100644 Task/Knuth-shuffle/REBOL/knuth-shuffle-1.rebol create mode 100644 Task/Knuth-shuffle/REBOL/knuth-shuffle-2.rebol delete mode 100644 Task/Knuth-shuffle/REBOL/knuth-shuffle.rebol create mode 100644 Task/Knuth-shuffle/YAMLScript/knuth-shuffle.ys create mode 100644 Task/Knuths-power-tree/Fortran/knuths-power-tree.f rename Task/Knuths-power-tree/Python/{knuths-power-tree.py => knuths-power-tree-1.py} (100%) create mode 100644 Task/Knuths-power-tree/Python/knuths-power-tree-2.py create mode 100644 Task/Largest-int-from-concatenated-ints/DuckDB/largest-int-from-concatenated-ints.duckdb create mode 100644 Task/Largest-proper-divisor-of-n/AutoLISP/largest-proper-divisor-of-n.l create mode 100644 Task/Last-Friday-of-each-month/C++/last-friday-of-each-month-3.cpp create mode 100644 Task/Last-Friday-of-each-month/DuckDB/last-friday-of-each-month.duckdb create mode 100644 Task/Last-letter-first-letter/FutureBasic/last-letter-first-letter.basic create mode 100644 Task/Leap-year/DuckDB/leap-year.duckdb create mode 100644 Task/Leap-year/Pluto/leap-year.pluto create mode 100644 Task/Left-factorials/DuckDB/left-factorials.duckdb create mode 100644 Task/Leonardo-numbers/DuckDB/leonardo-numbers.duckdb create mode 100644 Task/Leonardo-numbers/Pascal-P/leonardo-numbers.pas create mode 100644 Task/Letter-frequency/DuckDB/letter-frequency-1.duckdb create mode 100644 Task/Letter-frequency/DuckDB/letter-frequency-2.duckdb create mode 100644 Task/Letter-frequency/Koka/letter-frequency.koka create mode 100644 Task/Letter-frequency/TAV/letter-frequency.tav create mode 100644 Task/Levenshtein-distance-Alignment/Ada/levenshtein-distance-alignment.ada create mode 100644 Task/Levenshtein-distance/DuckDB/levenshtein-distance.duckdb create mode 100644 Task/Levenshtein-distance/Pascal-P/levenshtein-distance.pas create mode 100644 Task/List-comprehensions/DuckDB/list-comprehensions-1.duckdb create mode 100644 Task/List-comprehensions/DuckDB/list-comprehensions-2.duckdb create mode 100644 Task/List-comprehensions/DuckDB/list-comprehensions-3.duckdb create mode 100644 Task/List-comprehensions/DuckDB/list-comprehensions-4.duckdb create mode 100644 Task/List-comprehensions/DuckDB/list-comprehensions-5.duckdb create mode 100644 Task/Literals-Floating-point/ArkScript/literals-floating-point.ark create mode 100644 Task/Literals-Floating-point/Pluto/literals-floating-point.pluto create mode 100644 Task/Literals-Integer/ArkScript/literals-integer.ark create mode 100644 Task/Literals-Integer/DuckDB/literals-integer.duckdb create mode 100644 Task/Literals-Integer/Pluto/literals-integer.pluto create mode 100644 Task/Literals-String/ArkScript/literals-string.ark create mode 100644 Task/Logical-operations/ArkScript/logical-operations.ark create mode 100644 Task/Logical-operations/DuckDB/logical-operations.duckdb create mode 100644 Task/Logical-operations/Red/logical-operations.red create mode 100644 Task/Long-literals-with-continuations/Ada/long-literals-with-continuations.ada delete mode 100644 Task/Long-multiplication/F-Sharp/long-multiplication.fs create mode 100644 Task/Longest-increasing-subsequence/Ada/longest-increasing-subsequence.ada create mode 100644 Task/Longest-increasing-subsequence/DuckDB/longest-increasing-subsequence.duckdb create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/Pluto/loop-over-multiple-arrays-simultaneously.pluto create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/REBOL/loop-over-multiple-arrays-simultaneously.rebol create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/TAV/loop-over-multiple-arrays-simultaneously.tav create mode 100644 Task/Loops-Break/DuckDB/loops-break.duckdb create mode 100644 Task/Loops-Break/Koka/loops-break.koka create mode 100644 Task/Loops-Break/Pluto/loops-break.pluto create mode 100644 Task/Loops-Break/TAV/loops-break-1.tav create mode 100644 Task/Loops-Break/TAV/loops-break-2.tav create mode 100644 Task/Loops-Break/Ursalang/loops-break.ursa rename Task/Loops-Break/Zig/{loops-break.zig => loops-break-1.zig} (100%) create mode 100644 Task/Loops-Break/Zig/loops-break-2.zig create mode 100644 Task/Loops-Continue/Pluto/loops-continue.pluto rename Task/Loops-Continue/REBOL/{loops-continue.rebol => loops-continue-1.rebol} (84%) create mode 100644 Task/Loops-Continue/REBOL/loops-continue-2.rebol create mode 100644 Task/Loops-Do-while/DuckDB/loops-do-while.duckdb create mode 100644 Task/Loops-Do-while/Pluto/loops-do-while.pluto create mode 100644 Task/Loops-Do-while/TAV/loops-do-while-1.tav create mode 100644 Task/Loops-Do-while/TAV/loops-do-while-2.tav create mode 100644 Task/Loops-Downward-for/DuckDB/loops-downward-for-1.duckdb create mode 100644 Task/Loops-Downward-for/DuckDB/loops-downward-for-2.duckdb create mode 100644 Task/Loops-Downward-for/Pluto/loops-downward-for.pluto create mode 100644 Task/Loops-Downward-for/TAV/loops-downward-for.tav create mode 100644 Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-1.duckdb create mode 100644 Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-2.duckdb create mode 100644 Task/Loops-For-with-a-specified-step/Pluto/loops-for-with-a-specified-step.pluto create mode 100644 Task/Loops-For/Adina/loops-for-1.adina create mode 100644 Task/Loops-For/Adina/loops-for-2.adina create mode 100644 Task/Loops-For/DuckDB/loops-for-1.duckdb create mode 100644 Task/Loops-For/DuckDB/loops-for-2.duckdb create mode 100644 Task/Loops-For/DuckDB/loops-for-3.duckdb create mode 100644 Task/Loops-For/Eiffel/loops-for.e create mode 100644 Task/Loops-For/Extended-Color-BASIC/loops-for.basic create mode 100644 Task/Loops-For/Pluto/loops-for.pluto create mode 100644 Task/Loops-For/TAV/loops-for-1.tav create mode 100644 Task/Loops-For/TAV/loops-for-2.tav create mode 100644 Task/Loops-For/TAV/loops-for-3.tav create mode 100644 Task/Loops-Foreach/Pluto/loops-foreach.pluto create mode 100644 Task/Loops-Increment-loop-index-within-loop-body/DuckDB/loops-increment-loop-index-within-loop-body.duckdb create mode 100644 Task/Loops-Increment-loop-index-within-loop-body/Pluto/loops-increment-loop-index-within-loop-body.pluto create mode 100644 Task/Loops-Increment-loop-index-within-loop-body/REBOL/loops-increment-loop-index-within-loop-body.rebol create mode 100644 Task/Loops-Infinite/Eiffel/loops-infinite.e create mode 100644 Task/Loops-Infinite/Pluto/loops-infinite.pluto rename Task/Loops-Infinite/REBOL/{loops-infinite.rebol => loops-infinite-1.rebol} (100%) create mode 100644 Task/Loops-Infinite/REBOL/loops-infinite-2.rebol create mode 100644 Task/Loops-Infinite/REBOL/loops-infinite-3.rebol create mode 100644 Task/Loops-Infinite/TAV/loops-infinite.tav create mode 100644 Task/Loops-N-plus-one-half/DuckDB/loops-n-plus-one-half.duckdb create mode 100644 Task/Loops-N-plus-one-half/Pluto/loops-n-plus-one-half.pluto create mode 100644 Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-1.tav create mode 100644 Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-2.tav create mode 100644 Task/Loops-Nested/DuckDB/loops-nested.duckdb create mode 100644 Task/Loops-Nested/Pluto/loops-nested.pluto create mode 100644 Task/Loops-Nested/Zig/loops-nested.zig create mode 100644 Task/Loops-While/DuckDB/loops-while.duckdb create mode 100644 Task/Loops-While/Mn/loops-while.mn create mode 100644 Task/Loops-While/Pluto/loops-while.pluto create mode 100644 Task/Loops-While/TAV/loops-while.tav create mode 100644 Task/Loops-While/Ursalang/loops-while.ursa create mode 100644 Task/Loops-With-multiple-ranges/DuckDB/loops-with-multiple-ranges.duckdb rename Task/Loops-With-multiple-ranges/Haskell/{loops-with-multiple-ranges.hs => loops-with-multiple-ranges-1.hs} (100%) create mode 100644 Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-2.hs create mode 100644 Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-3.hs create mode 100644 Task/Loops-With-multiple-ranges/Pluto/loops-with-multiple-ranges.pluto create mode 100644 Task/Loops-With-multiple-ranges/REBOL/loops-with-multiple-ranges.rebol create mode 100644 Task/Loops-Wrong-ranges/Icon/loops-wrong-ranges.icon create mode 100644 Task/Loops-Wrong-ranges/Pluto/loops-wrong-ranges.pluto create mode 100644 Task/Loops-Wrong-ranges/REBOL/loops-wrong-ranges.rebol create mode 100644 Task/Luhn-test-of-credit-card-numbers/DuckDB/luhn-test-of-credit-card-numbers.duckdb create mode 100644 Task/Luhn-test-of-credit-card-numbers/Pluto/luhn-test-of-credit-card-numbers.pluto create mode 100644 Task/M-bius-function/C-sharp/m-bius-function.cs create mode 100644 Task/M-bius-function/Pascal-P/m-bius-function.pas create mode 100644 Task/M-bius-function/Pluto/m-bius-function.pluto create mode 100644 Task/M-bius-function/PowerShell/m-bius-function.psh create mode 100644 Task/M-bius-function/R/m-bius-function.r create mode 100644 Task/M-bius-function/Tcl/m-bius-function.tcl create mode 100644 Task/M-bius-function/Zig/m-bius-function.zig create mode 100644 Task/MD5/DuckDB/md5.duckdb create mode 100644 Task/MD5/JavaScript/md5.js create mode 100644 Task/MD5/REBOL/md5-1.rebol create mode 100644 Task/MD5/REBOL/md5-2.rebol delete mode 100644 Task/MD5/REBOL/md5.rebol create mode 100644 Task/Machine-code/Ada/machine-code.ada create mode 100644 Task/Machine-code/Pluto/machine-code-1.pluto create mode 100644 Task/Machine-code/Pluto/machine-code-2.pluto create mode 100644 Task/Magic-8-ball/Prolog/magic-8-ball.pro create mode 100644 Task/Magic-constant/Pascal-P/magic-constant.pas create mode 100644 Task/Magic-squares-of-doubly-even-order/Objeck/magic-squares-of-doubly-even-order.objeck create mode 100644 Task/Magic-squares-of-doubly-even-order/Pluto/magic-squares-of-doubly-even-order.pluto create mode 100644 Task/Magic-squares-of-odd-order/Pluto/magic-squares-of-odd-order.pluto create mode 100644 Task/Magic-squares-of-singly-even-order/Pluto/magic-squares-of-singly-even-order.pluto create mode 100644 Task/Main-step-of-GOST-28147-89/Zig/main-step-of-gost-28147-89.zig delete mode 100644 Task/Mandelbrot-set/Julia/mandelbrot-set-4.jl delete mode 100644 Task/Mandelbrot-set/Julia/mandelbrot-set-5.jl delete mode 100644 Task/Mandelbrot-set/Julia/mandelbrot-set-6.jl delete mode 100644 Task/Mandelbrot-set/Julia/mandelbrot-set-7.jl create mode 100644 Task/Mandelbrot-set/Python/mandelbrot-set-11.py create mode 100644 Task/Mandelbrot-set/Python/mandelbrot-set-12.py create mode 100644 Task/Map-range/DuckDB/map-range.duckdb create mode 100644 Task/Map-range/Pascal-P/map-range.pas create mode 100644 Task/Matrix-multiplication/DuckDB/matrix-multiplication-1.duckdb create mode 100644 Task/Matrix-multiplication/DuckDB/matrix-multiplication-2.duckdb create mode 100644 Task/Matrix-multiplication/DuckDB/matrix-multiplication-3.duckdb create mode 100644 Task/Matrix-multiplication/Objeck/matrix-multiplication.objeck create mode 100644 Task/Matrix-transposition/DuckDB/matrix-transposition-1.duckdb create mode 100644 Task/Matrix-transposition/DuckDB/matrix-transposition-2.duckdb create mode 100644 Task/Matrix-transposition/DuckDB/matrix-transposition-3.duckdb create mode 100644 Task/Mayan-calendar/Rust/mayan-calendar.rs create mode 100644 Task/Mayan-numerals/FutureBasic/mayan-numerals.basic create mode 100644 Task/McNuggets-problem/Fortran/mcnuggets-problem.f create mode 100644 Task/Meissel-Mertens-constant/JavaScript/meissel-mertens-constant.js create mode 100644 Task/Meissel-Mertens-constant/Rust/meissel-mertens-constant.rs create mode 100644 Task/Merge-and-aggregate-datasets/DuckDB/merge-and-aggregate-datasets.duckdb create mode 100644 Task/Metallic-ratios/DuckDB/metallic-ratios-1.duckdb create mode 100644 Task/Metallic-ratios/DuckDB/metallic-ratios-2.duckdb create mode 100644 Task/Metallic-ratios/DuckDB/metallic-ratios-3.duckdb create mode 100644 Task/Metaprogramming/V-(Vlang)/metaprogramming.v create mode 100644 Task/Mian-Chowla-sequence/Agena/mian-chowla-sequence.agena create mode 100644 Task/Mian-Chowla-sequence/Pluto/mian-chowla-sequence.pluto create mode 100644 Task/Middle-three-digits/DuckDB/middle-three-digits.duckdb create mode 100644 Task/Miller-Rabin-primality-test/Haskell/miller-rabin-primality-test-3.hs create mode 100644 Task/Minesweeper-game/Liberty-BASIC/minesweeper-game.basic create mode 100644 Task/Minimal-steps-down-to-1/Ada/minimal-steps-down-to-1.ada rename Task/Modular-arithmetic/Common-Lisp/{modular-arithmetic.lisp => modular-arithmetic-1.lisp} (100%) create mode 100644 Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-2.lisp create mode 100644 Task/Modular-arithmetic/Rust/modular-arithmetic.rs create mode 100644 Task/Modular-arithmetic/Zig/modular-arithmetic.zig create mode 100644 Task/Modular-inverse/FutureBasic/modular-inverse.basic create mode 100644 Task/Modular-inverse/Pluto/modular-inverse.pluto create mode 100644 Task/Modular-inverse/Zig/modular-inverse.zig create mode 100644 Task/Monads-Writer-monad/Koka/monads-writer-monad.koka create mode 100644 Task/Monte-Carlo-methods/APL/monte-carlo-methods.apl create mode 100644 Task/Monte-Carlo-methods/DuckDB/monte-carlo-methods.duckdb create mode 100644 Task/Monte-Carlo-methods/FutureBasic/monte-carlo-methods.basic create mode 100644 Task/Monte-Carlo-methods/SETL/monte-carlo-methods.setl create mode 100644 Task/Multi-dimensional-array/BBC-BASIC/multi-dimensional-array-1.basic create mode 100644 Task/Multi-dimensional-array/BBC-BASIC/multi-dimensional-array-2.basic create mode 100644 Task/Multiple-regression/Rust/multiple-regression.rs create mode 100644 Task/Multiplication-tables/Pluto/multiplication-tables.pluto create mode 100644 Task/Multiplication-tables/TAV/multiplication-tables.tav create mode 100644 Task/Multiplicative-order/F-Sharp/multiplicative-order.fs create mode 100644 Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark create mode 100644 Task/Munching-squares/YAMLScript/munching-squares.ys create mode 100644 Task/Mutex/FutureBasic/mutex.basic create mode 100644 Task/Mutual-recursion/Pluto/mutual-recursion.pluto create mode 100644 Task/N-queens-problem/ArkScript/n-queens-problem.ark create mode 100644 Task/Named-parameters/FutureBasic/named-parameters.basic create mode 100644 Task/Named-parameters/Pluto/named-parameters.pluto create mode 100644 Task/Naming-conventions/Ada/naming-conventions-1.ada create mode 100644 Task/Naming-conventions/Ada/naming-conventions-2.ada create mode 100644 Task/Naming-conventions/Ada/naming-conventions-3.ada rename Task/Narcissistic-decimal-number/Lua/{narcissistic-decimal-number.lua => narcissistic-decimal-number-1.lua} (100%) create mode 100644 Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-2.lua create mode 100644 Task/Narcissistic-decimal-number/Pluto/narcissistic-decimal-number.pluto create mode 100644 Task/Nested-function/DuckDB/nested-function.duckdb create mode 100644 Task/Nested-templated-data/Pluto/nested-templated-data.pluto create mode 100644 Task/Next-highest-int-from-digits/YAMLScript/next-highest-int-from-digits.ys create mode 100644 Task/Non-decimal-radices-Convert/Pluto/non-decimal-radices-convert.pluto create mode 100644 Task/Nth-root/DuckDB/nth-root.duckdb create mode 100644 Task/Nth/DuckDB/nth.duckdb create mode 100644 Task/Null-object/ArkScript/null-object.ark create mode 100644 Task/Null-object/Tcl/null-object-3.tcl create mode 100644 Task/Null-object/Tcl/null-object-4.tcl create mode 100644 Task/Numerical-integration/Pluto/numerical-integration.pluto create mode 100644 Task/OLE-automation/Julia/ole-automation.jl create mode 100644 Task/Object-serialization/REBOL/object-serialization.rebol create mode 100644 Task/Odd-word-problem/Nom/odd-word-problem.num create mode 100644 Task/Old-Russian-measure-of-length/ANSI-BASIC/old-russian-measure-of-length.basic create mode 100644 Task/Old-Russian-measure-of-length/ASIC/old-russian-measure-of-length.asic create mode 100644 Task/Old-Russian-measure-of-length/GW-BASIC/old-russian-measure-of-length.basic create mode 100644 Task/Old-Russian-measure-of-length/Nascom-BASIC/old-russian-measure-of-length.basic create mode 100644 Task/Old-Russian-measure-of-length/Pluto/old-russian-measure-of-length.pluto create mode 100644 Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-1.pro create mode 100644 Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-2.pro create mode 100644 Task/One-dimensional-cellular-automata/YAMLScript/one-dimensional-cellular-automata.ys create mode 100644 Task/One-of-n-lines-in-a-file/DuckDB/one-of-n-lines-in-a-file.duckdb create mode 100644 Task/Order-by-pair-comparisons/Pluto/order-by-pair-comparisons.pluto create mode 100644 Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-1.pro create mode 100644 Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-2.pro create mode 100644 Task/Order-two-numerical-lists/DuckDB/order-two-numerical-lists.duckdb create mode 100644 Task/Ordered-words/DuckDB/ordered-words.duckdb create mode 100644 Task/Ordered-words/TAV/ordered-words.tav create mode 100644 Task/Own-digits-power-sum/Scheme/own-digits-power-sum.scm rename Task/Padovan-sequence/Julia/{padovan-sequence.jl => padovan-sequence-1.jl} (92%) create mode 100644 Task/Padovan-sequence/Julia/padovan-sequence-2.jl create mode 100644 Task/Padovan-sequence/Phix/padovan-sequence-4.phix create mode 100644 Task/Palindrome-detection/DuckDB/palindrome-detection.duckdb create mode 100644 Task/Palindrome-detection/Pluto/palindrome-detection.pluto create mode 100644 Task/Pancake-numbers/Free-Pascal-Lazarus/pancake-numbers.pas rename Task/Pancake-numbers/FreeBASIC/{pancake-numbers.basic => pancake-numbers-1.basic} (100%) create mode 100644 Task/Pancake-numbers/FreeBASIC/pancake-numbers-2.basic delete mode 100644 Task/Pancake-numbers/Julia/pancake-numbers-1.jl rename Task/Pancake-numbers/Julia/{pancake-numbers-2.jl => pancake-numbers.jl} (100%) create mode 100644 Task/Pancake-numbers/Phix/pancake-numbers-4.phix create mode 100644 Task/Pancake-numbers/Pluto/pancake-numbers-1.pluto create mode 100644 Task/Pancake-numbers/Pluto/pancake-numbers-2.pluto create mode 100644 Task/Pancake-numbers/Pluto/pancake-numbers-3.pluto create mode 100644 Task/Pancake-numbers/Pluto/pancake-numbers-4.pluto create mode 100644 Task/Pancake-numbers/Ruby/pancake-numbers-1.rb create mode 100644 Task/Pancake-numbers/Ruby/pancake-numbers-2.rb delete mode 100644 Task/Pancake-numbers/Ruby/pancake-numbers.rb create mode 100644 Task/Pancake-numbers/Wren/pancake-numbers-3.wren create mode 100644 Task/Pancake-numbers/Wren/pancake-numbers-4.wren create mode 100644 Task/Parameterized-SQL-statement/DuckDB/parameterized-sql-statement.duckdb create mode 100644 Task/Parse-an-IP-Address/Dart/parse-an-ip-address.dart create mode 100644 Task/Parse-an-IP-Address/Elixir/parse-an-ip-address.ex create mode 100644 Task/Parse-an-IP-Address/Fortran/parse-an-ip-address.f create mode 100644 Task/Parse-an-IP-Address/JavaScript/parse-an-ip-address.js create mode 100644 Task/Parse-an-IP-Address/Mathematica/parse-an-ip-address.math create mode 100644 Task/Parse-an-IP-Address/OCaml/parse-an-ip-address.ml create mode 100644 Task/Parse-an-IP-Address/R/parse-an-ip-address.r rename Task/Parse-an-IP-Address/Rust/{parse-an-ip-address.rs => parse-an-ip-address-1.rs} (100%) create mode 100644 Task/Parse-an-IP-Address/Rust/parse-an-ip-address-2.rs create mode 100644 Task/Parse-an-IP-Address/Swift/parse-an-ip-address.swift create mode 100644 Task/Parse-an-IP-Address/Zig/parse-an-ip-address.zig create mode 100644 Task/Parsing-RPN-calculator-algorithm/Crystal/parsing-rpn-calculator-algorithm.cr create mode 100644 Task/Parsing-RPN-calculator-algorithm/Pluto/parsing-rpn-calculator-algorithm.pluto create mode 100644 Task/Parsing-RPN-calculator-algorithm/Red/parsing-rpn-calculator-algorithm.red create mode 100644 Task/Parsing-RPN-to-infix-conversion/Red/parsing-rpn-to-infix-conversion.red create mode 100644 Task/Parsing-Shunting-yard-algorithm/Red/parsing-shunting-yard-algorithm.red create mode 100644 Task/Pascals-triangle-Puzzle/EasyLang/pascals-triangle-puzzle.easy create mode 100644 Task/Pascals-triangle-Puzzle/Fortran/pascals-triangle-puzzle.f create mode 100644 Task/Pascals-triangle-Puzzle/JavaScript/pascals-triangle-puzzle.js create mode 100644 Task/Pascals-triangle-Puzzle/Pluto/pascals-triangle-puzzle.pluto create mode 100644 Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb delete mode 100644 Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-1.rexx delete mode 100644 Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-2.rexx delete mode 100644 Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-3.rexx create mode 100644 Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems.rexx rename Task/Pell-numbers/Julia/{pell-numbers.jl => pell-numbers-1.jl} (100%) create mode 100644 Task/Pell-numbers/Julia/pell-numbers-2.jl create mode 100644 Task/Pell-numbers/PARI-GP/pell-numbers.parigp create mode 100644 Task/Perfect-shuffle/FutureBasic/perfect-shuffle.basic create mode 100644 Task/Perfect-shuffle/Pluto/perfect-shuffle.pluto create mode 100644 Task/Permutations-Derangements/DuckDB/permutations-derangements.duckdb create mode 100644 Task/Permutations-by-swapping/Zig/permutations-by-swapping.zig create mode 100644 Task/Permutations/DuckDB/permutations.duckdb create mode 100644 Task/Permutations/Pluto/permutations.pluto create mode 100644 Task/Permutations/TAV/permutations-1.tav create mode 100644 Task/Permutations/TAV/permutations-2.tav create mode 100644 Task/Permutations/TAV/permutations-3.tav create mode 100644 Task/Permutations/TAV/permutations-4.tav create mode 100644 Task/Pernicious-numbers/Agena/pernicious-numbers.agena create mode 100644 Task/Pernicious-numbers/Pluto/pernicious-numbers.pluto create mode 100644 Task/Phrase-reversals/Prolog/phrase-reversals.pro create mode 100644 Task/Pick-random-element/DuckDB/pick-random-element.duckdb create mode 100644 Task/Pick-random-element/Pluto/pick-random-element.pluto create mode 100644 Task/Pick-random-element/Scheme/pick-random-element.scm rename Task/Pick-random-element/Tcl/{pick-random-element.tcl => pick-random-element-1.tcl} (100%) create mode 100644 Task/Pick-random-element/Tcl/pick-random-element-2.tcl create mode 100644 Task/Pisano-period/Agena/pisano-period.agena create mode 100644 Task/Pisano-period/Pluto/pisano-period.pluto create mode 100644 Task/Play-recorded-sounds/FuncSug/play-recorded-sounds.funcsug create mode 100644 Task/Play-recorded-sounds/Raku/play-recorded-sounds.raku delete mode 100644 Task/Polymorphism/M2000-Interpreter/polymorphism-1.m2000 delete mode 100644 Task/Polymorphism/M2000-Interpreter/polymorphism-2.m2000 delete mode 100644 Task/Polymorphism/M2000-Interpreter/polymorphism-3.m2000 create mode 100644 Task/Polymorphism/M2000-Interpreter/polymorphism.m2000 create mode 100644 Task/Polymorphism/Rhombus/polymorphism-1.rhombus create mode 100644 Task/Polymorphism/Rhombus/polymorphism-2.rhombus create mode 100644 Task/Polyspiral/REBOL/polyspiral.rebol create mode 100644 Task/Population-count/Prolog/population-count.pro create mode 100644 Task/Power-set/Pluto/power-set.pluto create mode 100644 Task/Primality-by-trial-division/Agena/primality-by-trial-division.agena create mode 100644 Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-1.duckdb create mode 100644 Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-2.duckdb create mode 100644 Task/Primality-by-trial-division/Pluto/primality-by-trial-division.pluto create mode 100644 Task/Prime-decomposition/DuckDB/prime-decomposition.duckdb create mode 100644 Task/Prime-decomposition/OoRexx/prime-decomposition.rexx create mode 100644 Task/Priority-queue/Pluto/priority-queue.pluto create mode 100644 Task/Probabilistic-choice/DuckDB/probabilistic-choice.duckdb create mode 100644 Task/Program-termination/ArkScript/program-termination.ark create mode 100644 Task/Proper-divisors/DuckDB/proper-divisors.duckdb create mode 100644 Task/Pseudo-random-numbers-Middle-square-method/DuckDB/pseudo-random-numbers-middle-square-method.duckdb rename Task/Queue-Definition/ALGOL-68/{queue-definition.alg => queue-definition-1.alg} (100%) create mode 100644 Task/Queue-Definition/ALGOL-68/queue-definition-2.alg create mode 100644 Task/Quickselect-algorithm/YAMLScript/quickselect-algorithm.ys create mode 100644 Task/Quine/Extended-Color-BASIC/quine.basic create mode 100644 Task/Quine/REBOL/quine-1.rebol create mode 100644 Task/Quine/REBOL/quine-2.rebol delete mode 100644 Task/Quine/REBOL/quine.rebol create mode 100644 Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-1.pro create mode 100644 Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-2.pro create mode 100644 Task/Ramanujan-primes-twins/Rust/ramanujan-primes-twins.rs create mode 100644 Task/Ramer-Douglas-Peucker-line-simplification/Pascal-P/ramer-douglas-peucker-line-simplification.pas create mode 100644 Task/Random-numbers/DuckDB/random-numbers.duckdb create mode 100644 Task/Range-expansion/DuckDB/range-expansion.duckdb create mode 100644 Task/Range-extraction/DuckDB/range-extraction.duckdb create mode 100644 Task/Read-a-file-character-by-character-UTF8/Ada/read-a-file-character-by-character-utf8.ada create mode 100644 Task/Read-a-file-line-by-line/DuckDB/read-a-file-line-by-line.duckdb create mode 100644 Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-1.pluto create mode 100644 Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-2.pluto create mode 100644 Task/Read-entire-file/ArkScript/read-entire-file.ark create mode 100644 Task/Real-constants-and-functions/Maxima/real-constants-and-functions.maxima create mode 100644 Task/Real-constants-and-functions/TAV/real-constants-and-functions.tav create mode 100644 Task/Reflection-List-methods/DuckDB/reflection-list-methods.duckdb create mode 100644 Task/Reflection-List-properties/DuckDB/reflection-list-properties.duckdb create mode 100644 Task/Regular-expressions/Maxima/regular-expressions.maxima create mode 100644 Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-1.duckdb create mode 100644 Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-2.duckdb create mode 100644 Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-3.duckdb create mode 100644 Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-4.duckdb create mode 100644 Task/Rename-a-file/Maxima/rename-a-file.maxima create mode 100644 Task/Rename-a-file/Pluto/rename-a-file.pluto create mode 100644 Task/Rename-a-file/R/rename-a-file.r create mode 100644 Task/Rep-string/DuckDB/rep-string.duckdb create mode 100644 Task/Repeat-a-string/DuckDB/repeat-a-string-1.duckdb create mode 100644 Task/Repeat-a-string/DuckDB/repeat-a-string-2.duckdb create mode 100644 Task/Repeat-a-string/Pluto/repeat-a-string.pluto create mode 100644 Task/Repunit-primes/R/repunit-primes.r create mode 100644 Task/Retrieve-and-search-chat-history/R/retrieve-and-search-chat-history.r create mode 100644 Task/Return-multiple-values/DuckDB/return-multiple-values-1.duckdb create mode 100644 Task/Return-multiple-values/DuckDB/return-multiple-values-2.duckdb create mode 100644 Task/Reverse-a-string/ArkScript/reverse-a-string.ark create mode 100644 Task/Reverse-a-string/DuckDB/reverse-a-string.duckdb create mode 100644 Task/Reverse-a-string/Nom/reverse-a-string.num create mode 100644 Task/Reverse-a-string/Pluto/reverse-a-string.pluto create mode 100644 Task/Reverse-a-string/TAV/reverse-a-string.tav create mode 100644 Task/Reverse-words-in-a-string/Pluto/reverse-words-in-a-string.pluto create mode 100644 Task/Roman-numerals-Encode/Pluto/roman-numerals-encode.pluto create mode 100644 Task/Roots-of-a-quadratic-function/Pluto/roots-of-a-quadratic-function.pluto create mode 100644 Task/Roots-of-unity/DuckDB/roots-of-unity.duckdb create mode 100644 Task/Roots-of-unity/Pluto/roots-of-unity.pluto create mode 100644 Task/Rot-13/Crystal/rot-13.cr create mode 100644 Task/Rot-13/Pluto/rot-13.pluto create mode 100644 Task/Rot-13/Rhombus/rot-13.rhombus create mode 100644 Task/Run-length-encoding/DuckDB/run-length-encoding-1.duckdb create mode 100644 Task/Run-length-encoding/DuckDB/run-length-encoding-2.duckdb create mode 100644 Task/Runge-Kutta-method/Pluto/runge-kutta-method.pluto create mode 100644 Task/Ruth-Aaron-numbers/Python/ruth-aaron-numbers.py create mode 100644 Task/SEDOLs/Prolog/sedols-1.pro create mode 100644 Task/SEDOLs/Prolog/sedols-2.pro create mode 100644 Task/SEDOLs/Prolog/sedols-3.pro create mode 100644 Task/SHA-1/REBOL/sha-1-1.rebol create mode 100644 Task/SHA-1/REBOL/sha-1-2.rebol create mode 100644 Task/SHA-256/REBOL/sha-256.rebol create mode 100644 Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-1.duckdb create mode 100644 Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-2.duckdb create mode 100644 Task/Search-a-list-of-records/Icon/search-a-list-of-records.icon create mode 100644 Task/Self-numbers/Pluto/self-numbers.pluto create mode 100644 Task/Semordnilap/ArkScript/semordnilap.ark create mode 100644 Task/Semordnilap/Pluto/semordnilap.pluto create mode 100644 Task/Semordnilap/Prolog/semordnilap.pro create mode 100644 Task/Semordnilap/REBOL/semordnilap-1.rebol create mode 100644 Task/Semordnilap/REBOL/semordnilap-2.rebol create mode 100644 Task/Semordnilap/TAV/semordnilap.tav create mode 100644 Task/Sequence-of-primes-by-trial-division/Agena/sequence-of-primes-by-trial-division.agena create mode 100644 Task/Sequence-of-primes-by-trial-division/Pluto/sequence-of-primes-by-trial-division.pluto create mode 100644 Task/Set-consolidation/DuckDB/set-consolidation-1.duckdb create mode 100644 Task/Set-consolidation/DuckDB/set-consolidation-2.duckdb create mode 100644 Task/Set-consolidation/DuckDB/set-consolidation-3.duckdb create mode 100644 Task/Set-consolidation/Pluto/set-consolidation.pluto create mode 100644 Task/Set/DuckDB/set-1.duckdb create mode 100644 Task/Set/DuckDB/set-2.duckdb create mode 100644 Task/Set/DuckDB/set-3.duckdb create mode 100644 Task/Set/DuckDB/set-4.duckdb create mode 100644 Task/Set/DuckDB/set-5.duckdb create mode 100644 Task/Set/DuckDB/set-6.duckdb create mode 100644 Task/Set/DuckDB/set-7.duckdb create mode 100644 Task/Set/DuckDB/set-8.duckdb create mode 100644 Task/Set/DuckDB/set-9.duckdb create mode 100644 Task/Set/Pluto/set.pluto create mode 100644 Task/Shell-one-liner/ArkScript/shell-one-liner.ark rename Task/Shoelace-formula-for-polygonal-area/Julia/{shoelace-formula-for-polygonal-area.jl => shoelace-formula-for-polygonal-area-1.jl} (100%) create mode 100644 Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-2.jl create mode 100644 Task/Shoelace-formula-for-polygonal-area/R/shoelace-formula-for-polygonal-area.r create mode 100644 Task/Short-circuit-evaluation/ArkScript/short-circuit-evaluation.ark create mode 100644 Task/Show-ASCII-table/ArkScript/show-ascii-table.ark create mode 100644 Task/Show-the-epoch/DuckDB/show-the-epoch.duckdb create mode 100644 Task/Sierpinski-pentagon/FutureBasic/sierpinski-pentagon.basic create mode 100644 Task/Sieve-of-Eratosthenes/DuckDB/sieve-of-eratosthenes.duckdb create mode 100644 Task/Simple-windowed-application/FuncSug/simple-windowed-application.funcsug create mode 100644 Task/Simple-windowed-application/TAV/simple-windowed-application.tav create mode 100644 Task/Simulate-input-Keyboard/Julia/simulate-input-keyboard.jl create mode 100644 Task/Simulate-input-Mouse/FuncSug/simulate-input-mouse.funcsug create mode 100644 Task/Singleton/Rust/singleton.rs create mode 100644 Task/Singly-linked-list-Element-definition/Crystal/singly-linked-list-element-definition.cr create mode 100644 Task/Singly-linked-list-Element-definition/Pluto/singly-linked-list-element-definition.pluto create mode 100644 Task/Singly-linked-list-Element-insertion/Crystal/singly-linked-list-element-insertion.cr create mode 100644 Task/Singly-linked-list-Element-insertion/Pluto/singly-linked-list-element-insertion.pluto create mode 100644 Task/Singly-linked-list-Traversal/Pluto/singly-linked-list-traversal.pluto create mode 100644 Task/Sleep/ArkScript/sleep.ark create mode 100644 Task/Sleep/FutureBasic/sleep.basic create mode 100644 Task/Sleep/Pluto/sleep.pluto create mode 100644 Task/Smarandache-prime-digital-sequence/Agena/smarandache-prime-digital-sequence.agena create mode 100644 Task/Smarandache-prime-digital-sequence/Pluto/smarandache-prime-digital-sequence.pluto create mode 100644 Task/Snake/Liberty-BASIC/snake.basic create mode 100644 Task/Sokoban/JavaScript/sokoban.js create mode 100644 Task/Sokoban/Rust/sokoban.rs create mode 100644 Task/Soloways-recurring-rainfall/AWK/soloways-recurring-rainfall.awk create mode 100644 Task/Soloways-recurring-rainfall/Agena/soloways-recurring-rainfall.agena create mode 100644 Task/Soloways-recurring-rainfall/COBOL/soloways-recurring-rainfall.cobol create mode 100644 Task/Soloways-recurring-rainfall/Crystal/soloways-recurring-rainfall.cr create mode 100644 Task/Soloways-recurring-rainfall/Pluto/soloways-recurring-rainfall.pluto create mode 100644 Task/Soloways-recurring-rainfall/R/soloways-recurring-rainfall.r create mode 100644 Task/Solve-a-Hopido-puzzle/JavaScript/solve-a-hopido-puzzle.js create mode 100644 Task/Sort-an-array-of-composite-structures/DuckDB/sort-an-array-of-composite-structures.duckdb create mode 100644 Task/Sort-an-integer-array/Pluto/sort-an-integer-array.pluto create mode 100644 Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-1.duckdb create mode 100644 Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-2.duckdb create mode 100644 Task/Sort-numbers-lexicographically/Icon/sort-numbers-lexicographically.icon create mode 100644 Task/Sort-three-variables/Prolog/sort-three-variables.pro create mode 100644 Task/Sorting-algorithms-Insertion-sort/FutureBasic/sorting-algorithms-insertion-sort.basic create mode 100644 Task/Sorting-algorithms-Insertion-sort/S-BASIC/sorting-algorithms-insertion-sort.basic create mode 100644 Task/Sorting-algorithms-Quicksort/ArkScript/sorting-algorithms-quicksort.ark create mode 100644 Task/Sorting-algorithms-Sleep-sort/FutureBasic/sorting-algorithms-sleep-sort.basic create mode 100644 Task/Sorting-algorithms-Sleep-sort/OCaml/sorting-algorithms-sleep-sort.ml create mode 100644 Task/Sorting-algorithms-Stooge-sort/Maxima/sorting-algorithms-stooge-sort.maxima create mode 100644 Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-1.logo create mode 100644 Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-2.logo create mode 100644 Task/Sparkline-in-unicode/YAMLScript/sparkline-in-unicode.ys create mode 100644 Task/Split-a-character-string-based-on-change-of-character/R/split-a-character-string-based-on-change-of-character.r create mode 100644 Task/Stack-traces/FutureBasic/stack-traces.basic create mode 100644 Task/Stack/Pluto/stack.pluto delete mode 100644 Task/Stack/REXX/stack-1.rexx rename Task/Stack/REXX/{stack-2.rexx => stack.rexx} (82%) create mode 100644 Task/Stack/TAV/stack-1.tav create mode 100644 Task/Stack/TAV/stack-2.tav create mode 100644 Task/Statistics-Basic/DuckDB/statistics-basic.duckdb create mode 100644 Task/Statistics-Basic/Maxima/statistics-basic.maxima create mode 100644 Task/Stem-and-leaf-plot/Prolog/stem-and-leaf-plot.pro create mode 100644 Task/Stern-Brocot-sequence/Zig/stern-brocot-sequence.zig create mode 100644 Task/Straddling-checkerboard/EasyLang/straddling-checkerboard.easy create mode 100644 Task/String-append/ArkScript/string-append.ark create mode 100644 Task/String-append/DuckDB/string-append-1.duckdb create mode 100644 Task/String-append/DuckDB/string-append-2.duckdb create mode 100644 Task/String-case/ArkScript/string-case.ark create mode 100644 Task/String-case/DuckDB/string-case.duckdb create mode 100644 Task/String-comparison/DuckDB/string-comparison.duckdb create mode 100644 Task/String-concatenation/ArkScript/string-concatenation.ark create mode 100644 Task/String-concatenation/Prolog/string-concatenation.pro create mode 100644 Task/String-concatenation/Tcl/string-concatenation-3.tcl create mode 100644 Task/String-interpolation-included-/ArkScript/string-interpolation-included-.ark create mode 100644 Task/String-interpolation-included-/Crystal/string-interpolation-included-.cr create mode 100644 Task/String-interpolation-included-/DuckDB/string-interpolation-included-.duckdb create mode 100644 Task/String-interpolation-included-/Pluto/string-interpolation-included-.pluto create mode 100644 Task/String-interpolation-included-/R/string-interpolation-included-.r create mode 100644 Task/String-length/ArkScript/string-length.ark create mode 100644 Task/String-length/DuckDB/string-length.duckdb create mode 100644 Task/String-length/FutureBasic/string-length.basic create mode 100644 Task/String-length/Pluto/string-length.pluto create mode 100644 Task/String-length/TAV/string-length.tav create mode 100644 Task/String-matching/ArkScript/string-matching.ark create mode 100644 Task/String-matching/DuckDB/string-matching.duckdb create mode 100644 Task/String-matching/R/string-matching.r create mode 100644 Task/String-prepend/ArkScript/string-prepend.ark create mode 100644 Task/String-prepend/DuckDB/string-prepend-1.duckdb create mode 100644 Task/String-prepend/DuckDB/string-prepend-2.duckdb create mode 100644 Task/String-prepend/DuckDB/string-prepend-3.duckdb create mode 100644 Task/Strip-a-set-of-characters-from-a-string/DuckDB/strip-a-set-of-characters-from-a-string.duckdb create mode 100644 Task/Strip-comments-from-a-string/DuckDB/strip-comments-from-a-string.duckdb create mode 100644 Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB/strip-control-codes-and-extended-characters-from-a-string.duckdb create mode 100644 Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB/strip-whitespace-from-a-string-top-and-tail.duckdb create mode 100644 Task/Substitution-cipher/Rust/substitution-cipher.rs create mode 100644 Task/Substring-Top-and-tail/Maxima/substring-top-and-tail.maxima create mode 100644 Task/Substring-Top-and-tail/R/substring-top-and-tail.r create mode 100644 Task/Substring/DuckDB/substring.duckdb create mode 100644 Task/Sudoku/DuckDB/sudoku.duckdb create mode 100644 Task/Sudoku/Zig/sudoku.zig create mode 100644 Task/Sum-and-product-of-an-array/ArkScript/sum-and-product-of-an-array.ark create mode 100644 Task/Sum-and-product-of-an-array/DuckDB/sum-and-product-of-an-array.duckdb create mode 100644 Task/Sum-digits-of-an-integer/ArkScript/sum-digits-of-an-integer.ark create mode 100644 Task/Sum-digits-of-an-integer/DuckDB/sum-digits-of-an-integer.duckdb rename Task/Sum-digits-of-an-integer/PascalABC.NET/{sum-digits-of-an-integer.pas => sum-digits-of-an-integer-1.pas} (100%) create mode 100644 Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-2.pas create mode 100644 Task/Sum-digits-of-an-integer/Pluto/sum-digits-of-an-integer.pluto create mode 100644 Task/Sum-multiples-of-3-and-5/DuckDB/sum-multiples-of-3-and-5.duckdb create mode 100644 Task/Sum-of-a-series/ArkScript/sum-of-a-series.ark create mode 100644 Task/Sum-of-a-series/DuckDB/sum-of-a-series-1.duckdb create mode 100644 Task/Sum-of-a-series/DuckDB/sum-of-a-series-2.duckdb create mode 100644 Task/Sum-of-a-series/DuckDB/sum-of-a-series-3.duckdb create mode 100644 Task/Sum-of-a-series/DuckDB/sum-of-a-series-4.duckdb create mode 100644 Task/Sum-of-a-series/FutureBasic/sum-of-a-series.basic create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena/sum-of-elements-below-main-diagonal-of-matrix.agena create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/Fennel/sum-of-elements-below-main-diagonal-of-matrix.fennel create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/Fortran/sum-of-elements-below-main-diagonal-of-matrix.f create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/Lua/sum-of-elements-below-main-diagonal-of-matrix.lua create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/Pluto/sum-of-elements-below-main-diagonal-of-matrix.pluto create mode 100644 Task/Sum-of-squares/ArkScript/sum-of-squares.ark create mode 100644 Task/Sum-of-squares/DuckDB/sum-of-squares-1.duckdb create mode 100644 Task/Sum-of-squares/DuckDB/sum-of-squares-2.duckdb create mode 100644 Task/Sum-of-squares/DuckDB/sum-of-squares-3.duckdb create mode 100644 Task/Sum-of-squares/DuckDB/sum-of-squares-4.duckdb create mode 100644 Task/Sum-to-100/FutureBasic/sum-to-100.basic create mode 100644 Task/Superellipse/Maxima/superellipse.maxima create mode 100644 Task/Superpermutation-minimisation/JavaScript/superpermutation-minimisation.js create mode 100644 Task/Symmetric-difference/DuckDB/symmetric-difference.duckdb create mode 100644 Task/Symmetric-difference/Pluto/symmetric-difference.pluto create mode 100644 Task/System-time/Pluto/system-time.pluto create mode 100644 Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-1.duckdb create mode 100644 Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-2.duckdb create mode 100644 Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-3.duckdb create mode 100644 Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-4.duckdb create mode 100644 Task/Tarjan/JavaScript/tarjan.js create mode 100644 Task/Tarjan/Zig/tarjan.zig create mode 100644 Task/Tau-function/FutureBasic/tau-function.basic create mode 100644 Task/Tau-function/Pluto/tau-function.pluto create mode 100644 Task/Tau-number/FutureBasic/tau-number.basic create mode 100644 Task/Tau-number/Pluto/tau-number.pluto create mode 100644 Task/Terminal-control-Clear-the-screen/Pluto/terminal-control-clear-the-screen.pluto create mode 100644 Task/Terminal-control-Coloured-text/Pluto/terminal-control-coloured-text.pluto create mode 100644 Task/Terminal-control-Cursor-movement/Pluto/terminal-control-cursor-movement.pluto create mode 100644 Task/Terminal-control-Cursor-positioning/Pluto/terminal-control-cursor-positioning.pluto create mode 100644 Task/Terminal-control-Dimensions/Pluto/terminal-control-dimensions.pluto create mode 100644 Task/Terminal-control-Display-an-extended-character/Pluto/terminal-control-display-an-extended-character.pluto create mode 100644 Task/Terminal-control-Hiding-the-cursor/Pluto/terminal-control-hiding-the-cursor.pluto create mode 100644 Task/Terminal-control-Inverse-video/Pluto/terminal-control-inverse-video.pluto create mode 100644 Task/Terminal-control-Preserve-screen/Pluto/terminal-control-preserve-screen.pluto create mode 100644 Task/Terminal-control-Ringing-the-terminal-bell/Pluto/terminal-control-ringing-the-terminal-bell.pluto create mode 100644 Task/Terminal-control-Ringing-the-terminal-bell/YAMLScript/terminal-control-ringing-the-terminal-bell.ys create mode 100644 Task/Terminal-control-Unicode-output/Pluto/terminal-control-unicode-output.pluto create mode 100644 Task/Test-integerness/Ada/test-integerness.ada create mode 100644 Task/Test-integerness/DuckDB/test-integerness-1.duckdb create mode 100644 Task/Test-integerness/DuckDB/test-integerness-2.duckdb create mode 100644 Task/Test-integerness/Pluto/test-integerness.pluto create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-1.duckdb create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-2.duckdb create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-3.duckdb create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-4.duckdb create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-5.duckdb create mode 100644 Task/Text-processing-2/DuckDB/text-processing-2-6.duckdb create mode 100644 Task/The-Name-Game/R/the-name-game.r create mode 100644 Task/The-Twelve-Days-of-Christmas/AutoLISP/the-twelve-days-of-christmas.l create mode 100644 Task/Thue-Morse/DuckDB/thue-morse-1.duckdb create mode 100644 Task/Thue-Morse/DuckDB/thue-morse-2.duckdb create mode 100644 Task/Thue-Morse/Prolog/thue-morse.pro create mode 100644 Task/Tic-tac-toe/TAV/tic-tac-toe.tav create mode 100644 Task/Time-a-function/Agena/time-a-function.agena create mode 100644 Task/Time-a-function/DuckDB/time-a-function.duckdb create mode 100644 Task/Time-a-function/Fennel/time-a-function.fennel create mode 100644 Task/Time-a-function/Pluto/time-a-function.pluto create mode 100644 Task/Tokenize-a-string-with-escaping/Icon/tokenize-a-string-with-escaping.icon create mode 100644 Task/Tokenize-a-string/DuckDB/tokenize-a-string.duckdb create mode 100644 Task/Tokenize-a-string/Refal/tokenize-a-string.refal create mode 100644 Task/Tokenize-a-string/SETL/tokenize-a-string.setl create mode 100644 Task/Tokenize-a-string/TAV/tokenize-a-string.tav create mode 100644 Task/Tonelli-Shanks-algorithm/Dart/tonelli-shanks-algorithm.dart create mode 100644 Task/Tonelli-Shanks-algorithm/Mathematica/tonelli-shanks-algorithm.math create mode 100644 Task/Tonelli-Shanks-algorithm/PARI-GP/tonelli-shanks-algorithm.parigp create mode 100644 Task/Tonelli-Shanks-algorithm/R/tonelli-shanks-algorithm.r create mode 100644 Task/Tonelli-Shanks-algorithm/Scala/tonelli-shanks-algorithm.scala create mode 100644 Task/Top-rank-per-group/DuckDB/top-rank-per-group-1.duckdb create mode 100644 Task/Top-rank-per-group/DuckDB/top-rank-per-group-2.duckdb create mode 100644 Task/Top-rank-per-group/DuckDB/top-rank-per-group-3.duckdb create mode 100644 Task/Topic-variable/Maxima/topic-variable.maxima create mode 100644 Task/Topswops/Prolog/topswops.pro create mode 100644 Task/Total-circles-area/Ada/total-circles-area.ada create mode 100644 Task/Total-circles-area/Pluto/total-circles-area-1.pluto create mode 100644 Task/Total-circles-area/Pluto/total-circles-area-2.pluto create mode 100644 Task/Totient-function/Agena/totient-function.agena create mode 100644 Task/Totient-function/Fortran/totient-function.f create mode 100644 Task/Totient-function/Pluto/totient-function.pluto create mode 100644 Task/Towers-of-Hanoi/Maxima/towers-of-hanoi.maxima create mode 100644 Task/Towers-of-Hanoi/Pluto/towers-of-hanoi.pluto create mode 100644 Task/Towers-of-Hanoi/Red/towers-of-hanoi.red create mode 100644 Task/Trabb-Pardo-Knuth-algorithm/Pluto/trabb-pardo-knuth-algorithm.pluto create mode 100644 Task/Trabb-Pardo-Knuth-algorithm/Prolog/trabb-pardo-knuth-algorithm.pro create mode 100644 Task/Trabb-Pardo-Knuth-algorithm/QB64/trabb-pardo-knuth-algorithm.qb64 create mode 100644 Task/Transliterate-English-text-using-the-Greek-alphabet/FreeBASIC/transliterate-english-text-using-the-greek-alphabet.basic create mode 100644 Task/Tree-datastructures/Rust/tree-datastructures.rs create mode 100644 Task/Tree-datastructures/Zig/tree-datastructures.zig create mode 100644 Task/Tree-from-nesting-levels/Icon/tree-from-nesting-levels.icon create mode 100644 Task/Tree-traversal/Adina/tree-traversal-1.adina create mode 100644 Task/Tree-traversal/Adina/tree-traversal-2.adina create mode 100644 Task/Trigonometric-functions/DuckDB/trigonometric-functions.duckdb create mode 100644 Task/Twos-complement/Ada/twos-complement.ada create mode 100644 Task/Twos-complement/Fortran/twos-complement.f create mode 100644 Task/UPC/Pluto/upc.pluto create mode 100644 Task/UPC/Rust/upc.rs create mode 100644 Task/UPC/Scala/upc.scala create mode 100644 Task/URL-decoding/DuckDB/url-decoding.duckdb create mode 100644 Task/UTF-8-encode-and-decode/DuckDB/utf-8-encode-and-decode.duckdb create mode 100644 Task/Undefined-values/YAMLScript/undefined-values.ys create mode 100644 Task/Unicode-strings/EasyLang/unicode-strings.easy create mode 100644 Task/Unicode-strings/Pluto/unicode-strings.pluto create mode 100644 Task/Unix-ls/DuckDB/unix-ls.duckdb create mode 100644 Task/Unprimeable-numbers/Agena/unprimeable-numbers.agena create mode 100644 Task/Unprimeable-numbers/Pluto/unprimeable-numbers.pluto create mode 100644 Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-1.jl create mode 100644 Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-2.jl create mode 100644 Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-3.jl create mode 100644 Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-4.jl create mode 100644 Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-1.lua create mode 100644 Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-2.lua create mode 100644 Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-3.lua create mode 100644 Task/User-input-Graphical/FuncSug/user-input-graphical.funcsug create mode 100644 Task/User-input-Text/ArkScript/user-input-text.ark create mode 100644 Task/User-input-Text/Extended-Color-BASIC/user-input-text.basic create mode 100644 Task/User-input-Text/Pluto/user-input-text.pluto create mode 100644 Task/Van-Eck-sequence/Agena/van-eck-sequence.agena create mode 100644 Task/Van-Eck-sequence/Pluto/van-eck-sequence.pluto create mode 100644 Task/Van-der-Corput-sequence/Agena/van-der-corput-sequence.agena create mode 100644 Task/Van-der-Corput-sequence/Pluto/van-der-corput-sequence.pluto create mode 100644 Task/Van-der-Corput-sequence/YAMLScript/van-der-corput-sequence.ys create mode 100644 Task/Variable-size-Get/DuckDB/variable-size-get.duckdb create mode 100644 Task/Variable-size-Set/DuckDB/variable-size-set.duckdb create mode 100644 Task/Variables/Bc/variables.bc create mode 100644 Task/Variadic-function/Pluto/variadic-function.pluto create mode 100644 Task/Vector-products/DuckDB/vector-products.duckdb create mode 100644 Task/Vector-products/Pluto/vector-products.pluto create mode 100644 Task/Vector/Ada/vector.ada create mode 100644 Task/Vector/Pluto/vector.pluto create mode 100644 Task/Verhoeff-algorithm/Zig/verhoeff-algorithm.zig create mode 100644 Task/Vigen-re-cipher-Cryptanalysis/Zig/vigen-re-cipher-cryptanalysis.zig create mode 100644 Task/Vogels-approximation-method/C-sharp/vogels-approximation-method.cs create mode 100644 Task/Vogels-approximation-method/Mathematica/vogels-approximation-method.math create mode 100644 Task/Vogels-approximation-method/Zig/vogels-approximation-method.zig create mode 100644 Task/Wagstaff-primes/Agena/wagstaff-primes.agena create mode 100644 Task/Wagstaff-primes/Lua/wagstaff-primes.lua create mode 100644 Task/Wagstaff-primes/Pluto/wagstaff-primes.pluto create mode 100644 Task/Wagstaff-primes/Ring/wagstaff-primes.ring create mode 100644 Task/War-card-game/Rust/war-card-game.rs create mode 100644 Task/War-card-game/Zig/war-card-game.zig create mode 100644 Task/Wieferich-primes/Agena/wieferich-primes.agena create mode 100644 Task/Wieferich-primes/Common-Lisp/wieferich-primes.lisp create mode 100644 Task/Wieferich-primes/Lua/wieferich-primes.lua create mode 100644 Task/Wieferich-primes/Pluto/wieferich-primes.pluto create mode 100644 Task/Wieferich-primes/R/wieferich-primes.r create mode 100644 Task/Window-creation/TAV/window-creation.tav create mode 100644 Task/Wireworld/Prolog/wireworld.pro create mode 100644 Task/Word-frequency/TAV/word-frequency.tav create mode 100644 Task/Word-wheel/ALGOL-68/word-wheel.alg create mode 100644 Task/Word-wrap/FutureBasic/word-wrap.basic create mode 100644 Task/Write-entire-file/ArkScript/write-entire-file.ark create mode 100644 Task/Write-entire-file/R/write-entire-file.r create mode 100644 Task/Xiaolin-Wus-line-algorithm/YAMLScript/xiaolin-wus-line-algorithm.ys create mode 100644 Task/Y-combinator/Pluto/y-combinator.pluto create mode 100644 Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena create mode 100644 Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel create mode 100644 Task/Yellowstone-sequence/FutureBasic/yellowstone-sequence.basic create mode 100644 Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto create mode 100644 Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys create mode 100644 Task/Zebra-puzzle/FutureBasic/zebra-puzzle.basic create mode 100644 Task/Zebra-puzzle/Pluto/zebra-puzzle.pluto create mode 100644 Task/Zero-to-the-zero-power/DuckDB/zero-to-the-zero-power.duckdb create mode 100644 Task/Zero-to-the-zero-power/Pluto/zero-to-the-zero-power.pluto create mode 100644 Task/Zero-to-the-zero-power/Prolog/zero-to-the-zero-power.pro create mode 100644 Task/Zig-zag-matrix/DuckDB/zig-zag-matrix.duckdb create mode 100644 Task/Zig-zag-matrix/YAMLScript/zig-zag-matrix.ys diff --git a/.gitignore b/.gitignore index 26ab3c8d09..ecbdc2385f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ /Cache/ /Meta/ /rosettacode.log +/entry +/pick +/random-clojure-task +/.clj-kondo/ +/.lsp/ diff --git a/Conf/lang.yaml b/Conf/lang.yaml index 4ccf7202e4..bf92f9a54f 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -24,10 +24,12 @@ Action!: .action ActionScript: .as Acurity Architect: .acurity Ada: .ada +Adina: .adina Agda: .agda Agda2: .agda2 Agena: .agena AHDL: .ahdl +AIDED NATURAL LANGUAGE: .aided Aikido: .aikido Aime: .aime Algae: .algae @@ -51,6 +53,7 @@ Anyways: .anyways Apex: .apex APL: .apl App Inventor: .app +Apple: .apple AppleScript: .applescript Applesoft BASIC: .basic Application Master: .app @@ -60,6 +63,8 @@ Arbre: .arbre Arc: .arc Arendelle: .arendelle Argile: .argile +Aria: .aria +ArkScript: .ark ARM Assembly: .arm ArnoldC: .arnoldc Arturo: .arturo @@ -138,6 +143,7 @@ C1R: .c1r C2: .c2 C3: .c3 CafeOBJ: .cafeobj +Calcscript: .calc Caml: .caml Casio BASIC: .basic Cat: .cat @@ -157,6 +163,7 @@ ChucK: .chuck Cilk++: .cilk++ Cilk: .cilk Cind: .cind +CJam: .cjam Clarion: .clarion Clay: .clay Clean: .clean @@ -180,6 +187,7 @@ Common Lisp: .lisp Component Pascal: .pas Computer/zero Assembly: .0asm ContextFree: .cf +Convex: .convex Coq: .coq Corescript: .core Cowgol: .cowgol @@ -216,6 +224,7 @@ Draco: .draco Dragon: .dragon DreamBerd: .dreamberd Dt: .dt +DuckDB: .duckdb DUP: .dup DWScript: .dw Dyalect: .dyalect @@ -260,6 +269,7 @@ Evaldraw: .evaldraw Excel: .excel Explore: .explore Extended BrainF***: .ebf +Extended Color BASIC: .basic Ezhil: .ezhil F: .f Factor: .factor @@ -297,6 +307,7 @@ Frink: .frink FRISC Assembly: .frisc F Sharp: .fs FTCBASIC: .basic +FuncSug: .funcsug FunL: .funl Furor: .furor FurryScript: .furryscript @@ -329,6 +340,7 @@ Gnuplot: .gnuplot Go!: .go Go: .go Goaldi: .goaldi +Goboscript: .gobo Golfscript: .golf Golo: .golo Goo: .goo @@ -402,6 +414,7 @@ Julia: .jl K: .k Kabap: .kabap Kamailio Script: .kamailio +Kantalo: .kantalo KAP: .kap Kaya: .kaya Keg: .keg @@ -419,6 +432,7 @@ KQL: .kql Ksh: .ksh L++: .l++ LabVIEW: .labview +Labyrinth: .labyrinth Lambda Prolog: .pro Lambdatalk: .lambdatalk Lang: .lang @@ -518,6 +532,7 @@ ML: .ml ML/I: .mli MLite: .mlite MMIX: .mmix +Mn: .mn Modula-2: .mod2 Modula-3: .mod3 Mojo: .mojo @@ -565,6 +580,7 @@ Nit: .nit Niue: .niue Nix: .nix NLP++: .nlp++ +Nom: .num NOWUT: .nowut NQP: .nqp NS-HUBASIC: .basic @@ -581,6 +597,7 @@ Objeck: .objeck ObjectIcon: .oi Objective-C: .m Object Pascal: .pas +Object Pascal Implementations: .pas OCaml: .ml Occam: .occam Octave: .octave @@ -613,6 +630,7 @@ Pare: .pare PARI/GP: .parigp Pascal: .pas PascalABC.NET: .pas +Pascal-P: .pas PASM: .pasm PDP-11 Assembly: .pdp11 Pebble: .pebble @@ -630,6 +648,7 @@ Phixmonti: .phixmonti PHL: .phl PHP: .php Picat: .picat +Pico-8: .pico8 PicoLisp: .l Pict: .pict Piet: .piet @@ -648,6 +667,7 @@ PL/M: .plm PL/pgSQL: .sql PL/SQL: .sql PLUS: .plus +Pluto: .pluto PLZ/SYS: .plz Pointless: .pointless Polyglot: .polyglot @@ -711,6 +731,7 @@ ReScript: .re Retro: .retro Revolution: .rev REXX: .rexx +Rhombus: .rhombus Rhope: .rhope Rhovas: .rhovas Ring: .ring @@ -812,6 +833,7 @@ SystemVerilog: .v TailDot: .taildot Tailspin: .tailspin TAL: .tal +TAV: .tav Tbas: .tbas Tcl: .tcl TechBASIC: .basic @@ -872,6 +894,7 @@ UserRPL: .rpl UTFool: .utfool Uxntal: .uxnatl V: .v +V (Vlang): .v Vala: .vala Vale: .vale VAX Assembly: .vax @@ -893,7 +916,7 @@ Vorpal: .vorpal Vox: .vox VRML: .vrml VTL-2: .vtl-2 -V (Vlang): .v +Vyxal: .vyxal Waduzitdo: .waduzitdo Wart: .wart WDTE: .wdte diff --git a/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt b/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt new file mode 100644 index 0000000000..c25a056976 --- /dev/null +++ b/Lang/AIDED-NATURAL-LANGUAGE/00-LANG.txt @@ -0,0 +1 @@ +{{stub}}{{language|Ayrch}} \ No newline at end of file diff --git a/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml b/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml new file mode 100644 index 0000000000..8395003e03 --- /dev/null +++ b/Lang/AIDED-NATURAL-LANGUAGE/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:AIDED_NATURAL_LANGUAGE diff --git a/Lang/ALGOL-60/Factorial b/Lang/ALGOL-60/Factorial deleted file mode 120000 index 67b243e1d0..0000000000 --- a/Lang/ALGOL-60/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/ALGOL-60 \ No newline at end of file diff --git a/Lang/ALGOL-68/Date-manipulation b/Lang/ALGOL-68/Date-manipulation new file mode 120000 index 0000000000..700d602cf1 --- /dev/null +++ b/Lang/ALGOL-68/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series b/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series new file mode 120000 index 0000000000..242e3aeb60 --- /dev/null +++ b/Lang/ALGOL-68/Distribution-of-0-digits-in-factorial-series @@ -0,0 +1 @@ +../../Task/Distribution-of-0-digits-in-factorial-series/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factorial b/Lang/ALGOL-68/Factorial deleted file mode 120000 index b406800839..0000000000 --- a/Lang/ALGOL-68/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Knapsack-problem-Continuous b/Lang/ALGOL-68/Knapsack-problem-Continuous new file mode 120000 index 0000000000..f49865cc46 --- /dev/null +++ b/Lang/ALGOL-68/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Word-wheel b/Lang/ALGOL-68/Word-wheel new file mode 120000 index 0000000000..ab6aaa99f7 --- /dev/null +++ b/Lang/ALGOL-68/Word-wheel @@ -0,0 +1 @@ +../../Task/Word-wheel/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-W/Factorial b/Lang/ALGOL-W/Factorial deleted file mode 120000 index 01c77fb141..0000000000 --- a/Lang/ALGOL-W/Factorial +++ /dev/null @@ -1 +0,0 @@ -../../Task/Factorial/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Knapsack-problem-Continuous b/Lang/ALGOL-W/Knapsack-problem-Continuous new file mode 120000 index 0000000000..fba28c1695 --- /dev/null +++ b/Lang/ALGOL-W/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/ALGOL-W \ No newline at end of file diff --git a/Lang/ANSI-BASIC/AKS-test-for-primes b/Lang/ANSI-BASIC/AKS-test-for-primes new file mode 120000 index 0000000000..4668d2783c --- /dev/null +++ b/Lang/ANSI-BASIC/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Old-Russian-measure-of-length b/Lang/ANSI-BASIC/Old-Russian-measure-of-length new file mode 120000 index 0000000000..81f64cd54c --- /dev/null +++ b/Lang/ANSI-BASIC/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/ANSI-BASIC \ No newline at end of file diff --git a/Lang/APL/Monte-Carlo-methods b/Lang/APL/Monte-Carlo-methods new file mode 120000 index 0000000000..2cf831a11c --- /dev/null +++ b/Lang/APL/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/APL \ No newline at end of file diff --git a/Lang/ARM-Assembly/00-LANG.txt b/Lang/ARM-Assembly/00-LANG.txt index 4c41d124d7..273ed5e757 100644 --- a/Lang/ARM-Assembly/00-LANG.txt +++ b/Lang/ARM-Assembly/00-LANG.txt @@ -4,9 +4,9 @@ The ARM architecture is widely used on mobile phones and tablets. It falls under ===Instruction Size=== Every instruction that the ARM can execute is 32 bits. While other processors can have variable length instructions, the ARM does not. This means that the ARM doesn't need to parse where an instruction begins and ends, which makes it run very fast. What you might not expect is that this 32-bit instruction size includes both the actual instruction and the operands! Let's take a look at a [[Z80 Assembly]] instruction and compare it to an ARM instruction. -LD HL,&8040 ;bytecode is 0x21 0x40 0x80 +LD HL,&8040 ;bytecode is 0x21 0x40 0x80 -mov r4,#0x04000000 ;bytecode is 0xE3A04301 +mov r4,#0x04000000 ;bytecode is 0xE3A04301 So where did the 0x04000000 go? It's actually been compressed and fit within those 4 bytes you saw earlier. The ARM is very good at decompressing it, since it's been shrunk to an 8-bit number that can be rotated by an even number of bits. Unfortunately, this compression method is a double-edged sword - some 32-bit numbers can't be compressed this way, and thus many instructions can't work with them! @@ -18,72 +18,73 @@ Registers are much more flexible than immediate operands. Unlike immediate opera Getting an address in a register can be achieved with the MOV command, but there are limitations to that which will be explained in detail later. It's more reliable to use ADR which loads a nearby address into a register. This address has to be within a certain distance from the current program counter or it can't be loaded, so it's not a reliable way to load from the heap on many machines. It's mostly intended for loading from nearby read-only data, such as text strings or stored immediates (more on that later). When you type ADR R0,LABEL, the assembler will convert this to MOV R0,PC,#N, where N is the difference between the current program counter value and the label you specified. LDR can be used in a similar fashion to ADR but there is a subtle distinction between the two. Assume that the section below is assembled starting at memory address 0x04000000: -DataBlock: +DataBlock: .long 0xDEADBEEF ;VASM uses .long for 32-bit data and .word for 16-bit data. Your assembler will probably use .word for 32 bit and .long 0xFFFFFFFF ; .hword for 16-bit. MyCode: adr r0, DataBlock ;loads the value 0x04000000 into R0 - ldr r1, DataBlock ;loads the value 0xDEADBEEF into R1 - adr r2, DataBlock+4 ;loads the value 0x04000004 into R2 - -ldr r3, DataBlock+4 ;loads the value 0xFFFFFFFF into R3 +ldr r3, DataBlock+4 ;loads the value 0xFFFFFFFF into R3 + As you can see, ADR only gives you the memory location of a value in memory, where LDR loads ''from'' that memory location. - ===Data Addressing using LDR and STR=== Unlike its "cousin," the Motorola 68000 (which isn't really related but has a somewhat similar design), the ARM cannot directly write immediate values to memory. Those values must be contained in registers first. Unlike the 68000, the ARM has no "address registers." Rather, enclosing a register name in square brackets turns its value into a reference to a memory location. You'll need to load that memory location's numeric "value" as a constant first. Then you can read from it with LDR and write to it with STR. Not only can you read from a given address, you can also adjust how you read from it, and what you do before or after the read. -RAM_ADDRESS: +RAM_ADDRESS: .long 0 ;for simplicity we'll assume that this can actually be written to. Represents a placeholder for 32-bit data. ;Your assembler's syntax may be different. - .long 0 ;another placeholder for 32-bit data MyCode: adr R2,RAM_Address ;get the address of a nearby place to store values. MOV R0,#0x12345678 ;the value to store. -STR R0,[R2] ;store 0x12345678 into the first 32-bit slot. +STR R0,[R2] ;store 0x12345678 into the first 32-bit slot. + This is the basic way to store into memory, but there are other options, such as offsetting and post-increment. -RAM_ADDRESS: +RAM_ADDRESS: .long 0 .long 0 ;we'll store here this time. MyCode: adr R2,RAM_Address ;point R2 to the first storage slot MOV R0,#0x12345678 -STR R0,[R2,#4] ;store into the SECOND slot. R2 still points to the first slot - the #4 is added to R2 only temporarily. +STR R0,[R2,#4] ;store into the SECOND slot. R2 still points to the first slot - the #4 is added to R2 only temporarily. + There's a limit on the size of an immediate value used to offset when loading/storing. You can also use a register as an offset, whose value will be added to the address. -RAM_AREA: +RAM_AREA: .space 64,0 ;64 bytes of ram ;assume that R2 contains the address of "RAM_AREA" MyCode: MOV R0,#0x12345678 MOV R1,#20 -STR R0,[R2,R1] ;equivalent of "STR R0,[R2,#20]" +STR R0,[R2,R1] ;equivalent of "STR R0,[R2,#20]" + Now let's say you wanted to actually alter the pointer to R2, so that it remains pointing to where you offset it to after the store or load. That's an option you have - all you have to do is type "!" after the brackets. This is called "pre-increment" or "pre-indexing." -RAM_ADDRESS: +RAM_ADDRESS: .long 0 .long 0 ;we'll store here this time, and we want R2 to still be pointing here after we write to it. MyCode: adr R2,RAM_Address ;point R2 to the first storage slot MOV R0,#0x12345678 -STR R0,[R2,#4]! ;store into the SECOND slot. R2 also points to the second slot now, even after this instruction has concluded. +STR R0,[R2,#4]! ;store into the SECOND slot. R2 also points to the second slot now, even after this instruction has concluded. + Here, the offset is performed ''before'' the storage operation. What if you want to offset afterwards? That would be useful for reading in a data stream. Good news - you can do that simply by having the offset value or register '''outside''' the brackets. This is called "post-increment" or "post-indexing." Unlike pre-indexing, these changes to the pointer are not temporary. -LDR R0,[R1],#4 ;load the 32-bit value stored at memory location R1 into R0, THEN add 4 to R1. This offset remains even after this - ; instruction is finished. +LDR R0,[R1],#4 ;load the 32-bit value stored at memory location R1 into R0, THEN add 4 to R1. This offset remains even after this + ; instruction is finished. + ===Barrel Shifter=== The ARM can add a bit shift or rotate to one of its operands at no additional cost to execution time or bytecode. If the operand being shifted is a register, the value of that register is not actually changed. The shift or rotate only applies during that instruction. diff --git a/Lang/ASIC/Old-Russian-measure-of-length b/Lang/ASIC/Old-Russian-measure-of-length new file mode 120000 index 0000000000..e5e809a47d --- /dev/null +++ b/Lang/ASIC/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/ASIC \ No newline at end of file diff --git a/Lang/AWK/100-doors b/Lang/AWK/100-doors deleted file mode 120000 index 99c9a19f16..0000000000 --- a/Lang/AWK/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/AWK \ No newline at end of file diff --git a/Lang/AWK/Factorial-primes b/Lang/AWK/Factorial-primes new file mode 120000 index 0000000000..7344ad75fd --- /dev/null +++ b/Lang/AWK/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/AWK \ No newline at end of file diff --git a/Lang/AWK/Soloways-recurring-rainfall b/Lang/AWK/Soloways-recurring-rainfall new file mode 120000 index 0000000000..1f850c19b0 --- /dev/null +++ b/Lang/AWK/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/AWK \ No newline at end of file diff --git a/Lang/Ada/Almkvist-Giullera-formula-for-pi b/Lang/Ada/Almkvist-Giullera-formula-for-pi new file mode 120000 index 0000000000..66015473cd --- /dev/null +++ b/Lang/Ada/Almkvist-Giullera-formula-for-pi @@ -0,0 +1 @@ +../../Task/Almkvist-Giullera-formula-for-pi/Ada \ No newline at end of file diff --git a/Lang/Ada/Biorhythms b/Lang/Ada/Biorhythms new file mode 120000 index 0000000000..0d82777906 --- /dev/null +++ b/Lang/Ada/Biorhythms @@ -0,0 +1 @@ +../../Task/Biorhythms/Ada \ No newline at end of file diff --git a/Lang/Ada/Boyer-Moore-string-search b/Lang/Ada/Boyer-Moore-string-search new file mode 120000 index 0000000000..114c2a5fea --- /dev/null +++ b/Lang/Ada/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/Ada \ No newline at end of file diff --git a/Lang/Ada/Calkin-Wilf-sequence b/Lang/Ada/Calkin-Wilf-sequence new file mode 120000 index 0000000000..9e4b8cd779 --- /dev/null +++ b/Lang/Ada/Calkin-Wilf-sequence @@ -0,0 +1 @@ +../../Task/Calkin-Wilf-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Camel-case-and-snake-case b/Lang/Ada/Camel-case-and-snake-case new file mode 120000 index 0000000000..1d95b38233 --- /dev/null +++ b/Lang/Ada/Camel-case-and-snake-case @@ -0,0 +1 @@ +../../Task/Camel-case-and-snake-case/Ada \ No newline at end of file diff --git a/Lang/Ada/Canonicalize-CIDR b/Lang/Ada/Canonicalize-CIDR new file mode 120000 index 0000000000..c0c0b338b8 --- /dev/null +++ b/Lang/Ada/Canonicalize-CIDR @@ -0,0 +1 @@ +../../Task/Canonicalize-CIDR/Ada \ No newline at end of file diff --git a/Lang/Ada/Deepcopy b/Lang/Ada/Deepcopy new file mode 120000 index 0000000000..4b1e30735d --- /dev/null +++ b/Lang/Ada/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Ada \ No newline at end of file diff --git a/Lang/Ada/Factorions b/Lang/Ada/Factorions new file mode 120000 index 0000000000..d9b74415a9 --- /dev/null +++ b/Lang/Ada/Factorions @@ -0,0 +1 @@ +../../Task/Factorions/Ada \ No newline at end of file diff --git a/Lang/Ada/Find-duplicate-files b/Lang/Ada/Find-duplicate-files new file mode 120000 index 0000000000..f7ad1ff6fd --- /dev/null +++ b/Lang/Ada/Find-duplicate-files @@ -0,0 +1 @@ +../../Task/Find-duplicate-files/Ada \ No newline at end of file diff --git a/Lang/Ada/Harmonic-series b/Lang/Ada/Harmonic-series new file mode 120000 index 0000000000..97492bcb66 --- /dev/null +++ b/Lang/Ada/Harmonic-series @@ -0,0 +1 @@ +../../Task/Harmonic-series/Ada \ No newline at end of file diff --git a/Lang/Ada/Knapsack-problem-Bounded b/Lang/Ada/Knapsack-problem-Bounded new file mode 120000 index 0000000000..1cfbda0d29 --- /dev/null +++ b/Lang/Ada/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Ada \ No newline at end of file diff --git a/Lang/Ada/Levenshtein-distance-Alignment b/Lang/Ada/Levenshtein-distance-Alignment new file mode 120000 index 0000000000..1c6a7ca906 --- /dev/null +++ b/Lang/Ada/Levenshtein-distance-Alignment @@ -0,0 +1 @@ +../../Task/Levenshtein-distance-Alignment/Ada \ No newline at end of file diff --git a/Lang/Ada/Long-literals-with-continuations b/Lang/Ada/Long-literals-with-continuations new file mode 120000 index 0000000000..9d6be6cfc8 --- /dev/null +++ b/Lang/Ada/Long-literals-with-continuations @@ -0,0 +1 @@ +../../Task/Long-literals-with-continuations/Ada \ No newline at end of file diff --git a/Lang/Ada/Longest-increasing-subsequence b/Lang/Ada/Longest-increasing-subsequence new file mode 120000 index 0000000000..dd360a694d --- /dev/null +++ b/Lang/Ada/Longest-increasing-subsequence @@ -0,0 +1 @@ +../../Task/Longest-increasing-subsequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Machine-code b/Lang/Ada/Machine-code new file mode 120000 index 0000000000..52ae4edc91 --- /dev/null +++ b/Lang/Ada/Machine-code @@ -0,0 +1 @@ +../../Task/Machine-code/Ada \ No newline at end of file diff --git a/Lang/Ada/Minimal-steps-down-to-1 b/Lang/Ada/Minimal-steps-down-to-1 new file mode 120000 index 0000000000..44f17e189f --- /dev/null +++ b/Lang/Ada/Minimal-steps-down-to-1 @@ -0,0 +1 @@ +../../Task/Minimal-steps-down-to-1/Ada \ No newline at end of file diff --git a/Lang/Ada/Naming-conventions b/Lang/Ada/Naming-conventions new file mode 120000 index 0000000000..44f00f1ff1 --- /dev/null +++ b/Lang/Ada/Naming-conventions @@ -0,0 +1 @@ +../../Task/Naming-conventions/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-a-file-character-by-character-UTF8 b/Lang/Ada/Read-a-file-character-by-character-UTF8 new file mode 120000 index 0000000000..71f788273b --- /dev/null +++ b/Lang/Ada/Read-a-file-character-by-character-UTF8 @@ -0,0 +1 @@ +../../Task/Read-a-file-character-by-character-UTF8/Ada \ No newline at end of file diff --git a/Lang/Ada/Test-integerness b/Lang/Ada/Test-integerness new file mode 120000 index 0000000000..8a5462dcb5 --- /dev/null +++ b/Lang/Ada/Test-integerness @@ -0,0 +1 @@ +../../Task/Test-integerness/Ada \ No newline at end of file diff --git a/Lang/Ada/Total-circles-area b/Lang/Ada/Total-circles-area new file mode 120000 index 0000000000..781e585826 --- /dev/null +++ b/Lang/Ada/Total-circles-area @@ -0,0 +1 @@ +../../Task/Total-circles-area/Ada \ No newline at end of file diff --git a/Lang/Ada/Twos-complement b/Lang/Ada/Twos-complement new file mode 120000 index 0000000000..396d1a76f2 --- /dev/null +++ b/Lang/Ada/Twos-complement @@ -0,0 +1 @@ +../../Task/Twos-complement/Ada \ No newline at end of file diff --git a/Lang/Ada/Vector b/Lang/Ada/Vector new file mode 120000 index 0000000000..4cc7975e2f --- /dev/null +++ b/Lang/Ada/Vector @@ -0,0 +1 @@ +../../Task/Vector/Ada \ No newline at end of file diff --git a/Lang/Adina/00-LANG.txt b/Lang/Adina/00-LANG.txt new file mode 100644 index 0000000000..e796807867 --- /dev/null +++ b/Lang/Adina/00-LANG.txt @@ -0,0 +1,13 @@ +{{language|Adina}} +Adina is a programming language, based on Racket and russian language. Unlike Racket it uses indent and operators precedence to describe program syntax. It may be used in english, because all Racket libraries are accessible. One should add "english()" in first string to use standard racket libraries. + +Адина, это язык программирования, основанный на Racket и русском языке. В отличие от Racket вместо скобок для синтаксической +структуры используются отступы и бинарные операторы. Также сделан доступ через квадратные скобки к элементам коллекции и через фигурные к методам объектов. + +Документация по адресу: https://docs.racket-lang.org/russian-lang/ + +==See Also== +* [[Racket]] + +==TODO== +[[Tasks not implemented in Adina]] \ No newline at end of file diff --git a/Lang/Adina/00-META.yaml b/Lang/Adina/00-META.yaml new file mode 100644 index 0000000000..e1ca8650ca --- /dev/null +++ b/Lang/Adina/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Adina diff --git a/Lang/Adina/100-doors b/Lang/Adina/100-doors new file mode 120000 index 0000000000..c96d2d65fc --- /dev/null +++ b/Lang/Adina/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Adina \ No newline at end of file diff --git a/Lang/Adina/Even-or-odd b/Lang/Adina/Even-or-odd new file mode 120000 index 0000000000..1718b42d76 --- /dev/null +++ b/Lang/Adina/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Adina \ No newline at end of file diff --git a/Lang/Adina/Hello-world-Text b/Lang/Adina/Hello-world-Text new file mode 120000 index 0000000000..f886a7cc4f --- /dev/null +++ b/Lang/Adina/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Adina \ No newline at end of file diff --git a/Lang/Adina/Loops-For b/Lang/Adina/Loops-For new file mode 120000 index 0000000000..c4d6bee093 --- /dev/null +++ b/Lang/Adina/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Adina \ No newline at end of file diff --git a/Lang/Adina/Tree-traversal b/Lang/Adina/Tree-traversal new file mode 120000 index 0000000000..fd3896d623 --- /dev/null +++ b/Lang/Adina/Tree-traversal @@ -0,0 +1 @@ +../../Task/Tree-traversal/Adina \ No newline at end of file diff --git a/Lang/Agena/00-LANG.txt b/Lang/Agena/00-LANG.txt index c2930ac7a2..c8171cc29e 100644 --- a/Lang/Agena/00-LANG.txt +++ b/Lang/Agena/00-LANG.txt @@ -21,4 +21,6 @@ The syntax looks like very simplified [[ALGOL 68]] with elements taken from [[Lu Agena is based on the [[ANSI]] [[C]] source code of [[Lua]], a popular and widely used Open Source programming language. == See Also == -[[ALGOL 68]] \ No newline at end of file +[[ALGOL 68]]
+[[Lua]]
+[[SQL]] \ No newline at end of file diff --git a/Lang/Agena/AKS-test-for-primes b/Lang/Agena/AKS-test-for-primes new file mode 120000 index 0000000000..ab27a842c8 --- /dev/null +++ b/Lang/Agena/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Abundant-deficient-and-perfect-number-classifications b/Lang/Agena/Abundant-deficient-and-perfect-number-classifications new file mode 120000 index 0000000000..89450cb83c --- /dev/null +++ b/Lang/Agena/Abundant-deficient-and-perfect-number-classifications @@ -0,0 +1 @@ +../../Task/Abundant-deficient-and-perfect-number-classifications/Agena \ No newline at end of file diff --git a/Lang/Agena/Abundant-odd-numbers b/Lang/Agena/Abundant-odd-numbers new file mode 120000 index 0000000000..a18ccbb662 --- /dev/null +++ b/Lang/Agena/Abundant-odd-numbers @@ -0,0 +1 @@ +../../Task/Abundant-odd-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Arbitrary-precision-integers-included- b/Lang/Agena/Arbitrary-precision-integers-included- new file mode 120000 index 0000000000..347104998a --- /dev/null +++ b/Lang/Agena/Arbitrary-precision-integers-included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included-/Agena \ No newline at end of file diff --git a/Lang/Agena/Attractive-numbers b/Lang/Agena/Attractive-numbers new file mode 120000 index 0000000000..bc968b5d21 --- /dev/null +++ b/Lang/Agena/Attractive-numbers @@ -0,0 +1 @@ +../../Task/Attractive-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Disarium-numbers b/Lang/Agena/Disarium-numbers new file mode 120000 index 0000000000..2bace62b71 --- /dev/null +++ b/Lang/Agena/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Factorial b/Lang/Agena/Factorial new file mode 120000 index 0000000000..21cbc1e46b --- /dev/null +++ b/Lang/Agena/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Agena \ No newline at end of file diff --git a/Lang/Agena/Factorial-primes b/Lang/Agena/Factorial-primes new file mode 120000 index 0000000000..68796e7224 --- /dev/null +++ b/Lang/Agena/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Giuga-numbers b/Lang/Agena/Giuga-numbers new file mode 120000 index 0000000000..273fdf8c7c --- /dev/null +++ b/Lang/Agena/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Goldbachs-comet b/Lang/Agena/Goldbachs-comet new file mode 120000 index 0000000000..26b052a294 --- /dev/null +++ b/Lang/Agena/Goldbachs-comet @@ -0,0 +1 @@ +../../Task/Goldbachs-comet/Agena \ No newline at end of file diff --git a/Lang/Agena/Horners-rule-for-polynomial-evaluation b/Lang/Agena/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..cffe37e87c --- /dev/null +++ b/Lang/Agena/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Agena \ No newline at end of file diff --git a/Lang/Agena/Humble-numbers b/Lang/Agena/Humble-numbers new file mode 120000 index 0000000000..bdce77fd35 --- /dev/null +++ b/Lang/Agena/Humble-numbers @@ -0,0 +1 @@ +../../Task/Humble-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/JSON b/Lang/Agena/JSON new file mode 120000 index 0000000000..9c20f7b68f --- /dev/null +++ b/Lang/Agena/JSON @@ -0,0 +1 @@ +../../Task/JSON/Agena \ No newline at end of file diff --git a/Lang/Agena/Jacobsthal-numbers b/Lang/Agena/Jacobsthal-numbers new file mode 120000 index 0000000000..740d21ef1a --- /dev/null +++ b/Lang/Agena/Jacobsthal-numbers @@ -0,0 +1 @@ +../../Task/Jacobsthal-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Jewels-and-stones b/Lang/Agena/Jewels-and-stones new file mode 120000 index 0000000000..7c03f8ec8f --- /dev/null +++ b/Lang/Agena/Jewels-and-stones @@ -0,0 +1 @@ +../../Task/Jewels-and-stones/Agena \ No newline at end of file diff --git a/Lang/Agena/Kaprekar-numbers b/Lang/Agena/Kaprekar-numbers new file mode 120000 index 0000000000..d665f2f5f5 --- /dev/null +++ b/Lang/Agena/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Mian-Chowla-sequence b/Lang/Agena/Mian-Chowla-sequence new file mode 120000 index 0000000000..a6489175a6 --- /dev/null +++ b/Lang/Agena/Mian-Chowla-sequence @@ -0,0 +1 @@ +../../Task/Mian-Chowla-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Pernicious-numbers b/Lang/Agena/Pernicious-numbers new file mode 120000 index 0000000000..454ce5b94d --- /dev/null +++ b/Lang/Agena/Pernicious-numbers @@ -0,0 +1 @@ +../../Task/Pernicious-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Pisano-period b/Lang/Agena/Pisano-period new file mode 120000 index 0000000000..afaae8dce9 --- /dev/null +++ b/Lang/Agena/Pisano-period @@ -0,0 +1 @@ +../../Task/Pisano-period/Agena \ No newline at end of file diff --git a/Lang/Agena/Primality-by-trial-division b/Lang/Agena/Primality-by-trial-division new file mode 120000 index 0000000000..621c0609eb --- /dev/null +++ b/Lang/Agena/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Agena \ No newline at end of file diff --git a/Lang/Agena/Sequence-of-primes-by-trial-division b/Lang/Agena/Sequence-of-primes-by-trial-division new file mode 120000 index 0000000000..d7958a31a1 --- /dev/null +++ b/Lang/Agena/Sequence-of-primes-by-trial-division @@ -0,0 +1 @@ +../../Task/Sequence-of-primes-by-trial-division/Agena \ No newline at end of file diff --git a/Lang/Agena/Smarandache-prime-digital-sequence b/Lang/Agena/Smarandache-prime-digital-sequence new file mode 120000 index 0000000000..3a1f0e0805 --- /dev/null +++ b/Lang/Agena/Smarandache-prime-digital-sequence @@ -0,0 +1 @@ +../../Task/Smarandache-prime-digital-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Soloways-recurring-rainfall b/Lang/Agena/Soloways-recurring-rainfall new file mode 120000 index 0000000000..b391a79582 --- /dev/null +++ b/Lang/Agena/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/Agena \ No newline at end of file diff --git a/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..6bd7256f3a --- /dev/null +++ b/Lang/Agena/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena \ No newline at end of file diff --git a/Lang/Agena/Time-a-function b/Lang/Agena/Time-a-function new file mode 120000 index 0000000000..e5746c4dff --- /dev/null +++ b/Lang/Agena/Time-a-function @@ -0,0 +1 @@ +../../Task/Time-a-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Totient-function b/Lang/Agena/Totient-function new file mode 120000 index 0000000000..d74f15771c --- /dev/null +++ b/Lang/Agena/Totient-function @@ -0,0 +1 @@ +../../Task/Totient-function/Agena \ No newline at end of file diff --git a/Lang/Agena/Unprimeable-numbers b/Lang/Agena/Unprimeable-numbers new file mode 120000 index 0000000000..fc3b30fec4 --- /dev/null +++ b/Lang/Agena/Unprimeable-numbers @@ -0,0 +1 @@ +../../Task/Unprimeable-numbers/Agena \ No newline at end of file diff --git a/Lang/Agena/Van-Eck-sequence b/Lang/Agena/Van-Eck-sequence new file mode 120000 index 0000000000..1714aa1507 --- /dev/null +++ b/Lang/Agena/Van-Eck-sequence @@ -0,0 +1 @@ +../../Task/Van-Eck-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Van-der-Corput-sequence b/Lang/Agena/Van-der-Corput-sequence new file mode 120000 index 0000000000..92bec950df --- /dev/null +++ b/Lang/Agena/Van-der-Corput-sequence @@ -0,0 +1 @@ +../../Task/Van-der-Corput-sequence/Agena \ No newline at end of file diff --git a/Lang/Agena/Wagstaff-primes b/Lang/Agena/Wagstaff-primes new file mode 120000 index 0000000000..b63d3369fa --- /dev/null +++ b/Lang/Agena/Wagstaff-primes @@ -0,0 +1 @@ +../../Task/Wagstaff-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Wieferich-primes b/Lang/Agena/Wieferich-primes new file mode 120000 index 0000000000..34597fbb1d --- /dev/null +++ b/Lang/Agena/Wieferich-primes @@ -0,0 +1 @@ +../../Task/Wieferich-primes/Agena \ No newline at end of file diff --git a/Lang/Agena/Yellowstone-sequence b/Lang/Agena/Yellowstone-sequence new file mode 120000 index 0000000000..4464a6e815 --- /dev/null +++ b/Lang/Agena/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/Agena \ No newline at end of file diff --git a/Lang/Apple/00-LANG.txt b/Lang/Apple/00-LANG.txt new file mode 100644 index 0000000000..e4e452b143 --- /dev/null +++ b/Lang/Apple/00-LANG.txt @@ -0,0 +1,12 @@ +{{language|Apple +|exec=Compiled +|safety=safe +|checking=static +|strength=strong +|site=https://github.com/vmchale/apple}} + +{{language programming paradigm|functional}} + +The Apple Array System is a JIT-compiler for a statically typed functional language specialized on arrays. + +It is expression-oriented (it has no imports); it is meant to be called from other languages. \ No newline at end of file diff --git a/Lang/Apple/00-META.yaml b/Lang/Apple/00-META.yaml new file mode 100644 index 0000000000..fcdeec5d5c --- /dev/null +++ b/Lang/Apple/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Apple diff --git a/Lang/Apple/Averages-Arithmetic-mean b/Lang/Apple/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b4236a6909 --- /dev/null +++ b/Lang/Apple/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Apple \ No newline at end of file diff --git a/Lang/Apple/Averages-Pythagorean-means b/Lang/Apple/Averages-Pythagorean-means new file mode 120000 index 0000000000..50c70e6c0b --- /dev/null +++ b/Lang/Apple/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Apple \ No newline at end of file diff --git a/Lang/Apple/Catamorphism b/Lang/Apple/Catamorphism new file mode 120000 index 0000000000..5d06cbf18d --- /dev/null +++ b/Lang/Apple/Catamorphism @@ -0,0 +1 @@ +../../Task/Catamorphism/Apple \ No newline at end of file diff --git a/Lang/Apple/Dot-product b/Lang/Apple/Dot-product new file mode 120000 index 0000000000..084fc21920 --- /dev/null +++ b/Lang/Apple/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Apple \ No newline at end of file diff --git a/Lang/Apple/Factorial b/Lang/Apple/Factorial new file mode 120000 index 0000000000..8d659daa6f --- /dev/null +++ b/Lang/Apple/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Apple \ No newline at end of file diff --git a/Lang/Apple/Factors-of-an-integer b/Lang/Apple/Factors-of-an-integer new file mode 120000 index 0000000000..a965a5d4bd --- /dev/null +++ b/Lang/Apple/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Apple \ No newline at end of file diff --git a/Lang/Apple/Filter b/Lang/Apple/Filter new file mode 120000 index 0000000000..5dfbcaf92d --- /dev/null +++ b/Lang/Apple/Filter @@ -0,0 +1 @@ +../../Task/Filter/Apple \ No newline at end of file diff --git a/Lang/Apple/ISBN13-check-digit b/Lang/Apple/ISBN13-check-digit new file mode 120000 index 0000000000..b9d843e9fc --- /dev/null +++ b/Lang/Apple/ISBN13-check-digit @@ -0,0 +1 @@ +../../Task/ISBN13-check-digit/Apple \ No newline at end of file diff --git a/Lang/Aria/00-LANG.txt b/Lang/Aria/00-LANG.txt new file mode 100644 index 0000000000..f3d1668eba --- /dev/null +++ b/Lang/Aria/00-LANG.txt @@ -0,0 +1,15 @@ +{{language +|exec=interpreted +|site=https://egranata.github.io/aria/ +}} + +Aria is a modern, dynamic scripting language. It is meant to be a “sweet spot” language, easy to pick-up and enjoyable to use. + +It provides a familiar C-style syntax, with a feature set inspired by well-beloved languages such as Python and Rust. It comes with little ceremony and a focus on getting stuff done. + +Aria programs are written as .aria files and passed to the Aria virtual machine, which compiles them down to bytecode and executes them. + +The Aria interpreter is written in Rust, 2024 edition. + +==Todo== +[[Tasks_not_implemented_in_Aria]] \ No newline at end of file diff --git a/Lang/Aria/00-META.yaml b/Lang/Aria/00-META.yaml new file mode 100644 index 0000000000..35ebadd91a --- /dev/null +++ b/Lang/Aria/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Aria diff --git a/Lang/Aria/99-bottles-of-beer b/Lang/Aria/99-bottles-of-beer new file mode 120000 index 0000000000..c2f486227d --- /dev/null +++ b/Lang/Aria/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/Aria \ No newline at end of file diff --git a/Lang/Aria/Hello-world-Text b/Lang/Aria/Hello-world-Text new file mode 120000 index 0000000000..bb8e1db7a7 --- /dev/null +++ b/Lang/Aria/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Aria \ No newline at end of file diff --git a/Lang/ArkScript/00-LANG.txt b/Lang/ArkScript/00-LANG.txt new file mode 100644 index 0000000000..11fc16bd5b --- /dev/null +++ b/Lang/ArkScript/00-LANG.txt @@ -0,0 +1,43 @@ +{{language|ArkScript +|exec=bytecode +|site=https://arkscript-lang.dev +|gc=no +|parampass=value +|strength=strong +|checking=dynamic +|tags=arkscript}} +ArkScript is a small, fast, functional and scripting language for C++ projects, inspired by [[Lua]], [[Lisp]], and [[Python]]. + +The language has been designed to be concise, with only 9 keywords, and two rules to parse it: +# the first node after an opening paren ( is a "function", the following nodes are arguments +# the only exception to the previous rule is when defining the argument list of a function + + +(let foo 5) +(let bar "hello world!") + +(let egg (fun (a b c) + (+ a (* b c)))) + +(print (egg 1 foo bar)) + + +The language is also +* small: the core fit under 8000 lines of code ; also small in terms of keywords (only 9) +* a scripting language: very easy to embed it in your projects. Registering your own functions in the language is made easy +* portable: a unique bytecode which can be run everywhere the virtual machine is +* a functional language: every parameter is passed by value, everything is immutable unless specified +* powerful: provides closures and explicit capture +* promoting functionalities before performances: expressiveness often brings more productivity, though performances aren't left behind +* a Lisp inspired language, with fewer parentheses: [...] is expanded to (list ...) and {} to (begin ...) +* extensible: supports C++ module to use it in the language, adding functionalities + + +===Implementation=== +The compiler and VM are implemented in [[C++]] 20. For more details, see [https://github.com/ArkScript-lang/Ark ArkScript GitHub]. + +===License=== +ArkScript is released under the Mozilla Public License 2.0. + +===Todo=== +[[Tasks not implemented in ArkScript]] \ No newline at end of file diff --git a/Lang/ArkScript/00-META.yaml b/Lang/ArkScript/00-META.yaml new file mode 100644 index 0000000000..0a989734f8 --- /dev/null +++ b/Lang/ArkScript/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:ArkScript diff --git a/Lang/ArkScript/100-doors b/Lang/ArkScript/100-doors new file mode 120000 index 0000000000..733c5ecdec --- /dev/null +++ b/Lang/ArkScript/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/99-bottles-of-beer b/Lang/ArkScript/99-bottles-of-beer new file mode 120000 index 0000000000..44d94215f1 --- /dev/null +++ b/Lang/ArkScript/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/A+B b/Lang/ArkScript/A+B new file mode 120000 index 0000000000..482decfa5a --- /dev/null +++ b/Lang/ArkScript/A+B @@ -0,0 +1 @@ +../../Task/A+B/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Abbreviations-easy b/Lang/ArkScript/Abbreviations-easy new file mode 120000 index 0000000000..03457b23d1 --- /dev/null +++ b/Lang/ArkScript/Abbreviations-easy @@ -0,0 +1 @@ +../../Task/Abbreviations-easy/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Ackermann-function b/Lang/ArkScript/Ackermann-function new file mode 120000 index 0000000000..f1f525fde6 --- /dev/null +++ b/Lang/ArkScript/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Apply-a-callback-to-an-array b/Lang/ArkScript/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..da474aa4d7 --- /dev/null +++ b/Lang/ArkScript/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Arithmetic-Complex b/Lang/ArkScript/Arithmetic-Complex new file mode 120000 index 0000000000..c21a1d5bf8 --- /dev/null +++ b/Lang/ArkScript/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Arithmetic-Integer b/Lang/ArkScript/Arithmetic-Integer new file mode 120000 index 0000000000..0023796f90 --- /dev/null +++ b/Lang/ArkScript/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Array-concatenation b/Lang/ArkScript/Array-concatenation new file mode 120000 index 0000000000..250e35894f --- /dev/null +++ b/Lang/ArkScript/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Array-length b/Lang/ArkScript/Array-length new file mode 120000 index 0000000000..f70d67437b --- /dev/null +++ b/Lang/ArkScript/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Ascending-primes b/Lang/ArkScript/Ascending-primes new file mode 120000 index 0000000000..9fc34de6f6 --- /dev/null +++ b/Lang/ArkScript/Ascending-primes @@ -0,0 +1 @@ +../../Task/Ascending-primes/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Associative-array-Creation b/Lang/ArkScript/Associative-array-Creation new file mode 120000 index 0000000000..2a5f3a1e53 --- /dev/null +++ b/Lang/ArkScript/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Associative-array-Iteration b/Lang/ArkScript/Associative-array-Iteration new file mode 120000 index 0000000000..f11b39f9bb --- /dev/null +++ b/Lang/ArkScript/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Balanced-brackets b/Lang/ArkScript/Balanced-brackets new file mode 120000 index 0000000000..7380d4a234 --- /dev/null +++ b/Lang/ArkScript/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Boolean-values b/Lang/ArkScript/Boolean-values new file mode 120000 index 0000000000..5efbe13431 --- /dev/null +++ b/Lang/ArkScript/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Calculating-the-value-of-e b/Lang/ArkScript/Calculating-the-value-of-e new file mode 120000 index 0000000000..0a0116531f --- /dev/null +++ b/Lang/ArkScript/Calculating-the-value-of-e @@ -0,0 +1 @@ +../../Task/Calculating-the-value-of-e/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Call-a-function b/Lang/ArkScript/Call-a-function new file mode 120000 index 0000000000..4d2870d9cb --- /dev/null +++ b/Lang/ArkScript/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Call-an-object-method b/Lang/ArkScript/Call-an-object-method new file mode 120000 index 0000000000..9b53aa0595 --- /dev/null +++ b/Lang/ArkScript/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Catamorphism b/Lang/ArkScript/Catamorphism new file mode 120000 index 0000000000..f6210b0ec4 --- /dev/null +++ b/Lang/ArkScript/Catamorphism @@ -0,0 +1 @@ +../../Task/Catamorphism/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Check-that-file-exists b/Lang/ArkScript/Check-that-file-exists new file mode 120000 index 0000000000..7e3651c090 --- /dev/null +++ b/Lang/ArkScript/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Closures-Value-capture b/Lang/ArkScript/Closures-Value-capture new file mode 120000 index 0000000000..6b30a8d976 --- /dev/null +++ b/Lang/ArkScript/Closures-Value-capture @@ -0,0 +1 @@ +../../Task/Closures-Value-capture/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Comments b/Lang/ArkScript/Comments new file mode 120000 index 0000000000..360a2acb05 --- /dev/null +++ b/Lang/ArkScript/Comments @@ -0,0 +1 @@ +../../Task/Comments/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Compound-data-type b/Lang/ArkScript/Compound-data-type new file mode 120000 index 0000000000..a901531424 --- /dev/null +++ b/Lang/ArkScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Concurrent-computing b/Lang/ArkScript/Concurrent-computing new file mode 120000 index 0000000000..13a2e9c874 --- /dev/null +++ b/Lang/ArkScript/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Conditional-structures b/Lang/ArkScript/Conditional-structures new file mode 120000 index 0000000000..10a922af53 --- /dev/null +++ b/Lang/ArkScript/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Conways-Game-of-Life b/Lang/ArkScript/Conways-Game-of-Life new file mode 120000 index 0000000000..2d495d7699 --- /dev/null +++ b/Lang/ArkScript/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Copy-a-string b/Lang/ArkScript/Copy-a-string new file mode 120000 index 0000000000..88194e46fb --- /dev/null +++ b/Lang/ArkScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Currying b/Lang/ArkScript/Currying new file mode 120000 index 0000000000..68a7b93b42 --- /dev/null +++ b/Lang/ArkScript/Currying @@ -0,0 +1 @@ +../../Task/Currying/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Delete-a-file b/Lang/ArkScript/Delete-a-file new file mode 120000 index 0000000000..d6dbc3ecd5 --- /dev/null +++ b/Lang/ArkScript/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-directory b/Lang/ArkScript/Empty-directory new file mode 120000 index 0000000000..5ade8a3b8b --- /dev/null +++ b/Lang/ArkScript/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-program b/Lang/ArkScript/Empty-program new file mode 120000 index 0000000000..d33db3e33c --- /dev/null +++ b/Lang/ArkScript/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Empty-string b/Lang/ArkScript/Empty-string new file mode 120000 index 0000000000..aa29f38546 --- /dev/null +++ b/Lang/ArkScript/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Enforced-immutability b/Lang/ArkScript/Enforced-immutability new file mode 120000 index 0000000000..c12069d86c --- /dev/null +++ b/Lang/ArkScript/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Even-or-odd b/Lang/ArkScript/Even-or-odd new file mode 120000 index 0000000000..7aee966d84 --- /dev/null +++ b/Lang/ArkScript/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Extend-your-language b/Lang/ArkScript/Extend-your-language new file mode 120000 index 0000000000..08fabf671d --- /dev/null +++ b/Lang/ArkScript/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Fibonacci-sequence b/Lang/ArkScript/Fibonacci-sequence new file mode 120000 index 0000000000..46f2bbba10 --- /dev/null +++ b/Lang/ArkScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/FizzBuzz b/Lang/ArkScript/FizzBuzz new file mode 120000 index 0000000000..2464c5dcce --- /dev/null +++ b/Lang/ArkScript/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Flatten-a-list b/Lang/ArkScript/Flatten-a-list new file mode 120000 index 0000000000..8540eceb42 --- /dev/null +++ b/Lang/ArkScript/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Function-definition b/Lang/ArkScript/Function-definition new file mode 120000 index 0000000000..e750f72eaf --- /dev/null +++ b/Lang/ArkScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Line-printer b/Lang/ArkScript/Hello-world-Line-printer new file mode 120000 index 0000000000..205cc44ef5 --- /dev/null +++ b/Lang/ArkScript/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Newline-omission b/Lang/ArkScript/Hello-world-Newline-omission new file mode 120000 index 0000000000..e70990b485 --- /dev/null +++ b/Lang/ArkScript/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Hello-world-Text b/Lang/ArkScript/Hello-world-Text new file mode 120000 index 0000000000..efe7845aa7 --- /dev/null +++ b/Lang/ArkScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Infinity b/Lang/ArkScript/Infinity new file mode 120000 index 0000000000..e2ef2bf985 --- /dev/null +++ b/Lang/ArkScript/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Integer-sequence b/Lang/ArkScript/Integer-sequence new file mode 120000 index 0000000000..386017d017 --- /dev/null +++ b/Lang/ArkScript/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-Floating-point b/Lang/ArkScript/Literals-Floating-point new file mode 120000 index 0000000000..5bc172fabe --- /dev/null +++ b/Lang/ArkScript/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-Integer b/Lang/ArkScript/Literals-Integer new file mode 120000 index 0000000000..b313b7f803 --- /dev/null +++ b/Lang/ArkScript/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Literals-String b/Lang/ArkScript/Literals-String new file mode 120000 index 0000000000..ec507deee1 --- /dev/null +++ b/Lang/ArkScript/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Logical-operations b/Lang/ArkScript/Logical-operations new file mode 120000 index 0000000000..aaefe48457 --- /dev/null +++ b/Lang/ArkScript/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Munchausen-numbers b/Lang/ArkScript/Munchausen-numbers new file mode 120000 index 0000000000..c351968c20 --- /dev/null +++ b/Lang/ArkScript/Munchausen-numbers @@ -0,0 +1 @@ +../../Task/Munchausen-numbers/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/N-queens-problem b/Lang/ArkScript/N-queens-problem new file mode 120000 index 0000000000..e917f9e593 --- /dev/null +++ b/Lang/ArkScript/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Null-object b/Lang/ArkScript/Null-object new file mode 120000 index 0000000000..a698a2ff71 --- /dev/null +++ b/Lang/ArkScript/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Program-termination b/Lang/ArkScript/Program-termination new file mode 120000 index 0000000000..19d9d120f6 --- /dev/null +++ b/Lang/ArkScript/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Read-entire-file b/Lang/ArkScript/Read-entire-file new file mode 120000 index 0000000000..e3a1c22530 --- /dev/null +++ b/Lang/ArkScript/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Reverse-a-string b/Lang/ArkScript/Reverse-a-string new file mode 120000 index 0000000000..a3a2ea0c27 --- /dev/null +++ b/Lang/ArkScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Semordnilap b/Lang/ArkScript/Semordnilap new file mode 120000 index 0000000000..25df93d2d3 --- /dev/null +++ b/Lang/ArkScript/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Shell-one-liner b/Lang/ArkScript/Shell-one-liner new file mode 120000 index 0000000000..889b436427 --- /dev/null +++ b/Lang/ArkScript/Shell-one-liner @@ -0,0 +1 @@ +../../Task/Shell-one-liner/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Short-circuit-evaluation b/Lang/ArkScript/Short-circuit-evaluation new file mode 120000 index 0000000000..dcd4ac26ee --- /dev/null +++ b/Lang/ArkScript/Short-circuit-evaluation @@ -0,0 +1 @@ +../../Task/Short-circuit-evaluation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Show-ASCII-table b/Lang/ArkScript/Show-ASCII-table new file mode 120000 index 0000000000..65d6365487 --- /dev/null +++ b/Lang/ArkScript/Show-ASCII-table @@ -0,0 +1 @@ +../../Task/Show-ASCII-table/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sleep b/Lang/ArkScript/Sleep new file mode 120000 index 0000000000..cd07cddf41 --- /dev/null +++ b/Lang/ArkScript/Sleep @@ -0,0 +1 @@ +../../Task/Sleep/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sorting-algorithms-Quicksort b/Lang/ArkScript/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..003f3fb633 --- /dev/null +++ b/Lang/ArkScript/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-append b/Lang/ArkScript/String-append new file mode 120000 index 0000000000..ade5a20d23 --- /dev/null +++ b/Lang/ArkScript/String-append @@ -0,0 +1 @@ +../../Task/String-append/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-case b/Lang/ArkScript/String-case new file mode 120000 index 0000000000..25e27a4618 --- /dev/null +++ b/Lang/ArkScript/String-case @@ -0,0 +1 @@ +../../Task/String-case/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-concatenation b/Lang/ArkScript/String-concatenation new file mode 120000 index 0000000000..999b5605f7 --- /dev/null +++ b/Lang/ArkScript/String-concatenation @@ -0,0 +1 @@ +../../Task/String-concatenation/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-interpolation-included- b/Lang/ArkScript/String-interpolation-included- new file mode 120000 index 0000000000..33fa86b906 --- /dev/null +++ b/Lang/ArkScript/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-length b/Lang/ArkScript/String-length new file mode 120000 index 0000000000..df129dcc11 --- /dev/null +++ b/Lang/ArkScript/String-length @@ -0,0 +1 @@ +../../Task/String-length/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-matching b/Lang/ArkScript/String-matching new file mode 120000 index 0000000000..7558bd042a --- /dev/null +++ b/Lang/ArkScript/String-matching @@ -0,0 +1 @@ +../../Task/String-matching/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/String-prepend b/Lang/ArkScript/String-prepend new file mode 120000 index 0000000000..083b99bbf0 --- /dev/null +++ b/Lang/ArkScript/String-prepend @@ -0,0 +1 @@ +../../Task/String-prepend/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-and-product-of-an-array b/Lang/ArkScript/Sum-and-product-of-an-array new file mode 120000 index 0000000000..4c22ecff5f --- /dev/null +++ b/Lang/ArkScript/Sum-and-product-of-an-array @@ -0,0 +1 @@ +../../Task/Sum-and-product-of-an-array/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-digits-of-an-integer b/Lang/ArkScript/Sum-digits-of-an-integer new file mode 120000 index 0000000000..29e7afd56c --- /dev/null +++ b/Lang/ArkScript/Sum-digits-of-an-integer @@ -0,0 +1 @@ +../../Task/Sum-digits-of-an-integer/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-of-a-series b/Lang/ArkScript/Sum-of-a-series new file mode 120000 index 0000000000..f009df3580 --- /dev/null +++ b/Lang/ArkScript/Sum-of-a-series @@ -0,0 +1 @@ +../../Task/Sum-of-a-series/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Sum-of-squares b/Lang/ArkScript/Sum-of-squares new file mode 120000 index 0000000000..85176ac4bb --- /dev/null +++ b/Lang/ArkScript/Sum-of-squares @@ -0,0 +1 @@ +../../Task/Sum-of-squares/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/User-input-Text b/Lang/ArkScript/User-input-Text new file mode 120000 index 0000000000..f0daf24108 --- /dev/null +++ b/Lang/ArkScript/User-input-Text @@ -0,0 +1 @@ +../../Task/User-input-Text/ArkScript \ No newline at end of file diff --git a/Lang/ArkScript/Write-entire-file b/Lang/ArkScript/Write-entire-file new file mode 120000 index 0000000000..978c98fba7 --- /dev/null +++ b/Lang/ArkScript/Write-entire-file @@ -0,0 +1 @@ +../../Task/Write-entire-file/ArkScript \ No newline at end of file diff --git a/Lang/AutoLISP/100-doors b/Lang/AutoLISP/100-doors new file mode 120000 index 0000000000..4d97a8a5d6 --- /dev/null +++ b/Lang/AutoLISP/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Babbage-problem b/Lang/AutoLISP/Babbage-problem new file mode 120000 index 0000000000..0ae3941c82 --- /dev/null +++ b/Lang/AutoLISP/Babbage-problem @@ -0,0 +1 @@ +../../Task/Babbage-problem/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Balanced-brackets b/Lang/AutoLISP/Balanced-brackets new file mode 120000 index 0000000000..b752cfc1d6 --- /dev/null +++ b/Lang/AutoLISP/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Entropy b/Lang/AutoLISP/Entropy new file mode 120000 index 0000000000..bc1dec235f --- /dev/null +++ b/Lang/AutoLISP/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Entropy-Narcissist b/Lang/AutoLISP/Entropy-Narcissist new file mode 120000 index 0000000000..0a143c87ce --- /dev/null +++ b/Lang/AutoLISP/Entropy-Narcissist @@ -0,0 +1 @@ +../../Task/Entropy-Narcissist/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/Largest-proper-divisor-of-n b/Lang/AutoLISP/Largest-proper-divisor-of-n new file mode 120000 index 0000000000..48c08fae1a --- /dev/null +++ b/Lang/AutoLISP/Largest-proper-divisor-of-n @@ -0,0 +1 @@ +../../Task/Largest-proper-divisor-of-n/AutoLISP \ No newline at end of file diff --git a/Lang/AutoLISP/The-Twelve-Days-of-Christmas b/Lang/AutoLISP/The-Twelve-Days-of-Christmas new file mode 120000 index 0000000000..3dd7563b0d --- /dev/null +++ b/Lang/AutoLISP/The-Twelve-Days-of-Christmas @@ -0,0 +1 @@ +../../Task/The-Twelve-Days-of-Christmas/AutoLISP \ No newline at end of file diff --git a/Lang/BBC-BASIC/Arbitrary-precision-integers-included- b/Lang/BBC-BASIC/Arbitrary-precision-integers-included- new file mode 120000 index 0000000000..ca18adffdc --- /dev/null +++ b/Lang/BBC-BASIC/Arbitrary-precision-integers-included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included-/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multi-dimensional-array b/Lang/BBC-BASIC/Multi-dimensional-array new file mode 120000 index 0000000000..4bc7c4a17c --- /dev/null +++ b/Lang/BBC-BASIC/Multi-dimensional-array @@ -0,0 +1 @@ +../../Task/Multi-dimensional-array/BBC-BASIC \ No newline at end of file diff --git a/Lang/Ballerina/Comments b/Lang/Ballerina/Comments new file mode 120000 index 0000000000..6b5d53ddee --- /dev/null +++ b/Lang/Ballerina/Comments @@ -0,0 +1 @@ +../../Task/Comments/Ballerina \ No newline at end of file diff --git a/Lang/Bc/Anti-primes b/Lang/Bc/Anti-primes new file mode 120000 index 0000000000..3d900bc4e9 --- /dev/null +++ b/Lang/Bc/Anti-primes @@ -0,0 +1 @@ +../../Task/Anti-primes/Bc \ No newline at end of file diff --git a/Lang/Bc/Arithmetic-derivative b/Lang/Bc/Arithmetic-derivative new file mode 120000 index 0000000000..3ff888839e --- /dev/null +++ b/Lang/Bc/Arithmetic-derivative @@ -0,0 +1 @@ +../../Task/Arithmetic-derivative/Bc \ No newline at end of file diff --git a/Lang/Bc/Department-numbers b/Lang/Bc/Department-numbers new file mode 120000 index 0000000000..0e2c9bd91f --- /dev/null +++ b/Lang/Bc/Department-numbers @@ -0,0 +1 @@ +../../Task/Department-numbers/Bc \ No newline at end of file diff --git a/Lang/Bc/Fairshare-between-two-and-more b/Lang/Bc/Fairshare-between-two-and-more new file mode 120000 index 0000000000..f5c1a3523e --- /dev/null +++ b/Lang/Bc/Fairshare-between-two-and-more @@ -0,0 +1 @@ +../../Task/Fairshare-between-two-and-more/Bc \ No newline at end of file diff --git a/Lang/Bc/Variables b/Lang/Bc/Variables new file mode 120000 index 0000000000..03f47bea63 --- /dev/null +++ b/Lang/Bc/Variables @@ -0,0 +1 @@ +../../Task/Variables/Bc \ No newline at end of file diff --git a/Lang/Beeswax/00-LANG.txt b/Lang/Beeswax/00-LANG.txt index bea56d7b6b..c131bf7731 100644 --- a/Lang/Beeswax/00-LANG.txt +++ b/Lang/Beeswax/00-LANG.txt @@ -25,7 +25,7 @@ All data in the local and global stacks are unsigned 64-bit integers, output as == More information == -* [[eso:Beeswax|Esoteric languages wiki entry]] +* [http://esolangs.org/wiki/beeswax Esoteric languages wiki entry] == Reference implementation, example programs and complete language specification == diff --git a/Lang/C-sharp/Camel-case-and-snake-case b/Lang/C-sharp/Camel-case-and-snake-case new file mode 120000 index 0000000000..0b673ec8ed --- /dev/null +++ b/Lang/C-sharp/Camel-case-and-snake-case @@ -0,0 +1 @@ +../../Task/Camel-case-and-snake-case/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Cistercian-numerals b/Lang/C-sharp/Cistercian-numerals new file mode 120000 index 0000000000..d482ff0533 --- /dev/null +++ b/Lang/C-sharp/Cistercian-numerals @@ -0,0 +1 @@ +../../Task/Cistercian-numerals/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/M-bius-function b/Lang/C-sharp/M-bius-function new file mode 120000 index 0000000000..56f84fb14c --- /dev/null +++ b/Lang/C-sharp/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Vogels-approximation-method b/Lang/C-sharp/Vogels-approximation-method new file mode 120000 index 0000000000..bb638d067a --- /dev/null +++ b/Lang/C-sharp/Vogels-approximation-method @@ -0,0 +1 @@ +../../Task/Vogels-approximation-method/C-sharp \ No newline at end of file diff --git a/Lang/CBASIC/Factorial b/Lang/CBASIC/Factorial new file mode 120000 index 0000000000..97dfd0b137 --- /dev/null +++ b/Lang/CBASIC/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/CBASIC \ No newline at end of file diff --git a/Lang/CJam/00-LANG.txt b/Lang/CJam/00-LANG.txt new file mode 100644 index 0000000000..9d6f8331dc --- /dev/null +++ b/Lang/CJam/00-LANG.txt @@ -0,0 +1,8 @@ +{{language|site=https://sourceforge.net/p/cjam/wiki/Home/}} + +[https://sourceforge.net/projects/cjam/ sf repo] + +From the [https://sourceforge.net/p/cjam/wiki/Home/ wiki]: + +:In order to run a CJam program, [https://sourceforge.net/projects/cjam/files/ download] the latest jar file, e.g. cjam-0.6.5.jar, and run this command: +:
java -jar cjam-0.6.5.jar file.cjam
\ No newline at end of file diff --git a/Lang/CJam/00-META.yaml b/Lang/CJam/00-META.yaml new file mode 100644 index 0000000000..49b8d01361 --- /dev/null +++ b/Lang/CJam/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:CJam diff --git a/Lang/COBOL/Soloways-recurring-rainfall b/Lang/COBOL/Soloways-recurring-rainfall new file mode 120000 index 0000000000..883bf3b2e0 --- /dev/null +++ b/Lang/COBOL/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/COBOL \ No newline at end of file diff --git a/Lang/Calcscript/00-LANG.txt b/Lang/Calcscript/00-LANG.txt new file mode 100644 index 0000000000..d2db819bbe --- /dev/null +++ b/Lang/Calcscript/00-LANG.txt @@ -0,0 +1,10 @@ +{{language +|site=https://gitee.com/jfiewo/calc/ +}} +Calcscript is a small lisp-like language. +* It has 3 datatypes: Int, Same, and Invalid. +* The usual 4 arithmetic operations are supported. + +See [https://gitee.com/jfiewo/calc/ the respository] for details. +{{language programming paradigm|Logic Programming}} +{{language programming paradigm|Functional}} \ No newline at end of file diff --git a/Lang/Calcscript/00-META.yaml b/Lang/Calcscript/00-META.yaml new file mode 100644 index 0000000000..cee9fc468f --- /dev/null +++ b/Lang/Calcscript/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Calcscript diff --git a/Lang/Common-Lisp/Wieferich-primes b/Lang/Common-Lisp/Wieferich-primes new file mode 120000 index 0000000000..91ad6e3ba2 --- /dev/null +++ b/Lang/Common-Lisp/Wieferich-primes @@ -0,0 +1 @@ +../../Task/Wieferich-primes/Common-Lisp \ No newline at end of file diff --git a/Lang/Component-Pascal/100-doors b/Lang/Component-Pascal/100-doors deleted file mode 120000 index 76b023254e..0000000000 --- a/Lang/Component-Pascal/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/Component-Pascal \ No newline at end of file diff --git a/Lang/Computer-zero-Assembly/00-LANG.txt b/Lang/Computer-zero-Assembly/00-LANG.txt index e6ea975211..779b92356f 100644 --- a/Lang/Computer-zero-Assembly/00-LANG.txt +++ b/Lang/Computer-zero-Assembly/00-LANG.txt @@ -19,10 +19,10 @@ There are only 32 bytes of memory, and this includes your program code, leaving ==Self-Modifying Code== With such little RAM available, the biggest tool we have at our disposal for programming is self-modifying code. The CPU makes no distinction between data and instructions, and as such we can store values into memory before that memory is executed, in order to change what the computer will do. Here's an example: -LDA 4 +LDA 4 STA 2 ADD 3 STP -SUB 3 +SUB 3 The above snippet of code never actually ADDs anything, since that instruction gets overwritten by SUB 3. And what is SUB 3 subtracting? It's subtracting the value of STP, which can be encoded as any number between 0xE0 and 0xFF. Specifically, the encoding of SUB 3 (i.e. 0b10000011) is decreased by some value between 0xE0 and 0xFF, and since all arithmetic on this CPU is modulo 256 (as is standard for nearly all 8-bit CPUs), there will be roll-over across the FF-00 boundary. Without a hardware carry flag, however, it's difficult to track this overflow. \ No newline at end of file diff --git a/Lang/Convex/00-LANG.txt b/Lang/Convex/00-LANG.txt new file mode 100644 index 0000000000..6676f23dde --- /dev/null +++ b/Lang/Convex/00-LANG.txt @@ -0,0 +1,6 @@ +Convex is a stack-based golfing esolang based on Golfscript and CJam. + +{{language|site=https://github.com/ZekNikZ/Convex}} + +{{try|Convex|[https://tio.run/#convex Try Convex on tio.run].}} +{{language_programming_paradigm|Concatenative}} \ No newline at end of file diff --git a/Lang/Convex/00-META.yaml b/Lang/Convex/00-META.yaml new file mode 100644 index 0000000000..b10fffa83e --- /dev/null +++ b/Lang/Convex/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Convex diff --git a/Lang/Crystal/Department-numbers b/Lang/Crystal/Department-numbers new file mode 120000 index 0000000000..1e36b398e9 --- /dev/null +++ b/Lang/Crystal/Department-numbers @@ -0,0 +1 @@ +../../Task/Department-numbers/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Parsing-RPN-calculator-algorithm b/Lang/Crystal/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..79e0e2ae7e --- /dev/null +++ b/Lang/Crystal/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Rot-13 b/Lang/Crystal/Rot-13 new file mode 120000 index 0000000000..430011bd06 --- /dev/null +++ b/Lang/Crystal/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Singly-linked-list-Element-definition b/Lang/Crystal/Singly-linked-list-Element-definition new file mode 120000 index 0000000000..1c9a4e215c --- /dev/null +++ b/Lang/Crystal/Singly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-definition/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Singly-linked-list-Element-insertion b/Lang/Crystal/Singly-linked-list-Element-insertion new file mode 120000 index 0000000000..e0de17b549 --- /dev/null +++ b/Lang/Crystal/Singly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-insertion/Crystal \ No newline at end of file diff --git a/Lang/Crystal/Soloways-recurring-rainfall b/Lang/Crystal/Soloways-recurring-rainfall new file mode 120000 index 0000000000..017187c230 --- /dev/null +++ b/Lang/Crystal/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/Crystal \ No newline at end of file diff --git a/Lang/Crystal/String-interpolation-included- b/Lang/Crystal/String-interpolation-included- new file mode 120000 index 0000000000..05bff0aabd --- /dev/null +++ b/Lang/Crystal/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/Crystal \ No newline at end of file diff --git a/Lang/Dart/AVL-tree b/Lang/Dart/AVL-tree new file mode 120000 index 0000000000..00bc5f9c2f --- /dev/null +++ b/Lang/Dart/AVL-tree @@ -0,0 +1 @@ +../../Task/AVL-tree/Dart \ No newline at end of file diff --git a/Lang/Dart/Boyer-Moore-string-search b/Lang/Dart/Boyer-Moore-string-search new file mode 120000 index 0000000000..8b8a6a6060 --- /dev/null +++ b/Lang/Dart/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/Dart \ No newline at end of file diff --git a/Lang/Dart/Break-OO-privacy b/Lang/Dart/Break-OO-privacy new file mode 120000 index 0000000000..e07e79a6ca --- /dev/null +++ b/Lang/Dart/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Dart \ No newline at end of file diff --git a/Lang/Dart/Continued-fraction b/Lang/Dart/Continued-fraction new file mode 120000 index 0000000000..ea5b665958 --- /dev/null +++ b/Lang/Dart/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Dart \ No newline at end of file diff --git a/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..eb55960eb5 --- /dev/null +++ b/Lang/Dart/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Dart \ No newline at end of file diff --git a/Lang/Dart/Dijkstras-algorithm b/Lang/Dart/Dijkstras-algorithm new file mode 120000 index 0000000000..fc7b73a06b --- /dev/null +++ b/Lang/Dart/Dijkstras-algorithm @@ -0,0 +1 @@ +../../Task/Dijkstras-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Floyd-Warshall-algorithm b/Lang/Dart/Floyd-Warshall-algorithm new file mode 120000 index 0000000000..34dc98809b --- /dev/null +++ b/Lang/Dart/Floyd-Warshall-algorithm @@ -0,0 +1 @@ +../../Task/Floyd-Warshall-algorithm/Dart \ No newline at end of file diff --git a/Lang/Dart/Parse-an-IP-Address b/Lang/Dart/Parse-an-IP-Address new file mode 120000 index 0000000000..bbe41020cb --- /dev/null +++ b/Lang/Dart/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Dart \ No newline at end of file diff --git a/Lang/Dart/Tonelli-Shanks-algorithm b/Lang/Dart/Tonelli-Shanks-algorithm new file mode 120000 index 0000000000..72acd046bd --- /dev/null +++ b/Lang/Dart/Tonelli-Shanks-algorithm @@ -0,0 +1 @@ +../../Task/Tonelli-Shanks-algorithm/Dart \ No newline at end of file diff --git a/Lang/Draco/Anti-primes b/Lang/Draco/Anti-primes new file mode 120000 index 0000000000..e9ba464537 --- /dev/null +++ b/Lang/Draco/Anti-primes @@ -0,0 +1 @@ +../../Task/Anti-primes/Draco \ No newline at end of file diff --git a/Lang/DuckDB/00-LANG.txt b/Lang/DuckDB/00-LANG.txt new file mode 100644 index 0000000000..2609130966 --- /dev/null +++ b/Lang/DuckDB/00-LANG.txt @@ -0,0 +1,4 @@ +[[DuckDB]] is an open-source, fast in-process analytical database management system based on a feature-rich SQL dialect complemented with deep integrations into client APIs. + +[[Category:Programming Languages]] +[[Category:SQL]] \ No newline at end of file diff --git a/Lang/DuckDB/00-META.yaml b/Lang/DuckDB/00-META.yaml new file mode 100644 index 0000000000..c9eafe7cf5 --- /dev/null +++ b/Lang/DuckDB/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:DuckDB diff --git a/Lang/DuckDB/100-doors b/Lang/DuckDB/100-doors new file mode 120000 index 0000000000..a0ee1f337e --- /dev/null +++ b/Lang/DuckDB/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/99-bottles-of-beer b/Lang/DuckDB/99-bottles-of-beer new file mode 120000 index 0000000000..c5f15cd273 --- /dev/null +++ b/Lang/DuckDB/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/A+B b/Lang/DuckDB/A+B new file mode 120000 index 0000000000..ae6220876f --- /dev/null +++ b/Lang/DuckDB/A+B @@ -0,0 +1 @@ +../../Task/A+B/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/ABC-problem b/Lang/DuckDB/ABC-problem new file mode 120000 index 0000000000..36e60dd0cd --- /dev/null +++ b/Lang/DuckDB/ABC-problem @@ -0,0 +1 @@ +../../Task/ABC-problem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Anagrams b/Lang/DuckDB/Anagrams new file mode 120000 index 0000000000..e80c01b2e3 --- /dev/null +++ b/Lang/DuckDB/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Anonymous-recursion b/Lang/DuckDB/Anonymous-recursion new file mode 120000 index 0000000000..e4448d2542 --- /dev/null +++ b/Lang/DuckDB/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-Complex b/Lang/DuckDB/Arithmetic-Complex new file mode 120000 index 0000000000..7e149e59dc --- /dev/null +++ b/Lang/DuckDB/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-Integer b/Lang/DuckDB/Arithmetic-Integer new file mode 120000 index 0000000000..5bc3696b71 --- /dev/null +++ b/Lang/DuckDB/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-geometric-mean b/Lang/DuckDB/Arithmetic-geometric-mean new file mode 120000 index 0000000000..2519d0a8f8 --- /dev/null +++ b/Lang/DuckDB/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arithmetic-numbers b/Lang/DuckDB/Arithmetic-numbers new file mode 120000 index 0000000000..a5e7e075b9 --- /dev/null +++ b/Lang/DuckDB/Arithmetic-numbers @@ -0,0 +1 @@ +../../Task/Arithmetic-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Array-concatenation b/Lang/DuckDB/Array-concatenation new file mode 120000 index 0000000000..7ef5be0b5a --- /dev/null +++ b/Lang/DuckDB/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Array-length b/Lang/DuckDB/Array-length new file mode 120000 index 0000000000..ebd59786ea --- /dev/null +++ b/Lang/DuckDB/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Arrays b/Lang/DuckDB/Arrays new file mode 120000 index 0000000000..85190ece0f --- /dev/null +++ b/Lang/DuckDB/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Creation b/Lang/DuckDB/Associative-array-Creation new file mode 120000 index 0000000000..ea2505f34f --- /dev/null +++ b/Lang/DuckDB/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Iteration b/Lang/DuckDB/Associative-array-Iteration new file mode 120000 index 0000000000..c8269906e9 --- /dev/null +++ b/Lang/DuckDB/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Associative-array-Merging b/Lang/DuckDB/Associative-array-Merging new file mode 120000 index 0000000000..4e70d9ab01 --- /dev/null +++ b/Lang/DuckDB/Associative-array-Merging @@ -0,0 +1 @@ +../../Task/Associative-array-Merging/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Arithmetic-mean b/Lang/DuckDB/Averages-Arithmetic-mean new file mode 120000 index 0000000000..7ef12ec4b6 --- /dev/null +++ b/Lang/DuckDB/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mean-angle b/Lang/DuckDB/Averages-Mean-angle new file mode 120000 index 0000000000..5b1aa18e5e --- /dev/null +++ b/Lang/DuckDB/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mean-time-of-day b/Lang/DuckDB/Averages-Mean-time-of-day new file mode 120000 index 0000000000..7971faf640 --- /dev/null +++ b/Lang/DuckDB/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Mode b/Lang/DuckDB/Averages-Mode new file mode 120000 index 0000000000..0ba388e74d --- /dev/null +++ b/Lang/DuckDB/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Averages-Pythagorean-means b/Lang/DuckDB/Averages-Pythagorean-means new file mode 120000 index 0000000000..1a5cb3068d --- /dev/null +++ b/Lang/DuckDB/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Babbage-problem b/Lang/DuckDB/Babbage-problem new file mode 120000 index 0000000000..7cee7b9a76 --- /dev/null +++ b/Lang/DuckDB/Babbage-problem @@ -0,0 +1 @@ +../../Task/Babbage-problem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Benfords-law b/Lang/DuckDB/Benfords-law new file mode 120000 index 0000000000..9302673cc0 --- /dev/null +++ b/Lang/DuckDB/Benfords-law @@ -0,0 +1 @@ +../../Task/Benfords-law/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bin-given-limits b/Lang/DuckDB/Bin-given-limits new file mode 120000 index 0000000000..ba754d6a93 --- /dev/null +++ b/Lang/DuckDB/Bin-given-limits @@ -0,0 +1 @@ +../../Task/Bin-given-limits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Binary-digits b/Lang/DuckDB/Binary-digits new file mode 120000 index 0000000000..c4e4b4a580 --- /dev/null +++ b/Lang/DuckDB/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bioinformatics-base-count b/Lang/DuckDB/Bioinformatics-base-count new file mode 120000 index 0000000000..6f72a9bb3a --- /dev/null +++ b/Lang/DuckDB/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bitwise-IO b/Lang/DuckDB/Bitwise-IO new file mode 120000 index 0000000000..d00e607776 --- /dev/null +++ b/Lang/DuckDB/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Bitwise-operations b/Lang/DuckDB/Bitwise-operations new file mode 120000 index 0000000000..a0841908e6 --- /dev/null +++ b/Lang/DuckDB/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/CSV-data-manipulation b/Lang/DuckDB/CSV-data-manipulation new file mode 120000 index 0000000000..799ed97795 --- /dev/null +++ b/Lang/DuckDB/CSV-data-manipulation @@ -0,0 +1 @@ +../../Task/CSV-data-manipulation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Call-a-function b/Lang/DuckDB/Call-a-function new file mode 120000 index 0000000000..bf87fb6ba8 --- /dev/null +++ b/Lang/DuckDB/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Cartesian-product-of-two-or-more-lists b/Lang/DuckDB/Cartesian-product-of-two-or-more-lists new file mode 120000 index 0000000000..f0873100b0 --- /dev/null +++ b/Lang/DuckDB/Cartesian-product-of-two-or-more-lists @@ -0,0 +1 @@ +../../Task/Cartesian-product-of-two-or-more-lists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Case-sensitivity-of-identifiers b/Lang/DuckDB/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..2a0900e2e4 --- /dev/null +++ b/Lang/DuckDB/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Catalan-numbers b/Lang/DuckDB/Catalan-numbers new file mode 120000 index 0000000000..5591f12e62 --- /dev/null +++ b/Lang/DuckDB/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Catalan-numbers-Pascals-triangle b/Lang/DuckDB/Catalan-numbers-Pascals-triangle new file mode 120000 index 0000000000..690dec4614 --- /dev/null +++ b/Lang/DuckDB/Catalan-numbers-Pascals-triangle @@ -0,0 +1 @@ +../../Task/Catalan-numbers-Pascals-triangle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Check-that-file-exists b/Lang/DuckDB/Check-that-file-exists new file mode 120000 index 0000000000..7a35121080 --- /dev/null +++ b/Lang/DuckDB/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Collections b/Lang/DuckDB/Collections new file mode 120000 index 0000000000..4bd2b4f60a --- /dev/null +++ b/Lang/DuckDB/Collections @@ -0,0 +1 @@ +../../Task/Collections/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Combinations b/Lang/DuckDB/Combinations new file mode 120000 index 0000000000..61cb39c1bb --- /dev/null +++ b/Lang/DuckDB/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Combinations-with-repetitions b/Lang/DuckDB/Combinations-with-repetitions new file mode 120000 index 0000000000..3781b1dd53 --- /dev/null +++ b/Lang/DuckDB/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compare-a-list-of-strings b/Lang/DuckDB/Compare-a-list-of-strings new file mode 120000 index 0000000000..dcf4a9dc8d --- /dev/null +++ b/Lang/DuckDB/Compare-a-list-of-strings @@ -0,0 +1 @@ +../../Task/Compare-a-list-of-strings/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compare-length-of-two-strings b/Lang/DuckDB/Compare-length-of-two-strings new file mode 120000 index 0000000000..b29bfdb369 --- /dev/null +++ b/Lang/DuckDB/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Compound-data-type b/Lang/DuckDB/Compound-data-type new file mode 120000 index 0000000000..dc469b307b --- /dev/null +++ b/Lang/DuckDB/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Conditional-structures b/Lang/DuckDB/Conditional-structures new file mode 120000 index 0000000000..19bf4a5caa --- /dev/null +++ b/Lang/DuckDB/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Convert-seconds-to-compound-duration b/Lang/DuckDB/Convert-seconds-to-compound-duration new file mode 120000 index 0000000000..44055a0c42 --- /dev/null +++ b/Lang/DuckDB/Convert-seconds-to-compound-duration @@ -0,0 +1 @@ +../../Task/Convert-seconds-to-compound-duration/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Copy-a-string b/Lang/DuckDB/Copy-a-string new file mode 120000 index 0000000000..d5f908f98d --- /dev/null +++ b/Lang/DuckDB/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Count-occurrences-of-a-substring b/Lang/DuckDB/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..82775de6e5 --- /dev/null +++ b/Lang/DuckDB/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime b/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..14657f9c21 --- /dev/null +++ b/Lang/DuckDB/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Cumulative-standard-deviation b/Lang/DuckDB/Cumulative-standard-deviation new file mode 120000 index 0000000000..f323d6c56e --- /dev/null +++ b/Lang/DuckDB/Cumulative-standard-deviation @@ -0,0 +1 @@ +../../Task/Cumulative-standard-deviation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Currency b/Lang/DuckDB/Currency new file mode 120000 index 0000000000..092e5fcb13 --- /dev/null +++ b/Lang/DuckDB/Currency @@ -0,0 +1 @@ +../../Task/Currency/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Day-of-the-week b/Lang/DuckDB/Day-of-the-week new file mode 120000 index 0000000000..467c28db17 --- /dev/null +++ b/Lang/DuckDB/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Define-a-primitive-data-type b/Lang/DuckDB/Define-a-primitive-data-type new file mode 120000 index 0000000000..f086397ed2 --- /dev/null +++ b/Lang/DuckDB/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Detect-division-by-zero b/Lang/DuckDB/Detect-division-by-zero new file mode 120000 index 0000000000..92508ad1dd --- /dev/null +++ b/Lang/DuckDB/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determinant-and-permanent b/Lang/DuckDB/Determinant-and-permanent new file mode 120000 index 0000000000..6bccec7e87 --- /dev/null +++ b/Lang/DuckDB/Determinant-and-permanent @@ -0,0 +1 @@ +../../Task/Determinant-and-permanent/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters b/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters new file mode 120000 index 0000000000..3a9bd20a7a --- /dev/null +++ b/Lang/DuckDB/Determine-if-a-string-has-all-the-same-characters @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-has-all-the-same-characters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters b/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters new file mode 120000 index 0000000000..64885aacf1 --- /dev/null +++ b/Lang/DuckDB/Determine-if-a-string-has-all-unique-characters @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-has-all-unique-characters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-collapsible b/Lang/DuckDB/Determine-if-a-string-is-collapsible new file mode 120000 index 0000000000..0bb2727b9c --- /dev/null +++ b/Lang/DuckDB/Determine-if-a-string-is-collapsible @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-collapsible/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-numeric b/Lang/DuckDB/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..ead16cd478 --- /dev/null +++ b/Lang/DuckDB/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-if-a-string-is-squeezable b/Lang/DuckDB/Determine-if-a-string-is-squeezable new file mode 120000 index 0000000000..57414557b7 --- /dev/null +++ b/Lang/DuckDB/Determine-if-a-string-is-squeezable @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-squeezable/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Determine-sentence-type b/Lang/DuckDB/Determine-sentence-type new file mode 120000 index 0000000000..50fb0aaf1b --- /dev/null +++ b/Lang/DuckDB/Determine-sentence-type @@ -0,0 +1 @@ +../../Task/Determine-sentence-type/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Digital-root b/Lang/DuckDB/Digital-root new file mode 120000 index 0000000000..736b8ccc4f --- /dev/null +++ b/Lang/DuckDB/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Diversity-prediction-theorem b/Lang/DuckDB/Diversity-prediction-theorem new file mode 120000 index 0000000000..2c04d6784a --- /dev/null +++ b/Lang/DuckDB/Diversity-prediction-theorem @@ -0,0 +1 @@ +../../Task/Diversity-prediction-theorem/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Documentation b/Lang/DuckDB/Documentation new file mode 120000 index 0000000000..f9f6aaf2ce --- /dev/null +++ b/Lang/DuckDB/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Dot-product b/Lang/DuckDB/Dot-product new file mode 120000 index 0000000000..b17f0214ea --- /dev/null +++ b/Lang/DuckDB/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Dynamic-variable-names b/Lang/DuckDB/Dynamic-variable-names new file mode 120000 index 0000000000..c534bbc61d --- /dev/null +++ b/Lang/DuckDB/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Element-wise-operations b/Lang/DuckDB/Element-wise-operations new file mode 120000 index 0000000000..7d7754f7f7 --- /dev/null +++ b/Lang/DuckDB/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Empty-string b/Lang/DuckDB/Empty-string new file mode 120000 index 0000000000..67b471da95 --- /dev/null +++ b/Lang/DuckDB/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Entropy b/Lang/DuckDB/Entropy new file mode 120000 index 0000000000..9c2bc0a9a7 --- /dev/null +++ b/Lang/DuckDB/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Enumerations b/Lang/DuckDB/Enumerations new file mode 120000 index 0000000000..0605dce25b --- /dev/null +++ b/Lang/DuckDB/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Equilibrium-index b/Lang/DuckDB/Equilibrium-index new file mode 120000 index 0000000000..40fbbe81bb --- /dev/null +++ b/Lang/DuckDB/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Euler-method b/Lang/DuckDB/Euler-method new file mode 120000 index 0000000000..61aa9557d0 --- /dev/null +++ b/Lang/DuckDB/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Eulers-constant-0.5772... b/Lang/DuckDB/Eulers-constant-0.5772... new file mode 120000 index 0000000000..c954937ec2 --- /dev/null +++ b/Lang/DuckDB/Eulers-constant-0.5772... @@ -0,0 +1 @@ +../../Task/Eulers-constant-0.5772.../DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Eulers-identity b/Lang/DuckDB/Eulers-identity new file mode 120000 index 0000000000..58919d8390 --- /dev/null +++ b/Lang/DuckDB/Eulers-identity @@ -0,0 +1 @@ +../../Task/Eulers-identity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Evaluate-binomial-coefficients b/Lang/DuckDB/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..69d838bb98 --- /dev/null +++ b/Lang/DuckDB/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Even-or-odd b/Lang/DuckDB/Even-or-odd new file mode 120000 index 0000000000..e428a57303 --- /dev/null +++ b/Lang/DuckDB/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Exponentiation-order b/Lang/DuckDB/Exponentiation-order new file mode 120000 index 0000000000..56438a22ee --- /dev/null +++ b/Lang/DuckDB/Exponentiation-order @@ -0,0 +1 @@ +../../Task/Exponentiation-order/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Extreme-floating-point-values b/Lang/DuckDB/Extreme-floating-point-values new file mode 120000 index 0000000000..617a7e99de --- /dev/null +++ b/Lang/DuckDB/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Factorial b/Lang/DuckDB/Factorial new file mode 120000 index 0000000000..24543aba0b --- /dev/null +++ b/Lang/DuckDB/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Factors-of-an-integer b/Lang/DuckDB/Factors-of-an-integer new file mode 120000 index 0000000000..70e5ed8d56 --- /dev/null +++ b/Lang/DuckDB/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fairshare-between-two-and-more b/Lang/DuckDB/Fairshare-between-two-and-more new file mode 120000 index 0000000000..0c62807925 --- /dev/null +++ b/Lang/DuckDB/Fairshare-between-two-and-more @@ -0,0 +1 @@ +../../Task/Fairshare-between-two-and-more/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Feigenbaum-constant-calculation b/Lang/DuckDB/Feigenbaum-constant-calculation new file mode 120000 index 0000000000..6f57f3044b --- /dev/null +++ b/Lang/DuckDB/Feigenbaum-constant-calculation @@ -0,0 +1 @@ +../../Task/Feigenbaum-constant-calculation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fibonacci-sequence b/Lang/DuckDB/Fibonacci-sequence new file mode 120000 index 0000000000..0411dbf9f3 --- /dev/null +++ b/Lang/DuckDB/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/File-input-output b/Lang/DuckDB/File-input-output new file mode 120000 index 0000000000..0bb640b9cd --- /dev/null +++ b/Lang/DuckDB/File-input-output @@ -0,0 +1 @@ +../../Task/File-input-output/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Filter b/Lang/DuckDB/Filter new file mode 120000 index 0000000000..bec860336f --- /dev/null +++ b/Lang/DuckDB/Filter @@ -0,0 +1 @@ +../../Task/Filter/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Find-limit-of-recursion b/Lang/DuckDB/Find-limit-of-recursion new file mode 120000 index 0000000000..e7eff55309 --- /dev/null +++ b/Lang/DuckDB/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Find-the-last-Sunday-of-each-month b/Lang/DuckDB/Find-the-last-Sunday-of-each-month new file mode 120000 index 0000000000..39172062a9 --- /dev/null +++ b/Lang/DuckDB/Find-the-last-Sunday-of-each-month @@ -0,0 +1 @@ +../../Task/Find-the-last-Sunday-of-each-month/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Five-weekends b/Lang/DuckDB/Five-weekends new file mode 120000 index 0000000000..4d8ed3ebe3 --- /dev/null +++ b/Lang/DuckDB/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Fixed-length-records b/Lang/DuckDB/Fixed-length-records new file mode 120000 index 0000000000..0b8d72de87 --- /dev/null +++ b/Lang/DuckDB/Fixed-length-records @@ -0,0 +1 @@ +../../Task/Fixed-length-records/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Flatten-a-list b/Lang/DuckDB/Flatten-a-list new file mode 120000 index 0000000000..5bd1c5b0d8 --- /dev/null +++ b/Lang/DuckDB/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Formatted-numeric-output b/Lang/DuckDB/Formatted-numeric-output new file mode 120000 index 0000000000..789e647161 --- /dev/null +++ b/Lang/DuckDB/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Forward-difference b/Lang/DuckDB/Forward-difference new file mode 120000 index 0000000000..6a0d935f36 --- /dev/null +++ b/Lang/DuckDB/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Function-definition b/Lang/DuckDB/Function-definition new file mode 120000 index 0000000000..b39d093883 --- /dev/null +++ b/Lang/DuckDB/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gamma-function b/Lang/DuckDB/Gamma-function new file mode 120000 index 0000000000..6fcec68436 --- /dev/null +++ b/Lang/DuckDB/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gapful-numbers b/Lang/DuckDB/Gapful-numbers new file mode 120000 index 0000000000..875c3e4310 --- /dev/null +++ b/Lang/DuckDB/Gapful-numbers @@ -0,0 +1 @@ +../../Task/Gapful-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Generate-lower-case-ASCII-alphabet b/Lang/DuckDB/Generate-lower-case-ASCII-alphabet new file mode 120000 index 0000000000..51094f97da --- /dev/null +++ b/Lang/DuckDB/Generate-lower-case-ASCII-alphabet @@ -0,0 +1 @@ +../../Task/Generate-lower-case-ASCII-alphabet/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Generic-swap b/Lang/DuckDB/Generic-swap new file mode 120000 index 0000000000..b384241f1f --- /dev/null +++ b/Lang/DuckDB/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Golden-ratio-Convergence b/Lang/DuckDB/Golden-ratio-Convergence new file mode 120000 index 0000000000..0ca8f2458f --- /dev/null +++ b/Lang/DuckDB/Golden-ratio-Convergence @@ -0,0 +1 @@ +../../Task/Golden-ratio-Convergence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Gotchas b/Lang/DuckDB/Gotchas new file mode 120000 index 0000000000..16cceb3ff0 --- /dev/null +++ b/Lang/DuckDB/Gotchas @@ -0,0 +1 @@ +../../Task/Gotchas/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-common-divisor b/Lang/DuckDB/Greatest-common-divisor new file mode 120000 index 0000000000..6fb062c771 --- /dev/null +++ b/Lang/DuckDB/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-element-of-a-list b/Lang/DuckDB/Greatest-element-of-a-list new file mode 120000 index 0000000000..5a2c7a66c9 --- /dev/null +++ b/Lang/DuckDB/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Greatest-subsequential-sum b/Lang/DuckDB/Greatest-subsequential-sum new file mode 120000 index 0000000000..dd3661e978 --- /dev/null +++ b/Lang/DuckDB/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTP b/Lang/DuckDB/HTTP new file mode 120000 index 0000000000..f77a3116ff --- /dev/null +++ b/Lang/DuckDB/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTPS b/Lang/DuckDB/HTTPS new file mode 120000 index 0000000000..694faecb0f --- /dev/null +++ b/Lang/DuckDB/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/HTTPS-Authenticated b/Lang/DuckDB/HTTPS-Authenticated new file mode 120000 index 0000000000..c1b123b3b8 --- /dev/null +++ b/Lang/DuckDB/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hailstone-sequence b/Lang/DuckDB/Hailstone-sequence new file mode 120000 index 0000000000..8cb9cd3c4d --- /dev/null +++ b/Lang/DuckDB/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Harmonic-series b/Lang/DuckDB/Harmonic-series new file mode 120000 index 0000000000..d5b23dfe32 --- /dev/null +++ b/Lang/DuckDB/Harmonic-series @@ -0,0 +1 @@ +../../Task/Harmonic-series/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hash-from-two-arrays b/Lang/DuckDB/Hash-from-two-arrays new file mode 120000 index 0000000000..4fd3efc241 --- /dev/null +++ b/Lang/DuckDB/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hash-join b/Lang/DuckDB/Hash-join new file mode 120000 index 0000000000..d89e18cc75 --- /dev/null +++ b/Lang/DuckDB/Hash-join @@ -0,0 +1 @@ +../../Task/Hash-join/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Haversine-formula b/Lang/DuckDB/Haversine-formula new file mode 120000 index 0000000000..102a047e33 --- /dev/null +++ b/Lang/DuckDB/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Hello-world-Text b/Lang/DuckDB/Hello-world-Text new file mode 120000 index 0000000000..1af484f405 --- /dev/null +++ b/Lang/DuckDB/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Here-document b/Lang/DuckDB/Here-document new file mode 120000 index 0000000000..f233028f5b --- /dev/null +++ b/Lang/DuckDB/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/ISBN13-check-digit b/Lang/DuckDB/ISBN13-check-digit new file mode 120000 index 0000000000..ad247e79cf --- /dev/null +++ b/Lang/DuckDB/ISBN13-check-digit @@ -0,0 +1 @@ +../../Task/ISBN13-check-digit/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Identity-matrix b/Lang/DuckDB/Identity-matrix new file mode 120000 index 0000000000..d8402f7ae8 --- /dev/null +++ b/Lang/DuckDB/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols b/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols new file mode 120000 index 0000000000..90e880a4b1 --- /dev/null +++ b/Lang/DuckDB/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols @@ -0,0 +1 @@ +../../Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters b/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters new file mode 120000 index 0000000000..3722271469 --- /dev/null +++ b/Lang/DuckDB/Idiomatically-determine-all-the-lowercase-and-uppercase-letters @@ -0,0 +1 @@ +../../Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Increment-a-numerical-string b/Lang/DuckDB/Increment-a-numerical-string new file mode 120000 index 0000000000..a9f84c0e8c --- /dev/null +++ b/Lang/DuckDB/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Infinity b/Lang/DuckDB/Infinity new file mode 120000 index 0000000000..ed12f74690 --- /dev/null +++ b/Lang/DuckDB/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Integer-comparison b/Lang/DuckDB/Integer-comparison new file mode 120000 index 0000000000..c6cacfcd06 --- /dev/null +++ b/Lang/DuckDB/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Introspection b/Lang/DuckDB/Introspection new file mode 120000 index 0000000000..c3bb6d896d --- /dev/null +++ b/Lang/DuckDB/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Inverted-index b/Lang/DuckDB/Inverted-index new file mode 120000 index 0000000000..81053e0c15 --- /dev/null +++ b/Lang/DuckDB/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Inverted-syntax b/Lang/DuckDB/Inverted-syntax new file mode 120000 index 0000000000..cadc81e3b6 --- /dev/null +++ b/Lang/DuckDB/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/JSON b/Lang/DuckDB/JSON new file mode 120000 index 0000000000..e4757a4b09 --- /dev/null +++ b/Lang/DuckDB/JSON @@ -0,0 +1 @@ +../../Task/JSON/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Jaro-similarity b/Lang/DuckDB/Jaro-similarity new file mode 120000 index 0000000000..39c64b8488 --- /dev/null +++ b/Lang/DuckDB/Jaro-similarity @@ -0,0 +1 @@ +../../Task/Jaro-similarity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Knuth-shuffle b/Lang/DuckDB/Knuth-shuffle new file mode 120000 index 0000000000..7d43c57cbe --- /dev/null +++ b/Lang/DuckDB/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Largest-int-from-concatenated-ints b/Lang/DuckDB/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..8e73a50292 --- /dev/null +++ b/Lang/DuckDB/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Last-Friday-of-each-month b/Lang/DuckDB/Last-Friday-of-each-month new file mode 120000 index 0000000000..1236ebdc14 --- /dev/null +++ b/Lang/DuckDB/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Leap-year b/Lang/DuckDB/Leap-year new file mode 120000 index 0000000000..5816394f02 --- /dev/null +++ b/Lang/DuckDB/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Left-factorials b/Lang/DuckDB/Left-factorials new file mode 120000 index 0000000000..6877bf1f73 --- /dev/null +++ b/Lang/DuckDB/Left-factorials @@ -0,0 +1 @@ +../../Task/Left-factorials/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Leonardo-numbers b/Lang/DuckDB/Leonardo-numbers new file mode 120000 index 0000000000..206ddcfce9 --- /dev/null +++ b/Lang/DuckDB/Leonardo-numbers @@ -0,0 +1 @@ +../../Task/Leonardo-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Letter-frequency b/Lang/DuckDB/Letter-frequency new file mode 120000 index 0000000000..29228c3e0b --- /dev/null +++ b/Lang/DuckDB/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Levenshtein-distance b/Lang/DuckDB/Levenshtein-distance new file mode 120000 index 0000000000..d0954b60f2 --- /dev/null +++ b/Lang/DuckDB/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/List-comprehensions b/Lang/DuckDB/List-comprehensions new file mode 120000 index 0000000000..72558c43a1 --- /dev/null +++ b/Lang/DuckDB/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Literals-Integer b/Lang/DuckDB/Literals-Integer new file mode 120000 index 0000000000..39629959b4 --- /dev/null +++ b/Lang/DuckDB/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Logical-operations b/Lang/DuckDB/Logical-operations new file mode 120000 index 0000000000..14d59b0f70 --- /dev/null +++ b/Lang/DuckDB/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Longest-increasing-subsequence b/Lang/DuckDB/Longest-increasing-subsequence new file mode 120000 index 0000000000..35a8443499 --- /dev/null +++ b/Lang/DuckDB/Longest-increasing-subsequence @@ -0,0 +1 @@ +../../Task/Longest-increasing-subsequence/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Break b/Lang/DuckDB/Loops-Break new file mode 120000 index 0000000000..40b7904e3f --- /dev/null +++ b/Lang/DuckDB/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Do-while b/Lang/DuckDB/Loops-Do-while new file mode 120000 index 0000000000..257f84d6ba --- /dev/null +++ b/Lang/DuckDB/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Downward-for b/Lang/DuckDB/Loops-Downward-for new file mode 120000 index 0000000000..5516907335 --- /dev/null +++ b/Lang/DuckDB/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-For b/Lang/DuckDB/Loops-For new file mode 120000 index 0000000000..56dde9a604 --- /dev/null +++ b/Lang/DuckDB/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-For-with-a-specified-step b/Lang/DuckDB/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..f7e2b536d7 --- /dev/null +++ b/Lang/DuckDB/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body b/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body new file mode 120000 index 0000000000..d530992462 --- /dev/null +++ b/Lang/DuckDB/Loops-Increment-loop-index-within-loop-body @@ -0,0 +1 @@ +../../Task/Loops-Increment-loop-index-within-loop-body/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-N-plus-one-half b/Lang/DuckDB/Loops-N-plus-one-half new file mode 120000 index 0000000000..f9812bda7e --- /dev/null +++ b/Lang/DuckDB/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-Nested b/Lang/DuckDB/Loops-Nested new file mode 120000 index 0000000000..8b4afa46b5 --- /dev/null +++ b/Lang/DuckDB/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-While b/Lang/DuckDB/Loops-While new file mode 120000 index 0000000000..60343480f3 --- /dev/null +++ b/Lang/DuckDB/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Loops-With-multiple-ranges b/Lang/DuckDB/Loops-With-multiple-ranges new file mode 120000 index 0000000000..540b734a24 --- /dev/null +++ b/Lang/DuckDB/Loops-With-multiple-ranges @@ -0,0 +1 @@ +../../Task/Loops-With-multiple-ranges/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Luhn-test-of-credit-card-numbers b/Lang/DuckDB/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..397557411e --- /dev/null +++ b/Lang/DuckDB/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/MD5 b/Lang/DuckDB/MD5 new file mode 120000 index 0000000000..ab453e87da --- /dev/null +++ b/Lang/DuckDB/MD5 @@ -0,0 +1 @@ +../../Task/MD5/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Map-range b/Lang/DuckDB/Map-range new file mode 120000 index 0000000000..6cd697a04b --- /dev/null +++ b/Lang/DuckDB/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Matrix-multiplication b/Lang/DuckDB/Matrix-multiplication new file mode 120000 index 0000000000..2110896869 --- /dev/null +++ b/Lang/DuckDB/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Matrix-transposition b/Lang/DuckDB/Matrix-transposition new file mode 120000 index 0000000000..7e416217b2 --- /dev/null +++ b/Lang/DuckDB/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Merge-and-aggregate-datasets b/Lang/DuckDB/Merge-and-aggregate-datasets new file mode 120000 index 0000000000..e9d467735b --- /dev/null +++ b/Lang/DuckDB/Merge-and-aggregate-datasets @@ -0,0 +1 @@ +../../Task/Merge-and-aggregate-datasets/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Metallic-ratios b/Lang/DuckDB/Metallic-ratios new file mode 120000 index 0000000000..56fa981641 --- /dev/null +++ b/Lang/DuckDB/Metallic-ratios @@ -0,0 +1 @@ +../../Task/Metallic-ratios/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Middle-three-digits b/Lang/DuckDB/Middle-three-digits new file mode 120000 index 0000000000..9c32c60a1c --- /dev/null +++ b/Lang/DuckDB/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Monte-Carlo-methods b/Lang/DuckDB/Monte-Carlo-methods new file mode 120000 index 0000000000..f27be4f0e8 --- /dev/null +++ b/Lang/DuckDB/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nested-function b/Lang/DuckDB/Nested-function new file mode 120000 index 0000000000..6ccb0c0029 --- /dev/null +++ b/Lang/DuckDB/Nested-function @@ -0,0 +1 @@ +../../Task/Nested-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nth b/Lang/DuckDB/Nth new file mode 120000 index 0000000000..6d1fd0295b --- /dev/null +++ b/Lang/DuckDB/Nth @@ -0,0 +1 @@ +../../Task/Nth/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Nth-root b/Lang/DuckDB/Nth-root new file mode 120000 index 0000000000..bdfee4887c --- /dev/null +++ b/Lang/DuckDB/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/One-of-n-lines-in-a-file b/Lang/DuckDB/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..84adf8bb46 --- /dev/null +++ b/Lang/DuckDB/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Order-two-numerical-lists b/Lang/DuckDB/Order-two-numerical-lists new file mode 120000 index 0000000000..fcd259b6c0 --- /dev/null +++ b/Lang/DuckDB/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Ordered-words b/Lang/DuckDB/Ordered-words new file mode 120000 index 0000000000..57d12d9c27 --- /dev/null +++ b/Lang/DuckDB/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Palindrome-detection b/Lang/DuckDB/Palindrome-detection new file mode 120000 index 0000000000..a318cb02ae --- /dev/null +++ b/Lang/DuckDB/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Parameterized-SQL-statement b/Lang/DuckDB/Parameterized-SQL-statement new file mode 120000 index 0000000000..dded36b01b --- /dev/null +++ b/Lang/DuckDB/Parameterized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parameterized-SQL-statement/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pascals-triangle b/Lang/DuckDB/Pascals-triangle new file mode 120000 index 0000000000..e38a99fc2d --- /dev/null +++ b/Lang/DuckDB/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Permutations b/Lang/DuckDB/Permutations new file mode 120000 index 0000000000..fa1198c6a6 --- /dev/null +++ b/Lang/DuckDB/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Permutations-Derangements b/Lang/DuckDB/Permutations-Derangements new file mode 120000 index 0000000000..b4140ee27e --- /dev/null +++ b/Lang/DuckDB/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pick-random-element b/Lang/DuckDB/Pick-random-element new file mode 120000 index 0000000000..4eec54c36e --- /dev/null +++ b/Lang/DuckDB/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Primality-by-trial-division b/Lang/DuckDB/Primality-by-trial-division new file mode 120000 index 0000000000..8e9e10eb1a --- /dev/null +++ b/Lang/DuckDB/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Prime-decomposition b/Lang/DuckDB/Prime-decomposition new file mode 120000 index 0000000000..dbb3b57727 --- /dev/null +++ b/Lang/DuckDB/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Probabilistic-choice b/Lang/DuckDB/Probabilistic-choice new file mode 120000 index 0000000000..caa9cf57ce --- /dev/null +++ b/Lang/DuckDB/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Proper-divisors b/Lang/DuckDB/Proper-divisors new file mode 120000 index 0000000000..a8b8cf32ca --- /dev/null +++ b/Lang/DuckDB/Proper-divisors @@ -0,0 +1 @@ +../../Task/Proper-divisors/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method b/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method new file mode 120000 index 0000000000..3424580b60 --- /dev/null +++ b/Lang/DuckDB/Pseudo-random-numbers-Middle-square-method @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Middle-square-method/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Random-numbers b/Lang/DuckDB/Random-numbers new file mode 120000 index 0000000000..4e7ae21251 --- /dev/null +++ b/Lang/DuckDB/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Range-expansion b/Lang/DuckDB/Range-expansion new file mode 120000 index 0000000000..73f7852f3e --- /dev/null +++ b/Lang/DuckDB/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Range-extraction b/Lang/DuckDB/Range-extraction new file mode 120000 index 0000000000..70b9fee7f2 --- /dev/null +++ b/Lang/DuckDB/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Read-a-file-line-by-line b/Lang/DuckDB/Read-a-file-line-by-line new file mode 120000 index 0000000000..5698cabe3f --- /dev/null +++ b/Lang/DuckDB/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reflection-List-methods b/Lang/DuckDB/Reflection-List-methods new file mode 120000 index 0000000000..e87f71ad29 --- /dev/null +++ b/Lang/DuckDB/Reflection-List-methods @@ -0,0 +1 @@ +../../Task/Reflection-List-methods/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reflection-List-properties b/Lang/DuckDB/Reflection-List-properties new file mode 120000 index 0000000000..61160f5035 --- /dev/null +++ b/Lang/DuckDB/Reflection-List-properties @@ -0,0 +1 @@ +../../Task/Reflection-List-properties/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Remove-duplicate-elements b/Lang/DuckDB/Remove-duplicate-elements new file mode 120000 index 0000000000..e38927d88b --- /dev/null +++ b/Lang/DuckDB/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Rep-string b/Lang/DuckDB/Rep-string new file mode 120000 index 0000000000..ce2543465d --- /dev/null +++ b/Lang/DuckDB/Rep-string @@ -0,0 +1 @@ +../../Task/Rep-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Repeat-a-string b/Lang/DuckDB/Repeat-a-string new file mode 120000 index 0000000000..126fb8a5a7 --- /dev/null +++ b/Lang/DuckDB/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Return-multiple-values b/Lang/DuckDB/Return-multiple-values new file mode 120000 index 0000000000..44885d997f --- /dev/null +++ b/Lang/DuckDB/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Reverse-a-string b/Lang/DuckDB/Reverse-a-string new file mode 120000 index 0000000000..9c2fcefbbf --- /dev/null +++ b/Lang/DuckDB/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Roots-of-unity b/Lang/DuckDB/Roots-of-unity new file mode 120000 index 0000000000..fbae972a1d --- /dev/null +++ b/Lang/DuckDB/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Run-length-encoding b/Lang/DuckDB/Run-length-encoding new file mode 120000 index 0000000000..798b72b50c --- /dev/null +++ b/Lang/DuckDB/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Search-a-list-of-records b/Lang/DuckDB/Search-a-list-of-records new file mode 120000 index 0000000000..8875d845bf --- /dev/null +++ b/Lang/DuckDB/Search-a-list-of-records @@ -0,0 +1 @@ +../../Task/Search-a-list-of-records/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Set b/Lang/DuckDB/Set new file mode 120000 index 0000000000..7e25aac634 --- /dev/null +++ b/Lang/DuckDB/Set @@ -0,0 +1 @@ +../../Task/Set/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Set-consolidation b/Lang/DuckDB/Set-consolidation new file mode 120000 index 0000000000..46e9513ebb --- /dev/null +++ b/Lang/DuckDB/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Show-the-epoch b/Lang/DuckDB/Show-the-epoch new file mode 120000 index 0000000000..6cd68764f9 --- /dev/null +++ b/Lang/DuckDB/Show-the-epoch @@ -0,0 +1 @@ +../../Task/Show-the-epoch/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sieve-of-Eratosthenes b/Lang/DuckDB/Sieve-of-Eratosthenes new file mode 120000 index 0000000000..ee6aa1fbd3 --- /dev/null +++ b/Lang/DuckDB/Sieve-of-Eratosthenes @@ -0,0 +1 @@ +../../Task/Sieve-of-Eratosthenes/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sort-an-array-of-composite-structures b/Lang/DuckDB/Sort-an-array-of-composite-structures new file mode 120000 index 0000000000..35612aed66 --- /dev/null +++ b/Lang/DuckDB/Sort-an-array-of-composite-structures @@ -0,0 +1 @@ +../../Task/Sort-an-array-of-composite-structures/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sort-numbers-lexicographically b/Lang/DuckDB/Sort-numbers-lexicographically new file mode 120000 index 0000000000..390860d685 --- /dev/null +++ b/Lang/DuckDB/Sort-numbers-lexicographically @@ -0,0 +1 @@ +../../Task/Sort-numbers-lexicographically/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Statistics-Basic b/Lang/DuckDB/Statistics-Basic new file mode 120000 index 0000000000..c3caa99be7 --- /dev/null +++ b/Lang/DuckDB/Statistics-Basic @@ -0,0 +1 @@ +../../Task/Statistics-Basic/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-append b/Lang/DuckDB/String-append new file mode 120000 index 0000000000..cc8ce5011e --- /dev/null +++ b/Lang/DuckDB/String-append @@ -0,0 +1 @@ +../../Task/String-append/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-case b/Lang/DuckDB/String-case new file mode 120000 index 0000000000..ab3478758f --- /dev/null +++ b/Lang/DuckDB/String-case @@ -0,0 +1 @@ +../../Task/String-case/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-comparison b/Lang/DuckDB/String-comparison new file mode 120000 index 0000000000..b7a7339e14 --- /dev/null +++ b/Lang/DuckDB/String-comparison @@ -0,0 +1 @@ +../../Task/String-comparison/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-interpolation-included- b/Lang/DuckDB/String-interpolation-included- new file mode 120000 index 0000000000..807f8abec4 --- /dev/null +++ b/Lang/DuckDB/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-length b/Lang/DuckDB/String-length new file mode 120000 index 0000000000..f49078b058 --- /dev/null +++ b/Lang/DuckDB/String-length @@ -0,0 +1 @@ +../../Task/String-length/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-matching b/Lang/DuckDB/String-matching new file mode 120000 index 0000000000..e3f7fa5300 --- /dev/null +++ b/Lang/DuckDB/String-matching @@ -0,0 +1 @@ +../../Task/String-matching/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/String-prepend b/Lang/DuckDB/String-prepend new file mode 120000 index 0000000000..ea6f95610c --- /dev/null +++ b/Lang/DuckDB/String-prepend @@ -0,0 +1 @@ +../../Task/String-prepend/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-a-set-of-characters-from-a-string b/Lang/DuckDB/Strip-a-set-of-characters-from-a-string new file mode 120000 index 0000000000..77ce9f900d --- /dev/null +++ b/Lang/DuckDB/Strip-a-set-of-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-a-set-of-characters-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-comments-from-a-string b/Lang/DuckDB/Strip-comments-from-a-string new file mode 120000 index 0000000000..f58b2c006d --- /dev/null +++ b/Lang/DuckDB/Strip-comments-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-comments-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string b/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string new file mode 120000 index 0000000000..e3de3aa487 --- /dev/null +++ b/Lang/DuckDB/Strip-control-codes-and-extended-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail b/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail new file mode 120000 index 0000000000..93405e661f --- /dev/null +++ b/Lang/DuckDB/Strip-whitespace-from-a-string-Top-and-tail @@ -0,0 +1 @@ +../../Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Substring b/Lang/DuckDB/Substring new file mode 120000 index 0000000000..fe9daf5b9c --- /dev/null +++ b/Lang/DuckDB/Substring @@ -0,0 +1 @@ +../../Task/Substring/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sudoku b/Lang/DuckDB/Sudoku new file mode 120000 index 0000000000..efc19532bb --- /dev/null +++ b/Lang/DuckDB/Sudoku @@ -0,0 +1 @@ +../../Task/Sudoku/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-and-product-of-an-array b/Lang/DuckDB/Sum-and-product-of-an-array new file mode 120000 index 0000000000..9db07cfe55 --- /dev/null +++ b/Lang/DuckDB/Sum-and-product-of-an-array @@ -0,0 +1 @@ +../../Task/Sum-and-product-of-an-array/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-digits-of-an-integer b/Lang/DuckDB/Sum-digits-of-an-integer new file mode 120000 index 0000000000..2b4e9e5805 --- /dev/null +++ b/Lang/DuckDB/Sum-digits-of-an-integer @@ -0,0 +1 @@ +../../Task/Sum-digits-of-an-integer/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-multiples-of-3-and-5 b/Lang/DuckDB/Sum-multiples-of-3-and-5 new file mode 120000 index 0000000000..06a19cefb7 --- /dev/null +++ b/Lang/DuckDB/Sum-multiples-of-3-and-5 @@ -0,0 +1 @@ +../../Task/Sum-multiples-of-3-and-5/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-of-a-series b/Lang/DuckDB/Sum-of-a-series new file mode 120000 index 0000000000..db0f6f79c5 --- /dev/null +++ b/Lang/DuckDB/Sum-of-a-series @@ -0,0 +1 @@ +../../Task/Sum-of-a-series/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Sum-of-squares b/Lang/DuckDB/Sum-of-squares new file mode 120000 index 0000000000..fe3d9a8a52 --- /dev/null +++ b/Lang/DuckDB/Sum-of-squares @@ -0,0 +1 @@ +../../Task/Sum-of-squares/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Symmetric-difference b/Lang/DuckDB/Symmetric-difference new file mode 120000 index 0000000000..f254423d5f --- /dev/null +++ b/Lang/DuckDB/Symmetric-difference @@ -0,0 +1 @@ +../../Task/Symmetric-difference/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Table-creation-Postal-addresses b/Lang/DuckDB/Table-creation-Postal-addresses new file mode 120000 index 0000000000..174f03f886 --- /dev/null +++ b/Lang/DuckDB/Table-creation-Postal-addresses @@ -0,0 +1 @@ +../../Task/Table-creation-Postal-addresses/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Test-integerness b/Lang/DuckDB/Test-integerness new file mode 120000 index 0000000000..0e9573c924 --- /dev/null +++ b/Lang/DuckDB/Test-integerness @@ -0,0 +1 @@ +../../Task/Test-integerness/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Text-processing-2 b/Lang/DuckDB/Text-processing-2 new file mode 120000 index 0000000000..b3c883d2ec --- /dev/null +++ b/Lang/DuckDB/Text-processing-2 @@ -0,0 +1 @@ +../../Task/Text-processing-2/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Thue-Morse b/Lang/DuckDB/Thue-Morse new file mode 120000 index 0000000000..e14a41e488 --- /dev/null +++ b/Lang/DuckDB/Thue-Morse @@ -0,0 +1 @@ +../../Task/Thue-Morse/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Time-a-function b/Lang/DuckDB/Time-a-function new file mode 120000 index 0000000000..d82a288f55 --- /dev/null +++ b/Lang/DuckDB/Time-a-function @@ -0,0 +1 @@ +../../Task/Time-a-function/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Tokenize-a-string b/Lang/DuckDB/Tokenize-a-string new file mode 120000 index 0000000000..ee6d07a4b5 --- /dev/null +++ b/Lang/DuckDB/Tokenize-a-string @@ -0,0 +1 @@ +../../Task/Tokenize-a-string/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Top-rank-per-group b/Lang/DuckDB/Top-rank-per-group new file mode 120000 index 0000000000..ada50a852c --- /dev/null +++ b/Lang/DuckDB/Top-rank-per-group @@ -0,0 +1 @@ +../../Task/Top-rank-per-group/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Trigonometric-functions b/Lang/DuckDB/Trigonometric-functions new file mode 120000 index 0000000000..58530b66ee --- /dev/null +++ b/Lang/DuckDB/Trigonometric-functions @@ -0,0 +1 @@ +../../Task/Trigonometric-functions/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/URL-decoding b/Lang/DuckDB/URL-decoding new file mode 120000 index 0000000000..c717460642 --- /dev/null +++ b/Lang/DuckDB/URL-decoding @@ -0,0 +1 @@ +../../Task/URL-decoding/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/UTF-8-encode-and-decode b/Lang/DuckDB/UTF-8-encode-and-decode new file mode 120000 index 0000000000..792323a78c --- /dev/null +++ b/Lang/DuckDB/UTF-8-encode-and-decode @@ -0,0 +1 @@ +../../Task/UTF-8-encode-and-decode/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Unix-ls b/Lang/DuckDB/Unix-ls new file mode 120000 index 0000000000..85287a21f6 --- /dev/null +++ b/Lang/DuckDB/Unix-ls @@ -0,0 +1 @@ +../../Task/Unix-ls/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Variable-size-Get b/Lang/DuckDB/Variable-size-Get new file mode 120000 index 0000000000..3cff7c631a --- /dev/null +++ b/Lang/DuckDB/Variable-size-Get @@ -0,0 +1 @@ +../../Task/Variable-size-Get/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Variable-size-Set b/Lang/DuckDB/Variable-size-Set new file mode 120000 index 0000000000..ee4a003cfa --- /dev/null +++ b/Lang/DuckDB/Variable-size-Set @@ -0,0 +1 @@ +../../Task/Variable-size-Set/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Vector-products b/Lang/DuckDB/Vector-products new file mode 120000 index 0000000000..3347aa5bba --- /dev/null +++ b/Lang/DuckDB/Vector-products @@ -0,0 +1 @@ +../../Task/Vector-products/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Zero-to-the-zero-power b/Lang/DuckDB/Zero-to-the-zero-power new file mode 120000 index 0000000000..7c7bac0f0b --- /dev/null +++ b/Lang/DuckDB/Zero-to-the-zero-power @@ -0,0 +1 @@ +../../Task/Zero-to-the-zero-power/DuckDB \ No newline at end of file diff --git a/Lang/DuckDB/Zig-zag-matrix b/Lang/DuckDB/Zig-zag-matrix new file mode 120000 index 0000000000..dee409f57f --- /dev/null +++ b/Lang/DuckDB/Zig-zag-matrix @@ -0,0 +1 @@ +../../Task/Zig-zag-matrix/DuckDB \ No newline at end of file diff --git a/Lang/EasyLang/AKS-test-for-primes b/Lang/EasyLang/AKS-test-for-primes new file mode 120000 index 0000000000..fb3fd809a4 --- /dev/null +++ b/Lang/EasyLang/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm b/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..9b995802ee --- /dev/null +++ b/Lang/EasyLang/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Cholesky-decomposition b/Lang/EasyLang/Cholesky-decomposition new file mode 120000 index 0000000000..3d9b8e35d4 --- /dev/null +++ b/Lang/EasyLang/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Currency b/Lang/EasyLang/Currency new file mode 120000 index 0000000000..a42c848ea8 --- /dev/null +++ b/Lang/EasyLang/Currency @@ -0,0 +1 @@ +../../Task/Currency/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Death-Star b/Lang/EasyLang/Death-Star new file mode 120000 index 0000000000..71ec2dde3d --- /dev/null +++ b/Lang/EasyLang/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series b/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series new file mode 120000 index 0000000000..10532131de --- /dev/null +++ b/Lang/EasyLang/Distribution-of-0-digits-in-factorial-series @@ -0,0 +1 @@ +../../Task/Distribution-of-0-digits-in-factorial-series/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Draw-a-sphere b/Lang/EasyLang/Draw-a-sphere new file mode 120000 index 0000000000..4a92493ec5 --- /dev/null +++ b/Lang/EasyLang/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/EKG-sequence-convergence b/Lang/EasyLang/EKG-sequence-convergence new file mode 120000 index 0000000000..a5d661cade --- /dev/null +++ b/Lang/EasyLang/EKG-sequence-convergence @@ -0,0 +1 @@ +../../Task/EKG-sequence-convergence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Earliest-difference-between-prime-gaps b/Lang/EasyLang/Earliest-difference-between-prime-gaps new file mode 120000 index 0000000000..e8abb13bc1 --- /dev/null +++ b/Lang/EasyLang/Earliest-difference-between-prime-gaps @@ -0,0 +1 @@ +../../Task/Earliest-difference-between-prime-gaps/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length b/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length new file mode 120000 index 0000000000..440a0e3168 --- /dev/null +++ b/Lang/EasyLang/Elementary-cellular-automaton-Infinite-length @@ -0,0 +1 @@ +../../Task/Elementary-cellular-automaton-Infinite-length/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes b/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes new file mode 120000 index 0000000000..a64dc7d4f0 --- /dev/null +++ b/Lang/EasyLang/Erd-s-Selfridge-categorization-of-primes @@ -0,0 +1 @@ +../../Task/Erd-s-Selfridge-categorization-of-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Faulhabers-formula b/Lang/EasyLang/Faulhabers-formula new file mode 120000 index 0000000000..a0587d4c22 --- /dev/null +++ b/Lang/EasyLang/Faulhabers-formula @@ -0,0 +1 @@ +../../Task/Faulhabers-formula/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Faulhabers-triangle b/Lang/EasyLang/Faulhabers-triangle new file mode 120000 index 0000000000..0ced82832c --- /dev/null +++ b/Lang/EasyLang/Faulhabers-triangle @@ -0,0 +1 @@ +../../Task/Faulhabers-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fibonacci-word-fractal b/Lang/EasyLang/Fibonacci-word-fractal new file mode 120000 index 0000000000..d075c27d88 --- /dev/null +++ b/Lang/EasyLang/Fibonacci-word-fractal @@ -0,0 +1 @@ +../../Task/Fibonacci-word-fractal/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Find-Chess960-starting-position-identifier b/Lang/EasyLang/Find-Chess960-starting-position-identifier new file mode 120000 index 0000000000..74db5136c0 --- /dev/null +++ b/Lang/EasyLang/Find-Chess960-starting-position-identifier @@ -0,0 +1 @@ +../../Task/Find-Chess960-starting-position-identifier/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Fraction-reduction b/Lang/EasyLang/Fraction-reduction new file mode 120000 index 0000000000..61af524020 --- /dev/null +++ b/Lang/EasyLang/Fraction-reduction @@ -0,0 +1 @@ +../../Task/Fraction-reduction/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/French-Republican-calendar b/Lang/EasyLang/French-Republican-calendar new file mode 120000 index 0000000000..63cacd897e --- /dev/null +++ b/Lang/EasyLang/French-Republican-calendar @@ -0,0 +1 @@ +../../Task/French-Republican-calendar/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Function-prototype b/Lang/EasyLang/Function-prototype new file mode 120000 index 0000000000..d56b3a5da3 --- /dev/null +++ b/Lang/EasyLang/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hash-from-two-arrays b/Lang/EasyLang/Hash-from-two-arrays new file mode 120000 index 0000000000..0d148a2df3 --- /dev/null +++ b/Lang/EasyLang/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Honeycombs b/Lang/EasyLang/Honeycombs new file mode 120000 index 0000000000..5885102888 --- /dev/null +++ b/Lang/EasyLang/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hunt-the-Wumpus b/Lang/EasyLang/Hunt-the-Wumpus new file mode 120000 index 0000000000..8a2489577d --- /dev/null +++ b/Lang/EasyLang/Hunt-the-Wumpus @@ -0,0 +1 @@ +../../Task/Hunt-the-Wumpus/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Jacobsthal-numbers b/Lang/EasyLang/Jacobsthal-numbers new file mode 120000 index 0000000000..9469db92c2 --- /dev/null +++ b/Lang/EasyLang/Jacobsthal-numbers @@ -0,0 +1 @@ +../../Task/Jacobsthal-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pascals-triangle-Puzzle b/Lang/EasyLang/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..bb3b35817e --- /dev/null +++ b/Lang/EasyLang/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Straddling-checkerboard b/Lang/EasyLang/Straddling-checkerboard new file mode 120000 index 0000000000..df23fad6e0 --- /dev/null +++ b/Lang/EasyLang/Straddling-checkerboard @@ -0,0 +1 @@ +../../Task/Straddling-checkerboard/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Unicode-strings b/Lang/EasyLang/Unicode-strings new file mode 120000 index 0000000000..c52bd4da5c --- /dev/null +++ b/Lang/EasyLang/Unicode-strings @@ -0,0 +1 @@ +../../Task/Unicode-strings/EasyLang \ No newline at end of file diff --git a/Lang/Eiffel/Loops-For b/Lang/Eiffel/Loops-For new file mode 120000 index 0000000000..30f93ee824 --- /dev/null +++ b/Lang/Eiffel/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Loops-Infinite b/Lang/Eiffel/Loops-Infinite new file mode 120000 index 0000000000..1016f5af23 --- /dev/null +++ b/Lang/Eiffel/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Eiffel \ No newline at end of file diff --git a/Lang/Elixir/Determinant-and-permanent b/Lang/Elixir/Determinant-and-permanent new file mode 120000 index 0000000000..91e99770a2 --- /dev/null +++ b/Lang/Elixir/Determinant-and-permanent @@ -0,0 +1 @@ +../../Task/Determinant-and-permanent/Elixir \ No newline at end of file diff --git a/Lang/Elixir/K-d-tree b/Lang/Elixir/K-d-tree new file mode 120000 index 0000000000..4a7008abc8 --- /dev/null +++ b/Lang/Elixir/K-d-tree @@ -0,0 +1 @@ +../../Task/K-d-tree/Elixir \ No newline at end of file diff --git a/Lang/Elixir/Parse-an-IP-Address b/Lang/Elixir/Parse-an-IP-Address new file mode 120000 index 0000000000..bad8e9a86e --- /dev/null +++ b/Lang/Elixir/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Elixir \ No newline at end of file diff --git a/Lang/Erlang/Determinant-and-permanent b/Lang/Erlang/Determinant-and-permanent new file mode 120000 index 0000000000..1dcba08234 --- /dev/null +++ b/Lang/Erlang/Determinant-and-permanent @@ -0,0 +1 @@ +../../Task/Determinant-and-permanent/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Floyd-Warshall-algorithm b/Lang/Erlang/Floyd-Warshall-algorithm new file mode 120000 index 0000000000..ac856e6ffa --- /dev/null +++ b/Lang/Erlang/Floyd-Warshall-algorithm @@ -0,0 +1 @@ +../../Task/Floyd-Warshall-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Excel/Jacobi-symbol b/Lang/Excel/Jacobi-symbol new file mode 120000 index 0000000000..85f7061c07 --- /dev/null +++ b/Lang/Excel/Jacobi-symbol @@ -0,0 +1 @@ +../../Task/Jacobi-symbol/Excel \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/00-LANG.txt b/Lang/Extended-Color-BASIC/00-LANG.txt new file mode 100644 index 0000000000..17efd36e93 --- /dev/null +++ b/Lang/Extended-Color-BASIC/00-LANG.txt @@ -0,0 +1,7 @@ +{{language|Extended Color BASIC}} + +Microsoft Extended Color BASIC the BASIC interpreter for the Tandy Color Computer and the Dragon Data Motorola 6809 processor based machines. + +==See Also== +* [[wp:Extended Color BASIC|Wikipedia: Extended Color BASIC]] +* [[Tasks not Implemented in Extended Color BASIC]] \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/00-META.yaml b/Lang/Extended-Color-BASIC/00-META.yaml new file mode 100644 index 0000000000..57e9e4028d --- /dev/null +++ b/Lang/Extended-Color-BASIC/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Extended_Color_BASIC diff --git a/Lang/Extended-Color-BASIC/Arrays b/Lang/Extended-Color-BASIC/Arrays new file mode 120000 index 0000000000..2ca9fdf8eb --- /dev/null +++ b/Lang/Extended-Color-BASIC/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Copy-a-string b/Lang/Extended-Color-BASIC/Copy-a-string new file mode 120000 index 0000000000..7a931a182a --- /dev/null +++ b/Lang/Extended-Color-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Hello-world-Text b/Lang/Extended-Color-BASIC/Hello-world-Text new file mode 120000 index 0000000000..b5cfbf6b90 --- /dev/null +++ b/Lang/Extended-Color-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Loops-For b/Lang/Extended-Color-BASIC/Loops-For new file mode 120000 index 0000000000..8719420a7c --- /dev/null +++ b/Lang/Extended-Color-BASIC/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/Quine b/Lang/Extended-Color-BASIC/Quine new file mode 120000 index 0000000000..fb6135d264 --- /dev/null +++ b/Lang/Extended-Color-BASIC/Quine @@ -0,0 +1 @@ +../../Task/Quine/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/Extended-Color-BASIC/User-input-Text b/Lang/Extended-Color-BASIC/User-input-Text new file mode 120000 index 0000000000..545233f9b1 --- /dev/null +++ b/Lang/Extended-Color-BASIC/User-input-Text @@ -0,0 +1 @@ +../../Task/User-input-Text/Extended-Color-BASIC \ No newline at end of file diff --git a/Lang/F-Sharp/Long-multiplication b/Lang/F-Sharp/Long-multiplication deleted file mode 120000 index a8ece45d37..0000000000 --- a/Lang/F-Sharp/Long-multiplication +++ /dev/null @@ -1 +0,0 @@ -../../Task/Long-multiplication/F-Sharp \ No newline at end of file diff --git a/Lang/F-Sharp/Multiplicative-order b/Lang/F-Sharp/Multiplicative-order new file mode 120000 index 0000000000..b2064cc3e0 --- /dev/null +++ b/Lang/F-Sharp/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/F-Sharp \ No newline at end of file diff --git a/Lang/Factor/Best-shuffle b/Lang/Factor/Best-shuffle new file mode 120000 index 0000000000..a10c8f5d14 --- /dev/null +++ b/Lang/Factor/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Factor \ No newline at end of file diff --git a/Lang/Fennel/00-LANG.txt b/Lang/Fennel/00-LANG.txt index d4313c004b..a3b3fb9075 100644 --- a/Lang/Fennel/00-LANG.txt +++ b/Lang/Fennel/00-LANG.txt @@ -10,4 +10,9 @@ According to Fennel website: Fennel is a programming language that brings togeth Anywhere you can run Lua code, you can run Fennel code. -See more examples at: [https://fennel-lang.org/ Fennel Website] \ No newline at end of file +See more examples at: [https://fennel-lang.org/ Fennel Website] + +A useful learning tool is antifennel at [https://git.sr.ht/~technomancy/antifennel https://git.sr.ht/~technomancy/antifennel] that can convert Lua programs to Fennel. +NB, some Lua features are not supported, particularly , and goto and any new features in Lua 5.5. + +As well as [[Lua]] 5.x VMs, Fennel programs can also be run with [[Pluto]], though warnings will probably be generated when Pluto parses the generated Lua. \ No newline at end of file diff --git a/Lang/Fennel/Abundant-deficient-and-perfect-number-classifications b/Lang/Fennel/Abundant-deficient-and-perfect-number-classifications new file mode 120000 index 0000000000..fbb88cf56d --- /dev/null +++ b/Lang/Fennel/Abundant-deficient-and-perfect-number-classifications @@ -0,0 +1 @@ +../../Task/Abundant-deficient-and-perfect-number-classifications/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Factorial b/Lang/Fennel/Factorial new file mode 120000 index 0000000000..ad3ab162af --- /dev/null +++ b/Lang/Fennel/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Factorial-primes b/Lang/Fennel/Factorial-primes new file mode 120000 index 0000000000..f7ae7a4fab --- /dev/null +++ b/Lang/Fennel/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Goldbachs-comet b/Lang/Fennel/Goldbachs-comet new file mode 120000 index 0000000000..38a9767c12 --- /dev/null +++ b/Lang/Fennel/Goldbachs-comet @@ -0,0 +1 @@ +../../Task/Goldbachs-comet/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Horners-rule-for-polynomial-evaluation b/Lang/Fennel/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..74fe37f151 --- /dev/null +++ b/Lang/Fennel/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Jacobsthal-numbers b/Lang/Fennel/Jacobsthal-numbers new file mode 120000 index 0000000000..fcf69f6156 --- /dev/null +++ b/Lang/Fennel/Jacobsthal-numbers @@ -0,0 +1 @@ +../../Task/Jacobsthal-numbers/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Fennel/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..e6054255ef --- /dev/null +++ b/Lang/Fennel/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Time-a-function b/Lang/Fennel/Time-a-function new file mode 120000 index 0000000000..e57c2d9bfb --- /dev/null +++ b/Lang/Fennel/Time-a-function @@ -0,0 +1 @@ +../../Task/Time-a-function/Fennel \ No newline at end of file diff --git a/Lang/Fennel/Yellowstone-sequence b/Lang/Fennel/Yellowstone-sequence new file mode 120000 index 0000000000..e160b50754 --- /dev/null +++ b/Lang/Fennel/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/Fennel \ No newline at end of file diff --git a/Lang/Fortran/Associative-array-Merging b/Lang/Fortran/Associative-array-Merging new file mode 120000 index 0000000000..862cee9b2b --- /dev/null +++ b/Lang/Fortran/Associative-array-Merging @@ -0,0 +1 @@ +../../Task/Associative-array-Merging/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Catalan-numbers-Pascals-triangle b/Lang/Fortran/Catalan-numbers-Pascals-triangle new file mode 120000 index 0000000000..e33b331d86 --- /dev/null +++ b/Lang/Fortran/Catalan-numbers-Pascals-triangle @@ -0,0 +1 @@ +../../Task/Catalan-numbers-Pascals-triangle/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Chinese-zodiac b/Lang/Fortran/Chinese-zodiac new file mode 120000 index 0000000000..87ed14e5e7 --- /dev/null +++ b/Lang/Fortran/Chinese-zodiac @@ -0,0 +1 @@ +../../Task/Chinese-zodiac/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Cyclotomic-polynomial b/Lang/Fortran/Cyclotomic-polynomial new file mode 120000 index 0000000000..0c2fd63e5e --- /dev/null +++ b/Lang/Fortran/Cyclotomic-polynomial @@ -0,0 +1 @@ +../../Task/Cyclotomic-polynomial/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Disarium-numbers b/Lang/Fortran/Disarium-numbers new file mode 120000 index 0000000000..4713bf931d --- /dev/null +++ b/Lang/Fortran/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Display-a-linear-combination b/Lang/Fortran/Display-a-linear-combination new file mode 120000 index 0000000000..4a9784f58d --- /dev/null +++ b/Lang/Fortran/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Fortran \ No newline at end of file diff --git a/Lang/Fortran/EKG-sequence-convergence b/Lang/Fortran/EKG-sequence-convergence new file mode 120000 index 0000000000..3ba5c0a162 --- /dev/null +++ b/Lang/Fortran/EKG-sequence-convergence @@ -0,0 +1 @@ +../../Task/EKG-sequence-convergence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Egyptian-division b/Lang/Fortran/Egyptian-division new file mode 120000 index 0000000000..bb7a134139 --- /dev/null +++ b/Lang/Fortran/Egyptian-division @@ -0,0 +1 @@ +../../Task/Egyptian-division/Fortran \ No newline at end of file diff --git a/Lang/Fortran/French-Republican-calendar b/Lang/Fortran/French-Republican-calendar new file mode 120000 index 0000000000..765942db3d --- /dev/null +++ b/Lang/Fortran/French-Republican-calendar @@ -0,0 +1 @@ +../../Task/French-Republican-calendar/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hofstadter-Figure-Figure-sequences b/Lang/Fortran/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..46497cf751 --- /dev/null +++ b/Lang/Fortran/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Humble-numbers b/Lang/Fortran/Humble-numbers new file mode 120000 index 0000000000..5aff41aed9 --- /dev/null +++ b/Lang/Fortran/Humble-numbers @@ -0,0 +1 @@ +../../Task/Humble-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Jewels-and-stones b/Lang/Fortran/Jewels-and-stones new file mode 120000 index 0000000000..5375572de2 --- /dev/null +++ b/Lang/Fortran/Jewels-and-stones @@ -0,0 +1 @@ +../../Task/Jewels-and-stones/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Knapsack-problem-Bounded b/Lang/Fortran/Knapsack-problem-Bounded new file mode 120000 index 0000000000..9f9870702b --- /dev/null +++ b/Lang/Fortran/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Knuths-power-tree b/Lang/Fortran/Knuths-power-tree new file mode 120000 index 0000000000..163172c51f --- /dev/null +++ b/Lang/Fortran/Knuths-power-tree @@ -0,0 +1 @@ +../../Task/Knuths-power-tree/Fortran \ No newline at end of file diff --git a/Lang/Fortran/McNuggets-problem b/Lang/Fortran/McNuggets-problem new file mode 120000 index 0000000000..6e4b8bc9dd --- /dev/null +++ b/Lang/Fortran/McNuggets-problem @@ -0,0 +1 @@ +../../Task/McNuggets-problem/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Parse-an-IP-Address b/Lang/Fortran/Parse-an-IP-Address new file mode 120000 index 0000000000..33994c1cc1 --- /dev/null +++ b/Lang/Fortran/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Pascals-triangle-Puzzle b/Lang/Fortran/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..5cea267339 --- /dev/null +++ b/Lang/Fortran/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Fortran/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..a739c37e8e --- /dev/null +++ b/Lang/Fortran/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Totient-function b/Lang/Fortran/Totient-function new file mode 120000 index 0000000000..2559e22f69 --- /dev/null +++ b/Lang/Fortran/Totient-function @@ -0,0 +1 @@ +../../Task/Totient-function/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Twos-complement b/Lang/Fortran/Twos-complement new file mode 120000 index 0000000000..b8e6672d37 --- /dev/null +++ b/Lang/Fortran/Twos-complement @@ -0,0 +1 @@ +../../Task/Twos-complement/Fortran \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Abstract-type b/Lang/Free-Pascal-Lazarus/Abstract-type new file mode 120000 index 0000000000..89db3c6334 --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Cistercian-numerals b/Lang/Free-Pascal-Lazarus/Cistercian-numerals new file mode 120000 index 0000000000..e09b44b1be --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Cistercian-numerals @@ -0,0 +1 @@ +../../Task/Cistercian-numerals/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Pancake-numbers b/Lang/Free-Pascal-Lazarus/Pancake-numbers new file mode 120000 index 0000000000..e82c81624b --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Pancake-numbers @@ -0,0 +1 @@ +../../Task/Pancake-numbers/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/FreeBASIC/Babylonian-spiral b/Lang/FreeBASIC/Babylonian-spiral new file mode 120000 index 0000000000..e141e5d456 --- /dev/null +++ b/Lang/FreeBASIC/Babylonian-spiral @@ -0,0 +1 @@ +../../Task/Babylonian-spiral/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Bitcoin-public-point-to-address b/Lang/FreeBASIC/Bitcoin-public-point-to-address new file mode 120000 index 0000000000..6ff9b61a5b --- /dev/null +++ b/Lang/FreeBASIC/Bitcoin-public-point-to-address @@ -0,0 +1 @@ +../../Task/Bitcoin-public-point-to-address/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Catmull-Clark-subdivision-surface b/Lang/FreeBASIC/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..aa2f6e5ed9 --- /dev/null +++ b/Lang/FreeBASIC/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Color-quantization b/Lang/FreeBASIC/Color-quantization new file mode 120000 index 0000000000..ddc5eaabb7 --- /dev/null +++ b/Lang/FreeBASIC/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Dominoes b/Lang/FreeBASIC/Dominoes new file mode 120000 index 0000000000..46d9dcf5f4 --- /dev/null +++ b/Lang/FreeBASIC/Dominoes @@ -0,0 +1 @@ +../../Task/Dominoes/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Find-duplicate-files b/Lang/FreeBASIC/Find-duplicate-files new file mode 120000 index 0000000000..f2becdf037 --- /dev/null +++ b/Lang/FreeBASIC/Find-duplicate-files @@ -0,0 +1 @@ +../../Task/Find-duplicate-files/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/FreeBASIC/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..90493830d8 --- /dev/null +++ b/Lang/FreeBASIC/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Transliterate-English-text-using-the-Greek-alphabet b/Lang/FreeBASIC/Transliterate-English-text-using-the-Greek-alphabet new file mode 120000 index 0000000000..a3142e6912 --- /dev/null +++ b/Lang/FreeBASIC/Transliterate-English-text-using-the-Greek-alphabet @@ -0,0 +1 @@ +../../Task/Transliterate-English-text-using-the-Greek-alphabet/FreeBASIC \ No newline at end of file diff --git a/Lang/Frink/Disarium-numbers b/Lang/Frink/Disarium-numbers new file mode 120000 index 0000000000..30da6e89d2 --- /dev/null +++ b/Lang/Frink/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Frink \ No newline at end of file diff --git a/Lang/Frink/Happy-numbers b/Lang/Frink/Happy-numbers new file mode 120000 index 0000000000..e83b081fcc --- /dev/null +++ b/Lang/Frink/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Frink \ No newline at end of file diff --git a/Lang/FuncSug/00-LANG.txt b/Lang/FuncSug/00-LANG.txt new file mode 100644 index 0000000000..9239e3a1ef --- /dev/null +++ b/Lang/FuncSug/00-LANG.txt @@ -0,0 +1 @@ +{{stub}}{{language|FuncSug}} \ No newline at end of file diff --git a/Lang/FuncSug/00-META.yaml b/Lang/FuncSug/00-META.yaml new file mode 100644 index 0000000000..0613d9bea7 --- /dev/null +++ b/Lang/FuncSug/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:FuncSug diff --git a/Lang/FuncSug/GUI-component-interaction b/Lang/FuncSug/GUI-component-interaction new file mode 120000 index 0000000000..744e9aac1b --- /dev/null +++ b/Lang/FuncSug/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/GUI-enabling-disabling-of-controls b/Lang/FuncSug/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..049595483a --- /dev/null +++ b/Lang/FuncSug/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/Hello-world-Text b/Lang/FuncSug/Hello-world-Text new file mode 120000 index 0000000000..f188530df7 --- /dev/null +++ b/Lang/FuncSug/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/Play-recorded-sounds b/Lang/FuncSug/Play-recorded-sounds new file mode 120000 index 0000000000..9418947577 --- /dev/null +++ b/Lang/FuncSug/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/Simple-windowed-application b/Lang/FuncSug/Simple-windowed-application new file mode 120000 index 0000000000..8eec686bff --- /dev/null +++ b/Lang/FuncSug/Simple-windowed-application @@ -0,0 +1 @@ +../../Task/Simple-windowed-application/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/Simulate-input-Mouse b/Lang/FuncSug/Simulate-input-Mouse new file mode 120000 index 0000000000..186d49bf08 --- /dev/null +++ b/Lang/FuncSug/Simulate-input-Mouse @@ -0,0 +1 @@ +../../Task/Simulate-input-Mouse/FuncSug \ No newline at end of file diff --git a/Lang/FuncSug/User-input-Graphical b/Lang/FuncSug/User-input-Graphical new file mode 120000 index 0000000000..b685a2412e --- /dev/null +++ b/Lang/FuncSug/User-input-Graphical @@ -0,0 +1 @@ +../../Task/User-input-Graphical/FuncSug \ No newline at end of file diff --git a/Lang/FutureBasic/Arithmetic-Complex b/Lang/FutureBasic/Arithmetic-Complex new file mode 120000 index 0000000000..eab72eafe1 --- /dev/null +++ b/Lang/FutureBasic/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Averages-Mean-time-of-day b/Lang/FutureBasic/Averages-Mean-time-of-day new file mode 120000 index 0000000000..0caef5a9a0 --- /dev/null +++ b/Lang/FutureBasic/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Boyer-Moore-string-search b/Lang/FutureBasic/Boyer-Moore-string-search new file mode 120000 index 0000000000..574c899ddd --- /dev/null +++ b/Lang/FutureBasic/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/CRC-32 b/Lang/FutureBasic/CRC-32 new file mode 120000 index 0000000000..8330772d04 --- /dev/null +++ b/Lang/FutureBasic/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Carmichael-3-strong-pseudoprimes b/Lang/FutureBasic/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..17664f9781 --- /dev/null +++ b/Lang/FutureBasic/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Deal-cards-for-FreeCell b/Lang/FutureBasic/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..b84bfb771c --- /dev/null +++ b/Lang/FutureBasic/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Demings-funnel b/Lang/FutureBasic/Demings-funnel new file mode 120000 index 0000000000..a0b916f84d --- /dev/null +++ b/Lang/FutureBasic/Demings-funnel @@ -0,0 +1 @@ +../../Task/Demings-funnel/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Euler-method b/Lang/FutureBasic/Euler-method new file mode 120000 index 0000000000..89a7e85a03 --- /dev/null +++ b/Lang/FutureBasic/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Find-limit-of-recursion b/Lang/FutureBasic/Find-limit-of-recursion new file mode 120000 index 0000000000..cbc1e3a568 --- /dev/null +++ b/Lang/FutureBasic/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Five-weekends b/Lang/FutureBasic/Five-weekends new file mode 120000 index 0000000000..d11a92b953 --- /dev/null +++ b/Lang/FutureBasic/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Gamma-function b/Lang/FutureBasic/Gamma-function new file mode 120000 index 0000000000..fbf1cf8878 --- /dev/null +++ b/Lang/FutureBasic/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Gaussian-elimination b/Lang/FutureBasic/Gaussian-elimination new file mode 120000 index 0000000000..f8adccdee8 --- /dev/null +++ b/Lang/FutureBasic/Gaussian-elimination @@ -0,0 +1 @@ +../../Task/Gaussian-elimination/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Guess-the-number-With-feedback-player- b/Lang/FutureBasic/Guess-the-number-With-feedback-player- new file mode 120000 index 0000000000..0ee5d26b61 --- /dev/null +++ b/Lang/FutureBasic/Guess-the-number-With-feedback-player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player-/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Hamming-numbers b/Lang/FutureBasic/Hamming-numbers new file mode 120000 index 0000000000..69b0f1ea7d --- /dev/null +++ b/Lang/FutureBasic/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Last-letter-first-letter b/Lang/FutureBasic/Last-letter-first-letter new file mode 120000 index 0000000000..82ed39c3f0 --- /dev/null +++ b/Lang/FutureBasic/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Mayan-numerals b/Lang/FutureBasic/Mayan-numerals new file mode 120000 index 0000000000..cbc6204e00 --- /dev/null +++ b/Lang/FutureBasic/Mayan-numerals @@ -0,0 +1 @@ +../../Task/Mayan-numerals/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Modular-inverse b/Lang/FutureBasic/Modular-inverse new file mode 120000 index 0000000000..89556b3bbe --- /dev/null +++ b/Lang/FutureBasic/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Monte-Carlo-methods b/Lang/FutureBasic/Monte-Carlo-methods new file mode 120000 index 0000000000..729102269f --- /dev/null +++ b/Lang/FutureBasic/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Mutex b/Lang/FutureBasic/Mutex new file mode 120000 index 0000000000..027130dc63 --- /dev/null +++ b/Lang/FutureBasic/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Named-parameters b/Lang/FutureBasic/Named-parameters new file mode 120000 index 0000000000..77a79a818c --- /dev/null +++ b/Lang/FutureBasic/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Perfect-shuffle b/Lang/FutureBasic/Perfect-shuffle new file mode 120000 index 0000000000..6d2e5e3668 --- /dev/null +++ b/Lang/FutureBasic/Perfect-shuffle @@ -0,0 +1 @@ +../../Task/Perfect-shuffle/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sierpinski-pentagon b/Lang/FutureBasic/Sierpinski-pentagon new file mode 120000 index 0000000000..1e105b6fb4 --- /dev/null +++ b/Lang/FutureBasic/Sierpinski-pentagon @@ -0,0 +1 @@ +../../Task/Sierpinski-pentagon/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sleep b/Lang/FutureBasic/Sleep new file mode 120000 index 0000000000..8ce099ff7d --- /dev/null +++ b/Lang/FutureBasic/Sleep @@ -0,0 +1 @@ +../../Task/Sleep/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sorting-algorithms-Insertion-sort b/Lang/FutureBasic/Sorting-algorithms-Insertion-sort new file mode 120000 index 0000000000..d1f91f0286 --- /dev/null +++ b/Lang/FutureBasic/Sorting-algorithms-Insertion-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Insertion-sort/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sorting-algorithms-Sleep-sort b/Lang/FutureBasic/Sorting-algorithms-Sleep-sort new file mode 120000 index 0000000000..b94b39a51d --- /dev/null +++ b/Lang/FutureBasic/Sorting-algorithms-Sleep-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Sleep-sort/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Stack-traces b/Lang/FutureBasic/Stack-traces new file mode 120000 index 0000000000..589e50b2fa --- /dev/null +++ b/Lang/FutureBasic/Stack-traces @@ -0,0 +1 @@ +../../Task/Stack-traces/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/String-length b/Lang/FutureBasic/String-length new file mode 120000 index 0000000000..6df040b0bc --- /dev/null +++ b/Lang/FutureBasic/String-length @@ -0,0 +1 @@ +../../Task/String-length/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sum-of-a-series b/Lang/FutureBasic/Sum-of-a-series new file mode 120000 index 0000000000..44687bc461 --- /dev/null +++ b/Lang/FutureBasic/Sum-of-a-series @@ -0,0 +1 @@ +../../Task/Sum-of-a-series/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Sum-to-100 b/Lang/FutureBasic/Sum-to-100 new file mode 120000 index 0000000000..5cdb7cf4a8 --- /dev/null +++ b/Lang/FutureBasic/Sum-to-100 @@ -0,0 +1 @@ +../../Task/Sum-to-100/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Tau-function b/Lang/FutureBasic/Tau-function new file mode 120000 index 0000000000..4d9cc08c3d --- /dev/null +++ b/Lang/FutureBasic/Tau-function @@ -0,0 +1 @@ +../../Task/Tau-function/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Tau-number b/Lang/FutureBasic/Tau-number new file mode 120000 index 0000000000..363cfbc636 --- /dev/null +++ b/Lang/FutureBasic/Tau-number @@ -0,0 +1 @@ +../../Task/Tau-number/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Word-wrap b/Lang/FutureBasic/Word-wrap new file mode 120000 index 0000000000..d1cd565464 --- /dev/null +++ b/Lang/FutureBasic/Word-wrap @@ -0,0 +1 @@ +../../Task/Word-wrap/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Yellowstone-sequence b/Lang/FutureBasic/Yellowstone-sequence new file mode 120000 index 0000000000..8a816499f6 --- /dev/null +++ b/Lang/FutureBasic/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Zebra-puzzle b/Lang/FutureBasic/Zebra-puzzle new file mode 120000 index 0000000000..68d36dbfcd --- /dev/null +++ b/Lang/FutureBasic/Zebra-puzzle @@ -0,0 +1 @@ +../../Task/Zebra-puzzle/FutureBasic \ No newline at end of file diff --git a/Lang/GW-BASIC/Old-Russian-measure-of-length b/Lang/GW-BASIC/Old-Russian-measure-of-length new file mode 120000 index 0000000000..6121a6a7b1 --- /dev/null +++ b/Lang/GW-BASIC/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/GW-BASIC \ No newline at end of file diff --git a/Lang/Go/Distance-and-Bearing b/Lang/Go/Distance-and-Bearing new file mode 120000 index 0000000000..566b8d5b53 --- /dev/null +++ b/Lang/Go/Distance-and-Bearing @@ -0,0 +1 @@ +../../Task/Distance-and-Bearing/Go \ No newline at end of file diff --git a/Lang/Goboscript/00-LANG.txt b/Lang/Goboscript/00-LANG.txt new file mode 100644 index 0000000000..4cafdccd97 --- /dev/null +++ b/Lang/Goboscript/00-LANG.txt @@ -0,0 +1 @@ +{{stub}}{{language|goboscript}} \ No newline at end of file diff --git a/Lang/Goboscript/00-META.yaml b/Lang/Goboscript/00-META.yaml new file mode 100644 index 0000000000..48464a36ad --- /dev/null +++ b/Lang/Goboscript/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Goboscript diff --git a/Lang/Haskell/00-LANG.txt b/Lang/Haskell/00-LANG.txt index fe49ebce44..9b79cdd879 100644 --- a/Lang/Haskell/00-LANG.txt +++ b/Lang/Haskell/00-LANG.txt @@ -20,5 +20,5 @@ Linspire GNU/[[Linux]] chose Haskell for system tools development. ==Citations== * [[wp:Haskell_%28programming_language%29|Wikipedia:Haskell (programming language)]] -==Todo== -[[Reports:Tasks_not_implemented_in_Haskell]] \ No newline at end of file +==Unimplemented Tasks== +* [[Tasks_not_implemented_in_Haskell|Haskell Unimplemented]] \ No newline at end of file diff --git a/Lang/Haxe/Abstract-type b/Lang/Haxe/Abstract-type new file mode 120000 index 0000000000..6ff9aba1f6 --- /dev/null +++ b/Lang/Haxe/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Apply-a-callback-to-an-array b/Lang/Haxe/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..6fdb21da75 --- /dev/null +++ b/Lang/Haxe/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Arrays b/Lang/Haxe/Arrays new file mode 120000 index 0000000000..bd303e4884 --- /dev/null +++ b/Lang/Haxe/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Associative-array-Creation b/Lang/Haxe/Associative-array-Creation new file mode 120000 index 0000000000..38347f6de6 --- /dev/null +++ b/Lang/Haxe/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Associative-array-Iteration b/Lang/Haxe/Associative-array-Iteration new file mode 120000 index 0000000000..aa7c7951b8 --- /dev/null +++ b/Lang/Haxe/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Binary-digits b/Lang/Haxe/Binary-digits new file mode 120000 index 0000000000..9bf8952c0d --- /dev/null +++ b/Lang/Haxe/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Boolean-values b/Lang/Haxe/Boolean-values new file mode 120000 index 0000000000..b5ef0e7d8b --- /dev/null +++ b/Lang/Haxe/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Call-an-object-method b/Lang/Haxe/Call-an-object-method new file mode 120000 index 0000000000..953d02b76c --- /dev/null +++ b/Lang/Haxe/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Character-codes b/Lang/Haxe/Character-codes new file mode 120000 index 0000000000..92ab060a1a --- /dev/null +++ b/Lang/Haxe/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Classes b/Lang/Haxe/Classes new file mode 120000 index 0000000000..5c922938d4 --- /dev/null +++ b/Lang/Haxe/Classes @@ -0,0 +1 @@ +../../Task/Classes/Haxe \ No newline at end of file diff --git a/Lang/Icon/00-LANG.txt b/Lang/Icon/00-LANG.txt index 6d6b15bfc2..16054a3927 100644 --- a/Lang/Icon/00-LANG.txt +++ b/Lang/Icon/00-LANG.txt @@ -39,5 +39,7 @@ Several extensions of Icon were developed to improve functionality. Many of the * [[Icon%2BUnicon/Intro|An introduction to Icon and Unicon for Rosetta Code]] * [[:Category:Icon/Omit|Unimplementable tasks]] * [[:Category:Icon_examples_needing_attention|Tasks requiring attention]] -* [[Reports:Tasks_not_implemented_in_Icon|Tasks not yet implemented]] -* [[:Category:Icon_Programming_Library|The Icon Programming Library]] \ No newline at end of file +* [[:Category:Icon_Programming_Library|The Icon Programming Library]] + +==Todo== +* [[Tasks not implemented in Icon]] \ No newline at end of file diff --git a/Lang/Icon/Exponentiation-order b/Lang/Icon/Exponentiation-order new file mode 120000 index 0000000000..c87e5174b5 --- /dev/null +++ b/Lang/Icon/Exponentiation-order @@ -0,0 +1 @@ +../../Task/Exponentiation-order/Icon \ No newline at end of file diff --git a/Lang/Icon/Jewels-and-stones b/Lang/Icon/Jewels-and-stones new file mode 120000 index 0000000000..5dee8d7cee --- /dev/null +++ b/Lang/Icon/Jewels-and-stones @@ -0,0 +1 @@ +../../Task/Jewels-and-stones/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Wrong-ranges b/Lang/Icon/Loops-Wrong-ranges new file mode 120000 index 0000000000..0317af2079 --- /dev/null +++ b/Lang/Icon/Loops-Wrong-ranges @@ -0,0 +1 @@ +../../Task/Loops-Wrong-ranges/Icon \ No newline at end of file diff --git a/Lang/Icon/Search-a-list-of-records b/Lang/Icon/Search-a-list-of-records new file mode 120000 index 0000000000..b796eca599 --- /dev/null +++ b/Lang/Icon/Search-a-list-of-records @@ -0,0 +1 @@ +../../Task/Search-a-list-of-records/Icon \ No newline at end of file diff --git a/Lang/Icon/Sort-numbers-lexicographically b/Lang/Icon/Sort-numbers-lexicographically new file mode 120000 index 0000000000..7c99f7d928 --- /dev/null +++ b/Lang/Icon/Sort-numbers-lexicographically @@ -0,0 +1 @@ +../../Task/Sort-numbers-lexicographically/Icon \ No newline at end of file diff --git a/Lang/Icon/Tokenize-a-string-with-escaping b/Lang/Icon/Tokenize-a-string-with-escaping new file mode 120000 index 0000000000..6a5856de9c --- /dev/null +++ b/Lang/Icon/Tokenize-a-string-with-escaping @@ -0,0 +1 @@ +../../Task/Tokenize-a-string-with-escaping/Icon \ No newline at end of file diff --git a/Lang/Icon/Tree-from-nesting-levels b/Lang/Icon/Tree-from-nesting-levels new file mode 120000 index 0000000000..670d6ecf62 --- /dev/null +++ b/Lang/Icon/Tree-from-nesting-levels @@ -0,0 +1 @@ +../../Task/Tree-from-nesting-levels/Icon \ No newline at end of file diff --git a/Lang/Idris/Comments b/Lang/Idris/Comments new file mode 120000 index 0000000000..ffaead275c --- /dev/null +++ b/Lang/Idris/Comments @@ -0,0 +1 @@ +../../Task/Comments/Idris \ No newline at end of file diff --git a/Lang/Insitux/00-LANG.txt b/Lang/Insitux/00-LANG.txt index ffe7dc9e9e..b852a0706e 100644 --- a/Lang/Insitux/00-LANG.txt +++ b/Lang/Insitux/00-LANG.txt @@ -3,10 +3,8 @@ |hopl=no |tags=insitux}} -Insitux (pronounced /ɪnˈsɪtjuːɪks/) is a dynamically-typed functional scripting language inspired by Clojure, originally commissioned in July 2021 for safe and extensible in-game scripting in a popular Roblox game. It has retained compatibility with Roblox by using two sets of "poly-fills" between [https://roblox-ts.com/ roblox-ts] and Node.js / web, meaning it can target Roblox, Node.js, and web with two slightly varying codebases. +Insitux (pronounced /ɪnˈsɪtjuːɪks/) is a dynamically-typed functional scripting language inspired by Clojure, originally commissioned in July 2021 for safe and extensible in-game scripting in a popular Roblox game. It now targets Node.js/Bun and client-side web. -Despite its origins it is a capable language, with development focusing on the language itself, its Node.js ecosystem, and to a lesser extent its web ecosystem. This primarily involves adding to the already 200+ built-in operations, which tend to cause existing Insitux programs to shrink in size over time. - -Insitux currently does not have a performance focus, and due to its syntactic flexibility, and its engine being transpiled into both JavaScript and [https://luau-lang.org/ Luau], it is difficult to optimise. Eventually Roblox support will be dropped / forked, pivoting mainline Insitux into AOT and JIT JavaScript transpilation. +Despite its origins it is a capable language, with development focusing on the language itself, its Node.js ecosystem, and to a lesser extent its web ecosystem. This primarily involves adding to the already 200+ built-in operations, which tend to cause existing Insitux programs to shrink in size over time; and improving language performance since dropping Roblox compatibility in 2024. {{language programming paradigm|functional}} \ No newline at end of file diff --git a/Lang/Janet/Comments b/Lang/Janet/Comments new file mode 120000 index 0000000000..b5297d4f4d --- /dev/null +++ b/Lang/Janet/Comments @@ -0,0 +1 @@ +../../Task/Comments/Janet \ No newline at end of file diff --git a/Lang/JavaScript/Aliquot-sequence-classifications b/Lang/JavaScript/Aliquot-sequence-classifications new file mode 120000 index 0000000000..5043f9bf29 --- /dev/null +++ b/Lang/JavaScript/Aliquot-sequence-classifications @@ -0,0 +1 @@ +../../Task/Aliquot-sequence-classifications/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/B-zier-curves-Intersections b/Lang/JavaScript/B-zier-curves-Intersections new file mode 120000 index 0000000000..e14b622f07 --- /dev/null +++ b/Lang/JavaScript/B-zier-curves-Intersections @@ -0,0 +1 @@ +../../Task/B-zier-curves-Intersections/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Balanced-ternary b/Lang/JavaScript/Balanced-ternary new file mode 120000 index 0000000000..c71298b653 --- /dev/null +++ b/Lang/JavaScript/Balanced-ternary @@ -0,0 +1 @@ +../../Task/Balanced-ternary/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Bitcoin-public-point-to-address b/Lang/JavaScript/Bitcoin-public-point-to-address new file mode 120000 index 0000000000..c3f037151b --- /dev/null +++ b/Lang/JavaScript/Bitcoin-public-point-to-address @@ -0,0 +1 @@ +../../Task/Bitcoin-public-point-to-address/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Break-OO-privacy b/Lang/JavaScript/Break-OO-privacy new file mode 120000 index 0000000000..085d7969ff --- /dev/null +++ b/Lang/JavaScript/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Catmull-Clark-subdivision-surface b/Lang/JavaScript/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..40bf4ef0fc --- /dev/null +++ b/Lang/JavaScript/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Checkpoint-synchronization b/Lang/JavaScript/Checkpoint-synchronization new file mode 120000 index 0000000000..cf18aef6aa --- /dev/null +++ b/Lang/JavaScript/Checkpoint-synchronization @@ -0,0 +1 @@ +../../Task/Checkpoint-synchronization/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Continued-fraction b/Lang/JavaScript/Continued-fraction new file mode 120000 index 0000000000..73bc586c57 --- /dev/null +++ b/Lang/JavaScript/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/JavaScript/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..95862446c9 --- /dev/null +++ b/Lang/JavaScript/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Deconvolution-1D b/Lang/JavaScript/Deconvolution-1D new file mode 120000 index 0000000000..719c208ec2 --- /dev/null +++ b/Lang/JavaScript/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Deconvolution-2D+ b/Lang/JavaScript/Deconvolution-2D+ new file mode 120000 index 0000000000..61f93d9cd6 --- /dev/null +++ b/Lang/JavaScript/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/MD5 b/Lang/JavaScript/MD5 new file mode 120000 index 0000000000..764b1e5dd2 --- /dev/null +++ b/Lang/JavaScript/MD5 @@ -0,0 +1 @@ +../../Task/MD5/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Meissel-Mertens-constant b/Lang/JavaScript/Meissel-Mertens-constant new file mode 120000 index 0000000000..8dd5c0b197 --- /dev/null +++ b/Lang/JavaScript/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Parse-an-IP-Address b/Lang/JavaScript/Parse-an-IP-Address new file mode 120000 index 0000000000..5981d2ba9f --- /dev/null +++ b/Lang/JavaScript/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Pascals-triangle-Puzzle b/Lang/JavaScript/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..2acf8cdb4d --- /dev/null +++ b/Lang/JavaScript/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Sokoban b/Lang/JavaScript/Sokoban new file mode 120000 index 0000000000..3ab86467bd --- /dev/null +++ b/Lang/JavaScript/Sokoban @@ -0,0 +1 @@ +../../Task/Sokoban/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Solve-a-Hopido-puzzle b/Lang/JavaScript/Solve-a-Hopido-puzzle new file mode 120000 index 0000000000..aea3983b76 --- /dev/null +++ b/Lang/JavaScript/Solve-a-Hopido-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Hopido-puzzle/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Superpermutation-minimisation b/Lang/JavaScript/Superpermutation-minimisation new file mode 120000 index 0000000000..a257c8e7e7 --- /dev/null +++ b/Lang/JavaScript/Superpermutation-minimisation @@ -0,0 +1 @@ +../../Task/Superpermutation-minimisation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Tarjan b/Lang/JavaScript/Tarjan new file mode 120000 index 0000000000..c299c7aebb --- /dev/null +++ b/Lang/JavaScript/Tarjan @@ -0,0 +1 @@ +../../Task/Tarjan/JavaScript \ No newline at end of file diff --git a/Lang/Julia/OLE-automation b/Lang/Julia/OLE-automation new file mode 120000 index 0000000000..58b1722653 --- /dev/null +++ b/Lang/Julia/OLE-automation @@ -0,0 +1 @@ +../../Task/OLE-automation/Julia \ No newline at end of file diff --git a/Lang/Julia/Simulate-input-Keyboard b/Lang/Julia/Simulate-input-Keyboard new file mode 120000 index 0000000000..79cc3689e4 --- /dev/null +++ b/Lang/Julia/Simulate-input-Keyboard @@ -0,0 +1 @@ +../../Task/Simulate-input-Keyboard/Julia \ No newline at end of file diff --git a/Lang/Julia/Use-another-language-to-call-a-function b/Lang/Julia/Use-another-language-to-call-a-function new file mode 120000 index 0000000000..c21a8c88ad --- /dev/null +++ b/Lang/Julia/Use-another-language-to-call-a-function @@ -0,0 +1 @@ +../../Task/Use-another-language-to-call-a-function/Julia \ No newline at end of file diff --git a/Lang/Kantalo/00-LANG.txt b/Lang/Kantalo/00-LANG.txt new file mode 100644 index 0000000000..453580c58d --- /dev/null +++ b/Lang/Kantalo/00-LANG.txt @@ -0,0 +1,40 @@ +{{language|Kantalo +|version=0.0.2 +|exec=interpreted +|strength=weak +|express=explicit +|checking=dynamic +|gc=yes +|tags=Kantalo,Language +|LCT=yes +|hopl=no +|safety=unsafe +|site=http://kantalo.kesug.com/}} + +=={{header|Kantalo}}== + +Kantalo is a non-object-oriented programming language, with the aim of making it easier to use. + +==Main commands== + +Here are some kantalo commands: + +
  • var.save - It is used to define variable.
  • +
  • var.import - Import variable outside functions.
  • +
  • var.edit - Edit an Existing Variable.
  • +
  • terminal.text - Returns a message passed within the argument.
  • +
  • terminal.input - Creates a text input.
  • +
  • if- Used to create conditions .
  • +
  • func - It is used to create functions.
  • +
  • execute - Performs functions.
  • + +
    +Simple Hello world with kantalo: +
    + +var.save nome = "Alice", +func saudacao > ( + terminal.text("Seja bem-vindo(a), -*nome*-!") +) +execute saudacao + \ No newline at end of file diff --git a/Lang/Kantalo/00-META.yaml b/Lang/Kantalo/00-META.yaml new file mode 100644 index 0000000000..c7d465ac08 --- /dev/null +++ b/Lang/Kantalo/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Kantalo diff --git a/Lang/Koka/00-LANG.txt b/Lang/Koka/00-LANG.txt index 96ea39de13..540a8fe180 100644 --- a/Lang/Koka/00-LANG.txt +++ b/Lang/Koka/00-LANG.txt @@ -3,7 +3,7 @@ Releases: - https://github.com/koka-lang/koka/releases -Latest: v2.4.2 +Latest: v3.1.3 '''Language Reference''' diff --git a/Lang/Koka/A+B b/Lang/Koka/A+B new file mode 120000 index 0000000000..5fcfbb2462 --- /dev/null +++ b/Lang/Koka/A+B @@ -0,0 +1 @@ +../../Task/A+B/Koka \ No newline at end of file diff --git a/Lang/Koka/Extend-your-language b/Lang/Koka/Extend-your-language new file mode 120000 index 0000000000..fa9d061610 --- /dev/null +++ b/Lang/Koka/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Koka \ No newline at end of file diff --git a/Lang/Koka/Jump-anywhere b/Lang/Koka/Jump-anywhere new file mode 120000 index 0000000000..39d5f8124d --- /dev/null +++ b/Lang/Koka/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/Koka \ No newline at end of file diff --git a/Lang/Koka/Letter-frequency b/Lang/Koka/Letter-frequency new file mode 120000 index 0000000000..35e2486b2e --- /dev/null +++ b/Lang/Koka/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Koka \ No newline at end of file diff --git a/Lang/Koka/Loops-Break b/Lang/Koka/Loops-Break new file mode 120000 index 0000000000..21d8774db0 --- /dev/null +++ b/Lang/Koka/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Koka \ No newline at end of file diff --git a/Lang/Koka/Monads-Writer-monad b/Lang/Koka/Monads-Writer-monad new file mode 120000 index 0000000000..21e3e4c596 --- /dev/null +++ b/Lang/Koka/Monads-Writer-monad @@ -0,0 +1 @@ +../../Task/Monads-Writer-monad/Koka \ No newline at end of file diff --git a/Lang/Kotlin/Boyer-Moore-string-search b/Lang/Kotlin/Boyer-Moore-string-search new file mode 120000 index 0000000000..985c6560bd --- /dev/null +++ b/Lang/Kotlin/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/Kotlin \ No newline at end of file diff --git a/Lang/Labyrinth/00-LANG.txt b/Lang/Labyrinth/00-LANG.txt new file mode 100644 index 0000000000..6b7624f3ac --- /dev/null +++ b/Lang/Labyrinth/00-LANG.txt @@ -0,0 +1 @@ +{{stub}}{{language|site=https://github.com/m-ender/labyrinth}} \ No newline at end of file diff --git a/Lang/Labyrinth/00-META.yaml b/Lang/Labyrinth/00-META.yaml new file mode 100644 index 0000000000..2e09fd26db --- /dev/null +++ b/Lang/Labyrinth/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Labyrinth diff --git a/Lang/Liberty-BASIC/Hunt-the-Wumpus b/Lang/Liberty-BASIC/Hunt-the-Wumpus new file mode 120000 index 0000000000..4e2d0e150d --- /dev/null +++ b/Lang/Liberty-BASIC/Hunt-the-Wumpus @@ -0,0 +1 @@ +../../Task/Hunt-the-Wumpus/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Minesweeper-game b/Lang/Liberty-BASIC/Minesweeper-game new file mode 120000 index 0000000000..19abfc9a07 --- /dev/null +++ b/Lang/Liberty-BASIC/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Snake b/Lang/Liberty-BASIC/Snake new file mode 120000 index 0000000000..20a60d8427 --- /dev/null +++ b/Lang/Liberty-BASIC/Snake @@ -0,0 +1 @@ +../../Task/Snake/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Logo/Sparkline-in-unicode b/Lang/Logo/Sparkline-in-unicode new file mode 120000 index 0000000000..d2b466f59a --- /dev/null +++ b/Lang/Logo/Sparkline-in-unicode @@ -0,0 +1 @@ +../../Task/Sparkline-in-unicode/Logo \ No newline at end of file diff --git a/Lang/Lua/100-doors b/Lang/Lua/100-doors deleted file mode 120000 index ce373fa8af..0000000000 --- a/Lang/Lua/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/Lua \ No newline at end of file diff --git a/Lang/Lua/Jacobsthal-numbers b/Lang/Lua/Jacobsthal-numbers new file mode 120000 index 0000000000..ff787752c3 --- /dev/null +++ b/Lang/Lua/Jacobsthal-numbers @@ -0,0 +1 @@ +../../Task/Jacobsthal-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Knapsack-problem-Bounded b/Lang/Lua/Knapsack-problem-Bounded new file mode 120000 index 0000000000..edddb60b00 --- /dev/null +++ b/Lang/Lua/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Lua \ No newline at end of file diff --git a/Lang/Lua/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Lua/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..63a3cd2cf9 --- /dev/null +++ b/Lang/Lua/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Lua \ No newline at end of file diff --git a/Lang/Lua/Use-another-language-to-call-a-function b/Lang/Lua/Use-another-language-to-call-a-function new file mode 120000 index 0000000000..05e8f054e4 --- /dev/null +++ b/Lang/Lua/Use-another-language-to-call-a-function @@ -0,0 +1 @@ +../../Task/Use-another-language-to-call-a-function/Lua \ No newline at end of file diff --git a/Lang/Lua/Wagstaff-primes b/Lang/Lua/Wagstaff-primes new file mode 120000 index 0000000000..c8cec659a4 --- /dev/null +++ b/Lang/Lua/Wagstaff-primes @@ -0,0 +1 @@ +../../Task/Wagstaff-primes/Lua \ No newline at end of file diff --git a/Lang/Lua/Wieferich-primes b/Lang/Lua/Wieferich-primes new file mode 120000 index 0000000000..ac68d34377 --- /dev/null +++ b/Lang/Lua/Wieferich-primes @@ -0,0 +1 @@ +../../Task/Wieferich-primes/Lua \ No newline at end of file diff --git a/Lang/Mathematica/ASCII-art-diagram-converter b/Lang/Mathematica/ASCII-art-diagram-converter new file mode 120000 index 0000000000..1006da4cf6 --- /dev/null +++ b/Lang/Mathematica/ASCII-art-diagram-converter @@ -0,0 +1 @@ +../../Task/ASCII-art-diagram-converter/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Camel-case-and-snake-case b/Lang/Mathematica/Camel-case-and-snake-case new file mode 120000 index 0000000000..6d73876132 --- /dev/null +++ b/Lang/Mathematica/Camel-case-and-snake-case @@ -0,0 +1 @@ +../../Task/Camel-case-and-snake-case/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Erd-s-Nicolas-numbers b/Lang/Mathematica/Erd-s-Nicolas-numbers new file mode 120000 index 0000000000..d74b7bd3b7 --- /dev/null +++ b/Lang/Mathematica/Erd-s-Nicolas-numbers @@ -0,0 +1 @@ +../../Task/Erd-s-Nicolas-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Parse-an-IP-Address b/Lang/Mathematica/Parse-an-IP-Address new file mode 120000 index 0000000000..32b7086e88 --- /dev/null +++ b/Lang/Mathematica/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Tonelli-Shanks-algorithm b/Lang/Mathematica/Tonelli-Shanks-algorithm new file mode 120000 index 0000000000..747956daa4 --- /dev/null +++ b/Lang/Mathematica/Tonelli-Shanks-algorithm @@ -0,0 +1 @@ +../../Task/Tonelli-Shanks-algorithm/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Vogels-approximation-method b/Lang/Mathematica/Vogels-approximation-method new file mode 120000 index 0000000000..2d01457a6e --- /dev/null +++ b/Lang/Mathematica/Vogels-approximation-method @@ -0,0 +1 @@ +../../Task/Vogels-approximation-method/Mathematica \ No newline at end of file diff --git a/Lang/Maxima/Array-length b/Lang/Maxima/Array-length new file mode 120000 index 0000000000..da5c3a4dcd --- /dev/null +++ b/Lang/Maxima/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Delete-a-file b/Lang/Maxima/Delete-a-file new file mode 120000 index 0000000000..9515074358 --- /dev/null +++ b/Lang/Maxima/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Hash-from-two-arrays b/Lang/Maxima/Hash-from-two-arrays new file mode 120000 index 0000000000..b59b47ec09 --- /dev/null +++ b/Lang/Maxima/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Real-constants-and-functions b/Lang/Maxima/Real-constants-and-functions new file mode 120000 index 0000000000..5465f4ddf0 --- /dev/null +++ b/Lang/Maxima/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Regular-expressions b/Lang/Maxima/Regular-expressions new file mode 120000 index 0000000000..ad80bc2114 --- /dev/null +++ b/Lang/Maxima/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Rename-a-file b/Lang/Maxima/Rename-a-file new file mode 120000 index 0000000000..875c72e05d --- /dev/null +++ b/Lang/Maxima/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Sorting-algorithms-Stooge-sort b/Lang/Maxima/Sorting-algorithms-Stooge-sort new file mode 120000 index 0000000000..df60525c6e --- /dev/null +++ b/Lang/Maxima/Sorting-algorithms-Stooge-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Stooge-sort/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Statistics-Basic b/Lang/Maxima/Statistics-Basic new file mode 120000 index 0000000000..3aa4fcf62d --- /dev/null +++ b/Lang/Maxima/Statistics-Basic @@ -0,0 +1 @@ +../../Task/Statistics-Basic/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Substring-Top-and-tail b/Lang/Maxima/Substring-Top-and-tail new file mode 120000 index 0000000000..6897859615 --- /dev/null +++ b/Lang/Maxima/Substring-Top-and-tail @@ -0,0 +1 @@ +../../Task/Substring-Top-and-tail/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Superellipse b/Lang/Maxima/Superellipse new file mode 120000 index 0000000000..4ecd2801c8 --- /dev/null +++ b/Lang/Maxima/Superellipse @@ -0,0 +1 @@ +../../Task/Superellipse/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Topic-variable b/Lang/Maxima/Topic-variable new file mode 120000 index 0000000000..e2a8f808d7 --- /dev/null +++ b/Lang/Maxima/Topic-variable @@ -0,0 +1 @@ +../../Task/Topic-variable/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Towers-of-Hanoi b/Lang/Maxima/Towers-of-Hanoi new file mode 120000 index 0000000000..40963f2edb --- /dev/null +++ b/Lang/Maxima/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/Maxima \ No newline at end of file diff --git a/Lang/Mn/00-LANG.txt b/Lang/Mn/00-LANG.txt new file mode 100644 index 0000000000..0fd90d2c3a --- /dev/null +++ b/Lang/Mn/00-LANG.txt @@ -0,0 +1,7 @@ +{{stub}}{{language|mn}} +mn is a minimalistic, concatenative, functional stack language. It is a very simple subset of [[min]]. + +==Links== +*[https://h3rald.com/mn/Mn_DeveloperGuide.htm Learn mn] + +{{Language programming paradigm|Concatenative}} \ No newline at end of file diff --git a/Lang/Mn/00-META.yaml b/Lang/Mn/00-META.yaml new file mode 100644 index 0000000000..f79f1602c3 --- /dev/null +++ b/Lang/Mn/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Mn diff --git a/Lang/Mn/Factorial b/Lang/Mn/Factorial new file mode 120000 index 0000000000..4c7a3c3b43 --- /dev/null +++ b/Lang/Mn/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Mn \ No newline at end of file diff --git a/Lang/Mn/Loops-While b/Lang/Mn/Loops-While new file mode 120000 index 0000000000..9e10aebd40 --- /dev/null +++ b/Lang/Mn/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Mn \ No newline at end of file diff --git a/Lang/Modula-2/AKS-test-for-primes b/Lang/Modula-2/AKS-test-for-primes new file mode 120000 index 0000000000..f86ed2a172 --- /dev/null +++ b/Lang/Modula-2/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Cistercian-numerals b/Lang/Modula-2/Cistercian-numerals new file mode 120000 index 0000000000..5da4e51fc7 --- /dev/null +++ b/Lang/Modula-2/Cistercian-numerals @@ -0,0 +1 @@ +../../Task/Cistercian-numerals/Modula-2 \ No newline at end of file diff --git a/Lang/Mojo/Hunt-the-Wumpus b/Lang/Mojo/Hunt-the-Wumpus new file mode 120000 index 0000000000..a79c86df71 --- /dev/null +++ b/Lang/Mojo/Hunt-the-Wumpus @@ -0,0 +1 @@ +../../Task/Hunt-the-Wumpus/Mojo \ No newline at end of file diff --git a/Lang/Nascom-BASIC/Old-Russian-measure-of-length b/Lang/Nascom-BASIC/Old-Russian-measure-of-length new file mode 120000 index 0000000000..73ef2957e7 --- /dev/null +++ b/Lang/Nascom-BASIC/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/Nascom-BASIC \ No newline at end of file diff --git a/Lang/Nom/00-LANG.txt b/Lang/Nom/00-LANG.txt new file mode 100644 index 0000000000..596e8bc965 --- /dev/null +++ b/Lang/Nom/00-LANG.txt @@ -0,0 +1,18 @@ +{{language|Nom}} + +Nom is an interpreted and also compiling (via the translation scripts) +language. Documentation for ''Nom'' can be found at [www.nomlang.org] along +with the downloadable [http://nomlang.org/download implementation]. +All the source code is also hosted in [https://sourceforge.net sourceforge] +at https://bumble.sf.net/books/pars/ + +Nom is based on the PEP (''Parsing Engine for Patterns'') virtual machine, +which is a text-based virtual machine. The PEP virtual machine is +documented at [http://nomlang.org/doc/machine/]. Nom was first ''conceived'' +around about 2005 but a good working implementation (the +[https://bumble.sf.net/books/pars/object/pep.c pep] interpreter) was not +achieved until approximately 2019. + +Nom is, I believe a new approach to recognising/parsing/transforming/transpiling/compiling context-free languages +since it uses the same standard Unix-style approach of a ''text-stream-filter'' +as with tools like ''sed'' or ''awk''. \ No newline at end of file diff --git a/Lang/Nom/00-META.yaml b/Lang/Nom/00-META.yaml new file mode 100644 index 0000000000..347649abaa --- /dev/null +++ b/Lang/Nom/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Nom diff --git a/Lang/Nom/Balanced-brackets b/Lang/Nom/Balanced-brackets new file mode 120000 index 0000000000..53c6847c48 --- /dev/null +++ b/Lang/Nom/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Nom \ No newline at end of file diff --git a/Lang/Nom/CSV-to-HTML-translation b/Lang/Nom/CSV-to-HTML-translation new file mode 120000 index 0000000000..efc535b187 --- /dev/null +++ b/Lang/Nom/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Nom \ No newline at end of file diff --git a/Lang/Nom/Determine-if-a-string-is-numeric b/Lang/Nom/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..dc0b5a67ea --- /dev/null +++ b/Lang/Nom/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Nom \ No newline at end of file diff --git a/Lang/Nom/Empty-string b/Lang/Nom/Empty-string new file mode 120000 index 0000000000..e51cf14c29 --- /dev/null +++ b/Lang/Nom/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Nom \ No newline at end of file diff --git a/Lang/Nom/Even-or-odd b/Lang/Nom/Even-or-odd new file mode 120000 index 0000000000..a93a39c338 --- /dev/null +++ b/Lang/Nom/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Nom \ No newline at end of file diff --git a/Lang/Nom/Hello-world-Text b/Lang/Nom/Hello-world-Text new file mode 120000 index 0000000000..6575bd7149 --- /dev/null +++ b/Lang/Nom/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Nom \ No newline at end of file diff --git a/Lang/Nom/Input-loop b/Lang/Nom/Input-loop new file mode 120000 index 0000000000..c687c9a3a9 --- /dev/null +++ b/Lang/Nom/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Nom \ No newline at end of file diff --git a/Lang/Nom/Odd-word-problem b/Lang/Nom/Odd-word-problem new file mode 120000 index 0000000000..43979a4bb7 --- /dev/null +++ b/Lang/Nom/Odd-word-problem @@ -0,0 +1 @@ +../../Task/Odd-word-problem/Nom \ No newline at end of file diff --git a/Lang/Nom/Reverse-a-string b/Lang/Nom/Reverse-a-string new file mode 120000 index 0000000000..38692d6625 --- /dev/null +++ b/Lang/Nom/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Nom \ No newline at end of file diff --git a/Lang/OCaml/Parse-an-IP-Address b/Lang/OCaml/Parse-an-IP-Address new file mode 120000 index 0000000000..f01fc56f01 --- /dev/null +++ b/Lang/OCaml/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Sorting-algorithms-Sleep-sort b/Lang/OCaml/Sorting-algorithms-Sleep-sort new file mode 120000 index 0000000000..1cc75210f7 --- /dev/null +++ b/Lang/OCaml/Sorting-algorithms-Sleep-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Sleep-sort/OCaml \ No newline at end of file diff --git a/Lang/Objeck/Catalan-numbers-Pascals-triangle b/Lang/Objeck/Catalan-numbers-Pascals-triangle new file mode 120000 index 0000000000..bc3c684d61 --- /dev/null +++ b/Lang/Objeck/Catalan-numbers-Pascals-triangle @@ -0,0 +1 @@ +../../Task/Catalan-numbers-Pascals-triangle/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Disarium-numbers b/Lang/Objeck/Disarium-numbers new file mode 120000 index 0000000000..bc58c40d5c --- /dev/null +++ b/Lang/Objeck/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Objeck \ No newline at end of file diff --git a/Lang/Objeck/HTTPS-Client-authenticated b/Lang/Objeck/HTTPS-Client-authenticated new file mode 120000 index 0000000000..6f56878ef9 --- /dev/null +++ b/Lang/Objeck/HTTPS-Client-authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Client-authenticated/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Magic-squares-of-doubly-even-order b/Lang/Objeck/Magic-squares-of-doubly-even-order new file mode 120000 index 0000000000..526cd66745 --- /dev/null +++ b/Lang/Objeck/Magic-squares-of-doubly-even-order @@ -0,0 +1 @@ +../../Task/Magic-squares-of-doubly-even-order/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Matrix-multiplication b/Lang/Objeck/Matrix-multiplication new file mode 120000 index 0000000000..e2801343eb --- /dev/null +++ b/Lang/Objeck/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Objeck \ No newline at end of file diff --git a/Lang/Object-Pascal-Implementations/00-LANG.txt b/Lang/Object-Pascal-Implementations/00-LANG.txt new file mode 100644 index 0000000000..74167ef7a7 --- /dev/null +++ b/Lang/Object-Pascal-Implementations/00-LANG.txt @@ -0,0 +1,3 @@ +{{language|Object Pascal}} +{{implementation cat|Object Pascal}} +{{implementation|Pascal}} \ No newline at end of file diff --git a/Lang/Object-Pascal-Implementations/00-META.yaml b/Lang/Object-Pascal-Implementations/00-META.yaml new file mode 100644 index 0000000000..34f0628a46 --- /dev/null +++ b/Lang/Object-Pascal-Implementations/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Object_Pascal_Implementations diff --git a/Lang/Odin/Comments b/Lang/Odin/Comments new file mode 120000 index 0000000000..69505856e6 --- /dev/null +++ b/Lang/Odin/Comments @@ -0,0 +1 @@ +../../Task/Comments/Odin \ No newline at end of file diff --git a/Lang/OoRexx/Prime-decomposition b/Lang/OoRexx/Prime-decomposition new file mode 120000 index 0000000000..f16b4825fb --- /dev/null +++ b/Lang/OoRexx/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/OoRexx \ No newline at end of file diff --git a/Lang/OxygenBasic/Josephus-problem b/Lang/OxygenBasic/Josephus-problem new file mode 120000 index 0000000000..26c79416e6 --- /dev/null +++ b/Lang/OxygenBasic/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/OxygenBasic \ No newline at end of file diff --git a/Lang/PARI-GP/Pell-numbers b/Lang/PARI-GP/Pell-numbers new file mode 120000 index 0000000000..6dc31a644a --- /dev/null +++ b/Lang/PARI-GP/Pell-numbers @@ -0,0 +1 @@ +../../Task/Pell-numbers/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Tonelli-Shanks-algorithm b/Lang/PARI-GP/Tonelli-Shanks-algorithm new file mode 120000 index 0000000000..de551c5a5b --- /dev/null +++ b/Lang/PARI-GP/Tonelli-Shanks-algorithm @@ -0,0 +1 @@ +../../Task/Tonelli-Shanks-algorithm/PARI-GP \ No newline at end of file diff --git a/Lang/PHP/AKS-test-for-primes b/Lang/PHP/AKS-test-for-primes new file mode 120000 index 0000000000..e35d324f89 --- /dev/null +++ b/Lang/PHP/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/PHP \ No newline at end of file diff --git a/Lang/PL-M/100-doors b/Lang/PL-M/100-doors deleted file mode 120000 index fb7e956c0e..0000000000 --- a/Lang/PL-M/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/PL-M \ No newline at end of file diff --git a/Lang/Pascal-P/00-LANG.txt b/Lang/Pascal-P/00-LANG.txt new file mode 100644 index 0000000000..ce87f461ab --- /dev/null +++ b/Lang/Pascal-P/00-LANG.txt @@ -0,0 +1,23 @@ +{{language|Pascal-P +|exec=bytecode +|strength=strong +|safety=safe +|express=explicit +|checking=static +|parampass=both +|gc=no +|LCT=yes +}}{{language programming paradigm|Procedural}} + +{{implementation|Pascal}}{{Compiler}} + +'''Pascal-P''' is a renowned [[:Category:Pascal|Pascal]] compiler designed to generate [[bytecode]], known as ''p-code'', and interpret the resulting code. The compilers and interpreters of Pascal-P are developed using the Pascal programming language. + +Originally developed in Zurich in 1973, the earliest iteration of Pascal-P, known as Pascal-P1, laid the foundation for subsequent versions, including P2, P3, and P4. While versions P1 and P3 are no longer accessible, P2 is still readily available and has notably served as the base for the UCSD system. Furthermore, there exist derivative versions, such as P5 and P6, which have evolved from the core Pascal-P compiler. + +Notably, Pascal-P is heralded for its portability, as it is capable of generating code suitable for a hypothetical stack computer system. This feature enhances its versatility and applicability across various platforms and environments. Additionally, Pascal-P has made significant contributions to the realm of education, often being utilized as an educational tool to impart knowledge and foster learning in the field of computer programming. + +== External links == +* [http://pascal.hansotten.com/niklaus-wirth/px-compilers Px compilers] on [http://pascal.hansotten.com/ Pascal for small machines] +* [https://sourceforge.net/projects/pascalp4/ Scott Moore's version of P4] The package includes crucial components essential for program execution on the MS-DOS platform - the compiler and the p-code interpreter executables. +* [https://www.moorecad.com/standardpascal/p4.html The P4 compiler] on [https://www.moorecad.com/ Scott Moore's page] \ No newline at end of file diff --git a/Lang/Pascal-P/00-META.yaml b/Lang/Pascal-P/00-META.yaml new file mode 100644 index 0000000000..5af4159a1f --- /dev/null +++ b/Lang/Pascal-P/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Pascal-P diff --git a/Lang/Pascal-P/Cistercian-numerals b/Lang/Pascal-P/Cistercian-numerals new file mode 120000 index 0000000000..3169bb4737 --- /dev/null +++ b/Lang/Pascal-P/Cistercian-numerals @@ -0,0 +1 @@ +../../Task/Cistercian-numerals/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/FizzBuzz b/Lang/Pascal-P/FizzBuzz new file mode 120000 index 0000000000..8d0c857c1d --- /dev/null +++ b/Lang/Pascal-P/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/Leonardo-numbers b/Lang/Pascal-P/Leonardo-numbers new file mode 120000 index 0000000000..33730eb927 --- /dev/null +++ b/Lang/Pascal-P/Leonardo-numbers @@ -0,0 +1 @@ +../../Task/Leonardo-numbers/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/Levenshtein-distance b/Lang/Pascal-P/Levenshtein-distance new file mode 120000 index 0000000000..369c4fda51 --- /dev/null +++ b/Lang/Pascal-P/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/M-bius-function b/Lang/Pascal-P/M-bius-function new file mode 120000 index 0000000000..5ac8d7d007 --- /dev/null +++ b/Lang/Pascal-P/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/Magic-constant b/Lang/Pascal-P/Magic-constant new file mode 120000 index 0000000000..d71a46b136 --- /dev/null +++ b/Lang/Pascal-P/Magic-constant @@ -0,0 +1 @@ +../../Task/Magic-constant/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/Map-range b/Lang/Pascal-P/Map-range new file mode 120000 index 0000000000..ecc77d75f6 --- /dev/null +++ b/Lang/Pascal-P/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Pascal-P \ No newline at end of file diff --git a/Lang/Pascal-P/Ramer-Douglas-Peucker-line-simplification b/Lang/Pascal-P/Ramer-Douglas-Peucker-line-simplification new file mode 120000 index 0000000000..41e4d1e47d --- /dev/null +++ b/Lang/Pascal-P/Ramer-Douglas-Peucker-line-simplification @@ -0,0 +1 @@ +../../Task/Ramer-Douglas-Peucker-line-simplification/Pascal-P \ No newline at end of file diff --git a/Lang/PascalABC.NET/15-puzzle-solver b/Lang/PascalABC.NET/15-puzzle-solver new file mode 120000 index 0000000000..73063f2237 --- /dev/null +++ b/Lang/PascalABC.NET/15-puzzle-solver @@ -0,0 +1 @@ +../../Task/15-puzzle-solver/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Abbreviations-easy b/Lang/PascalABC.NET/Abbreviations-easy new file mode 120000 index 0000000000..ea782fa0b0 --- /dev/null +++ b/Lang/PascalABC.NET/Abbreviations-easy @@ -0,0 +1 @@ +../../Task/Abbreviations-easy/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Abbreviations-simple b/Lang/PascalABC.NET/Abbreviations-simple new file mode 120000 index 0000000000..abc650feac --- /dev/null +++ b/Lang/PascalABC.NET/Abbreviations-simple @@ -0,0 +1 @@ +../../Task/Abbreviations-simple/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Arithmetic-evaluation b/Lang/PascalABC.NET/Arithmetic-evaluation new file mode 120000 index 0000000000..816270d1cc --- /dev/null +++ b/Lang/PascalABC.NET/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Bioinformatics-base-count b/Lang/PascalABC.NET/Bioinformatics-base-count new file mode 120000 index 0000000000..8f0159ab8b --- /dev/null +++ b/Lang/PascalABC.NET/Bioinformatics-base-count @@ -0,0 +1 @@ +../../Task/Bioinformatics-base-count/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Case-sensitivity-of-identifiers b/Lang/PascalABC.NET/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..b0fc4ead7c --- /dev/null +++ b/Lang/PascalABC.NET/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Combinations-with-repetitions b/Lang/PascalABC.NET/Combinations-with-repetitions new file mode 120000 index 0000000000..f75050c914 --- /dev/null +++ b/Lang/PascalABC.NET/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/PascalABC.NET \ No newline at end of file diff --git a/Lang/Perl/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Perl/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..bc2932bdb0 --- /dev/null +++ b/Lang/Perl/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Perl \ No newline at end of file diff --git a/Lang/Pico-8/00-LANG.txt b/Lang/Pico-8/00-LANG.txt new file mode 100644 index 0000000000..017ddd4004 --- /dev/null +++ b/Lang/Pico-8/00-LANG.txt @@ -0,0 +1 @@ +{{stub}}{{language|Pico-8}} \ No newline at end of file diff --git a/Lang/Pico-8/00-META.yaml b/Lang/Pico-8/00-META.yaml new file mode 100644 index 0000000000..5d0c380905 --- /dev/null +++ b/Lang/Pico-8/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Pico-8 diff --git a/Lang/Pico-8/Hello-world-Text b/Lang/Pico-8/Hello-world-Text new file mode 120000 index 0000000000..8a6a254eaa --- /dev/null +++ b/Lang/Pico-8/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Pico-8 \ No newline at end of file diff --git a/Lang/Pluto/00-LANG.txt b/Lang/Pluto/00-LANG.txt new file mode 100644 index 0000000000..debf9ec69a --- /dev/null +++ b/Lang/Pluto/00-LANG.txt @@ -0,0 +1,41 @@ +{{language|Pluto +|exec=interpreted +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|gc=yes +|hopl=no +|site=https://pluto-lang.org/}} +Pluto is a superset of Lua 5.4 with a focus on general-purpose programming. While being remarkably compatible with Lua 5.4 source-code & bytecode, it enhances the standard library & adds more than a dozen highly-desired syntaxes such as switch statements, compound operators, classes, class inheritance, string interpolation, type hinting, enums, and so on. + +Pluto aspires to be a version of Lua with a larger feature-set, that is all. Pluto is not a Lua-killer, an attempted successor, or any of that. Many people (rightly so) love Lua precisely because of the design philosophy. And fundamentally, Pluto is a major deviation from Lua's design philosophy. Some may prefer this, some may not. + +The language is being developed on [https://github.com/PlutoLang/Pluto github] and pre-built binaries for 64-bit Linux, MacOS and Windows can be downloaded [https://github.com/PlutoLang/Pluto/releases here]. + +Here is a list of custom libraries used on Rosetta Code: +{|class="wikitable" +! No. !! Module name !! No. !! Module name +|- +| 1 || [[:Category:Pluto-fmt|fmt]] || 2 || [[:Category:Pluto-math2|math2]] +|- +| 3 || [[:Category:Pluto-int|int]] || 4 || [[:Category:Pluto-table2|table2]] +|- +| 5 || [[:Category:Pluto-complex|complex]] || 6 || [[:Category:Pluto-rat|rat]] +|- +| 7 || [[:Category:Pluto-queue|queue]] || 8 || [[:Category:Pluto-map|map]] +|- +| 9 || [[:Category:Pluto-list|list]] || 10 || [[:Category:Pluto-perm|perm]] +|- +|11 || [[:Category:Pluto-ansi|ansi]] || 12 || [[:Category:Pluto-io2|io2]] +|- +|13 || [[:Category:Pluto-uchar|uchar]] || 14 || [[:Category:Pluto-gchar|gchar]] +|- +|} + +== To do == +[[Tasks not implemented in Pluto]] + +== See also == + +[[Lua]] \ No newline at end of file diff --git a/Lang/Pluto/00-META.yaml b/Lang/Pluto/00-META.yaml new file mode 100644 index 0000000000..4169e06d3e --- /dev/null +++ b/Lang/Pluto/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Pluto diff --git a/Lang/Pluto/99-bottles-of-beer b/Lang/Pluto/99-bottles-of-beer new file mode 120000 index 0000000000..cc21927564 --- /dev/null +++ b/Lang/Pluto/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/A+B b/Lang/Pluto/A+B new file mode 120000 index 0000000000..c26f431720 --- /dev/null +++ b/Lang/Pluto/A+B @@ -0,0 +1 @@ +../../Task/A+B/Pluto \ No newline at end of file diff --git a/Lang/Pluto/ABC-problem b/Lang/Pluto/ABC-problem new file mode 120000 index 0000000000..13affeffe2 --- /dev/null +++ b/Lang/Pluto/ABC-problem @@ -0,0 +1 @@ +../../Task/ABC-problem/Pluto \ No newline at end of file diff --git a/Lang/Pluto/AKS-test-for-primes b/Lang/Pluto/AKS-test-for-primes new file mode 120000 index 0000000000..55e9fce3e0 --- /dev/null +++ b/Lang/Pluto/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Abelian-sandpile-model b/Lang/Pluto/Abelian-sandpile-model new file mode 120000 index 0000000000..84e194b9d0 --- /dev/null +++ b/Lang/Pluto/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Abelian-sandpile-model-Identity b/Lang/Pluto/Abelian-sandpile-model-Identity new file mode 120000 index 0000000000..5258fd0a4e --- /dev/null +++ b/Lang/Pluto/Abelian-sandpile-model-Identity @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model-Identity/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Abstract-type b/Lang/Pluto/Abstract-type new file mode 120000 index 0000000000..f418e6a876 --- /dev/null +++ b/Lang/Pluto/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Abundant-deficient-and-perfect-number-classifications b/Lang/Pluto/Abundant-deficient-and-perfect-number-classifications new file mode 120000 index 0000000000..f5843a0883 --- /dev/null +++ b/Lang/Pluto/Abundant-deficient-and-perfect-number-classifications @@ -0,0 +1 @@ +../../Task/Abundant-deficient-and-perfect-number-classifications/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Abundant-odd-numbers b/Lang/Pluto/Abundant-odd-numbers new file mode 120000 index 0000000000..18495df602 --- /dev/null +++ b/Lang/Pluto/Abundant-odd-numbers @@ -0,0 +1 @@ +../../Task/Abundant-odd-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Achilles-numbers b/Lang/Pluto/Achilles-numbers new file mode 120000 index 0000000000..0121ec15f3 --- /dev/null +++ b/Lang/Pluto/Achilles-numbers @@ -0,0 +1 @@ +../../Task/Achilles-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Ackermann-function b/Lang/Pluto/Ackermann-function new file mode 120000 index 0000000000..b2e9e8bcf4 --- /dev/null +++ b/Lang/Pluto/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Address-of-a-variable b/Lang/Pluto/Address-of-a-variable new file mode 120000 index 0000000000..db8c9fa74c --- /dev/null +++ b/Lang/Pluto/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Almost-prime b/Lang/Pluto/Almost-prime new file mode 120000 index 0000000000..8dfdefc597 --- /dev/null +++ b/Lang/Pluto/Almost-prime @@ -0,0 +1 @@ +../../Task/Almost-prime/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Anti-primes b/Lang/Pluto/Anti-primes new file mode 120000 index 0000000000..62e9118e82 --- /dev/null +++ b/Lang/Pluto/Anti-primes @@ -0,0 +1 @@ +../../Task/Anti-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Approximate-equality b/Lang/Pluto/Approximate-equality new file mode 120000 index 0000000000..65832f9c4c --- /dev/null +++ b/Lang/Pluto/Approximate-equality @@ -0,0 +1 @@ +../../Task/Approximate-equality/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arbitrary-precision-integers-included- b/Lang/Pluto/Arbitrary-precision-integers-included- new file mode 120000 index 0000000000..63cf45fedf --- /dev/null +++ b/Lang/Pluto/Arbitrary-precision-integers-included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included-/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arithmetic-Complex b/Lang/Pluto/Arithmetic-Complex new file mode 120000 index 0000000000..e8437b9a01 --- /dev/null +++ b/Lang/Pluto/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arithmetic-Integer b/Lang/Pluto/Arithmetic-Integer new file mode 120000 index 0000000000..3b77091442 --- /dev/null +++ b/Lang/Pluto/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arithmetic-Rational b/Lang/Pluto/Arithmetic-Rational new file mode 120000 index 0000000000..497dafd0e0 --- /dev/null +++ b/Lang/Pluto/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arithmetic-derivative b/Lang/Pluto/Arithmetic-derivative new file mode 120000 index 0000000000..9254d1c7e4 --- /dev/null +++ b/Lang/Pluto/Arithmetic-derivative @@ -0,0 +1 @@ +../../Task/Arithmetic-derivative/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arithmetic-geometric-mean b/Lang/Pluto/Arithmetic-geometric-mean new file mode 120000 index 0000000000..7f7bd49c54 --- /dev/null +++ b/Lang/Pluto/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Array-concatenation b/Lang/Pluto/Array-concatenation new file mode 120000 index 0000000000..b151e60e5d --- /dev/null +++ b/Lang/Pluto/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Arrays b/Lang/Pluto/Arrays new file mode 120000 index 0000000000..36aa2a73e2 --- /dev/null +++ b/Lang/Pluto/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Ascending-primes b/Lang/Pluto/Ascending-primes new file mode 120000 index 0000000000..b086dde9de --- /dev/null +++ b/Lang/Pluto/Ascending-primes @@ -0,0 +1 @@ +../../Task/Ascending-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Associative-array-Creation b/Lang/Pluto/Associative-array-Creation new file mode 120000 index 0000000000..dab36a66d3 --- /dev/null +++ b/Lang/Pluto/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Associative-array-Iteration b/Lang/Pluto/Associative-array-Iteration new file mode 120000 index 0000000000..5ced29976c --- /dev/null +++ b/Lang/Pluto/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Associative-array-Merging b/Lang/Pluto/Associative-array-Merging new file mode 120000 index 0000000000..e8bdf6f6ca --- /dev/null +++ b/Lang/Pluto/Associative-array-Merging @@ -0,0 +1 @@ +../../Task/Associative-array-Merging/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Attractive-numbers b/Lang/Pluto/Attractive-numbers new file mode 120000 index 0000000000..cc6d5fdf22 --- /dev/null +++ b/Lang/Pluto/Attractive-numbers @@ -0,0 +1 @@ +../../Task/Attractive-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Averages-Arithmetic-mean b/Lang/Pluto/Averages-Arithmetic-mean new file mode 120000 index 0000000000..a80eb1d9ce --- /dev/null +++ b/Lang/Pluto/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Averages-Median b/Lang/Pluto/Averages-Median new file mode 120000 index 0000000000..4877cdaa55 --- /dev/null +++ b/Lang/Pluto/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Averages-Pythagorean-means b/Lang/Pluto/Averages-Pythagorean-means new file mode 120000 index 0000000000..f4cb6461df --- /dev/null +++ b/Lang/Pluto/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Averages-Root-mean-square b/Lang/Pluto/Averages-Root-mean-square new file mode 120000 index 0000000000..744197c17a --- /dev/null +++ b/Lang/Pluto/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Balanced-brackets b/Lang/Pluto/Balanced-brackets new file mode 120000 index 0000000000..e55ebe8e48 --- /dev/null +++ b/Lang/Pluto/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Base64-decode-data b/Lang/Pluto/Base64-decode-data new file mode 120000 index 0000000000..9e79a215f0 --- /dev/null +++ b/Lang/Pluto/Base64-decode-data @@ -0,0 +1 @@ +../../Task/Base64-decode-data/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Bell-numbers b/Lang/Pluto/Bell-numbers new file mode 120000 index 0000000000..12ebb36a37 --- /dev/null +++ b/Lang/Pluto/Bell-numbers @@ -0,0 +1 @@ +../../Task/Bell-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Bitmap b/Lang/Pluto/Bitmap new file mode 120000 index 0000000000..2eae4de5c9 --- /dev/null +++ b/Lang/Pluto/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Bitmap-Bresenhams-line-algorithm b/Lang/Pluto/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..648ca4156e --- /dev/null +++ b/Lang/Pluto/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Bitmap-Midpoint-circle-algorithm b/Lang/Pluto/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..30e98198c1 --- /dev/null +++ b/Lang/Pluto/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Bitwise-operations b/Lang/Pluto/Bitwise-operations new file mode 120000 index 0000000000..7aa2755b89 --- /dev/null +++ b/Lang/Pluto/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Pluto \ No newline at end of file diff --git a/Lang/Pluto/CRC-32 b/Lang/Pluto/CRC-32 new file mode 120000 index 0000000000..a2f9755cc8 --- /dev/null +++ b/Lang/Pluto/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Caesar-cipher b/Lang/Pluto/Caesar-cipher new file mode 120000 index 0000000000..92165c560f --- /dev/null +++ b/Lang/Pluto/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Calkin-Wilf-sequence b/Lang/Pluto/Calkin-Wilf-sequence new file mode 120000 index 0000000000..e7c08bf16e --- /dev/null +++ b/Lang/Pluto/Calkin-Wilf-sequence @@ -0,0 +1 @@ +../../Task/Calkin-Wilf-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Call-a-foreign-language-function b/Lang/Pluto/Call-a-foreign-language-function new file mode 120000 index 0000000000..f071bb1596 --- /dev/null +++ b/Lang/Pluto/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Call-a-function-in-a-shared-library b/Lang/Pluto/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..fb03a37240 --- /dev/null +++ b/Lang/Pluto/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Case-sensitivity-of-identifiers b/Lang/Pluto/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..e37b951419 --- /dev/null +++ b/Lang/Pluto/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Casting-out-nines b/Lang/Pluto/Casting-out-nines new file mode 120000 index 0000000000..f9d2b5090f --- /dev/null +++ b/Lang/Pluto/Casting-out-nines @@ -0,0 +1 @@ +../../Task/Casting-out-nines/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Collections b/Lang/Pluto/Collections new file mode 120000 index 0000000000..82a2dd2b4f --- /dev/null +++ b/Lang/Pluto/Collections @@ -0,0 +1 @@ +../../Task/Collections/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Combinations b/Lang/Pluto/Combinations new file mode 120000 index 0000000000..1554032a2c --- /dev/null +++ b/Lang/Pluto/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Combinations-with-repetitions b/Lang/Pluto/Combinations-with-repetitions new file mode 120000 index 0000000000..27271a521e --- /dev/null +++ b/Lang/Pluto/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Command-line-arguments b/Lang/Pluto/Command-line-arguments new file mode 120000 index 0000000000..0f5f02829e --- /dev/null +++ b/Lang/Pluto/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Comments b/Lang/Pluto/Comments new file mode 120000 index 0000000000..8d1e636123 --- /dev/null +++ b/Lang/Pluto/Comments @@ -0,0 +1 @@ +../../Task/Comments/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Compare-length-of-two-strings b/Lang/Pluto/Compare-length-of-two-strings new file mode 120000 index 0000000000..a17ca1cb1f --- /dev/null +++ b/Lang/Pluto/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Compiler-lexical-analyzer b/Lang/Pluto/Compiler-lexical-analyzer new file mode 120000 index 0000000000..0e5b3d7d41 --- /dev/null +++ b/Lang/Pluto/Compiler-lexical-analyzer @@ -0,0 +1 @@ +../../Task/Compiler-lexical-analyzer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Conditional-structures b/Lang/Pluto/Conditional-structures new file mode 120000 index 0000000000..480797a688 --- /dev/null +++ b/Lang/Pluto/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Pluto/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..4207df96c4 --- /dev/null +++ b/Lang/Pluto/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Convert-decimal-number-to-rational b/Lang/Pluto/Convert-decimal-number-to-rational new file mode 120000 index 0000000000..67bc18205b --- /dev/null +++ b/Lang/Pluto/Convert-decimal-number-to-rational @@ -0,0 +1 @@ +../../Task/Convert-decimal-number-to-rational/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Count-in-octal b/Lang/Pluto/Count-in-octal new file mode 120000 index 0000000000..c5624def8e --- /dev/null +++ b/Lang/Pluto/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Count-the-coins b/Lang/Pluto/Count-the-coins new file mode 120000 index 0000000000..7996299523 --- /dev/null +++ b/Lang/Pluto/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Create-a-file b/Lang/Pluto/Create-a-file new file mode 120000 index 0000000000..1e22b0b1e3 --- /dev/null +++ b/Lang/Pluto/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Currying b/Lang/Pluto/Currying new file mode 120000 index 0000000000..98e5282551 --- /dev/null +++ b/Lang/Pluto/Currying @@ -0,0 +1 @@ +../../Task/Currying/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Delete-a-file b/Lang/Pluto/Delete-a-file new file mode 120000 index 0000000000..b17ce9999b --- /dev/null +++ b/Lang/Pluto/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Descending-primes b/Lang/Pluto/Descending-primes new file mode 120000 index 0000000000..c35e1667b5 --- /dev/null +++ b/Lang/Pluto/Descending-primes @@ -0,0 +1 @@ +../../Task/Descending-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Determine-if-a-string-is-numeric b/Lang/Pluto/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..f3177e5d6e --- /dev/null +++ b/Lang/Pluto/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Disarium-numbers b/Lang/Pluto/Disarium-numbers new file mode 120000 index 0000000000..fd659f8581 --- /dev/null +++ b/Lang/Pluto/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Display-a-linear-combination b/Lang/Pluto/Display-a-linear-combination new file mode 120000 index 0000000000..b9e618e087 --- /dev/null +++ b/Lang/Pluto/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Distribution-of-0-digits-in-factorial-series b/Lang/Pluto/Distribution-of-0-digits-in-factorial-series new file mode 120000 index 0000000000..a06ffa876b --- /dev/null +++ b/Lang/Pluto/Distribution-of-0-digits-in-factorial-series @@ -0,0 +1 @@ +../../Task/Distribution-of-0-digits-in-factorial-series/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Doubly-linked-list-Definition b/Lang/Pluto/Doubly-linked-list-Definition new file mode 120000 index 0000000000..2c673acc7c --- /dev/null +++ b/Lang/Pluto/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Doubly-linked-list-Element-definition b/Lang/Pluto/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..7b2f1839e3 --- /dev/null +++ b/Lang/Pluto/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Doubly-linked-list-Traversal b/Lang/Pluto/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..9a9262d67b --- /dev/null +++ b/Lang/Pluto/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Dutch-national-flag-problem b/Lang/Pluto/Dutch-national-flag-problem new file mode 120000 index 0000000000..4ca6eb0344 --- /dev/null +++ b/Lang/Pluto/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Euler-method b/Lang/Pluto/Euler-method new file mode 120000 index 0000000000..b7dbfe93a0 --- /dev/null +++ b/Lang/Pluto/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Eulers-identity b/Lang/Pluto/Eulers-identity new file mode 120000 index 0000000000..97a4ba8ed8 --- /dev/null +++ b/Lang/Pluto/Eulers-identity @@ -0,0 +1 @@ +../../Task/Eulers-identity/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Even-or-odd b/Lang/Pluto/Even-or-odd new file mode 120000 index 0000000000..fc5cc6a785 --- /dev/null +++ b/Lang/Pluto/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Execute-a-system-command b/Lang/Pluto/Execute-a-system-command new file mode 120000 index 0000000000..005fc83a4b --- /dev/null +++ b/Lang/Pluto/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Factorial b/Lang/Pluto/Factorial new file mode 120000 index 0000000000..26b76cb13d --- /dev/null +++ b/Lang/Pluto/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Factorial-primes b/Lang/Pluto/Factorial-primes new file mode 120000 index 0000000000..b57eac84ac --- /dev/null +++ b/Lang/Pluto/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Factorions b/Lang/Pluto/Factorions new file mode 120000 index 0000000000..0d6fdce25f --- /dev/null +++ b/Lang/Pluto/Factorions @@ -0,0 +1 @@ +../../Task/Factorions/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Factors-of-an-integer b/Lang/Pluto/Factors-of-an-integer new file mode 120000 index 0000000000..cc13f27676 --- /dev/null +++ b/Lang/Pluto/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Farey-sequence b/Lang/Pluto/Farey-sequence new file mode 120000 index 0000000000..d29c19b41e --- /dev/null +++ b/Lang/Pluto/Farey-sequence @@ -0,0 +1 @@ +../../Task/Farey-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Feigenbaum-constant-calculation b/Lang/Pluto/Feigenbaum-constant-calculation new file mode 120000 index 0000000000..256bf8cb19 --- /dev/null +++ b/Lang/Pluto/Feigenbaum-constant-calculation @@ -0,0 +1 @@ +../../Task/Feigenbaum-constant-calculation/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Fibonacci-sequence b/Lang/Pluto/Fibonacci-sequence new file mode 120000 index 0000000000..efff8e1eb6 --- /dev/null +++ b/Lang/Pluto/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Filter b/Lang/Pluto/Filter new file mode 120000 index 0000000000..98b0321ee6 --- /dev/null +++ b/Lang/Pluto/Filter @@ -0,0 +1 @@ +../../Task/Filter/Pluto \ No newline at end of file diff --git a/Lang/Pluto/FizzBuzz b/Lang/Pluto/FizzBuzz new file mode 120000 index 0000000000..bd54d0d8bb --- /dev/null +++ b/Lang/Pluto/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Floyd-Warshall-algorithm b/Lang/Pluto/Floyd-Warshall-algorithm new file mode 120000 index 0000000000..7df2d45291 --- /dev/null +++ b/Lang/Pluto/Floyd-Warshall-algorithm @@ -0,0 +1 @@ +../../Task/Floyd-Warshall-algorithm/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Formatted-numeric-output b/Lang/Pluto/Formatted-numeric-output new file mode 120000 index 0000000000..ca4bc2e2c0 --- /dev/null +++ b/Lang/Pluto/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Function-definition b/Lang/Pluto/Function-definition new file mode 120000 index 0000000000..8c3e064f65 --- /dev/null +++ b/Lang/Pluto/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Gamma-function b/Lang/Pluto/Gamma-function new file mode 120000 index 0000000000..8b7dee23dc --- /dev/null +++ b/Lang/Pluto/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Generate-lower-case-ASCII-alphabet b/Lang/Pluto/Generate-lower-case-ASCII-alphabet new file mode 120000 index 0000000000..64f2576fe0 --- /dev/null +++ b/Lang/Pluto/Generate-lower-case-ASCII-alphabet @@ -0,0 +1 @@ +../../Task/Generate-lower-case-ASCII-alphabet/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Giuga-numbers b/Lang/Pluto/Giuga-numbers new file mode 120000 index 0000000000..221b7a2689 --- /dev/null +++ b/Lang/Pluto/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Goldbachs-comet b/Lang/Pluto/Goldbachs-comet new file mode 120000 index 0000000000..ff1cca329d --- /dev/null +++ b/Lang/Pluto/Goldbachs-comet @@ -0,0 +1 @@ +../../Task/Goldbachs-comet/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Greatest-common-divisor b/Lang/Pluto/Greatest-common-divisor new file mode 120000 index 0000000000..a4feeee2fd --- /dev/null +++ b/Lang/Pluto/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Greatest-element-of-a-list b/Lang/Pluto/Greatest-element-of-a-list new file mode 120000 index 0000000000..85148f8e2b --- /dev/null +++ b/Lang/Pluto/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Hailstone-sequence b/Lang/Pluto/Hailstone-sequence new file mode 120000 index 0000000000..0c70c36e8a --- /dev/null +++ b/Lang/Pluto/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Halt-and-catch-fire b/Lang/Pluto/Halt-and-catch-fire new file mode 120000 index 0000000000..f8e69baccf --- /dev/null +++ b/Lang/Pluto/Halt-and-catch-fire @@ -0,0 +1 @@ +../../Task/Halt-and-catch-fire/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Hash-from-two-arrays b/Lang/Pluto/Hash-from-two-arrays new file mode 120000 index 0000000000..5612dbf1a3 --- /dev/null +++ b/Lang/Pluto/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Hello-world-Newline-omission b/Lang/Pluto/Hello-world-Newline-omission new file mode 120000 index 0000000000..5020503885 --- /dev/null +++ b/Lang/Pluto/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Hello-world-Standard-error b/Lang/Pluto/Hello-world-Standard-error new file mode 120000 index 0000000000..2b41d962cc --- /dev/null +++ b/Lang/Pluto/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Hello-world-Text b/Lang/Pluto/Hello-world-Text new file mode 120000 index 0000000000..6d5bb1406f --- /dev/null +++ b/Lang/Pluto/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Higher-order-functions b/Lang/Pluto/Higher-order-functions new file mode 120000 index 0000000000..532e183ee0 --- /dev/null +++ b/Lang/Pluto/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Horners-rule-for-polynomial-evaluation b/Lang/Pluto/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..02512d6f7e --- /dev/null +++ b/Lang/Pluto/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Humble-numbers b/Lang/Pluto/Humble-numbers new file mode 120000 index 0000000000..f616a12fe9 --- /dev/null +++ b/Lang/Pluto/Humble-numbers @@ -0,0 +1 @@ +../../Task/Humble-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Increment-a-numerical-string b/Lang/Pluto/Increment-a-numerical-string new file mode 120000 index 0000000000..5413743d7c --- /dev/null +++ b/Lang/Pluto/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Infinity b/Lang/Pluto/Infinity new file mode 120000 index 0000000000..cb81bde8e2 --- /dev/null +++ b/Lang/Pluto/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Pluto \ No newline at end of file diff --git a/Lang/Pluto/JSON b/Lang/Pluto/JSON new file mode 120000 index 0000000000..bc77142a3f --- /dev/null +++ b/Lang/Pluto/JSON @@ -0,0 +1 @@ +../../Task/JSON/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Jacobsthal-numbers b/Lang/Pluto/Jacobsthal-numbers new file mode 120000 index 0000000000..310c137dfd --- /dev/null +++ b/Lang/Pluto/Jacobsthal-numbers @@ -0,0 +1 @@ +../../Task/Jacobsthal-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Jewels-and-stones b/Lang/Pluto/Jewels-and-stones new file mode 120000 index 0000000000..0d8632e132 --- /dev/null +++ b/Lang/Pluto/Jewels-and-stones @@ -0,0 +1 @@ +../../Task/Jewels-and-stones/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Josephus-problem b/Lang/Pluto/Josephus-problem new file mode 120000 index 0000000000..c17c5c052c --- /dev/null +++ b/Lang/Pluto/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Kaprekar-numbers b/Lang/Pluto/Kaprekar-numbers new file mode 120000 index 0000000000..1c32b1316d --- /dev/null +++ b/Lang/Pluto/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Leap-year b/Lang/Pluto/Leap-year new file mode 120000 index 0000000000..9574544885 --- /dev/null +++ b/Lang/Pluto/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Literals-Floating-point b/Lang/Pluto/Literals-Floating-point new file mode 120000 index 0000000000..f40aa2eb22 --- /dev/null +++ b/Lang/Pluto/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Literals-Integer b/Lang/Pluto/Literals-Integer new file mode 120000 index 0000000000..2ca0134201 --- /dev/null +++ b/Lang/Pluto/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loop-over-multiple-arrays-simultaneously b/Lang/Pluto/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..cebc902b5b --- /dev/null +++ b/Lang/Pluto/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Break b/Lang/Pluto/Loops-Break new file mode 120000 index 0000000000..2b3657d2de --- /dev/null +++ b/Lang/Pluto/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Continue b/Lang/Pluto/Loops-Continue new file mode 120000 index 0000000000..5f41db6125 --- /dev/null +++ b/Lang/Pluto/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Do-while b/Lang/Pluto/Loops-Do-while new file mode 120000 index 0000000000..a265d4decf --- /dev/null +++ b/Lang/Pluto/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Downward-for b/Lang/Pluto/Loops-Downward-for new file mode 120000 index 0000000000..6302a5cc0d --- /dev/null +++ b/Lang/Pluto/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-For b/Lang/Pluto/Loops-For new file mode 120000 index 0000000000..9f83ae12bd --- /dev/null +++ b/Lang/Pluto/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-For-with-a-specified-step b/Lang/Pluto/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..508122a2e3 --- /dev/null +++ b/Lang/Pluto/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Foreach b/Lang/Pluto/Loops-Foreach new file mode 120000 index 0000000000..9dbfba413e --- /dev/null +++ b/Lang/Pluto/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Increment-loop-index-within-loop-body b/Lang/Pluto/Loops-Increment-loop-index-within-loop-body new file mode 120000 index 0000000000..f1ce9d6778 --- /dev/null +++ b/Lang/Pluto/Loops-Increment-loop-index-within-loop-body @@ -0,0 +1 @@ +../../Task/Loops-Increment-loop-index-within-loop-body/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Infinite b/Lang/Pluto/Loops-Infinite new file mode 120000 index 0000000000..50986dd414 --- /dev/null +++ b/Lang/Pluto/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-N-plus-one-half b/Lang/Pluto/Loops-N-plus-one-half new file mode 120000 index 0000000000..433e3f6336 --- /dev/null +++ b/Lang/Pluto/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Nested b/Lang/Pluto/Loops-Nested new file mode 120000 index 0000000000..96f4c43c62 --- /dev/null +++ b/Lang/Pluto/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-While b/Lang/Pluto/Loops-While new file mode 120000 index 0000000000..3aa5f84aba --- /dev/null +++ b/Lang/Pluto/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-With-multiple-ranges b/Lang/Pluto/Loops-With-multiple-ranges new file mode 120000 index 0000000000..b1ef3af096 --- /dev/null +++ b/Lang/Pluto/Loops-With-multiple-ranges @@ -0,0 +1 @@ +../../Task/Loops-With-multiple-ranges/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Loops-Wrong-ranges b/Lang/Pluto/Loops-Wrong-ranges new file mode 120000 index 0000000000..7b8bd4ecb0 --- /dev/null +++ b/Lang/Pluto/Loops-Wrong-ranges @@ -0,0 +1 @@ +../../Task/Loops-Wrong-ranges/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Luhn-test-of-credit-card-numbers b/Lang/Pluto/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..c06ed72be3 --- /dev/null +++ b/Lang/Pluto/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/M-bius-function b/Lang/Pluto/M-bius-function new file mode 120000 index 0000000000..99da13a437 --- /dev/null +++ b/Lang/Pluto/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Machine-code b/Lang/Pluto/Machine-code new file mode 120000 index 0000000000..82c80d52fd --- /dev/null +++ b/Lang/Pluto/Machine-code @@ -0,0 +1 @@ +../../Task/Machine-code/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Magic-squares-of-doubly-even-order b/Lang/Pluto/Magic-squares-of-doubly-even-order new file mode 120000 index 0000000000..357d3e5480 --- /dev/null +++ b/Lang/Pluto/Magic-squares-of-doubly-even-order @@ -0,0 +1 @@ +../../Task/Magic-squares-of-doubly-even-order/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Magic-squares-of-odd-order b/Lang/Pluto/Magic-squares-of-odd-order new file mode 120000 index 0000000000..5df4846612 --- /dev/null +++ b/Lang/Pluto/Magic-squares-of-odd-order @@ -0,0 +1 @@ +../../Task/Magic-squares-of-odd-order/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Magic-squares-of-singly-even-order b/Lang/Pluto/Magic-squares-of-singly-even-order new file mode 120000 index 0000000000..2430b82023 --- /dev/null +++ b/Lang/Pluto/Magic-squares-of-singly-even-order @@ -0,0 +1 @@ +../../Task/Magic-squares-of-singly-even-order/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Mian-Chowla-sequence b/Lang/Pluto/Mian-Chowla-sequence new file mode 120000 index 0000000000..f966e85ca5 --- /dev/null +++ b/Lang/Pluto/Mian-Chowla-sequence @@ -0,0 +1 @@ +../../Task/Mian-Chowla-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Modular-inverse b/Lang/Pluto/Modular-inverse new file mode 120000 index 0000000000..339ad0f426 --- /dev/null +++ b/Lang/Pluto/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Multiplication-tables b/Lang/Pluto/Multiplication-tables new file mode 120000 index 0000000000..98a4d7bd3c --- /dev/null +++ b/Lang/Pluto/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Mutual-recursion b/Lang/Pluto/Mutual-recursion new file mode 120000 index 0000000000..3866a9925a --- /dev/null +++ b/Lang/Pluto/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Named-parameters b/Lang/Pluto/Named-parameters new file mode 120000 index 0000000000..8f0b72ba9b --- /dev/null +++ b/Lang/Pluto/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Narcissistic-decimal-number b/Lang/Pluto/Narcissistic-decimal-number new file mode 120000 index 0000000000..feead3c3a0 --- /dev/null +++ b/Lang/Pluto/Narcissistic-decimal-number @@ -0,0 +1 @@ +../../Task/Narcissistic-decimal-number/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Nested-templated-data b/Lang/Pluto/Nested-templated-data new file mode 120000 index 0000000000..d56f50a5d8 --- /dev/null +++ b/Lang/Pluto/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Non-decimal-radices-Convert b/Lang/Pluto/Non-decimal-radices-Convert new file mode 120000 index 0000000000..e1fddc5a20 --- /dev/null +++ b/Lang/Pluto/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Numerical-integration b/Lang/Pluto/Numerical-integration new file mode 120000 index 0000000000..e89c1b753a --- /dev/null +++ b/Lang/Pluto/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Old-Russian-measure-of-length b/Lang/Pluto/Old-Russian-measure-of-length new file mode 120000 index 0000000000..9f7493d0af --- /dev/null +++ b/Lang/Pluto/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Order-by-pair-comparisons b/Lang/Pluto/Order-by-pair-comparisons new file mode 120000 index 0000000000..1c7665f6b2 --- /dev/null +++ b/Lang/Pluto/Order-by-pair-comparisons @@ -0,0 +1 @@ +../../Task/Order-by-pair-comparisons/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Palindrome-detection b/Lang/Pluto/Palindrome-detection new file mode 120000 index 0000000000..755083778a --- /dev/null +++ b/Lang/Pluto/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Pancake-numbers b/Lang/Pluto/Pancake-numbers new file mode 120000 index 0000000000..129dac7c77 --- /dev/null +++ b/Lang/Pluto/Pancake-numbers @@ -0,0 +1 @@ +../../Task/Pancake-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Parsing-RPN-calculator-algorithm b/Lang/Pluto/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..f120a8c76e --- /dev/null +++ b/Lang/Pluto/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Pascals-triangle-Puzzle b/Lang/Pluto/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..312b0f9b1b --- /dev/null +++ b/Lang/Pluto/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Perfect-shuffle b/Lang/Pluto/Perfect-shuffle new file mode 120000 index 0000000000..1dd4b8c882 --- /dev/null +++ b/Lang/Pluto/Perfect-shuffle @@ -0,0 +1 @@ +../../Task/Perfect-shuffle/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Permutations b/Lang/Pluto/Permutations new file mode 120000 index 0000000000..750604fad2 --- /dev/null +++ b/Lang/Pluto/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Pernicious-numbers b/Lang/Pluto/Pernicious-numbers new file mode 120000 index 0000000000..29e4a1f27e --- /dev/null +++ b/Lang/Pluto/Pernicious-numbers @@ -0,0 +1 @@ +../../Task/Pernicious-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Pick-random-element b/Lang/Pluto/Pick-random-element new file mode 120000 index 0000000000..f181e160e5 --- /dev/null +++ b/Lang/Pluto/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Pisano-period b/Lang/Pluto/Pisano-period new file mode 120000 index 0000000000..377c8913e0 --- /dev/null +++ b/Lang/Pluto/Pisano-period @@ -0,0 +1 @@ +../../Task/Pisano-period/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Power-set b/Lang/Pluto/Power-set new file mode 120000 index 0000000000..72362c1ec0 --- /dev/null +++ b/Lang/Pluto/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Primality-by-trial-division b/Lang/Pluto/Primality-by-trial-division new file mode 120000 index 0000000000..01622c5c43 --- /dev/null +++ b/Lang/Pluto/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Priority-queue b/Lang/Pluto/Priority-queue new file mode 120000 index 0000000000..ad7bed4159 --- /dev/null +++ b/Lang/Pluto/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Read-a-file-line-by-line b/Lang/Pluto/Read-a-file-line-by-line new file mode 120000 index 0000000000..d35b8cfbc4 --- /dev/null +++ b/Lang/Pluto/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Rename-a-file b/Lang/Pluto/Rename-a-file new file mode 120000 index 0000000000..dd234bb854 --- /dev/null +++ b/Lang/Pluto/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Repeat-a-string b/Lang/Pluto/Repeat-a-string new file mode 120000 index 0000000000..7cea8b7235 --- /dev/null +++ b/Lang/Pluto/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Reverse-a-string b/Lang/Pluto/Reverse-a-string new file mode 120000 index 0000000000..dc5b2e2493 --- /dev/null +++ b/Lang/Pluto/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Reverse-words-in-a-string b/Lang/Pluto/Reverse-words-in-a-string new file mode 120000 index 0000000000..378e6ea4b7 --- /dev/null +++ b/Lang/Pluto/Reverse-words-in-a-string @@ -0,0 +1 @@ +../../Task/Reverse-words-in-a-string/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Roman-numerals-Encode b/Lang/Pluto/Roman-numerals-Encode new file mode 120000 index 0000000000..d12a85d68f --- /dev/null +++ b/Lang/Pluto/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Roots-of-a-quadratic-function b/Lang/Pluto/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..8e5bf4c688 --- /dev/null +++ b/Lang/Pluto/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Roots-of-unity b/Lang/Pluto/Roots-of-unity new file mode 120000 index 0000000000..e0f1ada438 --- /dev/null +++ b/Lang/Pluto/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Rot-13 b/Lang/Pluto/Rot-13 new file mode 120000 index 0000000000..ca2ef70221 --- /dev/null +++ b/Lang/Pluto/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Runge-Kutta-method b/Lang/Pluto/Runge-Kutta-method new file mode 120000 index 0000000000..1f412f01e7 --- /dev/null +++ b/Lang/Pluto/Runge-Kutta-method @@ -0,0 +1 @@ +../../Task/Runge-Kutta-method/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Self-numbers b/Lang/Pluto/Self-numbers new file mode 120000 index 0000000000..6ddaee76e3 --- /dev/null +++ b/Lang/Pluto/Self-numbers @@ -0,0 +1 @@ +../../Task/Self-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Semordnilap b/Lang/Pluto/Semordnilap new file mode 120000 index 0000000000..92f96e5b0c --- /dev/null +++ b/Lang/Pluto/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Sequence-of-primes-by-trial-division b/Lang/Pluto/Sequence-of-primes-by-trial-division new file mode 120000 index 0000000000..0a541cb28c --- /dev/null +++ b/Lang/Pluto/Sequence-of-primes-by-trial-division @@ -0,0 +1 @@ +../../Task/Sequence-of-primes-by-trial-division/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Set b/Lang/Pluto/Set new file mode 120000 index 0000000000..9bbe04e32f --- /dev/null +++ b/Lang/Pluto/Set @@ -0,0 +1 @@ +../../Task/Set/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Set-consolidation b/Lang/Pluto/Set-consolidation new file mode 120000 index 0000000000..af203f8560 --- /dev/null +++ b/Lang/Pluto/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Singly-linked-list-Element-definition b/Lang/Pluto/Singly-linked-list-Element-definition new file mode 120000 index 0000000000..1f46e7b961 --- /dev/null +++ b/Lang/Pluto/Singly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-definition/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Singly-linked-list-Element-insertion b/Lang/Pluto/Singly-linked-list-Element-insertion new file mode 120000 index 0000000000..27b69c63f5 --- /dev/null +++ b/Lang/Pluto/Singly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-insertion/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Singly-linked-list-Traversal b/Lang/Pluto/Singly-linked-list-Traversal new file mode 120000 index 0000000000..a9f1239636 --- /dev/null +++ b/Lang/Pluto/Singly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Traversal/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Sleep b/Lang/Pluto/Sleep new file mode 120000 index 0000000000..fe338781ff --- /dev/null +++ b/Lang/Pluto/Sleep @@ -0,0 +1 @@ +../../Task/Sleep/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Smarandache-prime-digital-sequence b/Lang/Pluto/Smarandache-prime-digital-sequence new file mode 120000 index 0000000000..c1bae0f65e --- /dev/null +++ b/Lang/Pluto/Smarandache-prime-digital-sequence @@ -0,0 +1 @@ +../../Task/Smarandache-prime-digital-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Soloways-recurring-rainfall b/Lang/Pluto/Soloways-recurring-rainfall new file mode 120000 index 0000000000..3292890eaf --- /dev/null +++ b/Lang/Pluto/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Sort-an-integer-array b/Lang/Pluto/Sort-an-integer-array new file mode 120000 index 0000000000..43fcfc8222 --- /dev/null +++ b/Lang/Pluto/Sort-an-integer-array @@ -0,0 +1 @@ +../../Task/Sort-an-integer-array/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Stack b/Lang/Pluto/Stack new file mode 120000 index 0000000000..b73a91dd58 --- /dev/null +++ b/Lang/Pluto/Stack @@ -0,0 +1 @@ +../../Task/Stack/Pluto \ No newline at end of file diff --git a/Lang/Pluto/String-interpolation-included- b/Lang/Pluto/String-interpolation-included- new file mode 120000 index 0000000000..7953b3790b --- /dev/null +++ b/Lang/Pluto/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/Pluto \ No newline at end of file diff --git a/Lang/Pluto/String-length b/Lang/Pluto/String-length new file mode 120000 index 0000000000..9313ae7886 --- /dev/null +++ b/Lang/Pluto/String-length @@ -0,0 +1 @@ +../../Task/String-length/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Sum-digits-of-an-integer b/Lang/Pluto/Sum-digits-of-an-integer new file mode 120000 index 0000000000..0c6a6782ed --- /dev/null +++ b/Lang/Pluto/Sum-digits-of-an-integer @@ -0,0 +1 @@ +../../Task/Sum-digits-of-an-integer/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/Pluto/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..45a9f51475 --- /dev/null +++ b/Lang/Pluto/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Symmetric-difference b/Lang/Pluto/Symmetric-difference new file mode 120000 index 0000000000..09ce1d13b8 --- /dev/null +++ b/Lang/Pluto/Symmetric-difference @@ -0,0 +1 @@ +../../Task/Symmetric-difference/Pluto \ No newline at end of file diff --git a/Lang/Pluto/System-time b/Lang/Pluto/System-time new file mode 120000 index 0000000000..8575dc8b3a --- /dev/null +++ b/Lang/Pluto/System-time @@ -0,0 +1 @@ +../../Task/System-time/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Tau-function b/Lang/Pluto/Tau-function new file mode 120000 index 0000000000..03b50006f6 --- /dev/null +++ b/Lang/Pluto/Tau-function @@ -0,0 +1 @@ +../../Task/Tau-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Tau-number b/Lang/Pluto/Tau-number new file mode 120000 index 0000000000..532021c510 --- /dev/null +++ b/Lang/Pluto/Tau-number @@ -0,0 +1 @@ +../../Task/Tau-number/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Clear-the-screen b/Lang/Pluto/Terminal-control-Clear-the-screen new file mode 120000 index 0000000000..edabc9ce73 --- /dev/null +++ b/Lang/Pluto/Terminal-control-Clear-the-screen @@ -0,0 +1 @@ +../../Task/Terminal-control-Clear-the-screen/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Coloured-text b/Lang/Pluto/Terminal-control-Coloured-text new file mode 120000 index 0000000000..378909157d --- /dev/null +++ b/Lang/Pluto/Terminal-control-Coloured-text @@ -0,0 +1 @@ +../../Task/Terminal-control-Coloured-text/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Cursor-movement b/Lang/Pluto/Terminal-control-Cursor-movement new file mode 120000 index 0000000000..bf8c8572a2 --- /dev/null +++ b/Lang/Pluto/Terminal-control-Cursor-movement @@ -0,0 +1 @@ +../../Task/Terminal-control-Cursor-movement/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Cursor-positioning b/Lang/Pluto/Terminal-control-Cursor-positioning new file mode 120000 index 0000000000..feeca5cd4b --- /dev/null +++ b/Lang/Pluto/Terminal-control-Cursor-positioning @@ -0,0 +1 @@ +../../Task/Terminal-control-Cursor-positioning/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Dimensions b/Lang/Pluto/Terminal-control-Dimensions new file mode 120000 index 0000000000..79b01b1a8a --- /dev/null +++ b/Lang/Pluto/Terminal-control-Dimensions @@ -0,0 +1 @@ +../../Task/Terminal-control-Dimensions/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Display-an-extended-character b/Lang/Pluto/Terminal-control-Display-an-extended-character new file mode 120000 index 0000000000..d9f4ec60f5 --- /dev/null +++ b/Lang/Pluto/Terminal-control-Display-an-extended-character @@ -0,0 +1 @@ +../../Task/Terminal-control-Display-an-extended-character/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Hiding-the-cursor b/Lang/Pluto/Terminal-control-Hiding-the-cursor new file mode 120000 index 0000000000..5126fbbc31 --- /dev/null +++ b/Lang/Pluto/Terminal-control-Hiding-the-cursor @@ -0,0 +1 @@ +../../Task/Terminal-control-Hiding-the-cursor/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Inverse-video b/Lang/Pluto/Terminal-control-Inverse-video new file mode 120000 index 0000000000..a011de6856 --- /dev/null +++ b/Lang/Pluto/Terminal-control-Inverse-video @@ -0,0 +1 @@ +../../Task/Terminal-control-Inverse-video/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Preserve-screen b/Lang/Pluto/Terminal-control-Preserve-screen new file mode 120000 index 0000000000..4985e385ae --- /dev/null +++ b/Lang/Pluto/Terminal-control-Preserve-screen @@ -0,0 +1 @@ +../../Task/Terminal-control-Preserve-screen/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Ringing-the-terminal-bell b/Lang/Pluto/Terminal-control-Ringing-the-terminal-bell new file mode 120000 index 0000000000..c14ff1f9fd --- /dev/null +++ b/Lang/Pluto/Terminal-control-Ringing-the-terminal-bell @@ -0,0 +1 @@ +../../Task/Terminal-control-Ringing-the-terminal-bell/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Terminal-control-Unicode-output b/Lang/Pluto/Terminal-control-Unicode-output new file mode 120000 index 0000000000..c67e68f15d --- /dev/null +++ b/Lang/Pluto/Terminal-control-Unicode-output @@ -0,0 +1 @@ +../../Task/Terminal-control-Unicode-output/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Test-integerness b/Lang/Pluto/Test-integerness new file mode 120000 index 0000000000..9a3717f805 --- /dev/null +++ b/Lang/Pluto/Test-integerness @@ -0,0 +1 @@ +../../Task/Test-integerness/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Time-a-function b/Lang/Pluto/Time-a-function new file mode 120000 index 0000000000..1ca7d0a7b7 --- /dev/null +++ b/Lang/Pluto/Time-a-function @@ -0,0 +1 @@ +../../Task/Time-a-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Total-circles-area b/Lang/Pluto/Total-circles-area new file mode 120000 index 0000000000..2f856ad28d --- /dev/null +++ b/Lang/Pluto/Total-circles-area @@ -0,0 +1 @@ +../../Task/Total-circles-area/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Totient-function b/Lang/Pluto/Totient-function new file mode 120000 index 0000000000..73b5eb6381 --- /dev/null +++ b/Lang/Pluto/Totient-function @@ -0,0 +1 @@ +../../Task/Totient-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Towers-of-Hanoi b/Lang/Pluto/Towers-of-Hanoi new file mode 120000 index 0000000000..9b1428dcf0 --- /dev/null +++ b/Lang/Pluto/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Trabb-Pardo-Knuth-algorithm b/Lang/Pluto/Trabb-Pardo-Knuth-algorithm new file mode 120000 index 0000000000..e85f9f54de --- /dev/null +++ b/Lang/Pluto/Trabb-Pardo-Knuth-algorithm @@ -0,0 +1 @@ +../../Task/Trabb-Pardo-Knuth-algorithm/Pluto \ No newline at end of file diff --git a/Lang/Pluto/UPC b/Lang/Pluto/UPC new file mode 120000 index 0000000000..477e69b6c6 --- /dev/null +++ b/Lang/Pluto/UPC @@ -0,0 +1 @@ +../../Task/UPC/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Unicode-strings b/Lang/Pluto/Unicode-strings new file mode 120000 index 0000000000..482c486148 --- /dev/null +++ b/Lang/Pluto/Unicode-strings @@ -0,0 +1 @@ +../../Task/Unicode-strings/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Unprimeable-numbers b/Lang/Pluto/Unprimeable-numbers new file mode 120000 index 0000000000..ec55975821 --- /dev/null +++ b/Lang/Pluto/Unprimeable-numbers @@ -0,0 +1 @@ +../../Task/Unprimeable-numbers/Pluto \ No newline at end of file diff --git a/Lang/Pluto/User-input-Text b/Lang/Pluto/User-input-Text new file mode 120000 index 0000000000..6c3afd2860 --- /dev/null +++ b/Lang/Pluto/User-input-Text @@ -0,0 +1 @@ +../../Task/User-input-Text/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Van-Eck-sequence b/Lang/Pluto/Van-Eck-sequence new file mode 120000 index 0000000000..d053bbc892 --- /dev/null +++ b/Lang/Pluto/Van-Eck-sequence @@ -0,0 +1 @@ +../../Task/Van-Eck-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Van-der-Corput-sequence b/Lang/Pluto/Van-der-Corput-sequence new file mode 120000 index 0000000000..e6ce56ddef --- /dev/null +++ b/Lang/Pluto/Van-der-Corput-sequence @@ -0,0 +1 @@ +../../Task/Van-der-Corput-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Variadic-function b/Lang/Pluto/Variadic-function new file mode 120000 index 0000000000..8d2be144f4 --- /dev/null +++ b/Lang/Pluto/Variadic-function @@ -0,0 +1 @@ +../../Task/Variadic-function/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Vector b/Lang/Pluto/Vector new file mode 120000 index 0000000000..fd56d6c8ab --- /dev/null +++ b/Lang/Pluto/Vector @@ -0,0 +1 @@ +../../Task/Vector/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Vector-products b/Lang/Pluto/Vector-products new file mode 120000 index 0000000000..83a09bc1a3 --- /dev/null +++ b/Lang/Pluto/Vector-products @@ -0,0 +1 @@ +../../Task/Vector-products/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Wagstaff-primes b/Lang/Pluto/Wagstaff-primes new file mode 120000 index 0000000000..d8a1a2f0da --- /dev/null +++ b/Lang/Pluto/Wagstaff-primes @@ -0,0 +1 @@ +../../Task/Wagstaff-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Wieferich-primes b/Lang/Pluto/Wieferich-primes new file mode 120000 index 0000000000..453231fbab --- /dev/null +++ b/Lang/Pluto/Wieferich-primes @@ -0,0 +1 @@ +../../Task/Wieferich-primes/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Y-combinator b/Lang/Pluto/Y-combinator new file mode 120000 index 0000000000..b356912f44 --- /dev/null +++ b/Lang/Pluto/Y-combinator @@ -0,0 +1 @@ +../../Task/Y-combinator/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Yellowstone-sequence b/Lang/Pluto/Yellowstone-sequence new file mode 120000 index 0000000000..f4fb013414 --- /dev/null +++ b/Lang/Pluto/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Zebra-puzzle b/Lang/Pluto/Zebra-puzzle new file mode 120000 index 0000000000..d1dee531e9 --- /dev/null +++ b/Lang/Pluto/Zebra-puzzle @@ -0,0 +1 @@ +../../Task/Zebra-puzzle/Pluto \ No newline at end of file diff --git a/Lang/Pluto/Zero-to-the-zero-power b/Lang/Pluto/Zero-to-the-zero-power new file mode 120000 index 0000000000..88cbcf1376 --- /dev/null +++ b/Lang/Pluto/Zero-to-the-zero-power @@ -0,0 +1 @@ +../../Task/Zero-to-the-zero-power/Pluto \ No newline at end of file diff --git a/Lang/PowerShell/AKS-test-for-primes b/Lang/PowerShell/AKS-test-for-primes new file mode 120000 index 0000000000..d5622ba541 --- /dev/null +++ b/Lang/PowerShell/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/M-bius-function b/Lang/PowerShell/M-bius-function new file mode 120000 index 0000000000..a50c276864 --- /dev/null +++ b/Lang/PowerShell/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/PowerShell \ No newline at end of file diff --git a/Lang/Prolog/100-prisoners b/Lang/Prolog/100-prisoners new file mode 120000 index 0000000000..f105600099 --- /dev/null +++ b/Lang/Prolog/100-prisoners @@ -0,0 +1 @@ +../../Task/100-prisoners/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Boolean-values b/Lang/Prolog/Boolean-values new file mode 120000 index 0000000000..a4d04329bd --- /dev/null +++ b/Lang/Prolog/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Damm-algorithm b/Lang/Prolog/Damm-algorithm new file mode 120000 index 0000000000..beadc26281 --- /dev/null +++ b/Lang/Prolog/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hello-world-Newline-omission b/Lang/Prolog/Hello-world-Newline-omission new file mode 120000 index 0000000000..c1a7a16c3a --- /dev/null +++ b/Lang/Prolog/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Prolog \ No newline at end of file diff --git a/Lang/Prolog/ISBN13-check-digit b/Lang/Prolog/ISBN13-check-digit new file mode 120000 index 0000000000..a76610ede1 --- /dev/null +++ b/Lang/Prolog/ISBN13-check-digit @@ -0,0 +1 @@ +../../Task/ISBN13-check-digit/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Integer-comparison b/Lang/Prolog/Integer-comparison new file mode 120000 index 0000000000..700709dfc3 --- /dev/null +++ b/Lang/Prolog/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Iterated-digits-squaring b/Lang/Prolog/Iterated-digits-squaring new file mode 120000 index 0000000000..2783b6cb96 --- /dev/null +++ b/Lang/Prolog/Iterated-digits-squaring @@ -0,0 +1 @@ +../../Task/Iterated-digits-squaring/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Josephus-problem b/Lang/Prolog/Josephus-problem new file mode 120000 index 0000000000..f88549c05c --- /dev/null +++ b/Lang/Prolog/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Magic-8-ball b/Lang/Prolog/Magic-8-ball new file mode 120000 index 0000000000..6daea6349e --- /dev/null +++ b/Lang/Prolog/Magic-8-ball @@ -0,0 +1 @@ +../../Task/Magic-8-ball/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Old-Russian-measure-of-length b/Lang/Prolog/Old-Russian-measure-of-length new file mode 120000 index 0000000000..d1594e7647 --- /dev/null +++ b/Lang/Prolog/Old-Russian-measure-of-length @@ -0,0 +1 @@ +../../Task/Old-Russian-measure-of-length/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Order-by-pair-comparisons b/Lang/Prolog/Order-by-pair-comparisons new file mode 120000 index 0000000000..b08bc67036 --- /dev/null +++ b/Lang/Prolog/Order-by-pair-comparisons @@ -0,0 +1 @@ +../../Task/Order-by-pair-comparisons/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Phrase-reversals b/Lang/Prolog/Phrase-reversals new file mode 120000 index 0000000000..1afa8eb5f5 --- /dev/null +++ b/Lang/Prolog/Phrase-reversals @@ -0,0 +1 @@ +../../Task/Phrase-reversals/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Population-count b/Lang/Prolog/Population-count new file mode 120000 index 0000000000..1ffa420c15 --- /dev/null +++ b/Lang/Prolog/Population-count @@ -0,0 +1 @@ +../../Task/Population-count/Prolog \ No newline at end of file diff --git a/Lang/Prolog/RPG-attributes-generator b/Lang/Prolog/RPG-attributes-generator new file mode 120000 index 0000000000..cde5e146a7 --- /dev/null +++ b/Lang/Prolog/RPG-attributes-generator @@ -0,0 +1 @@ +../../Task/RPG-attributes-generator/Prolog \ No newline at end of file diff --git a/Lang/Prolog/SEDOLs b/Lang/Prolog/SEDOLs new file mode 120000 index 0000000000..21d9643112 --- /dev/null +++ b/Lang/Prolog/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Semordnilap b/Lang/Prolog/Semordnilap new file mode 120000 index 0000000000..c4e2d18fc4 --- /dev/null +++ b/Lang/Prolog/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Sort-three-variables b/Lang/Prolog/Sort-three-variables new file mode 120000 index 0000000000..8518a9819c --- /dev/null +++ b/Lang/Prolog/Sort-three-variables @@ -0,0 +1 @@ +../../Task/Sort-three-variables/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Stem-and-leaf-plot b/Lang/Prolog/Stem-and-leaf-plot new file mode 120000 index 0000000000..8a3d5cbab0 --- /dev/null +++ b/Lang/Prolog/Stem-and-leaf-plot @@ -0,0 +1 @@ +../../Task/Stem-and-leaf-plot/Prolog \ No newline at end of file diff --git a/Lang/Prolog/String-concatenation b/Lang/Prolog/String-concatenation new file mode 120000 index 0000000000..47d572fb22 --- /dev/null +++ b/Lang/Prolog/String-concatenation @@ -0,0 +1 @@ +../../Task/String-concatenation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Thue-Morse b/Lang/Prolog/Thue-Morse new file mode 120000 index 0000000000..c42ff58a18 --- /dev/null +++ b/Lang/Prolog/Thue-Morse @@ -0,0 +1 @@ +../../Task/Thue-Morse/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Topswops b/Lang/Prolog/Topswops new file mode 120000 index 0000000000..20c5cfbba8 --- /dev/null +++ b/Lang/Prolog/Topswops @@ -0,0 +1 @@ +../../Task/Topswops/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Trabb-Pardo-Knuth-algorithm b/Lang/Prolog/Trabb-Pardo-Knuth-algorithm new file mode 120000 index 0000000000..dcd294e9ea --- /dev/null +++ b/Lang/Prolog/Trabb-Pardo-Knuth-algorithm @@ -0,0 +1 @@ +../../Task/Trabb-Pardo-Knuth-algorithm/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Wireworld b/Lang/Prolog/Wireworld new file mode 120000 index 0000000000..b45eaa2601 --- /dev/null +++ b/Lang/Prolog/Wireworld @@ -0,0 +1 @@ +../../Task/Wireworld/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Zero-to-the-zero-power b/Lang/Prolog/Zero-to-the-zero-power new file mode 120000 index 0000000000..5d3d1cb814 --- /dev/null +++ b/Lang/Prolog/Zero-to-the-zero-power @@ -0,0 +1 @@ +../../Task/Zero-to-the-zero-power/Prolog \ No newline at end of file diff --git a/Lang/Python/Ruth-Aaron-numbers b/Lang/Python/Ruth-Aaron-numbers new file mode 120000 index 0000000000..933b3d03bc --- /dev/null +++ b/Lang/Python/Ruth-Aaron-numbers @@ -0,0 +1 @@ +../../Task/Ruth-Aaron-numbers/Python \ No newline at end of file diff --git a/Lang/QB64/Trabb-Pardo-Knuth-algorithm b/Lang/QB64/Trabb-Pardo-Knuth-algorithm new file mode 120000 index 0000000000..bd61960412 --- /dev/null +++ b/Lang/QB64/Trabb-Pardo-Knuth-algorithm @@ -0,0 +1 @@ +../../Task/Trabb-Pardo-Knuth-algorithm/QB64 \ No newline at end of file diff --git a/Lang/R/Angles-geometric-normalization-and-conversion b/Lang/R/Angles-geometric-normalization-and-conversion new file mode 120000 index 0000000000..d1e56f507e --- /dev/null +++ b/Lang/R/Angles-geometric-normalization-and-conversion @@ -0,0 +1 @@ +../../Task/Angles-geometric-normalization-and-conversion/R \ No newline at end of file diff --git a/Lang/R/CUSIP b/Lang/R/CUSIP new file mode 120000 index 0000000000..e43a376539 --- /dev/null +++ b/Lang/R/CUSIP @@ -0,0 +1 @@ +../../Task/CUSIP/R \ No newline at end of file diff --git a/Lang/R/Continued-fraction b/Lang/R/Continued-fraction new file mode 120000 index 0000000000..8e8db83048 --- /dev/null +++ b/Lang/R/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/R \ No newline at end of file diff --git a/Lang/R/Cramers-rule b/Lang/R/Cramers-rule new file mode 120000 index 0000000000..839896c59f --- /dev/null +++ b/Lang/R/Cramers-rule @@ -0,0 +1 @@ +../../Task/Cramers-rule/R \ No newline at end of file diff --git a/Lang/R/Curzon-numbers b/Lang/R/Curzon-numbers new file mode 120000 index 0000000000..a381ff9f97 --- /dev/null +++ b/Lang/R/Curzon-numbers @@ -0,0 +1 @@ +../../Task/Curzon-numbers/R \ No newline at end of file diff --git a/Lang/R/Dijkstras-algorithm b/Lang/R/Dijkstras-algorithm new file mode 120000 index 0000000000..3bff2fae1d --- /dev/null +++ b/Lang/R/Dijkstras-algorithm @@ -0,0 +1 @@ +../../Task/Dijkstras-algorithm/R \ No newline at end of file diff --git a/Lang/R/Execute-HQ9+ b/Lang/R/Execute-HQ9+ new file mode 120000 index 0000000000..0972c0bb4f --- /dev/null +++ b/Lang/R/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/R \ No newline at end of file diff --git a/Lang/R/Factorial-primes b/Lang/R/Factorial-primes new file mode 120000 index 0000000000..90b75c9d38 --- /dev/null +++ b/Lang/R/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/R \ No newline at end of file diff --git a/Lang/R/Fibonacci-n-step-number-sequences b/Lang/R/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..1cf227761a --- /dev/null +++ b/Lang/R/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/R \ No newline at end of file diff --git a/Lang/R/Flipping-bits-game b/Lang/R/Flipping-bits-game new file mode 120000 index 0000000000..45f9cba067 --- /dev/null +++ b/Lang/R/Flipping-bits-game @@ -0,0 +1 @@ +../../Task/Flipping-bits-game/R \ No newline at end of file diff --git a/Lang/R/Floyd-Warshall-algorithm b/Lang/R/Floyd-Warshall-algorithm new file mode 120000 index 0000000000..f0f7534bc6 --- /dev/null +++ b/Lang/R/Floyd-Warshall-algorithm @@ -0,0 +1 @@ +../../Task/Floyd-Warshall-algorithm/R \ No newline at end of file diff --git a/Lang/R/Fractran b/Lang/R/Fractran new file mode 120000 index 0000000000..4684d03d23 --- /dev/null +++ b/Lang/R/Fractran @@ -0,0 +1 @@ +../../Task/Fractran/R \ No newline at end of file diff --git a/Lang/R/Giuga-numbers b/Lang/R/Giuga-numbers new file mode 120000 index 0000000000..e45399fcf4 --- /dev/null +++ b/Lang/R/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/R \ No newline at end of file diff --git a/Lang/R/Greedy-algorithm-for-Egyptian-fractions b/Lang/R/Greedy-algorithm-for-Egyptian-fractions new file mode 120000 index 0000000000..142b97c38d --- /dev/null +++ b/Lang/R/Greedy-algorithm-for-Egyptian-fractions @@ -0,0 +1 @@ +../../Task/Greedy-algorithm-for-Egyptian-fractions/R \ No newline at end of file diff --git a/Lang/R/Humble-numbers b/Lang/R/Humble-numbers new file mode 120000 index 0000000000..66447beec9 --- /dev/null +++ b/Lang/R/Humble-numbers @@ -0,0 +1 @@ +../../Task/Humble-numbers/R \ No newline at end of file diff --git a/Lang/R/M-bius-function b/Lang/R/M-bius-function new file mode 120000 index 0000000000..54d202ad87 --- /dev/null +++ b/Lang/R/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/R \ No newline at end of file diff --git a/Lang/R/Parse-an-IP-Address b/Lang/R/Parse-an-IP-Address new file mode 120000 index 0000000000..9f23986592 --- /dev/null +++ b/Lang/R/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/R \ No newline at end of file diff --git a/Lang/R/Rename-a-file b/Lang/R/Rename-a-file new file mode 120000 index 0000000000..d3214c3f95 --- /dev/null +++ b/Lang/R/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/R \ No newline at end of file diff --git a/Lang/R/Repunit-primes b/Lang/R/Repunit-primes new file mode 120000 index 0000000000..9ae6100164 --- /dev/null +++ b/Lang/R/Repunit-primes @@ -0,0 +1 @@ +../../Task/Repunit-primes/R \ No newline at end of file diff --git a/Lang/R/Retrieve-and-search-chat-history b/Lang/R/Retrieve-and-search-chat-history new file mode 120000 index 0000000000..6f350b7b8c --- /dev/null +++ b/Lang/R/Retrieve-and-search-chat-history @@ -0,0 +1 @@ +../../Task/Retrieve-and-search-chat-history/R \ No newline at end of file diff --git a/Lang/R/Shoelace-formula-for-polygonal-area b/Lang/R/Shoelace-formula-for-polygonal-area new file mode 120000 index 0000000000..8e6ea3fcc6 --- /dev/null +++ b/Lang/R/Shoelace-formula-for-polygonal-area @@ -0,0 +1 @@ +../../Task/Shoelace-formula-for-polygonal-area/R \ No newline at end of file diff --git a/Lang/R/Soloways-recurring-rainfall b/Lang/R/Soloways-recurring-rainfall new file mode 120000 index 0000000000..33b1f84311 --- /dev/null +++ b/Lang/R/Soloways-recurring-rainfall @@ -0,0 +1 @@ +../../Task/Soloways-recurring-rainfall/R \ No newline at end of file diff --git a/Lang/R/Split-a-character-string-based-on-change-of-character b/Lang/R/Split-a-character-string-based-on-change-of-character new file mode 120000 index 0000000000..16a92812f1 --- /dev/null +++ b/Lang/R/Split-a-character-string-based-on-change-of-character @@ -0,0 +1 @@ +../../Task/Split-a-character-string-based-on-change-of-character/R \ No newline at end of file diff --git a/Lang/R/String-interpolation-included- b/Lang/R/String-interpolation-included- new file mode 120000 index 0000000000..f311002546 --- /dev/null +++ b/Lang/R/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/R \ No newline at end of file diff --git a/Lang/R/String-matching b/Lang/R/String-matching new file mode 120000 index 0000000000..2461134ac0 --- /dev/null +++ b/Lang/R/String-matching @@ -0,0 +1 @@ +../../Task/String-matching/R \ No newline at end of file diff --git a/Lang/R/Substring-Top-and-tail b/Lang/R/Substring-Top-and-tail new file mode 120000 index 0000000000..271cd3b15f --- /dev/null +++ b/Lang/R/Substring-Top-and-tail @@ -0,0 +1 @@ +../../Task/Substring-Top-and-tail/R \ No newline at end of file diff --git a/Lang/R/The-Name-Game b/Lang/R/The-Name-Game new file mode 120000 index 0000000000..a5e981bf52 --- /dev/null +++ b/Lang/R/The-Name-Game @@ -0,0 +1 @@ +../../Task/The-Name-Game/R \ No newline at end of file diff --git a/Lang/R/Tonelli-Shanks-algorithm b/Lang/R/Tonelli-Shanks-algorithm new file mode 120000 index 0000000000..2ad48c9cd5 --- /dev/null +++ b/Lang/R/Tonelli-Shanks-algorithm @@ -0,0 +1 @@ +../../Task/Tonelli-Shanks-algorithm/R \ No newline at end of file diff --git a/Lang/R/Wieferich-primes b/Lang/R/Wieferich-primes new file mode 120000 index 0000000000..1c103bdf36 --- /dev/null +++ b/Lang/R/Wieferich-primes @@ -0,0 +1 @@ +../../Task/Wieferich-primes/R \ No newline at end of file diff --git a/Lang/R/Write-entire-file b/Lang/R/Write-entire-file new file mode 120000 index 0000000000..2972bb07fe --- /dev/null +++ b/Lang/R/Write-entire-file @@ -0,0 +1 @@ +../../Task/Write-entire-file/R \ No newline at end of file diff --git a/Lang/REBOL/00-LANG.txt b/Lang/REBOL/00-LANG.txt index 0117c8198c..f5919f4e5a 100644 --- a/Lang/REBOL/00-LANG.txt +++ b/Lang/REBOL/00-LANG.txt @@ -1,3 +1,5 @@ {{stub}}{{language|REBOL |site=http://rebol.com}} -REBOL stands for Relative Expression Based Object Language. \ No newline at end of file +REBOL stands for Relative Expression Based Object Language. + +See also: [https://rosettacode.org/wiki/Category:Rebol Category:Rebol] \ No newline at end of file diff --git a/Lang/REBOL/9-billion-names-of-God-the-integer b/Lang/REBOL/9-billion-names-of-God-the-integer new file mode 120000 index 0000000000..d19b039600 --- /dev/null +++ b/Lang/REBOL/9-billion-names-of-God-the-integer @@ -0,0 +1 @@ +../../Task/9-billion-names-of-God-the-integer/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Ackermann-function b/Lang/REBOL/Ackermann-function new file mode 120000 index 0000000000..bb556d5ce8 --- /dev/null +++ b/Lang/REBOL/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Loop-over-multiple-arrays-simultaneously b/Lang/REBOL/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..509d196c87 --- /dev/null +++ b/Lang/REBOL/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Loops-Increment-loop-index-within-loop-body b/Lang/REBOL/Loops-Increment-loop-index-within-loop-body new file mode 120000 index 0000000000..1d1b2df2c6 --- /dev/null +++ b/Lang/REBOL/Loops-Increment-loop-index-within-loop-body @@ -0,0 +1 @@ +../../Task/Loops-Increment-loop-index-within-loop-body/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Loops-With-multiple-ranges b/Lang/REBOL/Loops-With-multiple-ranges new file mode 120000 index 0000000000..bd25edb4b9 --- /dev/null +++ b/Lang/REBOL/Loops-With-multiple-ranges @@ -0,0 +1 @@ +../../Task/Loops-With-multiple-ranges/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Loops-Wrong-ranges b/Lang/REBOL/Loops-Wrong-ranges new file mode 120000 index 0000000000..a8f17c4209 --- /dev/null +++ b/Lang/REBOL/Loops-Wrong-ranges @@ -0,0 +1 @@ +../../Task/Loops-Wrong-ranges/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Object-serialization b/Lang/REBOL/Object-serialization new file mode 120000 index 0000000000..71f73b27eb --- /dev/null +++ b/Lang/REBOL/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Polyspiral b/Lang/REBOL/Polyspiral new file mode 120000 index 0000000000..70a487676d --- /dev/null +++ b/Lang/REBOL/Polyspiral @@ -0,0 +1 @@ +../../Task/Polyspiral/REBOL \ No newline at end of file diff --git a/Lang/REBOL/SHA-1 b/Lang/REBOL/SHA-1 new file mode 120000 index 0000000000..b430af646a --- /dev/null +++ b/Lang/REBOL/SHA-1 @@ -0,0 +1 @@ +../../Task/SHA-1/REBOL \ No newline at end of file diff --git a/Lang/REBOL/SHA-256 b/Lang/REBOL/SHA-256 new file mode 120000 index 0000000000..b5f39ed805 --- /dev/null +++ b/Lang/REBOL/SHA-256 @@ -0,0 +1 @@ +../../Task/SHA-256/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Semordnilap b/Lang/REBOL/Semordnilap new file mode 120000 index 0000000000..fee60064bb --- /dev/null +++ b/Lang/REBOL/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/REBOL \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/00-LANG.txt b/Lang/RISC-V-Assembly/00-LANG.txt index f524ed95fb..6a2bfde754 100644 --- a/Lang/RISC-V-Assembly/00-LANG.txt +++ b/Lang/RISC-V-Assembly/00-LANG.txt @@ -1,4 +1,76 @@ {{language|RISC-V Assembly}}[https://riscv.org Risc-V] is an open source hardware instruction set architecture based on the principle of a '''R'''educed '''I'''nstruction '''S'''et '''C'''omputer. The project was started by the university of California, Berkeley in 2010. This site refers to the Risc-V assembly language. ([https://en.wikipedia.org/wiki/RISC-V#Software Wikipedia page]), Website: [https://riscv.org https://riscv.org]. +'''Riscv on raspberry pico 2''' + +A pico2 with the chip rp2335 contains 2 cores hazard3 with risc v assembly +it is possible to programm assembly riscv with the sdk C++ and a compiler riscv32-unknown-elf-as.exe + +It is also possible to programm without SDK but it is necessary to write functions for init +the clocks and to communicate for usb connexion. + +install under Windows11 (or see documentation raspberry py pico SDK) : + +Create main folder (ex : \pico2) + +install SDK C++ (see instructions in raspberry pi pico2 SDK documentation) + +install toolchaine under \Pico2\tools\bin from + +https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-2/riscv-toolchain-14-x64-win.zip + + +Create work folder (ex : \pico2\hello) + +Create file CMakeLists.txt (see instructions in raspberry pi pico2 SDK documentation) + +Create program hello.s with a editor + +Copy a file pico_sdk_import.cmake from \pico2\pico-sdk\external + +Create a folder build under \pico2\hello + +Go to this folder + +Compile program with : + + cmake -DPICO_PLATFORM=rp2350-riscv -DPICO_TOOLCHAIN_PATH=E:\Pico2\tools\bin -G "NMake Makefiles" .. + +and + nmake + +copy the file .uf2 to raspberry pico2 (see documentation raspberry pi pico2) + +Start serial connexion on host (ex: putty on windows11) + +Example CMakeLists.txt : + +cmake_minimum_required(VERSION 3.13) + +include(pico_sdk_import.cmake) + +project(hello C CXX ASM) + +set(CMAKE_C_STANDARD 11) + +set(CMAKE_CXX_STANDARD 17) + +pico_sdk_init() + +add_executable(hello +hello.s # pgm source assembly riscv +) + +target_link_libraries(hello pico_stdlib) + +pico_enable_stdio_usb(hello 1) + +pico_enable_stdio_uart(hello 0) + +pico_add_extra_outputs(hello) + +see source program on hello world rosetta code + +cmake -DPython3_EXECUTABLE=C:\Users\Vincent\AppData\Local\Microsoft\WindowsApps\python3.10.exe -DPICO_PLATFORM=rp2350-riscv -DPICO_TOOLCHAIN_PATH=E:\Pico2\tools\bin -DPICO_SDK_PATH=..\..\..\pico-sdk -G "NMake Makefiles" .. + [[Category:Assembler language]] [[Category:Assembly]] \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/Address-of-a-variable b/Lang/RISC-V-Assembly/Address-of-a-variable new file mode 120000 index 0000000000..7e7b85f7fc --- /dev/null +++ b/Lang/RISC-V-Assembly/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/RISC-V-Assembly \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/Arithmetic-Integer b/Lang/RISC-V-Assembly/Arithmetic-Integer new file mode 120000 index 0000000000..41172f4754 --- /dev/null +++ b/Lang/RISC-V-Assembly/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/RISC-V-Assembly \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/Binary-digits b/Lang/RISC-V-Assembly/Binary-digits new file mode 120000 index 0000000000..45c4e871d7 --- /dev/null +++ b/Lang/RISC-V-Assembly/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/RISC-V-Assembly \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/Hello-world-Newbie b/Lang/RISC-V-Assembly/Hello-world-Newbie new file mode 120000 index 0000000000..5721ad4125 --- /dev/null +++ b/Lang/RISC-V-Assembly/Hello-world-Newbie @@ -0,0 +1 @@ +../../Task/Hello-world-Newbie/RISC-V-Assembly \ No newline at end of file diff --git a/Lang/RISC-V-Assembly/Include-a-file b/Lang/RISC-V-Assembly/Include-a-file new file mode 120000 index 0000000000..2742cb0a60 --- /dev/null +++ b/Lang/RISC-V-Assembly/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/RISC-V-Assembly \ No newline at end of file diff --git a/Lang/Raku/Play-recorded-sounds b/Lang/Raku/Play-recorded-sounds new file mode 120000 index 0000000000..7d18ecbdee --- /dev/null +++ b/Lang/Raku/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Raku \ No newline at end of file diff --git a/Lang/Red/Address-of-a-variable b/Lang/Red/Address-of-a-variable new file mode 120000 index 0000000000..81b5a1a171 --- /dev/null +++ b/Lang/Red/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Red \ No newline at end of file diff --git a/Lang/Red/Arithmetic-Integer b/Lang/Red/Arithmetic-Integer new file mode 120000 index 0000000000..cb3f74d046 --- /dev/null +++ b/Lang/Red/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Red \ No newline at end of file diff --git a/Lang/Red/Arithmetic-evaluation b/Lang/Red/Arithmetic-evaluation new file mode 120000 index 0000000000..c6c5c304b5 --- /dev/null +++ b/Lang/Red/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Red \ No newline at end of file diff --git a/Lang/Red/Calendar b/Lang/Red/Calendar new file mode 120000 index 0000000000..3283fd5906 --- /dev/null +++ b/Lang/Red/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/Red \ No newline at end of file diff --git a/Lang/Red/Calendar---for-REAL-programmers b/Lang/Red/Calendar---for-REAL-programmers new file mode 120000 index 0000000000..e0db1bd24f --- /dev/null +++ b/Lang/Red/Calendar---for-REAL-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-REAL-programmers/Red \ No newline at end of file diff --git a/Lang/Red/Currying b/Lang/Red/Currying new file mode 120000 index 0000000000..a40d4bf838 --- /dev/null +++ b/Lang/Red/Currying @@ -0,0 +1 @@ +../../Task/Currying/Red \ No newline at end of file diff --git a/Lang/Red/Five-weekends b/Lang/Red/Five-weekends new file mode 120000 index 0000000000..4b364097a6 --- /dev/null +++ b/Lang/Red/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Red \ No newline at end of file diff --git a/Lang/Red/Logical-operations b/Lang/Red/Logical-operations new file mode 120000 index 0000000000..b02eaed36f --- /dev/null +++ b/Lang/Red/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Red \ No newline at end of file diff --git a/Lang/Red/Parsing-RPN-calculator-algorithm b/Lang/Red/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..f68a7bf5c6 --- /dev/null +++ b/Lang/Red/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Red \ No newline at end of file diff --git a/Lang/Red/Parsing-RPN-to-infix-conversion b/Lang/Red/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..27fb99e707 --- /dev/null +++ b/Lang/Red/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Red \ No newline at end of file diff --git a/Lang/Red/Parsing-Shunting-yard-algorithm b/Lang/Red/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..64583c9508 --- /dev/null +++ b/Lang/Red/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Red \ No newline at end of file diff --git a/Lang/Red/Towers-of-Hanoi b/Lang/Red/Towers-of-Hanoi new file mode 120000 index 0000000000..112b276dee --- /dev/null +++ b/Lang/Red/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/Red \ No newline at end of file diff --git a/Lang/Refal/Tokenize-a-string b/Lang/Refal/Tokenize-a-string new file mode 120000 index 0000000000..f8ac7459de --- /dev/null +++ b/Lang/Refal/Tokenize-a-string @@ -0,0 +1 @@ +../../Task/Tokenize-a-string/Refal \ No newline at end of file diff --git a/Lang/Rhombus/00-LANG.txt b/Lang/Rhombus/00-LANG.txt new file mode 100644 index 0000000000..ef9932595f --- /dev/null +++ b/Lang/Rhombus/00-LANG.txt @@ -0,0 +1,5 @@ +{{language +|exec=both +|gc=yes +|site=https://rhombus-lang.org/ +}} \ No newline at end of file diff --git a/Lang/Rhombus/00-META.yaml b/Lang/Rhombus/00-META.yaml new file mode 100644 index 0000000000..732b96d2eb --- /dev/null +++ b/Lang/Rhombus/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Rhombus diff --git a/Lang/Rhombus/99-bottles-of-beer b/Lang/Rhombus/99-bottles-of-beer new file mode 120000 index 0000000000..bcb9ee7049 --- /dev/null +++ b/Lang/Rhombus/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Arbitrary-precision-integers-included- b/Lang/Rhombus/Arbitrary-precision-integers-included- new file mode 120000 index 0000000000..31558e19d7 --- /dev/null +++ b/Lang/Rhombus/Arbitrary-precision-integers-included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included-/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Caesar-cipher b/Lang/Rhombus/Caesar-cipher new file mode 120000 index 0000000000..dd9f5453ed --- /dev/null +++ b/Lang/Rhombus/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Factorial b/Lang/Rhombus/Factorial new file mode 120000 index 0000000000..92b62c830f --- /dev/null +++ b/Lang/Rhombus/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Fibonacci-sequence b/Lang/Rhombus/Fibonacci-sequence new file mode 120000 index 0000000000..d496e8a0b2 --- /dev/null +++ b/Lang/Rhombus/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/FizzBuzz b/Lang/Rhombus/FizzBuzz new file mode 120000 index 0000000000..5740514b72 --- /dev/null +++ b/Lang/Rhombus/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Guess-the-number-With-feedback b/Lang/Rhombus/Guess-the-number-With-feedback new file mode 120000 index 0000000000..c51dd719ba --- /dev/null +++ b/Lang/Rhombus/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Hello-world-Text b/Lang/Rhombus/Hello-world-Text new file mode 120000 index 0000000000..11fb03859d --- /dev/null +++ b/Lang/Rhombus/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Inheritance-Single b/Lang/Rhombus/Inheritance-Single new file mode 120000 index 0000000000..2f478862d8 --- /dev/null +++ b/Lang/Rhombus/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Polymorphism b/Lang/Rhombus/Polymorphism new file mode 120000 index 0000000000..a5540935b5 --- /dev/null +++ b/Lang/Rhombus/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Rhombus \ No newline at end of file diff --git a/Lang/Rhombus/Rot-13 b/Lang/Rhombus/Rot-13 new file mode 120000 index 0000000000..369226ff2f --- /dev/null +++ b/Lang/Rhombus/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Rhombus \ No newline at end of file diff --git a/Lang/Ring/Compare-a-list-of-strings b/Lang/Ring/Compare-a-list-of-strings new file mode 120000 index 0000000000..308f7db9af --- /dev/null +++ b/Lang/Ring/Compare-a-list-of-strings @@ -0,0 +1 @@ +../../Task/Compare-a-list-of-strings/Ring \ No newline at end of file diff --git a/Lang/Ring/Wagstaff-primes b/Lang/Ring/Wagstaff-primes new file mode 120000 index 0000000000..877433f537 --- /dev/null +++ b/Lang/Ring/Wagstaff-primes @@ -0,0 +1 @@ +../../Task/Wagstaff-primes/Ring \ No newline at end of file diff --git a/Lang/Run-BASIC/Josephus-problem b/Lang/Run-BASIC/Josephus-problem new file mode 120000 index 0000000000..d5ce7e543e --- /dev/null +++ b/Lang/Run-BASIC/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Run-BASIC \ No newline at end of file diff --git a/Lang/Rust/Break-OO-privacy b/Lang/Rust/Break-OO-privacy new file mode 120000 index 0000000000..37b6e0d417 --- /dev/null +++ b/Lang/Rust/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Rust \ No newline at end of file diff --git a/Lang/Rust/Camel-case-and-snake-case b/Lang/Rust/Camel-case-and-snake-case new file mode 120000 index 0000000000..5c92d90b28 --- /dev/null +++ b/Lang/Rust/Camel-case-and-snake-case @@ -0,0 +1 @@ +../../Task/Camel-case-and-snake-case/Rust \ No newline at end of file diff --git a/Lang/Rust/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Rust/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..7e0955d429 --- /dev/null +++ b/Lang/Rust/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Rust \ No newline at end of file diff --git a/Lang/Rust/Cyclops-numbers b/Lang/Rust/Cyclops-numbers new file mode 120000 index 0000000000..044bb62e43 --- /dev/null +++ b/Lang/Rust/Cyclops-numbers @@ -0,0 +1 @@ +../../Task/Cyclops-numbers/Rust \ No newline at end of file diff --git a/Lang/Rust/Deconvolution-1D b/Lang/Rust/Deconvolution-1D new file mode 120000 index 0000000000..d02a914ea3 --- /dev/null +++ b/Lang/Rust/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Rust \ No newline at end of file diff --git a/Lang/Rust/Deconvolution-2D+ b/Lang/Rust/Deconvolution-2D+ new file mode 120000 index 0000000000..4b9cb470ba --- /dev/null +++ b/Lang/Rust/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/Rust \ No newline at end of file diff --git a/Lang/Rust/Determine-if-two-triangles-overlap b/Lang/Rust/Determine-if-two-triangles-overlap new file mode 120000 index 0000000000..2bc1e5e063 --- /dev/null +++ b/Lang/Rust/Determine-if-two-triangles-overlap @@ -0,0 +1 @@ +../../Task/Determine-if-two-triangles-overlap/Rust \ No newline at end of file diff --git a/Lang/Rust/Duffinian-numbers b/Lang/Rust/Duffinian-numbers new file mode 120000 index 0000000000..5a84e9b8ff --- /dev/null +++ b/Lang/Rust/Duffinian-numbers @@ -0,0 +1 @@ +../../Task/Duffinian-numbers/Rust \ No newline at end of file diff --git a/Lang/Rust/Elliptic-curve-arithmetic b/Lang/Rust/Elliptic-curve-arithmetic new file mode 120000 index 0000000000..cb1c49b6dd --- /dev/null +++ b/Lang/Rust/Elliptic-curve-arithmetic @@ -0,0 +1 @@ +../../Task/Elliptic-curve-arithmetic/Rust \ No newline at end of file diff --git a/Lang/Rust/Faulhabers-triangle b/Lang/Rust/Faulhabers-triangle new file mode 120000 index 0000000000..49b5537877 --- /dev/null +++ b/Lang/Rust/Faulhabers-triangle @@ -0,0 +1 @@ +../../Task/Faulhabers-triangle/Rust \ No newline at end of file diff --git a/Lang/Rust/Fractran b/Lang/Rust/Fractran new file mode 120000 index 0000000000..46ed1ab96e --- /dev/null +++ b/Lang/Rust/Fractran @@ -0,0 +1 @@ +../../Task/Fractran/Rust \ No newline at end of file diff --git a/Lang/Rust/Humble-numbers b/Lang/Rust/Humble-numbers new file mode 120000 index 0000000000..001b631312 --- /dev/null +++ b/Lang/Rust/Humble-numbers @@ -0,0 +1 @@ +../../Task/Humble-numbers/Rust \ No newline at end of file diff --git a/Lang/Rust/Knapsack-problem-Bounded b/Lang/Rust/Knapsack-problem-Bounded new file mode 120000 index 0000000000..db57c7551f --- /dev/null +++ b/Lang/Rust/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Rust \ No newline at end of file diff --git a/Lang/Rust/Mayan-calendar b/Lang/Rust/Mayan-calendar new file mode 120000 index 0000000000..8da8002279 --- /dev/null +++ b/Lang/Rust/Mayan-calendar @@ -0,0 +1 @@ +../../Task/Mayan-calendar/Rust \ No newline at end of file diff --git a/Lang/Rust/Meissel-Mertens-constant b/Lang/Rust/Meissel-Mertens-constant new file mode 120000 index 0000000000..30f216e193 --- /dev/null +++ b/Lang/Rust/Meissel-Mertens-constant @@ -0,0 +1 @@ +../../Task/Meissel-Mertens-constant/Rust \ No newline at end of file diff --git a/Lang/Rust/Modular-arithmetic b/Lang/Rust/Modular-arithmetic new file mode 120000 index 0000000000..bf3b8fce76 --- /dev/null +++ b/Lang/Rust/Modular-arithmetic @@ -0,0 +1 @@ +../../Task/Modular-arithmetic/Rust \ No newline at end of file diff --git a/Lang/Rust/Multiple-regression b/Lang/Rust/Multiple-regression new file mode 120000 index 0000000000..84425ee458 --- /dev/null +++ b/Lang/Rust/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Rust \ No newline at end of file diff --git a/Lang/Rust/Ramanujan-primes-twins b/Lang/Rust/Ramanujan-primes-twins new file mode 120000 index 0000000000..ec360cedbc --- /dev/null +++ b/Lang/Rust/Ramanujan-primes-twins @@ -0,0 +1 @@ +../../Task/Ramanujan-primes-twins/Rust \ No newline at end of file diff --git a/Lang/Rust/Singleton b/Lang/Rust/Singleton new file mode 120000 index 0000000000..480988c162 --- /dev/null +++ b/Lang/Rust/Singleton @@ -0,0 +1 @@ +../../Task/Singleton/Rust \ No newline at end of file diff --git a/Lang/Rust/Sokoban b/Lang/Rust/Sokoban new file mode 120000 index 0000000000..57d1bc73b3 --- /dev/null +++ b/Lang/Rust/Sokoban @@ -0,0 +1 @@ +../../Task/Sokoban/Rust \ No newline at end of file diff --git a/Lang/Rust/Substitution-cipher b/Lang/Rust/Substitution-cipher new file mode 120000 index 0000000000..aa3ad1011d --- /dev/null +++ b/Lang/Rust/Substitution-cipher @@ -0,0 +1 @@ +../../Task/Substitution-cipher/Rust \ No newline at end of file diff --git a/Lang/Rust/Tree-datastructures b/Lang/Rust/Tree-datastructures new file mode 120000 index 0000000000..37b567712c --- /dev/null +++ b/Lang/Rust/Tree-datastructures @@ -0,0 +1 @@ +../../Task/Tree-datastructures/Rust \ No newline at end of file diff --git a/Lang/Rust/UPC b/Lang/Rust/UPC new file mode 120000 index 0000000000..775faf96be --- /dev/null +++ b/Lang/Rust/UPC @@ -0,0 +1 @@ +../../Task/UPC/Rust \ No newline at end of file diff --git a/Lang/Rust/War-card-game b/Lang/Rust/War-card-game new file mode 120000 index 0000000000..bc45c42250 --- /dev/null +++ b/Lang/Rust/War-card-game @@ -0,0 +1 @@ +../../Task/War-card-game/Rust \ No newline at end of file diff --git a/Lang/S-BASIC/Sorting-algorithms-Insertion-sort b/Lang/S-BASIC/Sorting-algorithms-Insertion-sort new file mode 120000 index 0000000000..60391d0e75 --- /dev/null +++ b/Lang/S-BASIC/Sorting-algorithms-Insertion-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Insertion-sort/S-BASIC \ No newline at end of file diff --git a/Lang/SETL/Monte-Carlo-methods b/Lang/SETL/Monte-Carlo-methods new file mode 120000 index 0000000000..da6adaf82b --- /dev/null +++ b/Lang/SETL/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/SETL \ No newline at end of file diff --git a/Lang/SETL/Tokenize-a-string b/Lang/SETL/Tokenize-a-string new file mode 120000 index 0000000000..bd55474aef --- /dev/null +++ b/Lang/SETL/Tokenize-a-string @@ -0,0 +1 @@ +../../Task/Tokenize-a-string/SETL \ No newline at end of file diff --git a/Lang/Scala/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Scala/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..03b359aab4 --- /dev/null +++ b/Lang/Scala/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Scala \ No newline at end of file diff --git a/Lang/Scala/Tonelli-Shanks-algorithm b/Lang/Scala/Tonelli-Shanks-algorithm new file mode 120000 index 0000000000..a29f0a9b6f --- /dev/null +++ b/Lang/Scala/Tonelli-Shanks-algorithm @@ -0,0 +1 @@ +../../Task/Tonelli-Shanks-algorithm/Scala \ No newline at end of file diff --git a/Lang/Scala/UPC b/Lang/Scala/UPC new file mode 120000 index 0000000000..bc3faec2ef --- /dev/null +++ b/Lang/Scala/UPC @@ -0,0 +1 @@ +../../Task/UPC/Scala \ No newline at end of file diff --git a/Lang/Scheme/Own-digits-power-sum b/Lang/Scheme/Own-digits-power-sum new file mode 120000 index 0000000000..0897a09d02 --- /dev/null +++ b/Lang/Scheme/Own-digits-power-sum @@ -0,0 +1 @@ +../../Task/Own-digits-power-sum/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Pick-random-element b/Lang/Scheme/Pick-random-element new file mode 120000 index 0000000000..5745ea287d --- /dev/null +++ b/Lang/Scheme/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Scheme \ No newline at end of file diff --git a/Lang/SequenceL/00-LANG.txt b/Lang/SequenceL/00-LANG.txt index 3c3098bf74..5e5a95101f 100644 --- a/Lang/SequenceL/00-LANG.txt +++ b/Lang/SequenceL/00-LANG.txt @@ -3,7 +3,7 @@ |strength=strong |safety=safe |checking=static -|site=http://sequencel.com +|site= |tags=sequencel |hopl=no}} {{language programming paradigm|Declarative}} diff --git a/Lang/Swift/AVL-tree b/Lang/Swift/AVL-tree new file mode 120000 index 0000000000..ff46aae38e --- /dev/null +++ b/Lang/Swift/AVL-tree @@ -0,0 +1 @@ +../../Task/AVL-tree/Swift \ No newline at end of file diff --git a/Lang/Swift/Boyer-Moore-string-search b/Lang/Swift/Boyer-Moore-string-search new file mode 120000 index 0000000000..d0d21c21e5 --- /dev/null +++ b/Lang/Swift/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/Swift \ No newline at end of file diff --git a/Lang/Swift/Chaocipher b/Lang/Swift/Chaocipher new file mode 120000 index 0000000000..6e9ab31392 --- /dev/null +++ b/Lang/Swift/Chaocipher @@ -0,0 +1 @@ +../../Task/Chaocipher/Swift \ No newline at end of file diff --git a/Lang/Swift/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- b/Lang/Swift/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- new file mode 120000 index 0000000000..bfa2341e33 --- /dev/null +++ b/Lang/Swift/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n- @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-ng-continued-fraction-n-/Swift \ No newline at end of file diff --git a/Lang/Swift/Floyd-Warshall-algorithm b/Lang/Swift/Floyd-Warshall-algorithm new file mode 120000 index 0000000000..d1366dce22 --- /dev/null +++ b/Lang/Swift/Floyd-Warshall-algorithm @@ -0,0 +1 @@ +../../Task/Floyd-Warshall-algorithm/Swift \ No newline at end of file diff --git a/Lang/Swift/K-d-tree b/Lang/Swift/K-d-tree new file mode 120000 index 0000000000..a4758e806b --- /dev/null +++ b/Lang/Swift/K-d-tree @@ -0,0 +1 @@ +../../Task/K-d-tree/Swift \ No newline at end of file diff --git a/Lang/Swift/Parse-an-IP-Address b/Lang/Swift/Parse-an-IP-Address new file mode 120000 index 0000000000..b157f3f9a2 --- /dev/null +++ b/Lang/Swift/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Swift \ No newline at end of file diff --git a/Lang/TAV/00-LANG.txt b/Lang/TAV/00-LANG.txt new file mode 100644 index 0000000000..bb9d8890a2 --- /dev/null +++ b/Lang/TAV/00-LANG.txt @@ -0,0 +1,46 @@ +{{language|TAV +|site=https://tavpl.de +|untyped=yes +|exec=machine +|gc=no +|parampass=reference +|checking=dynamic +|safety=safe +}} +{{language programming paradigm|Procedural}} +{{CompileOnline}} + +'''TAV''' is the '''terse and verbose''' +language that borrows from [[Python]], Stage2, [[Genie]] and more. + +Its most outstanding feature is the use of templates for function calls instead of the +traditional function_name(parameter, parameter, ...) form. +Matched parenthesis are consequently rarely necessary. + +Summary of important points: + +* C precompiler, should work on any system with a reasonable C compiler +* Block structuring by indentation, like in Python; line oriented +* No keywords in the core language, only symbols (i.e. bigraphs) +* Variables are of any kind (type) dynamically; no declarations necessary +* Function definition and calls by word sequences with interspersed parameters, often no parenthesis needed +* Maps (dictionaries) with all kinds of keys (except floating-point numbers) +* Rows (arrays) if the keys are dense integers, dynamically expanding +* Arbitrary precision integer numbers +* Dynamic Unicode strings +* Fields for extra data in rows and maps +* Attributes for information about an item +* Fault items for reliable error handling +* Reference counting avoids unsolicited delays for garbage-collection +* Basic support for object-oriented programming (no inheritance) +* Discretionary type system specified, but not yet tested +* Publication syntax with common English keywords instead of symbols +* Bindings to SDL, Cairo and GTK (proof-of-concept level) + +Many examples can be run via copy and paste in the Playground. + +Because there are no keywords and rarely nested parenthesis (of any kind), +syntax highlighting is not used. + +==Links== +*[[https://tavpl.de/TAV-Online TAV Online Playground]] \ No newline at end of file diff --git a/Lang/TAV/00-META.yaml b/Lang/TAV/00-META.yaml new file mode 100644 index 0000000000..94650f22a2 --- /dev/null +++ b/Lang/TAV/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:TAV diff --git a/Lang/TAV/A+B b/Lang/TAV/A+B new file mode 120000 index 0000000000..a5e97665e3 --- /dev/null +++ b/Lang/TAV/A+B @@ -0,0 +1 @@ +../../Task/A+B/TAV \ No newline at end of file diff --git a/Lang/TAV/Ackermann-function b/Lang/TAV/Ackermann-function new file mode 120000 index 0000000000..237de07217 --- /dev/null +++ b/Lang/TAV/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/TAV \ No newline at end of file diff --git a/Lang/TAV/Anagrams b/Lang/TAV/Anagrams new file mode 120000 index 0000000000..335a62bd1c --- /dev/null +++ b/Lang/TAV/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/TAV \ No newline at end of file diff --git a/Lang/TAV/Arithmetic-Integer b/Lang/TAV/Arithmetic-Integer new file mode 120000 index 0000000000..b9d994e37f --- /dev/null +++ b/Lang/TAV/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/TAV \ No newline at end of file diff --git a/Lang/TAV/Array-concatenation b/Lang/TAV/Array-concatenation new file mode 120000 index 0000000000..a1b0d9260d --- /dev/null +++ b/Lang/TAV/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/TAV \ No newline at end of file diff --git a/Lang/TAV/Array-length b/Lang/TAV/Array-length new file mode 120000 index 0000000000..0d849f41e8 --- /dev/null +++ b/Lang/TAV/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/TAV \ No newline at end of file diff --git a/Lang/TAV/Associative-array-Iteration b/Lang/TAV/Associative-array-Iteration new file mode 120000 index 0000000000..48bdb805ad --- /dev/null +++ b/Lang/TAV/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/TAV \ No newline at end of file diff --git a/Lang/TAV/Averages-Root-mean-square b/Lang/TAV/Averages-Root-mean-square new file mode 120000 index 0000000000..75f73fbdb8 --- /dev/null +++ b/Lang/TAV/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/TAV \ No newline at end of file diff --git a/Lang/TAV/Character-codes b/Lang/TAV/Character-codes new file mode 120000 index 0000000000..46e37f6e83 --- /dev/null +++ b/Lang/TAV/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/TAV \ No newline at end of file diff --git a/Lang/TAV/Command-line-arguments b/Lang/TAV/Command-line-arguments new file mode 120000 index 0000000000..72fc191937 --- /dev/null +++ b/Lang/TAV/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/TAV \ No newline at end of file diff --git a/Lang/TAV/Conditional-structures b/Lang/TAV/Conditional-structures new file mode 120000 index 0000000000..bf797da6e6 --- /dev/null +++ b/Lang/TAV/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/TAV \ No newline at end of file diff --git a/Lang/TAV/Copy-a-string b/Lang/TAV/Copy-a-string new file mode 120000 index 0000000000..3ca111af72 --- /dev/null +++ b/Lang/TAV/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/TAV \ No newline at end of file diff --git a/Lang/TAV/Create-a-two-dimensional-array-at-runtime b/Lang/TAV/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..ec0fae01dd --- /dev/null +++ b/Lang/TAV/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/TAV \ No newline at end of file diff --git a/Lang/TAV/Empty-string b/Lang/TAV/Empty-string new file mode 120000 index 0000000000..c001916e31 --- /dev/null +++ b/Lang/TAV/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/TAV \ No newline at end of file diff --git a/Lang/TAV/Factorial b/Lang/TAV/Factorial new file mode 120000 index 0000000000..005136367e --- /dev/null +++ b/Lang/TAV/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/TAV \ No newline at end of file diff --git a/Lang/TAV/Fibonacci-sequence b/Lang/TAV/Fibonacci-sequence new file mode 120000 index 0000000000..e65f13e72b --- /dev/null +++ b/Lang/TAV/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/TAV \ No newline at end of file diff --git a/Lang/TAV/Formatted-numeric-output b/Lang/TAV/Formatted-numeric-output new file mode 120000 index 0000000000..efbc60523a --- /dev/null +++ b/Lang/TAV/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/TAV \ No newline at end of file diff --git a/Lang/TAV/Greatest-element-of-a-list b/Lang/TAV/Greatest-element-of-a-list new file mode 120000 index 0000000000..b4f81674a0 --- /dev/null +++ b/Lang/TAV/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/TAV \ No newline at end of file diff --git a/Lang/TAV/Guess-the-number-With-feedback b/Lang/TAV/Guess-the-number-With-feedback new file mode 120000 index 0000000000..5779e4d532 --- /dev/null +++ b/Lang/TAV/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/TAV \ No newline at end of file diff --git a/Lang/TAV/HTTPS b/Lang/TAV/HTTPS new file mode 120000 index 0000000000..3b5c7b8988 --- /dev/null +++ b/Lang/TAV/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/TAV \ No newline at end of file diff --git a/Lang/TAV/Halt-and-catch-fire b/Lang/TAV/Halt-and-catch-fire new file mode 120000 index 0000000000..802c4aa7b1 --- /dev/null +++ b/Lang/TAV/Halt-and-catch-fire @@ -0,0 +1 @@ +../../Task/Halt-and-catch-fire/TAV \ No newline at end of file diff --git a/Lang/TAV/Hello-world-Graphical b/Lang/TAV/Hello-world-Graphical new file mode 120000 index 0000000000..5207716bc0 --- /dev/null +++ b/Lang/TAV/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/TAV \ No newline at end of file diff --git a/Lang/TAV/Hello-world-Text b/Lang/TAV/Hello-world-Text new file mode 120000 index 0000000000..3fd6788564 --- /dev/null +++ b/Lang/TAV/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/TAV \ No newline at end of file diff --git a/Lang/TAV/Letter-frequency b/Lang/TAV/Letter-frequency new file mode 120000 index 0000000000..891b699844 --- /dev/null +++ b/Lang/TAV/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/TAV \ No newline at end of file diff --git a/Lang/TAV/Loop-over-multiple-arrays-simultaneously b/Lang/TAV/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..b6133fd1e3 --- /dev/null +++ b/Lang/TAV/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-Break b/Lang/TAV/Loops-Break new file mode 120000 index 0000000000..9576a14c29 --- /dev/null +++ b/Lang/TAV/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-Do-while b/Lang/TAV/Loops-Do-while new file mode 120000 index 0000000000..1fc4e33872 --- /dev/null +++ b/Lang/TAV/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-Downward-for b/Lang/TAV/Loops-Downward-for new file mode 120000 index 0000000000..414c0842ce --- /dev/null +++ b/Lang/TAV/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-For b/Lang/TAV/Loops-For new file mode 120000 index 0000000000..b5f2be83c7 --- /dev/null +++ b/Lang/TAV/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-Infinite b/Lang/TAV/Loops-Infinite new file mode 120000 index 0000000000..6ab04989e3 --- /dev/null +++ b/Lang/TAV/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-N-plus-one-half b/Lang/TAV/Loops-N-plus-one-half new file mode 120000 index 0000000000..eaeea87dec --- /dev/null +++ b/Lang/TAV/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/TAV \ No newline at end of file diff --git a/Lang/TAV/Loops-While b/Lang/TAV/Loops-While new file mode 120000 index 0000000000..b408169718 --- /dev/null +++ b/Lang/TAV/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/TAV \ No newline at end of file diff --git a/Lang/TAV/Multiplication-tables b/Lang/TAV/Multiplication-tables new file mode 120000 index 0000000000..294070cfc4 --- /dev/null +++ b/Lang/TAV/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/TAV \ No newline at end of file diff --git a/Lang/TAV/Ordered-words b/Lang/TAV/Ordered-words new file mode 120000 index 0000000000..1dd34f0734 --- /dev/null +++ b/Lang/TAV/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/TAV \ No newline at end of file diff --git a/Lang/TAV/Permutations b/Lang/TAV/Permutations new file mode 120000 index 0000000000..c61f5ead43 --- /dev/null +++ b/Lang/TAV/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/TAV \ No newline at end of file diff --git a/Lang/TAV/Real-constants-and-functions b/Lang/TAV/Real-constants-and-functions new file mode 120000 index 0000000000..074b803009 --- /dev/null +++ b/Lang/TAV/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/TAV \ No newline at end of file diff --git a/Lang/TAV/Reverse-a-string b/Lang/TAV/Reverse-a-string new file mode 120000 index 0000000000..ded0969ffb --- /dev/null +++ b/Lang/TAV/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/TAV \ No newline at end of file diff --git a/Lang/TAV/Semordnilap b/Lang/TAV/Semordnilap new file mode 120000 index 0000000000..2269a5f472 --- /dev/null +++ b/Lang/TAV/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/TAV \ No newline at end of file diff --git a/Lang/TAV/Simple-windowed-application b/Lang/TAV/Simple-windowed-application new file mode 120000 index 0000000000..16b1926606 --- /dev/null +++ b/Lang/TAV/Simple-windowed-application @@ -0,0 +1 @@ +../../Task/Simple-windowed-application/TAV \ No newline at end of file diff --git a/Lang/TAV/Stack b/Lang/TAV/Stack new file mode 120000 index 0000000000..a05bead248 --- /dev/null +++ b/Lang/TAV/Stack @@ -0,0 +1 @@ +../../Task/Stack/TAV \ No newline at end of file diff --git a/Lang/TAV/String-length b/Lang/TAV/String-length new file mode 120000 index 0000000000..6374cb4fac --- /dev/null +++ b/Lang/TAV/String-length @@ -0,0 +1 @@ +../../Task/String-length/TAV \ No newline at end of file diff --git a/Lang/TAV/Tic-tac-toe b/Lang/TAV/Tic-tac-toe new file mode 120000 index 0000000000..c75d3a40ab --- /dev/null +++ b/Lang/TAV/Tic-tac-toe @@ -0,0 +1 @@ +../../Task/Tic-tac-toe/TAV \ No newline at end of file diff --git a/Lang/TAV/Tokenize-a-string b/Lang/TAV/Tokenize-a-string new file mode 120000 index 0000000000..8b4118dfbe --- /dev/null +++ b/Lang/TAV/Tokenize-a-string @@ -0,0 +1 @@ +../../Task/Tokenize-a-string/TAV \ No newline at end of file diff --git a/Lang/TAV/Window-creation b/Lang/TAV/Window-creation new file mode 120000 index 0000000000..83a0431016 --- /dev/null +++ b/Lang/TAV/Window-creation @@ -0,0 +1 @@ +../../Task/Window-creation/TAV \ No newline at end of file diff --git a/Lang/TAV/Word-frequency b/Lang/TAV/Word-frequency new file mode 120000 index 0000000000..569f86daf5 --- /dev/null +++ b/Lang/TAV/Word-frequency @@ -0,0 +1 @@ +../../Task/Word-frequency/TAV \ No newline at end of file diff --git a/Lang/Tcl/M-bius-function b/Lang/Tcl/M-bius-function new file mode 120000 index 0000000000..1c7ccdef59 --- /dev/null +++ b/Lang/Tcl/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/Tcl \ No newline at end of file diff --git a/Lang/Ursalang/Loops-Break b/Lang/Ursalang/Loops-Break new file mode 120000 index 0000000000..9956e0ecbe --- /dev/null +++ b/Lang/Ursalang/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Ursalang \ No newline at end of file diff --git a/Lang/Ursalang/Loops-While b/Lang/Ursalang/Loops-While new file mode 120000 index 0000000000..45dc0e4ade --- /dev/null +++ b/Lang/Ursalang/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Ursalang \ No newline at end of file diff --git a/Lang/V-(Vlang)/Compile-time-calculation b/Lang/V-(Vlang)/Compile-time-calculation new file mode 120000 index 0000000000..1ec9e378fa --- /dev/null +++ b/Lang/V-(Vlang)/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/V-(Vlang) \ No newline at end of file diff --git a/Lang/V-(Vlang)/Inheritance-Multiple b/Lang/V-(Vlang)/Inheritance-Multiple new file mode 120000 index 0000000000..5c8421d069 --- /dev/null +++ b/Lang/V-(Vlang)/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/V-(Vlang) \ No newline at end of file diff --git a/Lang/V-(Vlang)/Inheritance-Single b/Lang/V-(Vlang)/Inheritance-Single new file mode 120000 index 0000000000..e9a1dd6d9f --- /dev/null +++ b/Lang/V-(Vlang)/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/V-(Vlang) \ No newline at end of file diff --git a/Lang/V-(Vlang)/Metaprogramming b/Lang/V-(Vlang)/Metaprogramming new file mode 120000 index 0000000000..6b8564d95e --- /dev/null +++ b/Lang/V-(Vlang)/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/V-(Vlang) \ No newline at end of file diff --git a/Lang/Vyxal/00-LANG.txt b/Lang/Vyxal/00-LANG.txt new file mode 100644 index 0000000000..0acceafc9b --- /dev/null +++ b/Lang/Vyxal/00-LANG.txt @@ -0,0 +1,3 @@ +{{language|Vyxal}} + +Vyxal is an esoteric golfing language designed to make code golf challenges fun, and to allow code golfers to win said challenges. \ No newline at end of file diff --git a/Lang/Vyxal/00-META.yaml b/Lang/Vyxal/00-META.yaml new file mode 100644 index 0000000000..a5968dda5e --- /dev/null +++ b/Lang/Vyxal/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Vyxal diff --git a/Lang/Vyxal/Factorial b/Lang/Vyxal/Factorial new file mode 120000 index 0000000000..1cdfde0f4b --- /dev/null +++ b/Lang/Vyxal/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Vyxal \ No newline at end of file diff --git a/Lang/Vyxal/FizzBuzz b/Lang/Vyxal/FizzBuzz new file mode 120000 index 0000000000..22964032ea --- /dev/null +++ b/Lang/Vyxal/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Vyxal \ No newline at end of file diff --git a/Lang/XBasic/AKS-test-for-primes b/Lang/XBasic/AKS-test-for-primes new file mode 120000 index 0000000000..dcd18f7155 --- /dev/null +++ b/Lang/XBasic/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/XBasic \ No newline at end of file diff --git a/Lang/XBasic/Josephus-problem b/Lang/XBasic/Josephus-problem new file mode 120000 index 0000000000..425d14bd16 --- /dev/null +++ b/Lang/XBasic/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/XBasic \ No newline at end of file diff --git a/Lang/XPL0/AKS-test-for-primes b/Lang/XPL0/AKS-test-for-primes new file mode 120000 index 0000000000..16474e53df --- /dev/null +++ b/Lang/XPL0/AKS-test-for-primes @@ -0,0 +1 @@ +../../Task/AKS-test-for-primes/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Cistercian-numerals b/Lang/XPL0/Cistercian-numerals new file mode 120000 index 0000000000..c2ce89db06 --- /dev/null +++ b/Lang/XPL0/Cistercian-numerals @@ -0,0 +1 @@ +../../Task/Cistercian-numerals/XPL0 \ No newline at end of file diff --git a/Lang/YAMLScript/00-LANG.txt b/Lang/YAMLScript/00-LANG.txt index a35f9dca7d..53f8a21c4a 100644 --- a/Lang/YAMLScript/00-LANG.txt +++ b/Lang/YAMLScript/00-LANG.txt @@ -4,18 +4,23 @@ {{language programming paradigm|hosted}} {{implementation|Lisp}} -'''[https://yamlscript.org YS (aka YAMLScript)]''' is a new programming language that uses [https://yaml.org/ YAML] as its syntax. It is a complete, functional, general purpose language, but can also be easily embedded in YAML files to make them dynamic at load time. Most existing YAML files and all JSON files are already valid YS programs. +'''[https://yamlscript.org YS (pronounced "wise", aka YAMLScript)]''' is a new programming language that uses [https://yaml.org/ YAML] as its syntax. It is a complete, functional, general purpose language, but can also be easily embedded in YAML files to make them dynamic at load time. Most existing YAML files and all JSON files are already valid YS programs. You can learn YS for free (with help from experienced mentors) at [https://exercism.org/tracks/yamlscript Exercism]. -YS has a compiler/interpreter CLI program called [https://github.com/yaml/yamlscript/releases ys] and is also available in several programming languages as a binding module to the [https://github.com/yaml/yamlscript/releases libyamlscript.so] shared library: +YS has a compiler/interpreter CLI program called [https://github.com/yaml/yamlscript/releases ys] and is also available in several programming languages as a binding module to the [https://github.com/yaml/yamlscript/releases libys.so] shared library: +* [https://www.nuget.org/packages/YAMLScript/ C#] * [https://clojars.org/org.yamlscript/clj-yamlscript Clojure] +* [https://shardbox.org/shards/yamlscript Crystal] * [https://github.com/yaml/yamlscript-go Go] +* [https://hackage.haskell.org/package/yamlscript Haskell] * [https://clojars.org/org.yamlscript/yamlscript Java] * [https://juliahub.com/ui/Packages/General/YAMLScript Julia] +* [https://luarocks.org/modules/ingy/yamlscript Lua] * [https://www.npmjs.com/package/@yaml/yamlscript NodeJS] * [https://metacpan.org/pod/YAMLScript Perl] +* [https://packagist.org/packages/yaml/yamlscript PHP] * [https://pypi.org/project/yamlscript/ Python] * [https://raku.land/zef:ingy/YAMLScript Raku] * [https://rubygems.org/gems/yamlscript Ruby] @@ -25,7 +30,7 @@ YS has a compiler/interpreter CLI program called [https://github.com/yaml/ Run this command to install the ys command line YS runner/loader/compiler binary. - curl -s https://yamlscript.org/install | bash + curl https://getys.org/ys | bash That will install $HOME/.local/bin/ys. If $HOME/.local/bin is not in your PATH, run: diff --git a/Lang/YAMLScript/Best-shuffle b/Lang/YAMLScript/Best-shuffle new file mode 120000 index 0000000000..99ffbfc9b1 --- /dev/null +++ b/Lang/YAMLScript/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Conways-Game-of-Life b/Lang/YAMLScript/Conways-Game-of-Life new file mode 120000 index 0000000000..3153c05b26 --- /dev/null +++ b/Lang/YAMLScript/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Dragon-curve b/Lang/YAMLScript/Dragon-curve new file mode 120000 index 0000000000..7f9deedb82 --- /dev/null +++ b/Lang/YAMLScript/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Even-or-odd b/Lang/YAMLScript/Even-or-odd new file mode 120000 index 0000000000..95556dd2eb --- /dev/null +++ b/Lang/YAMLScript/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Integer-comparison b/Lang/YAMLScript/Integer-comparison new file mode 120000 index 0000000000..47b0c04990 --- /dev/null +++ b/Lang/YAMLScript/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/JortSort b/Lang/YAMLScript/JortSort new file mode 120000 index 0000000000..28bb797476 --- /dev/null +++ b/Lang/YAMLScript/JortSort @@ -0,0 +1 @@ +../../Task/JortSort/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Knuth-shuffle b/Lang/YAMLScript/Knuth-shuffle new file mode 120000 index 0000000000..676dc89553 --- /dev/null +++ b/Lang/YAMLScript/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Munching-squares b/Lang/YAMLScript/Munching-squares new file mode 120000 index 0000000000..2b7870226f --- /dev/null +++ b/Lang/YAMLScript/Munching-squares @@ -0,0 +1 @@ +../../Task/Munching-squares/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Next-highest-int-from-digits b/Lang/YAMLScript/Next-highest-int-from-digits new file mode 120000 index 0000000000..6dd0221650 --- /dev/null +++ b/Lang/YAMLScript/Next-highest-int-from-digits @@ -0,0 +1 @@ +../../Task/Next-highest-int-from-digits/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/One-dimensional-cellular-automata b/Lang/YAMLScript/One-dimensional-cellular-automata new file mode 120000 index 0000000000..74c105b72e --- /dev/null +++ b/Lang/YAMLScript/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Quickselect-algorithm b/Lang/YAMLScript/Quickselect-algorithm new file mode 120000 index 0000000000..978322a04a --- /dev/null +++ b/Lang/YAMLScript/Quickselect-algorithm @@ -0,0 +1 @@ +../../Task/Quickselect-algorithm/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Sparkline-in-unicode b/Lang/YAMLScript/Sparkline-in-unicode new file mode 120000 index 0000000000..ae2a07413c --- /dev/null +++ b/Lang/YAMLScript/Sparkline-in-unicode @@ -0,0 +1 @@ +../../Task/Sparkline-in-unicode/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Terminal-control-Ringing-the-terminal-bell b/Lang/YAMLScript/Terminal-control-Ringing-the-terminal-bell new file mode 120000 index 0000000000..21baf990a9 --- /dev/null +++ b/Lang/YAMLScript/Terminal-control-Ringing-the-terminal-bell @@ -0,0 +1 @@ +../../Task/Terminal-control-Ringing-the-terminal-bell/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Undefined-values b/Lang/YAMLScript/Undefined-values new file mode 120000 index 0000000000..ff7699a995 --- /dev/null +++ b/Lang/YAMLScript/Undefined-values @@ -0,0 +1 @@ +../../Task/Undefined-values/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Van-der-Corput-sequence b/Lang/YAMLScript/Van-der-Corput-sequence new file mode 120000 index 0000000000..654ffd3cbb --- /dev/null +++ b/Lang/YAMLScript/Van-der-Corput-sequence @@ -0,0 +1 @@ +../../Task/Van-der-Corput-sequence/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Xiaolin-Wus-line-algorithm b/Lang/YAMLScript/Xiaolin-Wus-line-algorithm new file mode 120000 index 0000000000..be316f6902 --- /dev/null +++ b/Lang/YAMLScript/Xiaolin-Wus-line-algorithm @@ -0,0 +1 @@ +../../Task/Xiaolin-Wus-line-algorithm/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Yellowstone-sequence b/Lang/YAMLScript/Yellowstone-sequence new file mode 120000 index 0000000000..efac2d410f --- /dev/null +++ b/Lang/YAMLScript/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/YAMLScript \ No newline at end of file diff --git a/Lang/YAMLScript/Zig-zag-matrix b/Lang/YAMLScript/Zig-zag-matrix new file mode 120000 index 0000000000..691eda7cd9 --- /dev/null +++ b/Lang/YAMLScript/Zig-zag-matrix @@ -0,0 +1 @@ +../../Task/Zig-zag-matrix/YAMLScript \ No newline at end of file diff --git a/Lang/Zig/24-game-Solve b/Lang/Zig/24-game-Solve new file mode 120000 index 0000000000..cf80fe1aa1 --- /dev/null +++ b/Lang/Zig/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Zig \ No newline at end of file diff --git a/Lang/Zig/AVL-tree b/Lang/Zig/AVL-tree new file mode 120000 index 0000000000..05056fdece --- /dev/null +++ b/Lang/Zig/AVL-tree @@ -0,0 +1 @@ +../../Task/AVL-tree/Zig \ No newline at end of file diff --git a/Lang/Zig/Abelian-sandpile-model b/Lang/Zig/Abelian-sandpile-model new file mode 120000 index 0000000000..aff7b1b955 --- /dev/null +++ b/Lang/Zig/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/Zig \ No newline at end of file diff --git a/Lang/Zig/Abelian-sandpile-model-Identity b/Lang/Zig/Abelian-sandpile-model-Identity new file mode 120000 index 0000000000..5a22dd3380 --- /dev/null +++ b/Lang/Zig/Abelian-sandpile-model-Identity @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model-Identity/Zig \ No newline at end of file diff --git a/Lang/Zig/Arrays b/Lang/Zig/Arrays new file mode 120000 index 0000000000..8271fea84a --- /dev/null +++ b/Lang/Zig/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Zig \ No newline at end of file diff --git a/Lang/Zig/Associative-array-Creation b/Lang/Zig/Associative-array-Creation new file mode 120000 index 0000000000..9dff0b181f --- /dev/null +++ b/Lang/Zig/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Zig \ No newline at end of file diff --git a/Lang/Zig/Associative-array-Iteration b/Lang/Zig/Associative-array-Iteration new file mode 120000 index 0000000000..0120ea3ca0 --- /dev/null +++ b/Lang/Zig/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Zig \ No newline at end of file diff --git a/Lang/Zig/Base64-decode-data b/Lang/Zig/Base64-decode-data new file mode 120000 index 0000000000..9291a91364 --- /dev/null +++ b/Lang/Zig/Base64-decode-data @@ -0,0 +1 @@ +../../Task/Base64-decode-data/Zig \ No newline at end of file diff --git a/Lang/Zig/Bifid-cipher b/Lang/Zig/Bifid-cipher new file mode 120000 index 0000000000..c3e619eb90 --- /dev/null +++ b/Lang/Zig/Bifid-cipher @@ -0,0 +1 @@ +../../Task/Bifid-cipher/Zig \ No newline at end of file diff --git a/Lang/Zig/Boolean-values b/Lang/Zig/Boolean-values new file mode 120000 index 0000000000..8bbec67819 --- /dev/null +++ b/Lang/Zig/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Zig \ No newline at end of file diff --git a/Lang/Zig/Boyer-Moore-string-search b/Lang/Zig/Boyer-Moore-string-search new file mode 120000 index 0000000000..9c6dd89c45 --- /dev/null +++ b/Lang/Zig/Boyer-Moore-string-search @@ -0,0 +1 @@ +../../Task/Boyer-Moore-string-search/Zig \ No newline at end of file diff --git a/Lang/Zig/Break-OO-privacy b/Lang/Zig/Break-OO-privacy new file mode 120000 index 0000000000..535f70b15b --- /dev/null +++ b/Lang/Zig/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Zig \ No newline at end of file diff --git a/Lang/Zig/Camel-case-and-snake-case b/Lang/Zig/Camel-case-and-snake-case new file mode 120000 index 0000000000..ab00dfd34b --- /dev/null +++ b/Lang/Zig/Camel-case-and-snake-case @@ -0,0 +1 @@ +../../Task/Camel-case-and-snake-case/Zig \ No newline at end of file diff --git a/Lang/Zig/Cholesky-decomposition b/Lang/Zig/Cholesky-decomposition new file mode 120000 index 0000000000..7fbe65969f --- /dev/null +++ b/Lang/Zig/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Zig \ No newline at end of file diff --git a/Lang/Zig/Cumulative-standard-deviation b/Lang/Zig/Cumulative-standard-deviation new file mode 120000 index 0000000000..225e824146 --- /dev/null +++ b/Lang/Zig/Cumulative-standard-deviation @@ -0,0 +1 @@ +../../Task/Cumulative-standard-deviation/Zig \ No newline at end of file diff --git a/Lang/Zig/Cyclops-numbers b/Lang/Zig/Cyclops-numbers new file mode 120000 index 0000000000..625d97b345 --- /dev/null +++ b/Lang/Zig/Cyclops-numbers @@ -0,0 +1 @@ +../../Task/Cyclops-numbers/Zig \ No newline at end of file diff --git a/Lang/Zig/Deconvolution-1D b/Lang/Zig/Deconvolution-1D new file mode 120000 index 0000000000..26b778762a --- /dev/null +++ b/Lang/Zig/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Zig \ No newline at end of file diff --git a/Lang/Zig/Determinant-and-permanent b/Lang/Zig/Determinant-and-permanent new file mode 120000 index 0000000000..6aec06c204 --- /dev/null +++ b/Lang/Zig/Determinant-and-permanent @@ -0,0 +1 @@ +../../Task/Determinant-and-permanent/Zig \ No newline at end of file diff --git a/Lang/Zig/Eertree b/Lang/Zig/Eertree new file mode 120000 index 0000000000..297f5d26a6 --- /dev/null +++ b/Lang/Zig/Eertree @@ -0,0 +1 @@ +../../Task/Eertree/Zig \ No newline at end of file diff --git a/Lang/Zig/Elliptic-Curve-Digital-Signature-Algorithm b/Lang/Zig/Elliptic-Curve-Digital-Signature-Algorithm new file mode 120000 index 0000000000..8631c5bdb3 --- /dev/null +++ b/Lang/Zig/Elliptic-Curve-Digital-Signature-Algorithm @@ -0,0 +1 @@ +../../Task/Elliptic-Curve-Digital-Signature-Algorithm/Zig \ No newline at end of file diff --git a/Lang/Zig/Elliptic-curve-arithmetic b/Lang/Zig/Elliptic-curve-arithmetic new file mode 120000 index 0000000000..6d1206bc71 --- /dev/null +++ b/Lang/Zig/Elliptic-curve-arithmetic @@ -0,0 +1 @@ +../../Task/Elliptic-curve-arithmetic/Zig \ No newline at end of file diff --git a/Lang/Zig/Evolutionary-algorithm b/Lang/Zig/Evolutionary-algorithm new file mode 120000 index 0000000000..59ff814ffb --- /dev/null +++ b/Lang/Zig/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Zig \ No newline at end of file diff --git a/Lang/Zig/Factors-of-an-integer b/Lang/Zig/Factors-of-an-integer new file mode 120000 index 0000000000..9bd33985d3 --- /dev/null +++ b/Lang/Zig/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Zig \ No newline at end of file diff --git a/Lang/Zig/Farey-sequence b/Lang/Zig/Farey-sequence new file mode 120000 index 0000000000..44274502d4 --- /dev/null +++ b/Lang/Zig/Farey-sequence @@ -0,0 +1 @@ +../../Task/Farey-sequence/Zig \ No newline at end of file diff --git a/Lang/Zig/Gray-code b/Lang/Zig/Gray-code new file mode 120000 index 0000000000..f2147c406a --- /dev/null +++ b/Lang/Zig/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Zig \ No newline at end of file diff --git a/Lang/Zig/K-d-tree b/Lang/Zig/K-d-tree new file mode 120000 index 0000000000..3fd542d0d2 --- /dev/null +++ b/Lang/Zig/K-d-tree @@ -0,0 +1 @@ +../../Task/K-d-tree/Zig \ No newline at end of file diff --git a/Lang/Zig/Knapsack-problem-0-1 b/Lang/Zig/Knapsack-problem-0-1 new file mode 120000 index 0000000000..95f8fcd9fc --- /dev/null +++ b/Lang/Zig/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Zig \ No newline at end of file diff --git a/Lang/Zig/Knights-tour b/Lang/Zig/Knights-tour new file mode 120000 index 0000000000..a8fa50bb64 --- /dev/null +++ b/Lang/Zig/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Zig \ No newline at end of file diff --git a/Lang/Zig/Loops-Nested b/Lang/Zig/Loops-Nested new file mode 120000 index 0000000000..a78e39957d --- /dev/null +++ b/Lang/Zig/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Zig \ No newline at end of file diff --git a/Lang/Zig/M-bius-function b/Lang/Zig/M-bius-function new file mode 120000 index 0000000000..b4ad984b09 --- /dev/null +++ b/Lang/Zig/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/Zig \ No newline at end of file diff --git a/Lang/Zig/Main-step-of-GOST-28147-89 b/Lang/Zig/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..433b294fbc --- /dev/null +++ b/Lang/Zig/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/Zig \ No newline at end of file diff --git a/Lang/Zig/Modular-arithmetic b/Lang/Zig/Modular-arithmetic new file mode 120000 index 0000000000..a64c6161fe --- /dev/null +++ b/Lang/Zig/Modular-arithmetic @@ -0,0 +1 @@ +../../Task/Modular-arithmetic/Zig \ No newline at end of file diff --git a/Lang/Zig/Modular-inverse b/Lang/Zig/Modular-inverse new file mode 120000 index 0000000000..f96c2102b0 --- /dev/null +++ b/Lang/Zig/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Zig \ No newline at end of file diff --git a/Lang/Zig/Parse-an-IP-Address b/Lang/Zig/Parse-an-IP-Address new file mode 120000 index 0000000000..dcc1d9a064 --- /dev/null +++ b/Lang/Zig/Parse-an-IP-Address @@ -0,0 +1 @@ +../../Task/Parse-an-IP-Address/Zig \ No newline at end of file diff --git a/Lang/Zig/Permutations-by-swapping b/Lang/Zig/Permutations-by-swapping new file mode 120000 index 0000000000..5e667cc7e2 --- /dev/null +++ b/Lang/Zig/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Zig \ No newline at end of file diff --git a/Lang/Zig/Stern-Brocot-sequence b/Lang/Zig/Stern-Brocot-sequence new file mode 120000 index 0000000000..4e68e871bc --- /dev/null +++ b/Lang/Zig/Stern-Brocot-sequence @@ -0,0 +1 @@ +../../Task/Stern-Brocot-sequence/Zig \ No newline at end of file diff --git a/Lang/Zig/Sudoku b/Lang/Zig/Sudoku new file mode 120000 index 0000000000..cc0b8be01d --- /dev/null +++ b/Lang/Zig/Sudoku @@ -0,0 +1 @@ +../../Task/Sudoku/Zig \ No newline at end of file diff --git a/Lang/Zig/Tarjan b/Lang/Zig/Tarjan new file mode 120000 index 0000000000..47db828add --- /dev/null +++ b/Lang/Zig/Tarjan @@ -0,0 +1 @@ +../../Task/Tarjan/Zig \ No newline at end of file diff --git a/Lang/Zig/Tree-datastructures b/Lang/Zig/Tree-datastructures new file mode 120000 index 0000000000..2483259e7c --- /dev/null +++ b/Lang/Zig/Tree-datastructures @@ -0,0 +1 @@ +../../Task/Tree-datastructures/Zig \ No newline at end of file diff --git a/Lang/Zig/Verhoeff-algorithm b/Lang/Zig/Verhoeff-algorithm new file mode 120000 index 0000000000..d90fb8e2ca --- /dev/null +++ b/Lang/Zig/Verhoeff-algorithm @@ -0,0 +1 @@ +../../Task/Verhoeff-algorithm/Zig \ No newline at end of file diff --git a/Lang/Zig/Vigen-re-cipher-Cryptanalysis b/Lang/Zig/Vigen-re-cipher-Cryptanalysis new file mode 120000 index 0000000000..7fd7d3aa92 --- /dev/null +++ b/Lang/Zig/Vigen-re-cipher-Cryptanalysis @@ -0,0 +1 @@ +../../Task/Vigen-re-cipher-Cryptanalysis/Zig \ No newline at end of file diff --git a/Lang/Zig/Vogels-approximation-method b/Lang/Zig/Vogels-approximation-method new file mode 120000 index 0000000000..af40cfb307 --- /dev/null +++ b/Lang/Zig/Vogels-approximation-method @@ -0,0 +1 @@ +../../Task/Vogels-approximation-method/Zig \ No newline at end of file diff --git a/Lang/Zig/War-card-game b/Lang/Zig/War-card-game new file mode 120000 index 0000000000..6bc9afa5bf --- /dev/null +++ b/Lang/Zig/War-card-game @@ -0,0 +1 @@ +../../Task/War-card-game/Zig \ No newline at end of file diff --git a/Task/100-doors/AWK/100-doors-1.awk b/Task/100-doors/AWK/100-doors-1.awk deleted file mode 100644 index 1c2a279c09..0000000000 --- a/Task/100-doors/AWK/100-doors-1.awk +++ /dev/null @@ -1,17 +0,0 @@ -BEGIN { - for(i=1; i <= 100; i++) - { - doors[i] = 0 # close the doors - } - for(i=1; i <= 100; i++) - { - for(j=i; j <= 100; j += i) - { - doors[j] = (doors[j]+1) % 2 - } - } - for(i=1; i <= 100; i++) - { - print i, doors[i] ? "open" : "close" - } -} diff --git a/Task/100-doors/AWK/100-doors-2.awk b/Task/100-doors/AWK/100-doors-2.awk deleted file mode 100644 index 9344bbec27..0000000000 --- a/Task/100-doors/AWK/100-doors-2.awk +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN { - for(i=1; i <= 100; i++) { - doors[i] = 0 # close the doors - } - for(i=1; i <= 100; i++) { - if ( int(sqrt(i)) == sqrt(i) ) { - doors[i] = 1 - } - } - for(i=1; i <= 100; i++) - { - print i, doors[i] ? "open" : "close" - } -} diff --git a/Task/100-doors/Adina/100-doors-1.adina b/Task/100-doors/Adina/100-doors-1.adina new file mode 100644 index 0000000000..0e7190c89e --- /dev/null +++ b/Task/100-doors/Adina/100-doors-1.adina @@ -0,0 +1,16 @@ +двери = новый-массив 100 ложь + +цикл + шаг + в-диапазоне 1 101 + цикл + номер + в-диапазоне (шаг - 1) 100 шаг + двери[номер] := не двери[номер] + +цикл + номер 100 + вывести/перенос + формат «Дверь ~a ~a» + номер + 1 + двери[номер] ? «открыта» «закрыта» diff --git a/Task/100-doors/Adina/100-doors-2.adina b/Task/100-doors/Adina/100-doors-2.adina new file mode 100644 index 0000000000..6286140dc0 --- /dev/null +++ b/Task/100-doors/Adina/100-doors-2.adina @@ -0,0 +1,17 @@ +english() +doors = make-vector 100 #f + +for + $ step + in-range 1 101 + for + $ number + in-range (step - 1) 100 step + doors[number] := not doors[number] + +for + $ number 100 + displayln + format "Door ~a ~a" + number + 1 + if doors[number] "open" "closed" diff --git a/Task/100-doors/ArkScript/100-doors-1.ark b/Task/100-doors/ArkScript/100-doors-1.ark new file mode 100644 index 0000000000..713e3b360f --- /dev/null +++ b/Task/100-doors/ArkScript/100-doors-1.ark @@ -0,0 +1,21 @@ +(import std.Range :range :forEach) +(import std.List) + +(mut doors (list:fill 100 false)) +(let r (range 0 100)) + +(forEach r + (fun (i) { + (mut j i) + (while (< j 100) { + (@= doors j (not (@ doors j))) + (set j (+ j i 1)) }) + (print doors) })) + +(print + (list:map + (list:filter + (list:zipWithIndex doors) + (fun (e) + (@ e 1))) + (fun (e) (@ e 0)))) diff --git a/Task/100-doors/ArkScript/100-doors-2.ark b/Task/100-doors/ArkScript/100-doors-2.ark new file mode 100644 index 0000000000..b1cb4380b2 --- /dev/null +++ b/Task/100-doors/ArkScript/100-doors-2.ark @@ -0,0 +1,4 @@ +[true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true true] +... +[true false false true false false false false true false false false false false false true false false false false false false false false true false false false false false false false false false false true false false false false false false false false false false false false true false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false false true] +[0 3 8 15 24 35 48 63 80 99] diff --git a/Task/100-doors/AutoLISP/100-doors.l b/Task/100-doors/AutoLISP/100-doors.l new file mode 100644 index 0000000000..d4a0ebbe77 --- /dev/null +++ b/Task/100-doors/AutoLISP/100-doors.l @@ -0,0 +1,18 @@ +(defun CreateDoors (n / doors) + (repeat n + (setq doors (cons nil doors)) + ) +) + +(defun Doors (doors / cnt) + (setq cnt 0) + (mapcar + '(lambda (d) + (zerop (rem (sqrt (setq cnt (1+ cnt))) 1)) + ) + doors + ) +) + +> (Doors (CreateDoors 100)) +(T nil nil T nil nil nil nil T nil nil nil nil nil nil T nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil T nil nil nil nil) diff --git a/Task/100-doors/Component-Pascal/100-doors.pas b/Task/100-doors/Component-Pascal/100-doors.pas deleted file mode 100644 index 0e11914244..0000000000 --- a/Task/100-doors/Component-Pascal/100-doors.pas +++ /dev/null @@ -1,26 +0,0 @@ -MODULE Doors100; -IMPORT StdLog; - -PROCEDURE Do*; -VAR - i,j: INTEGER; - closed: ARRAY 101 OF BOOLEAN; -BEGIN - (* initialization of closed to true *) - FOR i := 0 TO LEN(closed) - 1 DO closed[i] := TRUE END; - (* process *) - FOR i := 1 TO LEN(closed) DO; - j := 1; - WHILE j < LEN(closed) DO - IF j MOD i = 0 THEN closed[j] := ~closed[j] END;INC(j) - END - END; - (* print results *) - i := 1; - WHILE i < LEN(closed) DO - IF (i - 1) MOD 10 = 0 THEN StdLog.Ln END; - IF closed[i] THEN StdLog.String("C ") ELSE StdLog.String("O ") END; - INC(i) - END; -END Do; -END Doors100. diff --git a/Task/100-doors/DuckDB/100-doors.duckdb b/Task/100-doors/DuckDB/100-doors.duckdb new file mode 100644 index 0000000000..aa3716882e --- /dev/null +++ b/Task/100-doors/DuckDB/100-doors.duckdb @@ -0,0 +1,19 @@ +# Show the state of n doors after n iterations +create or replace function doors(n) as ( + with recursive cte(ix,d) as ( + select 0 as ix, list_transform(range(0, n), x -> false) as d + union all + select ix+1, + list_transform(d, (x,i) -> if (i % (ix + 1) = 0, NOT x, x)) + from cte + where ix < n + ) + select last(d order by ix) + from cte +); + +# For brevity, we just show the indices of the doors that are open after all +# have been visited: +select ix +from (select unnest(generate_series(1,100)) as ix, unnest(doors(100)) as d) +where d = true; diff --git a/Task/100-doors/Haskell/100-doors-3.hs b/Task/100-doors/Haskell/100-doors-3.hs index 2cea247dfd..3b66096632 100644 --- a/Task/100-doors/Haskell/100-doors-3.hs +++ b/Task/100-doors/Haskell/100-doors-3.hs @@ -1,6 +1,9 @@ -gate :: Eq a => [a] -> [a] -> [Door] -gate (x:xs) (y:ys) | x == y = Open : gate xs ys -gate (x:xs) ys = Closed : gate xs ys -gate [] _ = [] +isDoorOpen :: Integral a => a -> Bool +-- In Haskell, we are too lazy to open and close doors. Instead we +-- count how many times we would have toggled them, and then check if +-- that number is odd. +isDoorOpen doorNumber = odd numToggles + where numToggles = length [ 1 | x <- [1..doorNumber], doorNumber `rem` x == 0] -run n = gate [1..n] [k*k | k <- [1..]] +main = do + print $ "Open doors are " ++ show [x | x <- [0..100], isDoorOpen x] diff --git a/Task/100-doors/Haskell/100-doors-4.hs b/Task/100-doors/Haskell/100-doors-4.hs index 44f44aa391..2cea247dfd 100644 --- a/Task/100-doors/Haskell/100-doors-4.hs +++ b/Task/100-doors/Haskell/100-doors-4.hs @@ -1 +1,6 @@ -run n = takeWhile (< n) [k*k | k <- [1..]] +gate :: Eq a => [a] -> [a] -> [Door] +gate (x:xs) (y:ys) | x == y = Open : gate xs ys +gate (x:xs) ys = Closed : gate xs ys +gate [] _ = [] + +run n = gate [1..n] [k*k | k <- [1..]] diff --git a/Task/100-doors/Haskell/100-doors-5.hs b/Task/100-doors/Haskell/100-doors-5.hs new file mode 100644 index 0000000000..44f44aa391 --- /dev/null +++ b/Task/100-doors/Haskell/100-doors-5.hs @@ -0,0 +1 @@ +run n = takeWhile (< n) [k*k | k <- [1..]] diff --git a/Task/100-doors/Lua/100-doors.lua b/Task/100-doors/Lua/100-doors.lua deleted file mode 100644 index 3183bc7730..0000000000 --- a/Task/100-doors/Lua/100-doors.lua +++ /dev/null @@ -1,11 +0,0 @@ -local is_open = {} - -for pass = 1,100 do - for door = pass,100,pass do - is_open[door] = not is_open[door] - end -end - -for i,v in next,is_open do - print ('Door '..i..':',v and 'open' or 'close') -end diff --git a/Task/100-doors/PL-M/100-doors.plm b/Task/100-doors/PL-M/100-doors.plm deleted file mode 100644 index 0013832477..0000000000 --- a/Task/100-doors/PL-M/100-doors.plm +++ /dev/null @@ -1,55 +0,0 @@ -100H: /* FIND THE FIRST FEW SQUARES VIA THE UNOPTIMISED DOOR FLIPPING METHOD */ - - /* BDOS SYSTEM CALL */ - BDOS: PROCEDURE( FN, ARG ); - DECLARE FN BYTE, ARG ADDRESS; - GO TO 5; - END BDOS; - - /* PRINTS A BYTE AS A CHARACTER */ - PRINT$CHAR: PROCEDURE( CH ); - DECLARE CH BYTE; - CALL BDOS( 2, CH ); - END PRINT$CHAR; - - /* PRINTS A BYTE AS A NUMBER */ - PRINT$BYTE: PROCEDURE( N ); - DECLARE N BYTE; - DECLARE ( V, D3, D2 ) BYTE; - V = N; - D3 = V MOD 10; - IF ( V := V / 10 ) <> 0 THEN DO; - D2 = V MOD 10; - IF ( V := V / 10 ) <> 0 THEN CALL PRINT$CHAR( '0' + V ); - CALL PRINT$CHAR( '0' + D2 ); - END; - CALL PRINT$CHAR( '0' + D3 ); - END PRINT$BYTE; - - DECLARE DOOR$DCL LITERALLY '101'; - DECLARE FALSE LITERALLY '0'; - DECLARE CR LITERALLY '0DH'; - DECLARE LF LITERALLY '0AH'; - - /* ARRAY OF DOORS - DOOR( I ) IS TRUE IF OPEN, FALSE IF CLOSED */ - DECLARE DOOR( DOOR$DCL ) BYTE; - DECLARE ( I, J ) BYTE; - - /* SET ALL DOORS TO CLOSED */ - DO I = 0 TO LAST( DOOR ); DOOR( I ) = FALSE; END; - /* REPEATEDLY FLIP THE DOORS */ - DO I = 1 TO LAST( DOOR ); - DO J = I TO LAST( DOOR ) BY I; - DOOR( J ) = NOT DOOR( J ); - END; - END; - /* DISPLAY THE RESULTS */ - DO I = 1 TO LAST( DOOR ); - IF DOOR( I ) THEN DO; - CALL PRINT$CHAR( ' ' ); - CALL PRINT$BYTE( I ); - END; - END; - CALL PRINT$CHAR( CR ); - CALL PRINT$CHAR( LF ); -EOF diff --git a/Task/100-doors/REBOL/100-doors-2.rebol b/Task/100-doors/REBOL/100-doors-2.rebol index 73f1f448f3..b8428a69d9 100644 --- a/Task/100-doors/REBOL/100-doors-2.rebol +++ b/Task/100-doors/REBOL/100-doors-2.rebol @@ -1,2 +1,26 @@ -doors: array/initial 100 'closed -repeat i 10 [doors/(i * i): 'open] +;; Create a bitset with capacity for 100 bits (representing 100 doors) +;; Each bit represents a door state: 0 = closed, 1 = open +doors: make bitset! 100 + +;; Outer loop: Make 100 passes (i = 1 to 100) +repeat i 100 [ + ;; Inner loop: Check each door position (j = 1 to 100) + repeat j 100 [ + ;; If door j index is divisible by pass number i (no remainder) + if zero? (j // i) [ + ;; Toggle the door's bit: + ;; doors/:j accesses door j in the bitset + ;; 'not' flips the bit value (0 -> 1, 1 -> 0) + doors/:j: not doors/:j + ] + ] +] + +;; Final loop: Check which doors are open, print their numbers +repeat i 100 [ + ;; If door i's bit is set (open) + if doors/:i [ + ;; Print the door's number and that it is open + print ["door" i "is open"] + ] +] diff --git a/Task/100-doors/REBOL/100-doors-3.rebol b/Task/100-doors/REBOL/100-doors-3.rebol new file mode 100644 index 0000000000..318cdd4a11 --- /dev/null +++ b/Task/100-doors/REBOL/100-doors-3.rebol @@ -0,0 +1,6 @@ +;; Loop variable i from 1 to 10 (since 10^2 = 100, covers doors 1 to 100) +repeat i 10 [ + ;; Print that door number (i squared) is open + ;; These are exactly the doors with perfect square numbers: 1, 4, 9, ..., 100 + print ["door" (i * i) "is open"] +] diff --git a/Task/100-prisoners/Prolog/100-prisoners.pro b/Task/100-prisoners/Prolog/100-prisoners.pro new file mode 100644 index 0000000000..375a4acfc8 --- /dev/null +++ b/Task/100-prisoners/Prolog/100-prisoners.pro @@ -0,0 +1,43 @@ +:- use_module(library(aggregate)). +:- use_module(library(lists)). +:- use_module(library(random)). + +random_subset(Length, List, Subset) :- + random_permutation(List, Shuffled), + length(Subset, Length), + prefix(Subset, Shuffled). + +random_play :- + numlist(1, 100, Prisoners), + random_permutation(Prisoners, Drawers), + forall(member(Prisoner, Prisoners), ( + random_subset(50, Drawers, CheckedDrawers), + memberchk(Prisoner, CheckedDrawers) + )). + +optimal_play :- + numlist(1, 100, Prisoners), + random_permutation(Prisoners, Drawers), + forall(member(Prisoner, Prisoners), optimal_play(50, Prisoner, Prisoner, Drawers)). + +optimal_play(ChecksRemaining, Prisoner, NumberToCheck, Drawers) :- + ChecksRemaining > 0, + nth1(NumberToCheck, Drawers, NumberInDrawer), + ( NumberInDrawer = Prisoner + -> true + ; ChecksRemaining0 is ChecksRemaining - 1, + optimal_play(ChecksRemaining0, Prisoner, NumberInDrawer, Drawers) + ). + +:- meta_predicate play_n_times(+, 0, -). +play_n_times(PlayCount, Play, Percentage) :- + aggregate_all(count, ( between(1, PlayCount, _), call(Play) ), Victories), + Percentage is Victories / PlayCount * 100. + +main(SimulationCount) :- + play_n_times(SimulationCount, random_play, RandomPlayPercent), + play_n_times(SimulationCount, optimal_play, OptimalPlayPercent), + format("Simulation count: ~d\nRandom play wins: ~f% of the simulations.\nOptimal play wins ~f% of the simulations.", + [SimulationCount, RandomPlayPercent, OptimalPlayPercent]). + +:- main(100_000). diff --git a/Task/15-puzzle-solver/PascalABC.NET/15-puzzle-solver.pas b/Task/15-puzzle-solver/PascalABC.NET/15-puzzle-solver.pas new file mode 100644 index 0000000000..36a40f7d75 --- /dev/null +++ b/Task/15-puzzle-solver/PascalABC.NET/15-puzzle-solver.pas @@ -0,0 +1,3 @@ +// Игра в 15 PABCWork.NET\Samples\Games\15.pas +see +https://rosettacode.org/wiki/15_puzzle_game#PascalABC.NET diff --git a/Task/2048/EasyLang/2048.easy b/Task/2048/EasyLang/2048.easy index 410f4010a9..079064a289 100644 --- a/Task/2048/EasyLang/2048.easy +++ b/Task/2048/EasyLang/2048.easy @@ -142,7 +142,7 @@ proc handle_mup . on mouse_up handle_mup . -on key +on key_down if stat = 2 if keybkey = " " : init return diff --git a/Task/24-game-Solve/Zig/24-game-solve.zig b/Task/24-game-Solve/Zig/24-game-solve.zig new file mode 100644 index 0000000000..1837c9404d --- /dev/null +++ b/Task/24-game-Solve/Zig/24-game-solve.zig @@ -0,0 +1,273 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; +const HashMap = std.HashMap; +const Allocator = std.mem.Allocator; + +const Operator = enum { + sub, + plus, + mul, + div, +}; + +const Factor = struct { + content: []const u8, + value: i32, + + fn deinit(self: Factor, allocator: Allocator) void { + allocator.free(self.content); + } +}; + +fn apply(allocator: Allocator, op: Operator, left: []const Factor, right: []const Factor) !ArrayList(Factor) { + var ret = ArrayList(Factor).init(allocator); + + for (left) |l| { + for (right) |r| { + switch (op) { + .sub => { + if (l.value > r.value) { + const content = try std.fmt.allocPrint(allocator, "({s} - {s})", .{ l.content, r.content }); + try ret.append(Factor{ + .content = content, + .value = l.value - r.value, + }); + } + }, + .plus => { + const content = try std.fmt.allocPrint(allocator, "({s} + {s})", .{ l.content, r.content }); + try ret.append(Factor{ + .content = content, + .value = l.value + r.value, + }); + }, + .mul => { + const content = try std.fmt.allocPrint(allocator, "({s} x {s})", .{ l.content, r.content }); + try ret.append(Factor{ + .content = content, + .value = l.value * r.value, + }); + }, + .div => { + if (l.value >= r.value and r.value > 0 and @rem(l.value, r.value) == 0) { + const content = try std.fmt.allocPrint(allocator, "({s} / {s})", .{ l.content, r.content }); + try ret.append(Factor{ + .content = content, + .value = @divTrunc(l.value, r.value), + }); + } + }, + } + } + } + + return ret; +} + +fn calc(allocator: Allocator, ops: [3]Operator, numbers: [4]i32) !ArrayList(Factor) { + var current_factors = ArrayList(Factor).init(allocator); + defer { + for (current_factors.items) |factor| { + factor.deinit(allocator); + } + current_factors.deinit(); + } + + // Initialize with first number + const initial_content = try std.fmt.allocPrint(allocator, "{}", .{numbers[0]}); + try current_factors.append(Factor{ + .content = initial_content, + .value = numbers[0], + }); + + // Process each operation + for (ops, 0..) |op, i| { + var next_factors = ArrayList(Factor).init(allocator); + defer { + for (next_factors.items) |factor| { + factor.deinit(allocator); + } + next_factors.deinit(); + } + + const mono_content = try std.fmt.allocPrint(allocator, "{}", .{numbers[i + 1]}); + defer allocator.free(mono_content); + const mono_factor = Factor{ + .content = mono_content, + .value = numbers[i + 1], + }; + const mono_slice = &[_]Factor{mono_factor}; + + switch (op) { + .mul, .plus => { + var applied = try apply(allocator, op, current_factors.items, mono_slice); + defer applied.deinit(); + try next_factors.appendSlice(applied.items); + }, + .div, .sub => { + var applied1 = try apply(allocator, op, current_factors.items, mono_slice); + defer applied1.deinit(); + try next_factors.appendSlice(applied1.items); + + var applied2 = try apply(allocator, op, mono_slice, current_factors.items); + defer applied2.deinit(); + try next_factors.appendSlice(applied2.items); + }, + } + + // Clear current factors and move next_factors to current_factors + for (current_factors.items) |factor| { + factor.deinit(allocator); + } + current_factors.clearRetainingCapacity(); + + // Move ownership from next_factors to current_factors + try current_factors.appendSlice(next_factors.items); + next_factors.clearRetainingCapacity(); // Don't deinit the items, we moved them + } + + // Create result and transfer ownership + var result = ArrayList(Factor).init(allocator); + try result.appendSlice(current_factors.items); + current_factors.clearRetainingCapacity(); // Don't deinit, we transferred ownership + + return result; +} + +const OpIter = struct { + index: usize, + + const OPTIONS = [_]Operator{ .mul, .sub, .plus, .div }; + + fn init() OpIter { + return OpIter{ .index = 0 }; + } + + fn next(self: *OpIter) ?[3]Operator { + if (self.index >= 64) { + return null; + } + + const f1 = OPTIONS[(self.index & (3 << 4)) >> 4]; + const f2 = OPTIONS[(self.index & (3 << 2)) >> 2]; + const f3 = OPTIONS[(self.index & (3 << 0)) >> 0]; + + self.index += 1; + return [3]Operator{ f1, f2, f3 }; + } +}; + +fn orders() [24][4]usize { + return [24][4]usize{ + [4]usize{ 0, 1, 2, 3 }, + [4]usize{ 0, 1, 3, 2 }, + [4]usize{ 0, 2, 1, 3 }, + [4]usize{ 0, 2, 3, 1 }, + [4]usize{ 0, 3, 1, 2 }, + [4]usize{ 0, 3, 2, 1 }, + [4]usize{ 1, 0, 2, 3 }, + [4]usize{ 1, 0, 3, 2 }, + [4]usize{ 1, 2, 0, 3 }, + [4]usize{ 1, 2, 3, 0 }, + [4]usize{ 1, 3, 0, 2 }, + [4]usize{ 1, 3, 2, 0 }, + [4]usize{ 2, 0, 1, 3 }, + [4]usize{ 2, 0, 3, 1 }, + [4]usize{ 2, 1, 0, 3 }, + [4]usize{ 2, 1, 3, 0 }, + [4]usize{ 2, 3, 0, 1 }, + [4]usize{ 2, 3, 1, 0 }, + [4]usize{ 3, 0, 1, 2 }, + [4]usize{ 3, 0, 2, 1 }, + [4]usize{ 3, 1, 0, 2 }, + [4]usize{ 3, 1, 2, 0 }, + [4]usize{ 3, 2, 0, 1 }, + [4]usize{ 3, 2, 1, 0 }, + }; +} + +fn applyOrder(numbers: [4]i32, order: [4]usize) [4]i32 { + return [4]i32{ numbers[order[0]], numbers[order[1]], numbers[order[2]], numbers[order[3]] }; +} + +fn solutions(allocator: Allocator, numbers: [4]i32) !ArrayList(Factor) { + var ret = ArrayList(Factor).init(allocator); + var hash_set = HashMap([]const u8, void, std.hash_map.StringContext, std.hash_map.default_max_load_percentage).init(allocator); + defer { + // Free all keys in the hash map + var iterator = hash_set.iterator(); + while (iterator.next()) |entry| { + allocator.free(entry.key_ptr.*); + } + hash_set.deinit(); + } + + var op_iter = OpIter.init(); + while (op_iter.next()) |ops| { + const all_orders = orders(); + for (all_orders) |order| { + const reordered_numbers = applyOrder(numbers, order); + var results = calc(allocator, ops, reordered_numbers) catch continue; + defer { + for (results.items) |factor| { + factor.deinit(allocator); + } + results.deinit(); + } + + for (results.items) |factor| { + if (factor.value == 24) { + // Check if we've seen this content before + if (hash_set.contains(factor.content)) { + continue; + } + + // Add to hash set with a duplicated key + const key_copy = try allocator.dupe(u8, factor.content); + try hash_set.put(key_copy, {}); + + // Add to results with a duplicated content + try ret.append(Factor{ + .content = try allocator.dupe(u8, factor.content), + .value = factor.value, + }); + } + } + } + } + + return ret; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + // Hard-coded input: 5598 + const nums = [4]i32{ 5, 5, 9, 8 }; + + var sols = solutions(allocator, nums) catch { + print("Error computing solutions\n", .{}); + return; + }; + defer { + for (sols.items) |factor| { + factor.deinit(allocator); + } + sols.deinit(); + } + + const len = sols.items.len; + if (len == 0) { + print("no solution for {}, {}, {}, {}\n", .{ nums[0], nums[1], nums[2], nums[3] }); + return; + } + + print("solutions for {}, {}, {}, {}\n", .{ nums[0], nums[1], nums[2], nums[3] }); + for (sols.items) |s| { + print("{s}\n", .{s.content}); + } + print("{} solutions found\n", .{len}); +} diff --git a/Task/24-game/FutureBasic/24-game.basic b/Task/24-game/FutureBasic/24-game.basic index 68da1c6faa..e3cb41f183 100644 --- a/Task/24-game/FutureBasic/24-game.basic +++ b/Task/24-game/FutureBasic/24-game.basic @@ -1,4 +1,4 @@ -include resources "24 Game Icon.icns" +//include resources "24 Game Icon.icns" #build CompilerOptions @"-Wno-unused-variable" diff --git a/Task/24-game/Rust/24-game.rs b/Task/24-game/Rust/24-game.rs index 8e9e7f0ced..149fb0aa62 100644 --- a/Task/24-game/Rust/24-game.rs +++ b/Task/24-game/Rust/24-game.rs @@ -43,7 +43,7 @@ fn to_rpn(input: &mut String){ rpn_string.push(top); } - println!("you formula results in {}", rpn_string); + println!("your formula results in {}", rpn_string); *input=rpn_string; } @@ -72,7 +72,7 @@ fn calculate(input: &String, list : &mut [u32;4]) -> f32{ }; } } - println!("you formula results in {}",accumulator); + println!("your formula results in {}",accumulator); accumulator } @@ -95,14 +95,14 @@ fn main() { to_rpn(&mut input); let result = calculate(&input, &mut list); - if list.iter().any(|&list| list !=10){ + if list.iter().any(|&num| num != 10) { + println!("you didn't use all the numbers"); + } else { println!("and you used all numbers"); match result { 24.0 => println!("you won"), - _ => println!("but your formulla doesn't result in 24"), + _ => println!("but your formula doesn't result in 24"), } - }else{ - println!("you didn't use all the numbers"); } } diff --git a/Task/9-billion-names-of-God-the-integer/REBOL/9-billion-names-of-god-the-integer.rebol b/Task/9-billion-names-of-God-the-integer/REBOL/9-billion-names-of-god-the-integer.rebol new file mode 100644 index 0000000000..4c937e4e34 --- /dev/null +++ b/Task/9-billion-names-of-God-the-integer/REBOL/9-billion-names-of-god-the-integer.rebol @@ -0,0 +1,101 @@ +Rebol [ + title: "Rosetta code: 9 billion names of God the integer" + file: %9_billion_names_of_God_the_integer.r3 + url: https://rosettacode.org/wiki/9_billion_names_of_God_the_integer + needs: 3.0.0 + note: {Based on Red language version} +] +names-of-god: function/with [ + row [integer!] "row number (>= 1)" + /show "Display intermediate results" + /all "When showing, print all intermediate data" +][ + ;; Validate input - require row >= 1, otherwise trigger a runtime error + assert [row >= 1] + + ;; If /show refinement is used, display results for the given row + if show [ + ;; Ensure nums/:row is computed; if not, recursively compute it + unless nums/:row [names-of-god row] + + ;; Loop from 1 to row + repeat i row [ + either all [ ;; If /all refinement is used, display extra details + probe reduce [i nums/:i sums/:i] ;; Show index, sequence, and sum + ][ + print nums/:i ;; Otherwise, just print the sequence + ] + ] + ] + + ;; Compute a new row from scratch (if row not already computed)... + unless sum: sums/:row [ + out: clear [] ;; Temporary storage for row's elements + half: to integer! row / 2 ;; Middle position of the row + + ;; Ensure all required previous rows exist; generate missing ones + if row - 1 > last: length? nums [ + repeat i row - last - 1 [ + names-of-god last + i + ] + ] + + ;; Build the `out` block for this row + repeat col row - 1 [ + ;; Special case: the middle element + either col = (half + 1) [ + append out at nums/(row - 1) half ;; Insert from previous row's middle + break ;; Stop building here + ][ + ;; General case: append sum-part of two earlier sequences + append out sum-part nums/(row - col) col + ] + ] + + ;; Compute the sum of the row + sum: 0.0 + forall out [ + sum: sum + out/1 + ] + + ;; Cache the computed row and its sum + sums/:row: sum + nums/:row: copy out + clear out + ] + sums/:row ;; Return sum of the row +][ + ;; ===== WITH BLOCK (local helper definitions and persistent state) ===== + + ;; Helper function: sum the first `count` elements from the given block `nums` + sum-part: function [nums [block!] count [integer!]][ + out: 0.0 + loop count [ + out: out + nums/1 + if empty? nums: next nums [break] ;; Stop if we've exhausted the block + ] + ;; If within integer range, convert to integer + if out <= 0#7fffffffffffffff [out: to integer! out] + out + ] + + ;; Persistent storage for each computed row (map! with row → sequence) + ;; Start with base cases: + ;; row 1 = [1] + ;; row 2 = [1 1] + nums: make map! [1 [1] 2 [1 1]] + + ;; Persistent storage for row sums (map! with row → sum) + ;; Base sums: row 1 sum = 1, row 2 sum = 2 + sums: make map! [1 1 2 2] +] + + + +print "rows: ^/" +names-of-god/show 25 + +print "^/sums: ^/" +probe names-of-god 23 +probe names-of-god 123 +probe names-of-god 1234 diff --git a/Task/99-bottles-of-beer/ALGOL-68/99-bottles-of-beer.alg b/Task/99-bottles-of-beer/ALGOL-68/99-bottles-of-beer.alg index 5ec893ef5a..194eebdb25 100644 --- a/Task/99-bottles-of-beer/ALGOL-68/99-bottles-of-beer.alg +++ b/Task/99-bottles-of-beer/ALGOL-68/99-bottles-of-beer.alg @@ -1,8 +1,10 @@ -main:( - FOR bottles FROM 99 TO 1 BY -1 DO - printf(($z-d" bottles of beer on the wall"l$, bottles)); - printf(($z-d" bottles of beer"l$, bottles)); - printf(($"Take one down, pass it around"l$)); - printf(($z-d" bottles of beer on the wall"ll$, bottles-1)) - OD -) +FOR bottles FROM 99 BY -1 TO 1 DO + STRING bottles now = whole(bottles,0) + " bottle" + IF bottles = 1 THEN "" ELSE "s" FI; + STRING bottles left = IF bottles = 1 THEN "No more" ELSE whole(bottles-1,0) FI + + " bottle" + + IF bottles = 2 THEN "" ELSE "s" FI; + print((bottles now," of beer on the wall",newline)); + print((bottles now," of beer",newline)); + print(("Take one down, pass it around",newline)); + print((bottles left," of beer on the wall",newline,newline)) +OD diff --git a/Task/99-bottles-of-beer/Aria/99-bottles-of-beer.aria b/Task/99-bottles-of-beer/Aria/99-bottles-of-beer.aria new file mode 100644 index 0000000000..7e36393581 --- /dev/null +++ b/Task/99-bottles-of-beer/Aria/99-bottles-of-beer.aria @@ -0,0 +1,48 @@ +struct Lyrics { + type func new(n: Int) { + assert n > 0; + return alloc(This) { + .n = n, + }; + } + + func prettyprint() { + val suffix_n = this.n == 1 ? "" : "s"; + val suffix_n_minus_1 = this.n == 2 ? "" : "s"; + return "{0} bottle{2} of beer on the wall, {0} bottle{2} of beer.\nTake one down and pass it around, {1} bottle{3} of beer on the wall.\n".format(this.n, this.n-1, suffix_n, suffix_n_minus_1); + } +} + +struct Song { + type func new(n: Int) { + assert n > 0; + return alloc(This) { + .n = n, + }; + } + + func iterator() { + return this; + } + + func next() { + if this.n == 0 { + return Box(){.done = true}; + } + + val n = this.n; + this.n -= 1; + + return Box() { + .done = false, + .value = Lyrics.new(n), + }; + } +} + +func main() { + val song = Song.new(99); + for verse in song { + println(verse); + } +} diff --git a/Task/99-bottles-of-beer/ArkScript/99-bottles-of-beer.ark b/Task/99-bottles-of-beer/ArkScript/99-bottles-of-beer.ark new file mode 100644 index 0000000000..d12274823c --- /dev/null +++ b/Task/99-bottles-of-beer/ArkScript/99-bottles-of-beer.ark @@ -0,0 +1,24 @@ +# try and get an argument from the command line invocation +(let arg + (if (>= (len sys:args) 1) + (toNumber (@ sys:args 0)) + nil)) +# if no argument was passed the default value will be 100 +(let i + (if (nil? arg) + 100 + arg)) + +(let explode-bottles (fun (n) + (if (> n 1) { + (print (string:format "{} Bottles of beer on the wall\n{} bottles of beer\nTake one down, pass it around" n n)) + (print (string:format "{} Bottles of beer on the wall." (- n 1))) + (explode-bottles (- n 1)) }) +(explode-bottles i) + +# alternative solution with a loop +(mut n i) +(while (> n 1) { + (print (string:format "{} Bottles of beer on the wall\n{} bottles of beer\nTake one down, pass it around" n n)) + (set n (- n 1)) + (print (string:format "{} Bottles of beer on the wall." n)) }) diff --git a/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-1.duckdb b/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-1.duckdb new file mode 100644 index 0000000000..3fe002df2b --- /dev/null +++ b/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-1.duckdb @@ -0,0 +1,13 @@ +.header off +.mode list +select list_transform( range(99,-1,-1), + n -> + if (n = 0, + 'No more bottles of beer on the wall' || chr(10) + || 'no more bottles of beer.' || chr(10) + || 'Go to the store, buy some more!' || chr(10) + || '99 bottles of beer on the wall.', + n || ' bottle' || if ( n = 1, '', 's') || ' of beer on the wall' || chr(10) + || n || ' bottle' || if ( n = 1, '', 's') || ' of beer;' || chr(10) + || 'Take one down, pass it around' || chr(10) ) ) + .array_to_string(chr(10)) ; diff --git a/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-2.duckdb b/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-2.duckdb new file mode 100644 index 0000000000..02dd9eb97c --- /dev/null +++ b/Task/99-bottles-of-beer/DuckDB/99-bottles-of-beer-2.duckdb @@ -0,0 +1,21 @@ +.header off +.mode list + +with recursive cte as ( + select 99 as n, '' as s + union all + select n-1 as n, + if (n = 0, + 'No more bottles of beer on the wall' || chr(10) + || 'no more bottles of beer.' || chr(10) + || 'Go to the store, buy some more!' || chr(10) + || '99 bottles of beer on the wall.', + n || ' bottle' || if ( n = 1, '', 's') || ' of beer on the wall' || chr(10) + || n || ' bottle' || if ( n = 1, '', 's') || ' of beer;' || chr(10) + || 'Take one down, pass it around' || chr(10) ) + from cte + where n > -1 + ) select s + from cte + where s != '' + order by n desc ; diff --git a/Task/99-bottles-of-beer/Pluto/99-bottles-of-beer.pluto b/Task/99-bottles-of-beer/Pluto/99-bottles-of-beer.pluto new file mode 100644 index 0000000000..1e20d4e1f4 --- /dev/null +++ b/Task/99-bottles-of-beer/Pluto/99-bottles-of-beer.pluto @@ -0,0 +1,12 @@ +function pl(n) return n==1?"":"s" end + +function fmt(s) + return $"{s} bottle{pl(s)} of beer on the wall, \n" .. + $"{s} bottle{pl(s)} of beer. \n" .. + $"Take one down, pass it around, \n" .. + $"{s-1} bottle{pl(s-1)} of beer on the wall.\n\n" +end + +for i = 99, 1, -1 do + print(fmt(i)) +end diff --git a/Task/99-bottles-of-beer/Rhombus/99-bottles-of-beer.rhombus b/Task/99-bottles-of-beer/Rhombus/99-bottles-of-beer.rhombus new file mode 100644 index 0000000000..b7564c4ae9 --- /dev/null +++ b/Task/99-bottles-of-beer/Rhombus/99-bottles-of-beer.rhombus @@ -0,0 +1,13 @@ +#lang rhombus/static + +for (i in 1..100): + fun plural(n :: Int): + if n == 1: + | "" + | "s" + let bottles = 100 - i + println(@str{@(bottles) bottle@(plural(bottles)) of beer on the wall, @(bottles) bottle@(plural(bottles)) of beer.}) + println(@str{Take one down and pass it around, @(bottles - 1) bottle@(plural(bottles - 1)) of beer on the wall.}) + +println("No more bottles of beer on the wall, no more bottles of beer.") +println("Go to the store and buy some more, 99 bottles of beer on the wall.") diff --git a/Task/A+B/Agena/a+b.agena b/Task/A+B/Agena/a+b.agena index 5b94875c68..0ac7496582 100644 --- a/Task/A+B/Agena/a+b.agena +++ b/Task/A+B/Agena/a+b.agena @@ -1,6 +1,10 @@ scope local f := trim( io.read() ) split " "; # read a line and split into fields - local a := tonumber( f[ 1 ] ); - local b := tonumber( f[ 2 ] ); - print( a + b ) -epocs + try + local a := tonumber( f[ 1 ] ); + local b := tonumber( f[ 2 ] ); + print( a + b ) + catch in ex then + print( "Unable to add the numbers: ", tostring( ex ) ) + yrt +end diff --git a/Task/A+B/ArkScript/a+b.ark b/Task/A+B/ArkScript/a+b.ark new file mode 100644 index 0000000000..71c47670c9 --- /dev/null +++ b/Task/A+B/ArkScript/a+b.ark @@ -0,0 +1,9 @@ +(import std.String :split) +(import std.List :map :reduce) + +(let in (input)) +(let numbers (map (split in " ") (fun (t) (toNumber t)))) +(print (reduce numbers (fun (a b) + (if (nil? b) + a + (+ a b))))) diff --git a/Task/A+B/DuckDB/a+b-1.duckdb b/Task/A+B/DuckDB/a+b-1.duckdb new file mode 100644 index 0000000000..06fc2868f4 --- /dev/null +++ b/Task/A+B/DuckDB/a+b-1.duckdb @@ -0,0 +1,5 @@ +.headers off +.mode list +select sum(c::INTEGER) +from (select unnest(regexp_extract_all(content, '[-0-9]+') ) as c + from read_text('rc-a+b.txt') ); diff --git a/Task/A+B/DuckDB/a+b-2.duckdb b/Task/A+B/DuckDB/a+b-2.duckdb new file mode 100644 index 0000000000..ce4c1aa6c7 --- /dev/null +++ b/Task/A+B/DuckDB/a+b-2.duckdb @@ -0,0 +1,2 @@ +select a+b from (select column0 as a, column1 as b +from read_csv('/dev/stdin', header=false, sep=' ')); diff --git a/Task/A+B/Koka/a+b.koka b/Task/A+B/Koka/a+b.koka new file mode 100644 index 0000000000..f0f1738e2d --- /dev/null +++ b/Task/A+B/Koka/a+b.koka @@ -0,0 +1,32 @@ +import std/os/readline + +// A prompt effect which retries getting input until a valid result is returned. +effect prompt + ctl delimit(): () // Captures the retry resumption + final ctl fail(): e // A failed input + +// Prompt for input, with retry until successful result +// - `message` is the original prompt +// - `err-message` is the error shown on failure +fun prompt(message: string, err-message: string, action: (string) -> a): a + var reattempt := fn() impossible() // We ensure all paths include a delimiter + with handler + raw ctl delimit() + reattempt := (fn() rcontext.resume(())) // set reattempt resumption + reattempt() // Initial try + final ctl fail() + reattempt() // Handle failure by reattempting + // Print the initial request message + println(message) + delimit() // Mark retry point + try { + action(readline()) // Read the input and apply the action + } fn(err) + // On an exception, print the error message and retry + println(err-message) + fail() // reset + +fun main() + with line <- prompt("Enter two numbers separated by space: ", "Invalid input, please enter two integers.") + val [a, b] = line.split(" ") + a.parse-int.unjust + b.parse-int.unjust diff --git a/Task/A+B/Pluto/a+b.pluto b/Task/A+B/Pluto/a+b.pluto new file mode 100644 index 0000000000..974f2e0a29 --- /dev/null +++ b/Task/A+B/Pluto/a+b.pluto @@ -0,0 +1,2 @@ +a, b = io.read("*n", "*n") +print(a+b) diff --git a/Task/A+B/TAV/a+b.tav b/Task/A+B/TAV/a+b.tav new file mode 100644 index 0000000000..29b223afca --- /dev/null +++ b/Task/A+B/TAV/a+b.tav @@ -0,0 +1,6 @@ +main(parms):+ + ?# lne =: file () give lines \ void is standard input + ab =: string lne split by many of #Whitespace + a =: string ab[1] as integer + b =: string ab[2] as integer + print a + b diff --git a/Task/ABC-problem/DuckDB/abc-problem.duckdb b/Task/ABC-problem/DuckDB/abc-problem.duckdb new file mode 100644 index 0000000000..0856cd977f --- /dev/null +++ b/Task/ABC-problem/DuckDB/abc-problem.duckdb @@ -0,0 +1,45 @@ +CREATE OR REPLACE FUNCTION matches(block, letter) as ( + block[1] = letter or block[2] = letter +); + +# permute(lst, n, word) generates sub-permutations, perm (of length n), of the list lst, +# that satisfy matches(perm[i], word[i]), for i in range(1, n+1). +# Normally n = length(word). +# The caller is responsible for ensuring appropriate adjustment of typographical case. +CREATE OR REPLACE FUNCTION permute(lst, n, word) as table ( + WITH RECURSIVE permute(perm, remaining) as ( + -- base case + SELECT + []::VARCHAR[] as perm, + lst::VARCHAR[] as remaining + UNION ALL + -- recursive case: add one element from remaining to perm and remove it from remaining + SELECT + (perm || [element]) AS perm, + (remaining[1:i-1] || remaining[i+1:]) AS remaining + FROM (select *, unnest(remaining) AS element, generate_subscripts(remaining,1) as i + FROM permute) + WHERE length(perm) < n + and matches(element, word[1 + length(perm)]) + ) + SELECT perm + FROM permute + WHERE length(perm) = n +); + +# All solutions +CREATE OR REPLACE FUNCTION solve(word) as table ( + from permute( + ['BO', 'XK', 'DQ', 'CP', 'NA', 'GT', 'RE', 'TG', 'QD', 'FS', + 'JW', 'HU', 'VI', 'AN', 'OB', 'ER', 'FS', 'LY', 'PC', 'ZM'], + length(word), upper(word) ) +); + +CREATE OR REPLACE FUNCTION one_solution(word) as ( + from solve(word) + limit 1 +); + +# Examples +select word, one_solution(word) +from (select unnest(['','A','BarK','BOOK','TREAT','COMMON','SQUAD','Confuse','abba']) as word); diff --git a/Task/ABC-problem/Pluto/abc-problem.pluto b/Task/ABC-problem/Pluto/abc-problem.pluto new file mode 100644 index 0000000000..243a9a5f79 --- /dev/null +++ b/Task/ABC-problem/Pluto/abc-problem.pluto @@ -0,0 +1,25 @@ +function r(word, bl) + if word == "" then return true end + local c = word:byte(1) | 32 + for i = 1, #bl do + local b = bl[i] + if c == b:byte(1) | 32 or c == b:byte(2) | 32 then + bl[i] = bl[1] + bl[1] = b + if r(word:sub(2), bl:slice(2)) then return true end + bl[1], bl[i] = bl[i], bl[1] + end + end + return false +end + +local function new_speller(blocks) + local bl = blocks:split(" ") + return |word| -> r(word, bl) +end + +local sp = new_speller("BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM") +local words = {"A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE"} +for words as word do + print(string.format("%-7s %s", word, sp(word))) +end diff --git a/Task/AKS-test-for-primes/ANSI-BASIC/aks-test-for-primes.basic b/Task/AKS-test-for-primes/ANSI-BASIC/aks-test-for-primes.basic new file mode 100644 index 0000000000..547da20116 --- /dev/null +++ b/Task/AKS-test-for-primes/ANSI-BASIC/aks-test-for-primes.basic @@ -0,0 +1,79 @@ +100 REM AKS test for primes +110 DECLARE EXTERNAL SUB PascalTriangle +120 DECLARE EXTERNAL SUB ExpandPoly +130 DECLARE EXTERNAL FUNCTION IsPrime +140 FOR N = 0 TO 9 +150 CALL ExpandPoly(N) +160 NEXT N +170 FOR N = 2 TO 50 +180 IF IsPrime(N) <> 0 THEN PRINT USING("###"): N; +190 NEXT N +200 PRINT +210 END +220 REM ** +230 EXTERNAL SUB PascalTriangle(N, PasTri()) +240 REM Calculate t!he N'th line 0.. middle +250 LET N = INT(N) +260 LET PasTri(0) = 1 +270 LET J = 1 +280 DO WHILE J <= N +290 LET J = J + 1 +300 LET K = INT(J / 2) +310 LET PasTri(K) = PasTri(K - 1) +320 FOR K = K TO 1 STEP -1 +330 LET PasTri(K) = PasTri(K) + PasTri(K - 1) +340 NEXT K +350 LOOP +360 END SUB +370 REM ** +380 EXTERNAL FUNCTION IsPrime(N) +390 LET N = INT(N) +400 DIM PasTri(0 TO 50) +410 LET PasTriMax = UBOUND(PasTri) +420 IF N > PasTriMax THEN +430 PRINT N; "is out of range" +440 STOP +450 END IF +460 CALL PascalTriangle(N, PasTri) +470 LET Res = 1 +480 LET I = INT(N / 2) +490 DO WHILE (Res <> 0) AND (I > 1) +500 IF (Res <> 0) AND (MOD(PasTri(I), N) = 0) THEN LET Res = 1 ELSE LET Res = 0 +510 LET I = I - 1 +520 LOOP +530 LET IsPrime = Res +540 END FUNCTION +550 REM ** +560 EXTERNAL SUB ExpandPoly(N) +570 LET N = INT(N) +580 DIM VZ$(0 TO 1) +590 LET VZ$(0) = "+" +600 LET VZ$(1) = "-" +610 DIM PasTri(0 TO 50) +620 LET PasTriMax = UBOUND(PasTri) +630 IF N > PasTriMax THEN +640 PRINT N; "is out of range" +650 STOP +660 END IF +670 SELECT CASE N +680 CASE 0 +690 PRINT "(x - 1) ^ 0 = 1" +700 CASE 1 +710 PRINT "(x - 1) ^ 1 = x - 1" +720 CASE ELSE +730 CALL PascalTriangle(N, PasTri) +740 PRINT "(x - 1) ^"; N; " = x ^"; N; +750 LET BVZ = 1 +760 FOR J = N - 1 TO INT(N / 2) + 1 STEP -1 +770 PRINT VZ$(BVZ); PasTri(N - J); "* x ^"; J; +780 LET BVZ = ABS(1 - BVZ) +790 NEXT J +800 FOR J = INT(N / 2) TO 2 STEP -1 +810 PRINT VZ$(BVZ); PasTri(J); "* x ^"; J; +820 LET BVZ = ABS(1 - BVZ) +830 NEXT J +840 PRINT VZ$(BVZ); PasTri(1); "* x "; +850 LET BVZ = ABS(1 - BVZ) +860 PRINT VZ$(BVZ); PasTri(0) +870 END SELECT +880 END SUB diff --git a/Task/AKS-test-for-primes/Agena/aks-test-for-primes.agena b/Task/AKS-test-for-primes/Agena/aks-test-for-primes.agena new file mode 100644 index 0000000000..6589095e8f --- /dev/null +++ b/Task/AKS-test-for-primes/Agena/aks-test-for-primes.agena @@ -0,0 +1,89 @@ +# AKS test for primes + +constant pas_tri_max := 50; + +proc pascal_triangle(n :: posint) is +# Calculate the n'th line 1.. middle +# For n = 1, 2, .. + create register pas_tri((n + 1) \ 2); + # pas_tri[0] always is 1 + j := 1; + case n + of 1, 2 then pas_tri[1] := 2 + else + j := 3; + pas_tri[1] := 2; + while j <= n do + j++; + k := j \ 2; # middle + pas_tri[k] := pas_tri[k - 1]; + while k >= 2 do + pas_tri[k] +:= pas_tri[k - 1]; + k-- + od; + pas_tri[1] +:= 1 + od + esle + esac + return pas_tri +end; + +proc is_prime(n :: nonnegint) :: boolean is + if n > pas_tri_max then + printf("%d is out of range\n", n); + os.exit(-1) + fi; + pas_tri := pascal_triangle(n); + res := true; + i := n \ 2; + while res and (i > 1) do + res := res and (pas_tri[i] symmod n = 0); + i-- + od; + return res +end; + +proc vz(b :: boolean) is + return if b then '-' else '+' fi +end; + +proc expand_poly(n :: nonnegint) is + if n > pas_tri_max then + printf("%d is out of range\n", n); + os.exit(-1) + fi; + case n + of 0 then printf("(x-1)^0 = 1\n"); + of 1 then printf("(x-1)^1 = x-1\n"); + else + pas_tri := pascal_triangle(n); + printf("(x-1)^%d = x^%d", n, n); + bvz := true; + n_div_2 := n \ 2 + for j from n - 1 to n_div_2 + 1 by -1 do + printf("%s%d*x^%d", vz(bvz), pas_tri[n - j], j); + bvz := not bvz + od; + for j from n_div_2 to 2 by -1 do + printf("%s%d*x^%d", vz(bvz), pas_tri[j], j); + bvz := not bvz + od; + printf("%s%d*x", vz(bvz), pas_tri[1]); + bvz := not bvz; + printf("%s1\n", vz(bvz)); + esle + esac +end; + +scope + local n; + for n from 0 to 9 do + expand_poly(n) + od; + for n from 2 to pas_tri_max do + if is_prime(n) then + printf("%3d", n) + fi + od; + printf("\n") +end diff --git a/Task/AKS-test-for-primes/EasyLang/aks-test-for-primes.easy b/Task/AKS-test-for-primes/EasyLang/aks-test-for-primes.easy new file mode 100644 index 0000000000..54fc26429d --- /dev/null +++ b/Task/AKS-test-for-primes/EasyLang/aks-test-for-primes.easy @@ -0,0 +1,43 @@ +func[] coefs n . + list[] = [ 1 ] + arrbase list[] 0 + for k = 0 to n : list[] &= list[k] * (n - k) / (k + 1) + for k = 1 step 2 to n : list[k] = -list[k] + return list[] +. +func isprimeaks n . + c[] = coefs n + c[0] -= 1 + c[n] += 1 + for i = 0 to n + if c[i] mod n <> 0 : return 0 + . + return 1 +. +proc pprintcoefs n list[] . + for i = 0 to n + s$ = "" + if i > 0 + s$ = " + " + if list[i] < 0 : s$ = " - " + . + c$ = abs list[i] + e = n - i + if c$ = "1" and e > 0 : c$ = "" + x$ = "" + if e <> 0 + x$ = "x" + if e <> 1 : x$ &= "^" & e + . + r$ &= s$ & c$ & x$ + . + print "(x-1)^" & n & " : " & r$ +. +for i = 0 to 7 + pprintcoefs i coefs i +. +print "" +for i = 2 to 49 + if isprimeaks i = 1 : write i & " " +. +print "" diff --git a/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic b/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic index c94e8f7494..72bc4196df 100644 --- a/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic +++ b/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic @@ -1,6 +1,5 @@ // AKS Test for Primes task // https://rosettacode.org/wiki/AKS_test_for_primes -// Translated from Yabasic to FutureBASIC #build ShowMoreWarnings NO diff --git a/Task/AKS-test-for-primes/Modula-2/aks-test-for-primes.mod2 b/Task/AKS-test-for-primes/Modula-2/aks-test-for-primes.mod2 new file mode 100644 index 0000000000..a138aea166 --- /dev/null +++ b/Task/AKS-test-for-primes/Modula-2/aks-test-for-primes.mod2 @@ -0,0 +1,119 @@ +MODULE AKSTest; +(* AKS test for primes *) + +FROM STextIO IMPORT + WriteLn, WriteString; +FROM SWholeIO IMPORT + WriteInt; + +CONST + PasTriMax = 33; (* for 32-bit integer type *) + +TYPE + TPasTri = ARRAY [0 .. PasTriMax] OF CARDINAL; + +VAR + N: CARDINAL; + +PROCEDURE PascalTriangle(N: CARDINAL; VAR PasTri: TPasTri); +(* Calculate the N'th line 0.. middle *) +VAR + J, K: CARDINAL; +BEGIN + PasTri[0] := 1; + J := 1; + WHILE J <= N DO + J := J + 1; + K := J DIV 2; + PasTri[K] := PasTri[K - 1]; + FOR K := K TO 1 BY -1 DO + PasTri[K] := PasTri[K] + PasTri[K - 1]; + END + END +END PascalTriangle; + +PROCEDURE IsPrime(N: CARDINAL): BOOLEAN; +VAR + Res : BOOLEAN; + I : CARDINAL; + PasTri: TPasTri; +BEGIN + IF N > PasTriMax THEN + WriteInt(N, 1); + WriteString(" is out of range"); + WriteLn; + HALT; + END; + PascalTriangle(N, PasTri); + Res := TRUE; + I := N DIV 2; + WHILE Res AND (I > 1) DO + Res := Res AND (PasTri[I] MOD N = 0); + I := I - 1 + END; + RETURN Res; +END IsPrime; + +PROCEDURE ExpandPoly(N: CARDINAL); +TYPE + TVZ = ARRAY BOOLEAN OF CHAR; +CONST + VZ = TVZ {'+', '-'}; +VAR + J : CARDINAL; + BVZ : BOOLEAN; + PasTri: TPasTri; +BEGIN + IF N > PasTriMax THEN + WriteInt(N, 1); + WriteString(" is out of range"); + WriteLn; + HALT + END; + CASE N OF + | 0: + WriteString("(x-1)^0 = 1"); WriteLn; + | 1: + WriteString("(x-1)^1 = x-1"); WriteLn; + ELSE + PascalTriangle(N, PasTri); + WriteString("(x-1)^"); + WriteInt(N, 1); + WriteString(" = x^"); + WriteInt(N, 1); + BVZ := TRUE; + FOR J := N - 1 TO N DIV 2 + 1 BY -1 DO + WriteString(VZ[BVZ]); + WriteInt(PasTri[N - J], 1); + WriteString("*x^"); + WriteInt(J, 1); + BVZ := NOT BVZ + END; + FOR J := N DIV 2 TO 2 BY -1 DO + WriteString(VZ[BVZ]); + WriteInt(PasTri[J], 1); + WriteString("*x^"); + WriteInt(J, 1); + BVZ := NOT BVZ + END; + WriteString(VZ[BVZ]); + WriteInt(PasTri[1], 1); + WriteString("*x"); + BVZ := NOT BVZ; + WriteString(VZ[BVZ]); + WriteInt(PasTri[0], 1); + WriteLn; + END; +END ExpandPoly; + +BEGIN + FOR N := 0 TO 9 DO + ExpandPoly(N) + END; + FOR N := 2 TO PasTriMax DO + IF IsPrime(N) THEN + WriteInt(N, 3) + END + END; + WriteLn; +END AKSTest. diff --git a/Task/AKS-test-for-primes/PHP/aks-test-for-primes.php b/Task/AKS-test-for-primes/PHP/aks-test-for-primes.php new file mode 100644 index 0000000000..9b3e9bbaa4 --- /dev/null +++ b/Task/AKS-test-for-primes/PHP/aks-test-for-primes.php @@ -0,0 +1,80 @@ + PAS_TRI_MAX) { + echo $n, " is out of range", PHP_EOL; + exit; + } + switch ($n) { + case 0: + echo "(x-1)^0 = 1", PHP_EOL; + break; + case 1: + echo "(x-1)^1 = x-1", PHP_EOL; + break; + default: + $pas_tri = []; + pascal_triangle($n, $pas_tri); + echo "(x-1)^", $n, " = x^", $n; + $bvz = true; + $n_div_2 = intdiv($n, 2); + for ($j = $n - 1; $j > $n_div_2; $j--) { + echo vz($bvz), $pas_tri[$n - $j], "*x^", $j; + $bvz = !$bvz; + } + for ($j = $n_div_2; $j >= 2; $j--) { + echo vz($bvz), $pas_tri[$j], "*x^", $j; + $bvz = !$bvz; + } + echo vz($bvz), $pas_tri[1], "*x"; + $bvz = !$bvz; + echo vz($bvz), $pas_tri[0], PHP_EOL; + } +} + +function pascal_triangle($n, &$pas_tri) { +// Calculate the $n'th line 0.. middle + $pas_tri = array_fill(0, intdiv($n + 1, 2) + 1, 0); + $pas_tri[0] = 1; + $j = 1; + while ($j <= $n) { + $j++; + $k = intdiv($j, 2); + $pas_tri[$k] = $pas_tri[$k - 1]; + while ($k >= 1) { + $pas_tri[$k] += $pas_tri[$k - 1]; + $k--; + } + } +} + +function is_prime($n):bool { + if ($n > PAS_TRI_MAX) { + echo $n, " is out of range", PHP_EOL; + exit; + } + $pas_tri = []; + pascal_triangle($n, $pas_tri); + $res = true; + $i = intdiv($n, 2); + while ($res && ($i > 1)) { + $res = $res && ($pas_tri[$i] % $n == 0); + --$i; + } + return $res; +} + +for ($n = 0; $n <= 9; $n++) + expand_poly($n); +for ($n = 2; $n <= PAS_TRI_MAX; $n++) + if (is_prime($n)) + echo str_pad($n, 3, " ", STR_PAD_LEFT); +echo PHP_EOL; +?> diff --git a/Task/AKS-test-for-primes/Pluto/aks-test-for-primes.pluto b/Task/AKS-test-for-primes/Pluto/aks-test-for-primes.pluto new file mode 100644 index 0000000000..382e876965 --- /dev/null +++ b/Task/AKS-test-for-primes/Pluto/aks-test-for-primes.pluto @@ -0,0 +1,90 @@ +do -- "AKS test for promes" task - translated from the Algol 68 sample + + local bigint = require "pluto:bigint" + local b0, b1 = new bigint( 0 ), new bigint( 1 ) + --[[ + Mathematical preliminaries. + + First note that the homogeneous polynomial (a+b)^n is symmetrical + (to see this just swap the variables a and b). Therefore its + coefficients need be calculated only to that of (ab)^{n/2} for even + n or (ab)^{(n-1)/2} for odd n. + + Second, the coefficients are the binomial coefficients C(n,k) where + the coefficient of a^k b^(n-k) is C(n,k) = n! / k! (k-1)!. This + leads to an immediate and relatively efficient implementation for + which we do not need to compute n! before dividing by k! and (k-1)! + but, rather cancel common factors as we go along. Further, the + well-known symmetry identity C(n,k) = C(n, n-k) allows a + significant reduction in computational effort. + + Third, (x-1)^n is the value of (a + b)^n when a=x and b = -1. The + powers of -1 alternate between +1 and -1 so we may as well compute + (x+1)^n and negate every other coefficient when printing. + ]] + + local function choose( n, k ) + local result = b1 + local symK = if k >= n//2 then n-k else k end -- Use symmetry + if symK > 0 then + local iPlus1 = b1 + local nMinusI = new bigint( n ) + for _ = 0, symK-1 do + result *= nMinusI + result /= iPlus1 + iPlus1 += b1 + nMinusI -= b1 + end + end + return result + end + local function coefficients( n ) + local a = {} + for i = 0, n//2 do + a[i] = choose( n, i ) + a[n-i] = a[i] -- Use symmetry + end + return a + end + --[[ + First print the polynomials (x-1)^n, remembering to alternate signs + and to tidy up the constant term, the x^1 term and the x^n term. + This means we must treat (x-1)^0 and (x-1)^1 specially + ]] + for n = 0,7 do + local a = coefficients( n ) + io.write( "(x-1)^"..n.." = " ) + switch n do + case 0: io.write( tostring( a[0] ) ) break + case 1: io.write( "x - "..tostring( a[1] ) ) break + default: io.write( "x^"..n ) + for i = 1,n-2 do + local ai = tostring( a[i] ) + io.write( if i % 2 == 1 then " - " else " + " end..ai.."x^"..(n-i) ) + end + io.write( if ( n - 1 ) % 2 == 1 then " - " else " + " end..tostring( a[n-1] ).."x" ) + io.write( if n % 2 == 1 then " - " else " + " end..tostring( a[n] ) ) + end + io.write( "\n" ) + end + --[[ + Finally, for the "AKS" portion of the task, the sign of the + coefficient has no effect on its divisibility by p so, once again, + we may as well use the positive coefficients. Symmetry clearly + reduces the necessary number of tests by a factor of two. + ]] + local function isPrime( n ) + local prime = true + local bn = new bigint( n ) + for i = 1,n//2 do + prime = choose( n, i ) % bn == b0 + if not prime then return false end + end + return true + end + io.write( "Primes between 1 and 50 are:" ) + for n = 2,50 do if isPrime(n) then io.write( " "..n ) end end + io.write( "\nPrimes between 900 and 1000 are:") + for n = 900,1000 do if isPrime(n) then io.write( " "..n ) end end + io.write( "\n" ) +end diff --git a/Task/AKS-test-for-primes/PowerShell/aks-test-for-primes.psh b/Task/AKS-test-for-primes/PowerShell/aks-test-for-primes.psh new file mode 100644 index 0000000000..c79bcdf5e7 --- /dev/null +++ b/Task/AKS-test-for-primes/PowerShell/aks-test-for-primes.psh @@ -0,0 +1,84 @@ +# AKS test for primes + +$script:PasTriMax = 61 # for long type of Pascal triangle numbers + +function Pascal-Triangle { + # Calculate the n'th line 0.. middle + param( + [int]$N + ) + + $pasTri = [long[]]::new([math]::Ceiling(($N + 2) / 2)) + $pasTri[0] = 1 + [int]$j = 1 + while ($j -le $N) { + $j++ + [int]$k = [math]::Floor($j / 2) + $pasTri[$k] = $pasTri[$k - 1] + for (; $k -ge 1; $k--) { + $pasTri[$k] += $pasTri[$k - 1] + } + } + # Now: $j -eq ($N + 1), so $k -eq [math]::Floor(($N + 1) / 2) + return $pasTri +} + +function Expand-Poly { + param ([int]$N) + + if ($N -gt $script:PasTriMax) { + throw "$N is out of range" + } + switch($N) { + 0 {Write-Output "(x-1)^0 = 1"} + 1 {Write-Output "(x-1)^1 = x-1"} + default { + $VZ = @('+', '-') + $pasTri = Pascal-Triangle($N) + [string]$outTri = @() + $outTri += "(x-1)^$N = x^$N" + [bool]$bVz = $true + [int]$nDiv2 = [math]::Floor($N / 2) + for ([int]$j = $N - 1; $j -gt $nDiv2; $j--) { + $outTri += "$($VZ[$bVz]) $($pasTri[$N - $j])*x^$j" + $bVz = -not $bVz + } + for ([int]$j = $nDiv2; $j -gt 1; $j--) { + $outTri += "$($VZ[$bVz]) $($pasTri[$j])*x^$j" + $bVz = -not $bVz + } + $outTri += "$($VZ[$bVz]) $($pasTri[1])*x" + $bVz = -not $bVz + $outTri += "$($VZ[$bVz]) $($pasTri[0])" + Write-Output $outTri + } + } +} + +function Is-Prime { + param([int]$N) + + if ($N -gt $script:PasTriMax) { + throw "$N is out of range" + } + $pasTri = Pascal-Triangle($N) + [bool]$res = $true + [int]$i = [math]::Floor($N / 2) + while ($res -and ($i -gt 1)) { + $res = $res -and ($pasTri[$i] % $N -eq 0) + $i-- + } + return $res +} + +# Test program +foreach ($n in 0..9) { + Expand-Poly($n) +} +[string]$primes = @() +foreach ($n in 2..$script:PasTriMax) { + if (Is-Prime($n)) { + $primes += "{0,3}" -f $n + } +} +Write-Output $primes diff --git a/Task/AKS-test-for-primes/REXX/aks-test-for-primes-2.rexx b/Task/AKS-test-for-primes/REXX/aks-test-for-primes-2.rexx index 1942f69672..80afc0c295 100644 --- a/Task/AKS-test-for-primes/REXX/aks-test-for-primes-2.rexx +++ b/Task/AKS-test-for-primes/REXX/aks-test-for-primes-2.rexx @@ -1,12 +1,12 @@ --- 22 Mar 2025 +-- 28 Jul 2025 include Settings +arg p +if p = '' then + p = 10 say 'AKS TEST FOR PRIMES' say version say -arg p -if p = '' then - p = 10 numeric digits Max(10,Abs(p)%3) call Combis p call Polynomials p @@ -37,9 +37,9 @@ else b = 0 p = Abs(p); prim. = 0; n = 0 do i = b to p - a = Ppow('1 -1',i) + a = PowP('1 -1',i) if i < 11 then - say '(x-1)^'i '=' Plst2form(Parr2lst()) + say '(x-1)^'i '=' Lst2FormP(Arr2LstP()) s = 1 do j = 2 to poly.0-1 a = poly.coef.j @@ -84,8 +84,4 @@ say Format(Time('e'),,3) 'seconds' say return -include Functions -include Numbers -include Polynomial -include Sequences -include Abend +include Math diff --git a/Task/AKS-test-for-primes/XBasic/aks-test-for-primes.basic b/Task/AKS-test-for-primes/XBasic/aks-test-for-primes.basic new file mode 100644 index 0000000000..ee9baae9d6 --- /dev/null +++ b/Task/AKS-test-for-primes/XBasic/aks-test-for-primes.basic @@ -0,0 +1,84 @@ +PROGRAM "akstest" +' AKS test for primes + +DECLARE FUNCTION Entry () +INTERNAL FUNCTION ExpandPoly(n@@) +INTERNAL FUNCTION PascalTriangle(n@@, @pasTri&&[]) +INTERNAL FUNCTION IsPrime(n@@) +INTERNAL FUNCTION Vz$(b@) +$$PasTriMax = 33 ' for 32-bit integer type + +FUNCTION Entry() + FOR n@@ = 0 TO 9 + ExpandPoly(n@@) + NEXT + FOR n@@ = 2 TO $$PasTriMax + IF IsPrime(n@@) THEN PRINT FORMAT$("###", n@@); + NEXT + PRINT +END FUNCTION + +FUNCTION ExpandPoly(n@@) + DIM pasTri&&[$$PasTriMax] + IF n@@ > $$PasTriMax THEN + PRINT n@@; " is out of range" + QUIT(1) + END IF + SELECT CASE n@@ + CASE 0: + PRINT "(x - 1) ^ 0 = 1" + CASE 1: + PRINT "(x - 1) ^ 1 = x - 1" + CASE ELSE: + PascalTriangle(n@@, @pasTri&&[]) + PRINT "(x - 1) ^"; n@@; " = x ^"; n@@; + bVz@ = $$TRUE + FOR j@@ = n@@ - 1 TO n@@ \ 2 + 1 STEP -1 + PRINT " "; Vz$(bVz@); pasTri&&[n@@ - j@@]; " * x ^"; j@@; + bVz@ = NOT bVz@ + NEXT + FOR j@@ = n@@ \ 2 TO 2 STEP -1 + PRINT " "; Vz$(bVz@); pasTri&&[j@@]; " * x ^"; j@@; + bVz@ = NOT bVz@ + NEXT + PRINT " "; Vz$(bVz@); pasTri&&[1]; " * x "; + bVz@ = NOT bVz@ + PRINT Vz$(bVz@); pasTri&&[0] + END SELECT + +END FUNCTION + +FUNCTION PascalTriangle(n@@, @pasTri&&[]) +' Calculate the n@@'th line 0.. middle + pasTri&&[0] = 1 + j@@ = 1 + DO WHILE j@@ <= n@@ + INC j@@ + k@@ = j@@ \ 2 + pasTri&&[k@@] = pasTri&&[k@@ - 1] + FOR k@@ = k@@ TO 1 STEP -1 + pasTri&&[k@@] = pasTri&&[k@@] + pasTri&&[k@@ - 1] + NEXT + LOOP +END FUNCTION + +FUNCTION IsPrime(n@@) + DIM pasTri&&[$$PasTriMax] + IF n@@ > $$PasTriMax THEN + PRINT n@@; " is out of range" + QUIT(1) + END IF + PascalTriangle(n@@, @pasTri&&[]) + res@ = $$TRUE + i@@ = n@@ \ 2 + DO WHILE res@ AND (i@@ > 1) + res@ = res@ AND (pasTri&&[i@@] MOD n@@ = 0) + DEC i@@ + LOOP + RETURN res@ +END FUNCTION + +FUNCTION Vz$(b@) + IF b@ THEN RETURN "-" ELSE RETURN "+" +END FUNCTION +END PROGRAM diff --git a/Task/AKS-test-for-primes/XPL0/aks-test-for-primes.xpl0 b/Task/AKS-test-for-primes/XPL0/aks-test-for-primes.xpl0 new file mode 100644 index 0000000000..a60bd11dec --- /dev/null +++ b/Task/AKS-test-for-primes/XPL0/aks-test-for-primes.xpl0 @@ -0,0 +1,105 @@ +\AKS test for primes +code Rem=2, ChOut=8, CrLf=9, Text=12, IntOut=11; +code real RlOut=48, Float=49, Format=52; +define PasTriMax = 33; \for 32-bit integer type +integer N; + + procedure PascalTriangle(N, PasTri); + \Calculate the N'th line 0.. middle + integer N, PasTri; + integer J, K; + begin + PasTri(0):= 1; + J:= 1; + while J <= N do + begin + J:= J + 1; + K:= J / 2; + PasTri(K):= PasTri(K - 1); + for K:= K downto 1 do PasTri(K):= PasTri(K) + PasTri(K - 1) + end \while + end; + + function integer IsPrime(N); + integer N; + integer Res, I, PasTri(PasTriMax + 1); + begin + if N > PasTriMax then + begin + IntOut(0, N); + Text(0, " is out of range"); + CrLf(0); + exit; + end; + PascalTriangle(N, PasTri); + Res:= true; + I:= N / 2; + while Res & (I > 1) do + begin + Res:= Res & (Rem(PasTri(I) / N) = 0); + I:= I - 1 + end; + return Res; + end; + + procedure ExpandPoly(N); + integer N; + integer J, BVZ, PasTri(PasTriMax + 1); + + procedure VZOut(D, B); + integer D, B; + begin + if B then ChOut(D, ^-) else ChOut(D, ^+) + end; + + begin + if N > PasTriMax then + begin + IntOut(0, N); + Text(0, " is out of range"); + CrLf(0); + exit + end; + case N of + 0: [Text(0, "(x-1)^^0 = 1"); CrLf(0)]; + 1: [Text(0, "(x-1)^^1 = x-1"); CrLf(0)] + other + begin + PascalTriangle(N, PasTri); + Text(0, "(x-1)^^"); + IntOut(0, N); + Text(0, " = x^^"); + IntOut(0, N); + BVZ:= true; + for J:= N - 1 downto N / 2 + 1 do + begin + VZOut(0, BVZ); + IntOut(0, PasTri(N - J)); + Text(0, "*x^^"); + IntOut(0, J); + BVZ:= ~BVZ; + end; + for J:= N / 2 downto 2 do + begin + VZOut(0, BVZ); + IntOut(0, PasTri(J)); + Text(0, "*x^^"); + IntOut(0, J); + BVZ:= ~BVZ + end; + VZOut(0, BVZ); + IntOut(0, PasTri(1)); + Text(0, "*x"); + BVZ:= ~BVZ; + VZOut(0, BVZ); + IntOut(0, PasTri(0)); + CrLf(0); + end \case other + end; + +begin +for N:= 0 to 9 do ExpandPoly(N); +for N:= 2 to PasTriMax do + if IsPrime(N) then [Format(3,0); RlOut(0, Float(N))]; +CrLf(0); +end diff --git a/Task/ASCII-art-diagram-converter/Mathematica/ascii-art-diagram-converter.math b/Task/ASCII-art-diagram-converter/Mathematica/ascii-art-diagram-converter.math new file mode 100644 index 0000000000..d8537d0ef8 --- /dev/null +++ b/Task/ASCII-art-diagram-converter/Mathematica/ascii-art-diagram-converter.math @@ -0,0 +1,86 @@ +diagram = " + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ID | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + |QR| Opcode |AA|TC|RD|RA| Z | RCODE | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | QDCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ANCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | NSCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ARCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"; + +testhexdata = "78477bbf5496e12e1bf169a4"; + +(* Define BitField as an Association instead of a struct *) +createBitField[name_, bits_, fieldstart_, fieldend_] := + <|"name" -> name, "bits" -> bits, "fieldstart" -> fieldstart, "fieldend" -> fieldend|>; + +diagramToStruct[txt_] := Module[{bitfields = {}, lines, nbits, fieldpos, bitaccum, + bitsize, bitlabel, bitstart, bitend}, + lines = StringTrim /@ StringSplit[txt, "\n"]; + + Do[ + nbits = StringCount[lines[[row]], "+"] - 1; + fieldpos = StringPosition[lines[[row + 1]], "|"][[All, 1]]; + bitaccum = Floor[row/2] * nbits; + + Do[ + endfield = fieldpos[[i + 1]]; + bitsize = Floor[(endfield - field)/3]; + bitlabel = StringTrim[StringTake[lines[[row + 1]], {field + 1, endfield - 1}]]; + bitstart = Floor[(field - 1)/3] + bitaccum; + bitend = bitstart + bitsize - 1; + AppendTo[bitfields, createBitField[bitlabel, bitsize, bitstart, bitend]], + + {i, 1, Length[fieldpos] - 1}, {field, {fieldpos[[i]]}} + ], + + {row, 1, Length[lines] - 1, 2} + ]; + + bitfields +]; + +(* Convert a hex byte to binary string with padding *) +binByte[c_] := IntegerString[FromDigits[c, 16], 2, 8]; + +(* Convert entire hex string to binary *) +hexToBinary[s_] := StringJoin[ + binByte /@ (StringTake[s, {#, # + 1}] & /@ Range[1, StringLength[s] - 1, 2]) +]; + +validator[binstring_, fields_] := + StringLength[binstring] == Total[#["bits"] & /@ fields]; + +bitReader[bitfields_, hexdata_] := Module[{b, pat}, + Print["\nEvaluation of hex data ", hexdata, " as bitfields:"]; + Print["Name Size Bits\n------- ---- ----------------"]; + + b = hexToBinary[hexdata]; + Assert[validator[b, bitfields]]; + + Do[ + pat = StringTake[b, {bf["fieldstart"] + 1, bf["fieldend"] + 1}]; + Print[StringPadRight[bf["name"], 9], + StringPadRight[ToString[bf["bits"]], 6], + StringPadLeft[pat, 16]], + {bf, bitfields} + ] +]; + +decoded = diagramToStruct[diagram]; + +Print["Diagram as bit fields:\nName Bits Start End\n------ ---- ----- ---"]; +Do[ + Print[StringPadRight[bf["name"], 8], + StringPadRight[ToString[bf["bits"]], 6], + StringPadRight[ToString[bf["fieldstart"]], 6], + StringPadLeft[ToString[bf["fieldend"]], 4]], + {bf, decoded} +]; + +bitReader[decoded, testhexdata]; diff --git a/Task/AVL-tree/Dart/avl-tree.dart b/Task/AVL-tree/Dart/avl-tree.dart new file mode 100644 index 0000000000..fb761a2aec --- /dev/null +++ b/Task/AVL-tree/Dart/avl-tree.dart @@ -0,0 +1,221 @@ +class Node { + int key; + int balance = 0; + int height = 0; + Node? left; + Node? right; + Node? parent; + + Node(this.key, this.parent); +} + + + + +class AVLTree { + Node? root; + + bool insert(int key) { + if (root == null) { + root = Node(key, null); + return true; + } + + Node? n = root; + while (true) { + if (n!.key == key) return false; + + Node parent = n; + + bool goLeft = n.key > key; + n = goLeft ? n.left : n.right; + + if (n == null) { + if (goLeft) { + parent.left = Node(key, parent); + } else { + parent.right = Node(key, parent); + } + rebalance(parent); + break; + } + } + return true; + } + + void _delete(Node node) { + if (node.left == null && node.right == null) { + if (node.parent == null) { + root = null; + } else { + Node parent = node.parent!; + if (parent.left == node) { + parent.left = null; + } else { + parent.right = null; + } + rebalance(parent); + } + return; + } + + if (node.left != null) { + Node child = node.left!; + while (child.right != null) child = child.right!; + node.key = child.key; + _delete(child); + } else { + Node child = node.right!; + while (child.left != null) child = child.left!; + node.key = child.key; + _delete(child); + } + } + + void delete(int delKey) { + if (root == null) return; + + Node? child = root; + while (child != null) { + Node node = child; + child = delKey >= node.key ? node.right : node.left; + if (delKey == node.key) { + _delete(node); + return; + } + } + } + + void rebalance(Node n) { + setBalance(n); + + if (n.balance == -2) { + if (height(n.left!.left) >= height(n.left!.right)) { + n = rotateRight(n); + } else { + n = rotateLeftThenRight(n); + } + } else if (n.balance == 2) { + if (height(n.right!.right) >= height(n.right!.left)) { + n = rotateLeft(n); + } else { + n = rotateRightThenLeft(n); + } + } + + if (n.parent != null) { + rebalance(n.parent!); + } else { + root = n; + } + } + + Node rotateLeft(Node a) { + Node b = a.right!; + b.parent = a.parent; + + a.right = b.left; + + if (a.right != null) a.right!.parent = a; + + b.left = a; + a.parent = b; + + if (b.parent != null) { + if (b.parent!.right == a) { + b.parent!.right = b; + } else { + b.parent!.left = b; + } + } + + setBalance(a, b); + + return b; + } + + Node rotateRight(Node a) { + Node b = a.left!; + b.parent = a.parent; + + a.left = b.right; + + if (a.left != null) a.left!.parent = a; + + b.right = a; + a.parent = b; + + if (b.parent != null) { + if (b.parent!.right == a) { + b.parent!.right = b; + } else { + b.parent!.left = b; + } + } + + setBalance(a, b); + + return b; + } + + Node rotateLeftThenRight(Node n) { + n.left = rotateLeft(n.left!); + return rotateRight(n); + } + + Node rotateRightThenLeft(Node n) { + n.right = rotateRight(n.right!); + return rotateLeft(n); + } + + int height(Node? n) { + if (n == null) return -1; + return n.height; + } + + void setBalance(Node n, [Node? n2]) { + reheight(n); + n.balance = height(n.right) - height(n.left); + + if (n2 != null) { + reheight(n2); + n2.balance = height(n2.right) - height(n2.left); + } + } + + void printBalance() { + _printBalance(root); + } + + void _printBalance(Node? n) { + if (n != null) { + _printBalance(n.left); + print('${n.balance} '); + _printBalance(n.right); + } + } + + void reheight(Node node) { + if (node != null) { + node.height = 1 + (height(node.left) > height(node.right) + ? height(node.left) + : height(node.right)); + } + } + + static void main() { + AVLTree tree = AVLTree(); + + print('Inserting values 1 to 10'); + for (int i = 1; i < 10; i++) { + tree.insert(i); + } + + print('Printing balance: '); + tree.printBalance(); + } +} + +void main() { + AVLTree.main(); +} diff --git a/Task/AVL-tree/Swift/avl-tree.swift b/Task/AVL-tree/Swift/avl-tree.swift new file mode 100644 index 0000000000..06db507617 --- /dev/null +++ b/Task/AVL-tree/Swift/avl-tree.swift @@ -0,0 +1,243 @@ +import Foundation + +// MARK: - AVL Tree --------------------------------------------------------- + +final class AVLTree { + // ---------- Node ------------------------------------------------------ + private class Node { + var key: Int + var balance: Int = 0 + var height: Int = 0 + + var left: Node? + var right: Node? + weak var parent: Node? // weak to avoid retain cycles + + init(key: Int, parent: Node?) { + self.key = key + self.parent = parent + } + } + + // ---------- Root ------------------------------------------------------- + private var root: Node? + + // ---------- Public API ------------------------------------------------- + + /// Inserts `key`. Returns `true` if the key was added, `false` if it already existed. + @discardableResult + func insert(_ key: Int) -> Bool { + // empty tree → new root + guard let rootNode = root else { + root = Node(key: key, parent: nil) + return true + } + + var n: Node? = rootNode + while let cur = n { + if cur.key == key { return false } // duplicate + + let goLeft = key < cur.key + let parent = cur + n = goLeft ? cur.left : cur.right + + // we have found the empty spot → insert + if n == nil { + let newNode = Node(key: key, parent: parent) + if goLeft { + parent.left = newNode + } else { + parent.right = newNode + } + rebalance(parent) // fix AVL balance upwards + break + } + } + return true + } + + /// Deletes `key` if it exists. Does nothing when the key is not present. + func delete(_ key: Int) { + var current = root + while let node = current { + if key == node.key { + delete(node) // internal helper that really removes the node + return + } + current = (key < node.key) ? node.left : node.right + } + // key not found → nothing to do + } + + /// Prints the balance factor of every node in‑order. + func printBalance() { + printBalance(node: root) + } + + // ---------- Private helpers ------------------------------------------- + + /// Removes `node` from the tree (used by the public `delete(_:)` above). + private func delete(_ node: Node) { + // ----- 1️⃣ leaf node ------------------------------------------------ + if node.left == nil && node.right == nil { + if let parent = node.parent { + if parent.left === node { parent.left = nil } + else { parent.right = nil } + rebalance(parent) + } else { + root = nil // tree becomes empty + } + return + } + + // ----- 2️⃣ node has a left subtree → replace with predecessor ----- + if let left = node.left { + var predecessor = left + while let r = predecessor.right { predecessor = r } + node.key = predecessor.key + delete(predecessor) + } + // ----- 3️⃣ otherwise it has a right subtree → replace with successor + else if let right = node.right { + var successor = right + while let l = successor.left { successor = l } + node.key = successor.key + delete(successor) + } + } + + /// Walks upward from `n`, fixing heights, balances and performing rotations. + private func rebalance(_ n: Node) { + setBalance(of: n) + + var node = n + if node.balance == -2 { + // left heavy + if height(of: node.left?.left) >= height(of: node.left?.right) { + node = rotateRight(node) + } else { + node = rotateLeftThenRight(node) + } + } else if node.balance == 2 { + // right heavy + if height(of: node.right?.right) >= height(of: node.right?.left) { + node = rotateLeft(node) + } else { + node = rotateRightThenLeft(node) + } + } + + // continue upwards – or make this node the new root + if let parent = node.parent { + rebalance(parent) + } else { + root = node + } + } + + // ---------- Rotations ------------------------------------------------- + + private func rotateLeft(_ a: Node) -> Node { + guard let b = a.right else { return a } // safety guard + + // detach b from a + b.parent = a.parent + a.right = b.left + a.right?.parent = a + + // attach a under b + b.left = a + a.parent = b + + // reconnect b with the rest of the tree + if let p = b.parent { + if p.left === a { + p.left = b + } else { + p.right = b + } + } + + setBalance(of: a, b) + return b + } + + private func rotateRight(_ a: Node) -> Node { + guard let b = a.left else { return a } // safety guard + + b.parent = a.parent + a.left = b.right + a.left?.parent = a + + b.right = a + a.parent = b + + if let p = b.parent { + if p.left === a { + p.left = b + } else { + p.right = b + } + } + + setBalance(of: a, b) + return b + } + + private func rotateLeftThenRight(_ n: Node) -> Node { + if let left = n.left { + n.left = rotateLeft(left) + } + return rotateRight(n) + } + + private func rotateRightThenLeft(_ n: Node) -> Node { + if let right = n.right { + n.right = rotateRight(right) + } + return rotateLeft(n) + } + + // ---------- Height / Balance helpers ---------------------------------- + + /// Height of a node – `-1` for `nil` (matches the Java implementation). + private func height(of node: Node?) -> Int { + node?.height ?? -1 + } + + /// Re‑computes stored height of `node`. + private func reheight(_ node: Node?) { + guard let node = node else { return } + node.height = 1 + max(height(of: node.left), height(of: node.right)) + } + + /// Updates both `height` and `balance` for every supplied node. + private func setBalance(of nodes: Node...) { + for n in nodes { + reheight(n) + n.balance = height(of: n.right) - height(of: n.left) + } + } + + // ---------- Printing --------------------------------------------------- + + private func printBalance(node: Node?) { + guard let node = node else { return } + printBalance(node: node.left) + print("\(node.balance) ", terminator: "") + printBalance(node: node.right) + } +} + +// MARK: - Demo ------------------------------------------------------------- + +let tree = AVLTree() + +print("Inserting values 1 to 10") +for i in 1...10 { + _ = tree.insert(i) +} + +print("Printing balance: ", terminator: "") +tree.printBalance() +print() // newline diff --git a/Task/AVL-tree/Zig/avl-tree.zig b/Task/AVL-tree/Zig/avl-tree.zig new file mode 100644 index 0000000000..3dddf5315b --- /dev/null +++ b/Task/AVL-tree/Zig/avl-tree.zig @@ -0,0 +1,268 @@ +const std = @import("std"); +const math = std.math; +const stdout = std.io.getStdOut().writer(); +const Allocator = std.mem.Allocator; + +// AVL node +fn AVLnode(comptime T: type) type { + return struct { + const Self = @This(); + + key: T, + balance: i32, + left: ?*Self, + right: ?*Self, + parent: ?*Self, + + fn init(k: T, p: ?*Self) Self { + return Self{ + .key = k, + .balance = 0, + .parent = p, + .left = null, + .right = null, + }; + } + + fn deinit(self: *Self, allocator: Allocator) void { + if (self.left) |left| { + left.deinit(allocator); + allocator.destroy(left); + } + if (self.right) |right| { + right.deinit(allocator); + allocator.destroy(right); + } + } + }; +} + +// AVL tree +fn AVLtree(comptime T: type) type { + return struct { + const Self = @This(); + const Node = AVLnode(T); + + root: ?*Node, + allocator: Allocator, + + fn init(allocator: Allocator) Self { + return Self{ + .root = null, + .allocator = allocator, + }; + } + + fn deinit(self: *Self) void { + if (self.root) |root| { + root.deinit(self.allocator); + self.allocator.destroy(root); + } + } + + fn rotateLeft(self: *Self, a: *Node) *Node { + var b = a.right.?; + b.parent = a.parent; + a.right = b.left; + + if (a.right != null) { + a.right.?.parent = a; + } + + b.left = a; + a.parent = b; + + if (b.parent) |parent| { + if (parent.right == a) { + parent.right = b; + } else { + parent.left = b; + } + } + + self.setBalance(a); + self.setBalance(b); + return b; + } + + fn rotateRight(self: *Self, a: *Node) *Node { + var b = a.left.?; + b.parent = a.parent; + a.left = b.right; + + if (a.left != null) { + a.left.?.parent = a; + } + + b.right = a; + a.parent = b; + + if (b.parent) |parent| { + if (parent.right == a) { + parent.right = b; + } else { + parent.left = b; + } + } + + self.setBalance(a); + self.setBalance(b); + return b; + } + + fn rotateLeftThenRight(self: *Self, n: *Node) *Node { + n.left = self.rotateLeft(n.left.?); + return self.rotateRight(n); + } + + fn rotateRightThenLeft(self: *Self, n: *Node) *Node { + n.right = self.rotateRight(n.right.?); + return self.rotateLeft(n); + } + + fn height(self: *Self, n: ?*Node) i32 { + if (n == null) + return -1; + return 1 + @max(self.height(n.?.left), self.height(n.?.right)); + } + + fn setBalance(self: *Self, n: *Node) void { + n.balance = self.height(n.right) - self.height(n.left); + } + + fn rebalance(self: *Self, _n: *Node) void { + var n=_n; + self.setBalance(n); + + if (n.balance == -2) { + if (self.height(n.left.?.left) >= self.height(n.left.?.right)) { + n = self.rotateRight(n); + } else { + n = self.rotateLeftThenRight(n); + } + } else if (n.balance == 2) { + if (self.height(n.right.?.right) >= self.height(n.right.?.left)) { + n = self.rotateLeft(n); + } else { + n = self.rotateRightThenLeft(n); + } + } + + if (n.parent != null) { + self.rebalance(n.parent.?); + } else { + self.root = n; + } + } + + fn insert(self: *Self, key: T) !bool { + if (self.root == null) { + const node = try self.allocator.create(Node); + node.* = Node.init(key, null); + self.root = node; + } else { + var n = self.root.?; + var parent: *Node = undefined; + + while (true) { + if (n.key == key) + return false; + + parent = n; + + const goLeft = n.key > key; + if (goLeft) { + if (n.left) |left| { + n = left; + } else { + const node = try self.allocator.create(Node); + node.* = Node.init(key, parent); + parent.left = node; + self.rebalance(parent); + break; + } + } else { + if (n.right) |right| { + n = right; + } else { + const node = try self.allocator.create(Node); + node.* = Node.init(key, parent); + parent.right = node; + self.rebalance(parent); + break; + } + } + } + } + + return true; + } + + fn deleteKey(self: *Self, delKey: T) void { + if (self.root == null) + return; + + var n = self.root.?; + var parent = self.root.?; + var delNode: ?*Node = null; + var child: ?*Node = self.root; + + while (child != null) { + parent = n; + n = child.?; + child = if (delKey >= n.key) n.right else n.left; + if (delKey == n.key) + delNode = n; + } + + if (delNode) |node| { + node.key = n.key; + + child = if (n.left != null) n.left else n.right; + + if (self.root.?.key == delKey) { + self.root = child; + } else { + if (parent.left == n) { + parent.left = child; + } else { + parent.right = child; + } + + self.rebalance(parent); + } + } + } + + fn printBalance(self: *Self, n: ?*Node) !void { + if (n != null) { + try self.printBalance(n.?.left); + try stdout.print("{} ", .{n.?.balance}); + try self.printBalance(n.?.right); + } + } + + fn printBalanceRoot(self: *Self) !void { + try self.printBalance(self.root); + try stdout.print("\n", .{}); + } + }; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + var t = AVLtree(i32).init(allocator); + defer t.deinit(); + + try stdout.print("Inserting integer values 1 to 10\n", .{}); + var i: i32 = 1; + while (i <= 10) : (i += 1) { + _ = try t.insert(i); + } + + try stdout.print("Printing balance: ", .{}); + try t.printBalanceRoot(); +} diff --git a/Task/Abbreviations-easy/ArkScript/abbreviations-easy.ark b/Task/Abbreviations-easy/ArkScript/abbreviations-easy.ark new file mode 100644 index 0000000000..da2282ce34 --- /dev/null +++ b/Task/Abbreviations-easy/ArkScript/abbreviations-easy.ark @@ -0,0 +1,54 @@ +(let commands "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up") + +(let user_words "riG rePEAT copies put mo rest types fup. 6 poweRin") + +(import std.List) +(import std.String) + +(let abbrev_length (fun (word) + (len + (list:takeWhile + word + (fun (char) { + (let ord (string:ord char)) + (and (<= 65 ord) (<= ord 90)) }))))) + +(let extract_cmds (fun (text) + (list:filter (string:split text " ") (fun (elem) (not (empty? elem)))))) + +(let cmds_with_abbrev_len + (list:map + (extract_cmds commands) + (fun (cmd) + [cmd (abbrev_length cmd)] ))) + +(let find_abbrev (fun (word) { + (let wlen (len word)) + (let lower (string:toLower word)) + + (list:map + (list:filter + cmds_with_abbrev_len + (fun (cmd_with_len) { + (let cmd (string:toLower (head cmd_with_len))) + (let min_len (@ cmd_with_len 1)) + + (and + (<= min_len wlen) + (<= wlen (len cmd)) + (= lower (string:slice cmd 0 wlen))) })) + (fun (cmd_with_len) (head cmd_with_len))) })) + +(let user_inputs (extract_cmds user_words)) + +(assert + (= + ["RIGHT" "REPEAT" "*error*" "PUT" "MOVE" "RESTORE" "*error*" "*error*" "*error*" "POWERINPUT"] + (list:map + user_inputs + (fun (str) { + (let abbrevs (find_abbrev str)) + (if (empty? abbrevs) + "*error*" + (string:toUpper (head abbrevs))) }))) + "commands were correctly deciphered") diff --git a/Task/Abbreviations-easy/PascalABC.NET/abbreviations-easy.pas b/Task/Abbreviations-easy/PascalABC.NET/abbreviations-easy.pas new file mode 100644 index 0000000000..cd4a089f62 --- /dev/null +++ b/Task/Abbreviations-easy/PascalABC.NET/abbreviations-easy.pas @@ -0,0 +1,26 @@ +begin + var commands := + ''' + Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy + COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find + NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput + Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO + MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT + READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT + RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up + '''.ToWords(AllDelimiters); + + var countDict := commands.Each(word -> word.TakeWhile(c -> c.IsUpper).Count); + + var correctedLine := 'riG rePEAT copies put mo rest types fup. 6 poweRin' + .ToWords + .Select(word -> + commands.FirstOrDefault( + cmd -> cmd.ToLower.StartsWith(word.ToLower) and + (word.Length >= countDict[cmd]) + )?.ToUpper ?? '*error*' + ) + .JoinToString; + + Print(correctedLine); +end. diff --git a/Task/Abbreviations-simple/PascalABC.NET/abbreviations-simple.pas b/Task/Abbreviations-simple/PascalABC.NET/abbreviations-simple.pas new file mode 100644 index 0000000000..db47a4c235 --- /dev/null +++ b/Task/Abbreviations-simple/PascalABC.NET/abbreviations-simple.pas @@ -0,0 +1,51 @@ +{$zerobasedstrings on} + +begin + var commandData := + ''' + add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 + compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate + 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 + forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load + locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2 + msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3 + refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left + 2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1 + '''.ToWords(AllDelimiters); + + var abbrDict := Dict('' to ''); + + var i := 0; + while i < commandData.Length do + begin + var cmd := commandData[i]; + i += 1; + + // Если следующего элемента нет или он не число, используем длину команды + var minLen := cmd.Length; + if (i < commandData.Length) and commandData[i].All(char.IsDigit) then + begin + minLen := commandData[i].ToInteger; + i += 1; + end; + + var cmdLower := cmd.ToLower; + for var len := minLen to cmd.Length do + begin + var abbr := cmdLower[:len]; + abbrDict[abbr] := cmd.ToUpper; + end; + end; + + var testStr := 'riG rePEAT copies put mo rest types fup. 6 poweRin'; + Writeln(' Input: ', testStr); + Writeln('Output: ', testStr.ToWords() + .Select(w -> abbrDict.Get(w.Trim.ToLower,'*error*')) + .JoinToString); + + testStr := ''; + Writeln(' Input: ', testStr); + Writeln('Output: ', testStr.ToWords() + .Select(w -> abbrDict.Get(w.Trim.ToLower,'*error*')) + .JoinToString); +end. diff --git a/Task/Abelian-sandpile-model-Identity/Pluto/abelian-sandpile-model-identity.pluto b/Task/Abelian-sandpile-model-Identity/Pluto/abelian-sandpile-model-identity.pluto new file mode 100644 index 0000000000..867e535547 --- /dev/null +++ b/Task/Abelian-sandpile-model-Identity/Pluto/abelian-sandpile-model-identity.pluto @@ -0,0 +1,79 @@ +class Sandpile + -- 'a' is a list of 9 integers in row order. + function __construct(public a) + self.neighbors = { + {2, 4}, {1, 3, 5}, {2, 6}, {1, 5, 7}, {2, 4, 6, 8}, + {3, 5, 9}, {4, 8}, {5, 7, 9}, {6, 8} + } + end + + function __add(other) + local b = {} + for i = 1, 9 do + b:insert(self.a[i] + other.a[i]) + end + return new Sandpile(b) + end + + function is_stable() + return self.a:checkall(|i| -> i <= 3) + end + + -- Just topples once so we can observe intermediate results. + function topple() + for i = 1, 9 do + if self.a[i] > 3 then + self.a[i] -= 4 + for self.neighbors[i] as j do ++self.a[j] end + return + end + end + end + + function to_string() + local s = "" + for i = 1, 3 do + for j = 1, 3 do s ..= $"{self.a[3*(i - 1) + j]} " end + s ..= "\n" + end + return s + end +end + +print("Avalanche of topplings:\n") +local s0 = new Sandpile({4, 3, 3, 3, 1, 2, 0, 2, 3}) +print(s0:to_string()) +while !s0:is_stable() do + s0:topple() + print(s0:to_string()) +end + +print("Commutative additions:\n") +local s1 = new Sandpile({1, 2, 0, 2, 1, 1, 0, 1, 3}) +local s2 = new Sandpile({2, 1, 3, 1, 0, 1, 0, 1, 0}) +local s3_a = s1 + s2 +while !s3_a:is_stable() do s3_a:topple() end +local s3_b = s2 + s1 +while !s3_b:is_stable() do s3_b:topple() end +local s1s = s1:to_string() +local s2s = s2:to_string() +local s3_as = s3_a:to_string() +local s3_bs = s3_b:to_string() +print(string.format("%s\nplus\n\n%s\nequals\n\n%s", s1s, s2s, s3_as)) +print(string.format("and\n\n%s\nplus\n\n%s\nalso equals\n\n%s", s2s, s1s, s3_bs)) + +print("Addition of identity sandpile:\n") +local s3 = new Sandpile({3, 3, 3, 3, 3, 3, 3, 3, 3}) +local s3_id = new Sandpile({2, 1, 2, 1, 0, 1, 2, 1, 2}) +local s4 = s3 + s3_id +while !s4:is_stable() do s4:topple() end +local s3s = s3:to_string() +local s3_ids = s3_id:to_string() +local s4s = s4:to_string() +print(string.format("%s\nplus\n\n%s\nequals\n\n%s", s3s, s3_ids, s4s)) + +print("Addition of identities:\n") +local s5 = s3_id + s3_id +while !s5:is_stable() do s5:topple() end +local s5s = s5:to_string() +print(string.format("%s\nplus\n\n%s\nequals\n\n%s", s3_ids, s3_ids, s5s)) diff --git a/Task/Abelian-sandpile-model-Identity/Zig/abelian-sandpile-model-identity.zig b/Task/Abelian-sandpile-model-Identity/Zig/abelian-sandpile-model-identity.zig new file mode 100644 index 0000000000..e889527ece --- /dev/null +++ b/Task/Abelian-sandpile-model-Identity/Zig/abelian-sandpile-model-identity.zig @@ -0,0 +1,126 @@ +const std = @import("std"); + +const Box = struct { + piles: [3][3]u8, + + fn init(piles: [3][3]u8) Box { + var a = Box{ .piles = piles }; + + for (a.piles) |row| { + for (row) |pile| { + if (pile >= 4) { + return a.avalanche(); + } + } + } + return a; + } + + fn avalanche(self: *const Box) Box { + var a = self.*; + for (self.piles, 0..) |row, i| { + for (row, 0..) |pile, j| { + if (pile >= 4) { + if (i > 0) { + a.piles[i - 1][j] += 1; + } + if (i < 2) { + a.piles[i + 1][j] += 1; + } + if (j > 0) { + a.piles[i][j - 1] += 1; + } + if (j < 2) { + a.piles[i][j + 1] += 1; + } + a.piles[i][j] -= 4; + } + } + } + return Box.init(a.piles); + } + + fn add(self: *const Box, other: *const Box) Box { + var b = Box{ + .piles = [_][3]u8{[_]u8{0} ** 3} ** 3, + }; + for (0..3) |row| { + for (0..3) |col| { + b.piles[row][col] = self.piles[row][col] + other.piles[row][col]; + } + } + return Box.init(b.piles); + } +}; + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + + try stdout.print("The piles demonstration avalanche starts as:\n{any}\n{any}\n{any}\n", .{ + [_]u8{ 4, 3, 3 }, + [_]u8{ 3, 1, 2 }, + [_]u8{ 0, 2, 3 }, + }); + + const s0 = Box.init([_][3]u8{ + [_]u8{ 4, 3, 3 }, + [_]u8{ 3, 1, 2 }, + [_]u8{ 0, 2, 3 }, + }); + + try stdout.print("And ends as:\n{any}\n{any}\n{any}\n", .{ + s0.piles[0], + s0.piles[1], + s0.piles[2], + }); + + const s1 = Box.init([_][3]u8{ + [_]u8{ 1, 2, 0 }, + [_]u8{ 2, 1, 1 }, + [_]u8{ 0, 1, 3 }, + }); + + const s2 = Box.init([_][3]u8{ + [_]u8{ 2, 1, 3 }, + [_]u8{ 1, 0, 1 }, + [_]u8{ 0, 1, 0 }, + }); + + const s1_2 = s1.add(&s2); + const s2_1 = s2.add(&s1); + + try stdout.print("The piles in s1 + s2 are:\n{any}\n{any}\n{any}\n", .{ + s1_2.piles[0], + s1_2.piles[1], + s1_2.piles[2], + }); + + try stdout.print("The piles in s2 + s1 are:\n{any}\n{any}\n{any}\n", .{ + s2_1.piles[0], + s2_1.piles[1], + s2_1.piles[2], + }); + + const s3 = Box.init([_][3]u8{[_]u8{3} ** 3} ** 3); + const s3_id = Box.init([_][3]u8{ + [_]u8{ 2, 1, 2 }, + [_]u8{ 1, 0, 1 }, + [_]u8{ 2, 1, 2 }, + }); + + const s4 = s3.add(&s3_id); + + try stdout.print("The piles in s3 + s3_id are:\n{any}\n{any}\n{any}\n", .{ + s4.piles[0], + s4.piles[1], + s4.piles[2], + }); + + const s5 = s3_id.add(&s3_id); + + try stdout.print("The piles in s3_id + s3_id are:\n{any}\n{any}\n{any}\n", .{ + s5.piles[0], + s5.piles[1], + s5.piles[2], + }); +} diff --git a/Task/Abelian-sandpile-model/Julia/abelian-sandpile-model.jl b/Task/Abelian-sandpile-model/Julia/abelian-sandpile-model.jl index fc19b42b8a..35866a7ca1 100644 --- a/Task/Abelian-sandpile-model/Julia/abelian-sandpile-model.jl +++ b/Task/Abelian-sandpile-model/Julia/abelian-sandpile-model.jl @@ -1,24 +1,25 @@ -module AbelSand +""" From code by Hayk Aleksanyan, see also github.com/hayk314/Sandpiles """ -# supports output functionality for the results of the sandpile simulations -# outputs the final grid in CSV format, as well as an image file +""" supports output functionality for the results of the sandpile simulations + outputs the final grid in CSV format, as well as an image file +""" +module AbelSand using CSV, DataFrames, Images -function TrimZeros(A) - # given an array A trims any zero rows/columns from its borders - # returns a 4 tuple of integers, i1, i2, j1, j2, where the trimmed array corresponds to A[i1:i2, j1:j2] - # A can be either numeric or a boolean array - +""" given an array A trims any zero rows/columns from its borders + returns a 4 tuple of integers, i1, i2, j1, j2, where the trimmed array corresponds to A[i1:i2, j1:j2] + A can be either numeric or a boolean array +""" +function trimzeros(A) i1, j1 = 1, 1 i2, j2 = size(A) - zz = typeof(A[1, 1])(0) # comparison of a value takes into account the type as well # i1 is the first row which has non zero element - for i = 1:size(A, 1) + for i in axes(A, 1) q = false - for k = 1:size(A, 2) + for k in axes(A, 2) if A[i, k] != zz q = true i1 = i @@ -32,26 +33,24 @@ function TrimZeros(A) end # i2 is the first from below row with non zero element - for i in size(A, 1):-1:1 + for i in reverse(axes(A, 1)) q = false - for k = 1:size(A, 2) + for k in axes(A, 2) if A[i, k] != zz q = true i2 = i break end end - if q == true break end end # j1 is the first column with non zero element - - for j = 1:size(A, 2) + for j in axes(A, 2) q = false - for k = 1:size(A, 1) + for k in axes(A, 1) if A[k, j] != zz j1 = j q = true @@ -65,18 +64,17 @@ function TrimZeros(A) end # j2 is the last column with non zero element - - for j in size(A, 2):-1:1 - q=false - for k=1:size(A,1) + for j in reverse(axes(A, 2)) + q = false + for k in axes(A, 1) if A[k, j] != zz j2 = j - q=true + q = true break end end - if q==true + if q == true break end end @@ -84,129 +82,124 @@ function TrimZeros(A) return i1, i2, j1, j2 end -function addLayerofZeros(A, extraLayer) - # adds layer of zeros from all corners to the given array A - - if extraLayer <= 0 - return A - end +""" adds layer of zeros from all corners to the given array A """ +function addlayerofzeros!(A, extraLayer) + extraLayer <= 0 && return A N, M = size(A) - - - Z = zeros( typeof(A[1,1]), N + 2*extraLayer, M + 2*extraLayer) - Z[(extraLayer+1):(N + extraLayer ), (extraLayer+1):(M+extraLayer)] = A + Z = zeros(typeof(A[1, 1]), N + 2 * extraLayer, M + 2 * extraLayer) + Z[(extraLayer+1):(N+extraLayer), (extraLayer+1):(M+extraLayer)] = A return Z - end -function printIntoFile(A, extraLayer, strFileName, TrimSmallValues = false) - # exports a 2d matrix A into a csv file - # @extraLayer is an integers adding layer of 0-s sorrounding the output matrix - - # trimming off very small values; tiny values affect the performance of CSV export +""" exports a 2d matrix A into a csv file, adjusting the size of the output matrix + @extraLayer is an integers adding layer of 0-s sorrounding the output matrix + trimming off very small values; tiny values affect the performance of CSV export +""" +function outputCSV!(A, extraLayer, strFileName, TrimSmallValues = false) if TrimSmallValues == true - A = map(x -> if (abs(x - floor(x)) < 0.01) floor(x) else x end, A) + A = map(x -> if (abs(x - floor(x)) < 0.01) + floor(x) + else + x + end, A) end - i1, i2, j1, j2 = TrimZeros( A ) + i1, i2, j1, j2 = trimzeros(A) A = A[i1:i2, j1:j2] - - A = addLayerofZeros(A, extraLayer) - - CSV.write(string(strFileName,".csv"), DataFrame(A), writeheader = false) + A = addlayerofzeros!(A, extraLayer) + CSV.write(string(strFileName, ".csv"), DataFrame(A, :auto), writeheader = false) return A - end -function Array_magnifier(A, cell_mag, border_mag) - # A is the main array; @cell_mag is the magnifying size of the cell, - # @border_mag is the magnifying size of the border between lattice cells - - # creates a new array where each cell of the original array A appears magnified by size = cell_mag - - +""" creates a new array A1 where each cell of the original array A appears magnified by size @cell_mag + A is the input array; @cell_mag is the magnifying size of the cell, + @border_mag is the magnifying size of the border between lattice cells +""" +function arraymagnifier(A, cell_mag, border_mag) total_factor = cell_mag + border_mag + A1 = zeros(typeof(A[1, 1]), total_factor * size(A, 1), total_factor * size(A, 2)) + for i ∈ axes(A, 1), j ∈ axes(A, 2), u ∈ ((i-1)*total_factor+1):(i*total_factor), + v ∈ ((j-1)*total_factor+1):(j*total_factor) - A1 = zeros(typeof(A[1, 1]), total_factor*size(A, 1), total_factor*size(A, 2)) - - for i = 1:size(A,1), j = 1:size(A,2), u = ((i-1)*total_factor+1):(i*total_factor), - v = ((j-1)*total_factor+1):(j*total_factor) - if(( u - (i - 1) * total_factor <= cell_mag) && (v - (j - 1) * total_factor <= cell_mag)) + if ((u - (i - 1) * total_factor <= cell_mag) && (v - (j - 1) * total_factor <= cell_mag)) A1[u, v] = A[i, j] end end return A1 - end -function saveAsGrayImage(A, fileName, cell_mag, border_mag, TrimSmallValues = false) - # given a 2d matrix A, we save it as a gray image after magnifying by the given factors - A1 = Array_magnifier(A, cell_mag, border_mag) - A1 = A1/maximum(maximum(A1)) +""" given a 2d matrix A, we save it as a gray image after magnifying by the given factors """ +function savegrayimage(A, fileName, cell_mag, border_mag, TrimSmallValues = false) + A1 = arraymagnifier(A, cell_mag, border_mag) + A1 = A1 / maximum(maximum(A1)) # trimming very small values from A1 to improve performance if TrimSmallValues == true - A1 = map(x -> if ( x < 0.01) 0.0 else round(x, digits = 2) end, A1) + A1 = map(x -> if (x < 0.01) + 0.0 + else + round(x, digits = 2) + end, A1) end - save(string(fileName, ".png") , colorview(Gray, A1)) + save(string(fileName, ".png"), colorview(Gray, A1)) end -function saveAsRGBImage(A, fileName, color_codes, cell_mag, border_mag) - # color_codes is a dictionary, where key is a value in A and value is an RGB triplet - # given a 2d array A, and color codes (mapping from values in A to RGB triples), save A - # into fileName as png image after applying the magnifying factors - - A1 = Array_magnifier(A, cell_mag, border_mag) +""" color_codes is a dictionary, where key is a value in A and value is an RGB triplet + given a 2d array A, and color codes (mapping from values in A to RGB triples), save A + into fileName as png image after applying the magnifying factors +""" +function saveRGBimage(A, fileName, color_codes, cell_mag, border_mag) + A1 = arraymagnifier(A, cell_mag, border_mag) color_mat = zeros(UInt8, (3, size(A1, 1), size(A1, 2))) - for i = 1:size(A1,1) - for j = 1:size(A1,2) - color_mat[:, i, j] = get(color_codes, A1[i, j] , [0, 0, 0]) + for i in axes(A1, 1) + for j in axes(A1, 2) + color_mat[:, i, j] = get(color_codes, A1[i, j], [0, 0, 0]) end end - save(string(fileName, ".png") , colorview(RGB, color_mat/255)) + save(string(fileName, ".png"), colorview(RGB, color_mat / 255)) end const N_size = 700 # the radius of the lattice Z^2, the actual size becomes (2*N+1)x(2*N+1) const dx = [1, 0, -1, 0] # for a given (x,y) in Z^2, (x + dx, y + dy) for all (dx,dy) covers the neighborhood of (x,y) const dy = [0, 1, 0, -1] +""" represents a 2D lattice coordinate """ struct L_coord - # represents a lattice coordinate x::Int y::Int end -function FindCoordinate(Z::Array{L_coord,1}, a::Int, b::Int) - # in the given array Z of coordinates finds the (first) index of the tuple (a,b) - # if no match, returns -1 - - for i=1:length(Z) +""" Finds the (first) index of the tuple (a,b) in the given array Z of coordinates + if no match, returns -1 +""" +function findcoordinate(Z::Array{L_coord, 1}, a::Int, b::Int) + for i ∈ 1:length(Z) if (Z[i].x == a) && (Z[i].y == b) return i end end - return -1 end -function move(N) - # the main function moving the pile sand grains of size N at the origin of Z^2 until the sandpile becomes stable - +""" Moves the pile's sand grains of size N stacked all at the origin of Z^2 + until the sandpile settled to stable configuration. + Returns the final lattice Z_lat and the odometer Odometer +""" +function settle(N) Z_lat = zeros(UInt8, 2 * N_size + 1, 2 * N_size + 1) # models the integer lattice Z^2, we will have at most 4 sands on each vertex V_sites = falses(2 * N_size + 1, 2 * N_size + 1) # all sites which are visited by the sandpile process, are being marked here Odometer = zeros(UInt64, 2 * N_size + 1, 2 * N_size + 1) # stores the values of the odometer function - walking = L_coord[] # the coordinates of sites which need to move - V_sites[N_size + 1, N_size + 1] = true + V_sites[N_size+1, N_size+1] = true # i1, ... j2 -> show the boundaries of the box which is visited by the sandpile process i1, i2, j1, j2 = N_size + 1, N_size + 1, N_size + 1, N_size + 1 @@ -217,12 +210,12 @@ function move(N) while n > 0 n -= 1 - Z_lat[N_size + 1, N_size + 1] += 1 - if (Z_lat[N_size + 1, N_size + 1] >= 4) + Z_lat[N_size+1, N_size+1] += 1 + if (Z_lat[N_size+1, N_size+1] >= 4) push!(walking, L_coord(N_size + 1, N_size + 1)) end - while(length(walking) > 0) + while (length(walking) > 0) w = pop!(walking) x = w.x y = w.y @@ -230,12 +223,12 @@ function move(N) Z_lat[x, y] -= 4 Odometer[x, y] += 4 - for k = 1:4 - Z_lat[x + dx[k], y + dy[k]] += 1 - V_sites[x + dx[k], y + dy[k]] = true - if Z_lat[x + dx[k], y + dy[k]] >= 4 - if FindCoordinate(walking, x + dx[k] , y + dy[k]) == -1 - push!(walking, L_coord( x + dx[k], y + dy[k])) + for k ∈ 1:4 + Z_lat[x+dx[k], y+dy[k]] += 1 + V_sites[x+dx[k], y+dy[k]] = true + if Z_lat[x+dx[k], y+dy[k]] >= 4 + if findcoordinate(walking, x + dx[k], y + dy[k]) == -1 + push!(walking, L_coord(x + dx[k], y + dy[k])) end end end @@ -247,29 +240,24 @@ function move(N) end - end #end of the main while + end # of the outer while t2 = time_ns() - println("The final boundaries are:: ", (i2 - i1 + 1),"x",(j2 - j1 + 1), "\n") - print("time elapsed: " , (t2 - t1) / 1.0e9, "\n") + println("The final boundaries are:: ", (i2 - i1 + 1), "x", (j2 - j1 + 1), "\n") + print("time elapsed: ", (t2 - t1) / 1.0e9, "\n") - Z_lat = printIntoFile(Z_lat, 0, string("Abel_Z_", N)) - Odometer = printIntoFile(Odometer, 1, string("Abel_OD_", N)) + Z_lat = outputCSV!(Z_lat, 0, string("Abel_Z_", N)) + Odometer = outputCSV!(Odometer, 1, string("Abel_OD_", N)) - saveAsGrayImage(Z_lat, string("Abel_Z_", N), 20, 0) - color_code = Dict(1=>[255, 128, 255], 2=>[255, 0, 0],3 => [0, 128, 255]) - saveAsRGBImage(Z_lat, string("Abel_Z_color_", N), color_code, 20, 0) + savegrayimage(Z_lat, string("Abel_Z_", N), 20, 0) + color_code = Dict(1 => [255, 128, 255], 2 => [255, 0, 0], 3 => [0, 128, 255]) + saveRGBimage(Z_lat, string("Abel_Z_color_", N), color_code, 20, 0) - # for the total elapsed time, it's better to use the @time macros on the main call - - return Z_lat, Odometer # these are trimmed in output module - -end # end of function move - - -end # module + return Z_lat, Odometer +end +end # of the module using .AbelSand -Z_lat, Odometer = AbelSand.move(100000) +Z_lat, Odometer = AbelSand.settle(100000) diff --git a/Task/Abelian-sandpile-model/Pluto/abelian-sandpile-model.pluto b/Task/Abelian-sandpile-model/Pluto/abelian-sandpile-model.pluto new file mode 100644 index 0000000000..0a161fb42c --- /dev/null +++ b/Task/Abelian-sandpile-model/Pluto/abelian-sandpile-model.pluto @@ -0,0 +1,80 @@ +class Sandpile + -- 'a' is a list of integers in row order. + function __construct(a) + local count = #a + self.rows = math.floor(math.sqrt(count)) + if self.rows * self.rows != count then + print("The matrix of values must be square.") + os.exit(1) + end + self.a = a + self.neighbors = {} + for i = 1, count do + self.neighbors[i] = {} + if (i - 1) % self.rows > 0 then self.neighbors[i]:insert(i - 1) end + if i % self.rows > 0 then self.neighbors[i]:insert(i + 1) end + if i - self.rows >= 1 then self.neighbors[i]:insert(i - self.rows) end + if i + self.rows < count + 1 then self.neighbors[i]:insert(i + self.rows) end + end + end + + function is_stable() + return self.a:checkall(|i| -> i <= 3) + end + + -- Topples until stable. + function topple() + while !self:is_stable() do + for i = 1, #self.a do + if self.a[i] > 3 then + self.a[i] -= 4 + for self.neighbors[i] as j do ++self.a[j] end + end + end + end + end + + function to_string() + local s = "" + for i = 1, self.rows do + for j = 1, self.rows do + s ..= string.format("%2d ", self.a[self.rows * (i - 1) + j]) + end + s ..="\n" + end + return s + end +end + +local function print_across(str1, str2) + local r1 = str1:split("\n") + local r2 = str2:split("\n") + local rows = #r1 - 1 + local cr = rows // 2 + 1 + for i = 1, rows do + local symbol = (i == cr) ? "->" : " " + print(string.format("%s %s %s", r1[i], symbol, r2[i])) + end + print() +end + +local a1, a2, a3, a4 = {}, {}, {}, {} +for i = 1, 25 do + a1[i] = 0 + a2[i] = 0 + a3[i] = 0 +end +for i = 1, 100 do + a4[i] = 0 +end +a1[13] = 4 +a2[13] = 6 +a3[13] = 16 +a4[56] = 64 +for {a1, a2, a3, a4} as a do + local s = new Sandpile(a) + local str1 = s:to_string() + s:topple() + local str2 = s:to_string() + print_across(str1, str2) +end diff --git a/Task/Abelian-sandpile-model/Zig/abelian-sandpile-model.zig b/Task/Abelian-sandpile-model/Zig/abelian-sandpile-model.zig new file mode 100644 index 0000000000..e930714042 --- /dev/null +++ b/Task/Abelian-sandpile-model/Zig/abelian-sandpile-model.zig @@ -0,0 +1,136 @@ +const std = @import("std"); + +/// It loops over the current state of the sandpile and updates it on-the-fly. +fn advance(field: [][]usize, boundary: *[4]usize) bool { + // This variable is used to check whether we changed anything in the array. If no, the loop terminates. + var done = false; + + var y = boundary[0]; + while (y < boundary[2]) : (y += 1) { + var x = boundary[1]; + while (x < boundary[3]) : (x += 1) { + if (field[y][x] >= 4) { + // This part was heavily inspired by the Pascal version. We subtract 4 as many times as we can + // and distribute it to the neighbors. Also, in case we have outgrown the current boundary, we + // update it to once again contain the entire sandpile. + + // The amount that gets added to the neighbors is the amount here divided by four and (implicitly) floored. + // The remaining sand is just current modulo 4. + const rem: usize = field[y][x] / 4; + field[y][x] = field[y][x] % 4; + + if (y > 0) { + field[y - 1][x] += rem; + if (y == boundary[0]) { + boundary[0] -= 1; + } + } + if (x > 0) { + field[y][x - 1] += rem; + if (x == boundary[1]) { + boundary[1] -= 1; + } + } + if (y + 1 < field.len) { + field[y + 1][x] += rem; + if (y == boundary[2] - 1) { + boundary[2] += 1; + } + } + if (x + 1 < field.len) { + field[y][x + 1] += rem; + if (x == boundary[3] - 1) { + boundary[3] += 1; + } + } + + done = true; + } + } + } + + return done; +} + +/// This function can be used to display the sandpile in the console window. +fn display(field: [][]usize) void { + for (field) |row| { + for (row) |cell| { + const c: u8 = switch (cell) { + 0 => ' ', + 1 => '.', + 2 => 'o', + 3 => 'O', + else => '#', + }; + std.debug.print("{c}", .{c}); + } + std.debug.print("\n", .{}); + } +} + +/// This function writes the end result to a file called "output.ppm". +fn write_pile(pile: [][]usize, allocator: std.mem.Allocator) !void { + // We first create the file (or erase its contents if it already existed). + const file = try std.fs.cwd().createFile("output.ppm", .{}); + defer file.close(); + + // Then we add the image signature, which is "P3 [width of image] [height of image][maximum value of color]". + try std.fmt.format(file.writer(), "P3\n{d} {d}\n255\n", .{ pile.len, pile.len }); + + for (pile) |row| { + var line = std.ArrayList(u8).init(allocator); + defer line.deinit(); + + // We map each value in the field to a color. + for (row) |elem| { + const color = switch (elem) { + 0 => "100 40 15 ", + 1 => "117 87 30 ", + 2 => "181 134 47 ", + 3 => "245 182 66 ", + else => unreachable, + }; + try line.appendSlice(color); + } + + try std.fmt.format(file.writer(), "{s}\n", .{line.items}); + } +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + // This is how big the final image will be. Currently the end result would be a 16x16 picture. + const field_size: usize = 16; + + // Create the 2D array + var playfield = try allocator.alloc([]usize, field_size); + defer { + for (playfield) |row| { + allocator.free(row); + } + allocator.free(playfield); + } + + for (playfield, 0..) |_, i| { + playfield[i] = try allocator.alloc(usize, field_size); + @memset(playfield[i], 0); + } + + // We put the initial sand in the exact middle of the field. + // This isn't necessary per se, but it ensures that sand can fully topple. + var boundary = [4]usize{ field_size / 2 - 1, field_size / 2 - 1, field_size / 2, field_size / 2 }; + playfield[field_size / 2 - 1][field_size / 2 - 1] = 16; + + // This is the main loop. We update the field until it returns false, signalling that the pile reached its + // final state. + while (advance(playfield, &boundary)) {} + + // Once this happens, we simply display the result. Uncomment the line below to write it to a file. + // Calling display with large field sizes is not recommended as it can easily become too large for the console. + display(playfield); + // try write_pile(playfield, allocator); +} diff --git a/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-1.pas b/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-1.pas new file mode 100644 index 0000000000..503c7d46f7 --- /dev/null +++ b/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-1.pas @@ -0,0 +1,60 @@ +program abstracts; +// this code also compiles in delphi +{$ifdef fpc}{$mode objfpc}{$endif} +type + // Pure Abstract Class. In cs theory also known as an interface, + // because it has no implementation + TAbstractClass = class abstract + protected + function noise:string;virtual;abstract; + end; + // classic inheritance + Tdog = class(TAbstractClass) + public + function noise:string;override; + end; + + Tcat = class(TAbstractClass) + public + function noise:string;override; + end; + + // unrelated class that matches the interface of TAbstractClass, the VMT. + Tbird = class + strict private + FField:string; + function noise:string;virtual; + property field:string read FField write FField; + end; + + function Tdog.Noise:string; + begin + Result := 'Woof'; + end; + + function Tcat.Noise:string; + begin + Result := 'Miauw'; + end; + + function TBird.Noise:string; + begin + Result := 'Tjirpp'; + end; + +var + cat, dog: TAbstractClass; + bird:Tbird; +begin + cat := Tcat.Create; + dog := Tdog.Create; + bird := TBird.Create; + writeln(cat.noise,dog.noise); + // even this works, because the layout is the same + // This is similar to C++, where pure abstract classes are interfaces. + writeln(TAbstractClass(bird).noise); + bird.free; + dog.free; + cat.free; + readln; +end. diff --git a/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-2.pas b/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-2.pas new file mode 100644 index 0000000000..255d8ba86d --- /dev/null +++ b/Task/Abstract-type/Free-Pascal-Lazarus/abstract-type-2.pas @@ -0,0 +1,32 @@ +program justasabstract; +{$ifdef fpc}{$mode objfpc}{$endif} +type + IAnimalInterface = interface + ['{BD40E312-36AD-4F8B-A3EF-727F2474E494}'] + function noise:string; + function move:string; + end; + + Tbird = class(TInterfacedObject,IAnimalInterface) + strict private + function noise:string;virtual; + function move:string;virtual; + end; + + function TBird.Noise:string; + begin + Result := 'Tjirpp'; + end; + + function TBird.move:string; + begin + Result := 'I fly'; + end; + +var + bird:IAnimalInterface; // as interface, this unhides the strict private methods too. +begin + bird := TBird.Create; + writeln(bird.noise); + writeln(bird.move); +end. diff --git a/Task/Abstract-type/Haxe/abstract-type-1.haxe b/Task/Abstract-type/Haxe/abstract-type-1.haxe new file mode 100644 index 0000000000..91134488e5 --- /dev/null +++ b/Task/Abstract-type/Haxe/abstract-type-1.haxe @@ -0,0 +1,44 @@ +interface Vocal { + public function speak():String; +} + +interface Gravitational { + public function getWeight():Int; +} + +abstract class Dog implements Vocal implements Gravitational { + public function speak():String { + return "Woof"; + } + + public function new() {} +} + +class Chihuahua extends Dog { + public function getWeight():Int { + return 5; + } +} + +class GreatDane extends Dog { + public function getWeight():Int { + return 150; + } +} + +class Main { + static public function main():Void { + var dogs:Array = []; + + var david = new Chihuahua(); + var goliath = new GreatDane(); + + dogs.push(david); + dogs.push(goliath); + + for (dog in dogs) { + trace(dog.speak()); + trace(dog.getWeight()); + } + } +} diff --git a/Task/Abstract-type/Haskell/abstract-type-6.hs b/Task/Abstract-type/Haxe/abstract-type-2.haxe similarity index 100% rename from Task/Abstract-type/Haskell/abstract-type-6.hs rename to Task/Abstract-type/Haxe/abstract-type-2.haxe diff --git a/Task/Abstract-type/Pluto/abstract-type.pluto b/Task/Abstract-type/Pluto/abstract-type.pluto new file mode 100644 index 0000000000..23e2c80efd --- /dev/null +++ b/Task/Abstract-type/Pluto/abstract-type.pluto @@ -0,0 +1,34 @@ +class Beast + function __construct() + error("Instantiation not allowed as class is abstract.") + end + + function kind() end + function name() end + function cry() end + + function print() + print($'{self:name()}, who\'s a {self:kind()}, cries: "{self:cry()}".') + end +end + +class Dog extends Beast + function __construct(private kind, private name) end + + function kind() return self.kind end + function name() return self.name end + function cry() return "Woof" end +end + +class Cat extends Beast + function __construct(private kind, private name) end + + function kind() return self.kind end + function name() return self.name end + function cry() return "Meow" end +end + +local d = new Dog("labrador", "Max") +local c = new Cat("siamese", "Sammy") +d:print() +c:print() diff --git a/Task/Abstract-type/REBOL/abstract-type.rebol b/Task/Abstract-type/REBOL/abstract-type.rebol index 353bba0dd1..184d2223f1 100644 --- a/Task/Abstract-type/REBOL/abstract-type.rebol +++ b/Task/Abstract-type/REBOL/abstract-type.rebol @@ -40,5 +40,5 @@ s: make shape [] s/draw ; Nothing happens. print "A box:" b: make box [pen: "O" size: 5] b/draw -print [crlf "A rectangle:"] +print "^/A rectangle:" r: make rectangle [size: 32x5] r/draw diff --git a/Task/Abundant-deficient-and-perfect-number-classifications/Agena/abundant-deficient-and-perfect-number-classifications.agena b/Task/Abundant-deficient-and-perfect-number-classifications/Agena/abundant-deficient-and-perfect-number-classifications.agena new file mode 100644 index 0000000000..0e13d96df2 --- /dev/null +++ b/Task/Abundant-deficient-and-perfect-number-classifications/Agena/abundant-deficient-and-perfect-number-classifications.agena @@ -0,0 +1,21 @@ +scope # count abundant, perfect and deficient numbers up to 20 000 + # construct a table of proper divisor sums + local constant MAX_NUMBER, constant pds := 20_000, seq(); + pds[ 1 ] := 0; + for i from 2 to MAX_NUMBER do pds[ i ] := 1 od; + for i from 2 to MAX_NUMBER do + for j from i + i to MAX_NUMBER by i do pds[ j ] +:= i od; + od; + # classify the numbers and count each type + local aCount, dCount, pCount := 0, 0, 0; + for i to MAX_NUMBER do + local constant dSum := pds[ i ]; + if dSum > i then aCount +:= 1 + elif dSum < i then dCount +:= 1 + else pCount +:= 1 + fi + od; + printf( "Abundant numbers up to %.0m: %8.0m\n", MAX_NUMBER, aCount ); + printf( "Perfect numbers up to %.0m: %8.0m\n", MAX_NUMBER, pCount ); + printf( "Deficient numbers up to %.0m: %8.0m\n", MAX_NUMBER, dCount ) +end diff --git a/Task/Abundant-deficient-and-perfect-number-classifications/Fennel/abundant-deficient-and-perfect-number-classifications.fennel b/Task/Abundant-deficient-and-perfect-number-classifications/Fennel/abundant-deficient-and-perfect-number-classifications.fennel new file mode 100644 index 0000000000..04ca0eabc8 --- /dev/null +++ b/Task/Abundant-deficient-and-perfect-number-classifications/Fennel/abundant-deficient-and-perfect-number-classifications.fennel @@ -0,0 +1,21 @@ +(do ;;; count abundant, perfect and deficient numbers up to 20 000 + ; construct a table of proper divisor sums + (local (max-number pds) (values 20_000 [])) + (tset pds 1 0) + (for [i 2 max-number] (tset pds i 1)) + (for [i 2 max-number] + (for [j (+ i i) max-number i] (tset pds j (+ i (. pds j)))) + ) + ; classify the numbers and count each type + (var (aCount dCount pCount) (values 0 0 0)) + (for [i 1 max-number] + (local dSum (. pds i)) + (if (> dSum i) (set aCount (+ aCount 1)) + (< dSum i) (set dCount (+ dCount 1)) + (set pCount (+ pCount 1)) + ) + ) + (io.write (string.format "Abundant numbers up to %d: %8d\n" max-number aCount)) + (io.write (string.format "Perfect numbers up to %d: %8d\n" max-number pCount)) + (io.write (string.format "Deficient numbers up to %d: %8d\n" max-number dCount)) +) diff --git a/Task/Abundant-deficient-and-perfect-number-classifications/Pluto/abundant-deficient-and-perfect-number-classifications.pluto b/Task/Abundant-deficient-and-perfect-number-classifications/Pluto/abundant-deficient-and-perfect-number-classifications.pluto new file mode 100644 index 0000000000..31fc30e8c2 --- /dev/null +++ b/Task/Abundant-deficient-and-perfect-number-classifications/Pluto/abundant-deficient-and-perfect-number-classifications.pluto @@ -0,0 +1,26 @@ +do -- count abundant, perfect and deficient numbers up to 20 000 + + local fmt = require( "fmt" ) -- RC Pluto formatting library + + -- construct a table of proper divisor sums + local maxNumber , pds = 20_000, {} + pds[ 1 ] = 0 + for i = 2, maxNumber do pds[ i ] = 1 end + for i = 2, maxNumber do + for j = i + i, maxNumber, i do pds[ j ] += i end + end + + -- classify the numbers and count each type + local aCount, dCount, pCount = 0, 0, 0 + for i = 1, maxNumber do + local dSum = pds[ i ] + if dSum > i then aCount += 1 + elseif dSum < i then dCount += 1 + else pCount += 1 + end + end + local formattedMax = string.formatint( maxNumber ) + fmt.write( "Abundant numbers up to %s: %8s\n", formattedMax, string.formatint( aCount ) ) + fmt.write( "Perfect numbers up to %s: %8s\n", formattedMax, string.formatint( pCount ) ) + fmt.write( "Deficient numbers up to %s: %8s\n", formattedMax, string.formatint( dCount ) ) +end diff --git a/Task/Abundant-deficient-and-perfect-number-classifications/Prolog/abundant-deficient-and-perfect-number-classifications.pro b/Task/Abundant-deficient-and-perfect-number-classifications/Prolog/abundant-deficient-and-perfect-number-classifications.pro index b0a87e05b3..26bfe44194 100644 --- a/Task/Abundant-deficient-and-perfect-number-classifications/Prolog/abundant-deficient-and-perfect-number-classifications.pro +++ b/Task/Abundant-deficient-and-perfect-number-classifications/Prolog/abundant-deficient-and-perfect-number-classifications.pro @@ -3,18 +3,19 @@ proper_divisors(N, [1|L]) :- FSQRTN is floor(sqrt(N)), proper_divisors(2, FSQRTN, N, L). -proper_divisors(M, FSQRTN, _, []) :- - M > FSQRTN, - !. -proper_divisors(M, FSQRTN, N, L) :- - N mod M =:= 0, !, - MO is N//M, % must be integer - L = [M,MO|L1], % both proper divisors - M1 is M+1, - proper_divisors(M1, FSQRTN, N, L1). -proper_divisors(M, FSQRTN, N, L) :- - M1 is M+1, - proper_divisors(M1, FSQRTN, N, L). +proper_divisors(M, FSQRTN, N, [MS|L]) :- + between(M, FSQRTN, D1), + N mod D1 =:= 0, !, + D2 is N//D1, % must be integer + ( D1 < D2 + -> + MS is D1 + D2, % already sum here + M2 is D1 + 1, + proper_divisors(M2, FSQRTN, N, L) + ; + MS is D1, L = [] % D1 only once + ). +proper_divisors(_, _FSQRTN, _, []) :- !. dpa(1, [1], [], []) :- !. diff --git a/Task/Abundant-odd-numbers/ALGOL-68/abundant-odd-numbers.alg b/Task/Abundant-odd-numbers/ALGOL-68/abundant-odd-numbers.alg index 4bc494606d..cc24a232e3 100644 --- a/Task/Abundant-odd-numbers/ALGOL-68/abundant-odd-numbers.alg +++ b/Task/Abundant-odd-numbers/ALGOL-68/abundant-odd-numbers.alg @@ -1,7 +1,5 @@ -BEGIN - # find some abundant odd numbers - numbers where the sum of the proper # - # divisors is bigger than the number # - # itself # +BEGIN # find some abundant odd numbers - numbers wose the proper divisor sum # + # is bigger than the number itself # # returns the sum of the proper divisors of n # PROC divisor sum = ( INT n )INT: @@ -41,34 +39,20 @@ BEGIN # 1000th odd abundant number # WHILE a count < 1 000 DO IF ( d sum := divisor sum( odd number ) ) > odd number THEN - a count := a count + 1 + a count +:= 1 FI; odd number +:= 2 OD; - print( ( "1000th abundant odd number:" - , newline - , " " - , whole( odd number - 2, 0 ) - , " proper divisor sum: " - , whole( d sum, 0 ) - , newline - ) - ); + print( ( "1000th abundant odd number:", newline, " " ) ); + print( ( whole( odd number - 2, 0 ), " proper divisor sum: ", whole( d sum, 0 ), newline ) ); # first odd abundant number > one billion # odd number := 1 000 000 001; BOOL found := FALSE; WHILE NOT found DO IF ( d sum := divisor sum( odd number ) ) > odd number THEN found := TRUE; - print( ( "First abundant odd number > 1 000 000 000:" - , newline - , " " - , whole( odd number, 0 ) - , " proper divisor sum: " - , whole( d sum, 0 ) - , newline - ) - ) + print( ( "First abundant odd number > 1 000 000 000:", newline, " " ) ); + print( ( whole( odd number, 0 ), " proper divisor sum: ", whole( d sum, 0 ), newline ) ) FI; odd number +:= 2 OD diff --git a/Task/Abundant-odd-numbers/Agena/abundant-odd-numbers.agena b/Task/Abundant-odd-numbers/Agena/abundant-odd-numbers.agena new file mode 100644 index 0000000000..498c14b6a4 --- /dev/null +++ b/Task/Abundant-odd-numbers/Agena/abundant-odd-numbers.agena @@ -0,0 +1,52 @@ +scope # find some abundant snumbers + # - numbers whose proper divisor sum is bigger than the number itself + + # returns the sum of the proper divisors of n + local constant divisor_sum := proc( n :: number ) :: number is + local sum := 1; + for d from 2 to entier sqrt( n ) do + if n mod d = 0 then + sum +:= d; + other_d := n \ d; + if other_d <> d then + sum +:= other_d + fi + fi + od; + return sum + end; + scope # find the numbers required by the task + # first 25 odd abundant numbers + local odd_number, a_count, d_sum := 1, 0, 0; + print( "The first 25 abundant odd numbers:" ); + while a_count < 25 do + d_sum := divisor_sum( odd_number ); + if d_sum > odd_number then + a_count +:= 1; + printf( "%6d proper divisor sum: %d\n", odd_number, d_sum ); + fi; + odd_number +:= 2 + od; + # 1000th odd abundant number + while a_count < 1_000 do + d_sum := divisor_sum( odd_number ); + if d_sum > odd_number then + a_count +:= 1 + fi; + odd_number +:= 2 + od; + printf( "1000th abundant odd number:\n %d proper divisor sum: %d\n", odd_number, d_sum ); + # first odd abundant number > one billion + odd_number := 1_000_000_001; + local found := false; + while not found do + d_sum := divisor_sum( odd_number ); + if d_sum > odd_number then + found := true; + print( "First abundant odd_number > 1 000 000 000:" ); + printf( " %d proper divisor sum: %d\n", odd_number, d_sum ); + fi; + odd_number +:= 2 + od + end +end diff --git a/Task/Abundant-odd-numbers/Pluto/abundant-odd-numbers.pluto b/Task/Abundant-odd-numbers/Pluto/abundant-odd-numbers.pluto new file mode 100644 index 0000000000..2147c9f991 --- /dev/null +++ b/Task/Abundant-odd-numbers/Pluto/abundant-odd-numbers.pluto @@ -0,0 +1,35 @@ +local int = require "int" +local fmt = require "fmt" +require "table2" + +local function abundant_odd(search_from, count_from, count_to, print_one) + local count = count_from + local n = search_from + while count < count_to do + local divs = int.divisors(n, true) + local tot = #divs > 0 ? (divs:sum()) : 0 + if tot > n then + ++count + if !print_one or count >= count_to then + local s = fmt.swrite(divs, " + ", "") + if !print_one then + fmt.print("%2d. %5d < %s = %d", count, n, s, tot) + else + fmt.print("%d < %s = %d", n, s, tot) + end + end + end + n += 2 + end + return n +end + +local MAX = 25 +print($"The first {MAX} abundant odd numbers are:") +local n = abundant_odd(1, 0, 25, false) + +print("\nThe one thousandth abundant odd number is:") +abundant_odd(n, 25, 1000, true) + +print("\nThe first abundant odd number above one billion is:") +abundant_odd(1e9 + 1, 0, 1, true) diff --git a/Task/Accumulator-factory/REBOL/accumulator-factory.rebol b/Task/Accumulator-factory/REBOL/accumulator-factory-1.rebol similarity index 70% rename from Task/Accumulator-factory/REBOL/accumulator-factory.rebol rename to Task/Accumulator-factory/REBOL/accumulator-factory-1.rebol index 35b5392daf..0738505b60 100644 --- a/Task/Accumulator-factory/REBOL/accumulator-factory.rebol +++ b/Task/Accumulator-factory/REBOL/accumulator-factory-1.rebol @@ -6,3 +6,6 @@ make-acc-gen: func [start-val] [ ] ] ] +gen: make-acc-gen 1 +print gen 5 ;== 6 +print gen 2.3 ;== 8.3 diff --git a/Task/Accumulator-factory/REBOL/accumulator-factory-2.rebol b/Task/Accumulator-factory/REBOL/accumulator-factory-2.rebol new file mode 100644 index 0000000000..02468d5450 --- /dev/null +++ b/Task/Accumulator-factory/REBOL/accumulator-factory-2.rebol @@ -0,0 +1,25 @@ +;; Define a generator function 'gen' with an optional refinement '/init' +;; - 'value' is a required number passed to the function +;; - '/init' is an optional refinement for initialization +gen: function/with [value [number!] /init] [ + + ;; If '/init' refinement is used, initialize state and exit immediately + if init [ + state: value ;; Set the initial state to the provided value + exit ;; Exit, so nothing else in the function is run + ] + + ;; If not initializing, add 'value' to 'state' + state: state + value + + ;; The function returns the new state each call +][state: 0] ;; 'state' is a local variable, initialized once per definition (persistent closure) + +;; Initialize the 'state' value of gen to 1 by calling it with '/init' +gen/init 1 + +;; Call gen with 5: Adds 5 to state and prints the result (should print 6) +print gen 5 + +;; Call gen with 2.3: Adds 2.3 to state and prints the result (should print 8.3) +print gen 2.3 diff --git a/Task/Achilles-numbers/Pluto/achilles-numbers.pluto b/Task/Achilles-numbers/Pluto/achilles-numbers.pluto new file mode 100644 index 0000000000..f28f017194 --- /dev/null +++ b/Task/Achilles-numbers/Pluto/achilles-numbers.pluto @@ -0,0 +1,63 @@ +local int = require "int" +local fmt = require "fmt" + +$define MAX_DIGITS = 15 + +local pps = {} + +local function get_perfect_powers(max_exp) + local upper = 10 ^ max_exp + for i = 2.0, int.sqrt(upper) do + local p = i + while true do + p *= i + if p >= upper then break end + pps[p] = true + end + end +end + +local function get_achilles(min_exp, max_exp) + local lower = 10 ^ min_exp + local upper = 10 ^ max_exp + local achilles = {} -- avoids duplicates + for b = 1.0, int.cbrt(upper) do + local b3 = b * b * b + for a = 1.0, int.sqrt(upper) do + local p = b3 * a * a + if p >= upper then break end + if p >= lower then + if !pps[p] then achilles[p] = true end + end + end + end + return achilles +end + +get_perfect_powers(MAX_DIGITS) +local achilles_set = get_achilles(1, 5) -- enough for first 2 parts +local achilles = achilles_set:keys() +achilles:sort() + +print("First 50 Achilles numbers:") +fmt.tprint("%4d", achilles:slice(1, 50), 10) + +print("\nFirst 30 strong Achilles numbers:") +local strong_achilles = {} +local count = 0 +local n = 1 +while count < 30 do + local tot = int.totient(achilles[n]) + if achilles_set[tot] then + strong_achilles:insert(achilles[n]) + ++count + end + ++n +end +fmt.tprint("%5d", strong_achilles, 10) + +print("\nNumber of Achilles numbers with:") +for d = 2, MAX_DIGITS do + local ac = get_achilles(d - 1, d):size() + fmt.print("%2d digits: %d", d, ac) +end diff --git a/Task/Ackermann-function/ArkScript/ackermann-function.ark b/Task/Ackermann-function/ArkScript/ackermann-function.ark new file mode 100644 index 0000000000..c662b841df --- /dev/null +++ b/Task/Ackermann-function/ArkScript/ackermann-function.ark @@ -0,0 +1,8 @@ +(let ackermann (fun (m n) { + (if (> m 0) + (if (= 0 n) + (ackermann (- m 1) 1) + (ackermann (- m 1) (ackermann m (- n 1)))) + (+ 1 n)) })) + +(assert (= 509 (ackermann 3 6)) "(ackermann 3 6) == 509") diff --git a/Task/Ackermann-function/Pluto/ackermann-function.pluto b/Task/Ackermann-function/Pluto/ackermann-function.pluto new file mode 100644 index 0000000000..91075937c7 --- /dev/null +++ b/Task/Ackermann-function/Pluto/ackermann-function.pluto @@ -0,0 +1,13 @@ +function ack(m,n) + if m==0 then + return n+1 + elseif n == 0 then + return ack(m-1,1) + else return ack(m-1,ack(m,n-1)) end +end + +for i = 0,3 do + for j = 0,8 do + print($"A({i},{j})={ack(i,j)}") + end +end diff --git a/Task/Ackermann-function/REBOL/ackermann-function-1.rebol b/Task/Ackermann-function/REBOL/ackermann-function-1.rebol new file mode 100644 index 0000000000..52928c349e --- /dev/null +++ b/Task/Ackermann-function/REBOL/ackermann-function-1.rebol @@ -0,0 +1,7 @@ +ackermann: func [m n] [ + case [ + m = 0 [n + 1] + n = 0 [ackermann m - 1 1] + true [ackermann m - 1 ackermann m n - 1] + ] +] diff --git a/Task/Ackermann-function/REBOL/ackermann-function-2.rebol b/Task/Ackermann-function/REBOL/ackermann-function-2.rebol new file mode 100644 index 0000000000..c6e294cb60 --- /dev/null +++ b/Task/Ackermann-function/REBOL/ackermann-function-2.rebol @@ -0,0 +1,16 @@ +ackermann: func [ + m [integer!] + n [integer!] +] [ + ;; Small-m closed forms + case [ + m = 0 [n + 1] + m = 1 [n + 2] + m = 2 [(2 * n) + 3] + m = 3 [ + ;; 2^(n+3) - 3 + (to integer! power 2 (n + 3)) - 3 + ] + ;; m >= 4 causes stack overflow + ] +] diff --git a/Task/Ackermann-function/TAV/ackermann-function.tav b/Task/Ackermann-function/TAV/ackermann-function.tav new file mode 100644 index 0000000000..f81000b3c8 --- /dev/null +++ b/Task/Ackermann-function/TAV/ackermann-function.tav @@ -0,0 +1,11 @@ +ackermann (n) (m) : + ? n = 0 + :> m+1 + ? m = 0 + :> ackermann (n-1) 1 + :> ackermann (n-1) ackermann n (m-1) \ = ackermann (n-1) (ackermann n (m-1)) +\ test it +main(params):+ + p1 =: string params[1] as integer else 3 + p2 =: string params[2] as integer else 5 + print "ackermann(" _ p1 _ "," _ p2 _ ") = " _ ackermann p1 p2 diff --git a/Task/Address-of-a-variable/Pluto/address-of-a-variable.pluto b/Task/Address-of-a-variable/Pluto/address-of-a-variable.pluto new file mode 100644 index 0000000000..7230dc3a18 --- /dev/null +++ b/Task/Address-of-a-variable/Pluto/address-of-a-variable.pluto @@ -0,0 +1,6 @@ +local s = "" +local t = {} +local function f() end +local n = 1 +local b = true +print(string.format("%p\t%p\t%p\t%p\t%p", s, t, f, n, b)) diff --git a/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx b/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx index 21c8179c31..355580acf3 100644 --- a/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx +++ b/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx @@ -1 +1,18 @@ -zzz = storage(xxx) +-- 7 Aug 2025 +include Settings + +say 'ADDRESS OF A VARIABLE' +say version +say +if Pos('Regina',version) > 0 then + call Library +call Primes 10 +call SysDumpVariables +exit + +Library: +call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs' +call SysLoadFuncs +return + +include Math diff --git a/Task/Address-of-a-variable/RISC-V-Assembly/address-of-a-variable.asm b/Task/Address-of-a-variable/RISC-V-Assembly/address-of-a-variable.asm new file mode 100644 index 0000000000..9a7e83e30b --- /dev/null +++ b/Task/Address-of-a-variable/RISC-V-Assembly/address-of-a-variable.asm @@ -0,0 +1,128 @@ +# riscv assembly raspberry pico2 rp2350 +# program adrvariable.s +# connexion putty com3 +/*********************************************/ +/* CONSTANTES */ +/********************************************/ +/* for this file see risc-v task include a file */ +.include "../../constantesRiscv.inc" + +/*******************************************/ +/* INITIALED DATAS */ +/*******************************************/ +.data +szMessStart: .asciz "Program riscv start.\r\n" +szCariageReturn: .asciz "\r\n" +.align 2 +tabValues: .int 1,2,3,4 + +/*******************************************/ +/* UNINITIALED DATA */ +/*******************************************/ +.bss +.align 2 +sConvArea: .skip 24 +ivalue1: .skip 4 + +/**********************************************/ +/* SECTION CODE */ +/**********************************************/ +.text +.global main + +main: + call stdio_init_all # général init +1: # start loop connexion + li a0,0 # raz argument register + call tud_cdc_n_connected # waiting for USB connection + beqz a0,1b # return code = zero ? + + la a0,szMessStart # message address + call writeString # display message + + la t1,ivalue1 # variable address + lw a0,(t1) # load word value + call displayResult + la t1,ivalue1 # variable address + li t0,12345 # new value + sw t0,(t1) # store word value + la t1,ivalue1 # variable address + lw a0,(t1) # load value for control + call displayResult + la t1,tabValues # load array address + lw a0,8(t1) # load value at byte 8 of array + call displayResult + la t1,tabValues # load array address + li t2,3 # init index value + slli t2,t2,2 # multiply index by 5 (integer size) + add t2,t2,t1 # add offset to array address + lw a0,(t2) # load value of index + call displayResult + + call getchar +100: # final loop + j 100b + +/**********************************************/ +/* displayResult */ +/**********************************************/ +/* a0 value */ +.equ LGZONECONV, 20 +displayResult: + addi sp, sp, -4 # reserve stack + sw ra, 0(sp) + la a1,sConvArea # conversion result address + call conversion10 # conversion decimal + la a0,sConvArea # message address + call writeString # display message + la a0,szCariageReturn + call writeString +100: + lw ra, 0(sp) + addi sp, sp, 4 + ret + +/**********************************************/ +/* decimal conversion */ +/**********************************************/ +/* a0 value */ +/* a1 conversion array address */ +.equ LGZONECONV, 20 +conversion10: + addi sp, sp, -4 + sw ra, 0(sp) + li t1,LGZONECONV + li t2,10 # divisor +1: + rem t4,a0,t2 # division remainder by 10 + addi t4,t4,48 # convert to decimal + add t5,a1,t1 # store character position + sb t4,(t5) # store byte + div a0,a0,t2 # compute quotient + beq a0,x0,2f # compare to 0 + addi t1,t1,-1 # decrement store position + bgt t1,x0,1b # and loop if position is ok +2: + li t2,0 # raz indice + li t3,LGZONECONV +3: # loop to transfer result at begining conversion area + add t5,a1,t1 # compute start position + lb t4,(t5) # load byte + add t5,a1,t2 # compute new position + sb t4,(t5) # and store byte + addi t2,t2,1 # increment indice + addi t1,t1,1 + ble t1,t3,3b # and loop if indice <= area size + add t5,a1,t2 # increment final position + sb x0,(t5) # and store byte final zero + mv a0,t2 # return size conversion + +100: + lw ra, 0(sp) + addi sp, sp, 4 + ret +/************************************/ +/* file include Fonctions */ +/***********************************/ +/* for this file see risc-v task include a file */ +.include "../../includeFunctions.s" diff --git a/Task/Address-of-a-variable/Red/address-of-a-variable.red b/Task/Address-of-a-variable/Red/address-of-a-variable.red new file mode 100644 index 0000000000..f23545f25f --- /dev/null +++ b/Task/Address-of-a-variable/Red/address-of-a-variable.red @@ -0,0 +1,17 @@ +Red/System [] + +print ["pointer test:" newline] + +a: 100 +print ["a is an integer variable, value: " a newline] + +p: declare pointer! [integer!] +p: :a +print ["p is the address of a: " p newline] +print ["p/value refer to the value pointed to by p: " p/value newline] + +q: declare pointer! [integer!] +q: p + 1 +print ["q is p + 1: " q " q/value is (uninitialized): " q/value newline] + +print ["q - p: " (q - p) newline] diff --git a/Task/Align-columns/ALGOL-68/align-columns.alg b/Task/Align-columns/ALGOL-68/align-columns.alg index ae3186556c..056358ac56 100644 --- a/Task/Align-columns/ALGOL-68/align-columns.alg +++ b/Task/Align-columns/ALGOL-68/align-columns.alg @@ -27,37 +27,38 @@ make term(text in file, "$"); on physical file end(text in file, (REF FILE skip)BOOL: stop iteration); on logical file end(text in file, (REF FILE skip)BOOL: stop iteration); +BOOL at eol := FALSE; +on line end(text in file, (REF FILE skip)BOOL: at eol := TRUE); FOR row DO - on line end(text in file, (REF FILE skip)BOOL: stop iteration); - FOR col DO - STRING tok; + at eol := FALSE; + FOR col WHILE NOT at eol DO + STRING tok := ""; getf(text in file, ($gx$,tok)); - IF row > 1 UPB page THEN page := flex page(page, row, 2 UPB page) FI; - IF col > 2 UPB page THEN page := flex page(page, 1 UPB page, col) FI; - page[row,col]:=tok - OD; - stop iteration: - SKIP + IF tok NE "" OR NOT at eol THEN + IF row > 1 UPB page THEN page := flex page(page, row, 2 UPB page) FI; + IF col > 2 UPB page THEN page := flex page(page, 1 UPB page, col) FI; + page[row,col]:=tok + FI + OD OD; stop iteration: SKIP; BEGIN - PROC aligner = (PAGE in page, PROC (STRING,INT)STRING aligner)VOID:( - PAGE page := in page; - [2 UPB page]INT max width; + PROC aligner = (PAGE in page, PROC (STRING,INT)STRING alignf)VOID:( + PAGE al page := in page; FOR col TO 2 UPB page DO - INT max len:=0; FOR row TO UPB page DO IF UPB page[row,col]>max len THEN max len:=UPB page[row,col] FI OD; - FOR row TO UPB page DO page[row,col] := aligner(page[row,col], maxlen) OD + INT max len:=0; FOR row TO UPB al page DO IF UPB al page[row,col]>max len THEN max len:=UPB al page[row,col] FI OD; + FOR row TO UPB al page DO al page[row,col] := alignf(page[row,col], maxlen) OD OD; - printf(($n(UPB page)(n(2 UPB page -1)(gx)gl)$,page)) + printf(($n(UPB page)(n(2 UPB page -1)(gx)gl)$,al page)) ); PROC left = (STRING in, INT len)STRING: in + " "*(len - UPB in), right = (STRING in, INT len)STRING: " "*(len - UPB in) + in, centre = (STRING in, INT len)STRING: ( INT pad=len-UPB in; pad%2*" "+ in + (pad-pad%2)*" " ); - []STRUCT(STRING name, PROC(STRING,INT)STRING align) aligners = (("Left",left), ("Left",right), ("Centre",centre)); + []STRUCT(STRING name, PROC(STRING,INT)STRING align) aligners = (("Left",left), ("right",right), ("Centre",centre)); FOR index TO UPB aligners DO print((new line, "# ",name OF aligners[index]," Column-aligned output:",new line)); diff --git a/Task/Aliquot-sequence-classifications/JavaScript/aliquot-sequence-classifications.js b/Task/Aliquot-sequence-classifications/JavaScript/aliquot-sequence-classifications.js new file mode 100644 index 0000000000..bd6d59798d --- /dev/null +++ b/Task/Aliquot-sequence-classifications/JavaScript/aliquot-sequence-classifications.js @@ -0,0 +1,81 @@ +// See https://en.wikipedia.org/wiki/Divisor_function +function divisorSum(n) { + let total = 1n; + let power = 2n; + // Deal with powers of 2 first + for (; n % 2n === 0n; power *= 2n, n /= 2n) { + total += power; + } + // Odd prime factors up to the square root + for (let p = 3n; p * p <= n; p += 2n) { + let sum = 1n; + for (power = p; n % p === 0n; power *= p, n /= p) { + sum += power; + } + total *= sum; + } + // If n > 1 then it's prime + if (n > 1n) { + total *= n + 1n; + } + return total; +} + +// See https://en.wikipedia.org/wiki/Aliquot_sequence +function classifyAliquotSequence(n) { + const limit = 16; + const terms = new Array(limit); + terms[0] = n; + let classification = "non-terminating"; + let length = 1; + + for (let i = 1; i < limit; ++i) { + ++length; + terms[i] = divisorSum(terms[i - 1]) - terms[i - 1]; + + if (terms[i] === n) { + classification = + (i === 1 ? "perfect" : (i === 2 ? "amicable" : "sociable")); + break; + } + + let j = 1; + for (; j < i; ++j) { + if (terms[i] === terms[i - j]) { + break; + } + } + + if (j < i) { + classification = (j === 1 ? "aspiring" : "cyclic"); + break; + } + + if (terms[i] === 0n) { + classification = "terminating"; + break; + } + } + + let output = `${n}: ${classification}, sequence: ${terms[0]}`; + for (let i = 1; i < length && terms[i] !== terms[i - 1]; ++i) { + output += ` ${terms[i]}`; + } + console.log(output); +} + +function main() { + for (let i = 1n; i <= 10n; ++i) { + classifyAliquotSequence(i); + } + + const specialNumbers = [11n, 12n, 28n, 496n, 220n, 1184n, 12496n, 1264460n, 790n, 909n, 562n, 1064n, 1488n]; + for (const i of specialNumbers) { + classifyAliquotSequence(i); + } + + classifyAliquotSequence(15355717786080n); + classifyAliquotSequence(153557177860800n); +} + +main(); diff --git a/Task/Almkvist-Giullera-formula-for-pi/Ada/almkvist-giullera-formula-for-pi.ada b/Task/Almkvist-Giullera-formula-for-pi/Ada/almkvist-giullera-formula-for-pi.ada new file mode 100644 index 0000000000..400094aff2 --- /dev/null +++ b/Task/Almkvist-Giullera-formula-for-pi/Ada/almkvist-giullera-formula-for-pi.ada @@ -0,0 +1,94 @@ +-- Big_Reals is an Ada 2022 unit +with Ada.Numerics.Big_Numbers.Big_Reals; +with Ada.Text_IO; + +use Ada.Numerics.Big_Numbers.Big_Reals; + +procedure Almkvist_Giullera is + + function "+" (B : Big_Real; A : Integer) return Big_Real is (B + To_Real (A)); + function "*" (A : Integer; B : Big_Real) return Big_Real is (To_Real (A) * B); + B0 : constant Big_Real := To_Real (0); + B1 : constant Big_Real := B0 + 1; + + function Factorial (N : Big_Real) return Big_Real + is + I : Big_Real := N; + F : Big_Real := B1; + begin + while I > B1 loop + F := F * I; + I := I - B1; + end loop; + + return F; + end Factorial; + + function F (N : Big_Real) return Big_Real renames Factorial; + procedure Put_Line (S : String) renames Ada.Text_IO.Put_Line; + + function Integer_Term (N : Big_Real) return Big_Real is + (32 * F (6 * N) / (3 * F (N) ** 6) * (532 * N ** 2 + 126 * N + 9)); + + procedure Show_Integer_Terms (N : Positive) is + begin + for I in 0 .. N - 1 loop + Put_Line ("Almkvist-Giullera integer term " + & I'Image & " is " + & To_String (Integer_Term (To_Real (I)), Aft => 0)); + end loop; + end Show_Integer_Terms; + + -- Use Newton's Method + function Sqrt (N : Big_Real; Precision : Positive) return Big_Real is + Diff : Big_Real := To_Real (10) ** (-Precision); + Estimate : Big_Real := B0; + Next : Big_Real := N; + begin + while abs (Next - Estimate) > Diff loop + Estimate := Next; + Next := Estimate - (Estimate ** 2 - N) / (2 * Estimate); + -- Nasty hack to limit precision. Otherwise there is a storage error. + Next := From_String (To_String (Next, Aft => Precision + 2)); + end loop; + + return Estimate; + end Sqrt; + + function Estimate_Pi (N : Integer; Precision : Positive) return Big_Real is + Sum : Big_Real := B0; + begin + for I in 0 .. N loop + Sum := Sum + Integer_Term (To_Real (I)) / To_Real (10) ** (6 * I + 3); + Sum := From_String (To_String (Sum, Aft => Precision + 2)); + end loop; + + return B1 / Sqrt (Sum, Precision + 2); + end Estimate_Pi; + + function Compute_Pi (Precision : Positive) return Big_Real is + Diff : constant Big_Real := To_Real (10) ** (-Precision); + Pi_Estimate : Big_Real := B0; + Next : Big_Real := B1; + N : Integer := 1; + begin + while abs (Next - Pi_Estimate) > Diff loop + N := N * 2; + Pi_Estimate := Next; + Next := Estimate_Pi (N, Precision); + end loop; + + return Pi_Estimate; + end Compute_Pi; + + procedure Show_Pi (Precision : Positive) is + Pi : constant Big_Real := Compute_Pi (Precision); + begin + Put_Line ("Pi to " & Precision'Image & " places is " + & To_String (Pi, Aft => Precision)); + end Show_Pi; + +begin + Show_Integer_Terms (10); + Show_Pi (70); +end almkvist_giullera; diff --git a/Task/Almost-prime/Icon/almost-prime-1.icon b/Task/Almost-prime/Icon/almost-prime-1.icon index 297458b93a..3b44419065 100644 --- a/Task/Almost-prime/Icon/almost-prime-1.icon +++ b/Task/Almost-prime/Icon/almost-prime-1.icon @@ -6,5 +6,5 @@ procedure main() end procedure genKap(k) - suspend (k = *factors(n := seq(q)), n) + suspend (k = *factors(n := seq()), n) end diff --git a/Task/Almost-prime/Pluto/almost-prime.pluto b/Task/Almost-prime/Pluto/almost-prime.pluto new file mode 100644 index 0000000000..042adee1e9 --- /dev/null +++ b/Task/Almost-prime/Pluto/almost-prime.pluto @@ -0,0 +1,26 @@ +local function k_prime(n, k) + local nf = 0 + for i = 2, n do + while n % i == 0 do + if nf == k then return false end + ++nf + n //= i + end + end + return nf == k +end + +local function gen(k, n) + local r = {} + local m = 2 + for i = 1, n do + while !k_prime(m, k) do ++m end + r[i] = m + ++m + end + return r +end + +for k = 1, 5 do + print($"{k}: {gen(k, 10):concat(", ")}") +end diff --git a/Task/Amb/Ada/amb.ada b/Task/Amb/Ada/amb-1.ada similarity index 100% rename from Task/Amb/Ada/amb.ada rename to Task/Amb/Ada/amb-1.ada diff --git a/Task/Amb/Ada/amb-2.ada b/Task/Amb/Ada/amb-2.ada new file mode 100644 index 0000000000..d2fd093f18 --- /dev/null +++ b/Task/Amb/Ada/amb-2.ada @@ -0,0 +1,78 @@ +-- MacOS, GNAT, gnat-aarch64-darwin-15.1.0-2 +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Amb is + type Alternatives is array (Positive range <>) of Unbounded_String; + + type Amb (Count : Positive) is record + This : Positive := 1; + Left : access Amb; + List : Alternatives (1..Count); + end record; + + function "/" (L, R : String) return Amb; + function "/" (L : Amb; R : String) return Amb; + function "=" (L, R : Amb) return Boolean; + function Image (L : Amb) return String; + procedure Join (L : access Amb; R : in out Amb); + procedure Failure (L : in out Amb); + + function Image (L : Amb) return String is + begin + return To_String (L.List (L.This)); + end Image; + + function "/" (L, R : String) return Amb is + Result : Amb (2); + begin + Append (Result.List (1), L); + Append (Result.List (2), R); + return Result; + end "/"; + + function "/" (L : Amb; R : String) return Amb is + Result : Amb (L.Count + 1); + begin + Result.List (1..L.Count) := L.List ; + Append (Result.List (Result.Count), R); + return Result; + end "/"; + + function "=" (L, R : Amb) return Boolean is + Left : Unbounded_String renames L.List (L.This); + begin + return Element (Left, Length (Left)) = Element (R.List (R.This), 1); + end "="; + + procedure Failure (L : in out Amb) is + begin + loop + if L.This < L.Count then + L.This := L.This + 1; + else + L.This := 1; + Failure (L.Left.all); + end if; + exit when L.Left = null or else L.Left.all = L; + end loop; + end Failure; + + procedure Join (L : access Amb; R : in out Amb) is + begin + R.Left := L; + while L.all /= R loop + Failure (R); + end loop; + end Join; + + W_1 : aliased Amb := "the" / "that" / "a"; + W_2 : aliased Amb := "frog" / "elephant" / "thing"; + W_3 : aliased Amb := "walked" / "treaded" / "grows"; + W_4 : aliased Amb := "slowly" / "quickly"; +begin + Join (W_1'Access, W_2); + Join (W_2'Access, W_3); + Join (W_3'Access, W_4); + Put_Line (Image (W_1) & ' ' & Image (W_2) & ' ' & Image (W_3) & ' ' & Image (W_4)); +end Test_Amb; diff --git a/Task/Amicable-pairs/PL-I-80/amicable-pairs-1.pli b/Task/Amicable-pairs/PL-I-80/amicable-pairs-1.pli deleted file mode 100644 index 0ce9c61830..0000000000 --- a/Task/Amicable-pairs/PL-I-80/amicable-pairs-1.pli +++ /dev/null @@ -1,47 +0,0 @@ -amicable: procedure options (main); - - %replace - search_limit by 20000; - - dcl (a, b, found) fixed bin; - - put skip list ('Searching for amicable pairs up to '); - put edit (search_limit) (f(5)); - found = 0; - do a = 2 to search_limit; - b = sumf(a); - if (b > a) then - do; - if (sumf(b) = a) then - do; - found = found + 1; - put skip edit (a,b) (f(7)); - end; - end; - end; - put skip list (found, ' pairs were found'); - stop; - - -/* return sum of the proper divisors of n */ -sumf: - procedure(n) returns (fixed bin); - - dcl (n, sum, f1, f2) fixed bin; - - sum = 1; /* 1 is a proper divisor of every number */ - f1 = 2; - do while ((f1 * f1) < n); - if mod(n, f1) = 0 then - do; - sum = sum + f1; - f2 = n / f1; - /* don't double count identical co-factors! */ - if f2 > f1 then sum = sum + f2; - end; - f1 = f1 + 1; - end; - return (sum); -end sumf; - -end amicable; diff --git a/Task/Amicable-pairs/PL-I-80/amicable-pairs-2.pli b/Task/Amicable-pairs/PL-I-80/amicable-pairs.pli similarity index 89% rename from Task/Amicable-pairs/PL-I-80/amicable-pairs-2.pli rename to Task/Amicable-pairs/PL-I-80/amicable-pairs.pli index c8263a3816..49d0c5315a 100644 --- a/Task/Amicable-pairs/PL-I-80/amicable-pairs-2.pli +++ b/Task/Amicable-pairs/PL-I-80/amicable-pairs.pli @@ -3,7 +3,7 @@ amicable: procedure options (main); %replace search_limit by 20000; - dcl sumf( 1 : search_limit ) fixed bin; + dcl sumf(1 : search_limit) fixed bin; dcl (a, b, found) fixed bin; put skip list ('Searching for amicable pairs up to '); @@ -12,7 +12,7 @@ amicable: procedure options (main); do a = 1 to search_limit; sumf( a ) = 1; end; do a = 2 to search_limit; do b = a + a to search_limit by a; - sumf( b ) = sumf( b ) + a; + sumf(b) = sumf(b) + a; end; end; diff --git a/Task/Anagrams/DuckDB/anagrams.duckdb b/Task/Anagrams/DuckDB/anagrams.duckdb new file mode 100644 index 0000000000..aaa0f5aad8 --- /dev/null +++ b/Task/Anagrams/DuckDB/anagrams.duckdb @@ -0,0 +1,20 @@ +# The MAP giving the frequency counts of characters in the given string +create or replace function spectrum(str) as ( + select histogram(c) + from (select unnest(regexp_extract_all(str,'.')) as c) +); + +# Find the anagram groups having the most members. +# Each group is sorted, and the groups are sorted by first word in the group. +with words as (from read_csv('unixdict.txt', header=false) _(word)), + histograms as (select word, spectrum(word) as h from words), + groups as (select h, count(h) as c from histograms group by h order by c desc), + mx as (select max(c) as mx from groups), + maximals as (select h from groups, mx where c = mx.mx), + results as (select (select array_agg(word).list_sort() + from histograms + where histograms.h = maximals.h ) as anagrams + from maximals) + select anagrams + from results + order by anagrams[1] ; diff --git a/Task/Anagrams/TAV/anagrams.tav b/Task/Anagrams/TAV/anagrams.tav new file mode 100644 index 0000000000..6b940f7f6e --- /dev/null +++ b/Task/Anagrams/TAV/anagrams.tav @@ -0,0 +1,38 @@ +\( Find anagrams (words with the same set of letters) + Words are the lines of an input file. + Sorting the letters of the word gives the key for a map + having a list (row) of all words so far. +\) +\+ stdlib +main(parms):+ + parms[1] =~ 'unixdict.txt' \ default input file + wordmap =: get words from parms[1] + maxw =: wordmap.maxlen + ?# idx =: map wordmap give keys ascending + words =: wordmap{idx} + ? maxw = words.count + print words::join values by ', ' + +\ read the file (infn) and return a map +get words from (infn): + res =: new map \ create the result map + res.maxlen =: 0 + ?# line =: file infn give lines \ or: infn::give lines + add line to res + :> res + +\ add a word to the map +add (word) to (amap): + idx =: sort characters of word::case to upper + row =: amap{idx} \ get indexed words + ? row = () \ new entry if void + row =: new row + amap{idx} =: row + row[] =: word \ add new entry + amap.maxlen =: maximum of amap.maxlen, row.count + +\ Sort the characters of a string +sort characters of (s): + sr =: string s as character row + row sr sort ascending + :> row sr join values as string \ without separator diff --git a/Task/Angles-geometric-normalization-and-conversion/R/angles-geometric-normalization-and-conversion.r b/Task/Angles-geometric-normalization-and-conversion/R/angles-geometric-normalization-and-conversion.r new file mode 100644 index 0000000000..b5d7f17fa3 --- /dev/null +++ b/Task/Angles-geometric-normalization-and-conversion/R/angles-geometric-normalization-and-conversion.r @@ -0,0 +1,23 @@ +test_angles <- c(-2,-1,0,1,2,6.2831853,16,57.2957795,359,399,6399,1000000) + +d2d <- function(a) sign(a)*(abs(a)%%360) +g2g <- function(a) sign(a)*(abs(a)%%400) +m2m <- function(a) sign(a)*(abs(a)%%6400) +r2r <- function(a) sign(a)*(abs(a)%%(2*pi)) + +normalised <- as.data.frame(sapply(c(d2d,g2g,m2m,r2r), function(f) f(test_angles))) +unitnames <- c("deg","grad","mil","rad") +colnames(normalised) <- sapply(unitnames, function(s) paste0(s, "_norm")) + +d2x <- function(a, unit) switch(unit, "grad"=a*10/9, "mil"=a*160/9, "rad"=a*pi/180) +g2x <- function(a, unit) switch(unit, "deg"=a*9/10, "mil"=a*16, "rad"=a*pi/200) +m2x <- function(a, unit) switch(unit, "deg"=a*9/160, "grad"=a/16, "rad"=a*pi/3200) +r2x <- function(a, unit) switch(unit, "deg"=a*180/pi, "grad"=a*200/pi, "mil"=a*3200/pi) + +deg_conv <- sapply(unitnames[-1], function(unit) d2x(d2d(test_angles), unit)) +grad_conv <- sapply(unitnames[-2], function(unit) g2x(g2g(test_angles), unit)) +mil_conv <- sapply(unitnames[-3], function(unit) m2x(m2m(test_angles), unit)) +rad_conv <- sapply(unitnames[-4], function(unit) r2x(r2r(test_angles), unit)) + +conv_list <- list(deg_conv, grad_conv, mil_conv, rad_conv) +setNames(lapply(1:4, function(n) cbind(test_angles, normalised[n], conv_list[[n]])), unitnames) diff --git a/Task/Anonymous-recursion/DuckDB/anonymous-recursion.duckdb b/Task/Anonymous-recursion/DuckDB/anonymous-recursion.duckdb new file mode 100644 index 0000000000..3127c641c3 --- /dev/null +++ b/Task/Anonymous-recursion/DuckDB/anonymous-recursion.duckdb @@ -0,0 +1,11 @@ +create or replace function fib(n) as ( + if ( n < 0, error('negative arguments not allowed'), + (with recursive fib(i,e,f) as ( + select 1, 1, 1 + union all + select i+1, e+f, e from fib + where i <= n) + select last(f order by i) + from fib) + ) +); diff --git a/Task/Anti-primes/Bc/anti-primes.bc b/Task/Anti-primes/Bc/anti-primes.bc new file mode 100644 index 0000000000..d282deaa5d --- /dev/null +++ b/Task/Anti-primes/Bc/anti-primes.bc @@ -0,0 +1,18 @@ +define factors(n) { + auto c + for(i=1;i<=n;i++) { + if(n%i==0) c+=1 + } + return c +} + +max = 0 +n = 1 +for(c=20; c > 0;) { + if(factors(n) > max) { + print n," " + max = factors(n) + c -= 1 + } + n += 1 +} diff --git a/Task/Anti-primes/Draco/anti-primes.draco b/Task/Anti-primes/Draco/anti-primes.draco new file mode 100644 index 0000000000..8b2db07dee --- /dev/null +++ b/Task/Anti-primes/Draco/anti-primes.draco @@ -0,0 +1,29 @@ +proc factors(word n) word: + word count, fac; + count := 1; + for fac from 1 upto n/2 do + if n % fac = 0 then + count := count + 1 + fi + od; + count +corp + +proc antiprimes(word amount) void: + word maxf, n, f; + maxf := 0; + n := 1; + while amount > 0 do + f := factors(n); + if f > maxf then + write(n, " "); + maxf := f; + amount := amount - 1 + fi; + n := n + 1 + od +corp + +proc main() void: + antiprimes(20) +corp diff --git a/Task/Anti-primes/Lua/anti-primes-2.lua b/Task/Anti-primes/Lua/anti-primes-2.lua index a849a48fa0..a3ca9023e3 100644 --- a/Task/Anti-primes/Lua/anti-primes-2.lua +++ b/Task/Anti-primes/Lua/anti-primes-2.lua @@ -26,4 +26,4 @@ function antiprimes(goal) end -- display the antiprimes -oo.write( table.concat( antiprimes( 20 ), " " ) ) +io.write( table.concat( antiprimes( 20 ), " " ) ) diff --git a/Task/Anti-primes/Pluto/anti-primes.pluto b/Task/Anti-primes/Pluto/anti-primes.pluto new file mode 100644 index 0000000000..3b7ee59a36 --- /dev/null +++ b/Task/Anti-primes/Pluto/anti-primes.pluto @@ -0,0 +1,32 @@ +do -- Find the first 20 antiprimes. + + local fmt = require( "fmt" ) + + -- returns a table of the first goal antiprimes + function antiprimes(goal) + local maxNumber = 0 + local ndc = {} -- table of divisor counts - initially empty + local list, number, mostFactors = {}, 1, 0 + while #list < goal do + if number > #ndc then + -- need a bigger table of divisor counts + maxNumber = maxNumber + 5000 + ndc = {} + for i = 1, maxNumber do ndc[ i ] = 1 end + for i = 2, maxNumber do + for j = i, maxNumber, i do ++ ndc[ j ] end + end + end + local factors = ndc[ number ] + if factors > mostFactors then + table.insert( list, number ) + mostFactors = factors + end + ++ number + end + return list + end + + -- display the antiprimes + fmt.lprint( antiprimes( 20 ), " ", "" ) +end diff --git a/Task/Apply-a-callback-to-an-array/ArkScript/apply-a-callback-to-an-array.ark b/Task/Apply-a-callback-to-an-array/ArkScript/apply-a-callback-to-an-array.ark new file mode 100644 index 0000000000..a264075a30 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/ArkScript/apply-a-callback-to-an-array.ark @@ -0,0 +1,8 @@ +(import std.List :map) + +(let array [1 2 3 4 5 6 7 8 9 10]) +(let mapped (map array (fun (i) (* i i)))) + +(assert + (= mapped [1 4 9 16 25 36 49 64 81 100]) + "mapped is a list of squares") diff --git a/Task/Apply-a-callback-to-an-array/Haxe/apply-a-callback-to-an-array.haxe b/Task/Apply-a-callback-to-an-array/Haxe/apply-a-callback-to-an-array.haxe new file mode 100644 index 0000000000..da0f9b93f7 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Haxe/apply-a-callback-to-an-array.haxe @@ -0,0 +1,10 @@ +class Main { + static function main() { + var numbers = [1, 2, 3, 4, 5]; + + var squared = (i) -> i * i; + + trace(numbers); + trace(numbers.map(squared)); + } +} diff --git a/Task/Approximate-equality/Pluto/approximate-equality.pluto b/Task/Approximate-equality/Pluto/approximate-equality.pluto new file mode 100644 index 0000000000..a40474d82c --- /dev/null +++ b/Task/Approximate-equality/Pluto/approximate-equality.pluto @@ -0,0 +1,16 @@ +local tol = 1e-16 +local sqrt2 = math.sqrt(2.0) +local pairs = { + {100000000000000.01, 100000000000000.011}, + {100.01, 100.011}, + {10000000000000.001 / 10000.0, 1000000000.0000001000}, + {0.001, 0.0010000001}, + {0.000000000000000000000101, 0.0}, + {sqrt2 * sqrt2, 2.0}, + {-sqrt2 * sqrt2, -2.0}, + {3.14159265358979323846, 3.14159265358979324} +} +print($"Approximate equality of test cases for a tolerance of {tol}:") +for i, pair in pairs do + print($" {i} -> {math.abs(pair[1] - pair[2]) < tol}") +end diff --git a/Task/Arbitrary-precision-integers-included-/Agena/arbitrary-precision-integers-included-.agena b/Task/Arbitrary-precision-integers-included-/Agena/arbitrary-precision-integers-included-.agena new file mode 100644 index 0000000000..f0b25b2245 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included-/Agena/arbitrary-precision-integers-included-.agena @@ -0,0 +1,25 @@ +scope # calculate 5^4^3^2 using Mike's Arbitrary Precision Math library + import mapm; # explicit import needed for: Linux, Mac OS X, Windows and Solaris + + # returns a string containing 5^4^3^2 as calculated by mapm + local constant calc5up4up3up2 := proc() is + return mapm.xtostring( mapm.xround( mapm.xnumber( 5 ) ^ mapm.xnumber( 4 ^ ( 3 ^ 2 ) ) ) ) + end; + + # do the calculation with default precision + local p := calc5up4up3up2(); + + # find the number of digits before the point + local d := size( p ); + local point := "." in p; + if point <> null then d := point - 1 fi; + + # redo the calculation with the actual number of required digits ( plus a bit extra ) + mapm.xdigits( d + 30 ); + p := calc5up4up3up2(); + d := size( p ); + point := "." in p; + if point <> null then d := point - 1 fi; + + io.write( "5^4^3^2 has ", d, " digits: ", p[ 1 to 20 ], "...", p[ d - 19 to d ], "\n" ) +end diff --git a/Task/Arbitrary-precision-integers-included-/BBC-BASIC/arbitrary-precision-integers-included-.basic b/Task/Arbitrary-precision-integers-included-/BBC-BASIC/arbitrary-precision-integers-included-.basic new file mode 100644 index 0000000000..9b470db7e7 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included-/BBC-BASIC/arbitrary-precision-integers-included-.basic @@ -0,0 +1,11 @@ + 10 INSTALL @lib$ + "bigint" + 20 t1 = TIME + 30 x = FNbignew(200000) + 40 PROCbigval(x, "5") + 50 PROCbigpow(x, x, 4^(3^2)) + 60 x$ = FNbigstr(x) + 70 t2 = TIME + 80 PRINT "First twenty digits: " LEFT$(x$, 20) + 90 PRINT " Last twenty digits: " RIGHT$(x$, 20) + 100 PRINT "Total number of digits: "; LEN(x$) + 110 PRINT "Approximate run time: "; (t2 - t1) / 100 " seconds" diff --git a/Task/Arbitrary-precision-integers-included-/Bracmat/arbitrary-precision-integers-included-.bracmat b/Task/Arbitrary-precision-integers-included-/Bracmat/arbitrary-precision-integers-included-.bracmat index 0cf1eaa821..8b4ca42a92 100644 --- a/Task/Arbitrary-precision-integers-included-/Bracmat/arbitrary-precision-integers-included-.bracmat +++ b/Task/Arbitrary-precision-integers-included-/Bracmat/arbitrary-precision-integers-included-.bracmat @@ -1,4 +1,4 @@ {?} @(5^4^3^2:?first [20 ? [-21 ?last [?length)&str$(!first "..." !last "\nlength " !length) {!} 62060698786608744707...92256259918212890625 length 183231 - S 2,46 sec + S 0,11 sec (4372.4475) diff --git a/Task/Arbitrary-precision-integers-included-/Nim/arbitrary-precision-integers-included-.nim b/Task/Arbitrary-precision-integers-included-/Nim/arbitrary-precision-integers-included-.nim index 73c032ed08..e7e928169e 100644 --- a/Task/Arbitrary-precision-integers-included-/Nim/arbitrary-precision-integers-included-.nim +++ b/Task/Arbitrary-precision-integers-included-/Nim/arbitrary-precision-integers-included-.nim @@ -1,6 +1,8 @@ +# Solution for https://rosettacode.org/wiki/Arbitrary-precision_integers_(included) import bigints +import std/math -var x = 5.pow 4.pow 3.pow 2 +var x = 5.initBigInt.pow 4 ^ (3 ^ 2) var s = $x echo s[0..19] diff --git a/Task/Arbitrary-precision-integers-included-/Pluto/arbitrary-precision-integers-included-.pluto b/Task/Arbitrary-precision-integers-included-/Pluto/arbitrary-precision-integers-included-.pluto new file mode 100644 index 0000000000..4a5147f062 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included-/Pluto/arbitrary-precision-integers-included-.pluto @@ -0,0 +1,10 @@ +local bigint = require "bigint" +local fmt = require "fmt" +local p = bigint.new(3) ^ bigint.new(2) +p = bigint.new(4) ^ p +p = bigint.new(5) ^ p + +local s = p:tostring() +fmt.print("5 ^ 4 ^ 3 ^ 2 has %s digits.\n", fmt.int(#s)) +print("The first twenty and last twenty are: ") +print(fmt.abridge(s, 20)) diff --git a/Task/Arbitrary-precision-integers-included-/Rhombus/arbitrary-precision-integers-included-.rhombus b/Task/Arbitrary-precision-integers-included-/Rhombus/arbitrary-precision-integers-included-.rhombus new file mode 100644 index 0000000000..f8e88ba5fa --- /dev/null +++ b/Task/Arbitrary-precision-integers-included-/Rhombus/arbitrary-precision-integers-included-.rhombus @@ -0,0 +1,5 @@ +def bignum : 5**4**3**2 +def num_length : to_string(bignum).length() +num_length +to_string(bignum).substring(..20) +to_string(bignum).substring(num_length-20..num_length) diff --git a/Task/Archimedean-spiral/EasyLang/archimedean-spiral.easy b/Task/Archimedean-spiral/EasyLang/archimedean-spiral.easy index 4fc2177a04..f286d38628 100644 --- a/Task/Archimedean-spiral/EasyLang/archimedean-spiral.easy +++ b/Task/Archimedean-spiral/EasyLang/archimedean-spiral.easy @@ -2,11 +2,9 @@ glinewidth 0.4 x0 = 50 y0 = 50 while r < 50 - xp = x - yp = y x = r * cos t + x0 y = r * sin t + y0 - if r > 0 : gline xp yp x y + glineto x y r += 0.05 t += 3 . diff --git a/Task/Arithmetic-Complex/ArkScript/arithmetic-complex.ark b/Task/Arithmetic-Complex/ArkScript/arithmetic-complex.ark new file mode 100644 index 0000000000..96b3a3957f --- /dev/null +++ b/Task/Arithmetic-Complex/ArkScript/arithmetic-complex.ark @@ -0,0 +1,30 @@ +(import std.Math) + +(let a (math:complex 1 1)) +(let b (math:complex 3.75 1.25)) + +(assert + (= + (math:complex-add a b) + (math:complex 4.75 2.25)) + "complex add") +(assert + (= + (math:complex-mul a b) + (math:complex 2.5 5)) + "complex mul") +(assert + (= + (math:complex-mul (math:complex -1 0) a) + (math:complex -1 -1)) + "complex negation") +(assert + (= + (math:complex-div (math:complex 1 0) a) + (math:complex 0.5 -0.5)) + "complex inversion") +(assert + (= + (math:complex-conjugate a) + (math:complex 1 -1)) + "complex conjugate") diff --git a/Task/Arithmetic-Complex/DuckDB/arithmetic-complex.duckdb b/Task/Arithmetic-Complex/DuckDB/arithmetic-complex.duckdb new file mode 100644 index 0000000000..6f63ed0faa --- /dev/null +++ b/Task/Arithmetic-Complex/DuckDB/arithmetic-complex.duckdb @@ -0,0 +1,86 @@ +CREATE TYPE COMPLEX AS STRUCT(r REAL, i REAL); + +CREATE OR REPLACE FUNCTION isreal(a) AS ( + if (try_cast(a as REAL), true, false) +); + +CREATE OR REPLACE FUNCTION tocomplex(a) AS ( + coalesce( try_cast(a as COMPLEX), {r: a, i:0.0 }::COMPLEX ) +); + +CREATE OR REPLACE FUNCTION complex_add_(a, b) AS ( + {r: a.r + b.r, i:a.i + b.i} +); + +CREATE OR REPLACE FUNCTION complex_add(a, b) AS ( + complex_add_(tocomplex(a), tocomplex(b)) +); + +CREATE OR REPLACE FUNCTION complex_mul_(a, b) AS ( + {r: a.r * b.r - a.i * b.i, i:a.r * b.i + a.i * b.r} +); + +CREATE OR REPLACE FUNCTION complex_mul(a, b) AS ( + complex_mul_(tocomplex(a), tocomplex(b)) +); + +CREATE OR REPLACE FUNCTION complex_mag(a) AS ( + case when isreal(a) + then abs(a::REAL) + else sqrt( (a::COMPLEX).r ^ 2 + (a::COMPLEX).i ^2) + end +); + +CREATE OR REPLACE FUNCTION complex_conj(a) AS ( + case when isreal(a) + then {r: a::REAL, i: 0.0} + else {r: (a::COMPLEX).r, i: - (a::COMPLEX).i} + end +); + +CREATE OR REPLACE FUNCTION complex_mag_squared(x) AS ( + case when isreal(x) + then x::REAL*x::REAL + else (x::COMPLEX).r ^ 2 + (x::COMPLEX).i ^ 2 + end +); + +# Oddly, the a.r notation cannot currently be used here +CREATE OR REPLACE FUNCTION complex_div_(a, b) AS ( + WITH denom AS (select complex_mag_squared(b) as denom, + a['r'] as ar, a['i'] as ai, b['r'] as br, b['i'] as bi + ) + SELECT {r: (ar * br + ai * bi) / denom, + i: (ai * br - ar * bi) / denom } + FROM denom +); + +CREATE OR REPLACE FUNCTION complex_div(a, b) AS ( + complex_div_(tocomplex(a), tocomplex(b)) +); + +CREATE OR REPLACE FUNCTION complex_exp_(z) AS ( + complex_mul_( {r: exp(z.r), i: 0.0}, {r: cos(z.i), i:sin(z.i) }) +); + +CREATE OR REPLACE FUNCTION complex_exp(z) AS ( + if( isreal(z), + {r:exp(z::REAL), i:0.0}, + complex_exp_( tocomplex(z) ) ) +); + +## Examples +.mode line +CREATE OR REPLACE FUNCTION test(x,y) as table ( + select x as "x", + y as "y", + complex_add(x,y) as "add", + complex_mul(x,y) as "mul", + complex_div(1, x) as "1/x", + complex_conj(x) as "conj(x)", + complex_div(x,y).complex_mul(y) as "(x/y)*y" +); + +from test({r:1,i:1}, {r:0,i:1} ); + +select complex_exp( {r:0, i:pi()} ) as "e^iπ"; diff --git a/Task/Arithmetic-Complex/FutureBasic/arithmetic-complex.basic b/Task/Arithmetic-Complex/FutureBasic/arithmetic-complex.basic new file mode 100644 index 0000000000..e54a45e971 --- /dev/null +++ b/Task/Arithmetic-Complex/FutureBasic/arithmetic-complex.basic @@ -0,0 +1,71 @@ +// +// Arithmetic/Complex +// Using FutureBasic 7.0.34 +// August 2025, R.W + +include "Tlbx complex.incl" +// through this include file, FB supports the following +// double complex functions (as of August 2025). +// Float and long double complex might be +// available in later versions + +//fn creal, cimag, cabs, carg, conj, cproj +//fn csqrt, cexp, clog, cpow +//fn csin, ccos, ctan +//fn casin, cacos, catan +//fn csinh, ccosh, ctanh +//fn casinh,cacosh,catanh + +// Below is redefining "I" to Cj since I don't want to lose the +// ability to use "i" as my favorite FOR NEXT / loop variable +BeginCDeclaration +#define Cj I +EndC +system double Cj + +local fn PrintComplexNumber( z as double_complex ) + double y + print @fn creal( z ) " "; + y = fn cimag( z ) + if ( y >= 0.0 ) then print @"+"; : else print @"-"; + print @abs( y ) "i" +end fn + +window 1,@"Arithmetic/Complex" + +double_complex z1, z2, z3, z4, z5, z6 +double_complex z7, z8, z9, zs, zn + +z1 = 1.5 + 3 * Cj //1.5 + 3i +z2 = 1.5 + 1.5 * Cj //1.5 + 1.5i + +// Operations using C99 operators +z3 = z1 + z2 // addition +z4 = z1 - z2 // subtraction +z5 = z1 * z2 // multiplication +z6 = z1 / z2 // division +//---------------- +z7 = fn conj(z1) // conjugate +z8 = fn cpow(z1,z2) // power ^ +z9 = fn cabs(z1) // norm | magnitude +zs = fn csqrt(z1) // square root +zn = -(z1) // negate + +// Extract real/imag parts using creal/cimag +print @ +print @" z1 + z2 = "; fn creal(z3); " + "; fn cimag(z3); "i" +print @" z1 - z2 = "; fn creal(z4); " + "; fn cimag(z4); "i" +print @" z1 * z2 = "; fn creal(z5); " + "; fn cimag(z5); "i" +print @" z1 / z2 = "; fn creal(z6); " + "; fn cimag(z6); "i" +print @" Conj z1 = "; fn creal(z7); " "; fn cimag(z7); "i" +print @" Abs z1 = "; fn creal(z9) +print @" z1 ^ z2 = "; +fn PrintComplexNumber(z8) +print @" cSqrt z1= "; +fn PrintComplexNumber(zs) +print @" -(z1) = "; +fn PrintComplexNumber(zn) +print @" z1 real = "; fn creal(z1) +print @" z1 imag = "; fn cimag(z1) + +HandleEvents diff --git a/Task/Arithmetic-Complex/Pluto/arithmetic-complex.pluto b/Task/Arithmetic-Complex/Pluto/arithmetic-complex.pluto new file mode 100644 index 0000000000..f2f68b630f --- /dev/null +++ b/Task/Arithmetic-Complex/Pluto/arithmetic-complex.pluto @@ -0,0 +1,15 @@ +require "complex" +local fmt = require "fmt" + +local x = new complex(1, 3) +local y = new complex(5, 2) + +fmt.print("x = %s", x) +fmt.print("y = %s", y) +fmt.print("x + y = %s", x + y) +fmt.print("x - y = %s", x - y) +fmt.print("x * y = %s", x * y) +fmt.print("x / y = %s", x / y) +fmt.print("-x = %s", -x) +fmt.print("1 / x = %s", x:inverse()) +fmt.print("x* = %s", x:conj()) diff --git a/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx index 7c72a01f37..e174652042 100644 --- a/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx +++ b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx @@ -1,4 +1,4 @@ --- 19 May 2025 +-- 7 Aug 2025 include Settings say 'COMPLEX ARITHMETIC' @@ -6,48 +6,45 @@ say version say a = '1 2'; b = '3 4'; c = '5 6'; d = '7 8'; i = I() say 'VALUES' -say 'a =' crec2form(a) -say 'b =' crec2form(b) -say 'c =' crec2form(c) -say 'd =' crec2form(d) +say 'a =' Rec2FormC(a) +say 'b =' Rec2FormC(b) +say 'c =' Rec2FormC(c) +say 'd =' Rec2FormC(d) say say 'BASICS' -say 'i*i =' crec2form(Csquare(i())) -say 'a+b =' crec2form(Cadd(a,b)) -say 'a-b =' crec2form(Csub(a,b)) -say 'a*b =' crec2form(Cmul(a,b)) -say 'a/b =' crec2form(Cdiv(a,b)) -say 'a^2 =' crec2form(Csquare(a,2)) -say 'a^5 =' crec2form(Cpow(a,5)) -say '-a =' crec2form(Cneg(a)) -say '1/a =' crec2form(Cinv(a)) -say 'a+b+c+d =' crec2form(Cadd(a,b,c,d)) -say 'a-b-c-d =' crec2form(Csub(a,b,c,d)) -say 'a*b*c*d =' crec2form(Cmul(a,b,c,d)) -say 'a/b/c/d =' crec2form(Cnormal(Cdiv(a,b,c,d))) +say 'i*i =' Rec2FormC(SquareC(i())) +say 'a+b =' Rec2FormC(AddC(a,b)) +say 'a-b =' Rec2FormC(SubC(a,b)) +say 'a*b =' Rec2FormC(MulC(a,b)) +say 'a/b =' Rec2FormC(DivC(a,b)) +say 'a^2 =' Rec2FormC(SquareC(a,2)) +say 'a^5 =' Rec2FormC(PowC(a,5)) +say '-a =' Rec2FormC(NegC(a)) +say '1/a =' Rec2FormC(InvC(a)) +say 'a+b+c+d =' Rec2FormC(AddC(a,b,c,d)) +say 'a-b-c-d =' Rec2FormC(SubC(a,b,c,d)) +say 'a*b*c*d =' Rec2FormC(MulC(a,b,c,d)) +say 'a/b/c/d =' Rec2FormC(Normal(DivC(a,b,c,d))) say say 'FORMULA' say 'a^2-2ab+3c-4ad^4+5 =' , -crec2form(Cadd(Csquare(a),Cmul(-2,a,b),Cmul(3,c),Cmul(-4,a,Cpower(d,4)),5)) +Rec2FormC(AddC(SquareC(a),MulC(-2,a,b),MulC(3,c),MulC(-4,a,PowerC(d,4)),5)) say say 'BONUS' -say 'Argument(a) =' Carg(a)+0 -say 'Conjugate(a) =' crec2form(Cconj(a)) -say 'Imag(a) =' Cim(a) -say 'Modulus(a) =' Cmod(a)+0 -say 'Polar(a) =' Cpol2form(Cnormal(Crec2pol(a))) -say 'Real(a) =' Cre(a) +say 'Argument(a) =' ArgC(a)+0 +say 'Conjugate(a) =' Rec2FormC(ConjC(a)) +say 'Imag(a) =' ImC(a) +say 'Modulus(a) =' ModC(a)+0 +say 'Polar(a) =' Pol2FormC(Normal(Rec2PolC(a))) +say 'Real(a) =' ReC(a) say say 'MORE' -say 'Arcsin(a) =' crec2form(Cnormal(Carcsin(a))) -say 'Exp(a) =' crec2form(Cnormal(Cexp(a))) -say 'Ln(a) =' crec2form(Cnormal(Cln(a))) -say 'Sin(a) =' crec2form(Cnormal(Csin(a))) -say 'Sqrt(a) =' crec2form(Cnormal(Csqrt(a))) -say 'i^i =' crec2form(Cnormal(Cpower(i,i))) +say 'Arcsin(a) =' Rec2FormC(Normal(ArcSinC(a))) +say 'Exp(a) =' Rec2FormC(Normal(ExpC(a))) +say 'Ln(a) =' Rec2FormC(Normal(LnC(a))) +say 'Sin(a) =' Rec2FormC(Normal(SinC(a))) +say 'Sqrt(a) =' Rec2FormC(Normal(SqRtC(a))) +say 'i^i =' Rec2FormC(Normal(PowerC(i,i))) exit -include Complex -include Functions -include Constants -include Abend +include Math diff --git a/Task/Arithmetic-Integer/ArkScript/arithmetic-integer.ark b/Task/Arithmetic-Integer/ArkScript/arithmetic-integer.ark new file mode 100644 index 0000000000..1fa6546301 --- /dev/null +++ b/Task/Arithmetic-Integer/ArkScript/arithmetic-integer.ark @@ -0,0 +1,10 @@ +(let a 4) +(let b 5) + +(assert (= (+ a b) 9) "sum") +(assert (= (- a b) -1) "difference") +(assert (= (- b a) 1) "difference") +(assert (= (* a b) 20) "product") +(assert (= (/ a b) 0.8) "quotient") +(assert (= (mod a b) 4) "remainder(a, b)") +(assert (= (mod b a) 1) "remainder(b, a)") diff --git a/Task/Arithmetic-Integer/DuckDB/arithmetic-integer.duckdb b/Task/Arithmetic-Integer/DuckDB/arithmetic-integer.duckdb new file mode 100644 index 0000000000..bdde026f71 --- /dev/null +++ b/Task/Arithmetic-Integer/DuckDB/arithmetic-integer.duckdb @@ -0,0 +1,3 @@ +SELECT x, y, (x+y), (x-y), (x*y), x // y, mod(x,y), exp(x) + FROM read_csv_auto('rc-arithmetic-integer.txt', header=false, + columns={'x': 'HUGEINT', 'y': 'HUGEINT'}) ; diff --git a/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena b/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena index d0e5d67143..71357b0182 100644 --- a/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena +++ b/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena @@ -3,13 +3,13 @@ import extensions; public program() { - var a := console.loadLineTo(new Integer()); - var b := console.loadLineTo(new Integer()); + var a := Console.loadLineTo(new Integer()); + var b := Console.loadLineTo(new Integer()); - console.printLine(a," + ",b," = ",a + b); - console.printLine(a," - ",b," = ",a - b); - console.printLine(a," * ",b," = ",a * b); - console.printLine(a," / ",b," = ",a / b); // truncates towards 0 - console.printLine(a," % ",b," = ",a.mod(b)); // matches sign of first operand - console.printLine(a," ^ ",b," = ",a ^ b); + Console.printLine(a," + ",b," = ",a + b); + Console.printLine(a," - ",b," = ",a - b); + Console.printLine(a," * ",b," = ",a * b); + Console.printLine(a," / ",b," = ",a / b); // truncates towards 0 + Console.printLine(a," % ",b," = ",a.mod(b)); // matches sign of first operand + Console.printLine(a," ^ ",b," = ",a ^ b); } diff --git a/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe b/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe index d18971aa92..513ff1c6ea 100644 --- a/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe +++ b/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe @@ -1,13 +1,16 @@ -class BasicIntegerArithmetic { - public static function main() { - var args =Sys.args(); - if (args.length < 2) return; - var a = Std.parseFloat(args[0]); - var b = Std.parseFloat(args[1]); - trace("a+b = " + (a+b)); - trace("a-b = " + (a-b)); - trace("a*b = " + (a*b)); - trace("a/b = " + (a/b)); - trace("a%b = " + (a%b)); +class Main { + static public function main():Void { + var input_a = Sys.stdin().readLine(); + var input_b = Sys.stdin().readLine(); + + var a = Std.parseInt(input_a); + var b = Std.parseInt(input_b); + + trace(a + b); + trace(a - b); + trace(a * b); + trace(Std.int(a / b)); + trace(a % b); + trace(Math.pow(a, b)); } } diff --git a/Task/Arithmetic-Integer/Pascal/arithmetic-integer.pas b/Task/Arithmetic-Integer/Pascal/arithmetic-integer.pas index 0f5806a811..28040742b4 100644 --- a/Task/Arithmetic-Integer/Pascal/arithmetic-integer.pas +++ b/Task/Arithmetic-Integer/Pascal/arithmetic-integer.pas @@ -1,5 +1,7 @@ program arithmetic(input, output) - +{$IFDEF FPC} + uses math; +{$ENDIF} var a, b: integer; diff --git a/Task/Arithmetic-Integer/Pluto/arithmetic-integer.pluto b/Task/Arithmetic-Integer/Pluto/arithmetic-integer.pluto new file mode 100644 index 0000000000..5e35d1e3bc --- /dev/null +++ b/Task/Arithmetic-Integer/Pluto/arithmetic-integer.pluto @@ -0,0 +1,13 @@ +local function divmod(a, b) return { a // b, a % b } end + +io.write("Input the first integer : ") +local a = io.read("n") +io.write("Input the second integer: ") +local b = io.read("n") +print($"sum: {a + b}") +print($"difference {a - b}") +print($"product {a * b}") +print($"quotient {a // b}") +print($"remainder {a % b}") +print($"exponentation {math.tointeger(a ^ b)}") +print($"divmod {divmod(a, b):concat(", ")}") diff --git a/Task/Arithmetic-Integer/RISC-V-Assembly/arithmetic-integer.asm b/Task/Arithmetic-Integer/RISC-V-Assembly/arithmetic-integer.asm new file mode 100644 index 0000000000..a65eff3a1e --- /dev/null +++ b/Task/Arithmetic-Integer/RISC-V-Assembly/arithmetic-integer.asm @@ -0,0 +1,146 @@ +# riscv assembly raspberry pico2 rp2350 +# program arith.s +# connexion putty com3 +/*********************************************/ +/* CONSTANTES */ +/********************************************/ +/* for this file see risc-v task include a file */ +.include "../../constantesRiscv.inc" + +/*******************************************/ +/* INITIALED DATAS */ +/*******************************************/ +.data +szMessStart: .asciz "Program riscv start.\r\n" +szCariageReturn: .asciz "\r\n" +szMessAdd: .asciz "Addition result :\r\n" +szMessSub: .asciz "Substraction result :\r\n" +szMessMul: .asciz "Multiplication result :\r\n" +szMessDiv: .asciz "Division result :\r\n" +szMessRem: .asciz "Division remainder :\r\n" +.align 2 +#tabValues: .int 1,2,3,4 + +/*******************************************/ +/* UNINITIALED DATA */ +/*******************************************/ +.bss +.align 2 +sConvArea: .skip 24 + +/**********************************************/ +/* SECTION CODE */ +/**********************************************/ +.text +.global main + +main: + call stdio_init_all # général init +1: # start loop connexion + li a0,0 # raz argument register + call tud_cdc_n_connected # waiting for USB connection + beqz a0,1b # return code = zero ? + + la a0,szMessStart # message address + call writeString # display message + + la a0,szMessAdd # addition + call writeString # display message + li t0,10 + addi a0,t0,1 # add immediat number + call displayResult + li s0,15 + li s1,8 + add a0,s0,s1 # register add + call displayResult + + la a0,szMessSub # subtraction + call writeString # display message + addi a0,s0,-6 # substract immediat number + call displayResult + sub a0,s0,s1 # substract register s1 to s0 + call displayResult + + la a0,szMessMul # multiplication + call writeString # display message + mul a0,s0,s1 # multiplication register + call displayResult + li s0,12345678 + li s1,23456789 + mul a0,s0,s1 # multiplication register + call displayResult + mulh a0,s0,s1 # Multiply signed (32) by signed (32), return upper 32 bits of the 64-bit result. + call displayResult + mulhsu a0,s0,s1 # Multiply signed (32) by unsigned (32), return upper 32 bits of the 64-bit result. + call displayResult + mulhu a0,s0,s1 # Multiply unsigned (32) by unsigned (32), return upper 32 bits of the 64-bit result. + call displayResult + + la a0,szMessDiv # division + call writeString # display message + li s0,-25 + li s1,8 + div a0,s0,s1 # divide signed + call displayResultS + li s0,-25 + li s1,8 + divu a0,s0,s1 # Divide (unsigned) + call displayResult + + la a0,szMessRem # division + call writeString # display message + li s0,-10 + li s1,8 + rem a0,s0,s1 # Remainder (signed). + call displayResultS + li s0,-10 + li s1,8 + remu a0,s0,s1 # Remainder (unsigned). + call displayResult + + call getchar +100: # final loop + j 100b + +/**********************************************/ +/* display result unsigned */ +/**********************************************/ +/* a0 value */ +.equ LGZONECONV, 20 +displayResult: + addi sp, sp, -4 # reserve stack + sw ra, 0(sp) + la a1,sConvArea # conversion result address + call conversion10 # conversion decimal + la a0,sConvArea # message address + call writeString # display message + la a0,szCariageReturn + call writeString +100: + lw ra, 0(sp) + addi sp, sp, 4 + ret +/**********************************************/ +/* displayResult signed */ +/**********************************************/ +/* a0 value */ +.equ LGZONECONV, 20 +displayResultS: + addi sp, sp, -4 # reserve stack + sw ra, 0(sp) + la a1,sConvArea # conversion result address + call conversion10S # conversion decimal + la a0,sConvArea # message address + call writeString # display message + la a0,szCariageReturn + call writeString +100: + lw ra, 0(sp) + addi sp, sp, 4 + ret + +/************************************/ +/* file include Fonctions */ +/***********************************/ +/* for this file see risc-v task include a file */ +.include "../../includeFunctions.s" diff --git a/Task/Arithmetic-Integer/Red/arithmetic-integer.red b/Task/Arithmetic-Integer/Red/arithmetic-integer.red new file mode 100644 index 0000000000..91d6bce211 --- /dev/null +++ b/Task/Arithmetic-Integer/Red/arithmetic-integer.red @@ -0,0 +1,42 @@ +Red [ "Arithmetic / Integers" ] + +;-- Modulo and // in Red are Euclidean modulo, so the correct integer (Euclidean) division must satisfy: +; a = b * div(a,b) + mod(a,b) +; with 0 <= mod(a,b) < |b| +; This is a custom operator to accompany the built-in Euclidean modulo +ediv: make op! function [a b] [ + either b > 0 + [ to-integer round/floor a / b ] ;b > 0: floor toward -inf + [ to-integer round/ceiling a / b ] ;b < 0: ceiling toward +inf +] +; Python-style divmod: +edivmod: make op! function [a b] [ compose [(a ediv b) (a // b)] ] + +;-- C-style truncated integer division: +quot: make op! function [a b] [ to-integer a / b ] ;truncated toward zero +; Haskell-style quotrem: +quotrem: make op! function [a b] [ compose [(a quot b) (a % b)] ]; reduce [a quot b a % b] ] ; rounds -> 0 + +while [(s: ask "^/Enter two integer separated with space (q = quit): ") <> "q"] [ + s: load rejoin ["[" s "]"] a: s/1 b: s/2 + + print ["Sum :" a "+" b " = " a + b] + print ["Difference :" a "-" b " = " a - b] + print ["Product :" a "*" b " = " a * b] + + print "^/Red's Euclidean Division:" + print ["eDiv :" a "eDiv " b " = " a eDiv b] + print ["modulo : modulo" a b " = " modulo a b] ;non-negative + print ["// :" a "//" b " = " a // b] ;operator form + print ["eDivMod :" a "eDivMod" b "= " mold a eDivMod b] + print rejoin ["Check: ("a" eDiv " b") * "b" + ("a" // "b") = "a" ? " (a eDiv b) * b + (a // b) = a] + + print "^/Red's C-style truncated integer division:" + print ["quot :" a "quot" b " = " a quot b] + print ["remainder : remainder" a b " = " remainder a b] ;sign as dividend + print ["% :" a "%" b " = " a % b] ;operator form + print ["quotRem :" a "quotRem" b " = " mold a quotRem b] + print rejoin ["Check: ("a" quot " b") * "b" + ("a" % "b") = "a" ? " (a quot b) * b + (a % b) = a] + + print ["^/Exponentiation :" a "**" b " = " a ** b] +] diff --git a/Task/Arithmetic-Integer/TAV/arithmetic-integer.tav b/Task/Arithmetic-Integer/TAV/arithmetic-integer.tav new file mode 100644 index 0000000000..3077c59f4c --- /dev/null +++ b/Task/Arithmetic-Integer/TAV/arithmetic-integer.tav @@ -0,0 +1,11 @@ + a, b =: 6, 4 + print 'a + b =', a + b + print 'a - b =', a - b + print 'a * b =', a * b + print 'a // b =', a // b \ integer division is %% + print 'a %% b =', a %% b \ usual modulus + print 'a ^ b =', a ^ b + qr =: a // b, a %% b \ operator /% rarely used, not implemented + print 'a /% b =', join qr by ',' + r =: a / b \ rational result + print r, r.num, r.den \ number, numerator, denominator diff --git a/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig b/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig index 564d8cc2b4..17f6f7d217 100644 --- a/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig +++ b/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig @@ -1,23 +1,26 @@ const std = @import("std"); pub fn main() !void { - var buf: [1024]u8 = undefined; - const reader = std.io.getStdIn().reader(); const stdout = std.io.getStdOut().writer(); - try stdout.writeAll("Enter two integers separated by a space: "); - const input = try reader.readUntilDelimiter(&buf, '\n'); - const text = std.mem.trimRight(u8, input, "\r\n"); + const stdin = std.io.getStdIn().reader(); + var buff = [_]u8{0} ** 1024; - var it = std.mem.tokenizeScalar(u8, text, ' '); + try stdout.print("Value of a: ", .{}); + const input_a: ?[]u8 = try stdin.readUntilDelimiterOrEof(buff[0..], '\n'); + const trimmed_a = std.mem.trimEnd(u8, input_a.?, "\r"); // for Windows + const a = try std.fmt.parseInt(i32, trimmed_a, 10); - const a = try std.fmt.parseInt(i64, it.next().?, 10); - const b = try std.fmt.parseInt(i64, it.next().?, 10); + try stdout.print("Value of b: ", .{}); + const input_b: ?[]u8 = try stdin.readUntilDelimiterOrEof(buff[0..], '\n'); + const trimmed_b = std.mem.trimEnd(u8, input_b.?, "\r"); // for Windows + const b = try std.fmt.parseInt(i32, trimmed_b, 10); - try stdout.print("Values: a {d} b {d}\n", .{a, b}); - try stdout.print("Sum: a + b = {d}\n", .{a + b}); - try stdout.print("Difference: a - b = {d}\n", .{a - b}); - try stdout.print("Product: a * b = {d}\n", .{a * b}); - try stdout.print("Integer quotient: a / b = {d}\n", .{@divTrunc(a, b)}); //truncates towards 0 - try stdout.print("Remainder: a % b = {d}\n", .{@rem(a, b)}); // same sign as first operand - try stdout.print("Exponentiation: math.pow = {d}\n", .{std.math.pow(i64, a, b)}); //no exponentiation operator + try stdout.print("a + b = {d}\n", .{a + b}); + try stdout.print("a - b = {d}\n", .{a - b}); + try stdout.print("a * b = {d}\n", .{a * b}); + try stdout.print("a / b (floor) = {d}\n", .{@divFloor(a, b)}); + try stdout.print("a / b (trunk) = {d}\n", .{@divTrunc(a, b)}); + try stdout.print("a % b (mod) = {d}\n", .{@mod(a, b)}); + try stdout.print("a % b (rem) = {d}\n", .{@rem(a, b)}); + try stdout.print("a ^ b = {d}\n", .{std.math.pow(i32, a, b)}); } diff --git a/Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto b/Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto new file mode 100644 index 0000000000..cdf2393f77 --- /dev/null +++ b/Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto @@ -0,0 +1,12 @@ +local int = require "int" +require "rat" + +local one = rat.of(1) +print("The following numbers (less than 2^19) are perfect:") +for i = 2, (1 << 19) - 1 do + local sum = rat.of(1, i) + local divs = int.divisors(i, true) + divs:remove(1) + for divs as j do sum += rat.of(1, j) end + if sum == one then print($" {i}") end +end diff --git a/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx index a7f3438a50..bde84235e2 100644 --- a/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx +++ b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx @@ -1,64 +1,63 @@ +-- 28 Jul 2025 include Settings -say 'RATIONAL ARITHMETIC - 2 Mar 2025' +say 'RATIONAL ARITHMETIC' say version say a = '1 2'; b = '-3 4'; c = '5 -6'; d = '-7 -8'; e = 3; f = 1.666666666 say 'VALUES' -say 'a =' Rlst2form(a) -say 'b =' Rlst2form(b) -say 'c =' Rlst2form(c) -say 'd =' Rlst2form(d) +say 'a =' Lst2FormQ(a) +say 'b =' Lst2FormQ(b) +say 'c =' Lst2FormQ(c) +say 'd =' Lst2FormQ(d) say 'e =' e say 'f =' f say say 'BASICS' -say 'a+b =' Rlst2form(Radd(a,b)) -say 'a+b+c+d =' Rlst2form(Radd(a,b,c,d)) -say 'a-b =' Rlst2form(Rsub(a,b)) -say 'a-b-c-d =' Rlst2form(Rsub(a,b,c,d)) -say 'a*b =' Rlst2form(Rmul(a,b)) -say 'a*b*c*d =' Rlst2form(Rmul(a,b,c,d)) -say 'a/b =' Rlst2form(Rdiv(a,b)) -say 'a/b/c/d =' Rlst2form(Rdiv(a,b,c,d)) -say '-a =' Rlst2form(Rneg(a)) -say '1/a =' Rlst2form(Rinv(a)) +say 'a+b =' Lst2FormQ(AddQ(a,b)) +say 'a+b+c+d =' Lst2FormQ(AddQ(a,b,c,d)) +say 'a-b =' Lst2FormQ(SubQ(a,b)) +say 'a-b-c-d =' Lst2FormQ(SubQ(a,b,c,d)) +say 'a*b =' Lst2FormQ(MulQ(a,b)) +say 'a*b*c*d =' Lst2FormQ(MulQ(a,b,c,d)) +say 'a/b =' Lst2FormQ(DivQ(a,b)) +say 'a/b/c/d =' Lst2FormQ(DivQ(a,b,c,d)) +say '-a =' Lst2FormQ(NegQ(a)) +say '1/a =' Lst2FormQ(InvQ(a)) say -say 'COMPARE' -say 'a=b =' Rge(a,b) -say 'a>b =' Rgt(a,b) -say 'a<>b =' Rne(a,b) +say 'Compare' +say 'a=b =' GeQ(a,b) +say 'a>b =' GtQ(a,b) +say 'a<>b =' NeQ(a,b) say say 'BONUS' -say 'Abs(c) =' Rlst2form(Rabs(c)) -say 'Float(b) =' Rfloat(b) -say 'Neg(d) =' Rlst2form(Rneg(d)) -say 'Power(a,e) =' Rlst2form(Rpow(a,e)) -say 'Rational(f) =' Rlst2form(Rrat(f)) +say 'Abs(c) =' Lst2FormQ(AbsQ(c)) +say 'Float(b) =' FloatQ(b) +say 'Neg(d) =' Lst2FormQ(NegQ(d)) +say 'Power(a,e) =' Lst2FormQ(PowQ(a,e)) +say 'Rational(f) =' Lst2FormQ(RatQ(f)) say say 'FORMULA' say 'a^2-2ab+3c-4ad^4+5 = ', -Rlst2form(Radd(Rpow(a,2),Rmul(-2,a,b),Rmul(3,c),Rmul(-4,a,Rpow(d,4)),5)) +Lst2FormQ(AddQ(PowQ(a,2),MulQ(-2,a,b),MulQ(3,c),MulQ(-4,a,PowQ(d,4)),5)) say -say 'PERFECT NUMBERS' -call time('r') +say 'Perfect numbers' +call Time('r') numeric digits 20 do c = 6 to 2**19 s = 1 c; m = Isqrt(c) do f = 2 to m if c//f = 0 then do - s = Radd(s,1 f,1 c/f) + s = AddQ(s,1 f,1 c/f) end end - if Req(s,1) then + if EqQ(s,1) then say c 'is a perfect number' end -say time('e')/1's' +say Time('e')/1's' exit -include Rational -include Functions -include Abend +include Math diff --git a/Task/Arithmetic-derivative/Bc/arithmetic-derivative.bc b/Task/Arithmetic-derivative/Bc/arithmetic-derivative.bc new file mode 100644 index 0000000000..2fd8905b3f --- /dev/null +++ b/Task/Arithmetic-derivative/Bc/arithmetic-derivative.bc @@ -0,0 +1,25 @@ +define d(n) { + auto f + if(n<0) return -d(-n) + if(n<2) return 0 + s = 0 + r = n + for(f=2;f<=r;f++) { + while(r%f==0){ + r /= f + s += n / f + } + } + return s +} + +define padl(n,f) { + for(i=0;i - $40 { // ( + $40 : { // ( ^ weak self.newBracket().gotoStarting() } - ! { + ! : { ^ weak self.newToken().append(ch).gotoToken() } } @@ -108,22 +108,22 @@ singleton tokenState eval(ch) { ch => - $41 { // ) + $41 : { // ) ^ weak self.closeBracket().gotoToken() } - $42 { // * + $42 : { // * ^ weak self.newProduct().gotoOperator() } - $43 { // + + $43 : { // + ^ weak self.newSummary().gotoOperator() } - $45 { // - + $45 : { // - ^ weak self.newDifference().gotoOperator() } - $47 { // / + $47 : { // / ^ weak self.newFraction().gotoOperator() } - ! { + ! : { ^ weak self.append(ch) } } @@ -134,13 +134,13 @@ singleton startState eval(ch) { ch => - $40 { // ( + $40 : { // ( ^ weak self.newBracket().gotoStarting() } - $45 { // - + $45 : { // - ^ weak self.newToken().append("0").newDifference().gotoOperator() } - ! { + ! : { ^ weak self.newToken().append(ch).gotoToken() } } @@ -148,11 +148,11 @@ singleton startState class Scope { - object _state; - int _level; - object _parser; - object _token; - object _expression; + object _state; + int _level; + object _parser; + object? _token; + object _expression; constructor new(parser) { @@ -327,15 +327,15 @@ public program() var text := new StringWriter(); var parser := new Parser(); - while (console.readLine().writeTo(text).Length > 0) + while (Console.readLine().writeTo(text).Length > 0) { try { - console.printLine("=",parser.run(text)) + Console.printLine("=",parser.run(text)) } catch(Exception e) { - console.writeLine("Invalid Expression") + Console.writeLine("Invalid Expression") }; text.clear() diff --git a/Task/Arithmetic-evaluation/PascalABC.NET/arithmetic-evaluation.pas b/Task/Arithmetic-evaluation/PascalABC.NET/arithmetic-evaluation.pas new file mode 100644 index 0000000000..b19c2a67d1 --- /dev/null +++ b/Task/Arithmetic-evaluation/PascalABC.NET/arithmetic-evaluation.pas @@ -0,0 +1,127 @@ +type + IExprNode = interface + function Evaluate: real; + end; + + NumberNode = auto class(IExprNode) + public + value: real; + function Evaluate: real := value; + end; + + BinaryOpNode = auto class(IExprNode) + public + op: char; + left, right: IExprNode; + + function Evaluate: real; + begin + case op of + '+': Result := left.Evaluate + right.Evaluate; + '-': Result := left.Evaluate - right.Evaluate; + '*': Result := left.Evaluate * right.Evaluate; + '/': Result := left.Evaluate / right.Evaluate; + else + raise new Exception($'Unknown operator {op}'); + end; + end; + end; + + ExpressionParser = class + s: string; + pos: integer; + + constructor Create(input: string); + begin + s := input; + pos := 1; + end; + + function NextChar: char := + if pos <= s.Length then s[pos] else #0; + + procedure SkipSpaces := + while NextChar = ' ' do pos += 1; + + function ParseNumber: IExprNode; + begin + SkipSpaces; + var start := pos; + while NextChar.IsDigit do pos += 1; + if NextChar = '.' then + begin + pos += 1; + while NextChar.IsDigit do pos += 1; + end; + var value := s[start:pos].ToReal; + Result := new NumberNode(value); + end; + + function ParseFactor: IExprNode; + begin + SkipSpaces; + if NextChar = '(' then + begin + pos += 1; + Result := ParseExpr; + SkipSpaces; + if NextChar = ')' then + pos += 1 + else raise new Exception('Expected )'); + end + else + Result := ParseNumber; + end; + + function ParseTerm: IExprNode; + begin + Result := ParseFactor; + while true do + begin + SkipSpaces; + var ch := NextChar; + if (ch = '*') or (ch = '/') then + begin + pos += 1; + Result := new BinaryOpNode(ch, Result, ParseFactor); + end + else break; + end; + end; + + function ParseExpr: IExprNode; + begin + Result := ParseTerm; + while true do + begin + SkipSpaces; + var ch := NextChar; + if (ch = '+') or (ch = '-') then + begin + pos += 1; + Result := new BinaryOpNode(ch, Result, ParseTerm); + end + else break; + end; + end; + + function Parse: IExprNode := ParseExpr; + + end; + +begin + var inputs := [ + '2+3*(4-1)', + '10 + 2 / 3', + '(7+3)*(2+2)', + '8*(5+(2-3))', + '1/3', + '2.5 + 4.1 * (3 - 1.1/2)']; + + foreach var expr in inputs do + begin + var parser := new ExpressionParser(expr); + var tree := parser.Parse; + Println($'{expr} = {tree.Evaluate:0.###}'); + end; +end. diff --git a/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl b/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-1.pl similarity index 100% rename from Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl rename to Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-1.pl diff --git a/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-2.pl b/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-2.pl new file mode 100644 index 0000000000..47161a8da0 --- /dev/null +++ b/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation-2.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use strict; # https://rosettacode.org/wiki/Arithmetic_evaluation +use warnings; + +sub node { bless [ splice @_, 1 ], shift } +sub error { die s/\G.*//sr =~ tr/\t/ /cr, "^ @_ !\n" } +sub want { /\G$_[1]/gc ? shift : error pop } + +sub expr + { + /\G\h+/gc; + my $ast = + /\G\d+/gc ? node NUMBER => $& : + /\G\(/gc ? want expr(0), qr/\)/, 'Missing Right Paren' : + error 'Operand Expected'; + /\G\h+/gc, $ast = + $_[0] <= 0 && /\G\+/gc ? node ADD => $ast, expr(1) : + $_[0] <= 0 && /\G\-/gc ? node SUBTRACT => $ast, expr(1) : + $_[0] <= 1 && /\G\*/gc ? node MULTIPLY => $ast, expr(2) : + $_[0] <= 1 && /\G\//gc ? node DIVIDE => $ast, expr(2) : + return $ast while 1; + } + +sub ADD::value { $_[0][0]->value + $_[0][1]->value } +sub SUBTRACT::value { $_[0][0]->value - $_[0][1]->value } +sub MULTIPLY::value { $_[0][0]->value * $_[0][1]->value } +sub DIVIDE::value { $_[0][0]->value / $_[0][1]->value } +sub NUMBER::value { $_[0][0] } + +sub NUMBER::show { "$_[0][0]\n" } +sub UNIVERSAL::show + { ref($_[0]) . "\n" . join('', map $_->show, @{$_[0]}) =~ s/^/ /gmr } + +while( ) + { + eval + { + print; + my $ast = want expr(0), "\n", 'Incomplete Parse'; + print $ast->show, "value of ast = ", $ast->value, "\n\n"; + } or print "$@\n"; + } + +__DATA__ +(1+3)*7 +2 * 3 + 4 * 5 +2 + 3 * 4 + 5 +2 + 3 ** 4 + 5 diff --git a/Task/Arithmetic-evaluation/Red/arithmetic-evaluation.red b/Task/Arithmetic-evaluation/Red/arithmetic-evaluation.red new file mode 100644 index 0000000000..d672f8909b --- /dev/null +++ b/Task/Arithmetic-evaluation/Red/arithmetic-evaluation.red @@ -0,0 +1,113 @@ +Red [ "Arithmetic Evaluator - Hinjo, August 2025" + {Using a Modified Shunting-Yard algorithm to produce S-Expression as the AST + and a simple S-Expression evaluator (recursive).} +] + +s-expr: function [expr [string!] /trace] [ + output: copy [] ops: copy [] + prec: #["+" 2 "-" 2 "*" 3 "/" 3 "^^" 4] + asc: #["+" "L" "-" "L" "*" "L" "/" "L" "^^" "R"] + + stats: function [t] [ + if not trace [exit] + print [t "|" pad act 25 "|" pad (mold output) 45 pad/left (reverse form ops) 15] + ] + + make-node: function [op] [ + right: take/last output + left: take/last output + node: load rejoin ["[" op " " mold left " " mold right "]"] + node + ] + + tokens: split expr " " + while [not empty? tokens] [ + tok: first tokens tokens: next tokens + case [ + find "0123456789" tok [ + act: "1.Push number as value" + append output load tok + stats tok + ] + tok = "(" [ + act: "2.Push ( to ops" + append ops tok + stats tok + ] + tok = ")" [ + while [(last ops) <> "("] [ + act: "3.Pop op, build node" + append/only output make-node take/last ops + stats tok + ] + act: "4.Discard (" + take/last ops + stats tok + ] + find "+-*/^^" tok [ + + popping: func [][ + if empty? ops [return false] + if none? last ops [return false] + last-op: last ops + if last-op = ")" [return false] + if none? prec/:last-op [return false] + return (prec/:last-op > prec/:tok) + or ((prec/:last-op = prec/:tok) + and (asc/:tok = "L")) + ] + + while [popping] [ + act: "5.Pop op, build node" + append/only output make-node take/last ops + stats tok + ] + act: "6.Push current op" + append ops tok + stats tok + ] + ] + ] + act: "7.Final flush ops" + stats " " + while [not empty? ops] [ + act: "8.Pop op, build node" + append/only output make-node take/last ops + stats " " + ] + output/1 +] + +; basic s-expression evaluator +s-eval: function [expr][ + either block? expr [ + op: expr/1 + a: s-eval expr/2 + b: s-eval expr/3 + case [ + op = '+ [a + b] + op = '- [a - b] + op = '* [a * b] + op = '/ [a / b] + op = '^ [a ** b] + true [do make error! rejoin ["Unknown operator: " mold op]] + ] + ][ + expr ; base case: just a number + ] +] + +print "Simple test:" +s: "1 + 2" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] +s: "1 + 2 * 3" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] +s: "( 1 + 2 ) * 3" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] +s: "( 1 + 2 * 3 ) / 2" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] + +print "^/Complex ones:" +s: "3 + 4 * 2 / ( 1 - 5 ) ^^ 2 ^^ 3" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] +s: "( 1 + 2 * 3 ) ^^ 2 / 6 ^^ 2 ^^ 3 - 1" se: s-expr s print [pad s 40 " ==> " pad (mold se) 45 " = " s-eval se] + +print "^/Some test for input and output with trace:" +print ["^/" s: "3 + 4 * 2 / ( 1 - 5 ) ^^ 2 ^^ 3"] se: s-expr/trace s print [s " ==> " mold se " = " s-eval se] +print ["^/" s: "( ( 1 + 2 ) ^^ ( 3 + 4 ) ) ^^ ( 5 + 6 )"] se: s-expr/trace s print [s " ==> " mold se " = " s-eval se] +print ["^/" s: "1 + 2 * 3 / 4 + 5"] se: s-expr/trace s print [s " ==> " mold se " = " s-eval se] diff --git a/Task/Arithmetic-geometric-mean/ALGOL-68/arithmetic-geometric-mean.alg b/Task/Arithmetic-geometric-mean/ALGOL-68/arithmetic-geometric-mean.alg index f41fbacd2a..18ca866f48 100644 --- a/Task/Arithmetic-geometric-mean/ALGOL-68/arithmetic-geometric-mean.alg +++ b/Task/Arithmetic-geometric-mean/ALGOL-68/arithmetic-geometric-mean.alg @@ -19,5 +19,5 @@ BEGIN a FI END; - printf (($l(-35,33)l$, agm (LONG 1.0, LONG 1.0 / long sqrt (LONG 2.0)))) + printf (($lg(-35,33)l$, agm (LONG 1.0, LONG 1.0 / long sqrt (LONG 2.0)))) END diff --git a/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-1.duckdb b/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-1.duckdb new file mode 100644 index 0000000000..92b0794da3 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-1.duckdb @@ -0,0 +1,12 @@ +with recursive + rec(rn, a, g, diff) as ( + select 1, 1.0, 1/sqrt(2), 1 - 1/sqrt(2) + union all + select rn + 1, (a + g)/2, sqrt(a * g), (a + g)/2 - sqrt(a * g) + from rec + where diff > 1e-15 + ) +select * +from rec +where diff <= 1e-15 +; diff --git a/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-2.duckdb b/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-2.duckdb new file mode 100644 index 0000000000..3c8c0277bd --- /dev/null +++ b/Task/Arithmetic-geometric-mean/DuckDB/arithmetic-geometric-mean-2.duckdb @@ -0,0 +1,14 @@ +create or replace function agm(a0, g0) as ( +with recursive + rec as ( + select a0::DOUBLE as a, g0::DOUBLE as g, a - g as diff + union all + select a, g, (a - g) as diff + from ( select ((a + g)/2) as a, sqrt(a * g) as g, diff + from rec ) + where diff > 1e-15 ) + select (a + g)/2 + from rec + where diff <= 1e-15 + limit 1 +); diff --git a/Task/Arithmetic-geometric-mean/Pluto/arithmetic-geometric-mean.pluto b/Task/Arithmetic-geometric-mean/Pluto/arithmetic-geometric-mean.pluto new file mode 100644 index 0000000000..cc3914b6c2 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Pluto/arithmetic-geometric-mean.pluto @@ -0,0 +1,10 @@ +$define EPS = 1e-14 + +local function agm(a, g) + while math.abs(a - g) > math.abs(a) * EPS do + a, g = (a + g) / 2, math.sqrt(a * g) + end + return a +end + +print(agm(1.0, 1.0 /math.sqrt(2))) diff --git a/Task/Arithmetic-numbers/DuckDB/arithmetic-numbers.duckdb b/Task/Arithmetic-numbers/DuckDB/arithmetic-numbers.duckdb new file mode 100644 index 0000000000..4aea7d6141 --- /dev/null +++ b/Task/Arithmetic-numbers/DuckDB/arithmetic-numbers.duckdb @@ -0,0 +1,70 @@ +### Preliminaries +# If x is NULL then raise an error condition: +create or replace function try(x, ErrorMessage) as ( + if( x IS NULL, error( ErrorMessage ), x ) +); + +create or replace function proper_divisors(n) as table ( + select 1 where n > 1 + union all + select distinct i + from (select unnest( [ j, n // j]) as i + from range(2, 1 + sqrt(n).floor()::BIGINT) as t(j) + where (n % j) == 0) +); + +create or replace function composite(n) as ( + select count(*) == 2 as n from (from proper_divisors(n) limit 2) +); + +create or replace function average_is_integral(lst) as ( + list_sum(lst) % length(lst) = 0 +); + +create or replace function list_of_proper_divisors(n) as ( + select coalesce(array_agg(i), []) as divisors from proper_divisors(n) t(i) +); + + +### Arithmetic numbers +# A table of the arithmetic numbers in range(1, mx) +create or replace function arithmetic_numbers(mx) as table ( + select n + from range(1, mx) t(n) + where average_is_integral(list_of_proper_divisors(n) || [n]) + order by n -- needed +); + +# A table (n, composite) of the arithmetic numbers in range(1, mx) showing also whether each is composite +create or replace function describe_arithmetic_numbers(mx) as table ( + select n, length(lst) > 1 as composite + from + (select n, list_of_proper_divisors(n) as lst + from range(1, mx) t(n) + where average_is_integral(lst || [n]) + order by n -- needed + ) +); + +# Return a struct {nth, composites} giving the nth arithmetic number +# and the number of composites less than or equal to that number. +# If the heuristic fails, an error is raised. +create or replace function describe_nth_arithmetic_number(nth) as ( + with cte as (from describe_arithmetic_numbers(nth * 2) limit nth) + select try( + (select { nth: (select last(n) from cte), + composites: (select count(*) from cte where composite = true)} + where nth = (select count(*) from cte)), + 'heuristic failure') +); + +# Return a list of the first `number` arithmetic numbers using a +# heuristic cautiously +create or replace function arithmetic_numbers_list(number) as ( + with cte as (from describe_arithmetic_numbers(number * 2 ) limit number), + m as (select count(*) as m from cte) + select try( + if (m = number, (select array_agg(n) from cte), null), + 'heuristic failure' ) + from m +); diff --git a/Task/Array-concatenation/ArkScript/array-concatenation.ark b/Task/Array-concatenation/ArkScript/array-concatenation.ark new file mode 100644 index 0000000000..41ea61f667 --- /dev/null +++ b/Task/Array-concatenation/ArkScript/array-concatenation.ark @@ -0,0 +1,4 @@ +(let a [1 2 3]) +(let b [4 5 6]) + +(assert (= (concat a b) [1 2 3 4 5 6]) "array concatenation") diff --git a/Task/Array-concatenation/DuckDB/array-concatenation.duckdb b/Task/Array-concatenation/DuckDB/array-concatenation.duckdb new file mode 100644 index 0000000000..1502edf1f9 --- /dev/null +++ b/Task/Array-concatenation/DuckDB/array-concatenation.duckdb @@ -0,0 +1,4 @@ +# Concatenate two JSON arrays to produce an instance of JSON[] +create or replace function jsonarray2list(j) as ( + select list_transform(range(0, json_array_length(j)::BIGINT), i -> (j -> i)) +); diff --git a/Task/Array-concatenation/Elena/array-concatenation.elena b/Task/Array-concatenation/Elena/array-concatenation.elena index 4d412e7dbb..41d210bd59 100644 --- a/Task/Array-concatenation/Elena/array-concatenation.elena +++ b/Task/Array-concatenation/Elena/array-concatenation.elena @@ -5,7 +5,7 @@ public program() var a := new int[]{1,2,3}; var b := new int[]{4,5}; - console.printLine( + Console.printLine( "(",a.asEnumerable(),") + (",b.asEnumerable(), ") = (",(a + b).asEnumerable(),")").readChar(); } diff --git a/Task/Array-concatenation/Pluto/array-concatenation.pluto b/Task/Array-concatenation/Pluto/array-concatenation.pluto new file mode 100644 index 0000000000..e110f3faff --- /dev/null +++ b/Task/Array-concatenation/Pluto/array-concatenation.pluto @@ -0,0 +1,12 @@ +local array1 = {1, 2, 3} +local array2 = {4, 5, 6} + +-- Concatenate to a new array. +local array3 = {} +table.move(array1, 1, #array1, 1, array3) +table.move(array2, 1, #array2, #array3 + 1, array3) +print(array3:concat(", ")) + +-- Merge second into first array. +table.move(array2, 1, #array2, #array1 + 1, array1) +print(array1:concat(", ")) diff --git a/Task/Array-concatenation/TAV/array-concatenation.tav b/Task/Array-concatenation/TAV/array-concatenation.tav new file mode 100644 index 0000000000..b9f873d11c --- /dev/null +++ b/Task/Array-concatenation/TAV/array-concatenation.tav @@ -0,0 +1,3 @@ + a1 =: tuple 1, 2, 3 as row + row a1 append 4, 5, 6 \ append tuple elements to a row + print join a1 diff --git a/Task/Array-length/ArkScript/array-length.ark b/Task/Array-length/ArkScript/array-length.ark new file mode 100644 index 0000000000..1cd019c302 --- /dev/null +++ b/Task/Array-length/ArkScript/array-length.ark @@ -0,0 +1,2 @@ +(assert (= (len []) 0) "len of empty array is 0") +(assert (= (len [1 2 3 4]) 4) "len of array is 4") diff --git a/Task/Array-length/DuckDB/array-length.duckdb b/Task/Array-length/DuckDB/array-length.duckdb new file mode 100644 index 0000000000..dde1b2e9f1 --- /dev/null +++ b/Task/Array-length/DuckDB/array-length.duckdb @@ -0,0 +1 @@ +select length( ['apple', 'orange' ] ) as length; diff --git a/Task/Array-length/M2000-Interpreter/array-length.m2000 b/Task/Array-length/M2000-Interpreter/array-length.m2000 index 55bd640ccf..d3bf86ac9d 100644 --- a/Task/Array-length/M2000-Interpreter/array-length.m2000 +++ b/Task/Array-length/M2000-Interpreter/array-length.m2000 @@ -1,38 +1,3 @@ \\ A is a pointer to array A=("Apple", "Orange") Print Len(A)=2 ' True -Print Dimension(A, 0) ' LBound (0 or 1), here 0 -Print Dimension(A) ' No of Dimensions 1 -Print Dimension(A, 1) ' for 1 dimension array this is also Length=2 -\\ A$( ) is an Array (not a pointer to array) -Dim Base 1, A$(2) -A$(1)="Apple", "Orange" -Print Dimension(A$(), 0) ' LBound (0 or 1), here 1 -Print Dimension(A$()) ' No of Dimensions 1 -Print Dimension(A$(), 1) ' for 1 dimension array this is also Length=2 -Link A to B$() ' B$() is a reference to A -Print B$(0)=A$(1) -Print B$(1)=A$(2) -Dim C$() -\\ C$() get a copy of B$() -C$()=B$() -Print C$() ' prints Apple Orange -\\ An array can link to a new name as reference, and can change major type -\\ here A$() get A() so we can read/store numbers and read/store strings in same array -\\ using two names -Link A$() to A() -\\ An array pointer can point to another array -A=A() -Print Dimension(A, 0) ' LBound (0 or 1), here 1 (was 0) -\\ Because B$() is reference of A: -Print Dimension(B$(), 0) ' LBound (0 or 1), here 1 (was 0) -Print B$(1)=A$(1) -Print B$(2)=A$(2) -Print Dimension(C$(), 0) ' LBound (0 or 1), here 0 -\\ change base preserve items -Dim Base 1, C$(Dimension(C$(), 1)) -Print Dimension(C$(), 0) ' LBound (0 or 1), here 1 (was 0) -Print C$() ' prints Apple Orange -Print Len(C$()) ' Len return all items of an array - can be 0 -Dim K(1,1,1,1,1,1) ' Maximum 10 dimensions -Print Len(K()=1 ' True diff --git a/Task/Array-length/Maxima/array-length.maxima b/Task/Array-length/Maxima/array-length.maxima new file mode 100644 index 0000000000..56cfb97fe9 --- /dev/null +++ b/Task/Array-length/Maxima/array-length.maxima @@ -0,0 +1,4 @@ +length(["apple","orange"]); +fruits: matrix(["apple","orange"],["banana","pear"])$ +length(fruits); +length(list_matrix_entries(fruits)); diff --git a/Task/Array-length/TAV/array-length.tav b/Task/Array-length/TAV/array-length.tav new file mode 100644 index 0000000000..a54c8b0a26 --- /dev/null +++ b/Task/Array-length/TAV/array-length.tav @@ -0,0 +1 @@ +print ('apple', 'orange').Count diff --git a/Task/Array-length/Tcl/array-length-1.tcl b/Task/Array-length/Tcl/array-length-1.tcl new file mode 100644 index 0000000000..1fe942888c --- /dev/null +++ b/Task/Array-length/Tcl/array-length-1.tcl @@ -0,0 +1 @@ +set mylist { item1 item2 item3 } diff --git a/Task/Array-length/Tcl/array-length-2.tcl b/Task/Array-length/Tcl/array-length-2.tcl new file mode 100644 index 0000000000..2abd436f52 --- /dev/null +++ b/Task/Array-length/Tcl/array-length-2.tcl @@ -0,0 +1 @@ +set furniture "chair table lamp sofa bed desk" diff --git a/Task/Array-length/Tcl/array-length-3.tcl b/Task/Array-length/Tcl/array-length-3.tcl new file mode 100644 index 0000000000..36b3b6edee --- /dev/null +++ b/Task/Array-length/Tcl/array-length-3.tcl @@ -0,0 +1,5 @@ +set paths [split "/sbin:/bin:/usr/bin:/usr/local/bin:$home/bin" ":"] + +foreach p $paths { + puts "$p" +} diff --git a/Task/Array-length/Tcl/array-length-4.tcl b/Task/Array-length/Tcl/array-length-4.tcl new file mode 100644 index 0000000000..3ed1cddf82 --- /dev/null +++ b/Task/Array-length/Tcl/array-length-4.tcl @@ -0,0 +1,2 @@ +set A {} +set B [list] diff --git a/Task/Array-length/Tcl/array-length-5.tcl b/Task/Array-length/Tcl/array-length-5.tcl new file mode 100644 index 0000000000..b1f7c4fab0 --- /dev/null +++ b/Task/Array-length/Tcl/array-length-5.tcl @@ -0,0 +1 @@ + set var 5 ;# ($var is the string "5", or the integer 5 , or a list with one item {5} ) diff --git a/Task/Array-length/Tcl/array-length-6.tcl b/Task/Array-length/Tcl/array-length-6.tcl new file mode 100644 index 0000000000..e6250e3fd2 --- /dev/null +++ b/Task/Array-length/Tcl/array-length-6.tcl @@ -0,0 +1,5 @@ +set len [llength "Apples Oranges"] ;# 2 +set len [llength {Apples Oranges}] ;# 2 +set fruit { apples oranges cherries bananas} +set len [llength $fruit] +puts stdout "($len) : $fruit" diff --git a/Task/Array-length/Tcl/array-length-7.tcl b/Task/Array-length/Tcl/array-length-7.tcl new file mode 100644 index 0000000000..2042a29d9f --- /dev/null +++ b/Task/Array-length/Tcl/array-length-7.tcl @@ -0,0 +1,10 @@ +# The ''lindex'' command returns a single item at a given index of a list + +set c [lindex $fruit 2] ;# "cherries" (0-based index) + +# The ''lrange'' command returns a given range of items from a list, as a new list. + +set A [lrange $fruit 0 2] ;# {apples oranges cherries} (list) + +# An empty list is not necessarily an empty string: +set var { } ;# $var => " ", but [llength $var] => 0 diff --git a/Task/Array-length/Tcl/array-length.tcl b/Task/Array-length/Tcl/array-length.tcl deleted file mode 100644 index 5b7cf51645..0000000000 --- a/Task/Array-length/Tcl/array-length.tcl +++ /dev/null @@ -1,13 +0,0 @@ -;# not recommended: -set mylistA {apple orange} ;# actually a string -set mylistA "Apple Orange" ;# same - this works only for simple cases - -set lenA [llength $mylistA] -puts "$mylistA : $lenA" - -# better: to build a list, use 'list' and/or 'lappend': -set mylistB [list apple orange "red wine" {green frog}] -lappend mylistB "blue bird" - -set lenB [llength $mylistB] -puts "$mylistB : $lenB" diff --git a/Task/Arrays/BBC-BASIC/arrays.basic b/Task/Arrays/BBC-BASIC/arrays.basic index 508e04a217..eaf82c4ae8 100644 --- a/Task/Arrays/BBC-BASIC/arrays.basic +++ b/Task/Arrays/BBC-BASIC/arrays.basic @@ -15,3 +15,8 @@ PRINT array(2) TAB(16) array(3) TAB(32) array(4) PRINT array%(2) TAB(16) array%(3) TAB(32) array%(4) PRINT array$(2) TAB(16) array$(3) TAB(32) array$(4) + + REM Some versions of BBC BASIC support array slicing: + array(2 TO 4) = source(1 TO 3) + array(3 TO 5) = 2, 4, -1 + array(3 TO 5) = array(4 TO 6) diff --git a/Task/Arrays/DuckDB/arrays.duckdb b/Task/Arrays/DuckDB/arrays.duckdb new file mode 100644 index 0000000000..b580ce44c0 --- /dev/null +++ b/Task/Arrays/DuckDB/arrays.duckdb @@ -0,0 +1,9 @@ +# Insert `value` after row i (using IO=1) in a one-column table named t (a string). +create or replace function insert_after(i, value, t) as table ( + (FROM query_table(t) LIMIT i) + union all + select value + union all (FROM query_table(t) OFFSET i) +); + +from insert_after_row(1, 100, 't'); diff --git a/Task/Arrays/Elena/arrays-5.elena b/Task/Arrays/Elena/arrays-5.elena index 9b69e70cb8..ae97e67492 100644 --- a/Task/Arrays/Elena/arrays-5.elena +++ b/Task/Arrays/Elena/arrays-5.elena @@ -1,3 +1,3 @@ - system'console.writeLine(array[0]); - system'console.writeLine(stackAllocatedArray[1]); - system'console.writeLine(dynamicArray[2]); + system'Console.writeLine(array[0]); + system'Console.writeLine(stackAllocatedArray[1]); + system'Console.writeLine(dynamicArray[2]); diff --git a/Task/Arrays/Extended-Color-BASIC/arrays.basic b/Task/Arrays/Extended-Color-BASIC/arrays.basic new file mode 100644 index 0000000000..0f32fa7335 --- /dev/null +++ b/Task/Arrays/Extended-Color-BASIC/arrays.basic @@ -0,0 +1,4 @@ +10 DIM A(10), B$(10) +20 A(1) = 42 +30 B$(10) = "TOWEL" +40 PRINT A(1), B$(10) diff --git a/Task/Arrays/Haxe/arrays.haxe b/Task/Arrays/Haxe/arrays.haxe new file mode 100644 index 0000000000..8fccc28c0e --- /dev/null +++ b/Task/Arrays/Haxe/arrays.haxe @@ -0,0 +1,22 @@ +class Main { + static public function main():Void { + // Array (dynamic length) + var a = new Array(); + for (i in 1...4) + a.push(i); + // alt: var a = [1, 2, 3]; + // alt2: var a = [for (i in 1...4)]; + + for (i in 0...a.length) + trace(a[i]); + + // Vector (fixed-length) + var v = new haxe.ds.Vector(3); + v[0] = 1; + v[1] = 2; + v[2] = 3; + + for (i in 0...v.length) + trace(v[i]); + } +} diff --git a/Task/Arrays/Pluto/arrays.pluto b/Task/Arrays/Pluto/arrays.pluto new file mode 100644 index 0000000000..c7544909c7 --- /dev/null +++ b/Task/Arrays/Pluto/arrays.pluto @@ -0,0 +1,8 @@ +local array = {} +array:insert(42) +array:insert(43) +print(array:concat(", ")) -- 42, 43 +print(array[1]) -- 42, since indexing starts at 1 +print(#array) -- 2, since # is the length operator +array:clear() +print(#array) -- 0 diff --git a/Task/Arrays/REXX/arrays.rexx b/Task/Arrays/REXX/arrays.rexx index 74e20f3ddc..6f758adf93 100644 --- a/Task/Arrays/REXX/arrays.rexx +++ b/Task/Arrays/REXX/arrays.rexx @@ -1,56 +1,59 @@ --- 1 Jun 2025 +-- 7 Aug 2025 include Settings say 'ARRAYS' say version say -say 'A simple array...' -do i = 1 to 100 +if Pos('Regina',version) > 0 then + call Library +say 'Simple array...' +do i = 1 to 10 a.i=i*i end -say 'Square of' 5 'is' a.5 -say 'Square of' 55 'is' a.55 +say 'Square of' 3 'is' a.3 +say 'Square of' 7 'is' a.7 say say 'Mimic indexing...' -say 'Square of' 5 'is' a(5) -say 'Square of' 55 'is' a(55) +say 'Square of' 3 'is' a(3) +say 'Square of' 7 'is' a(7) say say 'A default value...' b. = 'Out of range' -do i = 1 to 100 +do i = 1 to 10 b.i=1/i end -say 'Inverse of' 5 'is' b.5 -say 'Inverse of' 55 'is' b.55 -say 'Inverse of' 555 'is' b.555 +say 'Inverse of' 3 'is' b.3 +say 'Inverse of' 7 'is' b.7 +say 'Inverse of' 11 'is' b.11 say -say 'An other index range...' -do i = -100 to 100 +say 'Index zero...' +do i = 1 to 10 c.i=i*i*i end -j=-55; say 'Cube of' j 'is' c.j -j=-5; say 'Cube of' j 'is' c.j -j=5; say 'Cube of' j 'is' c.j -j=55; say 'Cube of' j 'is' c.j +c.0=10 +j=0; say 'Number of rows is' c.j +j=3; say 'Cube of' j 'is' c.j +j=7; say 'Cube of' j 'is' c.j say -say 'A sparse array...' -d.='Not calculated' -do i = 2 by 2 to 100 +say 'Sparse array...' +d.=0 +do i = 3 by 3 to 9 d.i=-i end -say 'Negative of' 55 'is' d.55 -say 'Negative of' 56 'is' d.56 +say 'Negative of' 3 'is' d.3 +say 'Negative of' 7 'is' d.7 say -say 'Special indices...' -e.cat='civet'; say 'e.cat =' e.cat -a1='dog'; e.a1='pitbull' -a2=a1; say 'e.'a2 '=' e.a2 -a1='x.y.z'; e.a1='periods' -a2=a1; say 'e.'a2 '=' e.a2 -a1='x y z'; e.a1='spaces' -a2=a1; say 'e.'a2 '=' e.a2 -a1='└┴┬├─┼'; e.a1='specials' -a2=a1; say 'e.'a2 '=' e.a2 +say 'More dimensions...' +e.=0 +do i = 1 to 3 + do j = 1 to 3 + e.i.j=i*j + end +end +say '1x2 is' e.1.2 +say '3x2 is' e.3.2 +say +call SysDumpVariables say say 'Element has no value...' signal off novalue @@ -64,4 +67,11 @@ procedure expose a. arg xx return a.xx +Library: +say 'Library...' +call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs' +call SysLoadFuncs +say +return + include Abend diff --git a/Task/Arrays/Unicon/arrays-1.unicon b/Task/Arrays/Unicon/arrays-1.unicon new file mode 100644 index 0000000000..36bcabe0b8 --- /dev/null +++ b/Task/Arrays/Unicon/arrays-1.unicon @@ -0,0 +1 @@ +l := [: !&input :] # build a list of the lines read from standard input diff --git a/Task/Arrays/Unicon/arrays-2.unicon b/Task/Arrays/Unicon/arrays-2.unicon new file mode 100644 index 0000000000..b375465980 --- /dev/null +++ b/Task/Arrays/Unicon/arrays-2.unicon @@ -0,0 +1,6 @@ +procedure main() + L := [: 1 to 5:] + delete(L,4) + insert(L,2,"hello") + every write(!L) +end diff --git a/Task/Arrays/Unicon/arrays-3.unicon b/Task/Arrays/Unicon/arrays-3.unicon new file mode 100644 index 0000000000..856291bbb5 --- /dev/null +++ b/Task/Arrays/Unicon/arrays-3.unicon @@ -0,0 +1,3 @@ + L := list(5,0) + i := 0 + every !L := (i+:=1) diff --git a/Task/Arrays/Zig/arrays-1.zig b/Task/Arrays/Zig/arrays-1.zig new file mode 100644 index 0000000000..43a97f2473 --- /dev/null +++ b/Task/Arrays/Zig/arrays-1.zig @@ -0,0 +1,32 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + + // array literal + const array1 = [9]i32{ 0, 1, 1, 2, 3, 5, 7, 12, 21 }; + + // infer the size of the array + const array2 = [_]i32{ 0, 1, 1, 2, 3, 5, 7, 12, 21 }; + + // alternative initialization using result location + const array3: [9]i32 = .{ 0, 1, 1, 2, 3, 5, 7, 12, 21 }; + + // initialize an array with zeros using array multiplication + var array4 = [_]i32{0} ** 5; // array length: 5 + + // assign elements to an array (must be declared as a variable) + array4[0] = -12; + array4[2] = 345; + array4[4] = -6; + + // retieve elements from an array + try stdout.print("{d}, ", .{array4[0]}); + try stdout.print("{d}, ", .{array4[1]}); + try stdout.print("{d}, ", .{array4[2]}); + try stdout.print("{d}, ", .{array4[3]}); + try stdout.print("{d}\n", .{array4[4]}); + + // unused constants must be discarded + _ = array1; _ = array2; _ = array3; +} diff --git a/Task/Arrays/Zig/arrays-2.zig b/Task/Arrays/Zig/arrays-2.zig new file mode 100644 index 0000000000..474029db3b --- /dev/null +++ b/Task/Arrays/Zig/arrays-2.zig @@ -0,0 +1,21 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + + // ArrayLists are initialized in the heap + var array = std.ArrayList(i32).init(allocator); + defer array.deinit(); + + // pushing elements to an ArrayList + try array.append(-12); + try array.append(345); + try array.append(-7); + + // retrieving elements from an ArrayList + try stdout.print("{d}, ", .{array.items[0]}); + try stdout.print("{d}, ", .{array.items[1]}); + try stdout.print("{d}\n", .{array.items[2]}); +} diff --git a/Task/Ascending-primes/ArkScript/ascending-primes.ark b/Task/Ascending-primes/ArkScript/ascending-primes.ark new file mode 100644 index 0000000000..c5d1ce07ea --- /dev/null +++ b/Task/Ascending-primes/ArkScript/ascending-primes.ark @@ -0,0 +1,24 @@ +(import std.Math :sqrt :prime?) +(import std.List :iota) +(import std.String :join) +(import std.Range) + +(let ascending (fun (n f) { + (mut nums (iota 1 9)) + (mut i 0) + (mut matched []) + + (while (and (< (len matched) n) (< i (len nums))) { + (let val (@ nums i)) + (if (f val) + (append! matched val)) + + (mut r (range:range (+ 1 (mod val 10)) 10)) + (set r (range:map r (fun (k) (+ k (* 10 val))))) + (concat! nums r) + + (set i (+ 1 i)) }) + + matched })) + +(print (join (ascending 100 prime?) ", ")) diff --git a/Task/Ascending-primes/Pluto/ascending-primes.pluto b/Task/Ascending-primes/Pluto/ascending-primes.pluto new file mode 100644 index 0000000000..828f567f2f --- /dev/null +++ b/Task/Ascending-primes/Pluto/ascending-primes.pluto @@ -0,0 +1,24 @@ +require "map" +local int = require "int" +local fmt = require "fmt" + +local asc_primes = new set() -- avoids duplicates + +local function generate(first, cand, digits) + if digits == 0 then + if int.isprime(cand) then asc_primes:add(cand) end + return + end + local i = first + while i <= 9 do + local next = cand * 10 + i + generate(i + 1, next, digits - 1) + ++i + end +end + +for digits = 1, 9 do generate(1, 0, digits) end +asc_primes = asc_primes:keys() +asc_primes:sort() +print($"There are {#asc_primes} ascending primes, namely:") +fmt.tprint("%8d", asc_primes, 5) diff --git a/Task/Associative-array-Creation/ArkScript/associative-array-creation.ark b/Task/Associative-array-Creation/ArkScript/associative-array-creation.ark new file mode 100644 index 0000000000..32ff7c770a --- /dev/null +++ b/Task/Associative-array-Creation/ArkScript/associative-array-creation.ark @@ -0,0 +1,6 @@ +(import std.Dict) + +(let d (dict "key" "value" 5 12)) + +(print (dict:get d 5)) +(print (dict:get d "key")) diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-1.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-1.duckdb new file mode 100644 index 0000000000..1446b4df06 --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-1.duckdb @@ -0,0 +1,6 @@ +# Create a table to associate a key with 0 or more values +CREATE TABLE associative_array (KEY_COLUMN VARCHAR(10), VALUE_COLUMN VARCHAR(100)); +# Insert a Key Value pair +INSERT INTO associative_array (KEY_COLUMN, VALUE_COLUMN) VALUES ('KEY', 'VALUE'); +# Retrieve a key value pair +SELECT aa.value_column FROM associative_array aa where aa.key_column = 'KEY'; diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-2.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-2.duckdb new file mode 100644 index 0000000000..b88868f2bd --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-2.duckdb @@ -0,0 +1,5 @@ +CREATE TABLE associative_array (KEY_COLUMN VARCHAR, VALUE_COLUMN VARCHAR); +# Insert a Key Value pair +INSERT INTO associative_array VALUES ('KEY', 'VALUE'); +# Retrieve a key value pair +SELECT aa.value_column FROM associative_array aa where aa.key_column = 'KEY'; diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-3.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-3.duckdb new file mode 100644 index 0000000000..ce18cbb28a --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-3.duckdb @@ -0,0 +1 @@ +CREATE TABLE aa (KEY_COLUMN VARCHAR UNIQUE NOT NULL, VALUE_COLUMN VARCHAR NOT NULL); diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-4.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-4.duckdb new file mode 100644 index 0000000000..8c2a94853a --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-4.duckdb @@ -0,0 +1,3 @@ +INSERT into aa VALUES ('k', 1), ('l', 2); +from aa; +INSERT into aa VALUES ('k', 3); diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-5.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-5.duckdb new file mode 100644 index 0000000000..04cd514a5c --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-5.duckdb @@ -0,0 +1 @@ +SELECT aa FROM aa LIMIT 1; diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-6.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-6.duckdb new file mode 100644 index 0000000000..3e09d635b1 --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-6.duckdb @@ -0,0 +1 @@ +select unnest({'KEY_COLUMN': 'k', 'VALUE_COLUMN': 1}); diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-7.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-7.duckdb new file mode 100644 index 0000000000..7e94667264 --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-7.duckdb @@ -0,0 +1 @@ +SELECT info.* FROM (SELECT {'a': 1, 'b': 2 } as info); diff --git a/Task/Associative-array-Creation/DuckDB/associative-array-creation-8.duckdb b/Task/Associative-array-Creation/DuckDB/associative-array-creation-8.duckdb new file mode 100644 index 0000000000..c16b5ea5fd --- /dev/null +++ b/Task/Associative-array-Creation/DuckDB/associative-array-creation-8.duckdb @@ -0,0 +1 @@ +SELECT '{"a": 1, "A": 2}'::JSON as j; diff --git a/Task/Associative-array-Creation/Haxe/associative-array-creation.haxe b/Task/Associative-array-Creation/Haxe/associative-array-creation.haxe new file mode 100644 index 0000000000..3c680e9c0a --- /dev/null +++ b/Task/Associative-array-Creation/Haxe/associative-array-creation.haxe @@ -0,0 +1,7 @@ +class Main { + static public function main() { + var map = [1 => "one", 2 => "two"]; + trace(map); + $type(map); + } +} diff --git a/Task/Associative-array-Creation/Pluto/associative-array-creation.pluto b/Task/Associative-array-Creation/Pluto/associative-array-creation.pluto new file mode 100644 index 0000000000..2fe4836919 --- /dev/null +++ b/Task/Associative-array-Creation/Pluto/associative-array-creation.pluto @@ -0,0 +1,25 @@ +-- Create a map of key, value pairs. +local planets = { + Mercury = 1, + Venus = 2, + Earth = 3, + Mars = 4, + Jupiter = 5, + Saturn = 6, + Uranus = 7, + Neptune = 8, + Pluto = 9 +} + +-- Print it +-- Note that order is not guaranteed. +for k, v in planets do print(k, v) end +print() + +-- Create a new one by inverting the key, value pairs. +local planets2 = planets:invert() + +-- Print it. +-- Now treated as an array with indices 1 to 9 +-- which guarantees order. +for k, v in planets2 do print($"{k} {v}") end diff --git a/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx b/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx deleted file mode 100644 index 908c889146..0000000000 --- a/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx +++ /dev/null @@ -1,10 +0,0 @@ -/* Rexx */ - -key0 = '0' -key1 = 'key0' - -stem. = '.' /* Initialize the associative array 'stem' to '.' */ -stem.key1 = 'value0' /* Set a specific key/value pair */ - -Say 'stem.key0= 'stem.key /* Display a value for a key that wasn't set */ -Say 'stem.key1= 'stem.key1 /* Display a value for a key that was set */ diff --git a/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx b/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx deleted file mode 100644 index 6eef996e50..0000000000 --- a/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx +++ /dev/null @@ -1,27 +0,0 @@ -/*REXX program shows how to set/display values for an associative array.*/ -/*┌────────────────────────────────────────────────────────────────────┐ - │ The (below) two REXX statements aren't really necessary, but it │ - │ shows how to define any and all entries in a associative array so │ - │ that if a "key" is used that isn't defined, it can be displayed to │ - │ indicate such, or its value can be checked to determine if a │ - │ particular associative array element has been set (defined). │ - └────────────────────────────────────────────────────────────────────┘*/ -stateC.=' [not defined yet] ' /*sets any/all state capitols. */ -stateN.=' [not defined yet] ' /*sets any/all state names. */ -/*┌────────────────────────────────────────────────────────────────────┐ - │ In REXX, when a "key" is used, it's normally stored (internally) │ - │ as uppercase characters (as in the examples below). Actually, any │ - │ characters can be used, including blank(s) and non-displayable │ - │ characters (including '00'x, 'ff'x, commas, periods, quotes, ...).│ - └────────────────────────────────────────────────────────────────────┘*/ -stateC.ca='Sacramento'; stateN.ca='California' -stateC.nd='Bismarck' ; stateN.nd='North Dakota' -stateC.mn='St. Paul' ; stateN.mn='Minnesota' -stateC.dc='Washington'; stateN.dc='District of Columbia' -stateC.ri='Providence'; stateN.ri='Rhode Island and Providence Plantations' - -say 'capital of California is' stateC.ca -say 'capital of Oklahoma is' stateC.ok -yyy='RI' -say 'capital of' stateN.yyy "is" stateC.yyy - /*stick a fork in it, we're done.*/ diff --git a/Task/Associative-array-Creation/REXX/associative-array-creation.rexx b/Task/Associative-array-Creation/REXX/associative-array-creation.rexx new file mode 100644 index 0000000000..9aaddc689a --- /dev/null +++ b/Task/Associative-array-Creation/REXX/associative-array-creation.rexx @@ -0,0 +1,54 @@ +-- 8 Aug 2025 +include Settings + +say 'ASSOCIATIVE ARRAY: CREATION' +say version +say +say 'Basic examples...' +cap.='Unknown' +cap.be='Brussels' +cap.fr='Paris' +cap.uk='London' +call Capital 'BE' +call Capital 'UK' +call Capital 'NO' +day.='Unknown'; week.=day. +day.jan.2=2; week.jan.2=1 +day.mar.17=76; week.mar.17=12 +day.aug.7=219; week.aug.7=32 +call Calendar 'JAN',2 +call Calendar 'AUG',7 +call Calendar 'MAY',16 +say +say 'Keys can have any value...' +a.cat='civet'; say 'a.cat =' a.cat +a1='dog'; a.a1='pitbull' +a2=a1; say 'a.'a2 '=' a.a2 +a1='x.y.z'; a.a1='periods' +a2=a1; say 'a.'a2 '=' a.a2 +a1='x y z'; a.a1='spaces' +a2=a1; say 'a.'a2 '=' a.a2 +a1='ÀÁÂÃÄÅ'; a.a1='special characters' +a2=a1; say 'a.'a2 '=' a.a2 +say +if Pos('Regina',version) > 0 then + call Library +call SysDumpVariables +exit + +Capital: +arg country +say 'The capital of' country 'is' cap.country +return + +Calendar: +arg mm,dd +say mm dd 'is day no' day.mm.dd 'and week no' week.mm.dd +return + +Library: +call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs' +call SysLoadFuncs +return + +include Abend diff --git a/Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-2.sh b/Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-2.sh deleted file mode 100644 index 895c6026b1..0000000000 --- a/Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-2.sh +++ /dev/null @@ -1 +0,0 @@ -declare -A hash diff --git a/Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-1.sh b/Task/Associative-array-Creation/UNIX-Shell/associative-array-creation.sh similarity index 100% rename from Task/Associative-array-Creation/UNIX-Shell/associative-array-creation-1.sh rename to Task/Associative-array-Creation/UNIX-Shell/associative-array-creation.sh diff --git a/Task/Associative-array-Creation/Zig/associative-array-creation-1.zig b/Task/Associative-array-Creation/Zig/associative-array-creation-1.zig new file mode 100644 index 0000000000..bd95d38c80 --- /dev/null +++ b/Task/Associative-array-Creation/Zig/associative-array-creation-1.zig @@ -0,0 +1,18 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + + var hash_map = std.StringHashMap(f64).init(allocator); + defer hash_map.deinit(); + + try hash_map.put("pi", 3.14159265); + try hash_map.put("e", 2.71828183); + try hash_map.put("phi", 1.61803399); + + try stdout.print("{d}\n", .{hash_map.get("pi").?}); + try stdout.print("{d}\n", .{hash_map.get("e").?}); + try stdout.print("{d}\n", .{hash_map.get("phi").?}); +} diff --git a/Task/Associative-array-Creation/Zig/associative-array-creation-2.zig b/Task/Associative-array-Creation/Zig/associative-array-creation-2.zig new file mode 100644 index 0000000000..b969bddec4 --- /dev/null +++ b/Task/Associative-array-Creation/Zig/associative-array-creation-2.zig @@ -0,0 +1,23 @@ +const std = @import("std"); + +const Entity = struct { + name: []const u8, + hp: i32, +}; + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + + var hash_map = std.AutoHashMap(u32, Entity).init(allocator); + defer hash_map.deinit(); + + try hash_map.put(123, .{ .name = "Zombie", .hp = 20 }); + try hash_map.put(456, .{ .name = "Bat", .hp = 6 }); + try hash_map.put(789, .{ .name = "Pig", .hp = 10 }); + + try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(123).?); + try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(456).?); + try stdout.print("{s:6}: HP = {d:3}\n", hash_map.get(789).?); +} diff --git a/Task/Associative-array-Iteration/ArkScript/associative-array-iteration.ark b/Task/Associative-array-Iteration/ArkScript/associative-array-iteration.ark new file mode 100644 index 0000000000..91c6a4bc56 --- /dev/null +++ b/Task/Associative-array-Iteration/ArkScript/associative-array-iteration.ark @@ -0,0 +1,9 @@ +(import std.Dict) + +(let d (dict + "key1" "value1" + "key2" "value2")) + +(print (dict:entries d)) +(print (dict:keys d)) +(print (dict:values d)) diff --git a/Task/Associative-array-Iteration/DuckDB/associative-array-iteration.duckdb b/Task/Associative-array-Iteration/DuckDB/associative-array-iteration.duckdb new file mode 100644 index 0000000000..0b25cd2111 --- /dev/null +++ b/Task/Associative-array-Iteration/DuckDB/associative-array-iteration.duckdb @@ -0,0 +1,108 @@ +### MAPs + +# Since the keys of a JSON object must be strings, we'll use as an +# example of a MAP one which has integer keys: + +D create or replace macro amap() as (SELECT MAP( [1,2,3], ['hello', 'world', '!'])); +D select amap() "A Map"; +┌─────────────────────────┐ +│ A Map │ +│ map(integer, varchar) │ +├─────────────────────────┤ +│ {1=hello, 2=world, 3=!} │ +└─────────────────────────┘ + +# Iterating over the keys: + +D select unnest(map_keys(amap())) as key; +┌───────┐ +│ key │ +│ int32 │ +├───────┤ +│ 1 │ +│ 2 │ +│ 3 │ +└───────┘ + +# Iterating over the values: +D select unnest(map_values(amap())) as value; +┌─────────┐ +│ value │ +│ varchar │ +├─────────┤ +│ hello │ +│ world │ +│ ! │ +└─────────┘ + +# One way to generate the key-value pairs is as follows: +D select unnest(map_keys(amap())) as key, unnest(map_values(amap())) as value; +┌───────┬─────────┐ +│ key │ value │ +│ int32 │ varchar │ +├───────┼─────────┤ +│ 1 │ hello │ +│ 2 │ world │ +│ 3 │ ! │ +└───────┴─────────┘ + +# ... or avoiding calling amap() twice: + +D select unnest(map_keys(m)) as key, unnest(map_values(m)) as value + from (select amap() m); +┌───────┬─────────┐ +│ key │ value │ +│ int32 │ varchar │ +├───────┼─────────┤ +│ 1 │ hello │ +│ 2 │ world │ +│ 3 │ ! │ +└───────┴─────────┘ + +### JSON objects + +# For simplicity, we'll the JSON entity `amap()::JSON` as an example object: + +D select amap()::JSON as j; +┌───────────────────────────────────┐ +│ j │ +│ json │ +├───────────────────────────────────┤ +│ {"1":"hello","2":"world","3":"!"} │ +└───────────────────────────────────┘ + +# To find the keys of a JSON object as a list, +# whence one can use iteration over lists: + +D select json_keys(amap()::JSON) as keys; +┌───────────┐ +│ keys │ +│ varchar[] │ +├───────────┤ +│ [1, 2, 3] │ +└───────────┘ + +# Similarly, to find the values in a JSON object as a list: + +D select list_transform( json_keys(j), k -> (j->>k) ) as list + from (select amap()::JSON as j); +┌───────────────────┐ +│ list │ +│ varchar[] │ +├───────────────────┤ +│ [hello, world, !] │ +└───────────────────┘ + +# Show the key-value pairs as a table: +D select unnest(json_keys(j)) as key, + unnest(list_transform(json_keys(j), k -> (j->>k))) as value + from (select amap()::JSON as j); + +┌─────────┬─────────┐ +│ key │ value │ +│ varchar │ varchar │ +├─────────┼─────────┤ +│ 1 │ hello │ +│ 2 │ world │ +│ 3 │ ! │ +└─────────┴─────────┘ diff --git a/Task/Associative-array-Iteration/Elena/associative-array-iteration-1.elena b/Task/Associative-array-Iteration/Elena/associative-array-iteration-1.elena deleted file mode 100644 index 1190fcb3c7..0000000000 --- a/Task/Associative-array-Iteration/Elena/associative-array-iteration-1.elena +++ /dev/null @@ -1,18 +0,0 @@ -import system'collections; -import system'routines; -import extensions; - -public program() -{ - // 1. Create - var map := Dictionary.new(); - map["key"] := "foox"; - map["key"] := "foo"; - map["key2"]:= "foo2"; - map["key3"]:= "foo3"; - map["key4"]:= "foo4"; - - // Enumerate - map.forEach: - (keyValue){ console.printLine(keyValue.Key," : ",keyValue.Value) } -} diff --git a/Task/Associative-array-Iteration/Elena/associative-array-iteration-2.elena b/Task/Associative-array-Iteration/Elena/associative-array-iteration.elena similarity index 100% rename from Task/Associative-array-Iteration/Elena/associative-array-iteration-2.elena rename to Task/Associative-array-Iteration/Elena/associative-array-iteration.elena diff --git a/Task/Associative-array-Iteration/Haxe/associative-array-iteration.haxe b/Task/Associative-array-Iteration/Haxe/associative-array-iteration.haxe new file mode 100644 index 0000000000..ff94ad47ff --- /dev/null +++ b/Task/Associative-array-Iteration/Haxe/associative-array-iteration.haxe @@ -0,0 +1,18 @@ +class Main { + static public function main() { + var map = [1 => "one", 2 => "two"]; + + // key and value + for (key => value in map) { + trace(key + " " + value); + } + + // keys only + for (key in map.keys()) + trace(key); + + // values only + for (value in map) + trace(value); + } +} diff --git a/Task/Associative-array-Iteration/Pluto/associative-array-iteration.pluto b/Task/Associative-array-Iteration/Pluto/associative-array-iteration.pluto new file mode 100644 index 0000000000..89f8ff1597 --- /dev/null +++ b/Task/Associative-array-Iteration/Pluto/associative-array-iteration.pluto @@ -0,0 +1,19 @@ +-- Create a new map with four entries. +local capitals = { + Greece = "Athens", + Sweden = "Stockholm", + Peru = "Lima", + Uruguay = "Monevideo" +} + +-- Iterate through the map and print out the key/value pairs. +for k, v in capitals do print(k, v) end +print() + +-- Iterate though the map and print out just the keys. +for capitals:keys() as k do print(k) end +print() + +-- Iterate though the map and print out just the values. +for capitals:values() as v do print(v) end +print() diff --git a/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx b/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx index 5fbb924302..3e3f1bf670 100644 --- a/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx +++ b/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx @@ -1,58 +1,72 @@ -/*REXX program demonstrates how to set and display values for an associative array. */ -/*╔════════════════════════════════════════════════════════════════════════════════════╗ - ║ The (below) two REXX statements aren't really necessary, but it shows how to ║ - ║ define any and all entries in a associative array so that if a "key" is used that ║ - ║ isn't defined, it can be displayed to indicate such, or its value can be checked ║ - ║ to determine if a particular associative array element has been set (defined). ║ - ╚════════════════════════════════════════════════════════════════════════════════════╝*/ -stateF.= ' [not defined yet] ' /*sets any/all state former capitals.*/ -stateN.= ' [not defined yet] ' /*sets any/all state names. */ -w = 0 /*the maximum length of a state name.*/ -stateL = -/*╔════════════════════════════════════════════════════════════════════════════════════╗ - ║ The list of states (empty as of now). It's convenient to have them in alphabetic ║ - ║ order; they'll be listed in the order as they are in the REXX program below). ║ - ║ In REXX, when a key is used (for a stemmed array, as they are called in REXX), ║ - ║ and the key isn't assigned a value, the key's name is stored (internally) as ║ - ║ uppercase (Latin) characters (as in the examples below. If the key has a ║ - ║ a value, the key's value is used as is (i.e.: no upper translation is performed).║ - ║ Actually, any characters can be used, including blank(s) and non─displayable ║ - ║ characters (including '00'x, 'ff'x, commas, periods, quotes, ···). ║ - ╚════════════════════════════════════════════════════════════════════════════════════╝*/ -call setSC 'al', "Alabama" , 'Tuscaloosa' -call setSC 'ca', "California" , 'Benicia' -call setSC 'co', "Colorado" , 'Denver City' -call setSC 'ct', "Connecticut" , 'Hartford and New Haven (jointly)' -call setSC 'de', "Delaware" , 'New-Castle' -call setSC 'ga', "Georgia" , 'Milledgeville' -call setSC 'il', "Illinois" , 'Vandalia' -call setSC 'in', "Indiana" , 'Corydon' -call setSC 'ia', "Iowa" , 'Iowa City' -call setSC 'la', "Louisiana" , 'New Orleans' -call setSC 'me', "Maine" , 'Portland' -call setSC 'mi', "Michigan" , 'Detroit' -call setSC 'ms', "Mississippi" , 'Natchez' -call setSC 'mo', "Missouri" , 'Saint Charles' -call setSC 'mt', "Montana" , 'Virginia City' -call setSC 'ne', "Nebraska" , 'Lancaster' -call setSC 'nh', "New Hampshire" , 'Exeter' -call setSC 'ny', "New York" , 'New York' -call setSC 'nc', "North Carolina" , 'Fayetteville' -call setSC 'oh', "Ohio" , 'Chillicothe' -call setSC 'ok', "Oklahoma" , 'Guthrie' -call setSC 'pa', "Pennsylvania" , 'Lancaster' -call setSC 'sc', "South Carolina" , 'Charlestown' -call setSC 'tn', "Tennessee" , 'Murfreesboro' -call setSC 'vt', "Vermont" , 'Windsor' +-- 8 Aug 2025 +include Settings - do j=1 for words(stateL) /*show all capitals that were defined. */ - $= word(stateL, j) /*get the next (USA) state in the list.*/ - say 'the former capital of ('$") " left(stateN.$, w) " was " stateC.$ - end /*j*/ /* [↑] show states that were defined.*/ -exit /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -setSC: parse arg code,name,cap; upper code /*get code, name & cap.; uppercase code*/ - stateL= stateL code /*keep a list of all the US state codes*/ - stateN.code= name; w= max(w,length(name)) /*define the state's name; max width. */ - stateC.code= cap /* " " " code to the capital*/ - return /*return to invoker, SETSC is finished.*/ +say 'ASSOCIATIVE ARRAY: ITERATION' +say version +say +list=''; arra.=''; w=0 +-- States with former capitals: key, name, capital +call SetStateCap 'al','Alabama','Tuscaloosa' +call SetStateCap 'ca','California','Benicia' +call SetStateCap 'co','Colorado','Denver City' +call SetStateCap 'ct','Connecticut','Hartford and New Haven' +call SetStateCap 'de','Delaware','New-Castle' +call SetStateCap 'ga','Georgia','Milledgeville' +call SetStateCap 'il','Illinois','Vandalia' +call SetStateCap 'in','Indiana','Corydon' +call SetStateCap 'ia','Iowa','Iowa City' +call SetStateCap 'la','Louisiana','New Orleans' +call SetStateCap 'me','Maine','Portland' +call SetStateCap 'mi','Michigan','Detroit' +call SetStateCap 'ms','Mississippi','Natchez' +call SetStateCap 'mo','Missouri','Saint Charles' +call SetStateCap 'mt','Montana','Virginia City' +call SetStateCap 'ne','Nebraska','Lancaster' +call SetStateCap 'nh','New Hampshire','Exeter' +call SetStateCap 'ny','New York','New York' +call SetStateCap 'nc','North Carolina','Fayetteville' +call SetStateCap 'oh','Ohio','Chillicothe' +call SetStateCap 'ok','Oklahoma','Guthrie' +call SetStateCap 'pa','Pennsylvania','Lancaster' +call SetStateCap 'sc','South Carolina','Charlestown' +call SetStateCap 'tn','Tennessee','Murfreesboro' +call SetStateCap 'vt','Vermont','Windsor' +arra.0=w +-- Loop through list +say 'Using a list...' +do w = 1 to words(list) + a=Word(list,w) + say 'The former capital of' stna.a '('a')' 'was' stca.a +end +say +-- Loop through aux array...' +say 'Using an array...' +do w = 1 to arra.0 + a=arra.w + say 'The former capital of' stna.a '('a')' 'was' stca.a +end +say +-- Show all vars +say 'Variables...' +if pos('Regina',version) > 0 then + call Library +call SysDumpVariables +exit + +SetStateCap: +parse arg code,name,cap +code=Upper(code) +-- Next row in associative array +stna.code=name; stca.code=cap +-- Track keys in a list +list=list code +-- Track keys in an array +w=w+1; arra.w=code +return + +Library: +call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs' +call SysLoadFuncs +return + +include Abend diff --git a/Task/Associative-array-Iteration/TAV/associative-array-iteration.tav b/Task/Associative-array-Iteration/TAV/associative-array-iteration.tav new file mode 100644 index 0000000000..623ffbb902 --- /dev/null +++ b/Task/Associative-array-Iteration/TAV/associative-array-iteration.tav @@ -0,0 +1,24 @@ +main(params):+ + mm =: 'a' -> 1, 'b' -> 2, 'c' -> 3 + mm =: tuple mm as map + \ iterate over the pairs, order undefined + ?# t =: map mm give pairs + print t.1 _ '->' _ t.2 _ ' ' nonl + print '' + \ iterate over the keys + ?# k =: map mm give keys + print k, ' ' nonl + print '' + x =: mm{'c'} \ changes order by access + \ iterate over the values only + ?# v =: map mm give values + print v, ' ' nonl + print '' + \ ordered keys: + ?# k =: map mm give keys ascending + print k, ' ' nonl + print '' + \ ordered keys: + ?# k =: map mm give keys descending + print k _ '->' _ mm{k} _ ' ' nonl + print '' diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl index 191b6d0205..33e625a459 100644 --- a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl @@ -1,16 +1,7 @@ -array set myAry { - # list items here... +array set family { + surname Miller + father John + mother Helen + daughter [list Jane Karen] + son Donald } - -# Iterate over keys and values -foreach {key value} [array get myAry] { - puts "$key -> $value" -} - -# Iterate over just keys -foreach key [array names myAry] { - puts "key = $key" -} - -# There is nothing for directly iterating over just the values -# Use the keys+values version and ignore the keys diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl index 0c64d363c4..16bf134315 100644 --- a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl @@ -1,16 +1,3 @@ -set myDict [dict create ...]; # Make the dictionary - -# Iterate over keys and values -dict for {key value} $myDict { - puts "$key -> $value" -} - -# Iterate over keys -foreach key [dict keys $myDict] { - puts "key = $key" -} - -# Iterate over values -foreach value [dict values $myDict] { - puts "value = $value" -} +# "John Miller" +set dad "$family(father) $family(lastname)" +set second_daughter [lindex $family(daughter) 1] diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-3.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-3.tcl new file mode 100644 index 0000000000..68b3bbd537 --- /dev/null +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-3.tcl @@ -0,0 +1,2 @@ +set l [array get family] +# {surname Miller father John mother Helen daughter {Jane Karen} son Donald} diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-4.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-4.tcl new file mode 100644 index 0000000000..191b6d0205 --- /dev/null +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-4.tcl @@ -0,0 +1,16 @@ +array set myAry { + # list items here... +} + +# Iterate over keys and values +foreach {key value} [array get myAry] { + puts "$key -> $value" +} + +# Iterate over just keys +foreach key [array names myAry] { + puts "key = $key" +} + +# There is nothing for directly iterating over just the values +# Use the keys+values version and ignore the keys diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-5.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-5.tcl new file mode 100644 index 0000000000..0c64d363c4 --- /dev/null +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-5.tcl @@ -0,0 +1,16 @@ +set myDict [dict create ...]; # Make the dictionary + +# Iterate over keys and values +dict for {key value} $myDict { + puts "$key -> $value" +} + +# Iterate over keys +foreach key [dict keys $myDict] { + puts "key = $key" +} + +# Iterate over values +foreach value [dict values $myDict] { + puts "value = $value" +} diff --git a/Task/Associative-array-Iteration/Zig/associative-array-iteration-1.zig b/Task/Associative-array-Iteration/Zig/associative-array-iteration-1.zig new file mode 100644 index 0000000000..90daa4bc29 --- /dev/null +++ b/Task/Associative-array-Iteration/Zig/associative-array-iteration-1.zig @@ -0,0 +1,30 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + + var hash_map = std.StringArrayHashMap(f32).init(allocator); + defer hash_map.deinit(); + + try hash_map.put("B3", 246.94); + try hash_map.put("C4", 261.63); + try hash_map.put("C#4", 277.18); + + for (hash_map.keys()) |key| { + try stdout.print("{s}\n", .{key}); + } + + for (hash_map.values()) |value| { + try stdout.print("{d}\n", .{value}); + } + + var iter = hash_map.iterator(); + while (iter.next()) |entry| { + const key = entry.key_ptr.*; + const value = entry.value_ptr.*; + + try stdout.print("{s}, {d}\n", .{key, value}); + } +} diff --git a/Task/Associative-array-Iteration/Zig/associative-array-iteration-2.zig b/Task/Associative-array-Iteration/Zig/associative-array-iteration-2.zig new file mode 100644 index 0000000000..be3b2677d1 --- /dev/null +++ b/Task/Associative-array-Iteration/Zig/associative-array-iteration-2.zig @@ -0,0 +1,30 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + + var hash_map = std.AutoArrayHashMap(u8, []const u8).init(allocator); + defer hash_map.deinit(); + + try hash_map.put('A', "Alpha"); + try hash_map.put('B', "Bravo"); + try hash_map.put('C', "Charlie"); + + for (hash_map.keys()) |key| { + try stdout.print("{c}\n", .{key}); + } + + for (hash_map.values()) |value| { + try stdout.print("{s}\n", .{value}); + } + + var iter = hash_map.iterator(); + while (iter.next()) |entry| { + const key = entry.key_ptr.*; + const value = entry.value_ptr.*; + + try stdout.print("{c}, {s}\n", .{key, value}); + } +} diff --git a/Task/Associative-array-Merging/DuckDB/associative-array-merging-1.duckdb b/Task/Associative-array-Merging/DuckDB/associative-array-merging-1.duckdb new file mode 100644 index 0000000000..be9c95b7eb --- /dev/null +++ b/Task/Associative-array-Merging/DuckDB/associative-array-merging-1.duckdb @@ -0,0 +1,4 @@ +set variable base= { 'name': 'Rocket Skates', 'price': 12.75, 'color':'yellow'}::JSON; +set variable update = { 'price': 15.25, 'color': 'red', 'year': 1974 }::JSON; + +select json_merge_patch(getvariable('base'),getvariable('update')) as add; diff --git a/Task/Associative-array-Merging/DuckDB/associative-array-merging-2.duckdb b/Task/Associative-array-Merging/DuckDB/associative-array-merging-2.duckdb new file mode 100644 index 0000000000..3dd23a19a1 --- /dev/null +++ b/Task/Associative-array-Merging/DuckDB/associative-array-merging-2.duckdb @@ -0,0 +1,11 @@ +create or replace function map_merge_patch(a,b) as ( + with keys_t as ( + select (map_keys(a) + map_keys(b)).list_distinct() as keys + ), + values_t as ( + select list_transform(keys, key -> coalesce(b[key][1],a[key][1])) as values + from keys_t) + select MAP(keys, values) from keys_t, values_t +); + +select map_merge_patch( MAP([1,2],[1,2]), MAP([1,3],[10,30])) as add; diff --git a/Task/Associative-array-Merging/DuckDB/associative-array-merging-3.duckdb b/Task/Associative-array-Merging/DuckDB/associative-array-merging-3.duckdb new file mode 100644 index 0000000000..60dfac34ba --- /dev/null +++ b/Task/Associative-array-Merging/DuckDB/associative-array-merging-3.duckdb @@ -0,0 +1,11 @@ +create or replace function struct_merge_patch(base, update) as ( + + with cte as ( + from (select unnest(update)) + positional join + (select COLUMNS(x -> x not in json_keys(update::JSON)) from (select unnest(base))) + ) + select cte from cte +); + +select struct_merge_patch( getvariable('base'), getvariable('update')) as merged; diff --git a/Task/Associative-array-Merging/Fortran/associative-array-merging.f b/Task/Associative-array-Merging/Fortran/associative-array-merging.f new file mode 100644 index 0000000000..294f442506 --- /dev/null +++ b/Task/Associative-array-Merging/Fortran/associative-array-merging.f @@ -0,0 +1,94 @@ +module assoc_array_mod + implicit none + private + public :: KeyValue, merge_assoc_arrays + + ! Derived type for key-value pairs + type :: KeyValue + character(len=:), allocatable :: key + character(len=:), allocatable :: value + end type KeyValue + +contains + + ! Function to merge two associative arrays + function merge_assoc_arrays(base, update) result(merged) + type(KeyValue), intent(in) :: base(:), update(:) + type(KeyValue), allocatable :: merged(:) + type(KeyValue), allocatable :: temp(:) + integer :: base_size, update_size, i, j, k, merged_size + logical :: key_exists + + base_size = size(base) + update_size = size(update) + + ! Allocate temporary array to hold all possible keys (worst case: no overlap) + allocate(temp(base_size + update_size)) + merged_size = 0 + + ! Add all keys from update array (update takes precedence) + do i = 1, update_size + merged_size = merged_size + 1 + temp(merged_size)%key = update(i)%key + temp(merged_size)%value = update(i)%value + end do + + ! Add keys from base array that are not in update + do i = 1, base_size + key_exists = .false. + do j = 1, update_size + if (base(i)%key == update(j)%key) then + key_exists = .true. + exit + end if + end do + if (.not. key_exists) then + merged_size = merged_size + 1 + temp(merged_size)%key = base(i)%key + temp(merged_size)%value = base(i)%value + end if + end do + + ! Allocate merged array with exact size + allocate(merged(merged_size)) + do i = 1, merged_size + merged(i)%key = temp(i)%key + merged(i)%value = temp(i)%value + end do + + ! Clean up temporary array + deallocate(temp) + end function merge_assoc_arrays + +end module assoc_array_mod + +program main + use assoc_array_mod + implicit none + type(KeyValue), allocatable :: base(:), update(:), merged(:) + integer :: i + + ! Initialize base associative array + allocate(base(3)) + base(1) = KeyValue("name", "Rocket Skates") + base(2) = KeyValue("price", "12.75") + base(3) = KeyValue("color", "yellow") + + ! Initialize update associative array + allocate(update(3)) + update(1) = KeyValue("price", "15.25") + update(2) = KeyValue("color", "red") + update(3) = KeyValue("year", "1974") + + ! Merge the arrays + merged = merge_assoc_arrays(base, update) + + ! Print the merged array + print *, "Merged associative array:" + do i = 1, size(merged) + print *, "Key: ", merged(i)%key, ", Value: ", merged(i)%value + end do + + ! Clean up + deallocate(base, update, merged) +end program main diff --git a/Task/Associative-array-Merging/Pluto/associative-array-merging.pluto b/Task/Associative-array-Merging/Pluto/associative-array-merging.pluto new file mode 100644 index 0000000000..cfa921a360 --- /dev/null +++ b/Task/Associative-array-Merging/Pluto/associative-array-merging.pluto @@ -0,0 +1,11 @@ +local function merge_maps(m1, m2) + local m3 = {} + for m1:keys() as key do m3[key] = m1[key] end + for m2:keys() as key do m3[key] = m2[key] end + return m3 +end + +local base = {name = "Rocket Skates", price = 12.75, color = "yellow"} +local update = {price = 15.25, color = "red", year = 1974} +local merged = merge_maps(base, update) +for k, v in merged do print(k, v) end diff --git a/Task/Associative-array-Merging/REXX/associative-array-merging.rexx b/Task/Associative-array-Merging/REXX/associative-array-merging.rexx index d13ae1dcfd..40cf80021f 100644 --- a/Task/Associative-array-Merging/REXX/associative-array-merging.rexx +++ b/Task/Associative-array-Merging/REXX/associative-array-merging.rexx @@ -1,33 +1,78 @@ -/*REXX program merges two associative arrays (requiring an external list of indices). */ -$.= /*define default value(s) for arrays. */ -@.wAAn= 21; @.wKey= 7; @.wVal= 7 /*max widths of: AAname, keys, values.*/ -call defAA 'base', "name Rocket Skates", 'price 12.75', "color yellow" -call defAA 'update', "price 15.25", "color red", 'year 1974' -call show 'base' -call show 'update' -call show 'new' -exit /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -defAA: procedure expose $. @.; parse arg AAn; new= 'new' /*get AA name; set NEW.*/ - do j=2 to arg(); parse value arg(j) with key val /*obtain key and value.*/ - $.AAn.key= val /*assign a value to a key for AAn. */ - if wordpos(key, $.AAN.?keys)==0 then $.AAn.?keys= $.AAn.?keys key - /* [↑] add to key list if not in list.*/ - $.new.key= val /*assign a value to a key for "new".*/ - if wordpos(key, $.new.?keys)==0 then $.new.?keys= $.new.?keys key - /* [↑] add to key list if not in list.*/ - @.wKey= max(@.wKey, length(key) ) /*find max width of a name of a key. */ - @.wVal= max(@.wVal, length(val) ) /* " " " " " " " " value.*/ - @.wAA = max(@.wAAn, length(AAn) ) /* " " " " " " " array.*/ - end /*j*/ - return -/*──────────────────────────────────────────────────────────────────────────────────────*/ -show: procedure expose $. @.; parse arg AAn; say; _= '═' /*set title char.*/ - do j=1 for words($.AAn.?keys) /*process keys. */ - if j==1 then say center('associate array', @.wAAn, _) , - center("key" , @.wKey, _) , - center('value' , @.wVal + 2, _) - key= word($.AAn.?keys, j) /*get the name of a key.*/ - say center(AAn, @.wAAn) right(key, @.wKey) $.AAn.key /*show some information.*/ - end /*j*/ - return +-- 8 Aug 2025 +include Settings + +say 'ASSOCIATIVE ARRAY: MERGE' +say version +say +call CreateBase +call ShowBase 'Original' +call CreateUpdate +call ShowUpdate +call MergeBaseUpdate +call ShowBase 'Merged' +exit + +CreateBase: +base=''; base.='' +call ProcBase 'name','Rocket Skates' +call ProcBase 'price',12.75 +call ProcBase 'color','Yellow' +return + +ShowBase: +parse arg xx +sep=Copies('-',20) +say 'Base array' xx +say sep +say 'Key value' +say sep +do i = 1 to Words(base) + key=Word(base,i) + say Left(key,6) base.key +end +say sep +say +return + +CreateUpdate: +upda=''; upda.='' +call ProcUpdate 'price',15.25 +call ProcUpdate 'color','Red' +call ProcUpdate 'year',1974 +return + +ShowUpdate: +say 'Update array' +say sep +say 'Key value' +say sep +do i = 1 to Words(upda) + key=Word(upda,i) + say Left(key,6) upda.key +end +say sep +say +return + +MergeBaseUpdate: +do w = 1 to Words(upda) + key=Word(upda,w); val=upda.key + call ProcBase key,val +end +return + +ProcBase: +parse arg k,v +if WordPos(k,base) = 0 then + base=base k +base.k=v +return + +ProcUpdate: +parse arg k,v +if WordPos(k,upda) = 0 then + upda=upda k +upda.k=v +return + +include Abend diff --git a/Task/Attractive-numbers/Agena/attractive-numbers.agena b/Task/Attractive-numbers/Agena/attractive-numbers.agena new file mode 100644 index 0000000000..01fe38dcca --- /dev/null +++ b/Task/Attractive-numbers/Agena/attractive-numbers.agena @@ -0,0 +1,28 @@ +scope # find some attractive numbers - numbers whose prime factor counts are prime, n must be > 1 + + local constant maxNumber := 120; # maximum number we will consider + + printf( "The attractve numbers up to %d\n", maxNumber ); + local aCount := 0; + for i from 2 to maxNumber do + local v, fCount := i, 0; + while v mod 2 = 0 do + fCount +:= 1; + v \:= 2 + od; + for j from 3 to maxNumber by 2 while v > 1 do + while v > 1 and v mod j = 0 do + fCount +:= 1; + v \:= j + od + od; + if fCount > 0 then + if numtheory.isprime( fCount ) then + printf( " %3d", i ); + aCount +:= 1; + if aCount mod 20 = 0 then print() fi + fi + fi + od; + printf( "\nFound %d attractive numbers\n", aCount ) +end diff --git a/Task/Attractive-numbers/Lua/attractive-numbers.lua b/Task/Attractive-numbers/Lua/attractive-numbers.lua index 19f47fc858..fa18744307 100644 --- a/Task/Attractive-numbers/Lua/attractive-numbers.lua +++ b/Task/Attractive-numbers/Lua/attractive-numbers.lua @@ -11,11 +11,10 @@ end -- Compute the prime factors of n function factors (n) - local facList, divisor, count = {}, 1 + local facList, divisor = {}, 1 if n < 2 then return facList end while not isPrime(n) do while not isPrime(divisor) do divisor = divisor + 1 end - count = 0 while n % divisor == 0 do n = n / divisor table.insert(facList, divisor) @@ -28,6 +27,10 @@ function factors (n) end -- Main procedure +local count = 0 for i = 1, 120 do - if isPrime(#factors(i)) then io.write(i .. "\t") end + if isPrime(#factors(i)) then + count = count - 1 + io.write( string.format("%6d", i), ( count % 12 == 0 and "\n" or "" )) + end end diff --git a/Task/Attractive-numbers/Pluto/attractive-numbers.pluto b/Task/Attractive-numbers/Pluto/attractive-numbers.pluto new file mode 100644 index 0000000000..fad6286fed --- /dev/null +++ b/Task/Attractive-numbers/Pluto/attractive-numbers.pluto @@ -0,0 +1,40 @@ +do -- find some attractive numbers - numbers whose prime factor count is prime + + -- Returns true if x is prime, and false otherwise + function isPrime (x) + if x < 2 then return false end + if x < 4 then return true end + if x % 2 == 0 then return false end + for d = 3, math.sqrt(x), 2 do + if x % d == 0 then return false end + end + return true + end + + -- Compute the prime factors of n + function factors (n) + local facList, divisor = {}, 1 + if n > 1 then + while not isPrime(n) do + while not isPrime(divisor) do ++ divisor end + while n % divisor == 0 do + n //= divisor + facList:insert(divisor) + end + ++ divisor + if n == 1 then return facList end + end + facList:insert(n) + end + return facList + end + + -- Main procedure + local count = 0 + for i = 1, 120 do + if isPrime(#factors(i)) then + ++ count + io.write( string.format( "%6d", i ), if count % 12 == 0 then "\n" else "" end ) + end + end +end diff --git a/Task/Averages-Arithmetic-mean/Apple/averages-arithmetic-mean.apple b/Task/Averages-Arithmetic-mean/Apple/averages-arithmetic-mean.apple new file mode 100644 index 0000000000..02cf4807c8 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Apple/averages-arithmetic-mean.apple @@ -0,0 +1,2 @@ + > [(+)/x%ℝ(:x)] ⟨3,1,4,1,5,9⟩ +3.833333333333333 diff --git a/Task/Averages-Arithmetic-mean/DuckDB/averages-arithmetic-mean.duckdb b/Task/Averages-Arithmetic-mean/DuckDB/averages-arithmetic-mean.duckdb new file mode 100644 index 0000000000..f401cf4302 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/DuckDB/averages-arithmetic-mean.duckdb @@ -0,0 +1,3 @@ +create or replace function average(lst) as ( + list_sum(lst) / length(lst) +); diff --git a/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena b/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena index 11d1006f7a..7d2af43a0a 100644 --- a/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena +++ b/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena @@ -21,8 +21,8 @@ extension op public program() { - var array := new int[]{1, 2, 3, 4, 5, 6, 7, 8}; - console.printLine( - "Arithmetic mean of {",array.asEnumerable(),"} is ", - array.average()).readChar() + var array := new int[]{1, 2, 3, 4, 5, 6, 7, 8}; + Console.printLine( + "Arithmetic mean of {",array.asEnumerable(),"} is ", + array.average()).readChar() } diff --git a/Task/Averages-Arithmetic-mean/Pluto/averages-arithmetic-mean.pluto b/Task/Averages-Arithmetic-mean/Pluto/averages-arithmetic-mean.pluto new file mode 100644 index 0000000000..65b6a14afc --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Pluto/averages-arithmetic-mean.pluto @@ -0,0 +1,4 @@ +local function arithmetic_mean(a) return a:reduce(|sum, i| -> sum + i) / #a end + +local arrays = { {1, 2, 3, 4, 5}, {} } +for arrays as a do print(arithmetic_mean(a)) end diff --git a/Task/Averages-Mean-angle/DuckDB/averages-mean-angle.duckdb b/Task/Averages-Mean-angle/DuckDB/averages-mean-angle.duckdb new file mode 100644 index 0000000000..305fe03554 --- /dev/null +++ b/Task/Averages-Mean-angle/DuckDB/averages-mean-angle.duckdb @@ -0,0 +1,13 @@ +# Mean of given list of angles in degrees, to 7 decimal places +create or replace function mean_angle(lst) as ( + with angles as (select unnest(lst) as angle), + radians as (select (angle * pi() / 180) as alpha from angles), + trig as (select sin(alpha) as s, cos(alpha) as c from radians) + + select round(atan2( sum(s) / length(lst), sum(c) / length(lst) ) * 180 / pi(), 7) from trig +); + +select angles, mean_angle(angles) as mean from values + ([350, 10]), + ([90,180,270,360]), + ([10, 20, 30]) t(angles); diff --git a/Task/Averages-Mean-time-of-day/DuckDB/averages-mean-time-of-day.duckdb b/Task/Averages-Mean-time-of-day/DuckDB/averages-mean-time-of-day.duckdb new file mode 100644 index 0000000000..cfcd6745d2 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/DuckDB/averages-mean-time-of-day.duckdb @@ -0,0 +1,17 @@ +create or replace function mean_time(t1, t2) as ( + select if (diff >= 0, t1::TIME + INTERVAL (diff/2) seconds, + t1::TIME + INTERVAL ((86400 + diff)/2) seconds) + from + ( select datediff('seconds', t1::TIME, t2::TIME) as diff ) +); + +## Examples: +select times[1], times[2], mean_time(times[1], times[2]) as mean +from values + ( ['0:0:0', '12:0:0' ] ), + ( ['0:0:0', '24:0:0' ] ), + ( ['1:0:0', '1:0:0' ] ), + ( ['20:0:0', '4:0:0' ] ), + ( ['20:0:0', '4:0:2' ] ), + ( ['23:0:0', '23:0:0'] ) +t(times); diff --git a/Task/Averages-Mean-time-of-day/FutureBasic/averages-mean-time-of-day.basic b/Task/Averages-Mean-time-of-day/FutureBasic/averages-mean-time-of-day.basic new file mode 100644 index 0000000000..4e0717b789 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/FutureBasic/averages-mean-time-of-day.basic @@ -0,0 +1,70 @@ +// +// Averages/Mean time of day +// FutureBasic 7.0.34, August 2025 R.W +// +_angles = 1 //tag for MDA array + +// Our test data times +CFStringRef tm(4) = {@"Times",@"23:00:17", @"23:40:20", @"00:12:45", @"00:17:19"} + +// get average of angle sum +local fn MeanAngle( tag as Int ) as double + long count + double sinSum, cosSum + count = mda_count tag //count total including zeroeth element + sinSum = 0.0: cosSum = 0.0 + for long i = 1 to count - 1 //remove zero + sinSum += sin(mda tag(i) * PI / 180.0) + cosSum += cos(mda tag(i) * PI / 180.0) + next +end fn = fn atan2(sinSum / count, cosSum / count) * 180.0 / PI + +// Get seconds from time t format = "hh:mm:ss" +local fn timeToSecs(t As CFStringRef) as Int + Int hours, mins, secs + hours = IntVal(Left(t, 2)) + mins = IntVal(Mid(t, 3, 2)) + secs = IntVal(Right(t, 2)) +end fn = 3600 * hours + 60 * mins + secs + +// 1 second = 360/(24 * 3600) = 1/240th of a degree +local fn timeToDegrees(t as CFStringRef) as Double + Int secs + secs = fn timeToSecs(t) +end fn = secs/240.0 + +// convert degrees to time string +local fn degreesToTime(d As Double) as CFStringRef + Int hours, mins, secs + CFStringRef result,h,m,s, tmp + result = @"":h=@"":m=@"":s=@"":tmp = @"" + If d < 0 Then d = d + 360.0 + secs = d * 240.0 + hours = fix(secs / 3600) + tmp = mid(str(hours),1) + if hours < 10 then h = concat(@"0",tmp) else h = tmp + mins = secs % 3600 + secs = mins % 60 + tmp = mid(str(secs),1) + if secs < 10 then s = concat(@"0",tmp) else s = tmp + mins = fix(mins / 60) + tmp = mid(str(mins),1) + if mins < 10 then m = concat(@"0",tmp) else m = tmp + result = concat(result,h,@":",m,@":",s) +end fn = result + + +window 1 + +// load MDA array with time to degrees +// from test data +for Int x = 1 to 4 + mda _angles(x) = fn timeToDegrees(tm(x)) +next x + +double mean +mean = fn meanAngle(_angles) +print +print " Average time is: "; fn degreesToTime(mean) + +handleEvents diff --git a/Task/Averages-Median/Elena/averages-median.elena b/Task/Averages-Median/Elena/averages-median.elena index 8dd0572594..c5e03aa82e 100644 --- a/Task/Averages-Median/Elena/averages-median.elena +++ b/Task/Averages-Median/Elena/averages-median.elena @@ -33,8 +33,8 @@ public program() var a1 := new real[]{4.1r, 5.6r, 7.2r, 1.7r, 9.3r, 4.4r, 3.2r}; var a2 := new real[]{4.1r, 7.2r, 1.7r, 9.3r, 4.4r, 3.2r}; - console.printLine("median of (",a1.asEnumerable(),") is ",a1.Median); - console.printLine("median of (",a2.asEnumerable(),") is ",a2.Median); + Console.printLine("median of (",a1.asEnumerable(),") is ",a1.Median); + Console.printLine("median of (",a2.asEnumerable(),") is ",a2.Median); - console.readChar() + Console.readChar() } diff --git a/Task/Averages-Median/Pluto/averages-median.pluto b/Task/Averages-Median/Pluto/averages-median.pluto new file mode 100644 index 0000000000..76d20aff94 --- /dev/null +++ b/Task/Averages-Median/Pluto/averages-median.pluto @@ -0,0 +1,17 @@ +local function median(a) + local len = #a + if len == 0 then return nil end + local b = a:sorted() + local hlen = len // 2 + if len % 2 == 1 then return b[hlen + 1] end + return (b[hlen] + b[hlen + 1]) / 2.0 +end + +local arrays = { + {4, 2, 5, 3, 1}, + {9, 6, 8, 7}, + {2}, + {} +} + +for arrays as a do print(median(a)) end diff --git a/Task/Averages-Mode/DuckDB/averages-mode-1.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-1.duckdb new file mode 100644 index 0000000000..b8f3ef6eda --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-1.duckdb @@ -0,0 +1,10 @@ +# lst should be a DuckDB list +create or replace function mode(lst) as ( + with cte as ( + SELECT number, COUNT(*) as frequency + FROM (SELECT unnest(lst) as number) + GROUP BY number + ORDER BY frequency DESC + LIMIT 1) + (select number from cte) -- signal that the result is scalar + ); diff --git a/Task/Averages-Mode/DuckDB/averages-mode-2.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-2.duckdb new file mode 100644 index 0000000000..2787f7d621 --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-2.duckdb @@ -0,0 +1 @@ +select [1, 2, 2, 3, 3, 3, 4] as list, mode(list) as mode; diff --git a/Task/Averages-Mode/DuckDB/averages-mode-3.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-3.duckdb new file mode 100644 index 0000000000..8158bc7e74 --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-3.duckdb @@ -0,0 +1,10 @@ +create or replace function modal_values(lst) as table ( + with cte as ( + SELECT number, COUNT(*) as frequency + FROM (SELECT unnest(lst) as number) + GROUP BY number ) + select number + from cte + where frequency = (SELECT MAX(frequency) FROM cte) + order by number + ); diff --git a/Task/Averages-Mode/DuckDB/averages-mode-4.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-4.duckdb new file mode 100644 index 0000000000..104e77bdbb --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-4.duckdb @@ -0,0 +1 @@ +select median(n) as mode from modal_values( [1,1,1,2,2,2,3]) t(n); diff --git a/Task/Averages-Mode/DuckDB/averages-mode-5.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-5.duckdb new file mode 100644 index 0000000000..095bcb6299 --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-5.duckdb @@ -0,0 +1,15 @@ +# Find the mode of a column named values in the named table +# by taking the median() of the modal values +create or replace function mode_of_column(TableName) as ( + with cte as ( + SELECT value, COUNT(*) as frequency + FROM query_table(TableName) + GROUP BY value + ), + modal_values as ( + SELECT value + from cte + where frequency = (SELECT MAX(frequency) FROM cte) + order by value + ) select median(value) from modal_values +); diff --git a/Task/Averages-Mode/DuckDB/averages-mode-6.duckdb b/Task/Averages-Mode/DuckDB/averages-mode-6.duckdb new file mode 100644 index 0000000000..819c128044 --- /dev/null +++ b/Task/Averages-Mode/DuckDB/averages-mode-6.duckdb @@ -0,0 +1,2 @@ +with cte as (select val as value from averages) + select mode_of_column('cte') as 'mode of val'; diff --git a/Task/Averages-Mode/Elena/averages-mode.elena b/Task/Averages-Mode/Elena/averages-mode.elena index f1fca32540..e0992d1b2f 100644 --- a/Task/Averages-Mode/Elena/averages-mode.elena +++ b/Task/Averages-Mode/Elena/averages-mode.elena @@ -29,7 +29,7 @@ public program() var array2 := new int[]{1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17}; var array3 := new object[]{1, "blue", 2, 7.5r, 5, "green", "red", 5, 2, "blue", "white"}; - console + Console .printLine("mode of (",array1.asEnumerable(),") is (",array1.Mode,")") .printLine("mode of (",array2.asEnumerable(),") is (",array2.Mode,")") .printLine("mode of (",array3.asEnumerable(),") is (",array3.Mode,")") diff --git a/Task/Averages-Pythagorean-means/Apple/averages-pythagorean-means.apple b/Task/Averages-Pythagorean-means/Apple/averages-pythagorean-means.apple new file mode 100644 index 0000000000..a3ff60c36b --- /dev/null +++ b/Task/Averages-Pythagorean-means/Apple/averages-pythagorean-means.apple @@ -0,0 +1,12 @@ + > :store a [(+)/x%ℝ(:x)] + > :store g [((*)/x)**(⅟(ℝ(:x)))] + > :store h [⅟((+)/((1%)')x)] + + > :store x frange 1 10 10 + + > a x +5.5 + > g x +4.528728688116765 + > h x +0.34141715214740553 diff --git a/Task/Averages-Pythagorean-means/DuckDB/averages-pythagorean-means.duckdb b/Task/Averages-Pythagorean-means/DuckDB/averages-pythagorean-means.duckdb new file mode 100644 index 0000000000..b75db190c5 --- /dev/null +++ b/Task/Averages-Pythagorean-means/DuckDB/averages-pythagorean-means.duckdb @@ -0,0 +1,11 @@ +create or replace function average(lst) as ( + list_sum(lst) / length(lst) +); + +create or replace function list_geometric_mean(lst) as ( + list_product( list_transform(lst, x -> pow(x, 1/length(lst))) ) +); + +create or replace function list_harmonic_mean(lst) as ( + length(lst) / list_sum( list_transform(lst, x -> 1/x)) +); diff --git a/Task/Averages-Pythagorean-means/Pluto/averages-pythagorean-means.pluto b/Task/Averages-Pythagorean-means/Pluto/averages-pythagorean-means.pluto new file mode 100644 index 0000000000..903b1e2788 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Pluto/averages-pythagorean-means.pluto @@ -0,0 +1,11 @@ +local rng = range(1, 10) +local count = #rng +local A = rng:reduce(|acc, x| -> acc + x ) / count +local G = rng:reduce(|prod, x| -> prod * x, 1) ^ (1 / count) +local H = rng:reduce(|acc, x| -> acc + 1 / x) ^ (-1) * count + +print($"For the numbers \{{rng:min()}, {rng:max()}}:") +print($" Arithmetic mean = {A}") +print($" Geometric mean = {G}") +print($" Harmonic mean = {H}") +print($" A >= G >= H = {A >= G >= H}") diff --git a/Task/Averages-Root-mean-square/EasyLang/averages-root-mean-square.easy b/Task/Averages-Root-mean-square/EasyLang/averages-root-mean-square.easy index 50fec25962..744f7e1009 100644 --- a/Task/Averages-Root-mean-square/EasyLang/averages-root-mean-square.easy +++ b/Task/Averages-Root-mean-square/EasyLang/averages-root-mean-square.easy @@ -1,8 +1,5 @@ func rms v[] . - for v in v[] - sum += v * v - . + for v in v[] : sum += v * v return sqrt (sum / len v[]) . -v[] = [ 1 2 3 4 5 6 7 8 9 10 ] -print rms v[] +print rms [ 1 2 3 4 5 6 7 8 9 10 ] diff --git a/Task/Averages-Root-mean-square/Elena/averages-root-mean-square.elena b/Task/Averages-Root-mean-square/Elena/averages-root-mean-square.elena index 66c1f5e9b3..d4ec3261bc 100644 --- a/Task/Averages-Root-mean-square/Elena/averages-root-mean-square.elena +++ b/Task/Averages-Root-mean-square/Elena/averages-root-mean-square.elena @@ -10,5 +10,5 @@ extension op public program() { - console.printLine(new Range(1, 10).RootMeanSquare) + Console.printLine(new Range(1, 10).RootMeanSquare) } diff --git a/Task/Averages-Root-mean-square/Pluto/averages-root-mean-square.pluto b/Task/Averages-Root-mean-square/Pluto/averages-root-mean-square.pluto new file mode 100644 index 0000000000..d54e29247b --- /dev/null +++ b/Task/Averages-Root-mean-square/Pluto/averages-root-mean-square.pluto @@ -0,0 +1,7 @@ +local function rms(a) + local len = #a + if len == 0 then return nil end + return math.sqrt(a:reduce(|acc, i| -> acc + i * i) / len) +end + +print(rms(range(1, 10))) diff --git a/Task/Averages-Root-mean-square/TAV/averages-root-mean-square.tav b/Task/Averages-Root-mean-square/TAV/averages-root-mean-square.tav new file mode 100644 index 0000000000..9e44a48dcc --- /dev/null +++ b/Task/Averages-Root-mean-square/TAV/averages-root-mean-square.tav @@ -0,0 +1,10 @@ +main (parms):+ + t =: new tuple from 1 upto 10 + print t, '->', vector t norm + +\ input can be tuple, row or map (class function used) +vector (@) norm: + sq =: 0.0 + ?# v =: @::give values + sq =+ v * v + :> float (sq / @.Count) sqrt diff --git a/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena b/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena index c1663edc5a..8db130292f 100644 --- a/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena +++ b/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena @@ -19,8 +19,8 @@ class SMA var count := theList.Length; count => - 0 { ^0.0r } - ! { + 0 : { ^0.0r } + ! : { if (count > thePeriod) { theList.removeAt(0); @@ -35,22 +35,20 @@ class SMA } } -// --- Program --- - public program() { var SMA3 := SMA.new(3); var SMA5 := SMA.new(5); for (int i := 1; i <= 5; i += 1) { - console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append(i)); - console.printLine("sma5 + ", i, " = ", SMA5.append(i)) + Console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append(i)); + Console.printLine("sma5 + ", i, " = ", SMA5.append(i)) }; for (int i := 5; i >= 1; i -= 1) { - console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append(i)); - console.printLine("sma5 + ", i, " = ", SMA5.append(i)) + Console.printPaddingRight(30, "sma3 + ", i, " = ", SMA3.append(i)); + Console.printLine("sma5 + ", i, " = ", SMA5.append(i)) }; - console.readChar() + Console.readChar() } diff --git a/Task/B-zier-curves-Intersections/JavaScript/b-zier-curves-intersections.js b/Task/B-zier-curves-Intersections/JavaScript/b-zier-curves-intersections.js new file mode 100644 index 0000000000..035f0c110f --- /dev/null +++ b/Task/B-zier-curves-Intersections/JavaScript/b-zier-curves-intersections.js @@ -0,0 +1,162 @@ +class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +class QuadSpline { + constructor(c0, c1, c2) { + this.c0 = c0; + this.c1 = c1; + this.c2 = c2; + } +} + +class QuadCurve { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +// Subdivision by de Casteljau's algorithm. +function subdivideQuadSpline(q, t, u, v) { + const s = 1.0 - t; + const c0 = q.c0; + const c1 = q.c1; + const c2 = q.c2; + u.c0 = c0; + v.c2 = c2; + u.c1 = s * c0 + t * c1; + v.c1 = s * c1 + t * c2; + u.c2 = s * u.c1 + t * v.c1; + v.c0 = u.c2; +} + +function subdivideQuadCurve(q, t, u, v) { + subdivideQuadSpline(q.x, t, u.x, v.x); + subdivideQuadSpline(q.y, t, u.y, v.y); +} + +// It is assumed that xa0 <= xa1, ya0 <= ya1, xb0 <= xb1, and yb0 <= yb1. +function rectsOverlap(xa0, ya0, xa1, ya1, xb0, yb0, xb1, yb1) { + return (xb0 <= xa1 && xa0 <= xb1 && yb0 <= ya1 && ya0 <= yb1); +} + +function max3(x, y, z) { return Math.max(Math.max(x, y), z); } +function min3(x, y, z) { return Math.min(Math.min(x, y), z); } + +// This accepts the point as an intersection if the boxes are small enough. +function testIntersect(p, q, tol) { + const pxmin = min3(p.x.c0, p.x.c1, p.x.c2); + const pymin = min3(p.y.c0, p.y.c1, p.y.c2); + const pxmax = max3(p.x.c0, p.x.c1, p.x.c2); + const pymax = max3(p.y.c0, p.y.c1, p.y.c2); + + const qxmin = min3(q.x.c0, q.x.c1, q.x.c2); + const qymin = min3(q.y.c0, q.y.c1, q.y.c2); + const qxmax = max3(q.x.c0, q.x.c1, q.x.c2); + const qymax = max3(q.y.c0, q.y.c1, q.y.c2); + + let exclude = true; + let accept = false; + let intersect = new Point(0, 0); + + if (rectsOverlap(pxmin, pymin, pxmax, pymax, qxmin, qymin, qxmax, qymax)) { + exclude = false; + const xmin = Math.max(pxmin, qxmin); + const xmax = Math.min(pxmax, qxmax); + + if (xmax < xmin) { + throw new Error(`Assertion failure: ${xmax} < ${xmin}`); + } + + if (xmax - xmin <= tol) { + const ymin = Math.max(pymin, qymin); + const ymax = Math.min(pymax, qymax); + + if (ymax < ymin) { + throw new Error(`Assertion failure: ${ymax} < ${ymin}`); + } + + if (ymax - ymin <= tol) { + accept = true; + intersect.x = 0.5 * xmin + 0.5 * xmax; + intersect.y = 0.5 * ymin + 0.5 * ymax; + } + } + } + + return { exclude, accept, intersect }; +} + +function seemsToBeDuplicate(intersects, xy, spacing) { + let seemsToBeDup = false; + let i = 0; + + while (!seemsToBeDup && i !== intersects.length) { + const pt = intersects[i]; + seemsToBeDup = Math.abs(pt.x - xy.x) < spacing && Math.abs(pt.y - xy.y) < spacing; + i++; + } + + return seemsToBeDup; +} + +function findIntersects(p, q, tol, spacing) { + const intersects = []; + const workload = [{ p, q }]; + + // Quit looking after having emptied the workload. + while (workload.length > 0) { + const work = workload.pop(); + const { exclude, accept, intersect } = testIntersect(work.p, work.q, tol); + + if (accept) { + // To avoid detecting the same intersection twice, require some + // space between intersections. + if (!seemsToBeDuplicate(intersects, intersect, spacing)) { + intersects.push(intersect); + } + } else if (!exclude) { + const p0 = new QuadCurve(new QuadSpline(0, 0, 0), new QuadSpline(0, 0, 0)); + const p1 = new QuadCurve(new QuadSpline(0, 0, 0), new QuadSpline(0, 0, 0)); + const q0 = new QuadCurve(new QuadSpline(0, 0, 0), new QuadSpline(0, 0, 0)); + const q1 = new QuadCurve(new QuadSpline(0, 0, 0), new QuadSpline(0, 0, 0)); + + subdivideQuadCurve(work.p, 0.5, p0, p1); + subdivideQuadCurve(work.q, 0.5, q0, q1); + + workload.push({ p: p1, q: q1 }); + workload.push({ p: p1, q: q0 }); + workload.push({ p: p0, q: q1 }); + workload.push({ p: p0, q: q0 }); + } + } + + return intersects; +} + +function main() { + const p = new QuadCurve( + new QuadSpline(-1.0, 0.0, 1.0), + new QuadSpline(0.0, 10.0, 0.0) + ); + + const q = new QuadCurve( + new QuadSpline(2.0, -8.0, 2.0), + new QuadSpline(1.0, 2.0, 3.0) + ); + + const tol = 0.0000001; + const spacing = tol * 10; + + const intersects = findIntersects(p, q, tol, spacing); + + for (const intersect of intersects) { + console.log(`(${intersect.x}, ${intersect.y})`); + } +} + +main(); diff --git a/Task/Babbage-problem/AutoLISP/babbage-problem.l b/Task/Babbage-problem/AutoLISP/babbage-problem.l new file mode 100644 index 0000000000..9636fbb3f5 --- /dev/null +++ b/Task/Babbage-problem/AutoLISP/babbage-problem.l @@ -0,0 +1,54 @@ +;; Let's Create a tool [a function] that helps us check positive integers +;; to see which one's square is the first one that ends in ...269696 +;; It should be noted that a function can be used many times repetitively +;; so let's create that function which will be used many times. + +;; First, define the function, give it a name and parameters; it will look like: +;; (defun [function_name] ([input_parameter] / [local_variables]) +(defun SquareEndsWith269696? (number / ) + ;; Let's have the computer Square the number (whichever number was passed to the function) + (setq number (* number number)) + ;; Now let's convert that number to a string + (setq numberString (itoa number)) + ;; Is the length of the numberString greater than or equal to 6 digits? + (if (>= (strlen numberString) 6) + ;; If it was greater than or equal to 6, we will check the last 6 characters to see if they are equal to "269696" + ;; If this equality check is successful, then we have found our number, and will return a successful function check! + (eq "269696" (substr numberString (- (strlen numberString) 5))) + ;; Otherwise, an unsuccessful function check will be returned + ) +) + +;; Second, we will create a function that only needs to be used once, they do not always need to be used many times +;; Let's use your name as the initiator/name for this function +(defun c:BABBAGE ( / integer SquareFound) + ;; Once we have initiated the function, let's create our first integer to check + (setq integer 1) + ;; Now, let's perform a loop do perform an action many times within the function + ;; We do not want our loop to run infinitely, so let's create a True/False variable to identify if our task is complete + (setq SquareFound nil) + ;; ok, let's use the loop and True/False variable to continually check if we have found our correct integer + (while (not SquareFound) + ;; Now within the loop, let's use our First function to check if we have the correct integer + ;; We will save the new result of our check over our existing True/False variable + (setq SquareFound (SquareEndsWith269696? integer)) + ;; If the square was not found... + (if (not SquareFound) + ;; ...increase our integer number by 1 + (setq integer (1+ integer)) + ) + ;; Once the integer is found, our loop will end and the code will continue forward + ;; Otherwise, it will start back at "(while ..." + ) + ;; If we have made it this far, then our integer has been found! + ;; let's show everyone what the integer is + (prompt + (strcat + "\nThe smallest integer has been found!" + "\nInteger: " (itoa integer) ;; <-- we are converting the integer to a string + "\nSquared: " (itoa (* integer integer)) ;; <-- let's show everyone the squared number to prove it + ) + ) + ;; All done, this last line is not required, but makes the ending cleaner + (princ) +) diff --git a/Task/Babbage-problem/DuckDB/babbage-problem-1.duckdb b/Task/Babbage-problem/DuckDB/babbage-problem-1.duckdb new file mode 100644 index 0000000000..3a634060d8 --- /dev/null +++ b/Task/Babbage-problem/DuckDB/babbage-problem-1.duckdb @@ -0,0 +1,3 @@ +select * from generate_series(500,1000000) t(n) +where (n * n) % 1000000 == 269696 +limit 1; diff --git a/Task/Babbage-problem/DuckDB/babbage-problem-2.duckdb b/Task/Babbage-problem/DuckDB/babbage-problem-2.duckdb new file mode 100644 index 0000000000..807ff512ff --- /dev/null +++ b/Task/Babbage-problem/DuckDB/babbage-problem-2.duckdb @@ -0,0 +1,9 @@ +with recursive integers +as + (select 1::uint64 as n + UNION ALL + select n+1 from integers) + +select n from integers +where (n * n) % 1000000 == 269696 +limit 1; diff --git a/Task/Babbage-problem/Elena/babbage-problem.elena b/Task/Babbage-problem/Elena/babbage-problem.elena index c7c4a77da2..4721be5221 100644 --- a/Task/Babbage-problem/Elena/babbage-problem.elena +++ b/Task/Babbage-problem/Elena/babbage-problem.elena @@ -10,5 +10,5 @@ public program() n += 1 }; - console.printLine(n) + Console.printLine(n) } diff --git a/Task/Babylonian-spiral/EasyLang/babylonian-spiral.easy b/Task/Babylonian-spiral/EasyLang/babylonian-spiral.easy index 888e9c378e..98fc8c6b2a 100644 --- a/Task/Babylonian-spiral/EasyLang/babylonian-spiral.easy +++ b/Task/Babylonian-spiral/EasyLang/babylonian-spiral.easy @@ -1,14 +1,3 @@ -fastfunc findj a norm . - j = floor sqrt norm + 1 - repeat - b = j * j - if a + b < norm : return -1 - if a + b = norm : return j - until j = 0 - j -= 1 - . - return -1 -. proc babylon_spiral nsteps &pts[][] . pts[][] = [ [ 0 0 ] [ 0 1 ] ] norm = 1 @@ -21,16 +10,19 @@ proc babylon_spiral nsteps &pts[][] . for i = 0 to nsteps a = i * i if a > norm div 2 : break 1 - j = findj a norm - if j <> -1 - cands[][] &= [ i, j ] - cands[][] &= [ -i, j ] - cands[][] &= [ i, -j ] - cands[][] &= [ -i, -j ] - cands[][] &= [ j, i ] - cands[][] &= [ -j, i ] - cands[][] &= [ j, -i ] - cands[][] &= [ -j, -i ] + for j = floor sqrt norm + 1 downto 0 + b = j * j + if a + b < norm : break 1 + if a + b = norm + cands[][] &= [ i, j ] + cands[][] &= [ -i, j ] + cands[][] &= [ i, -j ] + cands[][] &= [ -i, -j ] + cands[][] &= [ j, i ] + cands[][] &= [ -j, i ] + cands[][] &= [ j, -i ] + cands[][] &= [ -j, -i ] + . . . . @@ -63,8 +55,9 @@ scy = 100 / (maxy - miny) * 0.96 ty = -miny * scy + 2 tx = -minx * scx + 2 glinewidth 0.1 -for i to len pts[][] - 1 - gline 0 ty 100 ty - gline tx 0 tx 100 - gline pts[i][1] * scx + tx, pts[i][2] * scy + ty, pts[i + 1][1] * scx + tx, pts[i + 1][2] * scy + ty +gline 0 ty 100 ty +gline tx 0 tx 100 +gpenup +for i to len pts[][] + glineto pts[i][1] * scx + tx, pts[i][2] * scy + ty . diff --git a/Task/Babylonian-spiral/FreeBASIC/babylonian-spiral.basic b/Task/Babylonian-spiral/FreeBASIC/babylonian-spiral.basic new file mode 100644 index 0000000000..2312460831 --- /dev/null +++ b/Task/Babylonian-spiral/FreeBASIC/babylonian-spiral.basic @@ -0,0 +1,92 @@ +Const PI = 4 * Atn(1) +Const TAU = 8 * Atn(1) + +Type Punto + x As Integer + y As Integer +End Type + +Sub InitSquares(squares() As Integer, nsteps As Integer) + For i As Integer = 0 To nsteps - 1 + squares(i) = i * i + Next +End Sub + +Sub BabylonianSpiral(points() As Punto, nsteps As Integer) + Dim As Integer squares(nsteps) + InitSquares(squares(), nsteps) + + points(0).x = 0 : points(0).y = 0 + points(1).x = 0 : points(1).y = 1 + + Dim As Integer norm = 1, i, j, k, a, b + Dim As Double theta, value, minvalue + Dim As Punto minimum + + For paso As Integer = 0 To nsteps - 3 + Dim As Punto prev = points(paso + 1) + theta = Atan2(prev.y, prev.x) + + Dim As Integer ncandidates = 0 + Dim As Punto candidates(100) + + Do + norm += 1 + For i = 0 To nsteps - 1 + a = squares(i) + If a > norm / 2 Then Exit For + For j = Int(Sqr(norm)) + 1 To 0 Step -1 + If j < 0 Then Exit For + b = squares(j) + If a + b < norm Then Exit For + If a + b = norm Then + Dim As Punto next_points(0 To 7) + next_points(0).x = i : next_points(0).y = j + next_points(1).x = -i : next_points(1).y = j + next_points(2).x = i : next_points(2).y = -j + next_points(3).x = -i : next_points(3).y = -j + next_points(4).x = j : next_points(4).y = i + next_points(5).x = -j : next_points(5).y = i + next_points(6).x = j : next_points(6).y = -i + next_points(7).x = -j : next_points(7).y = -i + + For k = 0 To 7 + candidates(ncandidates) = next_points(k) + ncandidates += 1 + Next + End If + Next + Next + Loop While ncandidates = 0 + + minvalue = TAU + For k = 0 To ncandidates - 1 + value = (theta - Atan2(candidates(k).y, candidates(k).x) + TAU) + value = value - Int(value / TAU) * TAU + If value < minvalue Then + minvalue = value + minimum = candidates(k) + End If + Next + + points(paso + 2) = minimum + Next + + For i = 0 To nsteps - 2 + points(i + 1).x = points(i).x + points(i + 1).x + points(i + 1).y = points(i).y + points(i + 1).y + Next +End Sub + +' Main program +Dim As Integer nsteps = 40 +Dim As Punto points(0 To nsteps - 1) +BabylonianSpiral(points(), nsteps) + +Print !"The first 40 points of the Babylonian spiral are:\n" +For i As Integer = 0 To nsteps - 1 + Print Using "(###_,###) "; points(i).x; points(i).y; + If (i + 1) Mod 10 = 0 Then Print +Next + +Sleep diff --git a/Task/Balanced-brackets/ArkScript/balanced-brackets.ark b/Task/Balanced-brackets/ArkScript/balanced-brackets.ark new file mode 100644 index 0000000000..1eb2101bb5 --- /dev/null +++ b/Task/Balanced-brackets/ArkScript/balanced-brackets.ark @@ -0,0 +1,24 @@ +(import std.List) + +(let gen_string (fun (length) { + (mut output "") + (while (< (len output) length) { + (set output (+ output (@ "[]" (random 0 1)))) }) + output })) + +(let balanced? (fun (str) { + (mut i 0) + (= + (len str) + (len + (list:takeWhile str (fun (char) { + (if (= "[" char) + (set i (+ i 1)) + (set i (- i 1))) + (>= i 0) }))))})) + +(list:forEach + (list:iota 0 5) + (fun (_) { + (let str (gen_string (random 2 8))) + (print (string:format "{:<8}: {:^6}" str (if (balanced? str) "OK" "NOT OK"))) })) diff --git a/Task/Balanced-brackets/AutoLISP/balanced-brackets.l b/Task/Balanced-brackets/AutoLISP/balanced-brackets.l new file mode 100644 index 0000000000..90ed32a229 --- /dev/null +++ b/Task/Balanced-brackets/AutoLISP/balanced-brackets.l @@ -0,0 +1,12 @@ +(defun BalancedBrackets (str / cntOpen curr) + (setq cntOpen 0) + (setq str (vl-string->list str)) + (while (and (>= cntOpen 0) str) + (setq curr (car str) str (cdr str)) + (cond + ((= 91 curr) (setq cntOpen (1+ cntOpen))) + ((= 93 curr) (setq cntOpen (1- cntOpen))) + ) + ) + (and (null str) (zerop cntOpen)) +) diff --git a/Task/Balanced-brackets/Elena/balanced-brackets.elena b/Task/Balanced-brackets/Elena/balanced-brackets.elena index 4636698372..c09c6651e8 100644 --- a/Task/Balanced-brackets/Elena/balanced-brackets.elena +++ b/Task/Balanced-brackets/Elena/balanced-brackets.elena @@ -1,7 +1,3 @@ -// Generate a string with N opening brackets ("[") and N closing brackets ("]"), in some arbitrary order. -// Determine whether the generated string is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), -// none of which mis-nest. - import system'routines; import extensions; import extensions'text; @@ -10,7 +6,7 @@ randomBrackets(len) { if (0 == len) { - ^emptyString + ^ EmptyString } else { @@ -43,8 +39,8 @@ public program() { var str := randomBrackets(len); - console.printLine("""",str,"""",str.isBalanced ? " is balanced" : " is not balanced") + Console.printLine("""",str,"""",str.isBalanced ? " is balanced" : " is not balanced") }; - console.readChar() + Console.readChar() } diff --git a/Task/Balanced-brackets/Nom/balanced-brackets.num b/Task/Balanced-brackets/Nom/balanced-brackets.num new file mode 100644 index 0000000000..eba2a9f889 --- /dev/null +++ b/Task/Balanced-brackets/Nom/balanced-brackets.num @@ -0,0 +1,19 @@ +read; +"[","]" { add "*"; push; } +[:space:] { clear; } +!"" { + clear; add "Sorry, only brackets [] allowed in this!\n"; + print; quit; +} +parse> +pop; pop; +"[*]*","ob*ob*" { clear; add "ob*"; push; .reparse } +pop; +"[*ob*]*" { clear; add "ob*"; push; .reparse } + +(eof) { + "ob*" { clear; add "brackets look balanced!\n"; print; quit; } + clear; add "brackets not balanced.\n"; print; quit; +} + +push; push; push; diff --git a/Task/Balanced-brackets/Pluto/balanced-brackets.pluto b/Task/Balanced-brackets/Pluto/balanced-brackets.pluto new file mode 100644 index 0000000000..a38471fe49 --- /dev/null +++ b/Task/Balanced-brackets/Pluto/balanced-brackets.pluto @@ -0,0 +1,36 @@ +local function is_balanced(s) + if s == "" then + return true + end + local counter_left = 0 -- number of left brackets so far unmatched + for i = 1, #s do + local c = s[i] + if c == "[" then + counter_left += 1 + elseif counter_left > 0 do + counter_left -= 1 + else + return false + end + end + return counter_left == 0 +end + +print("Checking examples in task description:") +local brackets = {"", "[]", "][", "[][]", "][][", "[[][]]", "[]][[]"} +for brackets as b do + local res = is_balanced(b) + local bb = (b != "") ? b : "(empty)" + print(string.format("%-8s %s", bb, res ? "OK" : "NOT OK")) +end + +print("\nChecking 7 random strings of brackets of length 8:") +math.randomseed(os.time()) +for i = 1, 7 do + local b = "" + for j = 1, 8 do + b ..= (math.random(0, 1) == 0) ? "[" : "]" + end + local res = is_balanced(b) + print(string.format("%s %s", b, res ? "OK" : "NOT OK")) +end diff --git a/Task/Balanced-ternary/JavaScript/balanced-ternary.js b/Task/Balanced-ternary/JavaScript/balanced-ternary.js new file mode 100644 index 0000000000..29ae058c1c --- /dev/null +++ b/Task/Balanced-ternary/JavaScript/balanced-ternary.js @@ -0,0 +1,203 @@ +class BTernary { + constructor(input) { + if (typeof input === 'string') { + let i = 0; + while (i < input.length && input.charAt(i) === '0') { + i++; + } + this.value = input.substring(i); + } else if (typeof input === 'number') { + this.value = this.convertToBT(input); + } + } + + convertToBT(v) { + if (v < 0) { + return this.flip(this.convertToBT(-v)); + } + if (v === 0) { + return ""; + } + const rem = this.mod3(v); + if (rem === 0) { + return this.convertToBT(Math.floor(v / 3)) + "0"; + } + if (rem === 1) { + return this.convertToBT(Math.floor(v / 3)) + "+"; + } + if (rem === 2) { + return this.convertToBT(Math.floor((v + 1) / 3)) + "-"; + } + return "You can't see me"; + } + + flip(s) { + let flip = ""; + for (let i = 0; i < s.length; i++) { + if (s.charAt(i) === '+') { + flip += '-'; + } else if (s.charAt(i) === '-') { + flip += '+'; + } else { + flip += '0'; + } + } + return flip; + } + + mod3(v) { + if (v > 0) { + return v % 3; + } + v = v % 3; + return (v + 3) % 3; + } + + intValue() { + let sum = 0; + const s = this.value; + for (let i = 0; i < s.length; i++) { + const c = s.charAt(s.length - i - 1); + let dig = 0; + if (c === '+') { + dig = 1; + } else if (c === '-') { + dig = -1; + } + sum += dig * Math.pow(3, i); + } + return sum; + } + + add(that) { + let a = this.value; + let b = that.value; + + const longer = a.length > b.length ? a : b; + let shorter = a.length > b.length ? b : a; + + while (shorter.length < longer.length) { + shorter = '0' + shorter; + } + + a = longer; + b = shorter; + + let carry = '0'; + let sum = ""; + for (let i = 0; i < a.length; i++) { + const place = a.length - i - 1; + const digisum = this.addDigitsWithCarry(a.charAt(place), b.charAt(place), carry); + if (digisum.length !== 1) { + carry = digisum.charAt(0); + } else { + carry = '0'; + } + sum = digisum.charAt(digisum.length - 1) + sum; + } + sum = carry + sum; + + return new BTernary(sum); + } + + addDigitsWithCarry(a, b, carry) { + const sum1 = this.addDigits(a, b); + const sum2 = this.addDigits(sum1.charAt(sum1.length - 1), carry); + + if (sum1.length === 1) { + return sum2; + } + if (sum2.length === 1) { + return sum1.charAt(0) + sum2; + } + return sum1.charAt(0) + ""; + } + + addDigits(a, b) { + let sum = ""; + if (a === '0') { + sum = b + ""; + } else if (b === '0') { + sum = a + ""; + } else if (a === '+') { + if (b === '+') { + sum = "+-"; + } else { + sum = "0"; + } + } else { + if (b === '+') { + sum = "0"; + } else { + sum = "-+"; + } + } + return sum; + } + + neg() { + return new BTernary(this.flip(this.value)); + } + + sub(that) { + return this.add(that.neg()); + } + + mul(that) { + const one = new BTernary(1); + const zero = new BTernary(0); + let mul = new BTernary(0); + + let flipflag = 0; + if (that.compareTo(zero) === -1) { + that = that.neg(); + flipflag = 1; + } + + for (let i = new BTernary(1); i.compareTo(that) < 1; i = i.add(one)) { + mul = mul.add(this); + } + + if (flipflag === 1) { + mul = mul.neg(); + } + return mul; + } + + equals(that) { + return this.value === that.value; + } + + compareTo(that) { + if (this.intValue() > that.intValue()) { + return 1; + } else if (this.equals(that)) { + return 0; + } + return -1; + } + + toString() { + return this.value; + } +} + +// Main execution +function main() { + const a = new BTernary("+-0++0+"); + const b = new BTernary(-436); + const c = new BTernary("+-++-"); + + console.log("a=" + a.intValue()); + console.log("b=" + b.intValue()); + console.log("c=" + c.intValue()); + console.log(); + + // result = a * (b - c) + const result = a.mul(b.sub(c)); + + console.log("result= " + result + " " + result.intValue()); +} + +// Run the main function +main(); diff --git a/Task/Base64-decode-data/Pluto/base64-decode-data.pluto b/Task/Base64-decode-data/Pluto/base64-decode-data.pluto new file mode 100644 index 0000000000..b8359fd691 --- /dev/null +++ b/Task/Base64-decode-data/Pluto/base64-decode-data.pluto @@ -0,0 +1,4 @@ +local base64 = require("base64") + +local s = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=" +print(base64.decode(s)) diff --git a/Task/Base64-decode-data/Zig/base64-decode-data.zig b/Task/Base64-decode-data/Zig/base64-decode-data.zig new file mode 100644 index 0000000000..cad232e18b --- /dev/null +++ b/Task/Base64-decode-data/Zig/base64-decode-data.zig @@ -0,0 +1,86 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; +const Allocator = std.mem.Allocator; + +const INPUT = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"; +const UPPERCASE_OFFSET: i8 = -65; +const LOWERCASE_OFFSET: i8 = 26 - 97; +const NUM_OFFSET: i8 = 52 - 48; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + print("Input: {s}\n", .{INPUT}); + + // Create a dynamic array to collect binary strings + var binary_strings = ArrayList([]const u8).init(allocator); + defer { + for (binary_strings.items) |item| { + allocator.free(item); + } + binary_strings.deinit(); + } + + // Process each character and convert to binary + for (INPUT) |ch| { + if (ch == '=') continue; // Filter '=' chars + + // Map char values using Base64 Characters Table + const ascii: i8 = @intCast(ch); + const convert: u8 = switch (ch) { + '0'...'9' => @intCast(ascii + NUM_OFFSET), + 'a'...'z' => @intCast(ascii + LOWERCASE_OFFSET), + 'A'...'Z' => @intCast(ascii + UPPERCASE_OFFSET), + '+' => 62, + '/' => 63, + else => { + print("Not a valid base64 encoded string\n", .{}); + return; + }, + }; + + // Convert to binary format (6 bits for base64) + const binary_str = try std.fmt.allocPrint(allocator, "{b:0>6}", .{convert}); + try binary_strings.append(binary_str); + } + + // Concatenate all binary strings + var total_len: usize = 0; + for (binary_strings.items) |item| { + total_len += item.len; + } + + const concatenated = try allocator.alloc(u8, total_len); + defer allocator.free(concatenated); + + var pos: usize = 0; + for (binary_strings.items) |item| { + @memcpy(concatenated[pos..pos + item.len], item); + pos += item.len; + } + + // Split into 8-character chunks and convert to bytes + var result_bytes = ArrayList(u8).init(allocator); + defer result_bytes.deinit(); + + var i: usize = 0; + while (i + 8 <= concatenated.len) : (i += 8) { + const chunk = concatenated[i..i + 8]; + const byte_value = std.fmt.parseInt(u8, chunk, 2) catch |err| { + print("Error parsing binary: {}\n", .{err}); + return; + }; + try result_bytes.append(byte_value); + } + + // Convert to UTF-8 string and print + const result_str = result_bytes.items; + if (std.unicode.utf8ValidateSlice(result_str)) { + print("Output: {s}\n", .{result_str}); + } else { + print("Invalid UTF-8 sequence\n", .{}); + } +} diff --git a/Task/Bell-numbers/Pluto/bell-numbers.pluto b/Task/Bell-numbers/Pluto/bell-numbers.pluto new file mode 100644 index 0000000000..5cabc1baca --- /dev/null +++ b/Task/Bell-numbers/Pluto/bell-numbers.pluto @@ -0,0 +1,32 @@ +local bigint = require "bigint" +local fmt = require "fmt" + +local function bell_triangle(n) + local zero = bigint.new(0) + local tri = {} + for i = 1, n do + tri[i] = {} + for j = 1, i - 1 do tri[i][j] = zero end + end + tri[2][1] = bigint.new(1) + for i = 3, n do + tri[i][1] = tri[i - 1][i - 2] + for j = 2, i - 1 do + tri[i][j] = tri[i][j - 1] + tri[i - 1][j - 1] + end + end + return tri +end + +local bt = bell_triangle(51) +print("First fifteen and fiftieth Bell numbers:") +for i = 2, 16 do + local s = bt[i][1]:tostring() + fmt.print("%2d: %s", i - 1, fmt.int(s)) +end +local s50 = bt[51][1]:tostring() +fmt.print("%2d: %s", 50, fmt.int(s50)) +print("\nThe first ten rows of Bell's triangle:") +for i = 2, 11 do + fmt.tprint("%7s", bt[i]:map(|j| -> fmt.int(j:tostring())), #bt[i]) +end diff --git a/Task/Benfords-law/DuckDB/benfords-law.duckdb b/Task/Benfords-law/DuckDB/benfords-law.duckdb new file mode 100644 index 0000000000..ec7d41aaa2 --- /dev/null +++ b/Task/Benfords-law/DuckDB/benfords-law.duckdb @@ -0,0 +1,22 @@ +with recursive fib (n1, n2) as ( + select + 1::double, 1::double + union all + select n2, n1+n2 + from fib + ), +lastdigits as ( + select format('{}', n1)[1]::int as digit + from fib + limit 1000 -- N.B. + ), +counts as ( + select digit, count() as actual + from lastdigits group by digit + ), +total as ( + select count() as total from lastdigits + ) +select digit, actual, (total * log(10, 1 + (1 / digit))) as expected + from counts, total + order by digit; diff --git a/Task/Bernoulli-numbers/R/bernoulli-numbers.r b/Task/Bernoulli-numbers/R/bernoulli-numbers.r index e6c84acce2..71e908ffcf 100644 --- a/Task/Bernoulli-numbers/R/bernoulli-numbers.r +++ b/Task/Bernoulli-numbers/R/bernoulli-numbers.r @@ -1,8 +1,6 @@ -library(pracma) +library(gmp) -for (idx in c(1,2*0:30)) { - b <- bernoulli(idx) - d <- as.character(denominator(b)) - n <- as.character(numerator(b)) - cat("B(",idx,") = ",n,"/",d,"\n", sep = "") -} +indices <- c(0,1,2*(1:30)) +bnums <- sapply(indices, BernoulliQ) +names(bnums) <- paste0("B(", indices, ")") +print(bnums, initLine=FALSE) diff --git a/Task/Bernoulli-numbers/REXX/bernoulli-numbers.rexx b/Task/Bernoulli-numbers/REXX/bernoulli-numbers.rexx index a1673236bf..83184fac1f 100644 --- a/Task/Bernoulli-numbers/REXX/bernoulli-numbers.rexx +++ b/Task/Bernoulli-numbers/REXX/bernoulli-numbers.rexx @@ -1,55 +1,129 @@ -/*REXX program calculates N number of Bernoulli numbers expressed as vulgar fractions.*/ -parse arg N .; if N=='' | N=="," then N= 60 /*Not specified? Then use the default.*/ -numeric digits max(9, n*2) /*increase the decimal digits if needed*/ -w= max(length(N), 4); Nw= N + w + N % 4 /*used for aligning (output) fractions.*/ -say 'B(n)' center("Bernoulli numbers expressed as vulgar fractions", max(78-w, Nw) ) -say copies('─',w) copies("─", max(78-w,Nw+2*w)) /*display 2nd line of title, separators*/ -!.= .; do #=0 to N /*process the numbers from 0 ──► N. */ - b= bern(#); if b==0 then iterate /*calculate Bernoulli number, skip if 0*/ - indent= max(0, nW - pos('/', b) ) /*calculate the alignment (indentation)*/ - say right(#, w) left('', indent) b /*display the indented Bernoulli number*/ - end /*#*/ /* [↑] align the Bernoulli fractions. */ -exit 0 /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -bern: parse arg x; if x==0 then return '1/1' /*handle the special case of zero. */ - if x==1 then return '-1/2' /* " " " " " one. */ - if x//2 then return 0 /* " " " " " odds > 1.*/ - do j=2 to x by 2; jp= j+1 /*process the positive integers up to X*/ - sn= 1 - j /*define the numerator. */ - sd= 2 /* " " denominator. */ - do k=2 to j-1 by 2 /*calculate a SN/SD sequence. */ - parse var @.k bn '/' ad /*get a previously calculated fraction.*/ - an= comb(jp, k) * bn /*use COMBination for the next term. */ - $lcm= LCM(sd, ad) /*use Least Common Denominator function*/ - sn= $lcm % sd * sn; sd= $lcm /*calculate the current numerator. */ - an= $lcm % ad * an /* " " next " */ - sn= sn + an /* " " current " */ - end /*k*/ /* [↑] calculate the SN/SD sequence.*/ - sn= -sn /*flip the sign for the numerator. */ - sd= sd * jp /*calculate the denominator. */ - if sn\==1 then do; _= GCD(sn, sd) /*get the Greatest Common Denominator.*/ - sn= sn%_; sd= sd%_ /*reduce the numerator and denominator.*/ - end /* [↑] done with the reduction(s). */ - @.j= sn'/'sd /*save the result for the next round. */ - end /*j*/ /* [↑] done calculating Bernoulli #'s.*/ - return sn'/'sd -/*──────────────────────────────────────────────────────────────────────────────────────*/ -comb: procedure expose !.; parse arg x,y; if x==y then return 1 - if !.C.x.y\==. then return !.C.x.y /*combination computed before?*/ - if x-y < y then y= x-y /*x-y < y? Then use a new Y.*/ - z= perm(x, y); do j=2 for y-1; z= z % j - end /*j*/ - !.C.x.y= z; return z /*assign memoization & return.*/ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -GCD: procedure; parse arg x,y; x= abs(x) - do until y==0; parse value x//y y with y x; end; return x -/*──────────────────────────────────────────────────────────────────────────────────────*/ -LCM: procedure; parse arg x,y /*X=ABS(X); Y=ABS(Y) not needed for Bernoulli #s.*/ - /*IF Y==0 THEN RETURN 0 " " " " " */ - $= x * y /*calculate part of the LCM here. */ - do until y==0; parse value x//y y with y x - end /*until*/ /* [↑] this is a short & fast GCD*/ - return $ % x /*divide the pre─calculated value.*/ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -perm: procedure expose !.; parse arg x,y; if !.P.x.y\==. then return !.P.x.y - z= 1; do j=x-y+1 to x; z= z*j; end; !.P.x.y= z; return z +-- 30 Jul 2025 +include Settings +numeric digits 16 +arg xx +if xx = '' then + xx=60 +ss=(xx>0); xx=Abs(xx) + +say 'BERNOULLI NUMBERS' +say version +say + +call Time('r') +call Rational1 xx +if ss then + call ShowFractions xx +call Timer + +call Time('r') +call Rational2 xx +if ss then + call ShowFractions xx +call Timer + +call Time('r') +call Decimal1 xx +if ss then + call ShowDecimals xx +call Timer + +call Time('r') +call Decimal2 xx +if ss then + call ShowDecimals xx +call Timer +exit + +Rational1: +procedure expose Memo. Bern. +arg xx +say 'Rational arithmetic' +say 'cf Generating function' +numeric digits Max(Digits(),3*xx) +Bern.=0; Bern.0='1 1'; Bern.1='-1 2' +do n = 2 by 2 to xx + s=0 + do k = 0 to n-1 + s=Addq(s,Scaleq(Bern.k,Comb(n+1,k))) + end k + Bern.n=Mulq(Negq(s),Invq(n+1)) +end n +return + +Rational2: +procedure expose Memo. Bern. +arg xx +say 'Numerator and denominator calculations' +say 'cf Double sum formula optimized' +numeric digits Max(Digits(),3*xx) +Bern.=0; Bern.0='1 1'; Bern.1='-1 2' +do j = 2 by 2 to xx + jp=j+1; sn=1-j; sd=2 + do k = 2 by 2 to j-1 + bn=bn.k; ad=ad.k; an=Comb(jp,k)*bn; tl=Lcm(sd,ad) + sn=tl%sd*sn; sd=tl; an=tl%ad*an; sn=sn+an + end k + sn=-sn; sd=sd*jp; bn.j=sn; ad.j=sd; g=Gcd(Abs(sn),sd) + Bern.j=sn/g sd/g +end j +return + +ShowFractions: +procedure expose Bern. +arg xx +w=Length(Word(Bern.xx,1))+2 +say ' Bn' Right('Num',w) '/' Left('Den',10) 'Decimal' +do i = 0 to xx + if Bern.i <> 0 then do + parse var Bern.i num den + say Right(i,3) Right(num,w) '/' Left(den,10) Digit(num/den,16) + end +end i +return + +Decimal1: +procedure expose Bern. Memo. +arg xx +say 'Floating point calculations' +say 'cf Generating function' +numeric digits Max(Digits(),2*xx) +Bern.=0; Bern.0=1; Bern.1='-0.5' +do n = 2 by 2 to xx + s=0 + do k = 0 to n-1 + s=s+Bern.k*Comb(n+1,k) + end k + Bern.n=-s/(n+1) +end n +return xx + +Decimal2: +procedure expose Bern. Memo. +arg xx +say 'Floating point calculations' +say 'cf Akiyama-Tanigawa' +numeric digits Max(Digits(),3*xx) +Bern.=0; Bern.0=1; Bern.1=-0.5 +do i = 2 by 2 to xx + do m = 0 to i + a.m=1/(m+1) + do j = m by -1 to 1 + j1=j-1; a.j1=j*(a.j1-a.j) + end + end m + Bern.i=a.0 +end i +return xx + +ShowDecimals: +procedure expose Bern. +arg xx +say ' Bn' 'Decimal' +do i = 0 to xx + if Bern.i <> 0 then + say Right(i,3) Digit(Bern.i,16) +end i +return + +include Math diff --git a/Task/Best-shuffle/Elena/best-shuffle.elena b/Task/Best-shuffle/Elena/best-shuffle.elena index 99e99cba05..2cbdf0b886 100644 --- a/Task/Best-shuffle/Elena/best-shuffle.elena +++ b/Task/Best-shuffle/Elena/best-shuffle.elena @@ -41,8 +41,8 @@ public program() { var shuffled_s := s.Shuffled; - console.printLine("The best shuffle of ",s," is ",shuffled_s,"(",shuffled_s.score(s),")") + Console.printLine("The best shuffle of ",s," is ",shuffled_s,"(",shuffled_s.score(s),")") }; - console.readChar() + Console.readChar() } diff --git a/Task/Best-shuffle/Factor/best-shuffle.factor b/Task/Best-shuffle/Factor/best-shuffle.factor new file mode 100644 index 0000000000..ac380801c1 --- /dev/null +++ b/Task/Best-shuffle/Factor/best-shuffle.factor @@ -0,0 +1,26 @@ +USING: arrays combinators.short-circuit formatting kernel random +sequences sequences.extras ; + +:: best-shuffle ( str -- str' ) + str clone :> new-str + str length :> n + n >array randomize :> range1 + n >array randomize :> range2 + + range1 [| i | + range2 [| j | + { + [ i j = ] + [ i new-str nth j new-str nth = ] + [ i str nth j new-str nth = ] + [ i new-str nth j str nth = ] + } 0|| [ + i j new-str exchange + ] unless + ] each + ] each + + new-str ; + +: best-shuffle. ( str -- ) + dup best-shuffle 2dup [ = ] 2count "%s, %s, (%d)\n" printf ; diff --git a/Task/Best-shuffle/YAMLScript/best-shuffle.ys b/Task/Best-shuffle/YAMLScript/best-shuffle.ys new file mode 100644 index 0000000000..2874ddd1dd --- /dev/null +++ b/Task/Best-shuffle/YAMLScript/best-shuffle.ys @@ -0,0 +1,44 @@ +!YS-v0 + +defn main(input): + say: read-string(input) + .map(best-shuffle):vec + +defn best-shuffle(s): + ref =: s:group-indices:cycles + prm =: concat.apply(map(partial(rotate 1) ref)) + ref =: concat(ref*) + + map(vector ref prm): + .sort-by(first _) + .map(second) + .map(partial(get s)) + .str(*) + .call(\([s _ s.score(_)]) _) + +defn score(before after): + map(== before after) + .filter(true?).# + +defn group-indices(s): + map-indexed(vector s) + .merge-vecs({}):vals + .sort-by(count _):reverse + +defn cycles(coll): + n =: coll.0.# + cycle =: range(n):cycle + coll =: concat(coll*) + map(vector coll cycle): + .merge-vecs([]) + +defn rotate(n coll): + c =: coll.# + n =: (c + n) % c + concat coll.drop(n): coll.take(n) + +defn merge-vecs(vecs init): + reduce _ init vecs: + fn(counts [index x]): + assoc counts x: + counts.$x.or([]).conj(index) diff --git a/Task/Bifid-cipher/Zig/bifid-cipher.zig b/Task/Bifid-cipher/Zig/bifid-cipher.zig new file mode 100644 index 0000000000..1647e357f2 --- /dev/null +++ b/Task/Bifid-cipher/Zig/bifid-cipher.zig @@ -0,0 +1,164 @@ +const std = @import("std"); + +const Point = struct { + row: i32, + col: i32, +}; + +const Bifid = struct { + grid: [][]u8, + coordinates: std.AutoHashMap(u8, Point), + n: i32, + allocator: std.mem.Allocator, + + pub fn init(allocator: std.mem.Allocator, n: i32, text: []const u8) !*Bifid { + if (text.len != @as(usize, @intCast(n * n))) { + return error.IncorrectLength; + } + + var self = try allocator.create(Bifid); + self.* = .{ + .grid = try allocator.alloc([]u8, @intCast(n)), + .coordinates = std.AutoHashMap(u8, Point).init(allocator), + .n = n, + .allocator = allocator, + }; + + for (0..@intCast(n)) |i| { + self.grid[i] = try allocator.alloc(u8, @intCast(n)); + } + + var row: i32 = 0; + var col: i32 = 0; + + for (text) |ch| { + self.grid[@intCast(row)][@intCast(col)] = ch; + try self.coordinates.put(ch, .{ .row = row, .col = col }); + + col += 1; + if (col == n) { + col = 0; + row += 1; + } + } + + if (n == 5) { + // Handle I/J as the same letter in traditional 5x5 grid + if (self.coordinates.get('I')) |i_coords| { + try self.coordinates.put('J', i_coords); + } + } + + return self; + } + + pub fn deinit(self: *Bifid) void { + for (self.grid) |row| { + self.allocator.free(row); + } + self.allocator.free(self.grid); + self.coordinates.deinit(); + self.allocator.destroy(self); + } + + pub fn encrypt(self: *const Bifid, text: []const u8, allocator: std.mem.Allocator) ![]u8 { + var row_one = std.ArrayList(i32).init(allocator); + defer row_one.deinit(); + var row_two = std.ArrayList(i32).init(allocator); + defer row_two.deinit(); + + for (text) |ch| { + if (self.coordinates.get(ch)) |coordinate| { + try row_one.append(coordinate.row); + try row_two.append(coordinate.col); + } + } + + // Extend row_one with all elements from row_two + for (row_two.items) |col| { + try row_one.append(col); + } + + var result = std.ArrayList(u8).init(allocator); + var i: usize = 0; + while (i < row_one.items.len - 1) : (i += 2) { + const r = @as(usize, @intCast(row_one.items[i])); + const c = @as(usize, @intCast(row_one.items[i + 1])); + try result.append(self.grid[r][c]); + } + + return result.toOwnedSlice(); + } + + pub fn decrypt(self: *const Bifid, text: []const u8, allocator: std.mem.Allocator) ![]u8 { + var row = std.ArrayList(i32).init(allocator); + defer row.deinit(); + + for (text) |ch| { + if (self.coordinates.get(ch)) |coordinate| { + try row.append(coordinate.row); + try row.append(coordinate.col); + } + } + + const middle = row.items.len / 2; + + var result = std.ArrayList(u8).init(allocator); + + for (0..middle) |i| { + const r = @as(usize, @intCast(row.items[i])); + const c = @as(usize, @intCast(row.items[i + middle])); + try result.append(self.grid[r][c]); + } + + return result.toOwnedSlice(); + } + + pub fn display(self: *const Bifid) void { + for (self.grid) |row| { + for (row) |ch| { + std.debug.print("{c} ", .{ch}); + } + std.debug.print("\n", .{}); + } + } +}; + +fn runTest(bifid: *const Bifid, message: []const u8, allocator: std.mem.Allocator) !void { + std.debug.print("Using Polybius square:\n", .{}); + bifid.display(); + std.debug.print("Message: {s}\n", .{message}); + + const encrypted = try bifid.encrypt(message, allocator); + defer allocator.free(encrypted); + std.debug.print("Encrypted: {s}\n", .{encrypted}); + + const decrypted = try bifid.decrypt(encrypted, allocator); + defer allocator.free(decrypted); + std.debug.print("Decrypted: {s}\n\n", .{decrypted}); +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const message1 = "ATTACKATDAWN"; + const message2 = "FLEEATONCE"; + const message3 = "THEINVASIONWILLSTARTONTHEFIRSTOFJANUARY"; + + const bifid1 = try Bifid.init(allocator, 5, "ABCDEFGHIKLMNOPQRSTUVWXYZ"); + defer bifid1.deinit(); + + const bifid2 = try Bifid.init(allocator, 5, "BGWKZQPNDSIOAXEFCLUMTHYVR"); + defer bifid2.deinit(); + + try runTest(bifid1, message1, allocator); + try runTest(bifid2, message2, allocator); + try runTest(bifid2, message1, allocator); + try runTest(bifid1, message2, allocator); + + const bifid3 = try Bifid.init(allocator, 6, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + defer bifid3.deinit(); + try runTest(bifid3, message3, allocator); +} diff --git a/Task/Bin-given-limits/DuckDB/bin-given-limits-1.duckdb b/Task/Bin-given-limits/DuckDB/bin-given-limits-1.duckdb new file mode 100644 index 0000000000..3ac65257db --- /dev/null +++ b/Task/Bin-given-limits/DuckDB/bin-given-limits-1.duckdb @@ -0,0 +1,24 @@ +# Return 'inf'::DOUBLE if the value is too large +# Assume limits is sorted +create or replace function classify(x, limits) as ( + with recursive cte as ( + select 0 as i, null as found + union all + select i+1, if(x < limits[1+i], limits[1+i], null) as found + from cte + where found is null and i < length(limits) + ) + select coalesce(last(found order by i), 'inf'::DOUBLE) from cte +); + +create or replace function bins(data, limits) as table ( + select value, classify(value, limits) + from unnest(data) _(value) +); + +set variable limits = [23, 37, 43, 53, 67, 83]; +set variable data = [95,21,94,12,99,4,70,75,83,93,52,80,57,5,53,86,65,17,92,83,71,61,54,58,47, + 16, 8, 9,32,84,7,87,46,19,30,37,96,6,98,40,79,97,45,64,60,29,49,36,43,55]; + +select histogram(boundary) +from bins(getvariable('data'), getvariable('limits') ) t(value, boundary); diff --git a/Task/Bin-given-limits/DuckDB/bin-given-limits-2.duckdb b/Task/Bin-given-limits/DuckDB/bin-given-limits-2.duckdb new file mode 100644 index 0000000000..dcd69d9fe2 --- /dev/null +++ b/Task/Bin-given-limits/DuckDB/bin-given-limits-2.duckdb @@ -0,0 +1,14 @@ +# "pretty print" the histogram as a table +create or replace function pp(data, limits) as table ( + with hist as ( + select histogram(boundary) as h + from bins(data, limits) t(value, boundary) + ), + upper as (select h['inf'::DOUBLE][1] as upper from hist) + select '< ' || x::VARCHAR as bin, (select coalesce(h[x][1],0) from hist) as frequency + from unnest(limits) _(x) + union all + select '< inf', upper from upper +); + +from pp(getvariable('data'), getvariable('limits')); diff --git a/Task/Binary-digits/DuckDB/binary-digits-1.duckdb b/Task/Binary-digits/DuckDB/binary-digits-1.duckdb new file mode 100644 index 0000000000..b0439c7cc0 --- /dev/null +++ b/Task/Binary-digits/DuckDB/binary-digits-1.duckdb @@ -0,0 +1,2 @@ +SELECT n, format('{:b}', n) +FROM (select unnest(range(0, 6) || [50, 9000]) as n); diff --git a/Task/Binary-digits/DuckDB/binary-digits-2.duckdb b/Task/Binary-digits/DuckDB/binary-digits-2.duckdb new file mode 100644 index 0000000000..943b003cac --- /dev/null +++ b/Task/Binary-digits/DuckDB/binary-digits-2.duckdb @@ -0,0 +1,22 @@ +# n is assumed to be a non-negative integer +CREATE OR REPLACE FUNCTION binary_digits(n) as ( + WITH RECURSIVE cte(num, str) as ( + -- Base case + SELECT n, '' + UNION ALL + -- Recursive case: divide by 2 and build the binary string + SELECT num // 2, (num % 2) || str + FROM cte + WHERE num > 0 + ) + SELECT CASE WHEN str = '' THEN '0' ELSE str END + FROM cte + WHERE num = 0 + LIMIT 1 +); + +select n, binary_digits(n) +from (select unnest(range(0, 6) || [50, 9000]) as n); + +.maxwidth 200 +select n, binary_digits(n) from (select 123456789123456789123456789123456789 as n) diff --git a/Task/Binary-digits/Elena/binary-digits.elena b/Task/Binary-digits/Elena/binary-digits.elena index dbab2c5f2b..163e2ca4b3 100644 --- a/Task/Binary-digits/Elena/binary-digits.elena +++ b/Task/Binary-digits/Elena/binary-digits.elena @@ -5,6 +5,6 @@ public program() { new int[]{5,50,9000}.forEach::(n) { - console.printLine(n.toString(2)) + Console.printLine(n.toString(2)) } } diff --git a/Task/Binary-digits/Haxe/binary-digits.haxe b/Task/Binary-digits/Haxe/binary-digits.haxe new file mode 100644 index 0000000000..f732d3f6e8 --- /dev/null +++ b/Task/Binary-digits/Haxe/binary-digits.haxe @@ -0,0 +1,15 @@ +class Main { + static public function main() { + var integers = [5, 50, 9000]; + + for (i in integers) { + var bin = ""; + while (i > 1) { + bin = (i % 2) + bin; + i = Std.int(i / 2); + } + bin = i + bin; + trace(bin); + } + } +} diff --git a/Task/Binary-digits/Icon/binary-digits.icon b/Task/Binary-digits/Icon/binary-digits-1.icon similarity index 100% rename from Task/Binary-digits/Icon/binary-digits.icon rename to Task/Binary-digits/Icon/binary-digits-1.icon diff --git a/Task/Binary-digits/Icon/binary-digits-2.icon b/Task/Binary-digits/Icon/binary-digits-2.icon new file mode 100644 index 0000000000..54b725932a --- /dev/null +++ b/Task/Binary-digits/Icon/binary-digits-2.icon @@ -0,0 +1,12 @@ +procedure main() + every write(bstring(0|5|50|255|1285|9000)) +end + +procedure bstring(i) + s := "" + repeat{ + s := string(iand(i,1)) || s + if (i := ishift(i,-1)) = 0 then break + } + return s +end diff --git a/Task/Binary-digits/RISC-V-Assembly/binary-digits.asm b/Task/Binary-digits/RISC-V-Assembly/binary-digits.asm new file mode 100644 index 0000000000..4c9a8b927b --- /dev/null +++ b/Task/Binary-digits/RISC-V-Assembly/binary-digits.asm @@ -0,0 +1,185 @@ + # riscv assembly raspberry pico2 rp2350 +# program binaryDigits.s +# For construction see the riscv main page +# Exec by connexion putty com3 +/*********************************************/ +/* CONSTANTES */ +/********************************************/ +.equ LENGTHDEC, 12 +.equ LENGTHBIN, 33 +/*******************************************/ +/* INITIALED DATAS */ +/*******************************************/ +.data +szMessStart: .asciz "Program riscv start.\r\n" + +szMessAffdeb: .asciz "Decimal value : " +szMessAfffin: .asciz " binary value : " +szCarriageReturn: .asciz " \r\n" +/*******************************************/ +/* UNINITIALED DATA */ +/*******************************************/ +.bss +sConvDec: .skip LENGTHDEC +sConvBin: .skip LENGTHBIN +.align 2 +/**********************************************/ +/* SECTION CODE */ +/**********************************************/ +.text +.global main + +main: + call stdio_init_all # général init +1: # start loop connexion + li a0,0 # raz argument register + call tud_cdc_n_connected # connexion usb by function sdk c++ + beqz a0,1b # return code = zero ? loop + + la a0,szMessStart # message address + call writeString # display string + li a0,50 + call conversion + li a0,-1 + call conversion + li a0,1 + call conversion + li a0,1<<30 + call conversion + call getchar +100: # final loop + j 100b +/************************************/ +/* conversion and display */ +/***********************************/ +/* a0 value */ +conversion: + addi sp, sp, -8 + sw ra, 0(sp) # save registers + sw s0, 4(sp) + mv s0,a0 + la a0,szMessAffdeb + call writeString # display message + mv a0,s0 + la a1,sConvDec + call conversion10S + call writeString # display + la a0,szMessAfffin + call writeString # display message + mv a0,s0 + la a1,sConvBin + call conversion2 + la a0,sConvBin + call writeString # display message + la a0,szCarriageReturn + call writeString # display newline + +100: + lw ra, 0(sp) # restaur registers + lw s0, 4(sp) + addi sp, sp, 8 + ret +/************************************/ +/* binary conversion */ +/***********************************/ +/* a0 value */ +/* a1 result area address */ +/* size mini 33 character */ +conversion2: # INFO: conversion2 + addi sp, sp, -8 # save registres + sw ra, 0(sp) + li t2,0 + li t1,0 +1: + slt t3,a0,x0 # if negative bit 31 is 1 + + slli a0,a0,1 # shift left one bit + add t0,a1,t1 # compute indice to store char in area + addi t3,t3,'0' # conversion byte to ascii char + sb t3,(t0) # store char in area + addi t1,t1,1 # next position + li t0,7 # for add a space separation + beq t2,t0,4f + li t0,15 # for add a space + beq t2,t0,4f + li t0,23 # for add a space + beq t2,t0,4f + j 5f + +4: # store space + li t3,' ' + add t0,a1,t1 + sb t3,(t0) + addi t1,t1,1 +5: + addi t2,t2,1 # increment bit indice + li t0,32 # maxi ? + blt t2,t0,1b # and loop + + add t0,a1,t1 + sb x0,(t0) # final zero +100: + lw ra, 0(sp) + addi sp, sp, 8 + ret +/***************************************************/ +/* register conversion in décimal signed */ +/***************************************************/ +/* a0 value */ +/* a1 result area address size mini 12c */ +/* a0 return result start address */ +/* a1 return characters number in area */ +conversion10S: # INFO: conversion10S + addi sp, sp, -8 # save registers + sw ra, 0(sp) + mv t5,a1 # begin store area + li t6,'+' + bge a0,x0,1f # positive number ? + li t6,'-' # negative + sub a0,x0,a0 # inversion +1: + li t4,LENGTHDEC # area size + add t2,t4,t5 + sb x0,(t2) # final zero + addi t4,t4,-1 # position précedente + li t1,10 +2: + remu t3,a0,t1 # reminder division by 10 + addi t3,t3,48 # conversion ascii + add t2,t4,t5 # compute store indice + sb t3,(t2) + addi t4,t4,-1 # position précedente + divu a0,a0,t1 # division by 10 + bne a0,x0,2b + # store signe in current position + add t2,t4,t5 + sb t6,(t2) +3: + add a0,t4,t5 # return store area begin address + li t0,LENGTHDEC # and size + sub a1,t0,t4 + +100: + lw ra, 0(sp) # restaur registers + addi sp, sp, 8 + ret +/************************************/ +/* string write on connexion usb */ +/***********************************/ +/* a0 String address */ +writeString: # INFO: writeString + addi sp, sp, -8 # save registers on stack + sw ra, 0(sp) + sw s0, 4(sp) + mv s0,a0 # save address +1: + lbu a0,(s0) # load one character + beqz a0,100f # end if zero + call __wrap_putchar # character write + add s0,s0,1 # increment address + j 1b # and loop +100: + lw ra, 0(sp) # restaur registers + lw s0, 4(sp) + addi sp, sp, 8 + ret diff --git a/Task/Bioinformatics-base-count/DuckDB/bioinformatics-base-count.duckdb b/Task/Bioinformatics-base-count/DuckDB/bioinformatics-base-count.duckdb new file mode 100644 index 0000000000..a774d42bcc --- /dev/null +++ b/Task/Bioinformatics-base-count/DuckDB/bioinformatics-base-count.duckdb @@ -0,0 +1,18 @@ +# Filter the contents of the file into a table (id, c) of uppercase letters +create or replace table bases as ( + select row_number() OVER () as id, c + from (select unnest(regexp_extract_all(content, '[A-Z]') ) as c + from read_text('rc-bioinformatics-base-count.txt') ) +); + +.print DNA sequence: +with tbl as (select (id - 1 - mod(id - 1, 50)) as "offset", c from bases) + select "offset", string_agg(c, '') as sequence + from tbl + group by "offset" + order by "offset" ; + +.print +.print Distribution of bases: +select histogram(c), count(*) as N +from bases ; diff --git a/Task/Bioinformatics-base-count/PascalABC.NET/bioinformatics-base-count.pas b/Task/Bioinformatics-base-count/PascalABC.NET/bioinformatics-base-count.pas new file mode 100644 index 0000000000..ddf4a8fef6 --- /dev/null +++ b/Task/Bioinformatics-base-count/PascalABC.NET/bioinformatics-base-count.pas @@ -0,0 +1,14 @@ +## var DNA := ''' +CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATG +CTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTG +AGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGAT +GGGACGTTTCGTCGACAAAGTCTTGTTTCGAGAGTAACGGCTACCGTCTT +CGATTCTGCTTATAACACTATGTTCTTATGAAATGGATGTTCTGAGTTGG +TCAGTCCCAATGTGCGGGGTTTCTTTTAGTACGTCGGGAGTGGTATTATA +TTTAATTTTTCTATATAGCGATCTGTATTTAAGCAATTCATTTAGGTTAT +CGCCGCGATGCTCGGTTCGGACCGCCAAGCATCTGGCTCCACTGCTAGTG +TCCTAAATTTGAATGGCAAACACAAATAAGATTTAGCAATTCGTGTAGAC +GACCGGGGACTTGCATGATGGGAGCAGCTTTGTTAAACTACGAACGTAAT +''';DNA:=DNA.Remove(#13,#10); +var t:=DNA.EachCount.OrderBy(x->x.key).Println.Sum(x->x.value); +Print('total,',t); diff --git a/Task/Biorhythms/Ada/biorhythms.ada b/Task/Biorhythms/Ada/biorhythms.ada new file mode 100644 index 0000000000..8f1fb796b8 --- /dev/null +++ b/Task/Biorhythms/Ada/biorhythms.ada @@ -0,0 +1,65 @@ +with Ada.Calendar; +with Ada.Calendar.Arithmetic; +with Ada.Calendar.Formatting; +with Ada.Command_Line; +with Ada.Numerics; +with Ada.Numerics.Elementary_Functions; +with Ada.Text_IO; + +use Ada.Calendar; +use Ada.Calendar.Arithmetic; +use Ada.Calendar.Formatting; +use Ada.Command_Line; +use Ada.Numerics; +use Ada.Numerics.Elementary_Functions; +use Ada.Text_IO; + +procedure Biorhythms is + Birth_Date : Time := Value (Argument (1) & " 00:00:00"); + Target_Date : Time := Value (Argument (2) & " 00:00:00"); + Days : Day_Count := Target_Date - Birth_Date; + + -- There's not much point having types for these for such a short + -- problem, but in a big program this would be useful to prevent + -- accidentally assigning wrong values. + type Physical_Type is mod 23; + type Emotional_Type is mod 28; + type Mental_Type is mod 33; + type Biorhythm_Type is + record + Physical : Physical_Type; + Emotional : Emotional_Type; + Mental : Mental_Type; + end record; + + function To_Biorhythm (D : Day_Count) return Biorhythm_Type is + ( + Physical_Type (D mod Physical_Type'Modulus), + Emotional_Type (D mod Emotional_Type'Modulus), + Mental_Type (D mod Mental_Type'Modulus) + ); + + Biorhythm : Biorhythm_Type := To_Biorhythm (Days); + + package Float_IO is new Ada.Text_IO.Float_IO (Float); + use Float_IO; + + function To_Percent (F : Float) return Float is + (100.0 * Sin (2.0 * Pi * F)); + + procedure Report_Biorhythm (B : Biorhythm_Type) is + PFrac : Float := Float (B.Physical) / Float (Physical_Type'Modulus); + EFrac : Float := Float (B.Emotional) / Float (Emotional_Type'Modulus); + MFrac : Float := Float (B.Mental) / Float (Mental_Type'Modulus); + Physical : Float := To_Percent (PFrac); + Emotional : Float := To_Percent (EFrac); + Mental : Float := To_Percent (MFrac); + begin + Put_Line ("Age in days: " & Days'Image); + Put ("Physical cycle: "); Put (Physical, 3, 1, 0); Put ("%"); New_Line; + Put ("Emotional cycle: "); Put (Emotional, 3, 1, 0); Put ("%"); New_Line; + Put ("Mental cycle: "); Put (Mental, 3, 1, 0); Put ("%"); New_Line; + end Report_Biorhythm; +begin + Report_Biorhythm (Biorhythm); +end Biorhythms; diff --git a/Task/Biorhythms/EasyLang/biorhythms.easy b/Task/Biorhythms/EasyLang/biorhythms.easy index 8f9bf9a6c9..cebda43194 100644 --- a/Task/Biorhythms/EasyLang/biorhythms.easy +++ b/Task/Biorhythms/EasyLang/biorhythms.easy @@ -27,10 +27,10 @@ proc cycle now cyc t$ col . gcolor col gtext 4 cyc * 1.2 - 20 t$ glinewidth 0.5 + gpenup for d = now - 20 to now + 20 - yp = y y = 50 + 20 * sin (360 * d / cyc) - if x > 0 : gline (x - 2.5) yp x y + glineto x y x += 2.5 . . diff --git a/Task/Bitcoin-public-point-to-address/FreeBASIC/bitcoin-public-point-to-address.basic b/Task/Bitcoin-public-point-to-address/FreeBASIC/bitcoin-public-point-to-address.basic new file mode 100644 index 0000000000..902427a908 --- /dev/null +++ b/Task/Bitcoin-public-point-to-address/FreeBASIC/bitcoin-public-point-to-address.basic @@ -0,0 +1,142 @@ +#include "SHA_256.bas" +#include "RIPEMD_160.bas" + +Const BITCOIN_SPECIAL_VALUE As String = "04" +Const BITCOIN_VERSION_NUMBER As String = "00" + +Dim Shared base_map(255) As Integer + +Sub init_base_map() + Dim As Integer i + For i = 0 To 255 + base_map(i) = -1 + Next + For i = 0 To 9 + base_map(Asc("0") + i) = i + Next + For i = 0 To 5 + base_map(Asc("a") + i) = 10 + i + base_map(Asc("A") + i) = 10 + i + Next + For i = 6 To 15 + base_map(Asc("a") + i) = 10 + i + base_map(Asc("A") + i) = 10 + i + Next +End Sub + +Sub hex_to_bytes(text As String, bytes() As Integer) + Dim As Integer first_digit, second_digit + Dim As Integer n = Len(text) \ 2 + Redim bytes(n - 1) + + For i As Integer = 0 To n - 1 + first_digit = base_map(Asc(Mid(text, 2 * i + 1, 1))) + second_digit = base_map(Asc(Mid(text, 2 * i + 2, 1))) + bytes(i) = (first_digit Shl 4) + second_digit + Next +End Sub + +Function vector_to_ascii_string(bytes() As Integer) As String + Dim As String result = "" + + For i As Integer = 0 To Ubound(bytes) + result &= Chr(bytes(i)) + Next + + Return result +End Function + +Sub compute_message_bytes(text As String, out_bytes() As Integer) + Dim As Integer bytes_1() + hex_to_bytes(text, bytes_1()) + + Dim As String ascii_1 = vector_to_ascii_string(bytes_1()) + Dim As String hexSHA_256 = SHA_256(ascii_1) + Dim As Integer bytes_2() + hex_to_bytes(hexSHA_256, bytes_2()) + + Dim As String ascii_2 = vector_to_ascii_string(bytes_2()) + Dim As String hexRIPEMD_160 = BITCOIN_VERSION_NUMBER & RIPEMD_160(ascii_2) + hex_to_bytes(hexRIPEMD_160, out_bytes()) +End Sub + +Sub compute_checksum(bytes() As Integer, out_checksum() As Integer) + Dim As String ascii_1 = vector_to_ascii_string(bytes()) + Dim As String hex_1 = SHA_256(ascii_1) + Dim As Integer bytes_1() + hex_to_bytes(hex_1, bytes_1()) + + Dim As String ascii_2 = vector_to_ascii_string(bytes_1()) + Dim As String hex_2 = SHA_256(ascii_2) + Dim As Integer bytes_2() + hex_to_bytes(hex_2, bytes_2()) + Redim out_checksum(3) + + For i As Integer = 0 To 3 + out_checksum(i) = bytes_2(i) + Next +End Sub + +Function encode_base_58(bytes() As Integer) As String + Const As String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + Const As Integer ALPHABET_SIZE = 58 + Dim As String result = String(34, " ") + Dim As Integer i, j, n, c + Dim As Integer temp() + + Redim As Integer bytes_copy(Ubound(bytes)) + For i = 0 To Ubound(bytes) + bytes_copy(i) = bytes(i) + Next + + For n = Len(result) - 1 To 0 Step -1 + c = 0 + For i = 0 To Ubound(bytes_copy) + c = c * 256 + bytes_copy(i) + bytes_copy(i) = c \ ALPHABET_SIZE + c Mod= ALPHABET_SIZE + Next + Mid(result, n + 1, 1) = Mid(ALPHABET, c + 1, 1) + Next + + ' Quitar los '1' iniciales extra + While Left(result, 2) = "11" + result = Mid(result, 2) + Wend + Return result +End Function + +Function encode_address(x As String, y As String) As String + Dim As String public_point = BITCOIN_SPECIAL_VALUE & x & y + If Len(public_point) <> 130 Then + Print "Invalid public point string" + Exit Function + End If + Dim As Integer message_bytes() + compute_message_bytes(public_point, message_bytes()) + + Dim As Integer checksum() + compute_checksum(message_bytes(), checksum()) + + Dim As Integer i + Dim As Integer full_bytes() + Redim full_bytes(Ubound(message_bytes) + 4) + For i = 0 To Ubound(message_bytes) + full_bytes(i) = message_bytes(i) + Next + For i = 0 To 3 + full_bytes(Ubound(message_bytes) + 1 + i) = checksum(i) + Next + + Return encode_base_58(full_bytes()) +End Function + +' Test Program +init_base_map() + +Dim As String x = "50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352" +Dim As String y = "2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6" + +Print encode_address(x, y) + +Sleep diff --git a/Task/Bitcoin-public-point-to-address/JavaScript/bitcoin-public-point-to-address.js b/Task/Bitcoin-public-point-to-address/JavaScript/bitcoin-public-point-to-address.js new file mode 100644 index 0000000000..1076901568 --- /dev/null +++ b/Task/Bitcoin-public-point-to-address/JavaScript/bitcoin-public-point-to-address.js @@ -0,0 +1,52 @@ +const crypto = require('crypto'); + +const digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; + +function b58(n) { + if (n === 0n) return ''; + return b58(n / 58n) + digits58[Number(n % 58n)]; +} + +function publicPointToAddress(x, y) { + // Convert hex strings to buffers + const xBuffer = Buffer.from(x, 'hex'); + const yBuffer = Buffer.from(y, 'hex'); + + // Create uncompressed public key format (0x04 + x + y) + const publicKey = Buffer.concat([Buffer.from([0x04]), xBuffer, yBuffer]); + + // SHA256 hash + const sha256Hash = crypto.createHash('sha256').update(publicKey).digest(); + + // RIPEMD160 hash + const ripemd160Hash = crypto.createHash('ripemd160').update(sha256Hash).digest(); + + // Add version byte (0x00 for mainnet) + const versionedHash = Buffer.concat([Buffer.from([0x00]), ripemd160Hash]); + + // Double SHA256 for checksum + const checksum = crypto.createHash('sha256') + .update(crypto.createHash('sha256').update(versionedHash).digest()) + .digest() + .slice(0, 4); + + // Combine versioned hash with checksum + const addressBytes = Buffer.concat([versionedHash, checksum]); + + // Convert to BigInt for base58 encoding + let n = 0n; + for (let i = 0; i < addressBytes.length; i++) { + n = (n << 8n) | BigInt(addressBytes[i]); + } + + return b58(n); +} + +// Test with the provided values +if (require.main === module) { + const address = publicPointToAddress( + '50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352', + '2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6' + ); + console.log(address); +} diff --git a/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy b/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy index 3aaf5eda4f..4d1203c99e 100644 --- a/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy +++ b/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy @@ -1,18 +1,16 @@ sysconf topleft proc quadraticbezier x1 y1 x2 y2 x3 y3 nseg . + gpenup for i = 0 to nseg t = i / nseg t1 = 1 - t a = t1 * t1 b = 2 * t * t1 c = t * t - px = x - py = y x = a * x1 + b * x2 + c * x3 + 0.5 y = a * y1 + b * y2 + c * y3 + 0.5 - if i > 0 : gline px py x y + glineto x y . . glinewidth 0.5 -gclear quadraticbezier 1 1 30 37 59 1 100 diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Pluto/bitmap-bresenhams-line-algorithm.pluto b/Task/Bitmap-Bresenhams-line-algorithm/Pluto/bitmap-bresenhams-line-algorithm.pluto new file mode 100644 index 0000000000..8ab23127e7 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Pluto/bitmap-bresenhams-line-algorithm.pluto @@ -0,0 +1,27 @@ +local canvas = require "canvas" + +local function line(c, x0, y0, x1, y1, col) + local dx = math.abs(x1 - x0) + local dy = math.abs(y1 - y0) + local sx = (x0 < x1) ? 1 : -1 + local sy = (y0 < y1) ? 1 : -1 + local err = (dx > dy ? dx : - dy) // 2 + while true do + c:set(x0, y0, col) + if x0 == x1 and y0 == y1 then break end + local e2 = err + if e2 > -dx then + err -= dy + x0 += sx + end + if e2 < dy then + err += dx + y0 += sy + end + end +end + +local c = canvas.new(400, 400) +c:fill(0xffffff) -- white background +line(c, 0, 0, 399, 399, 0x0000ff) -- draw a red diagonal +io.contents("mybmp.bmp", c:tobmp()) -- save to a bitmap file diff --git a/Task/Bitmap-Midpoint-circle-algorithm/EasyLang/bitmap-midpoint-circle-algorithm.easy b/Task/Bitmap-Midpoint-circle-algorithm/EasyLang/bitmap-midpoint-circle-algorithm.easy new file mode 100644 index 0000000000..2e0418ae0b --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/EasyLang/bitmap-midpoint-circle-algorithm.easy @@ -0,0 +1,27 @@ +proc pix x y . + grect x / 5 y / 5 0.25 0.25 +. +proc circ x0 y0 r . + t1 = r div 16 + x = r + while x >= y + pix x0 - x, y0 + y + pix x0 - x, y0 - y + pix x0 - y, y0 + x + pix x0 - y, y0 - x + pix x0 + x, y0 + y + pix x0 + x, y0 - y + pix x0 + y, y0 + x + pix x0 + y, y0 - x + y += 1 + t1 += y + t2 = t1 - x + if t2 >= 0 + t1 = t2 + x -= 1 + . + . +. +for r = 20 step 20 to 240 + circ 250 250 r +. diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Julia/bitmap-midpoint-circle-algorithm.jl b/Task/Bitmap-Midpoint-circle-algorithm/Julia/bitmap-midpoint-circle-algorithm.jl index 5b1e33d063..1295233abb 100644 --- a/Task/Bitmap-Midpoint-circle-algorithm/Julia/bitmap-midpoint-circle-algorithm.jl +++ b/Task/Bitmap-Midpoint-circle-algorithm/Julia/bitmap-midpoint-circle-algorithm.jl @@ -1,3 +1,5 @@ +using Images, ImageView + function drawcircle!(img::Matrix{T}, col::T, x0::Int, y0::Int, radius::Int) where T x = radius - 1 y = 0 @@ -24,8 +26,6 @@ function drawcircle!(img::Matrix{T}, col::T, x0::Int, y0::Int, radius::Int) wher return img end -# Test -using Images - img = fill(Gray(255.0), 25, 25); drawcircle!(img, Gray(0.0), 12, 12, 12) +imshow(img) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Pluto/bitmap-midpoint-circle-algorithm.pluto b/Task/Bitmap-Midpoint-circle-algorithm/Pluto/bitmap-midpoint-circle-algorithm.pluto new file mode 100644 index 0000000000..c0d4f3ed9c --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Pluto/bitmap-midpoint-circle-algorithm.pluto @@ -0,0 +1,33 @@ +local canvas = require "canvas" + +local function trunc(x) return x >= 0 ? math.floor(x) : math.ceil(x) end + +local function circle(c, cx, cy, r, col) + local d = trunc((5 - r * 4) / 4) + local x = 0 + local y = r + repeat + c:set(cx + x, cy + y, col) + c:set(cx + x, cy - y, col) + c:set(cx - x, cy + y, col) + c:set(cx - x, cy - y, col) + c:set(cx + y, cy + x, col) + c:set(cx + y, cy - x, col) + c:set(cx - y, cy + x, col) + c:set(cx - y, cy - x, col) + if d < 0 then + d += 2 * x + 1 + else + d += 2 * (x - y) + 1 + y -= 1 + end + ++x + until x > y +end + +local c = canvas.new(400, 400) +c:fill(0xffffff) -- white background + +-- Draw a blue circle with centre at (200, 200) and radius 100. +circle(c, 200, 200, 100, 0xff0000) +io.contents("mybmp.bmp", c:tobmp()) -- save to a bitmap file diff --git a/Task/Bitmap/Pluto/bitmap.pluto b/Task/Bitmap/Pluto/bitmap.pluto new file mode 100644 index 0000000000..8901f27d06 --- /dev/null +++ b/Task/Bitmap/Pluto/bitmap.pluto @@ -0,0 +1,23 @@ +local canvas = require "canvas" + +-- Create a new canvas object: 400 pixels wide and 400 pixels high. +local c = canvas.new(400, 400) + +-- Color the whole canvas blue. +c:fill(0xff0000) + +-- Draw a red square in the middle. +for i = 1, 51 do + for j = 1, 51 do + c:set(174 + i, 174 + j, 0x0000ff) + end +end + +-- Print to the terminal the color (as an integer) of a pixel. +print(c:get(200, 200)) -- 255 + +-- Convert the canvas to a BMP image. +local image = c:tobmp() + +-- Save the image to a file. +io.contents("mybmp.bmp", image) diff --git a/Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb b/Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb new file mode 100644 index 0000000000..df8d7f60c4 --- /dev/null +++ b/Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb @@ -0,0 +1,8 @@ +# s should be a bitstring. +# Right-pad s with 0s so that the length of the output string is a multiple of 8. +CREATE OR REPLACE FUNCTION print_bits(s) as ( + format('{:0<{}}', s, (ceil(length(s) / 8) * 8)::INT) +); + +# Example: +select print_bits('101'::BITSTRING); diff --git a/Task/Bitwise-IO/DuckDB/bitwise-io-2.duckdb b/Task/Bitwise-IO/DuckDB/bitwise-io-2.duckdb new file mode 100644 index 0000000000..57ab55eb4d --- /dev/null +++ b/Task/Bitwise-IO/DuckDB/bitwise-io-2.duckdb @@ -0,0 +1,13 @@ +# "Compress" a string by printing it as a bitstring without the left-most bit of each byte +CREATE OR REPLACE FUNCTION sevenbits(str) as ( + select string_agg(format('{}', ascii(s)::BITSTRING)[-7:], '') + from (select unnest(regexp_extract_all(str, '.')) as s) +); + +# Undo sevenbits() +CREATE OR REPLACE FUNCTION from_sevenbits(str) as ( + select string_agg(chr(s::BIT::INT), '') + from (select unnest(regexp_extract_all(str, '.......')) as s) +); + +select from_sevenbits(sevenbits('abracadabra')); diff --git a/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg index 7fdf9b8d88..ea11b79d5f 100644 --- a/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg +++ b/Task/Bitwise-operations/ALGOL-68/bitwise-operations-1.alg @@ -1,8 +1,13 @@ -main:( +BEGIN + + BITS all bits mask = NOT 16r0; + LONG BITS long bits mask = LENG all bits mask; PRIO SLC = 8, SRC = 8; # SLC and SRC are not built in, define and overload them here # OP SLC = (BITS b, INT rotate) BITS: b SHL rotate OR b SHR ( bits width - rotate ); - OP SRC = (BITS b, INT rotate) BITS: b SHR rotate OR b SHL ( bits width - rotate ); + OP SRC = (BITS b, INT rotate) BITS: b SHR rotate OR SHORTEN ( long bits mask + AND ( LENG b SHL ( bits width - rotate ) ) + ); # SRC and SRL are non-standard, but versions are built in to ALGOL 68R's standard prelude # PRIO XOR = 2; @@ -10,7 +15,10 @@ main:( # XOR is non-standard, but a version is built in to ALGOL 68G's standard prelude # # ALGOL 68 has 5 different ways of representing a BINary BITS - Bases: 2, 4, 8, 16 and flip/flop # - FORMAT b5 = $"2r"2r32d," 4r"4r16d," 8r"8r11d," 16r"16r8d," "gl$; + FORMAT b5 = IF bits width > 32 + THEN $"2r"2r64d," 4r"4r32d,l" 8r"8r22d," 16r"16r16d,l" "gl$ + ELSE $"2r"2r32d," 4r"4r16d," 8r"8r11d," 16r"16r8d,l" "gl$ + FI; OP BBBBB = (BITS b)[]BITS: (b,b,b,b,b); PROC bitwise = (BITS a, BITS b, INT shift)VOID: @@ -61,4 +69,4 @@ CO bitwise(8r377,8r252,5); bitwise(16rff,16raa,5) END CO -) +END diff --git a/Task/Bitwise-operations/DuckDB/bitwise-operations-1.duckdb b/Task/Bitwise-operations/DuckDB/bitwise-operations-1.duckdb new file mode 100644 index 0000000000..d81bf307e5 --- /dev/null +++ b/Task/Bitwise-operations/DuckDB/bitwise-operations-1.duckdb @@ -0,0 +1,5 @@ +create or replace function task(a,b) as table ( + select a, b, a&b, a|b, xor(a, b), ~a, a << b, a >> b +); + +from task(10, 2); diff --git a/Task/Bitwise-operations/DuckDB/bitwise-operations-2.duckdb b/Task/Bitwise-operations/DuckDB/bitwise-operations-2.duckdb new file mode 100644 index 0000000000..2e48fb4dd1 --- /dev/null +++ b/Task/Bitwise-operations/DuckDB/bitwise-operations-2.duckdb @@ -0,0 +1,5 @@ +select 10 as v, + ~(v::BITSTRING), + ~(v::INT) as "~INT", + ~(v::BIGINT) as "~BIGINT", + ~(10::UINTEGER) as "~UINTEGER"; diff --git a/Task/Bitwise-operations/Elena/bitwise-operations.elena b/Task/Bitwise-operations/Elena/bitwise-operations.elena index 941e955022..7c1422857a 100644 --- a/Task/Bitwise-operations/Elena/bitwise-operations.elena +++ b/Task/Bitwise-operations/Elena/bitwise-operations.elena @@ -2,18 +2,18 @@ import extensions; extension testOp { - bitwiseTest(y) - { - console.printLine(self," and ",y," = ",self & y); - console.printLine(self," or ",y," = ",self | y); - console.printLine(self," xor ",y," = ",self ^ y); - console.printLine("not ",self," = ",self.BInverted); - console.printLine(self," shr ",y," = ",self.shiftRight(y)); - console.printLine(self," shl ",y," = ",self.shiftLeft(y)); - } + bitwiseTest(y) + { + Console.printLine(self," and ",y," = ",self.band(y)); + Console.printLine(self," or ",y," = ",self.bor(y)); + Console.printLine(self," xor ",y," = ",self.bxor(y)); + Console.printLine("not ",self," = ",self.BInverted); + Console.printLine(self," shr ",y," = ",self.shiftRight(y)); + Console.printLine(self," shl ",y," = ",self.shiftLeft(y)); + } } public program() { - console.loadLineTo(new Integer()).bitwiseTest(console.loadLineTo(new Integer())) + Console.loadLineTo(new Integer()).bitwiseTest(Console.loadLineTo(new Integer())) } diff --git a/Task/Bitwise-operations/Icon/bitwise-operations.icon b/Task/Bitwise-operations/Icon/bitwise-operations.icon index 4bcace1afa..92610583bb 100644 --- a/Task/Bitwise-operations/Icon/bitwise-operations.icon +++ b/Task/Bitwise-operations/Icon/bitwise-operations.icon @@ -1,3 +1,5 @@ +link bitint # for int2bit + procedure main() bitdemo(255,2) bitdemo(-15,3) diff --git a/Task/Bitwise-operations/Pluto/bitwise-operations.pluto b/Task/Bitwise-operations/Pluto/bitwise-operations.pluto new file mode 100644 index 0000000000..a42f1b211c --- /dev/null +++ b/Task/Bitwise-operations/Pluto/bitwise-operations.pluto @@ -0,0 +1,20 @@ +-- Rotate left and right are not built-in but we use the +-- same 32-bit substitutes as in the Lua 5.3+ example. +local function rl(x, y) return ((x << y) & 0xffffffff) | (x >> (32 - y)) end + +local function rr(x, y) return (x >> y) | ((x << (32 - y)) & 0xffffffff) end + +local function bitwise(x, y) + print($" x = {x}") + print($" y = {y}") + print($" x & y = {x & y}") + print($" x | y = {x | y}") + print($" x ~ y = {x ~ y}") + print($"~x = {~x}") + print($" x << y = {x << y}") + print($" x >> y = {x >> y}") + print($" x rl y = {rl(x, y)}") + print($" x rr y = {rr(x, y)}") +end + +bitwise(10, 2) diff --git a/Task/Boolean-values/ArkScript/boolean-values.ark b/Task/Boolean-values/ArkScript/boolean-values.ark new file mode 100644 index 0000000000..d92c5993bd --- /dev/null +++ b/Task/Boolean-values/ArkScript/boolean-values.ark @@ -0,0 +1,14 @@ +(let test (fun (v) { + (puts v ": ") + (if v (print true) (print false)) })) + + +(test 1) +(test 0) +(test true) +(test false) +(test "hello") +(test "") +(test [1 2 3]) +(test []) +(test nil) diff --git a/Task/Boolean-values/Haxe/boolean-values.haxe b/Task/Boolean-values/Haxe/boolean-values.haxe new file mode 100644 index 0000000000..c2f8a2ed4c --- /dev/null +++ b/Task/Boolean-values/Haxe/boolean-values.haxe @@ -0,0 +1,8 @@ +class Main { + static public function main():Void { + var t = true; + var f = false; + $type(t); + $type(f); + } +} diff --git a/Task/Boolean-values/Prolog/boolean-values.pro b/Task/Boolean-values/Prolog/boolean-values.pro new file mode 100644 index 0000000000..361f023ab6 --- /dev/null +++ b/Task/Boolean-values/Prolog/boolean-values.pro @@ -0,0 +1,2 @@ +?- ( Bool = true ; Bool = false ), + ( Bool -> bool_is_true ; bool_is_false ). diff --git a/Task/Boolean-values/Zig/boolean-values.zig b/Task/Boolean-values/Zig/boolean-values.zig new file mode 100644 index 0000000000..f7b10d4ab0 --- /dev/null +++ b/Task/Boolean-values/Zig/boolean-values.zig @@ -0,0 +1,15 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + + const bool1: bool = true; + const bool2: bool = false; + const bool3 = 2 + 2 == 4; + const bool4 = 2 + 2 == 5; + + try stdout.print("{any}\n", .{bool1}); + try stdout.print("{any}\n", .{bool2}); + try stdout.print("{any} {any}\n", .{@TypeOf(bool3), bool3}); + try stdout.print("{any} {any}\n", .{@TypeOf(bool4), bool4}); +} diff --git a/Task/Boyer-Moore-string-search/Ada/boyer-moore-string-search.ada b/Task/Boyer-Moore-string-search/Ada/boyer-moore-string-search.ada new file mode 100644 index 0000000000..3c23105aee --- /dev/null +++ b/Task/Boyer-Moore-string-search/Ada/boyer-moore-string-search.ada @@ -0,0 +1,63 @@ +with Ada.Text_IO; + +with GNATColl.Boyer_Moore; + +procedure Boyermoore is + + procedure Search_All (Needle : in String; + Haystack : in String) + is + use Ada.Text_IO; + use GNATColl.Boyer_Moore; + + Found : String (Haystack'Range) := (others => ' '); + Count : Natural := 0; + Motif : Pattern; + First : Positive := Haystack'First; + Position : Integer; + begin + Put_Line ("Needle : " & Needle); + Put_Line ("Haystack: " & Haystack); + Put ("Found : "); + + Compile (Motif => Motif, + From_String => Needle, + Case_Sensitive => True); + loop + Position := Search (Motif => Motif, + In_String => Haystack (First .. Haystack'Last)); + exit when Position = -1; + + Count := Count + 1; + Found (Position .. Position + Needle'Length - 1) := (others => '^'); + First := Position + 1; + end loop; + + Free (Motif); + + if Count = 0 then + Put_Line (""); + else + Put_Line (Found); + end if; + New_Line; + end Search_All; + + Text_1 : constant String := "InhisbookseriesTheArtofComputerProgrammingpublishedbyAddisonWesleyDKnuthusesanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguagestoillustratetheconceptsandalgorithmsastheyarepresented"; + + Text_2 : constant String := "Nearby farms grew a half acre of alfalfa on the dairy's behalf, with bales of all that alfalfa exchanged for milk."; + + Text_3 : constant String := "GCTAGCTCTACGAGTCTA"; + Text_4 : constant String := "GGCTATAATGCGTA"; + Text_5 : constant String := "there would have been a time for such a word"; + Text_6 : constant String := "needle need noodle needle"; + +begin + Search_All ("put", Text_1); + Search_All ("and", Text_1); + Search_All ("alfalfa", Text_2); + Search_All ("TCTA", Text_3); + Search_All ("TAATAAA", Text_4); + Search_All ("word", Text_5); + Search_All ("needle", Text_6); +end Boyermoore; diff --git a/Task/Boyer-Moore-string-search/Dart/boyer-moore-string-search.dart b/Task/Boyer-Moore-string-search/Dart/boyer-moore-string-search.dart new file mode 100644 index 0000000000..24e59c3692 --- /dev/null +++ b/Task/Boyer-Moore-string-search/Dart/boyer-moore-string-search.dart @@ -0,0 +1,80 @@ +import 'dart:convert'; // for jsonEncode (used to mimic std::quoted) +import 'dart:io'; + +/// Prints a list of integers in the form `[1, 2, 3]`. +void display(List numbers) { + final joined = numbers.join(', '); + print('[$joined]'); +} + +/// Returns the first index of `needle` inside `haystack`, +/// or -1 if `needle` cannot be found. +int stringSearchSingle(String haystack, String needle) { + final idx = haystack.indexOf(needle); + return idx >= 0 ? idx : -1; +} + +/// Returns **all** non‑overlapping start indexes of `needle` inside `haystack`. +List stringSearch(String haystack, String needle) { + final List result = []; + + int start = 0; // where we continue searching from + int index = 0; // result of the latest search + + // Keep searching while we still find matches and we haven’t run off the end. + while (start < haystack.length && (index = stringSearchSingle( + haystack.substring(start), needle)) >= 0) { + final absoluteIdx = start + index; + result.add(absoluteIdx); + // Move past the match we just found so the next search starts after it. + start = absoluteIdx + needle.length; + } + + return result; +} + +void main() { + // --------------------------------------------------------------------------- + // 1️⃣ The data (identical to the C++ version) + // --------------------------------------------------------------------------- + const List texts = [ + "GCTAGCTCTACGAGTCTA", + "GGCTATAATGCGTA", + "there would have been a time for such a word", + "needle need noodle needle", + "DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages", + "Nearby farms grew an acre of alfalfa on the dairy's behalf, with bales of that alfalfa exchanged for milk." + ]; + + const List patterns = [ + "TCTA", + "TAATAAA", + "word", + "needle", + "and", + "alfalfa" + ]; + + // --------------------------------------------------------------------------- + // 2️⃣ Print the original texts (mirrors the first loop in C++). + // --------------------------------------------------------------------------- + for (var i = 0; i < texts.length; ++i) { + print('text${i + 1} = ${texts[i]}'); + } + print(''); // blank line like the C++ program + + // --------------------------------------------------------------------------- + // 3️⃣ Search each pattern in its corresponding text and print the results. + // --------------------------------------------------------------------------- + for (var i = 0; i < texts.length; ++i) { + final List indexes = stringSearch(texts[i], patterns[i]); + + // `jsonEncode` adds double quotes around a string and escapes characters, + // which behaves like `std::quoted` in C++. + final quotedPattern = jsonEncode(patterns[i]); + + stdout.write( + 'Found $quotedPattern in \'text${i + 1}\' at indexes '); + display(indexes); + } +} diff --git a/Task/Boyer-Moore-string-search/FutureBasic/boyer-moore-string-search.basic b/Task/Boyer-Moore-string-search/FutureBasic/boyer-moore-string-search.basic new file mode 100644 index 0000000000..6062c467ce --- /dev/null +++ b/Task/Boyer-Moore-string-search/FutureBasic/boyer-moore-string-search.basic @@ -0,0 +1,55 @@ +include "NSLog.incl" + +NSInteger local fn String_Search_Single( haystack as CFStringRef, needle as CFStringRef ) + CFRange range = fn StringRangeOfString( haystack, needle ) + return range.location +end fn = 0 + +CFArrayRef local fn String_Search( haystack as CFStringRef, needle as CFStringRef ) + CFMutableArrayRef result = fn MutableArrayNew + NSUInteger start = 0 + NSInteger index = 0 + + while ( index >= 0 && start < len(haystack) ) + CFStringRef haystackReduced = fn StringSubstringFromIndex( haystack, start ) + index = fn String_Search_Single( haystackReduced, needle ) + if ( index != NSNotFound ) + MutableArrayAddObject( result, @(start + index) ) + start += index + len(needle) + else + break + end if + wend + return result +end fn = 0 + +void local fn FindNeedlesInHaystacks + NSUInteger i + + CFArrayRef texts = @[ + @"GCTAGCTCTACGAGTCTA", + @"GGCTATAATGCGTA", + @"there would have been a time for such a word", + @"needle need noodle needle", + @"DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages", + @"Nearby farms grew an acre of alfalfa on the dairy's behalf, with bales of that alfalfa exchanged for milk." + ] + + CFArrayRef patterns = @[@"TCTA", @"TAATAAA", @"word", @"needle", @"and", @"alfalfa"] + + for i = 0 to fn ArrayCount(texts) - 1 + NSLog( @"text%lu = %@", (unsigned long)(i + 1), texts[i] ) + next + + NSLog( @"" ) + + for i = 0 to fn ArrayCount(texts) - 1 + CFArrayRef indexes = fn String_Search( texts[i], patterns[i] ) + NSLog( @"Found \"%@\" in 'text%lu' at indexes \b", patterns[i], (unsigned long)(i + 1) ) + NSLog( @"[%@]", fn ArrayComponentsJoinedByString( indexes, @", " ) ) + next +end fn + +fn FindNeedlesInHaystacks + +HandleEvents diff --git a/Task/Boyer-Moore-string-search/Kotlin/boyer-moore-string-search.kts b/Task/Boyer-Moore-string-search/Kotlin/boyer-moore-string-search.kts new file mode 100644 index 0000000000..e7cf98b9ac --- /dev/null +++ b/Task/Boyer-Moore-string-search/Kotlin/boyer-moore-string-search.kts @@ -0,0 +1,50 @@ +fun display(numbers: List) { + println("[${numbers.joinToString(", ")}]") +} + +fun stringSearchSingle(haystack: String, needle: String): Int { + val index = haystack.indexOf(needle) + return if (index != -1) index else -1 +} + +fun stringSearch(haystack: String, needle: String): List { + val result = mutableListOf() + var start = 0 + var index = 0 + + while (index >= 0 && start < haystack.length) { + val haystackReduced = haystack.substring(start) + index = stringSearchSingle(haystackReduced, needle) + + if (index >= 0) { + result.add(start + index) + start += index + needle.length + } + } + + return result +} + +fun main() { + val texts = listOf( + "GCTAGCTCTACGAGTCTA", + "GGCTATAATGCGTA", + "there would have been a time for such a word", + "needle need noodle needle", + "DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages", + "Nearby farms grew an acre of alfalfa on the dairy's behalf, with bales of that alfalfa exchanged for milk." + ) + + val patterns = listOf("TCTA", "TAATAAA", "word", "needle", "and", "alfalfa") + + texts.forEachIndexed { i, text -> + println("text${i + 1} = $text") + } + println() + + texts.forEachIndexed { i, text -> + val indexes = stringSearch(text, patterns[i]) + print("Found \"${patterns[i]}\" in 'text${i + 1}' at indexes ") + display(indexes) + } +} diff --git a/Task/Boyer-Moore-string-search/Swift/boyer-moore-string-search.swift b/Task/Boyer-Moore-string-search/Swift/boyer-moore-string-search.swift new file mode 100644 index 0000000000..76d2327ef7 --- /dev/null +++ b/Task/Boyer-Moore-string-search/Swift/boyer-moore-string-search.swift @@ -0,0 +1,59 @@ +import Foundation + +func display(_ numbers: [Int32]) { + let numbersStr = numbers.map { String($0) }.joined(separator: ", ") + print("[\(numbersStr)]") +} + +func stringSearchSingle(_ haystack: String, _ needle: String) -> Int32 { + guard let range = haystack.range(of: needle) else { + return -1 + } + return Int32(haystack.distance(from: haystack.startIndex, to: range.lowerBound)) +} + +func stringSearch(_ haystack: String, _ needle: String) -> [Int32] { + var result: [Int32] = [] + var start = 0 + var index: Int32 = 0 + + while index >= 0 && start < haystack.count { + let startIndex = haystack.index(haystack.startIndex, offsetBy: start) + let haystackReduced = String(haystack[startIndex...]) + index = stringSearchSingle(haystackReduced, needle) + + if index >= 0 { + result.append(Int32(start) + index) + start += Int(index) + needle.count + } + } + + return result +} + +func main() { + let texts = [ + "GCTAGCTCTACGAGTCTA", + "GGCTATAATGCGTA", + "there would have been a time for such a word", + "needle need noodle needle", + "DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages", + "Nearby farms grew an acre of alfalfa on the dairy's behalf, with bales of that alfalfa exchanged for milk." + ] + + let patterns = ["TCTA", "TAATAAA", "word", "needle", "and", "alfalfa"] + + for (i, text) in texts.enumerated() { + print("text\(i + 1) = \(text)") + } + print() + + for (i, text) in texts.enumerated() { + let indexes = stringSearch(text, patterns[i]) + print("Found \"\(patterns[i])\" in 'text\(i + 1)' at indexes ", terminator: "") + display(indexes) + } +} + +// Call main function +main() diff --git a/Task/Boyer-Moore-string-search/Zig/boyer-moore-string-search.zig b/Task/Boyer-Moore-string-search/Zig/boyer-moore-string-search.zig new file mode 100644 index 0000000000..29a4cd7704 --- /dev/null +++ b/Task/Boyer-Moore-string-search/Zig/boyer-moore-string-search.zig @@ -0,0 +1,71 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; +const Allocator = std.mem.Allocator; + +fn display(numbers: []const i32) void { + print("[", .{}); + for (numbers, 0..) |num, i| { + if (i > 0) { + print(", ", .{}); + } + print("{}", .{num}); + } + print("]\n", .{}); +} + +fn stringSearchSingle(haystack: []const u8, needle: []const u8) i32 { + if (std.mem.indexOf(u8, haystack, needle)) |index| { + return @intCast(index); + } + return -1; +} + +fn stringSearch(allocator: Allocator, haystack: []const u8, needle: []const u8) !ArrayList(i32) { + var result = ArrayList(i32).init(allocator); + var start: usize = 0; + + while (start < haystack.len) { + const haystack_reduced = haystack[start..]; + const index = stringSearchSingle(haystack_reduced, needle); + + if (index >= 0) { + try result.append(@as(i32, @intCast(start)) + index); + start += @as(usize, @intCast(index)) + needle.len; + } else { + break; + } + } + + return result; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const texts = [_][]const u8{ + "GCTAGCTCTACGAGTCTA", + "GGCTATAATGCGTA", + "there would have been a time for such a word", + "needle need noodle needle", + "DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages", + "Nearby farms grew an acre of alfalfa on the dairy's behalf, with bales of that alfalfa exchanged for milk." + }; + + const patterns = [_][]const u8{"TCTA", "TAATAAA", "word", "needle", "and", "alfalfa"}; + + for (texts, 0..) |text, i| { + print("text{} = {s}\n", .{ i + 1, text }); + } + print("\n" ,.{}); + + for (texts, 0..) |text, i| { + var indexes = try stringSearch(allocator, text, patterns[i]); + defer indexes.deinit(); + + print("Found \"{s}\" in 'text{}' at indexes ", .{ patterns[i], i + 1 }); + display(indexes.items); + } +} diff --git a/Task/Break-OO-privacy/Dart/break-oo-privacy.dart b/Task/Break-OO-privacy/Dart/break-oo-privacy.dart new file mode 100644 index 0000000000..d9db598356 --- /dev/null +++ b/Task/Break-OO-privacy/Dart/break-oo-privacy.dart @@ -0,0 +1,38 @@ +class CFactory { + int _count = 0; + + CFactory(); + + int get count => _count; + + CWidget getWidget() { + return CWidget._(this); + } +} + +class CWidget { + final CFactory _parent; + + // Private constructor - only accessible from CFactory + CWidget._(this._parent) { + _parent._count++; + print('Widget spawning. There are now ${_parent._count} Widgets instantiated.'); + } + + void dispose() { + _parent._count--; + print('Widget dying. There are now ${_parent._count} Widgets instantiated.'); + } +} + +void main() { + final factory = CFactory(); + + final widget1 = factory.getWidget(); + final widget2 = factory.getWidget(); + widget1.dispose(); + + final widget3 = factory.getWidget(); + widget3.dispose(); + widget2.dispose(); +} diff --git a/Task/Break-OO-privacy/JavaScript/break-oo-privacy.js b/Task/Break-OO-privacy/JavaScript/break-oo-privacy.js new file mode 100644 index 0000000000..12953361a7 --- /dev/null +++ b/Task/Break-OO-privacy/JavaScript/break-oo-privacy.js @@ -0,0 +1,54 @@ +class CFactory { + constructor() { + this.m_uiCount = 0; + } + + // Destructor equivalent - not needed in JS due to garbage collection + // but included for completeness + destroy() { + // Could perform cleanup here if needed + } + + getWidget() { + // Create a new CWidget, tell it we're its parent + return new CWidget(this); + } +} + +class CWidget { + constructor(parent) { + if (!parent || !(parent instanceof CFactory)) { + throw new Error("CWidget requires a CFactory parent"); + } + + this.m_parent = parent; + ++this.m_parent.m_uiCount; + + console.log(`Widget spawning. There are now ${this.m_parent.m_uiCount} Widgets instantiated.`); + } + + // Destructor equivalent + destroy() { + --this.m_parent.m_uiCount; + console.log(`Widget dying. There are now ${this.m_parent.m_uiCount} Widgets instantiated.`); + } +} + +// Main function equivalent +function main() { + const factory = new CFactory(); + + const pWidget1 = factory.getWidget(); + const pWidget2 = factory.getWidget(); + pWidget1.destroy(); // Equivalent to delete pWidget1 + + const pWidget3 = factory.getWidget(); + pWidget3.destroy(); // Equivalent to delete pWidget3 + pWidget2.destroy(); // Equivalent to delete pWidget2 + + // Optional: cleanup factory + factory.destroy(); +} + +// Run the main function +main(); diff --git a/Task/Break-OO-privacy/Rust/break-oo-privacy.rs b/Task/Break-OO-privacy/Rust/break-oo-privacy.rs new file mode 100644 index 0000000000..be583ca5e9 --- /dev/null +++ b/Task/Break-OO-privacy/Rust/break-oo-privacy.rs @@ -0,0 +1,62 @@ +use std::cell::RefCell; +use std::rc::{Rc, Weak}; + +pub struct Factory { + count: RefCell, +} + +pub struct Widget { + parent: Weak, +} + +impl Factory { + pub fn new() -> Rc { + Rc::new(Factory { + count: RefCell::new(0), + }) + } + + pub fn get_widget(self: &Rc) -> Widget { + Widget::new(Rc::downgrade(self)) + } + + fn increment_count(&self) { + *self.count.borrow_mut() += 1; + println!("Widget spawning. There are now {} Widgets instantiated.", self.count.borrow()); + } + + fn decrement_count(&self) { + *self.count.borrow_mut() -= 1; + println!("Widget dying. There are now {} Widgets instantiated.", self.count.borrow()); + } +} + +impl Widget { + fn new(parent: Weak) -> Self { + if let Some(factory) = parent.upgrade() { + factory.increment_count(); + } + + Widget { parent } + } +} + +impl Drop for Widget { + fn drop(&mut self) { + if let Some(factory) = self.parent.upgrade() { + factory.decrement_count(); + } + } +} + +fn main() { + let factory = Factory::new(); + + let widget1 = factory.get_widget(); + let widget2 = factory.get_widget(); + drop(widget1); + + let widget3 = factory.get_widget(); + drop(widget3); + drop(widget2); +} diff --git a/Task/Break-OO-privacy/Zig/break-oo-privacy.zig b/Task/Break-OO-privacy/Zig/break-oo-privacy.zig new file mode 100644 index 0000000000..9542d4d37c --- /dev/null +++ b/Task/Break-OO-privacy/Zig/break-oo-privacy.zig @@ -0,0 +1,88 @@ +const std = @import("std"); +const print = std.debug.print; +const Allocator = std.mem.Allocator; + +const Factory = struct { + count: u32, + allocator: Allocator, + ref_count: u32, + + const Self = @This(); + + pub fn create(allocator: Allocator) !*Self { + const factory = try allocator.create(Self); + factory.* = Self{ + .count = 0, + .allocator = allocator, + .ref_count = 1, + }; + return factory; + } + + pub fn retain(self: *Self) *Self { + self.ref_count += 1; + return self; + } + + pub fn release(self: *Self) void { + self.ref_count -= 1; + if (self.ref_count == 0) { + self.allocator.destroy(self); + } + } + + pub fn getWidget(self: *Self) !Widget { + return Widget.create(self); + } + + fn incrementCount(self: *Self) void { + self.count += 1; + print("Widget spawning. There are now {} Widgets instantiated.\n", .{self.count}); + } + + fn decrementCount(self: *Self) void { + self.count -= 1; + print("Widget dying. There are now {} Widgets instantiated.\n", .{self.count}); + } +}; + +const Widget = struct { + parent: ?*Factory, + + const Self = @This(); + + pub fn create(parent: *Factory) Self { + _ = parent.retain(); // Increment parent's reference count + parent.incrementCount(); + + return Self{ + .parent = parent, + }; + } + + pub fn deinit(self: *Self) void { + if (self.parent) |parent| { + parent.decrementCount(); + parent.release(); + self.parent = null; + } + } +}; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const factory = try Factory.create(allocator); + defer factory.release(); + + var widget1 = try factory.getWidget(); + var widget2 = try factory.getWidget(); + + widget1.deinit(); + + var widget3 = try factory.getWidget(); + widget3.deinit(); + widget2.deinit(); +} diff --git a/Task/Brownian-tree/EasyLang/brownian-tree.easy b/Task/Brownian-tree/EasyLang/brownian-tree.easy index 821e4bcf89..b5012e14d2 100644 --- a/Task/Brownian-tree/EasyLang/brownian-tree.easy +++ b/Task/Brownian-tree/EasyLang/brownian-tree.easy @@ -1,30 +1,30 @@ -gcolor3 0 1 1 len f[] 200 * 200 -grect 50 50 0.5 0.5 -f[100 * 200 + 100] = 1 -n = 9000 +func get x y . + return f[y * 200 + x + 1] +. +proc set x y . + grect x / 2 y / 2 0.5 0.5 + f[y * 200 + x + 1] = 1 +. +gcolor 599 +set 100 100 +n = 6000 while i < n repeat x = random 200 - 1 y = random 200 - 1 - until f[y * 200 + x + 1] <> 1 + until get x y <> 1 . while 1 = 1 xo = x yo = y x += random 3 - 2 y += random 3 - 2 - if x < 0 or y < 0 or x >= 200 or y >= 200 - break 1 - . - if f[y * 200 + x + 1] = 1 - grect xo / 2 yo / 2 0.5 0.5 - f[yo * 200 + xo + 1] = 1 + if x < 0 or y < 0 or x >= 200 or y >= 200 : break 1 + if get x y = 1 + set xo yo i += 1 - if i mod 16 = 0 - gcolor3 0.2 + i / n 1 1 - sleep 0 - . + if i mod 100 = 0 : sleep 0 break 1 . . diff --git a/Task/Bulls-and-cows/Elena/bulls-and-cows.elena b/Task/Bulls-and-cows/Elena/bulls-and-cows.elena index c21e80a79d..1d02177dd7 100644 --- a/Task/Bulls-and-cows/Elena/bulls-and-cows.elena +++ b/Task/Bulls-and-cows/Elena/bulls-and-cows.elena @@ -17,7 +17,7 @@ class GameMaster ask() { - var row := console.print("Your Guess #",_attempt," ?").readLine(); + var row := Console.print("Your Guess #",_attempt," ?").readLine(); ^ row.toArray() } @@ -40,7 +40,7 @@ class GameMaster var number := ch.toString().toInt(); // check range - ifnot (number > 0 && number < 10) + if:not (number > 0 && number < 10) { InvalidArgumentException.raise() }; // check duplicates @@ -68,12 +68,12 @@ class GameMaster }; bulls => - -1 { console.printLine("Not a valid guess."); ^ true } - 4 { console.printLine("Congratulations! You have won!"); ^ false } - ! { + -1 : { Console.printLine("Not a valid guess."); ^ true } + 4 : { Console.printLine("Congratulations! You have won!"); ^ false } + ! : { _attempt.append(1); - console.printLine("Your Score is ",bulls," bulls and ",cows," cows"); + Console.printLine("Your Score is ",bulls," bulls and ",cows," cows"); ^ true } @@ -88,5 +88,5 @@ public program() process.doWhile(); - console.readChar() + Console.readChar() } diff --git a/Task/Bulls-and-cows/J/bulls-and-cows-1.j b/Task/Bulls-and-cows/J/bulls-and-cows-1.j index 3384f1c33b..a39d72af95 100644 --- a/Task/Bulls-and-cows/J/bulls-and-cows-1.j +++ b/Task/Bulls-and-cows/J/bulls-and-cows-1.j @@ -1,5 +1,5 @@ output=. ['Bulls: '&,:@'Cows: 'echo@,.":@,. valid =. *./@e.&Num_j_*.4=# -guess =. 0 ".&> [: > $:^:(-.@valid)@(1!:1@1)@echo@'Guess:'t.0 +guess =. 0 ".&> $:^:(-.@valid)@(1!:1@1)@echo@'Guess:'{{x u y}} game =. [ $:^:(4 0-.@-:]) [ (+/@:= output@, e. +/@:*. ~:) guess moo =. 'You win!'[ (1+4?9:) game ] diff --git a/Task/CRC-32/FutureBasic/crc-32.basic b/Task/CRC-32/FutureBasic/crc-32.basic new file mode 100644 index 0000000000..3ca9fab1e9 --- /dev/null +++ b/Task/CRC-32/FutureBasic/crc-32.basic @@ -0,0 +1,46 @@ +// +// CRC_32 Checksum +// +// FutureBasic 7.0.34, August 2025 R.W +//---------------------------------------------- + +// Get CRC_32 checksum from a CFstring +// using the standard bits reversed 0x04C11DB7 + +// Verified accuracy using the site +// https://codeshack.io/crc32-checksum-generator/ + +local fn getCRC_32 (textStr As CFStringRef) As UInt32 + UInt32 i, j, crc, byte + crc = 0xFFFFFFFF + + for i = 0 to len(textStr) -1 + byte = ucc(textStr, i) + crc = crc XOR byte + for j = 0 to 7 + if ( crc AND 1 ) + crc = (crc >> 1) XOR 0xEDB88320 + else + crc = crc >> 1 + end if + next + next + crc = crc XOR 0xFFFFFFFF +end fn = crc + + +window 1,@"CRC checksum" + +CFStringRef testString +testString = @"The quick brown fox jumps over the lazy dog" + +UInt32 checksum +checksum = fn getCRC_32(testString) + +print +print @" ";testString +print @" has a checksum of ";hex(checksum) + +handleEvents + +// diff --git a/Task/CRC-32/Pluto/crc-32.pluto b/Task/CRC-32/Pluto/crc-32.pluto new file mode 100644 index 0000000000..310616ad92 --- /dev/null +++ b/Task/CRC-32/Pluto/crc-32.pluto @@ -0,0 +1,5 @@ +local crypto = require "crypto" +local fmt = require "fmt" + +local str = "The quick brown fox jumps over the lazy dog" +print(fmt.hex(crypto.crc32(str))) diff --git a/Task/CRC-32/R/crc-32.r b/Task/CRC-32/R/crc-32.r index a8bdc5c253..36236927d7 100644 --- a/Task/CRC-32/R/crc-32.r +++ b/Task/CRC-32/R/crc-32.r @@ -1 +1,2 @@ +library(digest) digest("The quick brown fox jumps over the lazy dog","crc32", serialize=F) diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb new file mode 100644 index 0000000000..dd05c0680d --- /dev/null +++ b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-1.duckdb @@ -0,0 +1,5 @@ +create or replace table csv as +from read_csv_auto('rc-csv-data-manipulation.csv'); + +# View the first row of the table: +from csv limit 1; diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb new file mode 100644 index 0000000000..5078ee97a4 --- /dev/null +++ b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-2.duckdb @@ -0,0 +1,4 @@ +copy + (select *, (C1 + C2 + C3 + C4 + C5) as sum + from csv) + to 'junk.csv'; diff --git a/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb new file mode 100644 index 0000000000..b3c1bedcf5 --- /dev/null +++ b/Task/CSV-data-manipulation/DuckDB/csv-data-manipulation-3.duckdb @@ -0,0 +1,6 @@ +ALTER TABLE csv ADD COLUMN sum integer; + +UPDATE csv +SET sum = C1 + C2 + C3 + C4 + C5; + +copy csv to 'junk2.csv'; diff --git a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num new file mode 100644 index 0000000000..c250b2c016 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-1.num @@ -0,0 +1,85 @@ +#* +(this is a multiline comment in Nom) + +GRAMMAR OR PARSE TOKENS + nl* - new line, end of line + field* - one csv field + fieldset* - a number of fields + record* - one record (line) or a set of csv fields + recordset* - +*# + + # using the empty recordset trick + begin { + add "recordset*"; push; + } + read; + # ignore whitespace outside of quotes + " " { while [ ]; clear; .restart } + "\n" { put; clear; add "nl*"; push; .reparse } + '"' { + until '"'; clip; clop; unescape '"'; + whilenot [\n,]; + replace "&" "&"; replace "<" "<"; replace ">" ">"; + put; clear; add ""; get; add ""; put; clear; + add "field*"; push; + clear; .reparse + } + "," { clear; } + + whilenot [\n,]; + replace "&" "&"; replace "<" "<"; replace ">" ">"; + put; clear; add ""; get; add ""; put; clear; + add "field*"; push; + +parse> + # useful for debugging + #add "line "; lines; add " char "; chars; add ": "; print; clear; + #add "\n"; unstack; print; clip; stack; + + # 1 token + pop; + # a record may be terminated by the end of input + (eof)."fieldset*" { + clear; add ""; get; add "\n"; put; clear; + add "record*"; push; .reparse + } + # 2 tokens + pop; + "recordset*field*" { + replace "field" "fieldset"; push; push; .reparse + } + # ignore blank lines + "recordset*nl*" { + clip; clip; clip; push; .reparse + } + "fieldset*field*" { + clear; get; ++; get; --; put; clear; + add "fieldset*"; push; .reparse + } + "fieldset*nl*" { + clear; add "\n "; get; add "\n"; put; clear; + add "record*"; push; .reparse + } + "recordset*record*" { + clear; a+; get; + ++; get; --; put; clear; + # if the count is 1, then this is the 1st + # record and should be marked up as a table header. + count; "1" { + clear; get; replace "tr>" "thead>"; put; + } + clear; add "recordset*"; push; .reparse + } + + (eof) { + !"recordset*" { + clear; add "[invalid csv]\nThe parse stack was: "; print; + clear; unstack; add "\n"; print; quit; + } + clear; + add "\n"; get; add "
    \n"; + add "[valid csv!] Found "; count; add " records.\n"; + print; quit; + } + push; push; diff --git a/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num new file mode 100644 index 0000000000..fa64e7c50e --- /dev/null +++ b/Task/CSV-to-HTML-translation/Nom/csv-to-html-translation-2.num @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
    CharacterSpeech
    The multitudeThe messiah! Show us the messiah!
    Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
    The multitudeWho are you?
    Brians motherI'm his mother; that's who!
    The multitudeBehold his mother! Behold his mother!
    diff --git a/Task/CUSIP/R/cusip.r b/Task/CUSIP/R/cusip.r new file mode 100644 index 0000000000..acc24bf4ce --- /dev/null +++ b/Task/CUSIP/R/cusip.r @@ -0,0 +1,25 @@ +library(stringr) + +cusip_checkdigit <- function(s){ + sum <- 0 + chars <- str_split_1(s,"") + for(i in 1:8){ + if(str_detect(chars[i],"[0-9]")) v <- as.numeric(chars[i]) + else if(str_detect(chars[i],"[A-Z]")) v <- 9+which(LETTERS==chars[i]) + else v <- switch(chars[i], "*"=36, "@"=37, "#"=38) + if(i%%2==0) v <- 2*v + sum <- sum+v%/%10+v%%10 + } + return((10-(sum%%10))%%10) +} + +cusip_isvalid <- function(s){ + if(str_length(s)!=9){ + stop("CUSIP must have exactly 9 characters") + } + checksum <- cusip_checkdigit(s) |> as.character() + ifelse(endsWith(s, checksum), "Valid CUSIP", "Invalid CUSIP") +} + +test_cusips <- c("037833100","17275R102","38259P508","594918104","68389X106","68389X105") +sapply(test_cusips, cusip_isvalid) diff --git a/Task/Caesar-cipher/Elena/caesar-cipher.elena b/Task/Caesar-cipher/Elena/caesar-cipher.elena index 6120e1217c..cf348f086a 100644 --- a/Task/Caesar-cipher/Elena/caesar-cipher.elena +++ b/Task/Caesar-cipher/Elena/caesar-cipher.elena @@ -61,15 +61,15 @@ extension encryptOp public program() { - console.printLine("Original text :",TestText); + Console.printLine("Original text :",TestText); var encryptedText := TestText.encrypt(Key); - console.printLine("Encrypted text:",encryptedText); + Console.printLine("Encrypted text:",encryptedText); var decryptedText := encryptedText.decrypt(Key); - console.printLine("Decrypted text:",decryptedText); + Console.printLine("Decrypted text:",decryptedText); - console.readChar() + Console.readChar() } diff --git a/Task/Caesar-cipher/Pluto/caesar-cipher.pluto b/Task/Caesar-cipher/Pluto/caesar-cipher.pluto new file mode 100644 index 0000000000..ce61edf0ca --- /dev/null +++ b/Task/Caesar-cipher/Pluto/caesar-cipher.pluto @@ -0,0 +1,20 @@ +local function caesar(s, k, e=true) + -- Parameters: s (string), k (key) + -- e (true=encode, false=decode) + if !e do k=-k end + local out = "" + for i = 1, #s do + local c = s[i] + if c:islower() then + out ..= string.char((c:byte() - 97 + k) % 26 + 97) + elseif c:isupper() then + out ..= string.char((c:byte() - 65 + k) % 26 + 65) + else + out ..= c + end + end + return out +end + +print(caesar("The quick brown fox jumps over the lazy dog.", 3)) +print(caesar("Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj.", 3, false)) diff --git a/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus b/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus new file mode 100644 index 0000000000..eb65b69fc6 --- /dev/null +++ b/Task/Caesar-cipher/Rhombus/caesar-cipher.rhombus @@ -0,0 +1,25 @@ +#lang rhombus/static + +import lib("racket/base.rkt") expose: + #{string->list} as string_to_list + #{list->string} as list_to_string + modulo + +fun make_rot13_char(key :: Int): + fun (char :: Char): + let char_int = char.to_int() + fun rot13_by_case(char_int, a_char :: Char) :: Int : + modulo(char_int - a_char.to_int() + key, 26) + a_char.to_int() + if char.is_alphabetic(): + | if char.is_lowercase(): + | Char.from_int(rot13_by_case(char_int, Char"a")) + | Char.from_int(rot13_by_case(char_int, Char"A")) + | char + +fun rot13_string(str :: String, key :: Int) :: String : + let chars :: PairList = string_to_list(str) + let rot13_char = make_rot13_char(key) + let str :: MutableString = list_to_string(chars.map(rot13_char)) + str.snapshot() + +rot13_string("Hello, World!", 14) // Output: "Vszzc, Kcfzr!"" diff --git a/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark b/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark new file mode 100644 index 0000000000..a344a4416c --- /dev/null +++ b/Task/Calculating-the-value-of-e/ArkScript/calculating-the-value-of-e.ark @@ -0,0 +1,22 @@ +(import std.Range :range) +(import std.List) + +(let fact (fun (n acc) { + (if (> n 0) + (fact (- n 1) (* acc n)) + acc) })) + +(let r (range 1 18)) +(let p + (list:sum + (list:map + (list:reverse (r.asList)) + (fun (n) + (/ 1 (fact n 1)) )))) + +(import std.Math :abs) + +(let my_e (+ p 1)) +(print my_e) +(print math:e) +(assert (< (abs (- my_e math:e)) (toNumber "1e-15")) "computed e is near the math:e") diff --git a/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-1.elena b/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-1.elena new file mode 100644 index 0000000000..1388ecca04 --- /dev/null +++ b/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-1.elena @@ -0,0 +1,57 @@ +public program = PROGRAM; + +CONSOLE = Console; + +abstract INDEXERCLASS : interface +{ + abstract ISAVAILABLE(); + abstract GETINDEX(); + abstract SETINDEX(INDEX); + abstract NEWINDEX(OFFS); + abstract GETVALUE(); + abstract GETLENGTH(); + + bool Available = ISAVAILABLE(); + int Index + { + get() = GETINDEX(); + + set(int INDEX) + { + SETINDEX(INDEX); + } + } + appendIndex(int OFFS) { this self.Index := NEWINDEX(OFFS) } + set Value(o) { NotSupportedException.raise() } + get Value() = GETVALUE(); + get int Length() { ^ GETLENGTH() } +} + +PARALLELENUMERATOR(N) { ^ ParallelEnumerator.new(N) } + +NEWDATE(Y,M,D) { ^ Date.new(Y,M,D) } +NEWTEXTBUILDER() { ^ new TextBuilder() } + +GETMONTH(D) { ^ D.Month } +GETDAYOFWEEK(D) { ^D.DayOfWeek } +GETDAYSTR(D) { ^ D.Day.toPrintable() } + +READCHAR() { Console.readChar() } +READINT(PROMPT) { ^ Console.write(PROMPT).readLine().toInt() } + +WRITEPADDING(OUTPUT,S,SPACER,LEN) { OUTPUT.writePadding(S,SPACER,LEN) } +WRITEPADDINGLEFT(OUTPUT,S,SPACER,LEN) { OUTPUT.writePaddingLeft(S,SPACER,LEN) } +WRITELINE(OUTPUT) { OUTPUT.writeLine() } +WRITE(OUTPUT,S) { OUTPUT.write(S) } +WRITEARGS(OUTPUT,S1,S2) { OUTPUT.print(S1, S2) } +WRITECOPIES(OUTPUT,S,N) { OUTPUT.writeCopies(S,N) } + +ALLOCATE(COUNT) { ^ Array.allocate(COUNT) } + +CLEAR(S) { S.clear() } + +POPULATE(OBJ, ACTION) { ^ OBJ.populate(ACTION) } +FOREACH(OBJ, ACTION) { ^ OBJ.forEach(ACTION) } + +const MONTHNAMES = new string[]{"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"}; +const DAYNAMES = new string[]{"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; diff --git a/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-2.elena b/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-2.elena new file mode 100644 index 0000000000..36acbbd0f8 --- /dev/null +++ b/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers-2.elena @@ -0,0 +1,146 @@ +// --- UPPERCASE CODE -- + +CALENDARMONTHPRINTER +{ + _DATE; + _LINE; + _MONTH; + _YEAR; + _ROW; + + constructor NEW(YEAR, MONTH) + { + _MONTH := MONTH; + _YEAR := YEAR; + _LINE := NEWTEXTBUILDER(); + _ROW := 0; + } + + WRITETITLE() + { + _ROW := 0; + _DATE := NEWDATE(_YEAR, _MONTH, 1); + + FOREACH(DAYNAMES, (NAME) + { WRITEARGS(_LINE, " ", NAME) }) + } + + WRITECALLINE() + { + CLEAR(_LINE); + + if (GETMONTH(_DATE) == _MONTH) + { + WRITECOPIES(_LINE, " ",(GETDAYOFWEEK(_DATE) == 0) ? 6 : (GETDAYOFWEEK(_DATE) - 1)); + + do + { + WRITEPADDINGLEFT(_LINE, GETDAYSTR(_DATE), $32, 3); + + _DATE := _DATE.addDays(1) + } + until(GETMONTH(_DATE) != _MONTH || GETDAYOFWEEK(_DATE) == 1) + }; + + int LENGTH := _LINE.Length; + if (LENGTH < 21) + { WRITECOPIES(_LINE, " ", 21 - LENGTH) }; + + _ROW += 1 + } + + indexer() = new INDEXERCLASS + { + ISAVAILABLE() = _ROW < 7; + + GETINDEX()= _ROW; + + SETINDEX(INDEX) + { + if (INDEX <= _ROW) + { WRITETITLE() }; + + while (INDEX > _ROW) + { WRITECALLINE() } + } + + NEWINDEX(OFFS) + { + ^ _ROW + OFFS + } + + GETLENGTH() { ^ 7 } + + GETVALUE() = self; + }; + + PRINTTITLETO(OUTPUT) + { + WRITEPADDING(OUTPUT, MONTHNAMES[_MONTH - 1], $32, 21) + } + + PRINTTO(OUTPUT) + { + WRITE(OUTPUT, *_LINE) + } +} + +CALENDARCLASS +{ + _YEAR; + _ROWLENGTH; + + constructor NEW(YEAR) + { + _YEAR := YEAR; + _ROWLENGTH := 3 + } + + PRINTTO(OUTPUT) + { + WRITEPADDING(OUTPUT, "[SNOOPY]", $32, _ROWLENGTH * 25); + WRITELINE(OUTPUT); + WRITEPADDING(OUTPUT, _YEAR.toPrintable(), $32, _ROWLENGTH * 25); + WRITELINE(OUTPUT); WRITELINE(OUTPUT); + + var ROWCOUNT := 12 / _ROWLENGTH; + var MONTHS := POPULATE(ALLOCATE(ROWCOUNT), (I => + POPULATE(ALLOCATE(_ROWLENGTH), (J => + CALENDARMONTHPRINTER.NEW(_YEAR, I * _ROWLENGTH + J + 1))))); + + FOREACH(MONTHS, (ROW) + { + FOREACH(ROW, (MONTH) + { + MONTH.PRINTTITLETO(OUTPUT); + + WRITE(OUTPUT, " ") + }); + + WRITELINE(OUTPUT); + + FOREACH(PARALLELENUMERATOR(ROW), (LINE) + { + FOREACH(LINE, (PRINTER) + { + PRINTER.PRINTTO(OUTPUT); + + WRITE(OUTPUT, " ") + }); + + WRITELINE(OUTPUT); + }) + }) + } +} + +// --- PROGRAM --- + +PROGRAM() +{ + CALENDARCLASS CALENDER := CALENDARCLASS.NEW(READINT("ENTER THE YEAR:")); + + CALENDER.PRINTTO(CONSOLE); + + READCHAR(); +} diff --git a/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers.elena b/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers.elena deleted file mode 100644 index 02e0ac506f..0000000000 --- a/Task/Calendar---for-REAL-programmers/Elena/calendar---for-real-programmers.elena +++ /dev/null @@ -1,161 +0,0 @@ -import system'text; -import system'routines; -import system'calendar; -import extensions; -import extensions'routines; - -const MonthNames = new string[]{"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"}; -const DayNames = new string[]{"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; - -class CalendarMonthPrinter -{ - Date _date; - TextBuilder _line; - int _month; - int _year; - Reference _row; - - constructor(year, month) - { - _month := month; - _year := year; - _line := new TextBuilder(); - _row := 0; - } - - writeTitle() - { - _row.Value := 0; - _date := Date.new(_year, _month, 1); - - DayNames.forEach::(name) - { _line.print(" ",name) } - } - - writeLine() - { - _line.clear(); - - if (_date.Month == _month) - { - var dw := _date.DayOfWeek; - - _line.writeCopies(" ",_date.DayOfWeek == 0 ? 6 : (_date.DayOfWeek - 1)); - - do - { - _line.writePaddingLeft(_date.Day.toPrintable(), $32, 3); - - _date := _date.addDays(1) - } - until(_date.Month != _month || _date.DayOfWeek == 1) - }; - - int length := _line.Length; - if (length < 21) - { _line.writeCopies(" ", 21 - length) }; - - _row.append(1) - } - - indexer() = new Indexer - { - bool Available = _row < 7; - - int Index - { - get() = _row.Value; - - set(int index) - { - if (index <= _row) - { self.writeTitle() }; - - while (index > _row) - { self.writeLine() } - } - } - - appendIndex(int index) - { - this self.Index := _row.Value + index - } - - get int Length() { ^ 7 } - - get Value() = self; - - set Value(o) { NotSupportedException.raise() } - }; - - printTitleTo(output) - { - output.writePadding(MonthNames[_month - 1], $32, 21) - } - - printTo(output) - { - output.write(_line.Value) - } -} - -class Calendar -{ - int _year; - int _rowLength; - - constructor new(int year) - { - _year := year; - _rowLength := 3 - } - - printTo(output) - { - output.writePadding("[SNOOPY]", $32, _rowLength * 25); - output.writeLine(); - output.writePadding(_year.toPrintable(), $32, _rowLength * 25); - output.writeLine().writeLine(); - - var rowCount := 12 / _rowLength; - var months := Array.allocate(rowCount).populate::(i => - Array.allocate(_rowLength) - .populate::(j => - new CalendarMonthPrinter(_year, i * _rowLength + j + 1))); - - months.forEach::(row) - { - var r := row; - - row.forEach::(month) - { - month.printTitleTo(output); - - output.write(" ") - }; - - output.writeLine(); - - ParallelEnumerator.new(row).forEach::(line) - { - line.forEach::(printer) - { - printer.printTo(output); - - output.write(" ") - }; - - output.writeLine() - } - } - } -} - -public program() -{ - var calender := Calendar.new(console.write("ENTER THE YEAR:").readLine().toInt()); - - calender.printTo(console); - - console.readChar() -} diff --git a/Task/Calendar---for-REAL-programmers/Red/calendar---for-real-programmers.red b/Task/Calendar---for-REAL-programmers/Red/calendar---for-real-programmers.red new file mode 100644 index 0000000000..1fc0cae3bb --- /dev/null +++ b/Task/Calendar---for-REAL-programmers/Red/calendar---for-real-programmers.red @@ -0,0 +1,52 @@ +Red [ "PRINT CALENDAR IN SIX MONTHS ACROSS AND FOR TWO ROWS - HINJO, 20 JULY 2025" ] + +MONTHS: SYSTEM/LOCALE/MONTHS + +; GET DAY FROM YEAR, MONTH, WEEK, AND WEEKDAY! +GETDAY: FUNCTION [Y[INTEGER!] M[INTEGER!] W[INTEGER!] WD[INTEGER!]] [ + FD: TO-DATE REDUCE [1 M Y] ; FIRST DAY! + SWD: FD/WEEKDAY + 1 IF SWD > 7 [SWD: 1] ; SHIFT FROM MON=1 TO SUN=1 + OFS: (W - 1) * 7 + (WD - SWD) ; OFFSET + D: FD + OFS ; DATE + EITHER D/MONTH = M [D/DAY][0] ; RETURN DAY OR ZERO! +] + +; CENTER STRING +CENTR: FUNCTION [STR WID] [ + GAP: WID - LENGTH? STR + LPAD: TO-INTEGER GAP / 2 + PAD/LEFT STR WID - LPAD + PAD STR WID +] + +EITHER "" = Y: ASK "YEAR (ENTER FOR CURRENT): " [Y: NOW/YEAR][Y: TO-INTEGER Y] + +PRINT CENTR "[ S N O O P Y ]" 130 ; PRINT SNOOPY BLOCK CENTERED +PRINT CENTR TO-STRING Y 130 ; PRINT YEAR + +FOREACH R [[1 2 3 4 5 6][7 8 9 10 11 12]] [ + ; PRINT MONTH'S NAME + FOREACH M R [ + PRIN REJOIN [CENTR UPPERCASE MONTHS/:M 21 " "] + ] PRINT "" + + ; PRINT FOR EACH WEEK ACROSS MONTHS + FOREACH W [0 1 2 3 4 5 6] [ + ; EACH MONTHS + FOREACH M R [ + EITHER W = 0 [ ; PRINT WEEKDAYS + FOREACH D ["SU" "MO" "TU" "WE" "TH" "FR" "SA"] + [PRIN [FORM PAD D 3]] + ] [ + FOREACH WD [1 2 3 4 5 6 7] [ ; PRINT DATES + ; RECONSTRUCT THE DAY + EITHER 0 < DT: GETDAY Y M W WD [ + PRIN [FORM PAD/LEFT DT 2] + ] [ + PRIN " " + ] PRIN " " + ] + ] PRIN " " + ] PRINT "" + ] PRINT "" +] diff --git a/Task/Calendar/Red/calendar.red b/Task/Calendar/Red/calendar.red new file mode 100644 index 0000000000..2fafda5123 --- /dev/null +++ b/Task/Calendar/Red/calendar.red @@ -0,0 +1,52 @@ +Red [ "Print Calendar in six months across and for two rows - Hinjo, 20 July 2025" ] + +months: system/locale/months + +; get day from year, month, week, and weekday! +getday: function [y[integer!] m[integer!] w[integer!] wd[integer!]] [ + fd: to-date reduce [1 m y] ; first day! + swd: fd/weekday + 1 if swd > 7 [swd: 1] ; shift from mon=1 to sun=1 + ofs: (w - 1) * 7 + (wd - swd) ; offset + d: fd + ofs ; date + either d/month = m [d/day][0] ; return day or zero! +] + +; center string +centr: function [str wid] [ + gap: wid - length? str + lpad: to-integer gap / 2 + pad/left str wid - lpad + pad str wid +] + +either "" = y: ask "Year (ENTER for current): " [y: now/year][y: to-integer y] + +print centr "[ S N O O P Y ]" 130 ; print snoopy block centered +print centr to-string y 130 ; print year + +foreach r [[1 2 3 4 5 6][7 8 9 10 11 12]] [ + ; print month's name + foreach m r [ + prin rejoin [centr months/:m 21 " "] + ] print "" + + ; print for each week across months + foreach w [0 1 2 3 4 5 6] [ + ; each months + foreach m r [ + either w = 0 [ ; print weekdays + foreach d ["Su" "Mo" "Tu" "We" "Th" "Fr" "Sa"] + [prin [form pad d 3]] + ] [ + foreach wd [1 2 3 4 5 6 7] [ ; print dates + ; reconstruct the day + either 0 < dt: getday y m w wd [ + prin [form pad/left dt 2] + ] [ + prin " " + ] prin " " + ] + ] prin " " + ] print "" + ] print "" +] diff --git a/Task/Calkin-Wilf-sequence/Ada/calkin-wilf-sequence.ada b/Task/Calkin-Wilf-sequence/Ada/calkin-wilf-sequence.ada new file mode 100644 index 0000000000..31840223a0 --- /dev/null +++ b/Task/Calkin-Wilf-sequence/Ada/calkin-wilf-sequence.ada @@ -0,0 +1,110 @@ +with Ada.Text_IO; + +procedure Calkin_Wilf is + type Rational is + record + Numerator : Integer; + Denominator : Positive; + end record; + + -- A generic solution would use Ada.Containers.Vectors, but + -- these puzzles are written to avoid numbers larger than + -- what fit in 64 bits, so we can assume a limit of 64 terms + type Term_Array is array (1 .. 64) of Positive; + + type Continued_Fraction is + record + Count : Positive; + Terms : Term_Array; + end record; + + -- Don't bother with reducing or negatives + function "+" (A, B : Rational) return Rational is + (A.Numerator * B.Denominator + B.Numerator * A.Denominator, + A.Denominator * B.Denominator); + + function "-" (A : Rational) return Rational is + (-A.Numerator, A.Denominator); + + function "-" (A, B : Rational) return Rational is + (A + (-B)); + + function "*" (A, B : Rational) return Rational is + (A.Numerator * B.Numerator, + A.Denominator * B.Denominator); + + function Invert (A : Rational) return Rational is + (A.Denominator, + A.Numerator); + + function Floor (A : Rational) return Rational is + (A.Numerator / A.Denominator, + 1); + + function Image (A : Rational) return String is + (A.Numerator'Image & " /" & A.Denominator'Image); + + function "=" (A, B : Rational) return Boolean is + (A.Numerator = B.Numerator and A.Denominator = B.Denominator); + + function Next_Calkin_Wilf_Term (R : Rational) return Rational is + (Invert ((2, 1) * Floor (R) + (1, 1) - R)); + + procedure Put_First_Terms (N : Positive) is + R : Rational := (1, 1); + begin + Ada.Text_IO.Put_Line ( + "The first " & N'Image & " terms of the Calkin-Wilf Sequence are:"); + for I in 1 .. N loop + Ada.Text_IO.Put_Line (I'Image & ": " & Image (R)); + R := Next_Calkin_Wilf_Term (R); + end loop; + end Put_First_Terms; + + function To_Continued_Fraction (R : Rational) return Continued_Fraction is + Count : Natural := 0; + Terms : Term_Array; + N : Natural := R.Numerator; + D : Natural := R.Denominator; + M : Natural; + begin + while D > 0 loop + Count := Count + 1; + Terms (Count) := N / D; + M := N mod D; + N := D; + D := M; + end loop; + + if Count mod 2 = 0 then + Terms (Count .. Count + 1) := (Terms (Count) - 1, 1); + Count := Count + 1; + end if; + + return (Count, Terms); + end To_Continued_Fraction; + + function To_Index (R : Rational) return Natural is + Cont_Frac : Continued_Fraction := To_Continued_Fraction (R); + Terms : Term_Array renames Cont_Frac.Terms; + Index : Natural := 0; + begin + for I in reverse 1 .. Cont_Frac.Count loop + for J in 1 .. Terms (I) loop + Index := Index * 2 + (I mod 2); + end loop; + end loop; + + return Index; + end To_Index; + + procedure Put_Term_Index (R : Rational) is + Index : Natural := To_Index (R); + begin + Ada.Text_IO.Put_Line ("Term " & Image (R) & " is at index " & Index'Image); + end Put_Term_Index; + +begin + Put_First_Terms (20); + Put_Term_Index((83116, 51639)); +end Calkin_Wilf; diff --git a/Task/Calkin-Wilf-sequence/Pluto/calkin-wilf-sequence.pluto b/Task/Calkin-Wilf-sequence/Pluto/calkin-wilf-sequence.pluto new file mode 100644 index 0000000000..a95db1986a --- /dev/null +++ b/Task/Calkin-Wilf-sequence/Pluto/calkin-wilf-sequence.pluto @@ -0,0 +1,47 @@ +require "rat" +local fmt = require "fmt" + +local function calkin_wilf(n) + local cw = {} + cw[1] = rat.of(1) + for i = 2, n do + local t = cw[i - 1]:floor() * 2 - cw[i - 1] + 1 + cw[i] = cw[1] / t + end + return cw +end + +local function to_continued(r) + local a = r:getNum() + local b = r:getDen() + local res = {} + repeat + res:insert(math.floor(a / b)) + a, b = b, a % b + until a == 1 + + if #res % 2 == 0 then -- ensure always odd + res[#res] -= 1 + res:insert(1) + end + return res +end + +local function get_term_number(cf) + local b = "" + local d = "1" + for cf as n do + b = string.rep(d, n) .. b + d = (d == "1") ? "0" : "1" + end + return tonumber(b, 2) +end + +local cw = calkin_wilf(20) +print("The first 20 terms of the Calkin-Wilf sequence are:") +for i = 1, 20 do fmt.print("%2d: %s", i, cw[i]:format("%d", "%d", false)) end +print() +local r = rat.of(83116, 51639) +local cf = to_continued(r) +local tn = get_term_number(cf) +fmt.print("%s is the %s term of the sequence.", r, fmt.ord(tn, true)) diff --git a/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-1.pluto b/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-1.pluto new file mode 100644 index 0000000000..e133651e4e --- /dev/null +++ b/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-1.pluto @@ -0,0 +1,18 @@ +/* mylib.c */ + +// gcc -c -fpic mylib.c +// gcc -shared -o mylib.so mylib.o + +#include +#include + +static void *strptr = NULL; + +extern char *my_strdup(const char *src) { + strptr = (void *)strdup(src); + return (char *)strptr; +} + +extern void my_free() { + free(strptr); +} diff --git a/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-2.pluto b/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-2.pluto new file mode 100644 index 0000000000..d99013f303 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Pluto/call-a-foreign-language-function-2.pluto @@ -0,0 +1,10 @@ +local ffi = require "pluto:ffi" +local lib = ffi.open("./mylib.so") +lib:cdef[[ + char *my_strdup(const char *src); + void my_free(); +]] +local s = "Hello World!" +print(lib.my_strdup(s)) +lib.my_free() +lib = nil diff --git a/Task/Call-a-function-in-a-shared-library/Pluto/call-a-function-in-a-shared-library.pluto b/Task/Call-a-function-in-a-shared-library/Pluto/call-a-function-in-a-shared-library.pluto new file mode 100644 index 0000000000..e32bbfc202 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Pluto/call-a-function-in-a-shared-library.pluto @@ -0,0 +1,19 @@ +local s1, s2 = "Hello", " World!" +local ffi = require "pluto:ffi" +local lib = ffi.open(os.platform == "windows" ? "msvcrt" : "libc.so.6") +if lib then + print("Shared library found") + lib:cdef[[ + char *strcat(char *dest, const char *src); + size_t strlen(const char *str); + ]] + local s = lib.strcat(s1, s2) + print(s) + print(lib.strlen(s)) + lib = nil +else + print("Shared library not found.") + local s = s1 .. s2 + print(s) + print(#s) +end diff --git a/Task/Call-a-function/ArkScript/call-a-function-1.ark b/Task/Call-a-function/ArkScript/call-a-function-1.ark new file mode 100644 index 0000000000..6b9bbd7045 --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-1.ark @@ -0,0 +1,4 @@ +# function call with no arguments +(foo) +# function call with fixed number of arguments +(bar 1 2) diff --git a/Task/Call-a-function/ArkScript/call-a-function-2.ark b/Task/Call-a-function/ArkScript/call-a-function-2.ark new file mode 100644 index 0000000000..83042ac194 --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-2.ark @@ -0,0 +1,3 @@ +(macro foo (...args) (print args)) +(foo) # => [] +(foo 1 2 3) # => [1 2 3] diff --git a/Task/Call-a-function/ArkScript/call-a-function-3.ark b/Task/Call-a-function/ArkScript/call-a-function-3.ark new file mode 100644 index 0000000000..85e79cbedf --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-3.ark @@ -0,0 +1,6 @@ +(let foo (fun () + 4 # this value will be discarded as it has no effect + (compute_something 1 2 3) # the return value will be discarded too + 5 )) + +(print (foo)) # => 5 diff --git a/Task/Call-a-function/ArkScript/call-a-function-4.ark b/Task/Call-a-function/ArkScript/call-a-function-4.ark new file mode 100644 index 0000000000..9480ebac53 --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-4.ark @@ -0,0 +1,6 @@ +(mut a 5) +(let foo (fun (bar) + (set bar 12))) +(print a) # => 5 +(foo a) +(print a) # => 5 diff --git a/Task/Call-a-function/ArkScript/call-a-function-5.ark b/Task/Call-a-function/ArkScript/call-a-function-5.ark new file mode 100644 index 0000000000..1f9b736c48 --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-5.ark @@ -0,0 +1,3 @@ +(if (= 5 (foo)) + (compute_something) + (print "uhoh")) diff --git a/Task/Call-a-function/ArkScript/call-a-function-6.ark b/Task/Call-a-function/ArkScript/call-a-function-6.ark new file mode 100644 index 0000000000..bb28c2001a --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-6.ark @@ -0,0 +1,4 @@ +(let foo (fun () ())) + +(print (type foo)) # => Function +(print (type print)) # => CProc diff --git a/Task/Call-a-function/ArkScript/call-a-function-7.ark b/Task/Call-a-function/ArkScript/call-a-function-7.ark new file mode 100644 index 0000000000..91926323a6 --- /dev/null +++ b/Task/Call-a-function/ArkScript/call-a-function-7.ark @@ -0,0 +1,8 @@ +(import std.Macros) + +(let test_func (fun (a b c) (* a b c))) +(let test_func1 (partial test_func 1)) +(let test_func2 (partial test_func1 2)) + +(print (test_func1 2 3)) # => 6 +(print (test_func2 3)) # => 6 diff --git a/Task/Call-a-function/DuckDB/call-a-function-1.duckdb b/Task/Call-a-function/DuckDB/call-a-function-1.duckdb new file mode 100644 index 0000000000..a40b00fc78 --- /dev/null +++ b/Task/Call-a-function/DuckDB/call-a-function-1.duckdb @@ -0,0 +1,5 @@ +create or replace macro fl(TableName) as table ( + (from query_table(TableName) limit 1) + UNION ALL + (select last(COLUMNS(*)) from query_table(TableName)) +); diff --git a/Task/Call-a-function/DuckDB/call-a-function-2.duckdb b/Task/Call-a-function/DuckDB/call-a-function-2.duckdb new file mode 100644 index 0000000000..f62d15561c --- /dev/null +++ b/Task/Call-a-function/DuckDB/call-a-function-2.duckdb @@ -0,0 +1 @@ +CREATE MACRO add_default(a, b := 5) AS a + b; diff --git a/Task/Call-a-function/Elena/call-a-function-1.elena b/Task/Call-a-function/Elena/call-a-function-1.elena index ce3efa2f68..2943a177d8 100644 --- a/Task/Call-a-function/Elena/call-a-function-1.elena +++ b/Task/Call-a-function/Elena/call-a-function-1.elena @@ -1,2 +1,2 @@ -var c0 := { console.writeLine("No argument provided") }; -var c2 := (int a, int b){ console.printLine("Arguments ",a," and ",b," provided") }; +var c0 := { Console.writeLine("No argument provided") }; +var c2 := (int a, int b){ Console.printLine("Arguments ",a," and ",b," provided") }; diff --git a/Task/Call-an-object-method/ArkScript/call-an-object-method.ark b/Task/Call-an-object-method/ArkScript/call-an-object-method.ark new file mode 100644 index 0000000000..7052c3c4b8 --- /dev/null +++ b/Task/Call-an-object-method/ArkScript/call-an-object-method.ark @@ -0,0 +1,17 @@ +(let create_user (fun (username password age) { + (let change_username (fun (new_name) + (set username new_name))) + (let check_password (fun (pass) + (= pass password))) + + (fun (&username &password &age &change_username &check_password) ()) })) + +(let me (create_user "Lex" "passw0rd" 25)) +(let john (create_user "John" "qwerty123" 28)) + +(assert (not (me.check_password "test!")) "password is not 'test!'") +(assert (!= me.username john.username) "usernames are distinct") + +(assert (= me.username "Lex") "my username is Lex") +(me.change_username "Rosetta") +(assert (= me.username "Rosetta") "my username is now Rosetta!") diff --git a/Task/Call-an-object-method/Elena/call-an-object-method.elena b/Task/Call-an-object-method/Elena/call-an-object-method.elena index 37f6dbf55c..b431936814 100644 --- a/Task/Call-an-object-method/Elena/call-an-object-method.elena +++ b/Task/Call-an-object-method/Elena/call-an-object-method.elena @@ -1 +1 @@ - console.printLine("Hello"," ","World!"); + Console.printLine("Hello"," ","World!"); diff --git a/Task/Call-an-object-method/Haxe/call-an-object-method.haxe b/Task/Call-an-object-method/Haxe/call-an-object-method.haxe new file mode 100644 index 0000000000..5eb6663bd5 --- /dev/null +++ b/Task/Call-an-object-method/Haxe/call-an-object-method.haxe @@ -0,0 +1,13 @@ +class ExampleClass { + public function exampleMethod() { + return "This is a method!"; + } + public function new() {} +} + +class Main { + static public function main():Void { + var exampleObject = new ExampleClass(); + trace(exampleObject.exampleMethod()); + } +} diff --git a/Task/Camel-case-and-snake-case/Ada/camel-case-and-snake-case.ada b/Task/Camel-case-and-snake-case/Ada/camel-case-and-snake-case.ada new file mode 100644 index 0000000000..8da706fcd8 --- /dev/null +++ b/Task/Camel-case-and-snake-case/Ada/camel-case-and-snake-case.ada @@ -0,0 +1,114 @@ +with Ada.Characters.Handling, + Ada.Strings, + Ada.Strings.Fixed, + Ada.Strings.Maps, + Ada.Strings.Maps.Constants, + Ada.Text_IO; + +use Ada.Characters.Handling, + Ada.Strings, + Ada.Strings.Fixed, + Ada.Strings.Maps, + Ada.Strings.Maps.Constants; + +procedure Camel_Snake_Case is + type Sample_Array is array (Positive range <>) of access constant String; + -- Work around for array elements needing to be the same size. + -- Could also use Ada.Strings.Bounded_Strings instead. + S1 : aliased constant String := "snakeCase"; + S2 : aliased constant String := "snake_case"; + S3 : aliased constant String := "variable_10_case"; + S4 : aliased constant String := "variable10Case"; + S5 : aliased constant String := "ɛrgo rE tHis"; + S6 : aliased constant String := "hurry-up-joe!"; + S7 : aliased constant String := "c://my-docs/happy_Flag-Day/12.doc"; + S8 : aliased constant String := " spaces "; + + Samples : constant Sample_Array := + ( + S1'Access, + S2'Access, + S3'Access, + S4'Access, + S5'Access, + S6'Access, + S7'Access, + S8'Access + ); + + function Should_Insert (This, Last : Character) return Boolean is + ( + (Is_In (Last, Lower_Set) and then + Is_In (This, Upper_Set or Decimal_Digit_Set)) + or else + (Is_In (Last, Upper_Set) and then + Is_In (This, Decimal_Digit_Set)) + or else + (Is_In (Last, Decimal_Digit_Set) and then + Is_In (This, Upper_Set)) + ); + + function To_Snake_Case (S : String) return String is + Trimmed : constant String := Trim (S, Both); + Separator_Map : constant Character_Mapping := To_Mapping (" -", "__"); + Translated : constant String := Translate (Trimmed, Separator_Map); + New_Word_Set : constant Character_Set := Upper_Set or Decimal_Digit_Set; + New_Word_Chars : constant Natural := Count (Translated, New_Word_Set); + Snake : String (1 .. Translated'Length + New_Word_Chars); + J : Positive := 2; + L : Character; + begin + Snake (1 .. Translated'Length) := Translated; + + for I in 2 .. Translated'Last loop + if Should_Insert (Translated (I), Translated (I - 1)) then + Snake (J) := '_'; + J := J + 1; + end if; + + L := Translated (I); + + if Is_In (Translated (I), Upper_Set) then + L := To_Lower (L); + end if; + + Snake (J) := L; + J := J + 1; + end loop; + + return Snake (1 .. J - 1); + end To_Snake_Case; + + function To_Camel_Case (S : String) return String is + Trimmed : constant String := Trim (S, Both); + Separators : constant Character_Set := To_Set (" -_"); + Snake : String (Trimmed'Range) := Trimmed; + J : Positive := 2; + begin + for I in 2 .. Trimmed'Length loop + if not Is_In (Trimmed (I), Separators) then + if Is_In (Trimmed (I - 1), Separators) and then + Is_In (Trimmed (I), Lower_Set) then + Snake (J) := To_Upper (Trimmed (I)); + else + Snake (J) := Trimmed (I); + end if; + + J := J + 1; + end if; + end loop; + + return Snake (1 .. J - 1); + end To_Camel_Case; + +begin + Ada.Text_IO.Put_Line ("=Snake Case="); + for I of Samples loop + Ada.Text_IO.Put_Line (I.all & " => " & To_Snake_Case (I.all)); + end loop; + + Ada.Text_IO.Put_Line ("=Camel Case="); + for I of Samples loop + Ada.Text_IO.Put_Line (I.all & " => " & To_Camel_Case (I.all)); + end loop; +end Camel_Snake_Case; diff --git a/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs b/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs new file mode 100644 index 0000000000..672207f79b --- /dev/null +++ b/Task/Camel-case-and-snake-case/C-sharp/camel-case-and-snake-case.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Text; + +public static class CamelCaseAndSnakeCase +{ + public static void Main(string[] args) + { + List variableNames = new List + { + "snakeCase", "snake_case", "variable_10_case", "variable10Case", + "ergo rE tHis", "hurry-up-joe!", "c://my-docs/happy_Flag-Day/12.doc", " spaces " + }; + + Console.WriteLine($"{"=== To snake_case ===",48}"); + foreach (string text in variableNames) + { + Console.WriteLine($"{text,34} --> {ToSnakeCase(text)}"); + } + + Console.WriteLine(); + Console.WriteLine($"{"=== To camelCase ===",48}"); + foreach (string text in variableNames) + { + Console.WriteLine($"{text,34} --> {ToCamelCase(text)}"); + } + } + + private static string ToSnakeCase(string aCamel) + { + aCamel = aCamel.Trim().Replace(SPACE, UNDERSCORE).Replace(HYPHEN, UNDERSCORE); + StringBuilder snake = new StringBuilder(); + bool first = true; + foreach (char ch in aCamel) + { + if (first) + { + snake.Append(ch); + first = false; + } + else if (!first && char.IsUpper(ch)) + { + if (snake.ToString().EndsWith(UNDERSCORE)) + { + snake.Append(char.ToLower(ch)); + } + else + { + snake.Append(UNDERSCORE + char.ToLower(ch)); + } + } + else + { + snake.Append(ch); + } + } + return snake.ToString(); + } + + private static string ToCamelCase(string aSnake) + { + aSnake = aSnake.Trim().Replace(SPACE, UNDERSCORE).Replace(HYPHEN, UNDERSCORE); + StringBuilder camel = new StringBuilder(); + bool underscore = false; + foreach (char ch in aSnake) + { + if (ch.ToString().Equals(UNDERSCORE)) + { + underscore = true; + } + else if (underscore) + { + camel.Append(char.ToUpper(ch)); + underscore = false; + } + else + { + camel.Append(ch); + } + } + return camel.ToString(); + } + + private static readonly string SPACE = " "; + private static readonly string UNDERSCORE = "_"; + private static readonly string HYPHEN = "-"; +} diff --git a/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math b/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math new file mode 100644 index 0000000000..ecae1a970d --- /dev/null +++ b/Task/Camel-case-and-snake-case/Mathematica/camel-case-and-snake-case.math @@ -0,0 +1,85 @@ +(* String case conversion functions in Mathematica *) + +snakeToCamelCase[nam_String, sep_String : "[_]+", lcmiddle_ : False] := Module[{words}, + If[nam == "", Return[nam]]; + words = StringSplit[StringTrim[nam], RegularExpression[sep]]; + If[lcmiddle, words = ToLowerCase /@ words]; + words[[2 ;;]] = StringJoin[ToUpperCase[StringTake[#, 1]], StringDrop[#, 1]] & /@ Select[words[[2 ;;]], StringLength[#] > 0 &]; + StringJoin[words] +] + +spaceToCamelCase[nam_String] := snakeToCamelCase[nam, "\\s+"] + +kebabToCamelCase[nam_String] := snakeToCamelCase[nam, "[\\-]+"] + +periodToCamelCase[nam_String] := snakeToCamelCase[nam, "[\\.]+"] + +allsepToCamelCase[nam_String] := snakeToCamelCase[nam, "[ \\-_\\.]+"] + +lowermiddleAllsepToCamelCase[nam_String] := snakeToCamelCase[nam, "[ \\-_\\.]+", True] + +camelToSnakeCase[nam_String, sep_String : "_", allsep_String : "[_]+", lcmiddle_ : True] := Module[{result, sep1, words}, + result = StringReplace[StringTrim[nam], RegularExpression["([A-Z]+)"] -> sep <> "$1"]; + sep1 = If[sep == ".", "\\.", sep]; + If[lcmiddle, + words = Select[StringSplit[result, sep1], StringLength[#] > 0 &]; + result = StringRiffle[ToLowerCase /@ words, sep], + words = Select[StringSplit[result, sep1], StringLength[#] > 0 &]; + result = StringRiffle[StringJoin[ToLowerCase[StringTake[#, 1]], StringDrop[#, 1]] & /@ words, sep] + ]; + StringReplace[result, RegularExpression[allsep] -> sep] +] + +preserveMidcapsCamelToSnakeCase[nam_String] := camelToSnakeCase[nam, "_", "[_]+", False] + +allsepToSnakeCase[nam_String] := camelToSnakeCase[nam, "_", "[ \\-\\._]+"] + +allsepToKebabCase[nam_String] := camelToSnakeCase[nam, "-", "[ \\-\\._]+"] + +allsepToSpaceCase[nam_String] := camelToSnakeCase[nam, " ", "[ \\-\\._]+"] + +allsepToPeriodCase[nam_String] := camelToSnakeCase[nam, ".", "[ \\-\\._]+"] + +allsepToSlashCase[nam_String] := camelToSnakeCase[nam, "/", "[ \\-\\._]+"] + +(* Test the functions *) +testFunctions = { + snakeToCamelCase, + spaceToCamelCase, + kebabToCamelCase, + periodToCamelCase, + allsepToCamelCase, + lowermiddleAllsepToCamelCase, + camelToSnakeCase, + preserveMidcapsCamelToSnakeCase, + allsepToSnakeCase, + allsepToKebabCase, + allsepToSpaceCase, + allsepToPeriodCase, + allsepToSlashCase +}; + +testStrings = { + "snakeCase", + "snake_case", + "snake-case", + "snake case", + "snake CASE", + "snake.case", + "variable_10_case", + "variable10Case", + "ɛrgo rE tHis", + "hurry-up-joe!", + "c://my-docs/happy_Flag-Day/12.doc", + " spaces " +}; + +Do[ + Print["Testing function ", f, ":"]; + Do[ + Print[StringPadLeft[testString, 36], " => ", f[testString]], + {testString, testStrings} + ]; + Print[""], + {f, testFunctions} +] diff --git a/Task/Camel-case-and-snake-case/Rust/camel-case-and-snake-case.rs b/Task/Camel-case-and-snake-case/Rust/camel-case-and-snake-case.rs new file mode 100644 index 0000000000..995275f9f2 --- /dev/null +++ b/Task/Camel-case-and-snake-case/Rust/camel-case-and-snake-case.rs @@ -0,0 +1,93 @@ +const HYPHEN: char = '-'; +const SPACE: char = ' '; +const UNDERSCORE: char = '_'; +const WHITESPACE: &str = " \n\r\t\u{0C}\u{0B}"; + +fn left_trim(text: &str) -> &str { + text.trim_start_matches(WHITESPACE.chars().collect::>().as_slice()) +} + +fn right_trim(text: &str) -> &str { + text.trim_end_matches(WHITESPACE.chars().collect::>().as_slice()) +} + +fn trim(text: &str) -> &str { + text.trim_matches(WHITESPACE.chars().collect::>().as_slice()) +} + +fn prepare_for_conversion(text: &mut String) { + *text = trim(text).to_string(); + *text = text.replace(SPACE, &UNDERSCORE.to_string()); + *text = text.replace(HYPHEN, &UNDERSCORE.to_string()); +} + +fn to_snake_case(camel: &str) -> String { + let mut text = camel.to_string(); + prepare_for_conversion(&mut text); + + let mut snake = String::new(); + let mut first = true; + + for ch in text.chars() { + if first { + snake.push(ch); + first = false; + } else if ch.is_ascii_uppercase() { + if snake.chars().last() == Some(UNDERSCORE) { + snake.push(ch.to_ascii_lowercase()); + } else { + snake.push(UNDERSCORE); + snake.push(ch.to_ascii_lowercase()); + } + } else { + snake.push(ch); + } + } + + snake +} + +fn to_camel_case(snake: &str) -> String { + let mut text = snake.to_string(); + prepare_for_conversion(&mut text); + + let mut camel = String::new(); + let mut underscore = false; + + for ch in text.chars() { + if ch == UNDERSCORE { + underscore = true; + } else if underscore { + camel.push(ch.to_ascii_uppercase()); + underscore = false; + } else { + camel.push(ch); + } + } + + camel +} + +fn main() { + let variable_names = vec![ + "snakeCase", + "snake_case", + "variable_10_case", + "variable10Case", + "ergo rE tHis", + "hurry-up-joe!", + "c://my-docs/happy_Flag-Day/12.doc", + " spaces " + ]; + + println!("{:>48}", "=== To snake_case ==="); + for text in &variable_names { + println!("{:>34} --> {}", text, to_snake_case(text)); + } + + println!(); + println!("{:>48}", "=== To camelCase ==="); + for text in &variable_names { + println!("{:>34} --> {}", text, to_camel_case(text)); + } +} diff --git a/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig b/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig new file mode 100644 index 0000000000..faee5b8822 --- /dev/null +++ b/Task/Camel-case-and-snake-case/Zig/camel-case-and-snake-case.zig @@ -0,0 +1,134 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; + +const HYPHEN: u8 = '-'; +const SPACE: u8 = ' '; +const UNDERSCORE: u8 = '_'; +const WHITESPACE = " \n\r\t\x0C\x0B"; + +fn isWhitespace(ch: u8) bool { + for (WHITESPACE) |ws| { + if (ch == ws) return true; + } + return false; +} + +fn leftTrim(text: []const u8) []const u8 { + var start: usize = 0; + while (start < text.len and isWhitespace(text[start])) { + start += 1; + } + return text[start..]; +} + +fn rightTrim(text: []const u8) []const u8 { + var end: usize = text.len; + while (end > 0 and isWhitespace(text[end - 1])) { + end -= 1; + } + return text[0..end]; +} + +fn trim(text: []const u8) []const u8 { + return rightTrim(leftTrim(text)); +} + +fn prepareForConversion(allocator: std.mem.Allocator, text: []const u8) ![]u8 { + const trimmed = trim(text); + var result = try ArrayList(u8).initCapacity(allocator, trimmed.len); + defer result.deinit(); + + for (trimmed) |ch| { + if (ch == SPACE or ch == HYPHEN) { + try result.append(UNDERSCORE); + } else { + try result.append(ch); + } + } + + return result.toOwnedSlice(); +} + +fn toSnakeCase(allocator: std.mem.Allocator, camel: []const u8) ![]u8 { + const text = try prepareForConversion(allocator, camel); + defer allocator.free(text); + + var snake = ArrayList(u8).init(allocator); + defer snake.deinit(); + + var first = true; + + for (text) |ch| { + if (first) { + try snake.append(ch); + first = false; + } else if (std.ascii.isUpper(ch)) { + if (snake.items.len > 0 and snake.items[snake.items.len - 1] == UNDERSCORE) { + try snake.append(std.ascii.toLower(ch)); + } else { + try snake.append(UNDERSCORE); + try snake.append(std.ascii.toLower(ch)); + } + } else { + try snake.append(ch); + } + } + + return snake.toOwnedSlice(); +} + +fn toCamelCase(allocator: std.mem.Allocator, snake: []const u8) ![]u8 { + const text = try prepareForConversion(allocator, snake); + defer allocator.free(text); + + var camel = ArrayList(u8).init(allocator); + defer camel.deinit(); + + var underscore = false; + + for (text) |ch| { + if (ch == UNDERSCORE) { + underscore = true; + } else if (underscore) { + try camel.append(std.ascii.toUpper(ch)); + underscore = false; + } else { + try camel.append(ch); + } + } + + return camel.toOwnedSlice(); +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const variable_names = [_][]const u8{ + "snakeCase", + "snake_case", + "variable_10_case", + "variable10Case", + "ergo rE tHis", + "hurry-up-joe!", + "c://my-docs/happy_Flag-Day/12.doc", + " spaces " + }; + + print("{s:>48}\n", .{"=== To snake_case ==="}); + for (variable_names) |text| { + const snake = try toSnakeCase(allocator, text); + defer allocator.free(snake); + print("{s:>34} --> {s}\n", .{ text, snake }); + } + + print("\n", .{}); + print("{s:>48}\n", .{"=== To camelCase ==="}); + for (variable_names) |text| { + const camel = try toCamelCase(allocator, text); + defer allocator.free(camel); + print("{s:>34} --> {s}\n", .{ text, camel }); + } +} diff --git a/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.ada b/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.ada new file mode 100644 index 0000000000..a138a754ae --- /dev/null +++ b/Task/Canonicalize-CIDR/Ada/canonicalize-cidr.ada @@ -0,0 +1,105 @@ +with Ada.Strings; +with Ada.Strings.Fixed; +with Ada.Strings.Maps; +with Ada.Text_IO; + +use Ada.Strings; +use Ada.Strings.Fixed; +use Ada.Strings.Maps; +use Ada.Text_IO; + +procedure Canonicalize_CIDR is + type IP_Octet_Type is mod 256; + + type IP_Record_Type is record + A, B, C, D : IP_Octet_Type; + end record + with Size => 32; + + for IP_Record_Type use record + -- Use little-endian ordering to match bit array + D at 0 range 0 .. 7; + C at 1 range 0 .. 7; + B at 2 range 0 .. 7; + A at 3 range 0 .. 7; + end record; + + type IP_Bitarray_Type is array (0 .. 31) of Boolean + with Component_Size => 1; + + subtype IP_Mask_Type is Natural range 0 .. 32; + + type IP_CIDR_Type is record + IP : IP_Record_Type; + Mask : IP_Mask_Type; + end record; + + function Parse_IP_CIDR (S : String) return IP_CIDR_Type is + IP_Record : IP_CIDR_Type; + Digit_Range : Character_Range := ('0', '9'); + Digit_Set : Character_Set := To_Set (Digit_Range); + Octets : array (1 .. 4) of IP_Octet_Type; + First : Positive; + Last : Natural := 0; + begin + for I in Octets'Range loop + Find_Token (S, Digit_Set, Last + 1, Inside, First, Last); + Octets (I) := IP_Octet_Type'Value (S (First .. Last)); + end loop; + IP_Record.IP.A := Octets (1); + IP_Record.IP.B := Octets (2); + IP_Record.IP.C := Octets (3); + IP_Record.IP.D := Octets (4); + + Find_Token (S, Digit_Set, Last + 1, Inside, First, Last); + IP_Record.Mask := IP_Mask_Type'Value (S (First .. Last)); + + return IP_Record; + end Parse_IP_CIDR; + + procedure Canonicalize_IP_CIDR (Addr : in out IP_CIDR_Type) is + -- Fun part. I can overlay different types over the same bits. + Bit_Overlay : IP_Bitarray_Type with Address => Addr.IP'Address; + begin + for I in Bit_Overlay'First .. Bit_Overlay'Last - Addr.Mask loop + Bit_Overlay (I) := False; + end loop; + end Canonicalize_IP_CIDR; + + procedure Put_IP_CIDR (Addr : IP_CIDR_TYPE) is + package Octet_IO is new Ada.Text_IO.Modular_IO (IP_Octet_Type); + package Mask_IO is new Ada.Text_IO.Integer_IO (IP_Mask_Type); + begin + Octet_IO.Put (Addr.IP.A, 0); + Put ("."); + Octet_IO.Put (Addr.IP.B, 0); + Put ("."); + Octet_IO.Put (Addr.IP.C, 0); + Put ("."); + Octet_IO.Put (Addr.IP.D, 0); + Put ("/"); + Mask_IO.Put (Addr.Mask, 0); + end Put_IP_CIDR; + + procedure Show_IP_Canonicalize (S : String) is + Canon : IP_CIDR_Type := Parse_IP_CIDR (S); + begin + Canonicalize_IP_Cidr (Canon); + Put (S & " -> "); + Put_IP_CIDR (Canon); + New_Line; + end Show_IP_Canonicalize; + + Test_IPs : array (1 .. 5) of String (1 .. 18) := + ( + "36.18.154.103/12 ", + "62.62.197.11/29 ", + "67.137.119.181/4 ", + "161.214.74.21/24 ", + "184.232.176.184/18" + ); +begin + for I of Test_IPs loop + Show_IP_Canonicalize (I); + end loop; +end Canonicalize_CIDR; diff --git a/Task/Carmichael-3-strong-pseudoprimes/FutureBasic/carmichael-3-strong-pseudoprimes.basic b/Task/Carmichael-3-strong-pseudoprimes/FutureBasic/carmichael-3-strong-pseudoprimes.basic new file mode 100644 index 0000000000..46d957a349 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/FutureBasic/carmichael-3-strong-pseudoprimes.basic @@ -0,0 +1,41 @@ +include "NSLog.incl" + +int local fn SpecialMod( n as int, m as int ) +— + return ((n % m) + m) % m +end fn = 0 + +BOOl local fn IsPrime( n as NSUInteger ) as BOOL +— + if n < 2 then exit fn = NO + if n = 2 then exit fn = YES + if n % 2 == 0 then exit fn = NO + for NSUInteger i = 3 to int(n^.5) step 2 + if n % i == 0 then exit fn = NO + next +end fn = YES + +void local fn Carmichael3( p1 as int ) +— + if (!fn IsPrime(p1)) then return + + int h3, d, p2, p3 + for h3 = 1 to p1 - 1 + for d = 1 to (h3 + p1) -1 + if ((h3 + p1) * (p1 - 1) % d == 0 && fn SpecialMod(-p1 * p1, h3) == d % h3) + p2 = 1 + ((p1 - 1) * (h3 + p1) / d) + if (!fn IsPrime(p2)) then continue + p3 = 1 + (p1 * p2 / h3) + if ( !fn IsPrime(p3) || (p2 * p3) % (p1 - 1) != 1 ) then continue + NSLog( @"%3d * %-5d * %-6d = %ld", p1, p2, p3, p1 * p2 * p3 ) + end if + next + next +end fn + +for int p1 = 2 to 61 + fn Carmichael3(p1) +next +NSLogScrollToTop + +HandleEvents diff --git a/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-1.duckdb b/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-1.duckdb new file mode 100644 index 0000000000..fa772220fe --- /dev/null +++ b/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-1.duckdb @@ -0,0 +1,2 @@ +select array_agg([a,b]) as product +from (select unnest([1,2]) as a), (select unnest([3,4]) as b); diff --git a/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-2.duckdb b/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-2.duckdb new file mode 100644 index 0000000000..5714140e23 --- /dev/null +++ b/Task/Cartesian-product-of-two-or-more-lists/DuckDB/cartesian-product-of-two-or-more-lists-2.duckdb @@ -0,0 +1,8 @@ +create or replace macro cp(x,y) as ( + select array_agg([a,b] order by ix, iy) + from (select unnest(x) as a, unnest(range(0, length(x))) as ix), + (select unnest(y) as b, unnest(range(0, length(y))) as iy) +); + +# Example: +select cp([1,2], [3,4]) as product; diff --git a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb new file mode 100644 index 0000000000..0b9cd57834 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-1.duckdb @@ -0,0 +1,3 @@ +create or replace function task(dog, Dog, DOG) as ( + format('The three dogs are named {:s}, {:s} and {:s}.', dog, Dog, DOG) +); diff --git a/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb new file mode 100644 index 0000000000..d7c7d9bd1c --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/DuckDB/case-sensitivity-of-identifiers-2.duckdb @@ -0,0 +1,2 @@ +select format('The three dogs are named {:s}, {:s} and {:s}.', dog, Dog, DOG) as example +from (select 'Benjamin' as dog, 'Samba' as Dog, 'Bernie' as DOG); diff --git a/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena b/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena index b33d071054..be30409312 100644 --- a/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena +++ b/Task/Case-sensitivity-of-identifiers/Elena/case-sensitivity-of-identifiers.elena @@ -5,5 +5,5 @@ public program() var dog := "Benjamin"; var Dog := "Samba"; var DOG := "Bernie"; - console.printLineFormatted("The three dogs are named {0}, {1} and {2}", dog, Dog, DOG) + Console.printLineFormatted("The three dogs are named {0}, {1} and {2}", dog, Dog, DOG) } diff --git a/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas b/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas new file mode 100644 index 0000000000..d697568ba5 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/PascalABC.NET/case-sensitivity-of-identifiers.pas @@ -0,0 +1,8 @@ +var + dog: string; +begin + dog := 'Benjamin'; + Dog := 'Samba'; + DOG := 'Bernie'; + Writeln('There is just one dog named ' + dog); +end. diff --git a/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto b/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto new file mode 100644 index 0000000000..79d19b3417 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Pluto/case-sensitivity-of-identifiers.pluto @@ -0,0 +1,13 @@ +do + local dog = "Benjamin"; + do + local Dog = "Samba"; + do + local DOG = "Bernie"; + if DOG != Dog or DOG != dog + then print( $"The three dogs are named: {dog}, {Dog} and {DOG}" ) + else print( $"There is just one dog named: {DOG}" ) + end + end + end +end diff --git a/Task/Casting-out-nines/Pluto/casting-out-nines.pluto b/Task/Casting-out-nines/Pluto/casting-out-nines.pluto new file mode 100644 index 0000000000..123bf40ebc --- /dev/null +++ b/Task/Casting-out-nines/Pluto/casting-out-nines.pluto @@ -0,0 +1,30 @@ +local function cast_out(base, start, finish) + local b = base - 1 + local ran = range(0, b - 1):filter(|n| -> n % b == (n * n) % b) + local x = start // b + local result = {} + while true do + for ran as n do + local k = b * x + n + if k >= start then + if k > finish then return result end + result:insert(k) + end + end + ++x + end +end + +local function print_array(a, w = 3, n = 10) + for i = 1, #a do + io.write(string.format($"%{w}d ", a[i])) + if i % n == 0 then print() end + end + if #a % 10 != n then print() end +end + +print_array(cast_out(16, 1, 255)) +print() +print_array(cast_out(10, 1, 99)) +print() +print_array(cast_out(17, 1, 288)) diff --git a/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb b/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb new file mode 100644 index 0000000000..90833b9fbe --- /dev/null +++ b/Task/Catalan-numbers-Pascals-triangle/DuckDB/catalan-numbers-pascals-triangle-1.duckdb @@ -0,0 +1,20 @@ +# Compute nCr naively using UHUGEINT +# The caller should ensure 2r < n +create or replace function nCr_(n, r) as + (with recursive cte as + (SELECT 1::UHUGEINT as c, n as numerator, 1::UHUGEINT as m + UNION ALL + SELECT (c * numerator / m) as c, + (numerator - 1) as numerator, + (m + 1) as m + FROM cte + WHERE m <= r) + SELECT last(c order by m) + FROM cte +); + +create or replace function nCr(n,r) as ( + if( nNew[N + 2]; + t[1] := 1; + + for(i := 1; i <= N; i++) { + + for(j := i; j > 1; j--){ + t[j] := t[j] + t[j - 1]; + }; + + t[i + 1] := t[i]; + + for(j := i + 1; j > 1; j--) { + t[j] := t[j] + t[j - 1]; + }; + + v := t[i + 1] - t[i]; + "{$v} "->Print(); + }; + } +} diff --git a/Task/Catalan-numbers/00-META.yaml b/Task/Catalan-numbers/00-META.yaml index e2478b7550..b52af46da3 100644 --- a/Task/Catalan-numbers/00-META.yaml +++ b/Task/Catalan-numbers/00-META.yaml @@ -1,3 +1,3 @@ --- from: http://rosettacode.org/wiki/Catalan_numbers -note: Arithmetic operations +note: Numbers diff --git a/Task/Catalan-numbers/DuckDB/catalan-numbers.duckdb b/Task/Catalan-numbers/DuckDB/catalan-numbers.duckdb new file mode 100644 index 0000000000..ae5037a4e4 --- /dev/null +++ b/Task/Catalan-numbers/DuckDB/catalan-numbers.duckdb @@ -0,0 +1,30 @@ +# table of the first Catalan numbers up to catalan(n) +# using the DuckDB type determined by `one`, which should be +# 1 of an appropriate type: +create or replace function catalan_t_(mx, one) as table ( + with recursive cte(n,c) as ( + select 0 as n, one as c + union all + select n+1, + 2 * (2 * n + 1) * c / (n+2) + from cte + where n < mx + ) + from cte +); + +# In general, use UHUGEINT +create or replace function catalan_t(mx) as table ( + from catalan_t_(mx, 1::UHUGEINT) +); + +# point-wise +create or replace function catalan(nn) as ( + select c + from catalan_t(nn) + offset nn +); + +from catalan_t(15); + +from catalan_t_(100, 1::DOUBLE) offset 100; diff --git a/Task/Catamorphism/Apple/catamorphism-1.apple b/Task/Catamorphism/Apple/catamorphism-1.apple new file mode 100644 index 0000000000..98e2a06683 --- /dev/null +++ b/Task/Catamorphism/Apple/catamorphism-1.apple @@ -0,0 +1,2 @@ + > (+)/ₒ 10 ⟨1::int,2,3,4,5,6,7,8,9⟩ +55 diff --git a/Task/Catamorphism/Apple/catamorphism-2.apple b/Task/Catamorphism/Apple/catamorphism-2.apple new file mode 100644 index 0000000000..f5028abe67 --- /dev/null +++ b/Task/Catamorphism/Apple/catamorphism-2.apple @@ -0,0 +1,2 @@ + > :ty (/) +(a → a → a) → Arr (i + 1 `Cons` sh) a → Arr sh a diff --git a/Task/Catamorphism/Apple/catamorphism-3.apple b/Task/Catamorphism/Apple/catamorphism-3.apple new file mode 100644 index 0000000000..bb376e7c75 --- /dev/null +++ b/Task/Catamorphism/Apple/catamorphism-3.apple @@ -0,0 +1,2 @@ + > (+)/ ⟨1::int,2,3,4,5,6,7,8,9⟩ +45 diff --git a/Task/Catamorphism/ArkScript/catamorphism.ark b/Task/Catamorphism/ArkScript/catamorphism.ark new file mode 100644 index 0000000000..747ff2cfd7 --- /dev/null +++ b/Task/Catamorphism/ArkScript/catamorphism.ark @@ -0,0 +1,7 @@ +(import std.List :reduce :foldLeft) + +(let sum (fun (a b) (+ a b))) + +(assert (= 10 (reduce [1 2 3 4] sum)) "reduce array to 10") +(assert (= 10 (foldLeft [1 2 3 4] 0 sum)) "fold array to 10") +(assert (= 12 (foldLeft [1 2 3 4] 2 sum)) "fold array to 12 with initial value") diff --git a/Task/Catamorphism/Elena/catamorphism.elena b/Task/Catamorphism/Elena/catamorphism.elena index df104d5f15..7876e7b8fa 100644 --- a/Task/Catamorphism/Elena/catamorphism.elena +++ b/Task/Catamorphism/Elena/catamorphism.elena @@ -13,5 +13,5 @@ public program() var concatenation := numbers.accumulate(new StringWriter(), (a,b => a.toPrintable() + b.toPrintable())); - console.printLine(summary," ",product," ",concatenation) + Console.printLine(summary," ",product," ",concatenation) } diff --git a/Task/Catmull-Clark-subdivision-surface/FreeBASIC/catmull-clark-subdivision-surface.basic b/Task/Catmull-Clark-subdivision-surface/FreeBASIC/catmull-clark-subdivision-surface.basic new file mode 100644 index 0000000000..8b4d224643 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/FreeBASIC/catmull-clark-subdivision-surface.basic @@ -0,0 +1,250 @@ +Type Punto + x As Double + y As Double + z As Double +End Type + +Type DatosBorde + a As Integer + b As Integer + f1 As Integer + f2 As Integer +End Type + +Dim Shared As Integer datosCara(0 To 4000-1) ' 1000 faces * 4 vertex +Dim Shared As Integer Ptr carasNuevas(0 To 1000-1) + + +Sub printPunto(p As Punto) + Print Using "[##.####, ##.####, ##.####]"; p.x; p.y; p.z +End Sub + +Sub printCara(f As Integer Ptr, n As Integer) + Print "["; + For i As Integer = 0 To n-1 + Print Using "## "; f[i]; + Next + Print Chr(8) & "]" +End Sub + +Function sumPunto(p1 As Punto, p2 As Punto) As Punto + Return Type(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z) +End Function +Function mulPunto(p As Punto, m As Double) As Punto + Return Type(p.x * m, p.y * m, p.z * m) +End Function +Function divPunto(p As Punto, d As Double) As Punto + Return mulPunto(p, 1/d) +End Function +Function centerPunto(p1 As Punto, p2 As Punto) As Punto + Return divPunto(sumPunto(p1, p2), 2) +End Function + +Function encontrarBorde(bordes() As DatosBorde, nBordes As Integer, a As Integer, b As Integer) As Integer + For k As Integer = 0 To nBordes-1 + If (bordes(k).a = a And bordes(k).b = b) Or (bordes(k).a = b And bordes(k).b = a) Then Return k + Next + Return -1 +End Function + +Sub cmcSubdiv(puntosEntrada() As Punto, carasEntrada() As Integer Ptr, carasCnt As Integer, puntosSalida() As Punto, carasSalida() As Integer Ptr, Byref carasSalidaCnt As Integer) + Dim As Integer i, j, n, fi + Dim As Integer Ptr f + + ' Step 1: calculate points of faces + Dim As Punto facePuntos(0 To carasCnt-1) + For i = 0 To carasCnt-1 + f = carasEntrada(i) + n = f[0] + Dim As Punto fp = Type(0,0,0) + For j = 1 To n + fp = sumPunto(fp, puntosEntrada(f[j])) + Next + facePuntos(i) = divPunto(fp, n) + Next + + ' Step 2: calculate unique edges and their faces + Redim As DatosBorde bordes(0 To 0) + Dim As Integer nBordes = 0 + For fi = 0 To carasCnt-1 + f = carasEntrada(fi) + n = f[0] + For i = 1 To n + Dim As Integer a = f[i] + Dim As Integer b = f[Iif(i < n, i+1, 1)] + If a > b Then Swap a, b + Dim As Integer idx = encontrarBorde(bordes(), nBordes, a, b) + If idx = -1 Then + If nBordes > 0 Then Redim Preserve bordes(0 To nBordes) + bordes(nBordes).a = a + bordes(nBordes).b = b + bordes(nBordes).f1 = fi + bordes(nBordes).f2 = -1 + nBordes += 1 + Else + bordes(idx).f2 = fi + End If + Next + Next + Redim Preserve bordes(0 To nBordes-1) + + ' Step 3: calculate edge points + Dim As Punto bordePuntos(0 To Ubound(bordes)) + For i = 0 To Ubound(bordes) + Dim As Punto ea = puntosEntrada(bordes(i).a) + Dim As Punto eb = puntosEntrada(bordes(i).b) + Dim As Punto cp = centerPunto(ea, eb) + Dim As Punto fp1 = facePuntos(bordes(i).f1) + Dim As Punto fp2 = Iif(bordes(i).f2 = -1, fp1, facePuntos(bordes(i).f2)) + Dim As Punto cfp = centerPunto(fp1, fp2) + bordePuntos(i) = centerPunto(cp, cfp) + Next + + ' Step 4: calculate new vertex points + Dim As Integer np = Ubound(puntosEntrada) + 1 + Dim As Integer pointsFaces(0 To np-1) + For fi = 0 To carasCnt-1 + f = carasEntrada(fi) + n = f[0] + For i = 1 To n + pointsFaces(f[i]) += 1 + Next + Next + Dim As Punto newPuntos(0 To np-1) + For i = 0 To np-1 + n = pointsFaces(i) + Dim As Double m1 = (n-3)/n + Dim As Double m2 = 1.0/n + Dim As Double m3 = 2.0/n + Dim As Punto afp = Type(0,0,0) + Dim As Punto ame = Type(0,0,0) + For fi = 0 To carasCnt-1 + f = carasEntrada(fi) + Dim As Integer nface = f[0] + For j = 1 To nface + If f[j] = i Then afp = sumPunto(afp, facePuntos(fi)) + Next + Next + For ei As Integer = 0 To Ubound(bordes) + If bordes(ei).a = i Or bordes(ei).b = i Then + Dim As Punto ea = puntosEntrada(bordes(ei).a) + Dim As Punto eb = puntosEntrada(bordes(ei).b) + ame = sumPunto(ame, centerPunto(ea, eb)) + End If + Next + afp = divPunto(afp, n) + ame = divPunto(ame, n) + Dim p1 As Punto = mulPunto(puntosEntrada(i), m1) + Dim p2 As Punto = mulPunto(afp, m2) + Dim p3 As Punto = mulPunto(ame, m3) + newPuntos(i) = sumPunto(sumPunto(p1, p2), p3) + Next + + ' Step 5: add face points + Dim As Integer caraPuntoNums(0 To carasCnt-1) + Dim As Integer sgtePuntoNum = np + Redim Preserve newPuntos(0 To sgtePuntoNum + carasCnt - 1) + For i = 0 To carasCnt-1 + newPuntos(sgtePuntoNum) = facePuntos(i) + caraPuntoNums(i) = sgtePuntoNum + sgtePuntoNum += 1 + Next + + ' Step 6: add edge points + Dim As Integer bordePuntoNums(0 To Ubound(bordes)) + Redim Preserve newPuntos(0 To sgtePuntoNum + Ubound(bordes)) + For i = 0 To Ubound(bordes) + newPuntos(sgtePuntoNum) = bordePuntos(i) + bordePuntoNums(i) = sgtePuntoNum + sgtePuntoNum += 1 + Next + + ' Step 7: build new faces (quads only) + Dim As Integer totalNewCaras = carasCnt * 4 + Dim As Integer caraLen = 4 + Dim As Integer caraIdx = 0 + For fi = 0 To carasCnt-1 + f = carasEntrada(fi) + If f[0] = 4 Then + Dim As Integer a = f[1], b = f[2], c = f[3], d = f[4] + Dim As Integer ab, bc, cd, da + For ei As Integer = 0 To Ubound(bordes) + If (bordes(ei).a = a And bordes(ei).b = b) Or (bordes(ei).a = b And bordes(ei).b = a) Then ab = bordePuntoNums(ei) + If (bordes(ei).a = b And bordes(ei).b = c) Or (bordes(ei).a = c And bordes(ei).b = b) Then bc = bordePuntoNums(ei) + If (bordes(ei).a = c And bordes(ei).b = d) Or (bordes(ei).a = d And bordes(ei).b = c) Then cd = bordePuntoNums(ei) + If (bordes(ei).a = d And bordes(ei).b = a) Or (bordes(ei).a = a And bordes(ei).b = d) Then da = bordePuntoNums(ei) + Next + Dim As Integer fp = caraPuntoNums(fi) + ' Face 1 + datosCara(caraIdx*caraLen + 0) = a + datosCara(caraIdx*caraLen + 1) = ab + datosCara(caraIdx*caraLen + 2) = fp + datosCara(caraIdx*caraLen + 3) = da + carasNuevas(caraIdx) = @datosCara(caraIdx*caraLen) + caraIdx += 1 + ' Face 2 + datosCara(caraIdx*caraLen + 0) = b + datosCara(caraIdx*caraLen + 1) = bc + datosCara(caraIdx*caraLen + 2) = fp + datosCara(caraIdx*caraLen + 3) = ab + carasNuevas(caraIdx) = @datosCara(caraIdx*caraLen) + caraIdx += 1 + ' Face 3 + datosCara(caraIdx*caraLen + 0) = c + datosCara(caraIdx*caraLen + 1) = cd + datosCara(caraIdx*caraLen + 2) = fp + datosCara(caraIdx*caraLen + 3) = bc + carasNuevas(caraIdx) = @datosCara(caraIdx*caraLen) + caraIdx += 1 + ' Face 4 + datosCara(caraIdx*caraLen + 0) = d + datosCara(caraIdx*caraLen + 1) = da + datosCara(caraIdx*caraLen + 2) = fp + datosCara(caraIdx*caraLen + 3) = cd + carasNuevas(caraIdx) = @datosCara(caraIdx*caraLen) + caraIdx += 1 + End If + Next + + Redim puntosSalida(0 To Ubound(newPuntos)) + For i = 0 To Ubound(newPuntos): puntosSalida(i) = newPuntos(i): Next + Redim carasSalida(0 To caraIdx-1) + For i = 0 To caraIdx-1: carasSalida(i) = carasNuevas(i): Next + carasSalidaCnt = caraIdx +End Sub + +' Main program +Dim As Punto puntosEntrada(0 To 7) = { _ +Type(-1, 1, 1), _ ' 0 +Type(-1, -1, 1), _ ' 1 +Type( 1, -1, 1), _ ' 2 +Type( 1, 1, 1), _ ' 3 +Type( 1, -1, -1), _ ' 4 +Type( 1, 1, -1), _ ' 5 +Type(-1, -1, -1), _ ' 6 +Type(-1, 1, -1) } ' 7 + +Dim As Integer f0(0 To 4) = {4, 0, 1, 2, 3} +Dim As Integer f1(0 To 4) = {4, 3, 2, 4, 5} +Dim As Integer f2(0 To 4) = {4, 5, 4, 6, 7} +Dim As Integer f3(0 To 4) = {4, 7, 0, 3, 5} +Dim As Integer f4(0 To 4) = {4, 7, 6, 1, 0} +Dim As Integer f5(0 To 4) = {4, 6, 1, 2, 4} + +Dim As Integer Ptr carasEntrada(0 To 5) = {@f0(0), @f1(0), @f2(0), @f3(0), @f4(0), @f5(0)} +Dim As Punto puntosSalida() +Dim As Integer Ptr carasSalida() +Dim As Integer carasSalidaCnt, i + +cmcSubdiv(puntosEntrada(), carasEntrada(), 6, puntosSalida(), carasSalida(), carasSalidaCnt) + +For i = 0 To Ubound(puntosSalida) + printPunto(puntosSalida(i)) +Next + +Print Chr(10) +For i = 0 To carasSalidaCnt-1 + printCara(carasSalida(i), 4) +Next + +Sleep diff --git a/Task/Catmull-Clark-subdivision-surface/JavaScript/catmull-clark-subdivision-surface.js b/Task/Catmull-Clark-subdivision-surface/JavaScript/catmull-clark-subdivision-surface.js new file mode 100644 index 0000000000..f791b148c1 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/JavaScript/catmull-clark-subdivision-surface.js @@ -0,0 +1,255 @@ +// A point of the current Catmull-Clark surface. +class Point { + constructor(x = 0.0, y = 0.0, z = 0.0) { + this.x = x; + this.y = y; + this.z = z; + } + + add(other) { + return new Point(this.x + other.x, this.y + other.y, this.z + other.z); + } + + multiply(factor) { + return new Point(this.x * factor, this.y * factor, this.z * factor); + } + + divide(factor) { + return this.multiply(1.0 / factor); + } + + lessThan(other) { + return (this.x < other.x) || + (this.x === other.x && this.y < other.y) || + (this.x === other.x && this.y === other.y && this.z < other.z); + } + + equals(other) { + return this.x === other.x && this.y === other.y && this.z === other.z; + } + + format(value) { + const formattedValue = value.toFixed(3); + return (value >= 0) ? " " + formattedValue : formattedValue; + } + + toString() { + return "(" + this.format(this.x) + ", " + this.format(this.y) + ", " + this.format(this.z) + ")"; + } +} + +// Return the centroid point of the given array of points. +function centroid(points) { + let sum = new Point(); + for (const point of points) { + sum = sum.add(point); + } + return sum.divide(points.length); +} + +// An edge of the current Catmull-Clark surface. +class Edge { + constructor(aBegin, aEnd) { + if (aEnd.lessThan(aBegin)) { + [aBegin, aEnd] = [aEnd, aBegin]; + } + this.begin = aBegin; + this.end = aEnd; + this.mid_edge = centroid([this.begin, this.end]); + this.hole_edge = false; + } + + contains(point) { + return point.equals(this.begin) || point.equals(this.end); + } + + lessThan(other) { + return this.begin.lessThan(other.begin) || + (this.begin.equals(other.begin) && this.end.lessThan(other.end)); + } + + equals(other) { + return this.contains(other.begin) && this.contains(other.end); + } +} + +// A face of the current Catmull-Clark surface. +class Face { + constructor(aVertices) { + this.vertices = aVertices; + this.face_point = centroid(this.vertices); + this.edges = []; + + for (let i = 0; i < this.vertices.length - 1; ++i) { + this.edges.push(new Edge(this.vertices[i], this.vertices[i + 1])); + } + this.edges.push(new Edge(this.vertices[this.vertices.length - 1], this.vertices[0])); + } + + contains(vertex) { + if (vertex instanceof Point) { + return this.vertices.some(v => v.equals(vertex)); + } else if (vertex instanceof Edge) { + return this.contains(vertex.begin) && this.contains(vertex.end); + } + return false; + } + + toString() { + let result = "Face: "; + for (let i = 0; i < this.vertices.length - 1; ++i) { + result += this.vertices[i].toString() + ", "; + } + return result + this.vertices[this.vertices.length - 1].toString(); + } +} + +// Return a map containing, for each vertex, +// the new vertex created by the current iteration of the Catmull-Clark surface subdivision algorithm. +function next_vertices(edges, faces) { + const next_vertices_map = new Map(); + const vertices = new Set(); + + // Collect all unique vertices + for (const face of faces) { + for (const vertex of face.vertices) { + vertices.add(vertex); + } + } + + // Convert Set to Array for iteration + const verticesArray = Array.from(vertices); + + for (const vertex of verticesArray) { + const faces_for_vertex = faces.filter(face => face.contains(vertex)); + const edges_for_vertex = edges.filter(edge => edge.contains(vertex)); + + if (faces_for_vertex.length !== edges_for_vertex.length) { + const mid_edge_of_hole_edges = edges_for_vertex + .filter(edge => edge.hole_edge) + .map(edge => edge.mid_edge); + + mid_edge_of_hole_edges.push(vertex); + next_vertices_map.set(vertex, centroid(mid_edge_of_hole_edges)); + } else { + const face_count = faces_for_vertex.length; + const multiple_1 = (face_count - 3) / face_count; + const multiple_2 = 1.0 / face_count; + const multiple_3 = 2.0 / face_count; + + const next_vertex_1 = vertex.multiply(multiple_1); + const face_points = faces_for_vertex.map(face => face.face_point); + const next_vertex_2 = centroid(face_points).multiply(multiple_2); + const mid_edges = edges_for_vertex.map(edge => edge.mid_edge); + const next_vertex_3 = centroid(mid_edges).multiply(multiple_3); + const next_vertex_4 = next_vertex_1.add(next_vertex_2); + + next_vertices_map.set(vertex, next_vertex_4.add(next_vertex_3)); + } + } + + return next_vertices_map; +} + +// The Catmull-Clarke surface subdivision algorithm. +function catmull_clark_surface_subdivision(faces) { + // Determine, for each edge, whether or not it is an edge of a hole, + // and set its edge point accordingly. + for (const face of faces) { + for (const edge of face.edges) { + const face_points_for_edge = []; + for (const search_face of faces) { + if (search_face.contains(edge)) { + face_points_for_edge.push(search_face.face_point); + } + } + + if (face_points_for_edge.length === 2) { + edge.hole_edge = false; + edge.edge_point = centroid([edge.mid_edge, centroid(face_points_for_edge)]); + } else { + edge.hole_edge = true; + edge.edge_point = edge.mid_edge; + } + } + } + + // Collect all edges + const edges = []; + for (const face of faces) { + for (const edge of face.edges) { + edges.push(edge); + } + } + + const next_vertex_map = next_vertices(edges, faces); + const next_faces = []; + + for (const face of faces) { + if (face.vertices.length >= 3) { // A face with 2 or fewer points does not contribute to the surface + const face_point = face.face_point; + for (let i = 0; i < face.vertices.length; ++i) { + const prevIndex = (i - 1 + face.vertices.length) % face.vertices.length; + next_faces.push(new Face([ + next_vertex_map.get(face.vertices[i]), + face.edges[i].edge_point, + face_point, + face.edges[prevIndex].edge_point + ])); + } + } + } + + return next_faces; +} + +// Display the current Catmull-Clark surface on the console. +function displaySurface(faces) { + console.log("Surface {"); + for (const face of faces) { + console.log(face.toString()); + } + console.log("}"); + console.log(); +} + +// Main function +function main() { + const faces = [ + new Face([ + new Point(-1.0, 1.0, 1.0), new Point(-1.0, -1.0, 1.0), + new Point(1.0, -1.0, 1.0), new Point(1.0, 1.0, 1.0) + ]), + new Face([ + new Point(1.0, 1.0, 1.0), new Point(1.0, -1.0, 1.0), + new Point(1.0, -1.0, -1.0), new Point(1.0, 1.0, -1.0) + ]), + new Face([ + new Point(1.0, 1.0, -1.0), new Point(1.0, -1.0, -1.0), + new Point(-1.0, -1.0, -1.0), new Point(-1.0, 1.0, -1.0) + ]), + new Face([ + new Point(-1.0, 1.0, -1.0), new Point(-1.0, 1.0, 1.0), + new Point(1.0, 1.0, 1.0), new Point(1.0, 1.0, -1.0) + ]), + new Face([ + new Point(-1.0, 1.0, -1.0), new Point(-1.0, -1.0, -1.0), + new Point(-1.0, -1.0, 1.0), new Point(-1.0, 1.0, 1.0) + ]), + new Face([ + new Point(-1.0, -1.0, -1.0), new Point(-1.0, -1.0, 1.0), + new Point(1.0, -1.0, 1.0), new Point(1.0, -1.0, -1.0) + ]) + ]; + + displaySurface(faces); + const iterations = 1; + let result = faces; + for (let i = 0; i < iterations; ++i) { + result = catmull_clark_surface_subdivision(result); + } + displaySurface(result); +} + +// Run the main function +main(); diff --git a/Task/Chaocipher/Swift/chaocipher.swift b/Task/Chaocipher/Swift/chaocipher.swift new file mode 100644 index 0000000000..ae0cc62b27 --- /dev/null +++ b/Task/Chaocipher/Swift/chaocipher.swift @@ -0,0 +1,84 @@ +enum Mode { + case encrypt + case decrypt +} + +class Chaocipher { + private static let L_ALPHABET = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" + private static let R_ALPHABET = "PTLNBQDEOYSFAVZKGJRIHWXUMC" + + private static func indexOf(array: [Character], char: Character) -> Int { + for i in 0.. String { + var left = Array(L_ALPHABET) + var right = Array(R_ALPHABET) + var eText = [Character](repeating: " ", count: text.count) + var temp = [Character](repeating: " ", count: 26) + + let textChars = Array(text) + + for i in 0.. String { + return exec(text: text, mode: .encrypt, showSteps: showSteps) + } + + static func decrypt(text: String, showSteps: Bool = false) -> String { + return exec(text: text, mode: .decrypt, showSteps: showSteps) + } +} + +// Main program +let plainText = "WELLDONEISBETTERTHANWELLSAID" +print("The original plaintext is : \(plainText)") +print("\nThe left and right alphabets after each permutation during encryption are:") +let cipherText = Chaocipher.encrypt(text: plainText, showSteps: true) +print("\nThe cipher text is : \(cipherText)") +let plainText2 = Chaocipher.decrypt(text: cipherText) +print("\nThe recovered plaintext is : \(plainText2)") diff --git a/Task/Character-codes/Elena/character-codes.elena b/Task/Character-codes/Elena/character-codes.elena index 6dbbbee50c..406defaafb 100644 --- a/Task/Character-codes/Elena/character-codes.elena +++ b/Task/Character-codes/Elena/character-codes.elena @@ -4,6 +4,6 @@ public program() { var ch := $97; - console.printLine(ch); - console.printLine(ch.toInt()) + Console.printLine(ch); + Console.printLine(ch.toInt()) } diff --git a/Task/Character-codes/Haxe/character-codes.haxe b/Task/Character-codes/Haxe/character-codes.haxe new file mode 100644 index 0000000000..3d1788b91d --- /dev/null +++ b/Task/Character-codes/Haxe/character-codes.haxe @@ -0,0 +1,7 @@ +class Main { + static public function main():Void { + trace("a".code); + trace("∅".code); + trace("🍆".code); + } +} diff --git a/Task/Character-codes/TAV/character-codes.tav b/Task/Character-codes/TAV/character-codes.tav new file mode 100644 index 0000000000..727bf15da6 --- /dev/null +++ b/Task/Character-codes/TAV/character-codes.tav @@ -0,0 +1,2 @@ + print string 'a' code point at 1 \ print 'a'.Codepoint + print integer 97 code point as string \ print 97.Character diff --git a/Task/Check-that-file-exists/ArkScript/check-that-file-exists.ark b/Task/Check-that-file-exists/ArkScript/check-that-file-exists.ark new file mode 100644 index 0000000000..8539bbafb5 --- /dev/null +++ b/Task/Check-that-file-exists/ArkScript/check-that-file-exists.ark @@ -0,0 +1,4 @@ +(print (io:fileExists? "input.txt")) +(print (io:fileExists? "/input.txt")) +(print (io:fileExists? "docs")) +(print (io:fileExists? "/docs")) diff --git a/Task/Check-that-file-exists/DuckDB/check-that-file-exists.duckdb b/Task/Check-that-file-exists/DuckDB/check-that-file-exists.duckdb new file mode 100644 index 0000000000..0e8902d3b1 --- /dev/null +++ b/Task/Check-that-file-exists/DuckDB/check-that-file-exists.duckdb @@ -0,0 +1,2 @@ +create or replace function file_exists(fn) as ( + 1 = (select count(file) from glob(fn)) ); diff --git a/Task/Check-that-file-exists/Elena/check-that-file-exists.elena b/Task/Check-that-file-exists/Elena/check-that-file-exists.elena index 2e7f05f379..35caac60bf 100644 --- a/Task/Check-that-file-exists/Elena/check-that-file-exists.elena +++ b/Task/Check-that-file-exists/Elena/check-that-file-exists.elena @@ -9,11 +9,11 @@ extension op public program() { - console.printLine("input.txt file ",File.assign("input.txt").validatePath()); + Console.printLine("input.txt file ",File.assign("input.txt").validatePath()); - console.printLine("\input.txt file ",File.assign("\input.txt").validatePath()); + Console.printLine("\input.txt file ",File.assign("\input.txt").validatePath()); - console.printLine("docs directory ",Directory.assign("docs").validatePath()); + Console.printLine("docs directory ",Directory.assign("docs").validatePath()); - console.printLine("\docs directory ",Directory.assign("\docs").validatePath()) + Console.printLine("\docs directory ",Directory.assign("\docs").validatePath()) } diff --git a/Task/Checkpoint-synchronization/JavaScript/checkpoint-synchronization.js b/Task/Checkpoint-synchronization/JavaScript/checkpoint-synchronization.js new file mode 100644 index 0000000000..da445826e3 --- /dev/null +++ b/Task/Checkpoint-synchronization/JavaScript/checkpoint-synchronization.js @@ -0,0 +1,47 @@ +class Latch { + constructor(limit) { + this.semafor = limit; + this.lock = new Promise(resolve => { + this.resolve = resolve; + }); + } + + wait() { + this.semafor--; + if (this.semafor === 0) { + this.resolve(); + } + return this.lock; + } +} + +class Worker { + static async doWork(howLong, barrier, name) { + await new Promise(resolve => setTimeout(resolve, howLong)); + console.log(`Worker ${name} finished work`); + await barrier.wait(); + console.log(`Worker ${name} finished assembly`); + } +} + +async function main() { + const latch = new Latch(5); + + // Random number generator function + const getRandomInt = (min, max) => { + return Math.floor(Math.random() * (max - min + 1)) + min; + }; + + const promises = [ + Worker.doWork(getRandomInt(300, 3000), latch, "John"), + Worker.doWork(getRandomInt(300, 3000), latch, "Henry"), + Worker.doWork(getRandomInt(300, 3000), latch, "Smith"), + Worker.doWork(getRandomInt(300, 3000), latch, "Jane"), + Worker.doWork(getRandomInt(300, 3000), latch, "Mary") + ]; + + await Promise.all(promises); + console.log("Assembly is finished"); +} + +main(); diff --git a/Task/Chinese-zodiac/Fortran/chinese-zodiac.f b/Task/Chinese-zodiac/Fortran/chinese-zodiac.f new file mode 100644 index 0000000000..8b06c9ce9c --- /dev/null +++ b/Task/Chinese-zodiac/Fortran/chinese-zodiac.f @@ -0,0 +1,62 @@ +program chinese_zodiac + implicit none + + ! Define arrays for animals and elements + character(len=10), dimension(12) :: animals = [character(len=10) :: & + "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", & + "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"] + character(len=10), dimension(5) :: elements = [character(len=10) :: & + "Wood", "Fire", "Earth", "Metal", "Water"] + + ! Define test years + integer, parameter :: numyears=9 + integer, dimension(numyears) :: years = [1935, 1938, 1957, 1968, 1972, 1976, 2006, 2017, 2025] + integer :: i, year + write(*,'(/)') + + ! Loop through years and print zodiac information + do i = 1, numyears + year = years(i) + write(*, '(I4, A)') year, " is the year of the " // & + trim(get_element(year)) // " " // & + trim(get_animal(year)) // " (" // & + trim(get_yy(year)) // ")." + end do + write(*,'(/)') +contains + + ! Function to get the element based on year + function get_element(year) result(element) + integer, intent(in) :: year + character(len=10) :: element + integer :: idx +! idx = floor(real((year - 4) / 2) / 5.0) + 1 + idx = floor(real(modulo(year - 4, 10)) / 2.0) + 1 + if (idx < 1) idx = 1 + if (idx > 5) idx = 5 + element = elements(idx) + end function get_element + + ! Function to get the animal based on year + function get_animal(year) result(animal) + integer, intent(in) :: year + character(len=10) :: animal + integer :: idx + idx = modulo(year - 4, 12) + 1 + if (idx < 1) idx = 1 + if (idx > 12) idx = 12 + animal = animals(idx) + end function get_animal + + ! Function to get yin/yang based on year + function get_yy(year) result(yy) + integer, intent(in) :: year + character(len=4) :: yy + if (modulo(year, 2) == 0) then + yy = "yang" + else + yy = "yin" + end if + end function get_yy + +end program chinese_zodiac diff --git a/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy b/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy new file mode 100644 index 0000000000..f06a3216a5 --- /dev/null +++ b/Task/Cholesky-decomposition/EasyLang/cholesky-decomposition.easy @@ -0,0 +1,19 @@ +func[][] cholesky a[][] . + n = len a[][] + len r[][] n + for i to n + len r[i][] n + for j to i + s = 0 + for k to j : s += r[i][k] * r[j][k] + if i = j + r[i][j] = sqrt (a[i][i] - s) + else + r[i][j] = 1 / r[j][j] * (a[i][j] - s) + . + . + . + return r[][] +. +print cholesky [ [ 25 15 -5 ] [ 15 18 0 ] [ -5 0 11 ] ] +print cholesky [ [ 18 22 54 42 ] [ 22 70 86 62 ] [ 54 86 174 134 ] [ 42 62 134 106 ] ] diff --git a/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig b/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig new file mode 100644 index 0000000000..39a4ebad30 --- /dev/null +++ b/Task/Cholesky-decomposition/Zig/cholesky-decomposition.zig @@ -0,0 +1,64 @@ +const std = @import("std"); + +fn cholesky(mat: []const f64, n: usize, allocator: std.mem.Allocator) ![]f64 { + const res = try allocator.alloc(f64, mat.len); + @memset(res, 0.0); + + for (0..n) |i| { + for (0..i+1) |j| { + var s: f64 = 0.0; + for (0..j) |k| { + s += res[i * n + k] * res[j * n + k]; + } + + res[i * n + j] = if (i == j) + std.math.sqrt(mat[i * n + i] - s) + else + (1.0 / res[j * n + j] * (mat[i * n + j] - s)); + } + } + return res; +} + +fn showMatrix(matrix: []const f64, n: usize) void { + for (0..n) |i| { + for (0..n) |j| { + std.debug.print("{d:.4}\t", .{matrix[i * n + j]}); + } + std.debug.print("\n", .{}); + } + std.debug.print("\n", .{}); +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + defer _ = gpa.deinit(); + + { + const dimension: usize = 3; + const m1 = [_]f64{ + 25.0, 15.0, -5.0, + 15.0, 18.0, 0.0, + -5.0, 0.0, 11.0 + }; + + const res1 = try cholesky(&m1, dimension, allocator); + defer allocator.free(res1); + showMatrix(res1, dimension); + } + + { + const dimension: usize = 4; + const m2 = [_]f64{ + 18.0, 22.0, 54.0, 42.0, + 22.0, 70.0, 86.0, 62.0, + 54.0, 86.0, 174.0, 134.0, + 42.0, 62.0, 134.0, 106.0 + }; + + const res2 = try cholesky(&m2, dimension, allocator); + defer allocator.free(res2); + showMatrix(res2, dimension); + } +} diff --git a/Task/Chowla-numbers/REXX/chowla-numbers.rexx b/Task/Chowla-numbers/REXX/chowla-numbers.rexx index 32d54ed564..5e9fe0aa6e 100644 --- a/Task/Chowla-numbers/REXX/chowla-numbers.rexx +++ b/Task/Chowla-numbers/REXX/chowla-numbers.rexx @@ -1,17 +1,17 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings +numeric digits 12 say 'CHOWLA NUMBERS' say version say -numeric digits 12 call ChowlaNumbers call PrimeCount call PerfectNumbers exit ChowlaNumbers: -procedure expose glob. +procedure expose Memo. call Time('r'); sep = Copies('-',12) say sep; say ' n Chowla(n)'; say sep m = 37 @@ -24,7 +24,7 @@ say return PrimeCount: -procedure expose glob. work. +procedure expose Memo. work. call Time('r'); sep = Copies('-',17) say sep; say Right('n',8) Right('Primes= 0 && r < Size && c >= 0 && c < Size) // Check bounds + _cells[r, c] = '*'; + } + } + + public void Show() + { + for (int i = 0; i < Size; i++) + { + for (int j = 0; j < Size; j++) + Console.Write(_cells[i, j]); + Console.WriteLine(); + } + } +} + +public static class Numerals +{ + // Draws the Cistercian numeral 'number' on the 'canvas'. + public static void DrawNumber(Canvas canvas, uint number) + { + int rAxis = (canvas.Size - 1) / 2; // Horizontal axis position + int cAxis = 5; // Vertical axis position + + // Draw vertical axis + canvas.DrawLine(0, cAxis, canvas.Size - 1, 1, 0); + + byte thousands = (byte)(number / 1000); + number %= 1000; + byte hundreds = (byte)(number / 100); + number %= 100; + byte tens = (byte)(number / 10); + byte ones = (byte)(number % 10); + + // Draw digits in their respective quadrants + if (thousands > 0) + DrawDigit(canvas, thousands, rAxis, cAxis, 1, -1); // Top left + if (hundreds > 0) + DrawDigit(canvas, hundreds, rAxis, cAxis, 1, 1); // Top right + if (tens > 0) + DrawDigit(canvas, tens, rAxis, cAxis, -1, -1); // Bottom left + if (ones > 0) + DrawDigit(canvas, ones, rAxis, cAxis, -1, 1); // Bottom right + } + + + // Draws the digit 'v' in the appropriate quadrant, determined by 'rs' and 'cs'. + // rs, cs are signs (1 or -1) for rows and columns relative to the axes. + private static void DrawDigit(Canvas canvas, byte digit, int rAxis, int cAxis, int rs, int cs) + { + switch (digit) + { + case 1: + canvas.DrawLine(rAxis + rs * 7, cAxis + cs, 4, 0, cs); + break; + case 2: + canvas.DrawLine(rAxis + rs * 3, cAxis + cs, 4, 0, cs); + break; + case 3: + canvas.DrawLine(rAxis + rs * 7, cAxis + cs, 4, -rs, cs); + break; + case 4: + canvas.DrawLine(rAxis + rs * 3, cAxis + cs, 4, rs, cs); + break; + case 5: + DrawDigit(canvas, 1, rAxis, cAxis, rs, cs); + DrawDigit(canvas, 4, rAxis, cAxis, rs, cs); + break; + case 6: + canvas.DrawLine(rAxis + rs * 3, cAxis + cs * 5, 4, rs, 0); + break; + case 7: + DrawDigit(canvas, 1, rAxis, cAxis, rs, cs); + DrawDigit(canvas, 6, rAxis, cAxis, rs, cs); + break; + case 8: + DrawDigit(canvas, 2, rAxis, cAxis, rs, cs); + DrawDigit(canvas, 6, rAxis, cAxis, rs, cs); + break; + case 9: + DrawDigit(canvas, 1, rAxis, cAxis, rs, cs); + DrawDigit(canvas, 8, rAxis, cAxis, rs, cs); + break; + } + } +} + +class Program +{ + public static void Test(uint n) + { + Console.WriteLine("{0}:", n); + Canvas canvas = new Canvas(15); + Numerals.DrawNumber(canvas, n); + canvas.Show(); + Console.WriteLine(); + } + + public static void Main() + { + Test(0); + Test(1); + Test(20); + Test(300); + Test(4000); + Test(5555); + Test(6789); + Test(9999); + } +} diff --git a/Task/Cistercian-numerals/Free-Pascal-Lazarus/cistercian-numerals.pas b/Task/Cistercian-numerals/Free-Pascal-Lazarus/cistercian-numerals.pas new file mode 100644 index 0000000000..767f3d587f --- /dev/null +++ b/Task/Cistercian-numerals/Free-Pascal-Lazarus/cistercian-numerals.pas @@ -0,0 +1,151 @@ +program CistercianNumerals; + +type + TSignVals = -1 .. 1; + + TCanvas = object + public + procedure Init(GridSize: integer); + procedure Clear; + procedure DrawLine(R0, C0, Dist: integer; DR, DC: TSignVals); + procedure Show; + function Size: integer; + private + Cells: array of array of char; + MaxCoord: integer; + end; + + procedure TCanvas.Init(GridSize: integer); + begin + SetLength(Cells, GridSize, GridSize); + MaxCoord := GridSize - 1; + end; + + procedure TCanvas.Clear; + var + I, J: integer; + begin + for I := 0 to MaxCoord do + for J := 0 to MaxCoord do + Cells[I, J] := ' '; + end; + + procedure TCanvas.DrawLine(R0, C0, Dist: integer; DR, DC: TSignVals); + { Draws a straight (vertical, horizontal, or diagonal) line + from Cells[R0, C0] to Cells[R0 + DR * Dist, C0 + DC * Dist]. } + var + C, R, I: integer; + begin + R := R0; + C := C0; + for I := 0 to Dist do + begin + Cells[R, C] := '*'; + R := R + DR; + C := C + DC; + end; + end; + + procedure TCanvas.Show; + var + I, J: integer; + begin + for I := 0 to MaxCoord do + begin + for J := 0 to MaxCoord do + Write(Cells[I, J]); + WriteLn; + end; + end; + + function TCanvas.Size: integer; + begin + Result := MaxCoord + 1; + end; + + procedure DrawNumber(var Canvas: TCanvas; V: integer); + { DrawDigit is part of the algorithm, so it is nested in DrawNumber. } + type + TDigits = 0 .. 9; + var + Thousands, Hundreds, Tens, Ones: integer; + RAxis, CAxis: integer; + + procedure DrawDigit(V: TDigits; RS, CS: TSignVals); + { RS, CS are signs of rows and cols in in relation to the axis. + They decide in which quadrant a digit is located. } + begin + case V of + 1: Canvas.DrawLine(RAxis + RS * 7, CAxis + CS, 4, 0, CS); + 2: Canvas.DrawLine(RAxis + RS * 3, CAxis + CS, 4, 0, CS); + 3: Canvas.DrawLine(RAxis + RS * 7, CAxis + CS, + 4, -RS, CS); + 4: Canvas.DrawLine(RAxis + RS * 3, CAxis + CS, 4, RS, CS); + 5: + begin + DrawDigit(1, RS, CS); + DrawDigit(4, RS, CS); + end; + 6: Canvas.DrawLine(RAxis + RS * 3, CAxis + CS * 5, 4, RS, 0); + 7: + begin + DrawDigit(1, RS, CS); + DrawDigit(6, RS, CS); + end; + 8: + begin + DrawDigit(2, RS, CS); + DrawDigit(6, RS, CS); + end; + 9: + begin + DrawDigit(1, RS, CS); + DrawDigit(8, RS, CS); + end + end; + end; {DrawDigit} + + begin {DrawNumber} + RAxis := (Canvas.Size - 1) div 2; + CAxis := 5; + Canvas.DrawLine(0, CAxis, Canvas.Size - 1, 1, 0); + {Draw 0 (or vertical axis)} + Thousands := V div 1000; + V := V mod 1000; + Hundreds := V div 100; + V := V mod 100; + Tens := V div 10; + Ones := V mod 10; + if Thousands > 0 then + DrawDigit(Thousands, 1, -1); + if Hundreds > 0 then + DrawDigit(Hundreds, 1, 1); + if Tens > 0 then + DrawDigit(Tens, -1, -1); + if Ones > 0 then + DrawDigit(Ones, -1, 1); + end; {DrawNumber} + + procedure Test(N: integer); + var + Canvas: TCanvas; + begin + WriteLn(N, ':'); + Canvas.Init(15); + Canvas.Clear; + DrawNumber(Canvas, N); + Canvas.Show; + WriteLn; + end; + +begin + Test(0); + Test(1); + Test(20); + Test(300); + Test(4000); + Test(5555); + Test(6789); + Test(9999); + // ReadLn; +end. diff --git a/Task/Cistercian-numerals/Modula-2/cistercian-numerals.mod2 b/Task/Cistercian-numerals/Modula-2/cistercian-numerals.mod2 new file mode 100644 index 0000000000..0e4ec4c24f --- /dev/null +++ b/Task/Cistercian-numerals/Modula-2/cistercian-numerals.mod2 @@ -0,0 +1,132 @@ +MODULE CistercianNumerals; +FROM STextIO IMPORT + WriteLn, WriteString; +FROM SWholeIO IMPORT + WriteInt; + +CONST + MaxCoord = 14; + +TYPE + TCanvas = ARRAY [0 .. MaxCoord], [0 .. MaxCoord] OF CHAR; + TSignVals = [-1 .. 1]; + +(* BEGIN. Operations on the TCanvas ADT. *) +PROCEDURE ClearCanvas(VAR Canvas: TCanvas); +VAR + I, J: CARDINAL; +BEGIN + FOR I := 0 TO MaxCoord DO + FOR J := 0 TO MaxCoord DO + Canvas[I, J] := ' ' + END + END +END ClearCanvas; + +PROCEDURE DrawLine(VAR Canvas: TCanvas; R0, C0: CARDINAL; + Dist: CARDINAL; DR, DC: TSignVals); +(* Draws a straight (vertical, horizontal, or diagonal) line + from Canvas[R0, C0] to Canvas[R0 + DR * Dist, C0 + DC * Dist]. *) +VAR + C, R, I: CARDINAL; +BEGIN + R := R0; C := C0; + FOR I := 0 TO Dist DO + Canvas[R, C] := '*'; + R := INT(R) + DR; C := INT(C) + DC; + END +END DrawLine; + +PROCEDURE ShowCanvas(VAR Canvas: TCanvas); +VAR + I, J: CARDINAL; + Row: ARRAY [0 .. MaxCoord + 1] OF CHAR; +BEGIN + FOR I := 0 TO MaxCoord DO + FOR J := 0 TO MaxCoord DO + Row[J] := Canvas[I, J] + END; + Row[MaxCoord + 1] := CHR(0); + WriteString(Row); + WriteLn + END +END ShowCanvas; +(* END Operations on the TCanvas ADT. *) + +PROCEDURE DrawNumber(VAR Canvas: TCanvas; V: CARDINAL); +(* DrawDigit is part of the algorithm, so it is nested in DrawNumber. *) +TYPE + TDigits = [0 .. 9]; +VAR + Thousands, Hundreds, Tens, Ones: CARDINAL; + RAxis, CAxis: CARDINAL; + + PROCEDURE DrawDigit(V: TDigits; RS, CS: TSignVals); + (* RS, CS are signs of rows and cols in in relation to the axis. + They decide in which quadrant a digit is located. *) + VAR + IRS, ICS: CARDINAL; + BEGIN + IRS := INT(RS); + ICS := INT(CS); + CASE V OF + | 1: DrawLine(Canvas, RAxis + IRS * 7, CAxis + ICS, 4, 0, CS) + | 2: DrawLine(Canvas, RAxis + IRS * 3, CAxis + ICS, 4, 0, CS) + | 3: DrawLine(Canvas, RAxis + IRS * 7, CAxis + ICS, 4, -RS, CS) + | 4: DrawLine(Canvas, RAxis + IRS * 3, CAxis + ICS, 4, RS, CS) + | 5: DrawDigit(1, RS, CS); DrawDigit(4, RS, CS) + | 6: DrawLine(Canvas, RAxis + IRS * 3, CAxis + ICS * 5, 4, RS, 0) + | 7: DrawDigit(1, RS, CS); DrawDigit(6, RS, CS) + | 8: DrawDigit(2, RS, CS); DrawDigit(6, RS, CS) + | 9: DrawDigit(1, RS, CS); DrawDigit(8, RS, CS) + ELSE + END; + END DrawDigit; + +BEGIN (*DrawNumber *) + RAxis := MaxCoord DIV 2; + CAxis := 5; + DrawLine(Canvas, 0, CAxis, MaxCoord, 1, 0); (* Draw 0 (or vertical axis) *) + Thousands := V DIV 1000; + V := V MOD 1000; + Hundreds := V DIV 100; + V := V MOD 100; + Tens := V DIV 10; + Ones := V MOD 10; + IF Thousands > 0 THEN + DrawDigit(Thousands, 1, -1) + END; + IF Hundreds > 0 THEN + DrawDigit(Hundreds, 1, 1) + END; + IF Tens > 0 THEN + DrawDigit(Tens, -1, -1) + END; + IF Ones > 0 THEN + DrawDigit(Ones, -1, 1) + END; +END DrawNumber; + +PROCEDURE Test(N: CARDINAL); +VAR + Canvas: TCanvas; +BEGIN + WriteInt(N, 1); + WriteString(':'); + WriteLn; + ClearCanvas(Canvas); + DrawNumber(Canvas, N); + ShowCanvas(Canvas); + WriteLn; +END Test; + +BEGIN + Test(0); + Test(1); + Test(20); + Test(300); + Test(4000); + Test(5555); + Test(6789); + Test(9999); +END CistercianNumerals. diff --git a/Task/Cistercian-numerals/Pascal-P/cistercian-numerals.pas b/Task/Cistercian-numerals/Pascal-P/cistercian-numerals.pas new file mode 100644 index 0000000000..9a846b5298 --- /dev/null +++ b/Task/Cistercian-numerals/Pascal-P/cistercian-numerals.pas @@ -0,0 +1,131 @@ +program cistnums; +(* Cistercian numerals *) +const + maxcoord = 14; + +type + tcanvas = array [0 .. maxcoord, 0 .. maxcoord] of char; + tsignvals = -1 .. 1; + + (* BEGIN. Operations on the tcanvas ADT. *) + procedure clearcanvas(var canvas: tcanvas); + var + i, j: integer; + begin + for i := 0 to maxcoord do + for j := 0 to maxcoord do + canvas[i, j] := ' '; + end; (* clearcanvas *) + + procedure drawline(var canvas: tcanvas; r0, c0: integer; + dist: integer; dr, dc: tsignvals); + (* Draws a straight (vertical, horizontal, or diagonal) line + from canvas[r0, c0] to canvas[r0 + dr * dist, c0 + dc * dist]. *) + var + c, r, i: integer; + begin + r := r0; + c := c0; + for i := 0 to dist do + begin + canvas[r, c] := '*'; + r := r + dr; + c := c + dc; + end; + end; (* drawline *) + + procedure showcanvas(var canvas: tcanvas); + var + i, j: integer; + begin + for i := 0 to maxcoord do + begin + for j := 0 to maxcoord do + write(canvas[i, j]); + writeln; + end; + end; (* showcanvas *) + (* END Operations on the tcanvas ADT. *) + + procedure drawnumber(var canvas: tcanvas; v: integer); + (* drawdigit is part of the algorithm, so it is nested in drawnumber. *) + type + tdigits = 0 .. 9; + var + thousands, hundreds, tens, ones: integer; + raxis, caxis: integer; + + procedure drawdigit(v: tdigits; rs, cs: tsignvals); + (* rs, cs are signs of rows and cols in in relation to the axis. + They decide in which quadrant a digit is located. *) + begin + case v of + 1: drawline(canvas, raxis + rs * 7, caxis + cs, 4, 0, cs); + 2: drawline(canvas, raxis + rs * 3, caxis + cs, 4, 0, cs); + 3: drawline(canvas, raxis + rs * 7, caxis + cs, 4, -rs, cs); + 4: drawline(canvas, raxis + rs * 3, caxis + cs, 4, rs, cs); + 5: + begin + drawdigit(1, rs, cs); + drawdigit(4, rs, cs); + end; + 6: drawline(canvas, raxis + rs * 3, caxis + cs * 5, 4, rs, 0); + 7: + begin + drawdigit(1, rs, cs); + drawdigit(6, rs, cs); + end; + 8: + begin + drawdigit(2, rs, cs); + drawdigit(6, rs, cs); + end; + 9: + begin + drawdigit(1, rs, cs); + drawdigit(8, rs, cs); + end; + end; + end; (* drawdigit *) + + begin (* drawnumber *) + raxis := maxcoord div 2; + caxis := 5; + drawline(canvas, 0, caxis, maxcoord, 1, 0); (* Draw 0 (or vertical axis) *) + thousands := v div 1000; + v := v mod 1000; + hundreds := v div 100; + v := v mod 100; + tens := v div 10; + ones := v mod 10; + if thousands > 0 then + drawdigit(thousands, 1, -1); + if hundreds > 0 then + drawdigit(hundreds, 1, 1); + if tens > 0 then + drawdigit(tens, -1, -1); + if ones > 0 then + drawdigit(ones, -1, 1); + end; (* drawnumber *) + + procedure test(n: integer); + var + canvas: tcanvas; + begin + writeln(n, ':'); + clearcanvas(canvas); + drawnumber(canvas, n); + showcanvas(canvas); + writeln; + end; + +begin + test(0); + test(1); + test(20); + test(300); + test(4000); + test(5555); + test(6789); + test(9999) +end. diff --git a/Task/Cistercian-numerals/XPL0/cistercian-numerals.xpl0 b/Task/Cistercian-numerals/XPL0/cistercian-numerals.xpl0 new file mode 100644 index 0000000000..76aebc2c36 --- /dev/null +++ b/Task/Cistercian-numerals/XPL0/cistercian-numerals.xpl0 @@ -0,0 +1,104 @@ +\ Cistercian numerals +code Rem=2, ChOut=8, CrLf=9, IntOut=11, Text=12; + +define CanvasSize = 15; + +\ BEGIN. Operations on the canvas (considered as an ADT). +procedure ClearCanvas(Canvas); +integer Canvas; +integer I, J; +begin +for I:= 0 to CanvasSize - 1 do + for J:= 0 to CanvasSize - 1 do Canvas(I, J):= ^ ; +end; \ClearCanvas + +procedure DrawLine(Canvas, R0, C0, Dist, DR, DC); +\ Draws a straight (vertical, horizontal, or diagonal) line +\ from Canvas(R0, C0) to Canvas(R0 + DR * Dist, C0 + DC * Dist) +integer Canvas, R0, C0, Dist, DR, DC; +integer C, R, I; +begin +if (DR # -1) and (DR # 0) and (DR # 1) then exit; +if (DC # -1) and (DC # 0) and (DC # 1) then exit; +R:= R0; C:= C0; +for I:= 0 to Dist do + begin + Canvas(R, C):= ^*; + R:= R + DR; C:= C + DC; + end +end; \DrawLine + +procedure ShowCanvas(Canvas); +integer Canvas; +integer I, J; +begin +for I:= 0 to CanvasSize - 1 do + begin + for J:= 0 to CanvasSize - 1 do ChOut(0, Canvas(I, J)); + CrLf(0); + end; +end; \ShowCanvas +\ END Operations on the canvas. + +procedure DrawNumber(Canvas, V); +integer Canvas, V; +integer Thousands, Hundreds, Tens, Ones, RAxis, CAxis; +\ DrawDigit is part of the algorithm, so it is nested in DrawNumber. + + procedure DrawDigit(V, RS, CS); + integer V, RS, CS; + \ RS, CS are signs of rows and cols in in relation to the axis. + \ They decide in which quadrant a digit is located. + begin + if (RS # -1) and (RS # 1) then exit; + if (CS # -1) and (CS # 1) then exit; + case V of + 1: DrawLine(Canvas, RAxis + RS * 7, CAxis + CS, 4, 0, CS); + 2: DrawLine(Canvas, RAxis + RS * 3, CAxis + CS, 4, 0, CS); + 3: DrawLine(Canvas, RAxis + RS * 7, CAxis + CS, 4, -RS, CS); + 4: DrawLine(Canvas, RAxis + RS * 3, CAxis + CS, 4, RS, CS); + 5: [DrawDigit(1, RS, CS); DrawDigit(4, RS, CS)]; + 6: DrawLine(Canvas, RAxis + RS * 3, CAxis + CS * 5, 4, RS, 0); + 7: [DrawDigit(1, RS, CS); DrawDigit(6, RS, CS)]; + 8: [DrawDigit(2, RS, CS); DrawDigit(6, RS, CS)]; + 9: [DrawDigit(1, RS, CS); DrawDigit(8, RS, CS)] + other []; + end; \DrawDigit; + +begin \DrawNumber +RAxis := (CanvasSize - 1) / 2; +CAxis := 5; +DrawLine(Canvas, 0, CAxis, CanvasSize - 1, 1, 0); \Draw 0 (or vertical axis) +Thousands:= V / 1000; +V:= Rem(V / 1000); +Hundreds:= V / 100; +V:= Rem(V / 100); +Tens:= V / 10; +Ones:= Rem(V / 10); +if Thousands > 0 then DrawDigit(Thousands, 1, -1); +if Hundreds > 0 then DrawDigit(Hundreds, 1, 1); +if Tens > 0 then DrawDigit(Tens, -1, -1); +if Ones > 0 then DrawDigit(Ones, -1, 1); +end; \DrawNumber + +procedure Test(N); +integer N; +integer Canvas(CanvasSize, CanvasSize); +begin +IntOut(0, N); ChOut(0, ^:); CrLf(0); +ClearCanvas(Canvas); +DrawNumber(Canvas, N); +ShowCanvas(Canvas); +CrLf(0); +end; + +begin +Test(0); +Test(1); +Test(20); +Test(300); +Test(4000); +Test(5555); +Test(6789); +Test(9999); +end diff --git a/Task/Classes/Elena/classes.elena b/Task/Classes/Elena/classes.elena index 4faedc117f..c55ff04498 100644 --- a/Task/Classes/Elena/classes.elena +++ b/Task/Classes/Elena/classes.elena @@ -23,5 +23,5 @@ public program() instance.someMethod(); // get the variable - console.printLine("Variable=",instance.Variable) + Console.printLine("Variable=",instance.Variable) } diff --git a/Task/Classes/Haxe/classes-1.haxe b/Task/Classes/Haxe/classes-1.haxe new file mode 100644 index 0000000000..37ec6fbcdf --- /dev/null +++ b/Task/Classes/Haxe/classes-1.haxe @@ -0,0 +1,14 @@ +class BasicClass { + public function basicMethod():Void { + return; + } + + public function new() {} +} + +class Main { + static public function main():Void { + var basic_object = new BasicClass(); + $type(basic_object); + } +} diff --git a/Task/Classes/Haskell/classes-3.hs b/Task/Classes/Haxe/classes-2.haxe similarity index 100% rename from Task/Classes/Haskell/classes-3.hs rename to Task/Classes/Haxe/classes-2.haxe diff --git a/Task/Closures-Value-capture/ArkScript/closures-value-capture.ark b/Task/Closures-Value-capture/ArkScript/closures-value-capture.ark new file mode 100644 index 0000000000..b14646e92e --- /dev/null +++ b/Task/Closures-Value-capture/ArkScript/closures-value-capture.ark @@ -0,0 +1,13 @@ +(mut funcs []) + +(mut i 0) +(while (< i 10) { + (let ii i) + (append! funcs (fun (&ii) (* ii ii))) + (set i (+ i 1)) }) + +(set i 0) +# display the result of all but the last +(while (< i 9) { + (assert (= ((@ funcs i)) (* i i)) "(@ funcs i) returns (* i i)") + (set i (+ 1 i)) }) diff --git a/Task/Closures-Value-capture/Elena/closures-value-capture.elena b/Task/Closures-Value-capture/Elena/closures-value-capture.elena index b943a12d2c..db252942a9 100644 --- a/Task/Closures-Value-capture/Elena/closures-value-capture.elena +++ b/Task/Closures-Value-capture/Elena/closures-value-capture.elena @@ -5,5 +5,5 @@ public program() { var functions := Array.allocate(10).populate::(int i => { ^ i * i} ); - functions.forEach::(func) { console.printLine(func()) } + functions.forEach::(func) { Console.printLine(func()) } } diff --git a/Task/Collections/DuckDB/collections.duckdb b/Task/Collections/DuckDB/collections.duckdb new file mode 100644 index 0000000000..edc60fa133 --- /dev/null +++ b/Task/Collections/DuckDB/collections.duckdb @@ -0,0 +1,11 @@ +create or replace function toset(l) as + array_sort(list_distinct(l)); + +create or replace function array_intersection(a,b) as + array_filter(a, x -> array_contains(b, x)); + +create or replace function set_union(a,b) as + toset(toset(a) || toset(b))); + +create or replace function set_intersection(a,b) as + array_intersection(toset(a),toset(b)); diff --git a/Task/Collections/Phix/collections-1.phix b/Task/Collections/Phix/collections-1.phix index 1211759da2..953e33257c 100644 --- a/Task/Collections/Phix/collections-1.phix +++ b/Task/Collections/Phix/collections-1.phix @@ -1,7 +1,6 @@ -(phixonline)--> +(phixonline) with javascript_semantics sequence collection = {} collection = append(collection,"one") collection = prepend(collection,2) ? collection -- {2,"one"} - +(phixonline) with javascript_semantics setd("one",0) setd(2,0) @@ -7,4 +7,3 @@ return 1 end function traverse_dict(routine_id("visitor")) -- shows 2, "one" - { Number in 0..9, Number #= Number0 - 48 }, digit(Number0). + +isbn13 --> + sequence(base10_digit, [D1, D2, D3]), "-", + sequence(base10_digit, [D4, D5, D6, D7, D8, D9, D10, D11, D12, D13]), + { ( D1 + 3 * D2 + D3 + 3 * D4 + + D5 + 3 * D6 + D7 + 3 * D8 + + D9 + 3 * D10 + D11 + 3 * D12 + D13 ) mod 10 #= 0 }. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro new file mode 100644 index 0000000000..7f3a3f0e20 --- /dev/null +++ b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-2.pro @@ -0,0 +1,11 @@ +?- phrase(isbn13, "978-0596528126"). +true. + +?- phrase(isbn13, "978-0596528120"). +false. + +?- phrase(isbn13, "978-1788399081"). +true. + +?- phrase(isbn13, "978-1788399083"). +false. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro new file mode 100644 index 0000000000..7225eeca85 --- /dev/null +++ b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-3.pro @@ -0,0 +1,12 @@ +?- ISBN = [0'9, 0'7, 0'8, 0'-, 0'0, 0'3, 0'0, 0'6, 0'4, 0'0, _, _, 0'5, 0'7], phrase(isbn13, ISBN). +ISBN = "978-0306400957" ; +ISBN = "978-0306401657" ; +ISBN = "978-0306402357" ; +ISBN = "978-0306403057" ; +ISBN = "978-0306404757" ; +ISBN = "978-0306405457" ; +ISBN = "978-0306406157" ; +ISBN = "978-0306407857" ; +ISBN = "978-0306408557" ; +ISBN = "978-0306409257" ; +false. diff --git a/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro new file mode 100644 index 0000000000..0b5d9cc7dc --- /dev/null +++ b/Task/ISBN13-check-digit/Prolog/isbn13-check-digit-4.pro @@ -0,0 +1,12 @@ +?- phrase(isbn13, ISBN). +ISBN = "000-0000000000" ; +ISBN = "000-0000000017" ; +ISBN = "000-0000000024" ; +ISBN = "000-0000000031" ; +ISBN = "000-0000000048" ; +ISBN = "000-0000000055" ; +ISBN = "000-0000000062" ; +ISBN = "000-0000000079" ; +ISBN = "000-0000000086" ; +ISBN = "000-0000000093" ; +ISBN = "000-0000000109" . % etc... diff --git a/Task/Identity-matrix/DuckDB/identity-matrix.duckdb b/Task/Identity-matrix/DuckDB/identity-matrix.duckdb new file mode 100644 index 0000000000..26cbc7a159 --- /dev/null +++ b/Task/Identity-matrix/DuckDB/identity-matrix.duckdb @@ -0,0 +1,20 @@ +# Produce an (i,j,value) table representing the matrix I(m,n) +# which is the identity matrix if m = n +create or replace function I(m,n,zero) as table ( + with recursive cte(i,j,ij,value) as ( + select 1, 1, (null,null), zero + union all + select if(j=n, i+1, i) as i, + if(j=n, 1, j+1) as j, + (i, j) as ij, + zero + if(i=j, 1, 0) as value + from cte + where i <= m + ) + select ij[1] as i, ij[2] as j, value + from cte + offset 1 +); + +# Generate a 3x3 matrix with DOUBLE(3,2) values: +from I(3, 3, 0.000); diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb new file mode 100644 index 0000000000..44a338df57 --- /dev/null +++ b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/DuckDB/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.duckdb @@ -0,0 +1,27 @@ +# Generate a string of all the codepoints in the range [m,n) +# corresponding to the given Unicode character class, where `class` +# could be '[a-z]' or '\p{Ll}', etc. +# +# Note: codepoints 55296 to 57343 (xD800–xDFFF) are reserved for the +# surrogates mechanism and are excluded as they are regarded as "illegal" +# as characters. +# +create or replace function generate(class, m, n) as ( + select string_agg(s, '') + from (select + case when 55296 <=i and i <= 57343 then null + else regexp_extract( chr(i::INTEGER), class) + end as s + from range(m, n) t(i)) +); + +# ident_start minus NBSP +select generate( '[A-Za-z\200-\237\241-\377_]',0, 1024); + +.mode list + +with ident_start as ( + select generate( '[A-Za-z\200-\237\241-\377_]',0,1024 ) as s + ) + select unnest(regexp_extract_all(s, '.{1,26}')) + from ident_start; diff --git a/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb new file mode 100644 index 0000000000..825cc013b9 --- /dev/null +++ b/Task/Idiomatically-determine-all-the-lowercase-and-uppercase-letters/DuckDB/idiomatically-determine-all-the-lowercase-and-uppercase-letters.duckdb @@ -0,0 +1,19 @@ +# The number of Unicode codepoints +set variable maxu = 1114112; + +# Generate a string of all the codepoints in the range [m,n) +# corresponding to the given Unicode character class, where `class` +# could be '[a-z]' or '\p{Ll}', etc. +# +# Note: codepoints 55296 to 57343 (xD800–xDFFF) are reserved for the +# surrogates mechanism and are excluded as they are regarded "illegal" +# as characters. +# +create or replace function generate(class, m, n) as ( + select string_agg(s, '') + from (select + case when 55296 <=i and i <= 57343 then null + else regexp_extract( chr(i::INTEGER), class) + end as s + from range(m, n) t(i)) +); diff --git a/Task/Include-a-file/RISC-V-Assembly/include-a-file-1.asm b/Task/Include-a-file/RISC-V-Assembly/include-a-file-1.asm new file mode 100644 index 0000000000..c9c972cd28 --- /dev/null +++ b/Task/Include-a-file/RISC-V-Assembly/include-a-file-1.asm @@ -0,0 +1,8 @@ +/************************************/ +/* Constantes */ +/************************************/ +.equ TRUE, 1 +.equ FALSE, 0 + +.equ LENGTHDEC, 12 +.equ LENGTHBIN, 33 diff --git a/Task/Include-a-file/RISC-V-Assembly/include-a-file-2.asm b/Task/Include-a-file/RISC-V-Assembly/include-a-file-2.asm new file mode 100644 index 0000000000..db35e7070a --- /dev/null +++ b/Task/Include-a-file/RISC-V-Assembly/include-a-file-2.asm @@ -0,0 +1,152 @@ +# fichier include riscv assembly for rosetta code +# includeFunctions.s + +/************************************/ +/* string write on connexion usb */ +/***********************************/ +/* a0 String address */ +writeString: # INFO: writeString + addi sp, sp, -8 # save registers on stack + sw ra, 0(sp) + sw s0, 4(sp) + mv s0,a0 # move string address +1: + lbu a0,(s0) # load one character + beqz a0,100f # end if zero + call putchar # character write + add s0,s0,1 # increment address + j 1b # and loop + +100: # end function + lw ra, 0(sp) # restaur registers + lw s0, 4(sp) + addi sp, sp, 8 + ret +/************************************/ +/* binary conversion */ +/***********************************/ +/* a0 value */ +/* a1 result area address */ +/* size mini 33 character */ +conversion2: # INFO: conversion2 + addi sp, sp, -8 # save registres + sw ra, 0(sp) + li t2,0 + li t1,0 +1: + slt t3,a0,x0 # if negative bit 31 is 1 + + slli a0,a0,1 # shift left one bit + add t0,a1,t1 # compute indice to store char in area + addi t3,t3,'0' # conversion byte to ascii char + sb t3,(t0) # store char in area + addi t1,t1,1 # next position + li t0,7 # for add a space separation + beq t2,t0,4f + li t0,15 # for add a space + beq t2,t0,4f + li t0,23 # for add a space + beq t2,t0,4f + j 5f + +4: # store space + li t3,' ' + add t0,a1,t1 + sb t3,(t0) + addi t1,t1,1 +5: + addi t2,t2,1 # increment bit indice + li t0,32 # maxi ? + blt t2,t0,1b # and loop + + add t0,a1,t1 + sb x0,(t0) # final zero +100: + lw ra, 0(sp) + addi sp, sp, 8 + ret +/**********************************************/ +/* decimal conversion */ +/**********************************************/ +/* a0 value */ +/* a1 conversion array address */ +/* a0 return result size */ +.equ LGZONECONV, 20 +conversion10: + addi sp, sp, -4 + sw ra, 0(sp) + li t1,LGZONECONV + li t2,10 # divisor +1: + rem t4,a0,t2 # division remainder by 10 + addi t4,t4,48 # convert to decimal + add t5,a1,t1 # store character position + sb t4,(t5) # store byte + div a0,a0,t2 # compute quotient + beq a0,x0,2f # compare to 0 + addi t1,t1,-1 # decrement store position + bgt t1,x0,1b # and loop if position is ok +2: + li t2,0 # raz indice + li t3,LGZONECONV +3: # loop to transfer result at begining conversion area + add t5,a1,t1 # compute start position + lb t4,(t5) # load byte + add t5,a1,t2 # compute new position + sb t4,(t5) # and store byte + addi t2,t2,1 # increment indice + addi t1,t1,1 + ble t1,t3,3b # and loop if indice <= area size + add t5,a1,t2 # increment final position + sb x0,(t5) # and store byte final zero + mv a0,t2 # return size conversion + +100: + lw ra, 0(sp) + addi sp, sp, 4 + ret +/***************************************************/ +/* register conversion in décimal signed */ +/***************************************************/ +/* a0 value */ +/* a1 result area address size mini 12c */ +/* a0 return result size */ +conversion10S: # INFO: conversion10S + addi sp, sp, -8 # save registers + sw ra, 0(sp) + li t6,'+' + bge a0,x0,1f # positive number ? + li t6,'-' # negative + sub a0,x0,a0 # inversion +1: + li t4,LENGTHDEC # area size + li t1,10 # divisor +2: + remu t3,a0,t1 # remainder division by 10 + addi t3,t3,48 # conversion ascii + add t2,t4,a1 # compute store indice + sb t3,(t2) + addi t4,t4,-1 # previous position + divu a0,a0,t1 # division by 10 + bne a0,x0,2b + # store signe in current position + add t2,t4,a1 + sb t6,(t2) + li t2,0 + li t3,LENGTHDEC +3: # loop copy result to area start + add t5,a1,t4 # compute start position + lb t6,(t5) # load byte + add t5,a1,t2 # compute new position + sb t6,(t5) # and store byte + addi t2,t2,1 # increment indice + addi t4,t4,1 + ble t4,t3,3b # and loop if indice <= area size + add t5,a1,t2 # increment final position + sb x0,(t5) # and store byte final zero + mv a0,t2 # return size conversion + +100: + lw ra, 0(sp) # restaur registers + addi sp, sp, 8 + ret diff --git a/Task/Include-a-file/RISC-V-Assembly/include-a-file-3.asm b/Task/Include-a-file/RISC-V-Assembly/include-a-file-3.asm new file mode 100644 index 0000000000..30025f2974 --- /dev/null +++ b/Task/Include-a-file/RISC-V-Assembly/include-a-file-3.asm @@ -0,0 +1,44 @@ +# riscv assembly raspberry pico2 rp2350 +# program include.s +# connexion putty com3 +/*********************************************/ +/* CONSTANTES */ +/********************************************/ +.include "../../constantesRiscv.inc" + +/*******************************************/ +/* INITIALED DATAS */ +/*******************************************/ +.data +szMessHello: .asciz "Hello world.\r\n" +szMessStart: .asciz "Program riscv start.\r\n" + +/*******************************************/ +/* UNINITIALED DATA */ +/*******************************************/ +.bss +.align 2 +/**********************************************/ +/* SECTION CODE */ +/**********************************************/ +.text +.global main + +main: + call stdio_init_all # général init +1: # start loop connexion + li a0,0 # raz argument register + call tud_cdc_n_connected + beqz a0,1b # retuen code = zero ? + + la a0,szMessStart # message address + call writeString # display message + la a0,szMessHello # message address + call writeString # display message + +100: # final loop + j 100b +/************************************/ +/* file include Fonctions */ +/***********************************/ +.include "../../includeFunctions.s" diff --git a/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-1.duckdb b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-1.duckdb new file mode 100644 index 0000000000..357617d7fc --- /dev/null +++ b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-1.duckdb @@ -0,0 +1 @@ +select '1'::INT + 1; diff --git a/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-2.duckdb b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-2.duckdb new file mode 100644 index 0000000000..f2698e8828 --- /dev/null +++ b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-2.duckdb @@ -0,0 +1 @@ +select '1.2'::FLOAT + 1; diff --git a/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-3.duckdb b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-3.duckdb new file mode 100644 index 0000000000..48d38fb4da --- /dev/null +++ b/Task/Increment-a-numerical-string/DuckDB/increment-a-numerical-string-3.duckdb @@ -0,0 +1 @@ +select (' 1.2' || chr(9))::FLOAT + 1; diff --git a/Task/Increment-a-numerical-string/Pluto/increment-a-numerical-string.pluto b/Task/Increment-a-numerical-string/Pluto/increment-a-numerical-string.pluto new file mode 100644 index 0000000000..bfbe214393 --- /dev/null +++ b/Task/Increment-a-numerical-string/Pluto/increment-a-numerical-string.pluto @@ -0,0 +1,4 @@ +local s = "1000" +++s -- implicit conversion to number before incrementing +print(s) +print(type(s)) diff --git a/Task/Infinity/ArkScript/infinity.ark b/Task/Infinity/ArkScript/infinity.ark new file mode 100644 index 0000000000..2fd9f611e3 --- /dev/null +++ b/Task/Infinity/ArkScript/infinity.ark @@ -0,0 +1,3 @@ +(assert (= false (math:Inf? 0)) "0 is not infinite") +(assert (math:Inf? math:Inf) "math:Inf is infinite") +(assert (not (math:Inf? math:NaN)) "math:NaN is not infinite") diff --git a/Task/Infinity/DuckDB/infinity.duckdb b/Task/Infinity/DuckDB/infinity.duckdb new file mode 100644 index 0000000000..506d3b31d0 --- /dev/null +++ b/Task/Infinity/DuckDB/infinity.duckdb @@ -0,0 +1 @@ +select 'Infinity' as s, s::DOUBLE as infinity, s::FLOAT = infinity, -infinity = '-INF'::DOUBLE; diff --git a/Task/Infinity/Pluto/infinity.pluto b/Task/Infinity/Pluto/infinity.pluto new file mode 100644 index 0000000000..e67a669ac0 --- /dev/null +++ b/Task/Infinity/Pluto/infinity.pluto @@ -0,0 +1,8 @@ +local function isinfinite(f) + return f == 1.0 / 0.0 or f == (-1.0) / 0.0 +end + +local fs = {1.5, 1.5 / 0.0, (-1.5) / 0.0} +for fs as f do + print(isinfinite(f)) +end diff --git a/Task/Inheritance-Multiple/V-(Vlang)/inheritance-multiple.v b/Task/Inheritance-Multiple/V-(Vlang)/inheritance-multiple.v new file mode 100644 index 0000000000..e656846519 --- /dev/null +++ b/Task/Inheritance-Multiple/V-(Vlang)/inheritance-multiple.v @@ -0,0 +1,38 @@ +struct Size { + mut: + width int + height int +} + +fn (s &Size) area() int { + return s.width * s.height +} + +struct Colors { + mut: + color string +} + +struct Button { + Size + Colors + title string +} + +fn main() { + mut button_1 := Button{ + title: "On" + width: 4 + height: 2 + } + button_1.color = "red" + println(button_1) + + mut button_2 := Button{ + title: "Off" + height: 4 + color: "blue" + } + button_2.width = 8 + println("The area of button 2 is ${button_2.area()}") +} diff --git a/Task/Inheritance-Single/Rhombus/inheritance-single.rhombus b/Task/Inheritance-Single/Rhombus/inheritance-single.rhombus new file mode 100644 index 0000000000..17f1674ba2 --- /dev/null +++ b/Task/Inheritance-Single/Rhombus/inheritance-single.rhombus @@ -0,0 +1,17 @@ +#lang rhombus/static + +class Animal(): + nonfinal + +class Dog(): + nonfinal + extends Animal + +class Cat(): + extends Animal + +class Lab(): + extends Dog + +class Collie(): + extends Dog diff --git a/Task/Inheritance-Single/V-(Vlang)/inheritance-single.v b/Task/Inheritance-Single/V-(Vlang)/inheritance-single.v new file mode 100644 index 0000000000..fe010e4c0c --- /dev/null +++ b/Task/Inheritance-Single/V-(Vlang)/inheritance-single.v @@ -0,0 +1,36 @@ +struct Animal { + mut: + alive bool +} + +struct Dog { + Animal + mut: + obediant bool +} + +struct Cat { + Animal + mut: + trained bool +} + +struct Lab { + Dog + mut: + color string +} + +struct Collie { + Dog + mut: + catches bool +} + +fn main() { + mut pet := Lab{} + pet.alive = true + pet.obediant = false + pet.color = "black" + println(pet) +} diff --git a/Task/Input-loop/Nom/input-loop.num b/Task/Input-loop/Nom/input-loop.num new file mode 100644 index 0000000000..e3adc9de66 --- /dev/null +++ b/Task/Input-loop/Nom/input-loop.num @@ -0,0 +1 @@ + read; print; clear; diff --git a/Task/Integer-comparison/DuckDB/integer-comparison.duckdb b/Task/Integer-comparison/DuckDB/integer-comparison.duckdb new file mode 100644 index 0000000000..0ea8171f76 --- /dev/null +++ b/Task/Integer-comparison/DuckDB/integer-comparison.duckdb @@ -0,0 +1,8 @@ +select a + || if ( a < b, ' is less than ', + if ( a = b, ' is equal to ', + if ( a > b, ' is greater than ', + ' is incomparable to '))) + || b as comparison +from read_csv_auto('/dev/stdin', header=false, sep=' ', + columns= {'a': 'INTEGER', 'b': 'INTEGER'}); diff --git a/Task/Integer-comparison/Prolog/integer-comparison-1.pro b/Task/Integer-comparison/Prolog/integer-comparison-1.pro new file mode 100644 index 0000000000..7d190e158f --- /dev/null +++ b/Task/Integer-comparison/Prolog/integer-comparison-1.pro @@ -0,0 +1,14 @@ +:- set_prolog_flag(double_quotes, chars). + +println([]) :- write('\n'). +println([Char | Chars]) :- write(Char), println(Chars). + +my_compare(A, B) :- + ( A < B + -> println("A is less than B") + ; A > B + -> println("A is greater than B") + ; % double equals is necessary if we want the predicate to fail if A or B is unbound + A == B + -> println("A is equal to B") + ). diff --git a/Task/Integer-comparison/Prolog/integer-comparison-2.pro b/Task/Integer-comparison/Prolog/integer-comparison-2.pro new file mode 100644 index 0000000000..6f156c08ac --- /dev/null +++ b/Task/Integer-comparison/Prolog/integer-comparison-2.pro @@ -0,0 +1,7 @@ +my_compare2(A, B) :- + compare(Order, A, B), + my_compare2_(Order). + +my_compare2_(<) :- println("A is less than B."). +my_compare2_(=) :- println("A is equal to B."). +my_compare2_(>) :- println("A is greater than B."). diff --git a/Task/Integer-comparison/YAMLScript/integer-comparison.ys b/Task/Integer-comparison/YAMLScript/integer-comparison.ys new file mode 100644 index 0000000000..59b265bd8e --- /dev/null +++ b/Task/Integer-comparison/YAMLScript/integer-comparison.ys @@ -0,0 +1,8 @@ +!YS-v0 + +defn main(x y): + say: + cond: + x < y: "$x is less than $y" + x > y: "$x is greater than $y" + else : "$x is equal to $y" diff --git a/Task/Integer-sequence/ArkScript/integer-sequence-1.ark b/Task/Integer-sequence/ArkScript/integer-sequence-1.ark new file mode 100644 index 0000000000..3292a2f31d --- /dev/null +++ b/Task/Integer-sequence/ArkScript/integer-sequence-1.ark @@ -0,0 +1,4 @@ +(mut i 0) +(while true { + (print i) + (set i (+ 1 i)) }) diff --git a/Task/Integer-sequence/ArkScript/integer-sequence-2.ark b/Task/Integer-sequence/ArkScript/integer-sequence-2.ark new file mode 100644 index 0000000000..99a3156c43 --- /dev/null +++ b/Task/Integer-sequence/ArkScript/integer-sequence-2.ark @@ -0,0 +1,5 @@ +(let loop (fun (i) { + (print i) + (loop (+ i 1)) })) + +(loop 0) diff --git a/Task/Introspection/DuckDB/introspection.duckdb b/Task/Introspection/DuckDB/introspection.duckdb new file mode 100644 index 0000000000..ec3b3e7b2f --- /dev/null +++ b/Task/Introspection/DuckDB/introspection.duckdb @@ -0,0 +1,10 @@ +# Return version() as a list of integers [major, minor, patch] +create or replace function semver() as + version().regexp_extract('v[0-9.]*')[2:].split('.') + .list_transform(x->cast(x as INTEGER)); + +# semversion should be a list of integers [major, minor, patch] +create or replace function errorIfBefore(semversion) as + if (semver() <= semversion, error( version() || ' is too old'), null); + +select errorIfBefore([1,1,5]); diff --git a/Task/Inverted-index/DuckDB/inverted-index.duckdb b/Task/Inverted-index/DuckDB/inverted-index.duckdb new file mode 100644 index 0000000000..07b4e48579 --- /dev/null +++ b/Task/Inverted-index/DuckDB/inverted-index.duckdb @@ -0,0 +1,25 @@ +install fts; -- once should be enough + +load fts; +create or replace table texts as (from read_text('inv*.txt')); + +pragma create_fts_index( + 'texts', -- table name + 'filename', -- column name + 'content', -- column name of text + stemmer = 'english', + stopwords = 'none', + strip_accents = 1, + lower = 1, -- ignore case + overwrite = 1); + +# Simple interface to match_bm25 for conjunctive queries: +create or replace function s(queryString) as table ( + select filename, + content, + fts_main_texts.match_bm25( filename, + queryString, + conjunctive := 1) as score + from texts + where score IS NOT NULL +); diff --git a/Task/Inverted-syntax/DuckDB/inverted-syntax-1.duckdb b/Task/Inverted-syntax/DuckDB/inverted-syntax-1.duckdb new file mode 100644 index 0000000000..49ff2b9ade --- /dev/null +++ b/Task/Inverted-syntax/DuckDB/inverted-syntax-1.duckdb @@ -0,0 +1 @@ +SELECT 1 as x; diff --git a/Task/Inverted-syntax/DuckDB/inverted-syntax-2.duckdb b/Task/Inverted-syntax/DuckDB/inverted-syntax-2.duckdb new file mode 100644 index 0000000000..293c959dec --- /dev/null +++ b/Task/Inverted-syntax/DuckDB/inverted-syntax-2.duckdb @@ -0,0 +1 @@ +CREATE TABLE foo AS ... diff --git a/Task/Inverted-syntax/DuckDB/inverted-syntax-3.duckdb b/Task/Inverted-syntax/DuckDB/inverted-syntax-3.duckdb new file mode 100644 index 0000000000..12c6d444ac --- /dev/null +++ b/Task/Inverted-syntax/DuckDB/inverted-syntax-3.duckdb @@ -0,0 +1 @@ +SET VARIABLE x = 1; diff --git a/Task/Isqrt-integer-square-root-of-X/REXX/isqrt-integer-square-root-of-x.rexx b/Task/Isqrt-integer-square-root-of-X/REXX/isqrt-integer-square-root-of-x.rexx index 29fcc4a72c..1754501f09 100644 --- a/Task/Isqrt-integer-square-root-of-X/REXX/isqrt-integer-square-root-of-x.rexx +++ b/Task/Isqrt-integer-square-root-of-X/REXX/isqrt-integer-square-root-of-x.rexx @@ -1,5 +1,4 @@ --- 8 May 2025 -Main: +-- 28 Jul 2025 include Settings say 'ISQRT (INTEGER SQUARE ROOT)' @@ -31,7 +30,7 @@ call Timer return Task2: -procedure +procedure expose Memo. arg xx,yy,zz,mm call Time('r') select @@ -120,6 +119,4 @@ do while z < zz end return zz -include Functions -include Helper -include Abend +include Math diff --git a/Task/Iterated-digits-squaring/Prolog/iterated-digits-squaring.pro b/Task/Iterated-digits-squaring/Prolog/iterated-digits-squaring.pro new file mode 100644 index 0000000000..b9925b14ab --- /dev/null +++ b/Task/Iterated-digits-squaring/Prolog/iterated-digits-squaring.pro @@ -0,0 +1,36 @@ +:- initialization(main, main). + +%! next_number_in_chain(+Number0, -Number) is det. +next_number_in_chain(Number0, Number) :- next_number_in_chain_(Number0, 0, Number). + +next_number_in_chain_(Number0, Number1, Number) :- + divmod(Number0, 10, Div, Mod), + Number2 is Number1 + Mod ^ 2, + ( Div = 0 + -> Number2 = Number + ; next_number_in_chain_(Div, Number2, Number) + ). + +%! number_chain(+Number, -End) is det. +number_chain(Number0, End) :- + ( Number0 =< 81 * 9 + -> number_chain_(Number0, End) + ; next_number_in_chain(Number0, Number), + number_chain(Number, End) + ). + +:- table number_chain_/2. +number_chain_(89, 89). +number_chain_( 1, 1). +number_chain_(Number0, End) :- + next_number_in_chain(Number0, Number), + number_chain_(Number, End). + +%! task(+Max, -Result) is det. +task(Max, Result) :- + aggregate_all(count, ( between(1, Max, N), number_chain(N, 89) ), Result). + +main([Input]) :- + atom_number(Input, Number), + time(task(Number, Result)), + writeln(Result). diff --git a/Task/JSON/Agena/json.agena b/Task/JSON/Agena/json.agena new file mode 100644 index 0000000000..a943498cc5 --- /dev/null +++ b/Task/JSON/Agena/json.agena @@ -0,0 +1,28 @@ +scope # JSON encode/decode - translation of the Phix sample, using Agena's standard json module + + import json; + + print( "roundtrip (10 examples):" ); + + local constant json_strings := [ '{"this":"that","age":{"this":"that","age":29}}' + , '1' + , '"hello"' + , 'null' + , '[12]' + , '[null,12]' + , '[]' + , '{"this":"that","age":29}' + , '{}' + , '[null,[null,12]]' + ]; + + for i to size json_strings do + local constant s := json_strings[ i ]; + local constant j := json.decode( s ); + local constant r := json.encode( j ); + local constant pad := if size s < 29 then 30 else size s + 1 fi; + print( " " & strings.ljustify( s, pad ) & " -> " + , j, "\n" & if s = r then "-> " else "** " fi & r & "\n" + ) + od +end diff --git a/Task/JSON/DuckDB/json-1.duckdb b/Task/JSON/DuckDB/json-1.duckdb new file mode 100644 index 0000000000..8c3a095cf1 --- /dev/null +++ b/Task/JSON/DuckDB/json-1.duckdb @@ -0,0 +1 @@ +from 'colors.json'; diff --git a/Task/JSON/DuckDB/json-2.duckdb b/Task/JSON/DuckDB/json-2.duckdb new file mode 100644 index 0000000000..202d376c1a --- /dev/null +++ b/Task/JSON/DuckDB/json-2.duckdb @@ -0,0 +1 @@ +select json::JSON from read_csv('colors.json', header=false, sep='\t') t(json); diff --git a/Task/JSON/DuckDB/json-3.duckdb b/Task/JSON/DuckDB/json-3.duckdb new file mode 100644 index 0000000000..ad119d13e6 --- /dev/null +++ b/Task/JSON/DuckDB/json-3.duckdb @@ -0,0 +1 @@ +COPY t to 'output.json'; diff --git a/Task/JSON/Pluto/json.pluto b/Task/JSON/Pluto/json.pluto new file mode 100644 index 0000000000..a91a76cdf1 --- /dev/null +++ b/Task/JSON/Pluto/json.pluto @@ -0,0 +1,30 @@ +do -- JSON encode/decode - translation of the Phix sample, using Pluto's standard json module + + local json = require( "json" ) + + print( "roundtrip (10 examples):" ) + + local json_strings = { '{"this":"that","age":{"this":"that","age":29}}' + , '1' + , '"hello"' + , 'null' + , '[12]' + , '[null,12]' + , '[]' + , '{"this":"that","age":29}' + , '{}' + , '[null,[null,12]]' + } + + for i = 1, #json_strings do + local s = json_strings[ i ] + local j = json.decode( s, json.withnull | json.withorder ) -- parse the string into a table + -- preserving nulls and element order + local r = json.encode( j ) -- turn j back into a JSON string + local v = dumpvar( j ):gsub( "\n", "" ):gsub( "\t", "" ) -- the table as a readable string + local sp = " " + io.write( " ", s, if #s >= #sp then "\n "..sp else sp:sub( 1, #sp - #s ) end ) + io.write( "-> ", if #v > 50 then v:sub( 1, 47 ).."..." else v end, "\n" ) + io.write( if s == r then "-> " else "** " end, r, "\n\n" ) + end +end diff --git a/Task/JSON/REBOL/json.rebol b/Task/JSON/REBOL/json-1.rebol similarity index 81% rename from Task/JSON/REBOL/json.rebol rename to Task/JSON/REBOL/json-1.rebol index 98c9a6e014..6249929d1d 100644 --- a/Task/JSON/REBOL/json.rebol +++ b/Task/JSON/REBOL/json-1.rebol @@ -10,5 +10,5 @@ json-str: {{"menu": { } }} -res: json-to-rebol json-str -js: rebol-to-json res +reb: json-to-rebol json-str +str: rebol-to-json reb diff --git a/Task/JSON/REBOL/json-2.rebol b/Task/JSON/REBOL/json-2.rebol new file mode 100644 index 0000000000..1137570a61 --- /dev/null +++ b/Task/JSON/REBOL/json-2.rebol @@ -0,0 +1,16 @@ +json-str: {{"menu": { + "id": "file", + "string": "File:", + "number": -3, + "boolean": true, + "boolean2": false, + "null": null, + "array": [1, 0.13, null, true, false, "\t\r\n"], + "empty-string": "" + } +}} +import json ;; just in case it's not yet imported +probe reb: decode 'json json-str +probe str: encode 'json reb ;; outputs without any indentation +;; Validate that re-encoded JSON is same +probe equal? reb decode 'json str diff --git a/Task/Jacobi-symbol/Excel/jacobi-symbol.excel b/Task/Jacobi-symbol/Excel/jacobi-symbol.excel new file mode 100644 index 0000000000..7923afe75c --- /dev/null +++ b/Task/Jacobi-symbol/Excel/jacobi-symbol.excel @@ -0,0 +1,34 @@ +To CopyPaste : =LAMBDA(a,n,[result],LET(s,IF(ISOMITTED(result),MOD(a,n),a),R,IF(ISOMITTED(result),EXPAND(1,COUNT(s),1,1),result),B,IF(s=0,HSTACK(s,n,R),IF(BITAND(s,1)=0,HSTACK(BITRSHIFT(s,1),n,IF(ABS(BITAND(n,7)-4)=1,-R,R)),HSTACK(MOD(n,s),s,IF(BITAND(s,3)+BITAND(n,3)-6=0,-R,R)))),new_a,INDEX(B,,1),new_n,INDEX(B,,2),new_result,INDEX(B,,3),IF(OR(new_a),Jacobi(new_a,new_n,new_result),IF(new_n=1,new_result,0)))) + +Easy-to-read display : +=LAMBDA(a,n,[result], + LET( + s, IF(ISOMITTED(result), MOD(a,n), a), + R, IF(ISOMITTED(result), EXPAND(1, COUNT(s), 1, 1), result), + B, IF( + s=0, + HSTACK(s,n,R), + IF( + BITAND(s,1)=0, + HSTACK( + BITRSHIFT(s,1), + n, + IF(ABS(BITAND(n,7)-4)=1,-R,R) + ), + HSTACK( + MOD(n,s), + s, + IF(BITAND(s,3)+BITAND(n,3)-6=0,-R,R) + ) + ) + ), + new_a, INDEX(B,,1), + new_n, INDEX(B,,2), + new_result, INDEX(B,,3), + IF( + OR(new_a), + Jacobi(new_a,new_n,new_result), + IF(new_n=1,new_result,0) + ) + ) +) diff --git a/Task/Jacobsthal-numbers/ALGOL-68/jacobsthal-numbers.alg b/Task/Jacobsthal-numbers/ALGOL-68/jacobsthal-numbers.alg index ffe68ab564..221694abb5 100644 --- a/Task/Jacobsthal-numbers/ALGOL-68/jacobsthal-numbers.alg +++ b/Task/Jacobsthal-numbers/ALGOL-68/jacobsthal-numbers.alg @@ -2,7 +2,7 @@ BEGIN # find some Jacobsthal and related Numbers # INT max jacobsthal = 29; # highest Jacobsthal number we will find # INT max oblong = 20; # highest Jacobsthal oblong number we will find # INT max j prime = 20; # number of Jacobsthal prinmes we will find # - PR precision 200 PR # set the precision of LONG LONG INT # + PR precision 250 PR # set the precision of LONG LONG INT # PR read "primes.incl.a68" PR # include prime utilities # [ 0 : max jacobsthal ]LONG INT j; # will hold Jacobsthal numbers # [ 0 : max jacobsthal ]LONG INT jl; # will hold Jacobsthal-Lucas numbers # diff --git a/Task/Jacobsthal-numbers/Agena/jacobsthal-numbers.agena b/Task/Jacobsthal-numbers/Agena/jacobsthal-numbers.agena new file mode 100644 index 0000000000..35d51d5a8b --- /dev/null +++ b/Task/Jacobsthal-numbers/Agena/jacobsthal-numbers.agena @@ -0,0 +1,50 @@ +scope # find some Jacobsthal and related Numbers + local constant maxJacobsthal # highest Jacobsthal number we will find + , constant maxOblong # highest Jacobsthal oblong number we will find + , constant maxJPrime # number of Jacobsthal primes we will find + := 29, 20, 10; + local constant j # will hold Jacobsthal numbers + , constant jl # will hold Jacobsthal-Lucas numbers + , constant jo # will hold Jacobsthal oblong numbers + := seq(), seq(), seq(); + # calculate the Jacobsthal Numbers and related numbers + # Jacobsthal : J0 = 0, J1 = 1, Jn = Jn-1 + 2 × Jn-2 + # Jacobsthal-Lucas: JL0 = 2, JL1 = 1, JLn = JLn-1 + 2 × JLn-2 + # Jacobsthal oblong: JOn = Jn x Jn-1 + # but Agena sequences are indexed from 1, so J0 is in j[ 1 ], JL0 is in jl[ 1 ], etc. + # but JO1 is in jo[ 1 ], however - also the sequence elements must be added in order + j[ 1 ] := 0; j[ 2 ] := 1; jl[ 1 ] := 2; jl[ 2 ] := 1; jo[ 1 ] := 0; + for n from 2 to maxJacobsthal do + j[ n + 1 ] := j[ n ] + ( 2 * j[ n - 1 ] ); + jl[ n + 1 ] := jl[ n ] + ( 2 * jl[ n - 1 ] ) + od; + for n to maxOblong do + jo[ n ] := j[ n + 1 ] * j[ n ] + od; + + local procedure showNumbers( legend :: string, numbers :: sequence ) + local nCount := 0; + printf( "First %d %s\n", size numbers, legend ); + for n to size numbers do + printf( " %11.0f", numbers[ n ] ); # using %11.0f and not %11d as some values will... + nCount +:= 1; # ...be larger than 2^32 + if nCount mod 5 = 0 then print() fi + od + end; + + # show the various numbers numbers + showNumbers( "Jacobsthal Numbers:", j ); + showNumbers( "Jacobsthal-Lucas Numbers:", jl ); + showNumbers( "Jacobsthal oblong Numbers:", jo ); + # find some prime Jacobsthal numbers + local jn1, jn2, pCount := j[ 2 ], j[ 1 ], 0; + printf( "First %d Jacobstal primes:\n n Jn\n", maxJPrime ); + for n from 2 while pCount < maxJPrime do + local constant jn := jn1 + ( 2 * jn2 ); + jn2, jn1 := jn1, jn; + if numtheory.isprime( jn ) then + pCount +:= 1; + printf( "%4d: %d\n", n, jn ) + fi + od +end diff --git a/Task/Jacobsthal-numbers/EasyLang/jacobsthal-numbers.easy b/Task/Jacobsthal-numbers/EasyLang/jacobsthal-numbers.easy new file mode 100644 index 0000000000..3229a8d841 --- /dev/null +++ b/Task/Jacobsthal-numbers/EasyLang/jacobsthal-numbers.easy @@ -0,0 +1,50 @@ +fastfunc isprim n . + if n < 2 : return 0 + i = 2 + while i <= sqrt n + if n mod i = 0 : return 0 + i += 1 + . + return 1 +. +subr jtinit + jtcurr = 0 + jtnext = 1 +. +proc jtstep . + swap jtnext jtcurr + jtnext += jtnext + jtcurr +. +print "First 30 Jacobsthal numbers:" +jtinit +for i to 30 + write jtcurr & " " + jtstep +. +print "" +print "\nFirst 30 Jacobsthal-Lucas numbers:" +jtinit +jtcurr = 2 +for i to 30 + write jtcurr & " " + jtstep +. +print "" +print "\nFirst 20 Jacobsthal oblong numbers:" +jtinit +for i to 20 + write jtcurr * jtnext & " " + jtstep +. +print "" +print "\nFirst 10 Jacobsthal prime numbers:" +jtinit +while cnt < 10 + jtstep + if isprim jtnext = 1 + write jtnext & " " + cnt += 1 + . + i += 1 +. +print "" diff --git a/Task/Jacobsthal-numbers/Fennel/jacobsthal-numbers.fennel b/Task/Jacobsthal-numbers/Fennel/jacobsthal-numbers.fennel new file mode 100644 index 0000000000..d9d8894e9c --- /dev/null +++ b/Task/Jacobsthal-numbers/Fennel/jacobsthal-numbers.fennel @@ -0,0 +1,64 @@ +(do ;;; find some Jacobsthal and related Numbers + (local (max-jacobsthal ; highest Jacobsthal number we will find + max-oblong ; highest Jacobsthal oblong number we will find + max-j-prime ; number of Jacobsthal primes we will find + ) (values 29 20 10)) + (local (j ; will hold Jacobsthal numbers + jl ; will hold Jacobsthal-Lucas numbers + jo ; will hold Jacobsthal oblong numbers + ) (values [] [] [])) + ; calculate the Jacobsthal Numbers and related numbers + ; Jacobsthal : J0 = 0, J1 = 1, Jn = Jn-1 + 2 × Jn-2 + ; Jacobsthal-Lucas: JL0 = 2, JL1 = 1, JLn = JLn-1 + 2 × JLn-2 + ; Jacobsthal oblong: JOn = Jn x Jn-1 + ; Lua arrays (and hence Fennel arrays) can be indexed from 0 but this uses indexing from 1, + ; to follow the Agena and Pluto samples, so J0 is in j[ 1 ], JL0 is in jl[ 1 ], etc. + ; but JO1 is in jo[ 1 ], however + (tset j 1 0) (tset j 2 1) (tset jl 1 2) (tset jl 2 1) (tset jo 1 0) + (for [n 2 max-jacobsthal] + (local (n+1 n-1) (values (+ n 1) (- n 1))) + (tset j n+1 (+ (. j n) (* 2 (. j n-1)))) + (tset jl n+1 (+ (. jl n) (* 2 (. jl n-1)))) + ) + (for [n 1 max-oblong] + (tset jo n (* (. j (+ n 1)) (. j n))) + ) + + (fn is-prime [n] + (var result (or (= n 2) (and (> n 1) (= 1 (band n 1))))) + (when result + (var k 3) + (local max-k (math.floor (math.sqrt n))) + (while (and result (<= k max-k)) + (set (result k) (values (not= 0 (% n k)) (+ k 2))) + ) + ) + result + ) + (fn show-numbers [legend numbers] + (var nCount 0) + (io.write (string.format "First %d %s\n" (length numbers) legend)) + (for [n 1 (length numbers)] + (io.write (string.format " %11d" (. numbers n))) + (set nCount (+ nCount 1)) + (when (= 0 (% nCount 5)) (print)) + ) + ) + + ; show the various numbers numbers + (show-numbers "Jacobsthal Numbers:" j ) + (show-numbers "Jacobsthal-Lucas Numbers:" jl ) + (show-numbers "Jacobsthal oblong Numbers:" jo ) + ; find some prime Jacobsthal numbers + (io.write (string.format "First %d Jacobstal primes:\n n Jn\n" max-j-prime)) + (var (jn1 jn2 pCount n) (values (. j 2) (. j 1) 0 2)) + (while (< pCount max-j-prime) + (local jn (+ jn1 (* 2 jn2))) + (set (jn2 jn1) (values jn1 jn)) + (when (is-prime jn) + (set pCount (+ pCount 1)) + (io.write (string.format "%4d: %d\n" n jn)) + ) + (set n (+ n 1)) + ) +) diff --git a/Task/Jacobsthal-numbers/Lua/jacobsthal-numbers.lua b/Task/Jacobsthal-numbers/Lua/jacobsthal-numbers.lua new file mode 100644 index 0000000000..7cb259f4bf --- /dev/null +++ b/Task/Jacobsthal-numbers/Lua/jacobsthal-numbers.lua @@ -0,0 +1,65 @@ +do -- find some Jacobsthal and related Numbers + + local maxJacobsthal -- highest Jacobsthal number we will find + , maxOblong -- highest Jacobsthal oblong number we will find + , maxJPrime -- number of Jacobsthal primes we will find + = 29, 20, 10 + local j -- will hold Jacobsthal numbers + , jl -- will hold Jacobsthal-Lucas numbers + , jo -- will hold Jacobsthal oblong numbers + = {}, {}, {} + -- calculate the Jacobsthal Numbers and related numbers + -- Jacobsthal : J0 == 0, J1 == 1, Jn == Jn-1 + 2 × Jn-2 + -- Jacobsthal-Lucas: JL0 == 2, JL1 == 1, JLn == JLn-1 + 2 × JLn-2 + -- Jacobsthal oblong: JOn == Jn x Jn-1 + -- Lua arrays can be indexed from 0 but as jo is indexed from 1, we index j, jl and jo + -- from 1 to simplify printing them + j[ 1 ], j[ 2 ], jl[ 1 ], jl[ 2 ], jo[ 1 ] = 0, 1, 2, 1, 0 + for n = 2, maxJacobsthal do + j[ n + 1 ] = j[ n ] + ( 2 * j[ n - 1 ] ) + jl[ n + 1 ] = jl[ n ] + ( 2 * jl[ n - 1 ] ) + end + for n = 1, maxOblong do + jo[ n ] = j[ n + 1 ] * j[ n ] + end + + function isPrime( p ) + if p <= 1 or p % 2 == 0 then + return p == 2 + else + local prime = true + local i = 3 + local rootP = math.floor( math.sqrt( p ) ) + while i <= rootP and prime do + prime = p % i ~= 0 + i = i + 1 + end + return prime + end + end + + local function showNumbers( legend, numbers ) + io.write( string.format( "First %d %s\n", # numbers, legend ) ) + for n = 1, # numbers do + io.write( string.format( " %11d", numbers[ n ] ) ) + if n % 5 == 0 then io.write( "\n" ) end + end + end + + -- show the various numbers numbers + showNumbers( "Jacobsthal Numbers:", j ) + showNumbers( "Jacobsthal-Lucas Numbers:", jl ) + showNumbers( "Jacobsthal oblong Numbers:", jo ) + -- find some prime Jacobsthal numbers + io.write( string.format( "First %d Jacobstal primes:\n n Jn\n", maxJPrime ) ) + local jn1, jn2, pCount, n = j[ 2 ], j[ 1 ], 0, 2 + while pCount < maxJPrime do + local jn = jn1 + ( 2 * jn2 ) + jn2, jn1 = jn1, jn + if isPrime( jn ) then + pCount = pCount + 1 + io.write( string.format( "%4d: %d\n", n, jn ) ) + end + n = n + 1 + end +end diff --git a/Task/Jacobsthal-numbers/Pluto/jacobsthal-numbers.pluto b/Task/Jacobsthal-numbers/Pluto/jacobsthal-numbers.pluto new file mode 100644 index 0000000000..17c53e05bd --- /dev/null +++ b/Task/Jacobsthal-numbers/Pluto/jacobsthal-numbers.pluto @@ -0,0 +1,50 @@ +do -- find some Jacobsthal and related Numbers + + local fmt = require( "fmt" ) -- RC Pluto formatting library + local int = require( "int" ) -- RC Pluto integer library - inc. some prime utilities + + local maxJacobsthal -- highest Jacobsthal number we will find + , maxOblong -- highest Jacobsthal oblong number we will find + , maxJPrime -- number of Jacobsthal primes we will find + = 29, 20, 10 + local j -- will hold Jacobsthal numbers + , jl -- will hold Jacobsthal-Lucas numbers + , jo -- will hold Jacobsthal oblong numbers + = {}, {}, {} + -- calculate the Jacobsthal Numbers and related numbers + -- Jacobsthal : J0 == 0, J1 == 1, Jn == Jn-1 + 2 × Jn-2 + -- Jacobsthal-Lucas: JL0 == 2, JL1 == 1, JLn == JLn-1 + 2 × JLn-2 + -- Jacobsthal oblong: JOn == Jn x Jn-1 + -- Pluto arrays can be indexed from 0 but as jo is indexed from 1, we index j, jl and jo + -- from 1 to simplify printing them + j[ 1 ], j[ 2 ], jl[ 1 ], jl[ 2 ], jo[ 1 ] = 0, 1, 2, 1, 0 + for n = 2, maxJacobsthal do + j[ n + 1 ] = j[ n ] + ( 2 * j[ n - 1 ] ) + jl[ n + 1 ] = jl[ n ] + ( 2 * jl[ n - 1 ] ) + end + for n = 1, maxOblong do + jo[ n ] = j[ n + 1 ] * j[ n ] + end + + local function showNumbers( legend : string, numbers : table ) + fmt.write( "First %d %s\n", # numbers, legend ) + fmt.tprint( " %11d", numbers, 5, "", "" ) + end + + -- show the various numbers numbers + showNumbers( "Jacobsthal Numbers:", j ) + showNumbers( "Jacobsthal-Lucas Numbers:", jl ) + showNumbers( "Jacobsthal oblong Numbers:", jo ) + -- find some prime Jacobsthal numbers + fmt.write( "First %d Jacobstal primes:\n n Jn\n", maxJPrime ) + local jn1, jn2, pCount, n = j[ 2 ], j[ 1 ], 0, 2 + while pCount < maxJPrime do + local jn = jn1 + ( 2 * jn2 ) + jn2, jn1 = jn1, jn + if int.isprime( jn ) then + ++ pCount + fmt.write( "%4d: %d\n", n, jn ) + end + ++ n + end +end diff --git a/Task/Jaro-similarity/DuckDB/jaro-similarity.duckdb b/Task/Jaro-similarity/DuckDB/jaro-similarity.duckdb new file mode 100644 index 0000000000..c7811f002e --- /dev/null +++ b/Task/Jaro-similarity/DuckDB/jaro-similarity.duckdb @@ -0,0 +1,6 @@ +select s1, s2, jaro_similarity(s1, s2) as jaro, jaro_winkler_similarity(s1, s2) as jw +from values + ('MARTHA', 'MARHTA'), + ('DIXON', 'DICKSONX'), + ('JELLYFISH', 'SMELLYFISH') + _(s1,s2); diff --git a/Task/Jewels-and-stones/Agena/jewels-and-stones.agena b/Task/Jewels-and-stones/Agena/jewels-and-stones.agena new file mode 100644 index 0000000000..10f80d7fa3 --- /dev/null +++ b/Task/Jewels-and-stones/Agena/jewels-and-stones.agena @@ -0,0 +1,10 @@ +scope # Jewels and Stones - based on the Lua sample + local count_jewels := proc( stones :: string, jewels :: string ) :: number is + local count := 0; + for i to size stones do + count +:= size jewels @@ mfind( stones[ i ] ) # @@ is like : in Lua/Pluto + od; + return count + end; + io.write( count_jewels( "aAAbbbb", "aA" ), " ", count_jewels( "ZZ", "z" ), "\n" ) +end diff --git a/Task/Jewels-and-stones/Fortran/jewels-and-stones.f b/Task/Jewels-and-stones/Fortran/jewels-and-stones.f new file mode 100644 index 0000000000..e710eb2920 --- /dev/null +++ b/Task/Jewels-and-stones/Fortran/jewels-and-stones.f @@ -0,0 +1,90 @@ +! Jewels and Stones +! tested with Intel ifx (IFX) 2025.2.0 20250605 on Kubuntu 25.04 +! GNU Fortran (Ubuntu 14.2.0-19ubuntu2) 14.2.0 on Kubuntu 25.04 +! VSI Fortran x86-64 V8.6-001 on OpenVMS x86_64 V9.2-3 +! July 2025 +! +! THis solution contains 2 functions: JewelCount and fastJewelCount. +! The first function tries to find each letter of Jewels in Stones +! The second uses a character map built from the letters of Jewels, then +! iterates through letters of Stones, looking up these in the map and +! +!---------------------------------------------------------------------------- +! +! Return the number of Jewels that can be found in Stones. +! +function JewelCount (stones, jewels) result (NumberOfJewels) + +implicit none + +character(len=*), intent(in) :: stones, jewels ! Function arguments +integer :: NumberOfJewels ! Return value +integer :: ii, jj ! Loop indices +NumberOfJewels = 0 + +! We go through both input strings using a nested loop +! so it runs in O(len(jewels) * len(stones)) +! Is certainly good enough for short input strings. +! See below for faster version. +! +do jj=1, len (stones) + do ii=1, len (jewels) + if (stones(jj:jj) .eq. jewels(ii:ii)) then + NumberOfJewels = NumberOfJewels + 1 + EXIT ! letters in "jewels" are unique. Dont proceed. + end if + end do +end do + +end function JewelCount ! ====================================== + +! +! This function does the same as above function JewelCount. +! It might be faster for very long input "stones". +! It First creates a map of all letters in "jewels", then +! it adds one for each letter of "stones" found therein. +! works in O(len(jewels) + len(stones)) +! +function fasterJewelCount (stones, jewels) result (NumberOfJewels) +implicit none +integer, parameter :: maxChar=128 ! sufficient for A-Z,a-z +character(len=*), intent(in) :: stones, jewels ! Function arguments +integer :: NumberOfJewels ! Return value +integer :: ii ! Loop index +integer :: ic +integer :: jMap(maxChar) = 0 + +NumberOfJewels = 0 + +! Insert letter of "jewels" into the map +do ii=1, len (jewels) + ic = ichar (jewels(ii:ii)) + if (ic >=1 .and. ic <= maxChar) then ! never trust correctness of input + jMap(ic) = 1 ! Assuming all letters of "jewels" appear only once + end if +end do + +! add one for each letter of "jewels" that can be found in the map +do ii=1, len (stones) + ic = ichar (stones(ii:ii)) + if (ic >=1 .and. ic <= maxChar) then ! better safe than sorry + NumberOfJewels = NumberOfJewels + jMap(ic) + end if +end do + +end function fasterJewelCount + +! +! A little main program demonstrates usage of functions JewelCount and fastJewelCOunt +! +program progCountJewels + +implicit none +integer, external :: JewelCount, fasterJewelCount + +print *, JewelCount ('aAAbbbb', 'aA') ! expect 3 +print *, JewelCount ('ZZ', 'az') ! expect 0 +print *, fasterJewelCount ('aAAbbbb', 'aA') ! expect 3 +print *, fasterJewelCount ('ZZ', 'az') ! expect 0 + +end program progCountJewels diff --git a/Task/Jewels-and-stones/Icon/jewels-and-stones.icon b/Task/Jewels-and-stones/Icon/jewels-and-stones.icon new file mode 100644 index 0000000000..c02a2d3929 --- /dev/null +++ b/Task/Jewels-and-stones/Icon/jewels-and-stones.icon @@ -0,0 +1,10 @@ +procedure main() + write(countjewels("aAAbbbb", "aA")) + write(countjewels("ZZ", "z")) +end + +procedure countjewels(s,j) + n := 0 + s ? every upto(cset(j)) do n +:= 1 + return n +end diff --git a/Task/Jewels-and-stones/Lua/jewels-and-stones.lua b/Task/Jewels-and-stones/Lua/jewels-and-stones.lua index 2a9919d828..8ed82da928 100644 --- a/Task/Jewels-and-stones/Lua/jewels-and-stones.lua +++ b/Task/Jewels-and-stones/Lua/jewels-and-stones.lua @@ -1,8 +1,7 @@ function count_jewels(s, j) local count = 0 for i=1,#s do - local c = s:sub(i,i) - if string.match(j, c) then + if j:match(s:sub(i,i)) then count = count + 1 end end diff --git a/Task/Jewels-and-stones/Pluto/jewels-and-stones.pluto b/Task/Jewels-and-stones/Pluto/jewels-and-stones.pluto new file mode 100644 index 0000000000..f8b9b96fc4 --- /dev/null +++ b/Task/Jewels-and-stones/Pluto/jewels-and-stones.pluto @@ -0,0 +1,12 @@ +do -- Jewels and Stones - translated from the Lua sample, using a few of Pluto's new features + local function count_jewels(s, j) + local count = 0 + for i=1,#s do + if j:match(s[i]) then + ++ count + end + end + return count + end + io.write( $"{count_jewels('aAAbbbb', 'aA')} {count_jewels('ZZ', 'z')}\n" ) +end diff --git a/Task/JortSort/YAMLScript/jortsort.ys b/Task/JortSort/YAMLScript/jortsort.ys new file mode 100644 index 0000000000..4e99508d1d --- /dev/null +++ b/Task/JortSort/YAMLScript/jortsort.ys @@ -0,0 +1,8 @@ +!YS-v0 + +defn main(*array): + array =: array:V + say: + if array == array:sort: + + "$array is sorted" + "$array is not sorted" diff --git a/Task/Josephus-problem/OxygenBasic/josephus-problem.basic b/Task/Josephus-problem/OxygenBasic/josephus-problem.basic new file mode 100644 index 0000000000..748b7954e0 --- /dev/null +++ b/Task/Josephus-problem/OxygenBasic/josephus-problem.basic @@ -0,0 +1,20 @@ +uses console + +int n, k +n = 41 'prisoners +k = 3 'order of execution + +function Josephus(n as int, k as int, m as int) as int + int lm, i + + lm = m + for i = m + 1 to n + lm = (lm + k) mod i + next + return lm +end function + +printl "n = " n chr(9) "k = " k chr(9) "final survivor = " Josephus(n, k, 0) + +printl cr "Enter ..." +waitkey diff --git a/Task/Josephus-problem/Pluto/josephus-problem.pluto b/Task/Josephus-problem/Pluto/josephus-problem.pluto new file mode 100644 index 0000000000..c6e845904a --- /dev/null +++ b/Task/Josephus-problem/Pluto/josephus-problem.pluto @@ -0,0 +1,34 @@ +local fmt = require "fmt" + +local function josephus(n, k, m) + if k <= 0 or m <= 0 or n <= k or n <= m then + error("one or more parameters are invalid") + end + local killed = {} + local survived = {} + for i = 1, n do survived[i] = i - 1 end + local start = k + while true do + local finish = #survived + local i = start + local deleted = 0 + while i <= finish do + killed:insert(survived:remove(i - deleted)) + if #survived == m then return {survived, killed} end + ++deleted + i += k + end + start = i - finish + end + return {survived, killed} +end + +local triples = { {5, 2, 1}, {41, 3, 1}, {41, 3, 3} } +for triples as triple do + local [n, k, m] = triple + print($"Prisoners = {n}, Step = {k}, Survivors = {m}") + local sk = josephus(n, k, m) + print($"Survived : {fmt.swrite(sk[1])}") + print($"Kill order : {fmt.swrite(sk[2])}") + print() +end diff --git a/Task/Josephus-problem/Prolog/josephus-problem-1.pro b/Task/Josephus-problem/Prolog/josephus-problem-1.pro new file mode 100644 index 0000000000..5a4a0ece7d --- /dev/null +++ b/Task/Josephus-problem/Prolog/josephus-problem-1.pro @@ -0,0 +1,15 @@ +josephus(N, K, Survivors) :- josephus(N, K, 1, Survivors). + +:- table josephus/4. +josephus(N, K, M, Survivors) :- + K > 0, + N > 0, + N0 is N - 1, + ( M = N + -> numlist(0, N0, Survivors) + ; josephus(N0, K, M, Survivors0), + findall(Survivor, ( + member(Survivor0, Survivors0), + Survivor is (Survivor0 + K) mod N + ), Survivors) + ). diff --git a/Task/Josephus-problem/Prolog/josephus-problem-2.pro b/Task/Josephus-problem/Prolog/josephus-problem-2.pro new file mode 100644 index 0000000000..1229e75fd9 --- /dev/null +++ b/Task/Josephus-problem/Prolog/josephus-problem-2.pro @@ -0,0 +1,5 @@ +?- josephus(41, 3, Survivors). +Survivors = [30]. + +?- josephus(41, 3, 5, Survivors). +Survivors = [3, 15, 21, 30, 34]. diff --git a/Task/Josephus-problem/QBasic/josephus-problem.basic b/Task/Josephus-problem/QBasic/josephus-problem.basic index a67a59158c..693968f883 100644 --- a/Task/Josephus-problem/QBasic/josephus-problem.basic +++ b/Task/Josephus-problem/QBasic/josephus-problem.basic @@ -1,12 +1,14 @@ -FUNCTION josephus (n, k, m) -lm = m -FOR i = m + 1 TO n - lm = (lm + k) MOD i -NEXT i -josephus = lm -END FUNCTION +DECLARE FUNCTION josephus! (n!, k!, m!) n = 41 k = 3 PRINT "n = "; n, "k = "; k, "final survivor = "; josephus(n, k, 0) END + +FUNCTION josephus (n, k, m) + lm = m + FOR i = m + 1 TO n + lm = (lm + k) MOD i + NEXT i + josephus = lm +END FUNCTION diff --git a/Task/Josephus-problem/Quite-BASIC/josephus-problem-1.basic b/Task/Josephus-problem/Quite-BASIC/josephus-problem.basic similarity index 100% rename from Task/Josephus-problem/Quite-BASIC/josephus-problem-1.basic rename to Task/Josephus-problem/Quite-BASIC/josephus-problem.basic diff --git a/Task/Josephus-problem/Run-BASIC/josephus-problem-1.basic b/Task/Josephus-problem/Run-BASIC/josephus-problem-1.basic new file mode 100644 index 0000000000..8963242dc5 --- /dev/null +++ b/Task/Josephus-problem/Run-BASIC/josephus-problem-1.basic @@ -0,0 +1,16 @@ +n = 41 +k = 3 +print "n = "; n; " k = "; k; " final survivor = "; josephus(n, k, 0) +end + +function josephus(n, k, m) + lm = m + for i = m + 1 to n + ' In Run BASIC there is no MOD operator + lm = lm + k + lm = lm - int(lm / i) * i + ' In Just Basic / Liberty BASIC it could be used + 'lm = (lm + k) mod i + next i + josephus = lm +end function diff --git a/Task/Josephus-problem/Quite-BASIC/josephus-problem-2.basic b/Task/Josephus-problem/Run-BASIC/josephus-problem-2.basic similarity index 100% rename from Task/Josephus-problem/Quite-BASIC/josephus-problem-2.basic rename to Task/Josephus-problem/Run-BASIC/josephus-problem-2.basic diff --git a/Task/Josephus-problem/Wren/josephus-problem.wren b/Task/Josephus-problem/Wren/josephus-problem.wren index e6d1c6effb..44f218cfd4 100644 --- a/Task/Josephus-problem/Wren/josephus-problem.wren +++ b/Task/Josephus-problem/Wren/josephus-problem.wren @@ -24,7 +24,7 @@ for (triple in triples) { var n = triple[0] var k = triple[1] var m = triple[2] - System.print("Prisoners = %(n), Step = %(m), Survivors = %(m)") + System.print("Prisoners = %(n), Step = %(k), Survivors = %(m)") var sk = josephus.call(n, k, m) System.print("Survived : %(sk[0])") System.print("Kill order : %(sk[1])") diff --git a/Task/Josephus-problem/XBasic/josephus-problem.basic b/Task/Josephus-problem/XBasic/josephus-problem.basic new file mode 100644 index 0000000000..5cff018dee --- /dev/null +++ b/Task/Josephus-problem/XBasic/josephus-problem.basic @@ -0,0 +1,21 @@ +PROGRAM "Josephus problem" +VERSION "0.0000" + +DECLARE FUNCTION Entry () +DECLARE FUNCTION Josephus (n, k, m) + +FUNCTION Entry () + n = 41 'prisoners + k = 3 'order of execution + + PRINT "n = "; n, "k = "; k, "final survivor = "; Josephus(n, k, 0) +END FUNCTION + +FUNCTION Josephus (n, k, m) + lm = m + FOR i = m + 1 TO n + lm = (lm + k) MOD i + NEXT + RETURN lm +END FUNCTION +END PROGRAM diff --git a/Task/Julia-set/EasyLang/julia-set.easy b/Task/Julia-set/EasyLang/julia-set.easy index 44a8af429b..45f74fce52 100644 --- a/Task/Julia-set/EasyLang/julia-set.easy +++ b/Task/Julia-set/EasyLang/julia-set.easy @@ -6,7 +6,7 @@ for y = 0 to 299 : for x = 0 to 299 gcolor3 0 0 0 for iter = 0 to 127 if zx * zx + zy * zy > 4 - gcolor3 iter / 16 0 0 + gcolor3 iter * 5 0 0 break 1 . h = zx * zx - zy * zy + cx diff --git a/Task/Jump-anywhere/Koka/jump-anywhere.koka b/Task/Jump-anywhere/Koka/jump-anywhere.koka new file mode 100644 index 0000000000..ec7e33dcfc --- /dev/null +++ b/Task/Jump-anywhere/Koka/jump-anywhere.koka @@ -0,0 +1,40 @@ +effect exit + final ctl exit(a: a): b + +fun find-first(): string + with handler + final ctl exit(a: string) a + return(x) "not found" + for(0, 10) fn(i) + if i == 9 then exit("Found 9") + +effect loop + final ctl lbreak(): () + final ctl lcontinue(): () + +fun loop(check: () -> bool, body: () -> ()): () + if check() then + val next = handle(body) + final ctl lbreak() (fn() ()) + final ctl lcontinue() (fn() loop(check, body)) // Continue the loop + return(x) (fn() loop(check, body)) + next() + else + () + +fun main() + find-first().println + var i := 0 + loop { i < 10 } { + i := i + 1 + // We can early return from the inner lambda (continue) + if i == 4 then return () + // Adding local breaks could be done by returning `True` / `False`: + // This would require us to always return `True` if we want to continue + // The following are non-local: + // They can be used in nested calls to exit from the innermost loop on the stack. + if i == 5 then lcontinue() + if i == 8 then lbreak() + println(i) + } + println(i) diff --git a/Task/K-d-tree/Elixir/k-d-tree.ex b/Task/K-d-tree/Elixir/k-d-tree.ex new file mode 100644 index 0000000000..2f6496a7a5 --- /dev/null +++ b/Task/K-d-tree/Elixir/k-d-tree.ex @@ -0,0 +1,262 @@ +defmodule KDTree do + @moduledoc """ + K-D Tree implementation for nearest neighbor search in k-dimensional space. + """ + + # Tree data structure + # {:node, value, left, right} | :empty + # KDTree: %{dims: [function], tree: tree} + + defstruct dims: [], tree: :empty + + @doc """ + Create an empty k-d tree with the given dimensional accessors. + """ + def empty(dims) do + %KDTree{dims: dims, tree: :empty} + end + + @doc """ + Create a k-d tree with a single value. + """ + def singleton(dims, value) do + empty(dims) |> insert(value) + end + + @doc """ + Insert a value into a k-d tree. + """ + def insert(%KDTree{dims: dims, tree: tree} = kdtree, value) do + cyclic_dims = Stream.cycle(dims) + new_tree = ins(cyclic_dims, tree, value) + %{kdtree | tree: new_tree} + end + + defp ins(_dims, :empty, value) do + {:node, value, :empty, :empty} + end + + defp ins(dims, {:node, split, left, right}, value) do + [d] = Enum.take(dims, 1) + remaining_dims = Stream.drop(dims, 1) + + if d.(value) < d.(split) do + {:node, split, ins(remaining_dims, left, value), right} + else + {:node, split, left, ins(remaining_dims, right, value)} + end + end + + @doc """ + Create a k-d tree from a list using the median-finding algorithm. + """ + def from_list(dims, values) do + cyclic_dims = Stream.cycle(dims) + tree = f_list(cyclic_dims, values) + %KDTree{dims: dims, tree: tree} + end + + defp f_list(_dims, []) do + :empty + end + + defp f_list(dims, values) do + [d] = Enum.take(dims, 1) + remaining_dims = Stream.drop(dims, 1) + + sorted = Enum.sort_by(values, d) + length = length(sorted) + mid_index = div(length, 2) + + {lower, higher} = Enum.split(sorted, mid_index) + + case higher do + [] -> + :empty + [median | rest] -> + {:node, median, f_list(remaining_dims, lower), f_list(remaining_dims, rest)} + end + end + + @doc """ + Create a k-d tree from a list by repeatedly inserting values. + Faster than median-finding but can create unbalanced trees. + """ + def from_list_linear(dims, values) do + Enum.reduce(values, empty(dims), &insert(&2, &1)) + end + + @doc """ + Find the nearest value to a given value. + Returns {nearest_value_or_nil, nodes_visited}. + """ + def nearest(%KDTree{dims: dims, tree: tree}, value) do + cyclic_dims = Stream.cycle(dims) + near(cyclic_dims, tree, value, dims) + end + + defp near(_dims, :empty, _value, _all_dims) do + {nil, 1} + end + + defp near(_dims, {:node, split, :empty, :empty}, _value, _all_dims) do + {split, 1} + end + + defp near(dims, {:node, split, left, right}, value, all_dims) do + [d] = Enum.take(dims, 1) + remaining_dims = Stream.drop(dims, 1) + + split_dist = sqr_dist(all_dims, value, split) + hyperplane_dist = square(d.(value) - d.(split)) + + {best_left, left_count} = near(remaining_dims, left, value, all_dims) + {best_right, right_count} = near(remaining_dims, right, value, all_dims) + + {{maybe_this_best, this_count}, {maybe_other_best, other_count}} = + if d.(value) < d.(split) do + {{best_left, left_count}, {best_right, right_count}} + else + {{best_right, right_count}, {best_left, left_count}} + end + + case maybe_this_best do + nil -> + count = 1 + this_count + other_count + case maybe_other_best do + nil -> + {split, count} + other_best -> + if sqr_dist(all_dims, value, other_best) < split_dist do + {other_best, count} + else + {split, count} + end + end + + this_best -> + this_best_dist = sqr_dist(all_dims, value, this_best) + {best, best_dist} = + if split_dist < this_best_dist do + {split, split_dist} + else + {this_best, this_best_dist} + end + + if best_dist < hyperplane_dist do + {best, 1 + this_count} + else + count = 1 + this_count + other_count + case maybe_other_best do + nil -> + {best, count} + other_best -> + if best_dist < sqr_dist(all_dims, value, other_best) do + {best, count} + else + {other_best, count} + end + end + end + end + end + + @doc """ + Calculate squared Euclidean distance between two points. + """ + def sqr_dist(dims, a, b) do + a_values = Enum.map(dims, & &1.(a)) + b_values = Enum.map(dims, & &1.(b)) + + Enum.zip(a_values, b_values) + |> Enum.map(fn {x, y} -> square(x - y) end) + |> Enum.sum() + end + + defp square(x), do: x * x + + @doc """ + Dimensional accessors for 2-tuple. + """ + def tuple_2d do + [&elem(&1, 0), &elem(&1, 1)] + end + + @doc """ + Dimensional accessors for 3-tuple. + """ + def tuple_3d do + [&elem(&1, 0), &elem(&1, 1), &elem(&1, 2)] + end + + @doc """ + Naive nearest search for verification. + """ + def linear_nearest(_dims, _value, []) do + nil + end + + def linear_nearest(dims, value, [head | tail]) do + Enum.min_by([head | tail], &sqr_dist(dims, value, &1)) + end + + @doc """ + Print search results. + """ + def print_results(point, {nearest, visited}, dims) do + case nearest do + nil -> + IO.puts("Could not find nearest.") + value -> + dist = :math.sqrt(sqr_dist(dims, point, value)) + IO.puts("Point: #{inspect(point)}") + IO.puts("Nearest: #{inspect(value)}") + IO.puts("Distance: #{dist}") + IO.puts("Visited: #{visited}") + IO.puts("") + end + end + + @doc """ + Generate random 3D points. + """ + def random_3d_points(n, {min_x, min_y, min_z}, {max_x, max_y, max_z}) do + for _ <- 1..n do + { + min_x + :rand.uniform() * (max_x - min_x), + min_y + :rand.uniform() * (max_y - min_y), + min_z + :rand.uniform() * (max_z - min_z) + } + end + end + + @doc """ + Main demonstration function. + """ + def main do + # Wikipedia example + wiki_values = [{2, 3}, {5, 4}, {9, 6}, {4, 7}, {8, 1}, {7, 2}] + wiki_tree = from_list(tuple_2d(), wiki_values) + wiki_search = {9, 2} + wiki_nearest = nearest(wiki_tree, wiki_search) + + IO.puts("Wikipedia example:") + print_results(wiki_search, wiki_nearest, tuple_2d()) + + # Random 3D example + :rand.seed(:exsplus, {1, 2, 3}) # Seed for reproducible results + rand_range = {{0, 0, 0}, {1000, 1000, 1000}} + rand_values = random_3d_points(1000, elem(rand_range, 0), elem(rand_range, 1)) + rand_search = hd(random_3d_points(1, elem(rand_range, 0), elem(rand_range, 1))) + rand_tree = from_list(tuple_3d(), rand_values) + rand_nearest = nearest(rand_tree, rand_search) + rand_nearest_linear = linear_nearest(tuple_3d(), rand_search, rand_values) + + IO.puts("1000 random 3D points on the range of [0, 1000):") + print_results(rand_search, rand_nearest, tuple_3d()) + IO.puts("Confirm naive nearest:") + IO.puts("#{inspect(rand_nearest_linear)}") + end +end + +KDTree.main() diff --git a/Task/K-d-tree/Swift/k-d-tree.swift b/Task/K-d-tree/Swift/k-d-tree.swift new file mode 100644 index 0000000000..b7aa48ec28 --- /dev/null +++ b/Task/K-d-tree/Swift/k-d-tree.swift @@ -0,0 +1,203 @@ +import Foundation + +// point is a k-dimensional point. +typealias Point = [Double] + +extension Point { + // sqd returns the square of the euclidean distance. + func sqd(to q: Point) -> Double { + var sum: Double = 0 + for dim in 0.. HyperRect { + return HyperRect(min: Array(self.min), max: Array(self.max)) + } +} + +class KDTree { + let root: KDNode? + let bounds: HyperRect + + init(root: KDNode?, bounds: HyperRect) { + self.root = root + self.bounds = bounds + } + + // nearest. find nearest neighbor. return values are: + // nearest neighbor - the point within the tree that is nearest p. + // square of the distance to that point. + // a count of the nodes visited in the search. + func nearest(to target: Point) -> (nearest: Point?, distSqd: Double, nodesVisited: Int) { + return nn(kd: root, target: target, hr: bounds, maxDistSqd: .infinity) + } + + // algorithm is table 6.4 from the paper + private func nn(kd: KDNode?, target: Point, hr: HyperRect, + maxDistSqd: Double) -> (nearest: Point?, distSqd: Double, nodesVisited: Int) { + if kd == nil { + return (nil, .infinity, 0) + } + + var nodesVisited = 1 + let s = kd!.split + let pivot = kd!.domElt + var leftHr = hr.copy() + var rightHr = hr.copy() + leftHr.max[s] = pivot[s] + rightHr.min[s] = pivot[s] + let targetInLeft = target[s] <= pivot[s] + + let (nearerKd, nearerHr, furtherKd, furtherHr): (KDNode?, HyperRect, KDNode?, HyperRect) + if targetInLeft { + nearerKd = kd!.left + nearerHr = leftHr + furtherKd = kd!.right + furtherHr = rightHr + } else { + nearerKd = kd!.right + nearerHr = rightHr + furtherKd = kd!.left + furtherHr = leftHr + } + + var (nearest, distSqd, nv) = nn(kd: nearerKd, target: target, hr: nearerHr, maxDistSqd: maxDistSqd) + nodesVisited += nv + + var maxDist = maxDistSqd + if distSqd < maxDist { + maxDist = distSqd + } + + var d = pivot[s] - target[s] + d *= d + if d > maxDist { + return (nearest, distSqd, nodesVisited) + } + + d = pivot.sqd(to: target) + if d < distSqd { + nearest = pivot + distSqd = d + maxDist = distSqd + } + + let (tempNearest, tempSqd, nv2) = nn(kd: furtherKd, target: target, hr: furtherHr, maxDistSqd: maxDist) + nodesVisited += nv2 + + if tempSqd < distSqd { + nearest = tempNearest + distSqd = tempSqd + } + + return (nearest, distSqd, nodesVisited) + } +} + +// Helper function to create a new KD tree +func newKd(pts: [Point], bounds: HyperRect) -> KDTree { + func nk2(exset: [Point], split: Int) -> KDNode? { + if exset.isEmpty { + return nil + } + + // Sort points by the split dimension + let sortedPoints = exset.sorted { $0[split] < $1[split] } + var m = sortedPoints.count / 2 + let d = sortedPoints[m] + + // Find largest index of points with median value + while m+1 < sortedPoints.count && sortedPoints[m+1][split] == d[split] { + m += 1 + } + + // Next split + var s2 = split + 1 + if s2 == d.count { + s2 = 0 + } + + return KDNode( + domElt: d, + split: split, + left: nk2(exset: Array(sortedPoints[0.. Point { + var p = Point(repeating: 0, count: dim) + for d in 0.. [Point] { + var p = [Point](repeating: [], count: n) + for i in 0.. 0) try writer.writeAll(", "); + try writer.print("{d:.1}", .{coord}); + } + try writer.writeAll("]"); + } +}; + +const KDTreeNode = struct { + point: Point, + dim: usize, + left: ?*KDTreeNode, + right: ?*KDTreeNode, + allocator: Allocator, + + const Self = @This(); + + pub fn init(allocator: Allocator, points: []Point, dim: usize) !*Self { + const points_len = points.len; + + if (points_len == 1) { + const node = try allocator.create(Self); + node.* = Self{ + .point = try points[0].clone(), + .dim = dim, + .left = null, + .right = null, + .allocator = allocator, + }; + return node; + } + + // Split around the median + const pivot = try quickselectBy(points, points_len / 2, dim, allocator); + + const left = if (points_len >= 2) + try Self.init(allocator, points[0..points_len / 2], (dim + 1) % pivot.coords.len) + else + null; + + const right = if (points_len >= 3) + try Self.init(allocator, points[points_len / 2 + 1..points_len], (dim + 1) % pivot.coords.len) + else + null; + + const node = try allocator.create(Self); + node.* = Self{ + .point = pivot, + .dim = dim, + .left = left, + .right = right, + .allocator = allocator, + }; + return node; + } + + pub fn deinit(self: *Self) void { + self.point.deinit(); + if (self.left) |left| { + left.deinit(); + self.allocator.destroy(left); + } + if (self.right) |right| { + right.deinit(); + self.allocator.destroy(right); + } + } + + pub fn findNearestNeighbor(self: *const Self, point: Point, allocator: Allocator) !struct { point: Point, n_visited: usize } { + const diff = try point.sub(self.point, allocator); + defer diff.deinit(); + const initial_dist_sq = diff.normSq(); + + const result = try self.findNearestNeighborHelper(point, self.point, initial_dist_sq, 1, allocator); + return .{ .point = try result.point.clone(), .n_visited = result.n_visited }; + } + + fn findNearestNeighborHelper( + self: *const Self, + point: Point, + best: Point, + best_dist_sq: f32, + n_visited: usize, + allocator: Allocator, + ) !struct { point: Point, n_visited: usize } { + var my_best = best; + var my_best_dist_sq = best_dist_sq; + var my_n_visited = n_visited; + + // Examine the near side first + if (self.point.coords[self.dim] < point.coords[self.dim] and self.right != null) { + const result = try self.right.?.findNearestNeighborHelper( + point, my_best, my_best_dist_sq, my_n_visited, allocator + ); + my_best = result.point; + my_n_visited = result.n_visited; + } else if (self.left != null) { + const result = try self.left.?.findNearestNeighborHelper( + point, my_best, my_best_dist_sq, my_n_visited, allocator + ); + my_best = result.point; + my_n_visited = result.n_visited; + } + + // Distance along this node's axis + const axis_dist_sq = std.math.pow(f32, self.point.coords[self.dim] - point.coords[self.dim], 2); + if (axis_dist_sq <= my_best_dist_sq) { + // Check if this node is closer than current best + const self_diff = try point.sub(self.point, allocator); + defer self_diff.deinit(); + const self_dist_sq = self_diff.normSq(); + + if (self_dist_sq < my_best_dist_sq) { + my_best = self.point; + my_best_dist_sq = self_dist_sq; + } + + my_n_visited += 1; + + // Check the far side of the split + if (self.point.coords[self.dim] < point.coords[self.dim] and self.left != null) { + const result = try self.left.?.findNearestNeighborHelper( + point, my_best, my_best_dist_sq, my_n_visited, allocator + ); + my_best = result.point; + my_n_visited = result.n_visited; + } else if (self.right != null) { + const result = try self.right.?.findNearestNeighborHelper( + point, my_best, my_best_dist_sq, my_n_visited, allocator + ); + my_best = result.point; + my_n_visited = result.n_visited; + } + } + + return .{ .point = my_best, .n_visited = my_n_visited }; + } +}; + +fn quickselectBy(arr: []Point, position: usize, dim: usize, allocator: Allocator) !Point { + if (arr.len == 1) return try arr[0].clone(); + + var rng = std.Random.DefaultPrng.init(@intCast(std.time.timestamp())); + const random = rng.random(); + + var pivot_index = random.uintLessThan(usize, arr.len); + pivot_index = partitionBy(arr, pivot_index, dim); + + const array_len = arr.len; + if (position == pivot_index) { + return try arr[position].clone(); + } else if (position < pivot_index) { + return quickselectBy(arr[0..pivot_index], position, dim, allocator); + } else { + return quickselectBy(arr[pivot_index + 1..array_len], position - pivot_index - 1, dim, allocator); + } +} + +fn partitionBy(arr: []Point, pivot_index: usize, dim: usize) usize { + const array_len = arr.len; + std.mem.swap(Point, &arr[pivot_index], &arr[array_len - 1]); + var store_index: usize = 0; + + for (0..array_len - 1) |i| { + if (arr[i].coords[dim] < arr[array_len - 1].coords[dim]) { + std.mem.swap(Point, &arr[i], &arr[store_index]); + store_index += 1; + } + } + std.mem.swap(Point, &arr[array_len - 1], &arr[store_index]); + return store_index; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + var rng = std.Random.DefaultPrng.init(@intCast(std.time.timestamp())); + const random = rng.random(); + + // Wikipedia example + const wp_coords = [_][]const f32{ + &[_]f32{ 2.0, 3.0 }, + &[_]f32{ 5.0, 4.0 }, + &[_]f32{ 9.0, 6.0 }, + &[_]f32{ 4.0, 7.0 }, + &[_]f32{ 8.0, 1.0 }, + &[_]f32{ 7.0, 2.0 }, + }; + + var wp_points = ArrayList(Point).init(allocator); + defer { + for (wp_points.items) |point| { + point.deinit(); + } + wp_points.deinit(); + } + + for (wp_coords) |coords| { + try wp_points.append(try Point.init(allocator, coords)); + } + + const wp_tree = try KDTreeNode.init(allocator, wp_points.items, 0); + defer { + wp_tree.deinit(); + allocator.destroy(wp_tree); + } + + const wp_target = try Point.init(allocator, &[_]f32{ 9.0, 2.0 }); + defer wp_target.deinit(); + + const wp_result = try wp_tree.findNearestNeighbor(wp_target, allocator); + defer wp_result.point.deinit(); + + const wp_diff = try wp_result.point.sub(wp_target, allocator); + defer wp_diff.deinit(); + + print("Wikipedia example data:\n", .{}); + print("Point: {}\n", .{wp_target}); + print("Nearest neighbor: {}\n", .{wp_result.point}); + print("Distance: {d:.6}\n", .{@sqrt(wp_diff.normSq())}); + print("Nodes visited: {}\n", .{wp_result.n_visited}); + + // Randomly generated 3D points + const n_random = 1000; + var random_points = ArrayList(Point).init(allocator); + defer { + for (random_points.items) |point| { + point.deinit(); + } + random_points.deinit(); + } + + for (0..n_random) |_| { + const coords = [_]f32{ + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + }; + try random_points.append(try Point.init(allocator, &coords)); + } + + const start_cons_time = std.time.nanoTimestamp(); + const random_tree = try KDTreeNode.init(allocator, random_points.items, 0); + const cons_time = std.time.nanoTimestamp() - start_cons_time; + defer { + random_tree.deinit(); + allocator.destroy(random_tree); + } + + print("1,000 3d points (Construction time: {}ms)\n", .{@divTrunc(cons_time, 1_000_000)}); + + const random_target_coords = [_]f32{ + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + }; + const random_target = try Point.init(allocator, &random_target_coords); + defer random_target.deinit(); + + const random_result = try random_tree.findNearestNeighbor(random_target, allocator); + defer random_result.point.deinit(); + + const random_diff = try random_result.point.sub(random_target, allocator); + defer random_diff.deinit(); + + print("Point: {}\n", .{random_target}); + print("Nearest neighbor: {}\n", .{random_result.point}); + print("Distance: {d:.6}\n", .{@sqrt(random_diff.normSq())}); + print("Nodes visited: {}\n", .{random_result.n_visited}); + + // Benchmark search time + const n_searches = 1000; + var random_targets = ArrayList(Point).init(allocator); + defer { + for (random_targets.items) |point| { + point.deinit(); + } + random_targets.deinit(); + } + + for (0..n_searches) |_| { + const coords = [_]f32{ + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + (random.float(f32) - 0.5) * 1000.0, + }; + try random_targets.append(try Point.init(allocator, &coords)); + } + + const start_search_time = std.time.nanoTimestamp(); + var total_n_visited: usize = 0; + for (random_targets.items) |target| { + const result = try random_tree.findNearestNeighbor(target, allocator); + defer result.point.deinit(); + total_n_visited += result.n_visited; + } + const search_time = std.time.nanoTimestamp() - start_search_time; + + print("Visited an average of {d:.1} nodes on {} searches in {} ms\n", .{ + @as(f32, @floatFromInt(total_n_visited)) / @as(f32, @floatFromInt(n_searches)), + n_searches, + @divTrunc(search_time, 1_000_000), + }); +} diff --git a/Task/Kaprekar-numbers/ALGOL-68/kaprekar-numbers.alg b/Task/Kaprekar-numbers/ALGOL-68/kaprekar-numbers.alg index 935d7587ae..f8294ca17d 100644 --- a/Task/Kaprekar-numbers/ALGOL-68/kaprekar-numbers.alg +++ b/Task/Kaprekar-numbers/ALGOL-68/kaprekar-numbers.alg @@ -8,6 +8,9 @@ PROC is kaprekar = ( INT n )BOOL: ELIF n = 1 THEN # 1 is defined to be a Kaprekar number # TRUE + ELIF n MOD 9 > 1 THEN + # n can't be Kaprekar if n MOD 9 is not 0 or 1 # + FALSE ELSE # n is a Kaprekar number if the digits of its # # square can be partitioned into two numbers # diff --git a/Task/Kaprekar-numbers/Agena/kaprekar-numbers.agena b/Task/Kaprekar-numbers/Agena/kaprekar-numbers.agena new file mode 100644 index 0000000000..029d913842 --- /dev/null +++ b/Task/Kaprekar-numbers/Agena/kaprekar-numbers.agena @@ -0,0 +1,42 @@ +scope # find some Kaprekar numbers + + # returns TRUE if n is a Kaprekar number, FALSE otherwise + local constant isKaprekar := proc( n :: number ) :: boolean is + if n < 1 then # 0 and -ve numbers are not Kaprekar numbers + return false + elif n = 1 then # 1 is defined to be a Kaprekar number + return true + elif n mod 9 > 1 then # can't be Kapreker - see notes on the Maple sample + return false + else + # n is a Kaprekar number if the digits of its + # square can be partitioned into two numbers + # that sum to n + local constant nSquared := n * n; + local powerOfTen := 10; + local result := false; + while nSquared > powerOfTen and not result do + local constant leftPart := nSquared \ powerOfTen; + local constant rightPart := nSquared mod powerOfTen; + result := ( leftPart + rightPart ) = n and rightPart <> 0; + powerOfTen *:= 10 + od; + return result + fi + end + + # find the Kaprekar numbers up to 1 000 000 + # printing all those below 10 000 + scope + local constant maxNumber := 1_000_000; + local kn := seq(); + for n to maxNumber do + if isKaprekar( n ) then + kn[ size kn + 1 ] := n + fi + od; + printf( "Kaprekar numbers below 10 000:" ); + for i while kn[ i ] < 10_000 do printf( " %d", kn[ i ] ) od; + printf( "\nThere are %d Kaprekar numbers below %d\n", size kn, maxNumber ) + end +end diff --git a/Task/Kaprekar-numbers/Pluto/kaprekar-numbers.pluto b/Task/Kaprekar-numbers/Pluto/kaprekar-numbers.pluto new file mode 100644 index 0000000000..926e041de5 --- /dev/null +++ b/Task/Kaprekar-numbers/Pluto/kaprekar-numbers.pluto @@ -0,0 +1,43 @@ +do -- find some Kaprekar numbers + + local fmt = require( "fmt" ) -- RC formatting module + + -- returns true if n is a Kaprekar number, false otherwise + local function isKaprekar( n ) + if n < 1 then -- 0 and -ve numbers are not Kaprekar numbers + return false + elseif n == 1 then -- 1 is defined to be a Kaprekar number + return true + elseif n % 9 > 1 then -- cant be Kapreker - see notes on the Maple sample + return false + else + -- n is a Kaprekar number if the digits of its + -- square can be partitioned into two numbers + -- that sum to n + local nSquared = n * n + local powerOfTen = 10 + local result = false + while nSquared > powerOfTen and not result do + local leftPart = nSquared // powerOfTen + local rightPart = nSquared % powerOfTen + result = ( ( leftPart + rightPart ) == n and rightPart != 0 ) + powerOfTen *= 10 + end + return result + end + end + + -- count the Kaprekar numbers up to 1 000 000 printing all those below 10 000 + do + local maxNumber = 1_000_000 + local kn = {} + for n = 1, maxNumber do + if isKaprekar( n ) then + kn:insert( n ) + end + end + fmt.write( "Kaprekar numbers below 10 000: " ) + fmt.lwrite( kn:filtered( |v| -> v < 10_000 ), " ", "" ) + fmt.write( "\nThere are %d Kaprekar numbers below %d\n", #kn, maxNumber ) + end +end diff --git a/Task/Knapsack-problem-0-1/Zig/knapsack-problem-0-1.zig b/Task/Knapsack-problem-0-1/Zig/knapsack-problem-0-1.zig new file mode 100644 index 0000000000..90f0b6cb9e --- /dev/null +++ b/Task/Knapsack-problem-0-1/Zig/knapsack-problem-0-1.zig @@ -0,0 +1,109 @@ +const std = @import("std"); + +const Item = struct { + name: []const u8, + weight: usize, + value: usize, +}; + +fn knapsack01_dyn(allocator: std.mem.Allocator, items: []const Item, max_weight: usize) !std.ArrayList(*const Item) { + // Create 2D array for dynamic programming + var best_value = try allocator.alloc([]usize, items.len + 1); + defer allocator.free(best_value); + + for (best_value) |*row| { + row.* = try allocator.alloc(usize, max_weight + 1); + } + defer { + for (best_value) |row| { + allocator.free(row); + } + } + + // Initialize with zeros + for (best_value) |row| { + @memset(row, 0); + } + + // Fill the table + for (items, 0..) |it, i| { + for (1..max_weight + 1) |w| { + if (it.weight > w) { + best_value[i + 1][w] = best_value[i][w]; + } else { + best_value[i + 1][w] = @max( + best_value[i][w], + best_value[i][w - it.weight] + it.value + ); + } + } + } + + // Backtrack to find selected items + var result = std.ArrayList(*const Item).init(allocator); + var left_weight = max_weight; + + var i: usize = items.len; + while (i > 0) : (i -= 1) { + if (best_value[i][left_weight] != best_value[i - 1][left_weight]) { + try result.append(&items[i - 1]); + left_weight -= items[i - 1].weight; + } + } + + return result; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const MAX_WEIGHT: usize = 400; + + const ITEMS = [_]Item{ + .{ .name = "map", .weight = 9, .value = 150 }, + .{ .name = "compass", .weight = 13, .value = 35 }, + .{ .name = "water", .weight = 153, .value = 200 }, + .{ .name = "sandwich", .weight = 50, .value = 160 }, + .{ .name = "glucose", .weight = 15, .value = 60 }, + .{ .name = "tin", .weight = 68, .value = 45 }, + .{ .name = "banana", .weight = 27, .value = 60 }, + .{ .name = "apple", .weight = 39, .value = 40 }, + .{ .name = "cheese", .weight = 23, .value = 30 }, + .{ .name = "beer", .weight = 52, .value = 10 }, + .{ .name = "suntancream", .weight = 11, .value = 70 }, + .{ .name = "camera", .weight = 32, .value = 30 }, + .{ .name = "T-shirt", .weight = 24, .value = 15 }, + .{ .name = "trousers", .weight = 48, .value = 10 }, + .{ .name = "umbrella", .weight = 73, .value = 40 }, + .{ .name = "waterproof trousers", .weight = 42, .value = 70 }, + .{ .name = "waterproof overclothes", .weight = 43, .value = 75 }, + .{ .name = "note-case", .weight = 22, .value = 80 }, + .{ .name = "sunglasses", .weight = 7, .value = 20 }, + .{ .name = "towel", .weight = 18, .value = 12 }, + .{ .name = "socks", .weight = 4, .value = 50 }, + .{ .name = "book", .weight = 30, .value = 10 }, + }; + + var items = try knapsack01_dyn(allocator, &ITEMS, MAX_WEIGHT); + defer items.deinit(); + + // Print in reverse order (to match original) + const stdout = std.io.getStdOut().writer(); + var i: usize = items.items.len; + while (i > 0) : (i -= 1) { + try stdout.print("{s}\n", .{items.items[i - 1].name}); + } + + // Calculate totals + var total_weight: usize = 0; + var total_value: usize = 0; + for (items.items) |item| { + total_weight += item.weight; + total_value += item.value; + } + + try stdout.print("Total weight: {}\n", .{total_weight}); + try stdout.print("Total value: {}\n", .{total_value}); +} diff --git a/Task/Knapsack-problem-Bounded/Ada/knapsack-problem-bounded.ada b/Task/Knapsack-problem-Bounded/Ada/knapsack-problem-bounded.ada new file mode 100644 index 0000000000..6c514a48cf --- /dev/null +++ b/Task/Knapsack-problem-Bounded/Ada/knapsack-problem-bounded.ada @@ -0,0 +1,143 @@ +with Ada.Text_IO; + +procedure Knapsack_Bounded is + subtype Item_Name is String (1 .. 22); + type Item_Weight is new Natural; + type Item_Value is new Natural; + type Item_Count is new Natural; + type Item_Pool is record + Name : Item_Name; + Weight : Item_Weight; + Value : Item_Value; + Count : Item_Count; + end record; + type Item_Bag is array (1 .. 22) of Item_Pool; + + Candidates : constant Item_Bag := + ( + ("map ", 9, 150, 1), + ("compass ", 13, 35, 1), + ("water ", 153, 200, 2), + ("sandwich ", 50, 60, 2), + ("glucose ", 15, 60, 2), + ("tin ", 68, 45, 3), + ("banana ", 27, 60, 3), + ("apple ", 39, 40, 3), + ("cheese ", 23, 30, 1), + ("beer ", 52, 10, 3), + ("suntan cream ", 11, 70, 1), + ("camera ", 32, 30, 1), + ("T-shirt ", 24, 15, 2), + ("trousers ", 48, 10, 2), + ("umbrella ", 73, 40, 1), + ("waterproof trousers ", 42, 70, 1), + ("waterproof overclothes", 43, 75, 1), + ("note-case ", 22, 80, 1), + ("sunglasses ", 7, 20, 1), + ("towel ", 18, 12, 2), + ("socks ", 4, 50, 1), + ("book ", 30, 10, 2) + ); + + Capacity : constant Item_Weight := 400; + Answer : Item_Bag; + + type Item_Table is + array (Item_Bag'First - 1 .. Item_Bag'Last, + Item_Weight'First .. Capacity) of Item_Value; + + Working_Table : Item_Table := (others => (others => 0)); + + procedure Fill_Table is + Item : Item_Pool; + V, Max_Value : Item_Value; + W : Item_Weight; + begin + for I in Candidates'Range loop + Item := Candidates (I); + + for J in Working_Table'Range (2) loop + Max_Value := Working_Table (I - 1, J); + + for K in 1 .. Item.Count loop + V := Item_Value (K) * Item.Value; + W := Item_Weight (K) * Item.Weight; + + if W <= J then + Max_Value := Item_Value'Max + (Max_Value, Working_Table (I - 1, J - W) + V); + end if; + end loop; + + Working_Table (I, J) := Max_Value; + end loop; + end loop; + end Fill_Table; + + procedure Trace_Answer is + Cap : Item_Weight := Capacity; + Count : Item_Count; + W, Weight : Item_Weight; + V, Max_Value : Item_Value; + begin + for I in reverse Answer'Range loop + Answer (I) := Candidates (I); + Max_Value := Working_Table (I, Cap); + Count := 0; + Weight := 0; + + for J in 1 .. Candidates (I).Count loop + W := Item_Weight (J) * Answer (I).Weight; + V := Item_Value (J) * Answer (I).Value; + if W <= Cap and then + Max_Value = Working_Table (I - 1, Cap - W) + V then + Weight := W; + Count := J; + end if; + end loop; + + Cap := Cap - Weight; + Answer (I).Count := Count; + end loop; + end Trace_Answer; + + procedure Show_Answer is + package Count_IO is new Ada.Text_IO.Integer_IO (Item_Count); + package Weight_IO is new Ada.Text_IO.Integer_IO (Item_Weight); + package Value_IO is new Ada.Text_IO.Integer_IO (Item_Value); + Item : Item_Pool; + C, Total_Items : Item_Count := 0; + W, Total_Weight : Item_Weight := 0; + V, Total_Value : Item_Value := 0; + Totals : String (Item_Name'Range) := "Totals "; + begin + for I in Answer'Range loop + Item := Answer (I); + C := Item.Count; + W := Item.Weight * Item_Weight (Item.Count); + V := Item.Value * Item_Value (Item.Count); + Total_Items := Total_Items + Item.Count; + Total_Weight := Total_Weight + W; + Total_Value := Total_Value + V; + + if C > 0 then + Ada.Text_IO.Put (Item.Name); + Count_IO.Put (C); + Weight_IO.Put (W); + Value_IO.Put (V); + Ada.Text_IO.New_Line; + end if; + end loop; + + Ada.Text_IO.Put (Totals); + Count_IO.Put (Total_Items); + Weight_IO.Put (Total_Weight); + Value_IO.Put (Total_Value); + Ada.Text_IO.New_Line; + end Show_Answer; + +begin + Fill_Table; + Trace_Answer; + Show_Answer; +end Knapsack_Bounded; diff --git a/Task/Knapsack-problem-Bounded/Fortran/knapsack-problem-bounded.f b/Task/Knapsack-problem-Bounded/Fortran/knapsack-problem-bounded.f new file mode 100644 index 0000000000..c45e4e4a0f --- /dev/null +++ b/Task/Knapsack-problem-Bounded/Fortran/knapsack-problem-bounded.f @@ -0,0 +1,184 @@ +module knapsack_mod + implicit none + + !-------------------------------------------------------------------- + ! Define an item type with a name, weight, value, and available count. + !-------------------------------------------------------------------- + type :: item + character(len=24) :: name ! Name (for display purposes) + integer :: weight ! Weight of one copy of the item + integer :: value ! Value of one copy of the item + integer :: count ! Maximum number of copies available + end type item + + !-------------------------------------------------------------------- + ! Define a parameter array of items. + !-------------------------------------------------------------------- + type(item), parameter :: items(*) = [ & + item("map ", 9, 150, 1), & + item("compass ", 13, 35, 1), & + item("water ", 153, 200, 2), & + item("sandwich ", 50, 60, 2), & + item("glucose ", 15, 60, 2), & + item("tin ", 68, 45, 3), & + item("banana ", 27, 60, 3), & + item("apple ", 39, 40, 3), & + item("cheese ", 23, 30, 1), & + item("beer ", 52, 10, 3), & + item("suntan cream ", 11, 70, 1), & + item("camera ", 32, 30, 1), & + item("T-shirt ", 24, 15, 2), & + item("trousers ", 48, 10, 2), & + item("umbrella ", 73, 40, 1), & + item("waterproof trousers ", 42, 70, 1), & + item("waterproof overclothes ", 43, 75, 1), & + item("note-case ", 22, 80, 1), & + item("sunglasses ", 7, 20, 1), & + item("towel ", 18, 12, 2), & + item("socks ", 4, 50, 1), & + item("book ", 30, 10, 2) & + ] + +contains + + !-------------------------------------------------------------------- + ! Function: knapsack + ! + ! Description: + ! Solves the bounded knapsack problem using dynamic programming. + ! This version retains a two-dimensional DP table (m) and applies + ! binary splitting to efficiently handle items available in multiple + ! copies. + ! + ! Input: + ! w - Maximum weight capacity of the knapsack. + ! + ! Output: + ! s - An integer array (of size equal to the number of items) + ! where s(i) indicates how many copies of item i are selected + ! in the optimal solution. + !-------------------------------------------------------------------- + function knapsack(w) result(s) + integer, intent(in) :: w ! Knapsack capacity + integer, allocatable :: s(:) ! Solution vector of item counts + integer, allocatable :: m(:,:) ! DP table: m(i,j) is the maximum value using items 1..i with capacity j + integer :: n ! Total number of items + integer :: i, j, v, k ! Loop indices and temporary value + + ! Variables for binary splitting of the count of an item. + integer :: available ! Remaining copies to process for the current item + integer :: r ! Current binary splitting factor + integer :: k_group ! Number of copies in the current group + integer :: group_weight ! Total weight of the current group (k_group * item weight) + integer :: group_value ! Total value of the current group (k_group * item value) + + ! Determine the number of items available. + n = size(items) + + ! Allocate the solution vector and DP table. + ! DP table m is sized from row 0 (base case: no items) to n, and column 0 to w. + allocate(s(n), m(0:n, 0:w)) + + ! Initialize both the DP table and the solution vector to 0. + m = 0 + s = 0 + + !------------------------------- + ! DP Table Construction + !------------------------------- + ! For each item i (from 1 to n), determine the best value achievable + ! with a knapsack capacity from 0 to w. + do i = 1, n + + ! First, copy the previous row into the current row. + ! This means if we do not take any of item i, the value remains as before. + do j = 0, w + m(i, j) = m(i-1, j) + end do + + ! Process item i using binary splitting: + ! Instead of iterating k from 1 to items(i)%count one by one, we split + ! the available copies into groups for an efficient "0/1 item" update. + available = items(i)%count + r = 1 + do while (available > 0) + ! Use k_group copies, which is the minimum of the current binary factor and available copies. + k_group = min(r, available) + + ! Compute group weight and value for k_group copies. + group_weight = k_group * items(i)%weight + group_value = k_group * items(i)%value + + ! Perform a 0/1 knapsack update for this group. + ! Loop backwards from capacity w down to group_weight so that each group + ! is only used once. We update row i (which already contains m(i-1, :) as baseline). + do j = w, group_weight, -1 + ! If adding this group improves the total value, update m(i,j). + v = m(i, j - group_weight) + group_value + if (v > m(i, j)) then + m(i, j) = v + end if + end do + + ! Subtract the number of copies processed and double the binary factor. + available = available - k_group + r = r * 2 + end do + + end do + + !------------------------------- + ! Backtracking to Retrieve the Solution + !------------------------------- + ! Starting from the maximum capacity and the last item, deduce how many copies + ! of each item were used in the optimal solution. + j = w + do i = n, 1, -1 + ! Store the optimal value for items 1..i with current capacity j. + v = m(i, j) + ! For item i, try every possible count from 0 to items(i)%count. + do k = 0, items(i)%count + if (j >= k * items(i)%weight) then + ! Check if the current value resulted from taking k copies of item i. + if (v == m(i-1, j - k*items(i)%weight) + k*items(i)%value) then + s(i) = k ! Record k copies for item i + j = j - k*items(i)%weight ! Decrease the remaining capacity + exit ! Proceed to the next (previous) item + end if + end if + end do + end do + + end function knapsack + +end module knapsack_mod + +program main + use knapsack_mod + implicit none + integer, allocatable :: s(:) + integer :: i, total_count, total_weight, total_value + + s = knapsack(400) + + total_count = 0 + total_weight = 0 + total_value = 0 + + write(*,'(A22 A6 A7 A6)') 'Item', 'Count', 'Weight', 'Value' + write(*,'("------------------------------------------------")') + + do i = 1, size(items) + if (s(i) > 0) then + write(*,'(A22 I5 I6 I6)') & + items(i)%name, s(i), s(i)*items(i)%weight, s(i)*items(i)%value + total_count = total_count + s(i) + total_weight = total_weight + s(i)*items(i)%weight + total_value = total_value + s(i)*items(i)%value + end if + end do + + write(*,'("------------------------------------------------")') + write(*,'(A22 I5 I6 I6)') 'Totals:', total_count, total_weight, total_value + +end program main diff --git a/Task/Knapsack-problem-Bounded/Lua/knapsack-problem-bounded.lua b/Task/Knapsack-problem-Bounded/Lua/knapsack-problem-bounded.lua new file mode 100644 index 0000000000..67c59db1c1 --- /dev/null +++ b/Task/Knapsack-problem-Bounded/Lua/knapsack-problem-bounded.lua @@ -0,0 +1,180 @@ +#!/usr/bin/env lua + +--- knapsack packing for max value under wieght limit + + -- A: use value/weight score as pre-sort + -- B: initial run with no items excluded + -- C: try combos excluding each item for best value + + +--- table of tables +-- {name weight value quantity wt/val } +items = { + {"map", 9, 150, 1}, + {"compass", 13, 35, 1}, + {"water", 153, 200, 2}, + {"sandwich", 50, 60, 2}, + {"glucose", 15, 60, 2}, + {"tin", 68, 45, 3}, + {"banana", 27, 60, 3}, + {"apple", 39, 40, 3}, + {"cheese", 23, 30, 1}, + {"beer", 52, 10, 3}, + {"suntan cream", 11, 70, 1}, + {"camera", 32, 30, 1}, + {"t-shirt", 24, 15, 2}, + {"trousers", 48, 10, 2}, + {"umbrella", 73, 40, 1}, + {"waterproof trousers", 42, 70, 1}, + {"waterproof overclothes", 43, 75, 1}, + {"note-case", 22, 80, 1}, + {"sunglasses", 7, 20, 1}, + {"towel", 18, 12, 2}, + {"socks", 4, 50, 1}, + {"book", 30, 10, 2}, +} + +-- for output +function print_as_sack(its) + if its == nil then return end + + -- format columns + -- [20 |8 |8 |8 ] + local head_fmt = "%-20s\t%-8s\t%-8s\t%-8s" + local data_fmt = "%-20s\t%-8d\t%-8d\t%-8d" + + local head_table = + string.format(head_fmt, "item", "weight", "value", "quantity") + + io.write(head_table, "\n") + line = string.rep("-" , 64) + io.write(line, "\n") + + for n=1,#its do + it = its[n] + local name,wt,val,q = table.unpack(it) + + local fmt_table = + string.format(data_fmt, name, wt, val, q) + io.write(fmt_table, "\n") + end + io.write(line, "\n") +end + +-- calc value:weight ratio +function append_wv (its) + + for index, it in pairs(its) do + local name,wt,val,q = table.unpack(it) + wv = val / wt + it[#it+1] = wv -- append + end +end + +-- sort by 5th item of each table entry +function sort_by_wv (its) + -- sorts decreasing + local wv_sorter = function(a,b) return a[5] > b[5] end + table.sort(its, wv_sorter) +end + +-- pack sorted by v:w ratio +-- all or none per item +function add_up (its, max, excl) + + local sack_items = {} + local sack = {} + local this_weight = 0 + local this_value = 0 + + for i = 1,#its do + it = its[i] + + -- is same table? + -- lua has no continue keyword + if it == excl then goto continue end + + -- unpack into vars + local name,wt,val,q,wv = table.unpack(it) + local count = 0 + local w = 0 + for j = 1, q do + local t_wt = wt +this_weight + if t_wt < max then + this_value = this_value + val + this_weight = t_wt + count = count + 1 + end + end + + if this_weight >= max then break end + + if count > 0 then + _s = {name, count} + table.insert (sack, _s) + end + + ::continue:: --skip item, continue + end -- for items + + -- go through chosen sack + -- make sack of items + for s = 1,#sack do + local s_item = sack[s] + local s_name,s_count = table.unpack(s_item) + + for j = 1,#its do + local it = its[j] + local iname = it[1] + if iname == s_name then + it[4] = s_count + table.insert(sack_items, it) + end -- if + end -- for j + end -- for sack + + -- update best + if this_value > best_value then + best_value = this_value + best_weight = this_weight + best_sack = sack_items + end +end -- function add_up + +-- Main execution +if debug.getinfo(1).what == "main" then + + max_weight = 400 + best_weight = 0 + best_value = 0 + best_sack = {} + + start = os.clock() + + append_wv(items) -- add weight/value + + sort_by_wv(items) -- sort by wv + + add_up(items, max_weight, {}) -- first try + + -- with each item excluded + for i = 1, #items do + add_up(items, max_weight, items[i]) + end + + stop = os.clock() + + time = stop - start -- seconds + + usec_time = time * 1e6 --microseconds + + + -- output + print_as_sack(best_sack) + print ("value:\t", best_value) + print("weight:\t", best_weight) + print("time:\t" , usec_time , " usec") + + os.exit(0) +end +-- end diff --git a/Task/Knapsack-problem-Bounded/Rust/knapsack-problem-bounded.rs b/Task/Knapsack-problem-Bounded/Rust/knapsack-problem-bounded.rs new file mode 100644 index 0000000000..14d93d6108 --- /dev/null +++ b/Task/Knapsack-problem-Bounded/Rust/knapsack-problem-bounded.rs @@ -0,0 +1,99 @@ +use std::collections::HashMap; + +fn main() { + let max_wt = 400; + + let grouped_items = vec![ + ("map", 9, 150, 1), + ("compass", 13, 35, 1), + ("water", 153, 200, 3), + ("sandwich", 50, 60, 2), + ("glucose", 15, 60, 2), + ("tin", 68, 45, 3), + ("banana", 27, 60, 3), + ("apple", 39, 40, 3), + ("cheese", 23, 30, 1), + ("beer", 52, 10, 3), + ("suntan cream", 11, 70, 1), + ("camera", 32, 30, 1), + ("t-shirt", 24, 15, 2), + ("trousers", 48, 10, 2), + ("umbrella", 73, 40, 1), + ("waterproof trousers", 42, 70, 1), + ("waterproof overclothes", 43, 75, 1), + ("note-case", 22, 80, 1), + ("sunglasses", 7, 20, 1), + ("towel", 18, 12, 2), + ("socks", 4, 50, 1), + ("book", 30, 10, 2), + ]; + + let mut items = Vec::new(); + for &(item, wt, val, n) in &grouped_items { + for _ in 0..n { + items.push((item, wt, val)); + } + } + + let bagged = knapsack01_dp(&items, max_wt); + + // Count and group the bagged items + let mut counts: HashMap<&str, i32> = HashMap::new(); + for &(item, _, _) in &bagged { + *counts.entry(item).or_insert(0) += 1; + } + + // Sort and print the results + let mut sorted_counts: Vec<_> = counts.iter().collect(); + sorted_counts.sort_by_key(|&(item, _)| *item); + + println!("Bagged the following {} items", bagged.len()); + for (item, count) in sorted_counts { + println!(" {} off: {}", count, item); + } + + let total_value: i32 = bagged.iter().map(|&(_, _, val)| val).sum(); + let total_weight: i32 = bagged.iter().map(|&(_, wt, _)| wt).sum(); + + println!("for a total value of {} and a total weight of {}", + total_value, total_weight); +} + +fn knapsack01_dp<'a>(items: &'a [(&'a str, i32, i32)], limit: i32) -> Vec<(&'a str, i32, i32)> { + let n = items.len(); + let limit_usize = limit as usize; + + // Create DP table + let mut table = vec![vec![0; (limit_usize + 1) as usize]; n + 1]; + + for j in 1..=n { + let (_, wt, val) = items[j-1]; + let wt_usize = wt as usize; + + for w in 1..=limit_usize { + if wt_usize > w { + table[j][w] = table[j-1][w]; + } else { + table[j][w] = std::cmp::max( + table[j-1][w], + table[j-1][w - wt_usize] + val + ); + } + } + } + + // Backtrack to find items + let mut result = Vec::new(); + let mut w = limit_usize; + + for j in (1..=n).rev() { + let was_added = table[j][w] != table[j-1][w]; + + if was_added { + result.push(items[j-1]); + w -= items[j-1].1 as usize; + } + } + + result +} diff --git a/Task/Knapsack-problem-Continuous/ALGOL-68/knapsack-problem-continuous.alg b/Task/Knapsack-problem-Continuous/ALGOL-68/knapsack-problem-continuous.alg new file mode 100644 index 0000000000..020bcee753 --- /dev/null +++ b/Task/Knapsack-problem-Continuous/ALGOL-68/knapsack-problem-continuous.alg @@ -0,0 +1,24 @@ +BEGIN # Knapsack problem: Continuous - based on the EasyLang sample # + + MODE ITEM = STRUCT( STRING name, REAL weight, value ); + PRIO SWAP = 1; + OP SWAP = ( REF ITEM a, b )VOID: BEGIN ITEM t = a; a := b; b := t END; + OP PRICE = ( ITEM a )REAL: value OF a / weight OF a; + []ITEM possible items + = ( ( "beef", 3.8, 36 ), ( "pork", 5.4, 43 ), ( "ham", 3.6, 90 ), ( "greaves", 2.4, 45 ) + , ( "flitch", 4.0, 30 ), ( "brawn", 2.5, 56 ), ( "welt", 3.7, 67 ), ( "salami", 3.0, 95 ) + , ( "sausage", 5.9, 98 ) + ); + [ LWB possible items : UPB possible items ]ITEM sack items := possible items; + FOR p FROM LWB sack items TO UPB sack items - 1 DO + FOR q FROM p + 1 TO UPB sack items DO + IF PRICE sack items[ q ] > PRICE sack items[ p ] THEN sack items[ p ] SWAP sack items[ q ] FI + OD + OD; + REAL max weight := 15; + FOR p FROM LWB sack items TO UPB sack items - 1 WHILE max weight > 0 DO + REAL w = IF weight OF sack items[ p ] > max weight THEN max weight ELSE weight OF sack items[ p ] FI; + print( ( fixed( w, -6, 2 ), " kg ", name OF sack items[ p ], newline ) ); + max weight -:= w + OD +END diff --git a/Task/Knapsack-problem-Continuous/ALGOL-W/knapsack-problem-continuous.alg b/Task/Knapsack-problem-Continuous/ALGOL-W/knapsack-problem-continuous.alg new file mode 100644 index 0000000000..f3697c4cd9 --- /dev/null +++ b/Task/Knapsack-problem-Continuous/ALGOL-W/knapsack-problem-continuous.alg @@ -0,0 +1,38 @@ +begin % Knapsack problem: Continuous - based on the Algol 68 sample, which is based on the EasyLang sample % + + record Item ( string(12) name; real weight, cost ); + real procedure price ( reference(Item) value a ) ; cost(a) / weight(a); + integer MAX_ITEMS; + MAX_ITEMS := 9; + + begin + reference(Item) array sackItems ( 1 :: MAX_ITEMS ); + real maxWeight; + + sackItems( 1 ) := Item( "beef", 3.8, 36 );sackItems( 2 ) := Item( "pork", 5.4, 43 ); + sackItems( 3 ) := Item( "ham", 3.6, 90 );sackItems( 4 ) := Item( "greaves", 2.4, 45 ); + sackItems( 5 ) := Item( "flitch", 4.0, 30 );sackItems( 6 ) := Item( "brawn", 2.5, 56 ); + sackItems( 7 ) := Item( "welt", 3.7, 67 );sackItems( 8 ) := Item( "salami", 3.0, 95 ); + sackItems( 9 ) := Item( "sausage", 5.9, 98 ); + + for p := 1 until MAX_ITEMS - 1 do begin + for q := p + 1 until MAX_ITEMS do begin + if price( sackItems( q ) ) > price( sackItems( p ) ) then begin + reference(Item) t; + t := sackItems( p ); + sackItems( p ) := sackItems( q ); + sackItems( q ) := t + end if_price_of_q_gt_price_of_p + end for_q + end for_p; + maxWeight := 15; + for p := 1 until MAX_ITEMS do begin + real w; + w := if weight(sackItems(p)) > maxWeight then maxWeight else weight(sackItems(p)); + write( s_w := 0, r_format := "A", r_w := 6, r_d := 2, w, " kg ", name(sackItems(p)) ); + maxWeight := maxWeight - w; + if maxWeight <= 0 then goto endSack + end for_p ; +endSack: + end +end. diff --git a/Task/Knights-tour/EasyLang/knights-tour.easy b/Task/Knights-tour/EasyLang/knights-tour.easy index e6511f1a37..7f88d40a53 100644 --- a/Task/Knights-tour/EasyLang/knights-tour.easy +++ b/Task/Knights-tour/EasyLang/knights-tour.easy @@ -1,4 +1,4 @@ -sys topleft +sysconf topleft dirs[][] = [ [ 1 2 ] [ 1 -2 ] [ 2 1 ] [ 2 -1 ] [ -1 2 ] [ -1 -2 ] [ -2 -1 ] [ -2 1 ] ] global brd[][] size . func cntmoves m[] . @@ -76,14 +76,13 @@ proc showgraf . gcolor col[(r + c) mod1 2] grect sc * c sc * r sc sc . + gpenup for i to size * size for r = 1 to size : for c = 1 to size : if brd[r][c] = i gcolor 600 x = c * sc - sc / 2 y = r * sc - sc / 2 - if i > 1 : gline xp yp x y - xp = x - yp = y + glineto x y gcolor 880 gcircle x y sc / 10 . diff --git a/Task/Knights-tour/Zig/knights-tour.zig b/Task/Knights-tour/Zig/knights-tour.zig new file mode 100644 index 0000000000..341cca46da --- /dev/null +++ b/Task/Knights-tour/Zig/knights-tour.zig @@ -0,0 +1,128 @@ +const std = @import("std"); + +const SIZE: usize = 8; +const MOVES = [_][2]i32{ + [_]i32{ 2, 1 }, + [_]i32{ 1, 2 }, + [_]i32{ -1, 2 }, + [_]i32{ -2, 1 }, + [_]i32{ -2, -1 }, + [_]i32{ -1, -2 }, + [_]i32{ 1, -2 }, + [_]i32{ 2, -1 }, +}; + +const Point = struct { + x: i32, + y: i32, + + fn mov(self: Point, dir: [2]i32) Point { + return .{ + .x = self.x + dir[0], + .y = self.y + dir[1], + }; + } +}; + +const Board = struct { + field: [SIZE][SIZE]i32, + + fn init() Board { + return .{ + .field = [_][SIZE]i32{[_]i32{0} ** SIZE} ** SIZE, + }; + } + + fn available(self: *const Board, p: Point) bool { + return 0 <= p.x and + p.x < @as(i32, @intCast(SIZE)) and + 0 <= p.y and + p.y < @as(i32, @intCast(SIZE)) and + self.field[@as(usize, @intCast(p.x))][@as(usize, @intCast(p.y))] == 0; + } + + // calculate the number of possible moves + fn countDegree(self: *const Board, p: Point) i32 { + var count: i32 = 0; + for (MOVES) |dir| { + const next = p.mov(dir); + if (self.available(next)) { + count += 1; + } + } + return count; + } + + fn format( + self: *const Board, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + + for (self.field) |row| { + for (row) |x| { + try writer.print("{d:3} ", .{x}); + } + try writer.writeByte('\n'); + } + } +}; + +fn knightsTour(x: i32, y: i32) ?Board { + var board = Board.init(); + var p = Point{ .x = x, .y = y }; + var step: i32 = 1; + board.field[@as(usize, @intCast(p.x))][@as(usize, @intCast(p.y))] = step; + step += 1; + + while (step <= @as(i32, @intCast(SIZE * SIZE))) { + // choose next square by Warnsdorf's rule + var candidates = std.ArrayList(struct { degree: i32, pos: Point }).init(std.heap.page_allocator); + defer candidates.deinit(); + + for (MOVES) |dir| { + const adj = p.mov(dir); + if (board.available(adj)) { + const degree = board.countDegree(adj); + candidates.append(.{ .degree = degree, .pos = adj }) catch unreachable; + } + } + + if (candidates.items.len == 0) { + return null; // can't move + } + + // Find minimum degree + var min_idx: usize = 0; + for (candidates.items, 0..) |candidate, i| { + if (candidate.degree < candidates.items[min_idx].degree) { + min_idx = i; + } + } + + // move to next square + p = candidates.items[min_idx].pos; + board.field[@as(usize, @intCast(p.x))][@as(usize, @intCast(p.y))] = step; + step += 1; + } + + return board; +} + +pub fn main() !void { + const x: i32 = 3; + const y: i32 = 1; + + const stdout = std.io.getStdOut().writer(); + try stdout.print("Board size: {d}\n", .{SIZE}); + try stdout.print("Starting position: ({d}, {d})\n", .{ x, y }); + + if (knightsTour(x, y)) |board| { + try stdout.print("{}\n", .{board}); + } else { + try stdout.print("Fail!\n", .{}); + } +} diff --git a/Task/Knuth-shuffle/DuckDB/knuth-shuffle.duckdb b/Task/Knuth-shuffle/DuckDB/knuth-shuffle.duckdb new file mode 100644 index 0000000000..8f22abbea6 --- /dev/null +++ b/Task/Knuth-shuffle/DuckDB/knuth-shuffle.duckdb @@ -0,0 +1,63 @@ +### Generic utilities + +create or replace function printstring(s, width) as ( + regexp_replace(s, '(.{1,' || width || '})', '\1' || chr(10), 'g' ) +); + +# It is assumed that 1 <= i, j <= length(ary) +create or replace function swap(ary, i, j) as ( + case when i = j then ary + when i < j then ary[1:i -1] || [ary[j]] || ary[i+1:j-1] || [ary[i]] || ary[j+1:] + else ary[1:j -1] || [ary[i]] || ary[j+1:i-1] || [ary[j]] || ary[i+1:] + end +); + +# Generate a pseudo-random integer in range(0,n), i.e. excluding n +create or replace function rnd(n) as ( + SELECT floor(random() * n)::BIGINT AS rnd +); + +### A deck of cards as codepoints +create or replace function deck() as ( + range(127137, 127148) || range(127149, 127151) -- Spades + || range(127153, 127164) || range(127165, 127167) -- Hearts + || range(127169, 127180) || range(127181, 127183) -- Diamonds + || range(127185, 127196) || range(127197, 127199) -- Clubs +); + +create or replace function printdeck(deck) as ( + list_transform(deck, x -> chr(x::INTEGER)).array_to_string('') +); + +### Knuth Shuffle of any list +create or replace function knuth_shuffle_table(arr) as table ( + WITH RECURSIVE cte(a, idx, r) AS ( + -- Base case: the original array, the index of the last element, and a random index + SELECT arr as a, length(arr) AS idx, 1 + rnd(length(arr)) as r + UNION ALL + -- Recursive case: shuffle the array by swapping the current index with a random element + SELECT + swap(a, r, idx) AS a, + idx - 1 AS idx, + 1 + rnd(idx - 1) as r + FROM cte + WHERE idx > 1 + ) + SELECT a + FROM cte + WHERE idx = 1 + LIMIT 1 +); + +# A scalar version of knuth_shuffle_table() specialized for INTEGER[] +# Currently DuckDB requires the specialization. +create or replace function knuth_shuffle(arr) as ( + from knuth_shuffle_table(arr::INTEGER[]) _(a) +); + +### Examples +select a, knuth_shuffle(a) +from values ([]), ([10,20]), ([0,10,20,30,40]) as t(a); + +.mode list +select knuth_shuffle(deck()).printdeck().printstring(13); diff --git a/Task/Knuth-shuffle/REBOL/knuth-shuffle-1.rebol b/Task/Knuth-shuffle/REBOL/knuth-shuffle-1.rebol new file mode 100644 index 0000000000..818565ad7b --- /dev/null +++ b/Task/Knuth-shuffle/REBOL/knuth-shuffle-1.rebol @@ -0,0 +1,4 @@ +probe random [] +probe random [10] +probe random [10 20] +probe random [10 20 30] diff --git a/Task/Knuth-shuffle/REBOL/knuth-shuffle-2.rebol b/Task/Knuth-shuffle/REBOL/knuth-shuffle-2.rebol new file mode 100644 index 0000000000..6fa456482f --- /dev/null +++ b/Task/Knuth-shuffle/REBOL/knuth-shuffle-2.rebol @@ -0,0 +1,48 @@ +Rebol [ + title: "Rosetta code: Knuth shuffle" + file: %Knuth_shuffle.r3 + url: https://rosettacode.org/wiki/Knuth_shuffle +] +fisher-yates: func [ + "Fisher-Yates shuffle algorithm - randomly shuffles elements in a block" + ;Uses the modern variant that works backwards through the array + data [series!] "Input block to shuffle" + /local i j tmp ;; Local variables: i=current index, j=random index, tmp=swap variable +][ + ;; Make a copy of the input block and get its length + ;; This prevents modification of the original block + i: length? data: copy data + + ;; Loop from the last element down to the second element + ;; We stop at 1 because there's no need to swap the first element with itself + while [i > 1] [ + ;; Generate random index j from 1 to i (inclusive) + j: random i + ;; Previous version tried to avoid self-swap as an optimization + ;; but actually it is faster to avoid it! + + ;; Three-step swap using path notation for direct block access + ;; Step 1: Store element at random position j in temporary variable + tmp: data/:j + + ;; Step 2: Move current element (at position i) to random position j + data/:j: data/:i + + ;; Step 3: Move stored element to current position i + ;; Using :tmp to get the value (word evaluation) + data/:i: :tmp + + ;; Move to previous element (working backwards through the block) + i: i - 1 + ] + + ;; Return the shuffled block + data +] + +random/seed 0 ;; to get consistent results + +probe fisher-yates [] +probe fisher-yates [10] +probe fisher-yates [10 20] +probe fisher-yates [10 20 30] diff --git a/Task/Knuth-shuffle/REBOL/knuth-shuffle.rebol b/Task/Knuth-shuffle/REBOL/knuth-shuffle.rebol deleted file mode 100644 index a16076dd9a..0000000000 --- a/Task/Knuth-shuffle/REBOL/knuth-shuffle.rebol +++ /dev/null @@ -1,18 +0,0 @@ -REBOL [ - Title: "Fisher-Yates" - Purpose: {Fisher-Yates shuffling algorithm} -] - -fisher-yates: func [b [block!] /local n i j k] [ - n: length? b: copy b - i: n - while [i > 1] [ - if i <> j: random i [ - error? set/any 'k pick b j - change/only at b j pick b i - change/only at b i get/any 'k - ] - i: i - 1 - ] - b -] diff --git a/Task/Knuth-shuffle/YAMLScript/knuth-shuffle.ys b/Task/Knuth-shuffle/YAMLScript/knuth-shuffle.ys new file mode 100644 index 0000000000..7d1331b7b0 --- /dev/null +++ b/Task/Knuth-shuffle/YAMLScript/knuth-shuffle.ys @@ -0,0 +1,8 @@ +!YS-v0 + +defn main(*list): + say: + reduce _ list:V range(list.#.-- 1 -1): + fn(v i): + r =: i:rand-int + assoc v: i (v r) r (v i) diff --git a/Task/Knuths-power-tree/Fortran/knuths-power-tree.f b/Task/Knuths-power-tree/Fortran/knuths-power-tree.f new file mode 100644 index 0000000000..754839f67e --- /dev/null +++ b/Task/Knuths-power-tree/Fortran/knuths-power-tree.f @@ -0,0 +1,379 @@ +module hash_map_module + + use iso_fortran_env + use qdmodule + + implicit none + private + public :: HashEntry, HashMap + + type HashEntry + integer(int64) :: key, value + type(HashEntry), pointer :: sgte => null() + end type HashEntry + +! Container for pointer to HashEntry + type HashEntryContainer + type(HashEntry), pointer :: ptr => null() + end type HashEntryContainer + + type HashMap + type(HashEntryContainer), allocatable :: buckets(:) + contains + procedure :: put => hash_map_put + procedure :: get => hash_map_get + procedure :: contains => hash_map_contains + end type HashMap + +contains + + subroutine hash_map_put(this, key, value) + class(HashMap), intent(inout) :: this + integer(int64), intent(in) :: key, value + integer(int64) :: bucket + type(HashEntry), pointer :: entry + + bucket = iand(key, int(255, int64)) + entry => this % buckets(bucket) % ptr + + ! Check for existing key + do while (associated(entry)) + if (entry % key == key) then + entry % value = value + return + end if + entry => entry % sgte + end do + + ! Insert new entry at head + allocate (entry) + entry % key = key + entry % value = value + entry % sgte => this % buckets(bucket) % ptr ! Correct pointer assignment + this % buckets(bucket) % ptr => entry ! Update head pointer + end subroutine hash_map_put + + function hash_map_get(this, key, defaultValue) result(res) + class(HashMap), intent(in) :: this + integer(int64), intent(in) :: key + integer(int64), optional, intent(in) :: defaultValue + integer(int64) :: res, bucket + type(HashEntry), pointer :: entry + + res = 0 + if (present(defaultValue)) res = defaultValue + bucket = iand(key, int(255, int64)) + entry => this % buckets(bucket) % ptr + + do while (associated(entry)) + if (entry % key == key) then + res = entry % value + return + end if + entry => entry % sgte + end do + end function hash_map_get + + function hash_map_contains(this, key) result(res) + class(HashMap), intent(in) :: this + integer(int64), intent(in) :: key + logical :: res + integer(int64) :: bucket + type(HashEntry), pointer :: entry + + bucket = iand(key, int(255, int64)) + entry => this % buckets(bucket) % ptr + + res = .false. + do while (associated(entry)) + if (entry % key == key) then + res = .true. + return + end if + entry => entry % sgte + end do + end function hash_map_contains + +end module hash_map_module + +module int_array_module + use iso_fortran_env + implicit none + private + public :: IntArray + + type IntArray + integer(int64), allocatable :: dato(:) + integer(int64) :: size = 0 + contains + procedure :: add => int_array_add + procedure :: get => int_array_get + procedure :: getSize => int_array_size + procedure :: clear => int_array_clear + end type + +contains + subroutine int_array_add(this, value) + use iso_fortran_env + class(IntArray), intent(inout) :: this + integer(int64), intent(in) :: value + integer(int64), allocatable :: temp(:) + integer(int64) :: current_capacity + + if (.not. allocated(this % dato)) then + allocate (this % dato(30)) + current_capacity = 30_8 + else + current_capacity = size(this % dato) + end if + + if (this % size >= current_capacity) then + call move_alloc(this % dato, temp) + allocate (this % dato(2 * current_capacity)) + this % dato(1:this % size) = temp(1:this % size) + end if + + this % size = this % size + 1 + this % dato(this % size) = value + end subroutine int_array_add + + function int_array_get(this, index) result(res) + class(IntArray), intent(in) :: this + integer(int64), intent(in) :: index + integer(int64) :: res + + res = 0 + if (index >= 1 .and. index <= this % size) res = this % dato(index) + end function + + function int_array_size(this) result(res) + use iso_fortran_env + class(IntArray), intent(in) :: this + integer(int64) :: res + res = this % size + end function + + subroutine int_array_clear(this) + class(IntArray), intent(inout) :: this + this % size = 0 + end subroutine +end module + +module power_module + use iso_fortran_env + use hash_map_module + use int_array_module + implicit none + private + public :: showPow, initialize_power ! Add initialization routine + + type(HashMap) :: p + type(IntArray) :: levels(1) + +contains + + subroutine initialize_power + integer :: i + if (allocated(p % buckets)) deallocate (p % buckets) + allocate (p % buckets(0:255)) + do i = 0, 255 + nullify (p % buckets(i) % ptr) ! Explicitly nullify all bucket pointers + end do + call levels(1) % clear() + call p % put(1_8, 0_8) + call levels(1) % add(1_8) + end subroutine + + recursive function path(n) result(res) + use iso_fortran_env + use hash_map_module + use int_array_module + implicit none + integer(int64), intent(in) :: n + type(IntArray) :: res + integer(int64) :: i, j, x, y, sum, curr + type(IntArray) :: q, tempPath + integer(int64) :: max_iter, iter + + ! Safety limit to prevent infinite loops + max_iter = 100000000 + iter = 0 + + if (n == 0) return + do while (.not. p % contains(n)) + q = IntArray() + + do i = 1, levels(1) % getSize() + x = levels(1) % get(i) + associate (xPath => path(x)) + do j = 1, xPath % getSize() + y = xPath % get(j) + sum = x + y + if (p % contains(sum)) cycle + call p % put(sum, x) + call q % add(sum) + end do + end associate + end do + call levels(1) % clear() + do i = 1, q % getSize() + call levels(1) % add(q % get(i)) + end do + + if (q % getSize() == 0) exit + + iter = iter + 1 + if (iter > max_iter) then + print *, "Path search exceeded maximum iterations for n=", n + exit + end if + end do + + curr = n + tempPath = IntArray() + + do while (curr /= 0) + call tempPath % add(curr) + curr = p % get(curr, 0_8) + end do + + do i = tempPath % getSize(), 1, -1 + call res % add(tempPath % get(i)) + end do + + return + end function path + + function treePowBig(x, n) result(res) + use iso_fortran_env + integer(int64), intent(in) :: x, n + integer(kind=16) :: res + integer(kind=16), allocatable :: r(:) + integer(int64) :: i, curr, p + type(IntArray) :: pathToN + + ! Allocate array to hold intermediate results + allocate (r(0:n)) + r(0) = 1_16 + if (n >= 1) r(1) = x + + p = 0 + pathToN = path(n) + + do i = 1, pathToN % getSize() + curr = pathToN % get(i) + r(curr) = r(curr - p) * r(p) + p = curr + end do + + res = r(n) + deallocate (r) + end function treePowBig + + function treePowDecimal(x, n) result(res) + use qdmodule + type(qd_real), intent(in) :: x + integer(int64), intent(in) :: n + type(qd_real) :: res + type(qd_real), allocatable :: r(:) + integer(int64) :: i, curr, p + type(IntArray) :: pathToN + + allocate (r(0:n)) + r(0) = "1.0" ! r(0) = 1.0 in quad-double + if (n >= 1) r(1) = x + + p = 0 + pathToN = path(n) + do i = 1, pathToN % getSize() + curr = pathToN % get(i) + r(curr) = r(curr - p) * r(p) + p = curr + end do + + res = r(n) + deallocate (r) + end function treePowDecimal + + subroutine showPow(x, n, xx) + use iso_fortran_env + use qdmodule + use int_array_module + implicit none + character(len=*) :: xx + type(qd_real), intent(in) :: x + integer(int64), intent(in) :: n + type(IntArray) :: pathToN + character(len=1024) :: pathStr + integer(int64) :: i + type(qd_real) :: result + character(len=1024) :: str + character(len=5) :: str2 + double precision :: try + integer :: unit +! + pathToN = path(n) + pathStr = "" + do i = 1, pathToN % getSize() + if (i > 1) pathStr = trim(pathStr)//", " + write (pathStr(len_trim(pathStr) + 1:), '(I0)') pathToN % get(i) + end do + + print '(I0,": [",A,"]" )', n, trim(pathStr) + + result = treePowDecimal(x, n) +! call qdwrite(6, result) ! Writes result to stdout (unit 6) + + ! Create a temporary internal file (string) + open (newunit=unit, status='scratch', action='readwrite', form='formatted') + + ! Write qd_real to the internal file + call qdwrite(unit, result) + + ! Read back into the string + rewind (unit) + read (unit, '(A)') str + close (unit) + write (str2, '(i0)') n + write (*, '(a)', advance="no") 'Result: '//xx//'^'//trim(adjustl(str2))//' = ' + read (str, *) try + if ((mod(try, 1.0) == 0.0) .and. (try < real(huge(1_16), kind=real64))) then + write (str, '(I0)') int(try, kind=16) + write (*, '(A)') trim(adjustl(str)) + else + if (try < 1.0d10) then + write (str, '(f20.13)') try + write (*, '(a)') trim(adjustl(str)) + else + write (*, '(a)') trim(adjustl(str)) + end if + end if + print * + end subroutine showPow + +end module + +program main + use iso_fortran_env + use qdmodule + use power_module + implicit none + integer(int64) :: i + type(qd_real) :: x + + call initialize_power() + + x = "2.0" + do i = 0, 17 + call showPow(x, i, "2.0") + end do + + x = "1.1" + call showPow(x, 81_8, "1.1") + call initialize_power() + + x = "3.0" + call showPow(x, 191_8, "3.0") + + stop 'Normal Finish' +end program diff --git a/Task/Knuths-power-tree/Python/knuths-power-tree.py b/Task/Knuths-power-tree/Python/knuths-power-tree-1.py similarity index 100% rename from Task/Knuths-power-tree/Python/knuths-power-tree.py rename to Task/Knuths-power-tree/Python/knuths-power-tree-1.py diff --git a/Task/Knuths-power-tree/Python/knuths-power-tree-2.py b/Task/Knuths-power-tree/Python/knuths-power-tree-2.py new file mode 100644 index 0000000000..d20cd8ad7f --- /dev/null +++ b/Task/Knuths-power-tree/Python/knuths-power-tree-2.py @@ -0,0 +1,57 @@ +""" https://rosettacode.org/wiki/Knuth%27s_power_tree """ + +from typing import List, Dict +from mpmath import mp + +# Set decimal precision for mpmath calculations (like Go example 320 bits) +mp.dps = 140 + +# Global variables +p: Dict[int, int] = {1: 0} +lvl: List[List[int]] = [[1]] + + +def path(n: int) -> List[int]: + """ return path to the node with id ''n'' """ + if n == 0: + return [] + + while n not in p: + q: List[int] = [] + for x in lvl[0]: + for y in path(x): + z = x + y + if z in p: + break + p[z] = x + q.append(z) + lvl[0] = q + + r = path(p[n]) + [n] + return r + + +def tree_pow(x: float, n: int) -> mp.mpf: + """ use power tree to compute x ** n """ + r: Dict[int, mp.mpf] = {0: mp.mpf('1'), 1: mp.mpf(str(x))} + prev = 0 + for i in path(n): + r[i] = mp.mpf(r[i - prev] * r[prev]) + prev = i + return r[n] + + +def show_pow(x: float, n: int) -> None: + """ print the power calculation """ + print(f"{n}: {path(n)}") + y = tree_pow(x, n) + ans = mp.nstr(y, n=100, strip_zeros=True)[ + :-2] if mp.isint(y) else mp.nstr(y, n=10) + print(f"{mp.nstr(x)} ^ {n} = {ans}\n") + + +if __name__ == "__main__": + for expo in range(18): + show_pow(2, expo) + show_pow(1.1, 81) + show_pow(3.0, 191) diff --git a/Task/Koch-curve/EasyLang/koch-curve.easy b/Task/Koch-curve/EasyLang/koch-curve.easy index 81bdc0e0b6..a26f8ce4e5 100644 --- a/Task/Koch-curve/EasyLang/koch-curve.easy +++ b/Task/Koch-curve/EasyLang/koch-curve.easy @@ -1,5 +1,3 @@ -xp = 0 / 0 -yp = xp proc koch x1 y1 x2 y2 iter . x3 = (x1 * 2 + x2) / 3 y3 = (y1 * 2 + y2) / 3 @@ -14,13 +12,11 @@ proc koch x1 y1 x2 y2 iter . koch x5 y5 x4 y4 iter koch x4 y4 x2 y2 iter else - if xp = xp : gline xp yp x1 y1 - gline x1 y1 x3 y3 - gline x3 y3 x3 y3 - gline x3 y3 x4 y4 - gline x4 y4 x2 y2 - xp = x2 - yp = y2 + glineto x1 y1 + glineto x3 y3 + glineto x3 y3 + glineto x4 y4 + glineto x2 y2 . . glinewidth 0.3 diff --git a/Task/Largest-int-from-concatenated-ints/DuckDB/largest-int-from-concatenated-ints.duckdb b/Task/Largest-int-from-concatenated-ints/DuckDB/largest-int-from-concatenated-ints.duckdb new file mode 100644 index 0000000000..2bb642a44b --- /dev/null +++ b/Task/Largest-int-from-concatenated-ints/DuckDB/largest-int-from-concatenated-ints.duckdb @@ -0,0 +1,18 @@ +create or replace function pad(s,n) as ( + s || repeat(s[-1], (n-length(s) )) +); + +create or replace function largest_int(lst) as ( + select array_agg(s order by x desc).array_to_string('') + from (select unnest(strs) as s, unnest(augmented) as x + from (select + list_transform(lst, x -> cast(x as VARCHAR)) as strs, + list_transform(strs, x -> length(x)).list_max() as mx, + list_transform(strs, x -> pad(x, mx)) as augmented ) ) +); + +## Examples +.mode line +select largest_int([1, 34, 3, 98, 9, 76, 45, 4]); + +select largest_int([54, 546, 548, 60]); diff --git a/Task/Largest-proper-divisor-of-n/AutoLISP/largest-proper-divisor-of-n.l b/Task/Largest-proper-divisor-of-n/AutoLISP/largest-proper-divisor-of-n.l new file mode 100644 index 0000000000..a1139cb80d --- /dev/null +++ b/Task/Largest-proper-divisor-of-n/AutoLISP/largest-proper-divisor-of-n.l @@ -0,0 +1,22 @@ +(progn + (defun LargestProperDivisor (n / x) + (cond + ((= 1 n) n) + ((> n 1) + (setq x (1- n)) + (while (not (zerop (rem n x))) + (setq x (1- x)) + ) + x + ) + ) + ) + ((lambda ( / cnt nums) + (mapcar + 'LargestProperDivisor + (repeat (1- (setq cnt 101)) + (setq nums (cons (setq cnt (1- cnt)) nums)) + ) + ) + )) +) diff --git a/Task/Last-Friday-of-each-month/C++/last-friday-of-each-month-3.cpp b/Task/Last-Friday-of-each-month/C++/last-friday-of-each-month-3.cpp new file mode 100644 index 0000000000..ab28f8ebcb --- /dev/null +++ b/Task/Last-Friday-of-each-month/C++/last-friday-of-each-month-3.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() { + std::cout << "The dates of the last Friday in each month of 2023:" << std::endl; + using namespace std::literals; + for ( auto ymd = std::chrono::Friday[std::chrono::last]/1/2023; + ymd.year() < 2024y; + ymd += std::chrono::months{1} ) + std::cout << std::chrono::sys_days{ymd} << '\n'; +} diff --git a/Task/Last-Friday-of-each-month/DuckDB/last-friday-of-each-month.duckdb b/Task/Last-Friday-of-each-month/DuckDB/last-friday-of-each-month.duckdb new file mode 100644 index 0000000000..fc10ee945f --- /dev/null +++ b/Task/Last-Friday-of-each-month/DuckDB/last-friday-of-each-month.duckdb @@ -0,0 +1,14 @@ +create or replace function last_friday(yr, mo) as ( + select dy + from (select unnest(range( + extract('day' from last_day(make_date(yr,mo,1))), 1, -1)) as dy ) + where extract('dayofweek' from make_date(yr, mo, dy )) = 5 -- Friday + limit 1 +); + +create or replace function last_fridays(yr) as table ( + select yr, mo, last_friday(yr, mo) as dy + from range(1,13) u(mo) +); + +from last_fridays(2012); diff --git a/Task/Last-letter-first-letter/FutureBasic/last-letter-first-letter.basic b/Task/Last-letter-first-letter/FutureBasic/last-letter-first-letter.basic new file mode 100644 index 0000000000..295fef5ce9 --- /dev/null +++ b/Task/Last-letter-first-letter/FutureBasic/last-letter-first-letter.basic @@ -0,0 +1,88 @@ +include "NSLog.incl" + +begin globals + NSInteger maxPathLength = 0 + NSInteger maxPathLengthCount = 0 + CFMutableStringRef maxPathExample +end globals + +void local fn SetUp + maxPathExample = fn MutableStringWithCapacity( 500 ) + + CFArrayRef names = @[@"audino", @"bagon", @"baltoy", @"banette", + @"bidoof", @"braviary", @"bronzor", @"carracosta", @"charmeleon", + @"cresselia", @"croagunk", @"darmanitan", @"deino", @"emboar", + @"emolga", @"exeggcute", @"gabite", @"girafarig", @"gulpin", + @"haxorus", @"heatmor", @"heatran", @"ivysaur", @"jellicent", + @"jumpluff", @"kangaskhan", @"kricketune", @"landorus", @"ledyba", + @"loudred", @"lumineon", @"lunatone", @"machamp", @"magnezone", + @"mamoswine", @"nosepass", @"petilil", @"pidgeotto", @"pikachu", + @"pinsir", @"poliwrath", @"poochyena", @"porygon2", @"porygonz", + @"registeel", @"relicanth", @"remoraid", @"rufflet", @"sableye", + @"scolipede", @"scrafty", @"seaking", @"sealeo", @"silcoon", + @"simisear", @"snivy", @"snorlax", @"spoink", @"starly", @"tirtouga", + @"trapinch", @"treecko", @"tyrogue", @"vigoroth", @"vulpix", + @"wailord", @"wartortle", @"whismur", @"wingull", @"yamask"] + AppSetProperty( @"pokemonNames", names ) +end fn + +void local fn Recursive( part as CFMutableArrayRef, offset as NSInteger ) + NSInteger i + + if ( offset > maxPathLength ) + maxPathLength = offset + maxPathLengthCount = 1 + else if ( offset == maxPathLength ) + maxPathLengthCount++ + MutableStringSetString( maxPathExample, @"" ) + for i = 0 to offset - 1 + if (i % 5 == 0) then MutableStringAppendString( maxPathExample, @"\n ") else MutableStringAppendString( maxPathExample, @" " ) + MutableStringAppendString( maxPathExample, part[i] ) + next + end if + + CFStringRef previousPart = part[offset - 1] + NSUInteger lastCharacterIndex = len(previousPart) - 1 + unichar lastChar = fn StringcharacterAtIndex( previousPart, lastCharacterIndex ) + + for i = offset to fn ArrayCount( part ) - 1 + if ( fn StringCharacterAtIndex( part[i], 0 ) == lastChar ) + CFStringRef tmp = part[offset] + part[offset] = part[i] + part[i] = tmp + fn Recursive( part, offset + 1 ) + part[i] = part[offset] + part[offset] = tmp + end if + next +end fn + +void local fn LastLetterFirstLetter + CFArrayRef names = fn AppProperty( @"pokemonNames" ) + CFMutableArrayRef mutableNames = fn MutableArrayWithArray( names ) + + for NSInteger i = 0 to fn ArrayCount( mutableNames ) - 1 + CFStringRef tmp = mutableNames[0] + mutableNames[0] = mutableNames[i] + mutableNames[i] = tmp + fn Recursive( mutableNames, 1 ) + mutableNames[i] = mutableNames[0] + mutableNames[0] = tmp + next + + CFTimeInterval t = fn CACurrentMediaTime + MutableStringReplaceAllOccurrencesOfString( maxPathExample, @" ", @"\n" ) + MutableStringReplaceAllOccurrencesOfString( maxPathExample, @"\n\n", @"\n" ) + MutableStringReplaceAllOccurrencesOfString( maxPathExample, @"\n\n", @"\n" ) + MutableStringReplaceAllOccurrencesOfString( maxPathExample, @"\n", @"\n\t" ) + NSLog( @"Maximum path length: %ld", (long)maxPathLength ) + NSLog( @"Paths of that length: %ld", (long)maxPathLengthCount ) + NSLog( @"One solution:\n %@", maxPathExample ) + NSLog( @"\nCompute time: %.3f ms", (fn CACurrentMediaTime-t)*1000 ) + +end fn + +fn SetUp +fn LastLetterFirstLetter + +HandleEvents diff --git a/Task/Leap-year/DuckDB/leap-year.duckdb b/Task/Leap-year/DuckDB/leap-year.duckdb new file mode 100644 index 0000000000..4441c42c50 --- /dev/null +++ b/Task/Leap-year/DuckDB/leap-year.duckdb @@ -0,0 +1,2 @@ +create or replace function is_leap_year(y) as + (y%4) == 0 and (y < 1582 or (y%400) == 0 or (y%100) != 0); diff --git a/Task/Leap-year/Pluto/leap-year.pluto b/Task/Leap-year/Pluto/leap-year.pluto new file mode 100644 index 0000000000..7a6bcf10b1 --- /dev/null +++ b/Task/Leap-year/Pluto/leap-year.pluto @@ -0,0 +1,7 @@ +function is_leap(y) + return (y % 4 == 0) and (y % 100 != 0) or (y % 400 == 0) +end + +for {1900,1904,1994,1996,1997,2000} as i do + io.write(''..is_leap(i),'\t') +end diff --git a/Task/Left-factorials/DuckDB/left-factorials.duckdb b/Task/Left-factorials/DuckDB/left-factorials.duckdb new file mode 100644 index 0000000000..ddb99186a8 --- /dev/null +++ b/Task/Left-factorials/DuckDB/left-factorials.duckdb @@ -0,0 +1,43 @@ +CREATE OR REPLACE FUNCTION factorial_t(num) as table ( + with recursive cte as ( + select 0 as n, 1::DOUBLE as fact + union all + select + n+1 as n, + ((n+1) * fact) as fact + from cte + where n < num + ) select n, fact from cte +) ; + +CREATE OR REPLACE FUNCTION left_factorial(num) as ( + if (num < 1, 0, + (select sum(fact) from factorial_t(num - 1)) ) +); + +CREATE OR REPLACE FUNCTION left_factorial_t(num) as table ( + with recursive cte as ( + select 0 as n, 1.0::DOUBLE as fact, 0::DOUBLE as sum + union all + select + n+1 as n, + ((n+1) * fact) as fact, + sum + fact as sum + from cte + where n < num + ) + select n, sum as left_factorial + from cte + order by n +) ; + +# First 10 +from left_factorial_t(10); + +# By 10s +from left_factorial_t(110) +where n % 10 = 0 +and n > 10; + +# Maximum is for 171 +select left_factorial(171); diff --git a/Task/Leonardo-numbers/DuckDB/leonardo-numbers.duckdb b/Task/Leonardo-numbers/DuckDB/leonardo-numbers.duckdb new file mode 100644 index 0000000000..e11104e931 --- /dev/null +++ b/Task/Leonardo-numbers/DuckDB/leonardo-numbers.duckdb @@ -0,0 +1,27 @@ +# The specification of `zero`, `one` and `incr` will determine precision. +# For maximum precision, specify them as UHUGEINT. +create or replace function Leonardo_table(max, zero, one, incr) as table ( + with recursive cte(n,lp,l) as ( + select 1 as n, zero as lp, one as l + union all + select n+1, l as lp, l + lp + incr as l + from cte + where n= 1 then + write(l0:1, ' '); + if lmt >= 2 then + write(l1:1, ' '); + for i := 3 to lmt do + begin + write(l0 + l1 + sum:1, ' '); + tmp := l0; + l0 := l1; + l1 := tmp + l1 + sum; + end; + writeln + end; + +begin + writeleonardonums(1, 1, 1, 25, 'Leonardo numbers'); + writeleonardonums(0, 1, 0, 25, 'Fibonacci numbers') +end. diff --git a/Task/Letter-frequency/DuckDB/letter-frequency-1.duckdb b/Task/Letter-frequency/DuckDB/letter-frequency-1.duckdb new file mode 100644 index 0000000000..5240e44975 --- /dev/null +++ b/Task/Letter-frequency/DuckDB/letter-frequency-1.duckdb @@ -0,0 +1,8 @@ +# First read in the file as a single row in a table: +create or replace table t as (select content from read_text('unixdict.txt')); + +# Use GROUP BY to create the table +select c, count(*) as count + from (select unnest(regexp_extract_all((from t), '.')) as c) + group by c + order by count, c; diff --git a/Task/Letter-frequency/DuckDB/letter-frequency-2.duckdb b/Task/Letter-frequency/DuckDB/letter-frequency-2.duckdb new file mode 100644 index 0000000000..3bc9e0ce46 --- /dev/null +++ b/Task/Letter-frequency/DuckDB/letter-frequency-2.duckdb @@ -0,0 +1,7 @@ +# See above for reading in the file. + +# Create a table containing all the individual characters +create or replace table c as (select unnest(regexp_extract_all((from t), '.')) as c); + +# Choose a large enough bin_count value to ensure each character has its own bin +from histogram('c', c, bin_count := 100) order by count desc; diff --git a/Task/Letter-frequency/Koka/letter-frequency.koka b/Task/Letter-frequency/Koka/letter-frequency.koka new file mode 100644 index 0000000000..7dc8e9a800 --- /dev/null +++ b/Task/Letter-frequency/Koka/letter-frequency.koka @@ -0,0 +1,20 @@ +import std/os/file +import std/os/path + +fun main() + val counts = count(read-text-file("input.txt".path).list) + counts.foreach fn((c, i)) + println(c.show-char ++ " = " ++ i.show) + println("Total letters = " ++ counts.map(snd).sum.show) + +fun add(freq: list<(char, int)>, c : char): list<(char, int)> + if c.is-alpha then + match freq + Nil -> [(c, 1)] + Cons((x, n), rest) -> + if x == c then Cons((x, n + 1), rest) + else Cons((x, n), add(rest, c)) + else freq + +fun count(text: list) + text.foldl([], add) diff --git a/Task/Letter-frequency/TAV/letter-frequency.tav b/Task/Letter-frequency/TAV/letter-frequency.tav new file mode 100644 index 0000000000..ebdabaf1a3 --- /dev/null +++ b/Task/Letter-frequency/TAV/letter-frequency.tav @@ -0,0 +1,11 @@ +main (parms):+ + text =: <'In olden times when wishing still helped one, + there lived a king whose daughters were all beautiful. + But the youngest was so beautiful that the sun itself, + which has seen so much, was astonished whenever it shone in her face.' + lc =: new map + ?# c =: string text give characters + ? string #ASCIIletters has character c + lc{c} =+ 1 + ?# k =: map lc give keys descending values + print k, lc{k} diff --git a/Task/Levenshtein-distance-Alignment/Ada/levenshtein-distance-alignment.ada b/Task/Levenshtein-distance-Alignment/Ada/levenshtein-distance-alignment.ada new file mode 100644 index 0000000000..dda6f2a6b2 --- /dev/null +++ b/Task/Levenshtein-distance-Alignment/Ada/levenshtein-distance-alignment.ada @@ -0,0 +1,88 @@ +with Ada.Assertions, + Ada.Text_IO; + +procedure Levenschtein_Alignment is + type Levenschtein_Array is array (Natural range <>, Natural range <>) of Natural; + + type Levenschtein_Matrix (S, T : Natural) is record + Source : String (1 .. S); + Target : String (1 .. T); + Matrix : Levenschtein_Array (0 .. S, 0 .. T); + end record; + + function Make (S, T : String) return Levenschtein_Matrix is + L : Levenschtein_Matrix (S'Length, T'Length); + begin + L.Source := S; + L.Target := T; + L.Matrix (0, 0) := 0; + + for I in S'Range loop + L.Matrix (I, 0) := I; + end loop; + + for I in T'Range loop + L.Matrix (0, I) := I; + end loop; + + return L; + end Make; + + Place_Palace : Levenschtein_Matrix := Make ("place", "palace"); + Rosettacode_Raisethysword : Levenschtein_Matrix := Make ("rosettacode", "raisethysword"); + + procedure Fill (L : in out Levenschtein_Matrix) is + Cost : Natural; + begin + for J in L.Target'Range loop + for I in L.Source'Range loop + if L.Source (I) = L.Target (J) then + Cost := 0; + else + Cost := 1; + end if; + + L.Matrix (I, J) := Natural'Min + (Cost + L.Matrix (I - 1, J - 1), -- Substitution + Natural'Min + (1 + L.Matrix (I - 1, J), -- Deletion + 1 + L.Matrix (I, J - 1))); -- Insertion + end loop; + end loop; + end Fill; + + -- For convenience, assume Source'Length <= Target'Length + procedure Show (L : Levenschtein_Matrix) is + Aligned_Source : String (1 .. L.Target'Length); + I : Natural := L.Source'Length; + J : Natural := L.Target'Length; + Min_Dist : Natural; + begin + Ada.Assertions.Assert (I <= J); + + for P in reverse 1 .. L.Target'Length loop + -- Deletion will not happen due to length assumption + Min_Dist := Natural'Min (L.Matrix (I, J - 1), L.Matrix (I - 1, J - 1)); + + if Min_Dist = L.Matrix (I - 1, J - 1) then + -- Substitution. Fill in source character + Aligned_Source (P) := L.Source (I); + I := I - 1; + J := J - 1; + elsif Min_Dist = L.Matrix (I, J - 1) then + -- Insertion. Fill in a wildcard + Aligned_Source (P) := '-'; + J := J - 1; + end if; + end loop; + + Ada.Text_IO.Put_Line (Aligned_Source); + Ada.Text_IO.Put_Line (L.Target); + end Show; +begin + Fill (Place_Palace); + Show (Place_Palace); + + Fill (Rosettacode_Raisethysword); + Show (Rosettacode_Raisethysword); +end Levenschtein_Alignment; diff --git a/Task/Levenshtein-distance/DuckDB/levenshtein-distance.duckdb b/Task/Levenshtein-distance/DuckDB/levenshtein-distance.duckdb new file mode 100644 index 0000000000..bd62d17fa2 --- /dev/null +++ b/Task/Levenshtein-distance/DuckDB/levenshtein-distance.duckdb @@ -0,0 +1,5 @@ +select s1, s2, levenshtein(s1,s2), damerau_levenshtein(s1,s2) +from values + ('kitten', 'sitting'), + ('sitting', 'sittnig'), + ('rosettacode', 'raisethysword') _(s1,s2); diff --git a/Task/Levenshtein-distance/Pascal-P/levenshtein-distance.pas b/Task/Levenshtein-distance/Pascal-P/levenshtein-distance.pas new file mode 100644 index 0000000000..e953320a34 --- /dev/null +++ b/Task/Levenshtein-distance/Pascal-P/levenshtein-distance.pas @@ -0,0 +1,81 @@ +program levdistdemo(output); + +const + maxlen = 15; + +type + stringalpha = array [1 .. maxlen] of char; + + function min3(a, b, c: integer): integer; + var + min: integer; + begin + min := a; + if b < min then + min := b; + if c < min then + min := c; + min3 := min; + end; + + function levdist(s: stringalpha; m: integer; + t: stringalpha; n: integer): integer; + var + d: array [0 .. maxlen, 0 .. maxlen] of integer; + i, j: integer; + begin + for i := 0 to m do + d[i, 0] := i; + for j := 0 to n do + d[0, j] := j; + for j := 1 to n do + for i := 1 to m do + if s[i] = t[j] then + d[i, j] := d[i - 1, j - 1] + else + d[i, j] := min3(d[i - 1, j] + 1, d[i, j - 1] + 1, + d[i - 1, j - 1] + 1); + levdist := d[m, n]; + end; + + procedure writeresults(s1, s2: stringalpha); + var + n1, n2: integer; + + function purelen(s: stringalpha): integer; + (* Returns length of s without trailing spaces *) + var + i: integer; + begin + i := maxlen; + while (i > 0) and (s[i] = ' ') do + i := i - 1; + purelen := i; + end; + + procedure writenchars(s: stringalpha; n: integer); + var + i: integer; + begin + for i := 1 to n do + write(s[i]); + end; + + begin + n1 := purelen(s1); + n2 := purelen(s2); + write('The Levenshtein distance between "'); + writenchars(s1, n1); + write('" and "'); + writenchars(s2, n2); + (* Here the levdist function is called. *) + writeln('" is: ', levdist(s1, n1, s2, n2): 1); + end; + +begin + (* In string assignment, a string literal must have the same size + as a string variable. So trailing spaces are needed, but they are not + considered in calculating a distance. *) + writeresults('kitten ', 'sitting '); + writeresults('rosettacode ', 'raisethysword '); +end. diff --git a/Task/List-comprehensions/DuckDB/list-comprehensions-1.duckdb b/Task/List-comprehensions/DuckDB/list-comprehensions-1.duckdb new file mode 100644 index 0000000000..4c713a0e9f --- /dev/null +++ b/Task/List-comprehensions/DuckDB/list-comprehensions-1.duckdb @@ -0,0 +1,7 @@ +# for x in 1 to n, for y in x+1 to n, for z in y+1 to n +create or replace function xyz(n) as table ( + from range(1,n+1) x(x) + cross join (from range(x+1,n+1) y(y)) + cross join (from range(y+1, n+1) z(z)) + +); diff --git a/Task/List-comprehensions/DuckDB/list-comprehensions-2.duckdb b/Task/List-comprehensions/DuckDB/list-comprehensions-2.duckdb new file mode 100644 index 0000000000..0826ceeb56 --- /dev/null +++ b/Task/List-comprehensions/DuckDB/list-comprehensions-2.duckdb @@ -0,0 +1,6 @@ +create or replace function triples(n) as table ( + from xyz(n) + where x*x + y*y = z*z +); + +from triples(10); diff --git a/Task/List-comprehensions/DuckDB/list-comprehensions-3.duckdb b/Task/List-comprehensions/DuckDB/list-comprehensions-3.duckdb new file mode 100644 index 0000000000..a613ad7de4 --- /dev/null +++ b/Task/List-comprehensions/DuckDB/list-comprehensions-3.duckdb @@ -0,0 +1,4 @@ +create or replace function list_triples(n) as ( + [ xyz FOR xyz IN (select array_agg([x,y,z] order by x) FROM xyz(n)) + IF xyz[1]**2 + xyz[2]**2 = xyz[3]**2 ] +); diff --git a/Task/List-comprehensions/DuckDB/list-comprehensions-4.duckdb b/Task/List-comprehensions/DuckDB/list-comprehensions-4.duckdb new file mode 100644 index 0000000000..3a9d0eebd0 --- /dev/null +++ b/Task/List-comprehensions/DuckDB/list-comprehensions-4.duckdb @@ -0,0 +1,5 @@ +create or replace function list_triples(n) as ( + list_filter( + (select array_agg([x,y,z] order by x) from xyz(n)), + x -> x[1]*x[1] + x[2]*x[2] = x[3]*x[3] ) +); diff --git a/Task/List-comprehensions/DuckDB/list-comprehensions-5.duckdb b/Task/List-comprehensions/DuckDB/list-comprehensions-5.duckdb new file mode 100644 index 0000000000..57c2588f30 --- /dev/null +++ b/Task/List-comprehensions/DuckDB/list-comprehensions-5.duckdb @@ -0,0 +1 @@ +select list_triples(10); diff --git a/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas b/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas index 3c888aa14f..c3820b8e57 100644 --- a/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas +++ b/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas @@ -1,2 +1,2 @@ ## -(1..20).CartesianPower(3).Where(\(x,y,z) -> (x*x + y*y = z*z) and (x < y)).PrintLines +(1..20).CartesianPower(3).Where(\(x,y,z) -> (x*x + y*y = z*z) and (x < y)).tolist.PrintLines diff --git a/Task/Literals-Floating-point/ArkScript/literals-floating-point.ark b/Task/Literals-Floating-point/ArkScript/literals-floating-point.ark new file mode 100644 index 0000000000..3e7cfb3852 --- /dev/null +++ b/Task/Literals-Floating-point/ArkScript/literals-floating-point.ark @@ -0,0 +1,3 @@ +(print 2.3) +(print 0.34e5) +(print (/ 23 10)) diff --git a/Task/Literals-Floating-point/Pluto/literals-floating-point.pluto b/Task/Literals-Floating-point/Pluto/literals-floating-point.pluto new file mode 100644 index 0000000000..7a673dcb9b --- /dev/null +++ b/Task/Literals-Floating-point/Pluto/literals-floating-point.pluto @@ -0,0 +1,4 @@ +local fs = {123.456, .456, 1e5, 2.5e-1, 0xap4, 0x1.ffp10} +for fs as f do + print(f) +end diff --git a/Task/Literals-Floating-point/REXX/literals-floating-point.rexx b/Task/Literals-Floating-point/REXX/literals-floating-point.rexx index df07d9fa3e..bc554a2caf 100644 --- a/Task/Literals-Floating-point/REXX/literals-floating-point.rexx +++ b/Task/Literals-Floating-point/REXX/literals-floating-point.rexx @@ -1,4 +1,4 @@ --- 19 May 2025 +-- 28 Jul 2025 include Settings say 'LITERALS FLOATING POINT' @@ -47,6 +47,4 @@ say Left('Scientific',l) '=' Sci(a) say Left('Engineering',l) '=' Eng(a) exit -include Functions -include Helper -include Abend +include Math diff --git a/Task/Literals-Integer/ArkScript/literals-integer.ark b/Task/Literals-Integer/ArkScript/literals-integer.ark new file mode 100644 index 0000000000..25dfb48096 --- /dev/null +++ b/Task/Literals-Integer/ArkScript/literals-integer.ark @@ -0,0 +1,4 @@ +(print 1) +(print 1e10) +(print 3E8) +(print 5e-3) diff --git a/Task/Literals-Integer/DuckDB/literals-integer.duckdb b/Task/Literals-Integer/DuckDB/literals-integer.duckdb new file mode 100644 index 0000000000..6954f438cb --- /dev/null +++ b/Task/Literals-Integer/DuckDB/literals-integer.duckdb @@ -0,0 +1 @@ +select '10000'::BIT::INT; #=> 16 diff --git a/Task/Literals-Integer/Pluto/literals-integer.pluto b/Task/Literals-Integer/Pluto/literals-integer.pluto new file mode 100644 index 0000000000..529f724d4b --- /dev/null +++ b/Task/Literals-Integer/Pluto/literals-integer.pluto @@ -0,0 +1,4 @@ +local n = {255, 0xff, 0o377, 0b11111111} +for n as i do + print(i) +end diff --git a/Task/Literals-String/ArkScript/literals-string.ark b/Task/Literals-String/ArkScript/literals-string.ark new file mode 100644 index 0000000000..3db1fb974a --- /dev/null +++ b/Task/Literals-String/ArkScript/literals-string.ark @@ -0,0 +1,4 @@ +(print "hello") +(print "hello\nworld") +(print "test\ttab") +(print "\u1234") diff --git a/Task/Logical-operations/ArkScript/logical-operations.ark b/Task/Logical-operations/ArkScript/logical-operations.ark new file mode 100644 index 0000000000..2bf1695df2 --- /dev/null +++ b/Task/Logical-operations/ArkScript/logical-operations.ark @@ -0,0 +1,9 @@ +(let logic (fun (a b) { + (print "a and b: " (and a b)) + (print "a or b:" (or a b)) + (print "not a: " (not a)) })) + +(logic true true) +(logic true false) +(logic false true) +(logic false false) diff --git a/Task/Logical-operations/DuckDB/logical-operations.duckdb b/Task/Logical-operations/DuckDB/logical-operations.duckdb new file mode 100644 index 0000000000..d4427a5b9b --- /dev/null +++ b/Task/Logical-operations/DuckDB/logical-operations.duckdb @@ -0,0 +1,22 @@ +create or replace function demo(p, q) as table ( + select p as p, + q as q, + p and q as and, + p or q as or, + not p as "NOT p", + (p is TRUE) as "p is TRUE", + (p is NULL) as "p is NULL" +); + +# Some examples +from demo(0, 0) +union all +from demo(0, 1) +union all +from demo(true, true) +union all +from demo(0, null) +union all +from demo(1, null) +union all +from demo(null, null); diff --git a/Task/Logical-operations/Red/logical-operations.red b/Task/Logical-operations/Red/logical-operations.red new file mode 100644 index 0000000000..a2dd549ded --- /dev/null +++ b/Task/Logical-operations/Red/logical-operations.red @@ -0,0 +1,14 @@ +Red [ "Logical Operations - Hinjo, 23 July 2025" ] + +test: func [a b] [ + foreach op [and or xor not] [ + either op = 'not + [ print [op a "==>" do compose [(op) a]] ] + [ print [a op b "==>" do compose [a (op) b]] ] + ] print "" +] + +test true true +test true false +test false true +test false false diff --git a/Task/Long-literals-with-continuations/Ada/long-literals-with-continuations.ada b/Task/Long-literals-with-continuations/Ada/long-literals-with-continuations.ada new file mode 100644 index 0000000000..8168637dca --- /dev/null +++ b/Task/Long-literals-with-continuations/Ada/long-literals-with-continuations.ada @@ -0,0 +1,34 @@ +with Ada.Characters.Latin_1; +with Ada.Strings; +with Ada.Strings.Fixed; +with Ada.Text_IO; + +procedure Long_Literal is + -- & is the concatenation operator + Elements : constant String := + "hydrogen helium lithium beryllium boron carbon nitrogen oxygen fluorine " & + "neon sodium magnesium aluminum silicon phosphorous sulfur chlorine argon " & + "potassium calcium scandium titanium vanadium chromium manganese iron " & + "cobalt nickel copper zinc gallium germanium arsenic selenium bromine " & + "krypton rubidium strontium yttrium zirconium niobium molybdenum " & + "technetium ruthenium rhodium palladium silver cadmium indium tin " & + "antimony tellurium iodine xenon cesium barium lanthanum cerium " & + "praseodymium neodymium promethium samarium europium gadolinium terbium " & + "dysprosium holmium erbium thulium ytterbium lutetium hafnium tantalum " & + "tungsten rhenium osmium iridium platinum gold mercury thallium lead " & + "bismuth polonium astatine radon francium radium actinium thorium " & + "protactinium uranium neptunium plutonium americium curium berkelium " & + "californium einsteinium fermium mendelevium nobelium lawrencium " & + "rutherfordium dubnium seaborgium bohrium hassium meitnerium darmstadtium " & + "roentgenium copernicium nihonium flerovium moscovium livermorium " & + "tennessine oganesson"; + Revision : constant String := "2025-08-02"; + Count : constant Natural := Ada.Strings.Fixed.Count (Elements, " ") + 1; + Last_Element : constant Natural := + Ada.Strings.Fixed.Index (Elements, " ", Ada.Strings.Backward) + 1; +begin + Ada.Text_IO.Put_Line ("Last Revision Date: " & Revision); + Ada.Text_IO.Put_Line ("Number of Elements: " & Count'Image); + Ada.Text_IO.Put_Line + ("Last Element: " & Elements (Last_Element .. Elements'Last)); +end Long_Literal; diff --git a/Task/Long-multiplication/F-Sharp/long-multiplication.fs b/Task/Long-multiplication/F-Sharp/long-multiplication.fs deleted file mode 100644 index 8338a96cf4..0000000000 --- a/Task/Long-multiplication/F-Sharp/long-multiplication.fs +++ /dev/null @@ -1,3 +0,0 @@ -> let X = 2I ** 64 * 2I ** 64 ;; - -val X : System.Numerics.BigInteger = 340282366920938463463374607431768211456 diff --git a/Task/Long-primes/REXX/long-primes.rexx b/Task/Long-primes/REXX/long-primes.rexx index 4270b9f8ab..ca54ba894b 100644 --- a/Task/Long-primes/REXX/long-primes.rexx +++ b/Task/Long-primes/REXX/long-primes.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings say 'LONG PRIMES' @@ -24,7 +24,7 @@ say 'Long primes < 500' p = 0 do i = 1 to prim.0 until p > 500 p = prim.i - if p-qperiod(1 p) = 1 then + if p-PeriodQ(1 p) = 1 then call Charout ,p' ' end say @@ -42,15 +42,11 @@ do i = 1 to prim.0 while a > 0 say Right(a,5) Right(n,4) w = w+1; a = Word(t,w) end - if p-qperiodinv(p) = 1 then do + if p-PeriodInvQ(p) = 1 then do n = n+1 end end say Format(Time('e'),,3) 'seconds'; say return -include Functions -include Sequences -include Rational -include Constants -include Abend +include Math diff --git a/Task/Longest-common-subsequence/ALGOL-68/longest-common-subsequence.alg b/Task/Longest-common-subsequence/ALGOL-68/longest-common-subsequence.alg index 54f29d5dd5..e02c0eccfa 100644 --- a/Task/Longest-common-subsequence/ALGOL-68/longest-common-subsequence.alg +++ b/Task/Longest-common-subsequence/ALGOL-68/longest-common-subsequence.alg @@ -1,15 +1,16 @@ -main:( - PROC lcs = (STRING a, b)STRING: - BEGIN - IF UPB a = 0 OR UPB b = 0 THEN - "" - ELIF a [UPB a] = b [UPB b] THEN - lcs (a [:UPB a - 1], b [:UPB b - 1]) + a [UPB a] - ELSE - STRING x = lcs (a, b [:UPB b - 1]); - STRING y = lcs (a [:UPB a - 1], b); - IF UPB x > UPB y THEN x ELSE y FI - FI - END # lcs #; - print((lcs ("thisisatest", "testing123testing"), new line)) -) +BEGIN PROC lcs = (STRING s, t) STRING: + IF LWB s > UPB s OR LWB t > UPB t + THEN # Trivial case: empty strings have an empty LCS. # + "" + ELIF s[UPB s] = t[UPB t] + THEN # If the last characters of 's' and 't' match, prepend the LCS of the preceeding strings # + lcs (s[: UPB s - 1], t[: UPB t - 1]) + s[UPB s] + ELSE # Find the longest LCS of these cases: + (1) excluding the last character of 's' including the last of 't', + (2) excluding the last character of 't' including the last of 's'. # + STRING u = lcs (s[: UPB s - 1], t), v = lcs (s, t[: UPB t - 1]); + (UPB u > UPB v | u | v) + FI; + + print((lcs ("thisisatest", "testing123testing"), new line)) +END diff --git a/Task/Longest-increasing-subsequence/Ada/longest-increasing-subsequence.ada b/Task/Longest-increasing-subsequence/Ada/longest-increasing-subsequence.ada new file mode 100644 index 0000000000..a7671eaf17 --- /dev/null +++ b/Task/Longest-increasing-subsequence/Ada/longest-increasing-subsequence.ada @@ -0,0 +1,51 @@ +with Ada.Text_IO; + +procedure Longest_Increasing_Subsequence is + type Sequence is array (Positive range <>) of Integer; + + Seq1 : constant Sequence := + (3, 2, 6, 4, 5, 1); + Seq2 : constant Sequence := + (0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15); + + function Lis (Seq : Sequence) return Sequence is + Best : Sequence (Seq'Range) := (others => 1); + Pred : Sequence (Seq'Range) := (others => 0); + Best_Idx, Max_Len : Natural := 0; + begin + -- Calculate LIS length for every end point + for I in Seq'Range loop + for J in 1 .. I - 1 loop + if Seq (J) < Seq (I) and then + Best (I) < 1 + Best (J) then + Best (I) := 1 + Best (J); + Pred (I) := J; + end if; + end loop; + end loop; + + -- Find tail of global LIS + for I in Best'Range loop + if Best (I) > Max_Len then + Best_Idx := I; + Max_Len := Best (I); + end if; + end loop; + + -- Trace sequence + declare + Lis : Sequence (1 .. Max_Len); + begin + for I in reverse 1 .. Max_Len loop + Lis (I) := Seq (Best_Idx); + Best_Idx := Pred (Best_Idx); + end loop; + + return Lis; + end; + end Lis; + +begin + Ada.Text_IO.Put_Line (Lis (Seq1)'Image); + Ada.Text_IO.Put_Line (Lis (Seq2)'Image); +end Longest_Increasing_Subsequence; diff --git a/Task/Longest-increasing-subsequence/DuckDB/longest-increasing-subsequence.duckdb b/Task/Longest-increasing-subsequence/DuckDB/longest-increasing-subsequence.duckdb new file mode 100644 index 0000000000..c869de0c5c --- /dev/null +++ b/Task/Longest-increasing-subsequence/DuckDB/longest-increasing-subsequence.duckdb @@ -0,0 +1,31 @@ +# Return a list - just one in the case of a tie +create or replace function longest_increasing_subsequence(lst) as ( + + -- Add a flag to signal the start of a new subsequence + with flagged as ( + select *, if(id = 1, 0, if(c > (lag(c) over ()), 0, 1)) as flag + from (select generate_subscripts(lst,1) as id, + unnest(lst) as c) + ), + partitions as ( + select *, sum(flag) over (order by id) as partition_number + from (select *, if(id=1 or (c > (lag(c) over ())), 1, 0) as flag + from flagged) + order by id asc + ), + subseq_number as ( + select max_by(partition_number, ncount) as n + from (select partition_number, count(*) as ncount + from partitions + group by partition_number) + ) + select array_agg(c order by id) + from partitions, subseq_number + where partition_number = subseq_number.n +); + +# Examples; +select l as list, longest_increasing_subsequence(l) as lis + from (select [3,2,6,4,5,1] as l union all + select [0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15] as l union all + select [0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15,20] as l); diff --git a/Task/Loop-over-multiple-arrays-simultaneously/Pluto/loop-over-multiple-arrays-simultaneously.pluto b/Task/Loop-over-multiple-arrays-simultaneously/Pluto/loop-over-multiple-arrays-simultaneously.pluto new file mode 100644 index 0000000000..2a7349438d --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/Pluto/loop-over-multiple-arrays-simultaneously.pluto @@ -0,0 +1,6 @@ +a = {'a','b','c'} +b = {'A','B','C'} +c = {1,2,3} +for i = 1,#c do + io.write(a[i],b[i],c[i],'\n') +end diff --git a/Task/Loop-over-multiple-arrays-simultaneously/REBOL/loop-over-multiple-arrays-simultaneously.rebol b/Task/Loop-over-multiple-arrays-simultaneously/REBOL/loop-over-multiple-arrays-simultaneously.rebol new file mode 100644 index 0000000000..e7bf28c8d3 --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/REBOL/loop-over-multiple-arrays-simultaneously.rebol @@ -0,0 +1,10 @@ +;; Define the three series +list1: [a b c] +list2: [A B C] +list3: [1 2 3] + +;; Iterate over them in parallel by index +repeat i length? list1 [ + ;; pick returns the i-th element + print rejoin [list1/:i list2/:i list3/:i] +] diff --git a/Task/Loop-over-multiple-arrays-simultaneously/TAV/loop-over-multiple-arrays-simultaneously.tav b/Task/Loop-over-multiple-arrays-simultaneously/TAV/loop-over-multiple-arrays-simultaneously.tav new file mode 100644 index 0000000000..510e266d29 --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/TAV/loop-over-multiple-arrays-simultaneously.tav @@ -0,0 +1,15 @@ + x =: 1, 2, 3, 4 + y =: 'a', 'b', 'c' + \ create z as row with keys from -1 to 3 + z =: new row + ?# i =: from -1 upto 3 + z[i] =: i+4 + + ?# i =: tuple x give keys + print i, x[i], y[i], z[i] + print '' + ?# i =: row z give keys + print i, x[i], y[i], z[i] + print '' + ?# i =: from 0 upto 4 + print i, x[i], y[i], z[i] diff --git a/Task/Loops-Break/DuckDB/loops-break.duckdb b/Task/Loops-Break/DuckDB/loops-break.duckdb new file mode 100644 index 0000000000..f0b5da4293 --- /dev/null +++ b/Task/Loops-Break/DuckDB/loops-break.duckdb @@ -0,0 +1,22 @@ +# PRN in range(0,n) +create or replace function prn(n) as trunc(random() * n)::BIGINT; + +# Print numbers in range(0,n) as per the task description +create or replace function task(n) as table ( + with recursive cte as ( + select prn(n) as rand, false as stop + union all + select + prn(n) as rand, + rand = 10 as stop + from cte + where stop != true + ) select rand + from cte + where stop = false +); + +.print A sample run: +from task(20); +.print A likely shorter one: +from task(11); diff --git a/Task/Loops-Break/Koka/loops-break.koka b/Task/Loops-Break/Koka/loops-break.koka new file mode 100644 index 0000000000..c4cef92515 --- /dev/null +++ b/Task/Loops-Break/Koka/loops-break.koka @@ -0,0 +1,12 @@ +import std/num/random + +effect ebreak + final ctl ebreak(): a + +fun main() + with final ctl ebreak() () + while {True} + val a = random-int() % 20 + println(a) + if a == 10 then ebreak() + println(random-int() % 20) diff --git a/Task/Loops-Break/Pluto/loops-break.pluto b/Task/Loops-Break/Pluto/loops-break.pluto new file mode 100644 index 0000000000..05fcf3c303 --- /dev/null +++ b/Task/Loops-Break/Pluto/loops-break.pluto @@ -0,0 +1,6 @@ +while true do + local r = math.random(0, 19) + print(r) + if r == 10 then break end + print(math.random(0, 19)) +end diff --git a/Task/Loops-Break/TAV/loops-break-1.tav b/Task/Loops-Break/TAV/loops-break-1.tav new file mode 100644 index 0000000000..e154b5106a --- /dev/null +++ b/Task/Loops-Break/TAV/loops-break-1.tav @@ -0,0 +1,7 @@ + ?* \ if no expression, forever + a =: random next integer %% 20 + print a + ? a = 10 + print random next integer %% 20 + ?> \ exit loop + print random next integer %% 20 diff --git a/Task/Loops-Break/TAV/loops-break-2.tav b/Task/Loops-Break/TAV/loops-break-2.tav new file mode 100644 index 0000000000..3f9e08991b --- /dev/null +++ b/Task/Loops-Break/TAV/loops-break-2.tav @@ -0,0 +1,7 @@ + while true + a = random next integer %% 20 + print a + if a == 10 + print random next integer %% 20 + break + print random next integer %% 20 diff --git a/Task/Loops-Break/Ursalang/loops-break.ursa b/Task/Loops-Break/Ursalang/loops-break.ursa new file mode 100644 index 0000000000..6773c478e8 --- /dev/null +++ b/Task/Loops-Break/Ursalang/loops-break.ursa @@ -0,0 +1,12 @@ +use js.Math + +let f = fn() { + Math.floor(Math.random() * 20) +} + +loop { + let n = f() + print(n) + if n == 10 { break } + print(f()) +} diff --git a/Task/Loops-Break/Zig/loops-break.zig b/Task/Loops-Break/Zig/loops-break-1.zig similarity index 100% rename from Task/Loops-Break/Zig/loops-break.zig rename to Task/Loops-Break/Zig/loops-break-1.zig diff --git a/Task/Loops-Break/Zig/loops-break-2.zig b/Task/Loops-Break/Zig/loops-break-2.zig new file mode 100644 index 0000000000..7329c1b27f --- /dev/null +++ b/Task/Loops-Break/Zig/loops-break-2.zig @@ -0,0 +1,25 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var prng = std.Random.DefaultPrng.init(blk: { + var seed: u64 = undefined; + try std.posix.getrandom(std.mem.asBytes(&seed)); + break :blk seed; + }); + const rand = prng.random(); + + while (true) { + const n1 = rand.intRangeAtMost(u8, 0, 19); + try stdout.print("{d:2} ", .{n1}); + + if (n1 == 10) { + break; + } + + const n2 = rand.intRangeAtMost(u8, 0, 19); + try stdout.print("{d:2}\n", .{n2}); + } + + try stdout.print("\n", .{}); +} diff --git a/Task/Loops-Continue/Pluto/loops-continue.pluto b/Task/Loops-Continue/Pluto/loops-continue.pluto new file mode 100644 index 0000000000..5b1e49dc47 --- /dev/null +++ b/Task/Loops-Continue/Pluto/loops-continue.pluto @@ -0,0 +1,8 @@ +for i = 1, 10 do + io.write(i) + if i % 5 == 0 then + print() + continue + end + io.write(", ") +end diff --git a/Task/Loops-Continue/REBOL/loops-continue.rebol b/Task/Loops-Continue/REBOL/loops-continue-1.rebol similarity index 84% rename from Task/Loops-Continue/REBOL/loops-continue.rebol rename to Task/Loops-Continue/REBOL/loops-continue-1.rebol index 216f116666..6b2e1988ba 100644 --- a/Task/Loops-Continue/REBOL/loops-continue.rebol +++ b/Task/Loops-Continue/REBOL/loops-continue-1.rebol @@ -3,7 +3,7 @@ REBOL [ URL: http://rosettacode.org/wiki/Loop/Continue ] -; REBOL does not provide a 'continue' word for loop constructs, +; REBOL2 does not provide a 'continue' word for loop constructs, ; however, you may not even miss it: print "One liner (compare to ALGOL 68 solution):" diff --git a/Task/Loops-Continue/REBOL/loops-continue-2.rebol b/Task/Loops-Continue/REBOL/loops-continue-2.rebol new file mode 100644 index 0000000000..bd9550c2ae --- /dev/null +++ b/Task/Loops-Continue/REBOL/loops-continue-2.rebol @@ -0,0 +1,8 @@ +repeat i 10 [ + prin i + if zero? i % 5 [ + prin newline + continue + ] + prin ", " +] diff --git a/Task/Loops-Do-while/DuckDB/loops-do-while.duckdb b/Task/Loops-Do-while/DuckDB/loops-do-while.duckdb new file mode 100644 index 0000000000..4dca729023 --- /dev/null +++ b/Task/Loops-Do-while/DuckDB/loops-do-while.duckdb @@ -0,0 +1,16 @@ +create or replace function do_while(init) as table ( + with recursive cte as ( + select init+1 as value -- Increment unconditionally + union all -- Loop + select value+1 as value -- Each time through the loop, add 1 to the value then print it. + from cte + where value % 6 != 0 -- "while value mod 6 is not equal to 0" + ) + from cte order by value +); + +# The task +from do_while(0); + +# Also check that the loop executes at least once. +from do_while(-1); diff --git a/Task/Loops-Do-while/Pluto/loops-do-while.pluto b/Task/Loops-Do-while/Pluto/loops-do-while.pluto new file mode 100644 index 0000000000..c5add00378 --- /dev/null +++ b/Task/Loops-Do-while/Pluto/loops-do-while.pluto @@ -0,0 +1,4 @@ +local value = 0 +repeat + print(++value) +until value % 6 == 0 diff --git a/Task/Loops-Do-while/TAV/loops-do-while-1.tav b/Task/Loops-Do-while/TAV/loops-do-while-1.tav new file mode 100644 index 0000000000..179cf892cc --- /dev/null +++ b/Task/Loops-Do-while/TAV/loops-do-while-1.tav @@ -0,0 +1,6 @@ + x =: 0 + ?* \ loop forever + x =+ 1 \ increment x + print x + ? x %% 6 = 0 \ until + ?> \ break diff --git a/Task/Loops-Do-while/TAV/loops-do-while-2.tav b/Task/Loops-Do-while/TAV/loops-do-while-2.tav new file mode 100644 index 0000000000..b06e7e33d3 --- /dev/null +++ b/Task/Loops-Do-while/TAV/loops-do-while-2.tav @@ -0,0 +1,6 @@ + x = 0 + while \ loop forever + x += 1 \ increment x + print x + if x %% 6 == 0 \ until + break diff --git a/Task/Loops-Downward-for/DuckDB/loops-downward-for-1.duckdb b/Task/Loops-Downward-for/DuckDB/loops-downward-for-1.duckdb new file mode 100644 index 0000000000..00a3c805b0 --- /dev/null +++ b/Task/Loops-Downward-for/DuckDB/loops-downward-for-1.duckdb @@ -0,0 +1 @@ +from range(10, -1, -1) t(countdown); diff --git a/Task/Loops-Downward-for/DuckDB/loops-downward-for-2.duckdb b/Task/Loops-Downward-for/DuckDB/loops-downward-for-2.duckdb new file mode 100644 index 0000000000..81cdd9a336 --- /dev/null +++ b/Task/Loops-Downward-for/DuckDB/loops-downward-for-2.duckdb @@ -0,0 +1,14 @@ +# Start at `start` +create or replace function task(start) as table ( + with recursive cte as ( + select start as n + union all + select + n - 1 as n + from cte + where n > 0 + ) + from cte +); + +from task(10); diff --git a/Task/Loops-Downward-for/Pluto/loops-downward-for.pluto b/Task/Loops-Downward-for/Pluto/loops-downward-for.pluto new file mode 100644 index 0000000000..ff0f196ea1 --- /dev/null +++ b/Task/Loops-Downward-for/Pluto/loops-downward-for.pluto @@ -0,0 +1,2 @@ +for i = 10, 0, -1 do io.write($"{i} ") end +print() diff --git a/Task/Loops-Downward-for/TAV/loops-downward-for.tav b/Task/Loops-Downward-for/TAV/loops-downward-for.tav new file mode 100644 index 0000000000..f91afc487c --- /dev/null +++ b/Task/Loops-Downward-for/TAV/loops-downward-for.tav @@ -0,0 +1,6 @@ + ?# i =: from 10 downto 0 + print i + ?# i =: from 20 downto 0 step 2 + print i // 2 + ?# i =: give numbers 10 -> 0 + print i diff --git a/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-1.duckdb b/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-1.duckdb new file mode 100644 index 0000000000..449cd50675 --- /dev/null +++ b/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-1.duckdb @@ -0,0 +1,3 @@ +.header off +.mode column +select format('whom do we appreciate? {:d}', i) from range(2, 10, 2) _(i); diff --git a/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-2.duckdb b/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-2.duckdb new file mode 100644 index 0000000000..a1e45134ef --- /dev/null +++ b/Task/Loops-For-with-a-specified-step/DuckDB/loops-for-with-a-specified-step-2.duckdb @@ -0,0 +1,8 @@ +with recursive cte as ( + select 2 as i + union all + select i+2 -- increment by 2 + from cte + where i < 8) + select format('whom do we appreciate? {:d}', i) + from cte; diff --git a/Task/Loops-For-with-a-specified-step/Pluto/loops-for-with-a-specified-step.pluto b/Task/Loops-For-with-a-specified-step/Pluto/loops-for-with-a-specified-step.pluto new file mode 100644 index 0000000000..3200bb4031 --- /dev/null +++ b/Task/Loops-For-with-a-specified-step/Pluto/loops-for-with-a-specified-step.pluto @@ -0,0 +1,2 @@ +for i = 1, 9, 2 do io.write($"{i} ") end +print() diff --git a/Task/Loops-For-with-a-specified-step/REBOL/loops-for-with-a-specified-step.rebol b/Task/Loops-For-with-a-specified-step/REBOL/loops-for-with-a-specified-step.rebol index 6b7d5b612f..f3a7cc653d 100644 --- a/Task/Loops-For-with-a-specified-step/REBOL/loops-for-with-a-specified-step.rebol +++ b/Task/Loops-For-with-a-specified-step/REBOL/loops-for-with-a-specified-step.rebol @@ -1,3 +1,2 @@ -for i 2 8 2 [ - prin rejoin [i ", "]] +for i 2 8 2 [prin join i ", "] print "who do we appreciate?" diff --git a/Task/Loops-For/Adina/loops-for-1.adina b/Task/Loops-For/Adina/loops-for-1.adina new file mode 100644 index 0000000000..dbbbfaca27 --- /dev/null +++ b/Task/Loops-For/Adina/loops-for-1.adina @@ -0,0 +1,6 @@ +цикл + номер-строки 5 + цикл + номер-колонки номер-строки + вывести «*» + вывести/перенос «*» diff --git a/Task/Loops-For/Adina/loops-for-2.adina b/Task/Loops-For/Adina/loops-for-2.adina new file mode 100644 index 0000000000..39c3639f3c --- /dev/null +++ b/Task/Loops-For/Adina/loops-for-2.adina @@ -0,0 +1,7 @@ +english() +for + $ i 5 + for + $ j i + display "*" + displayln "*" diff --git a/Task/Loops-For/DuckDB/loops-for-1.duckdb b/Task/Loops-For/DuckDB/loops-for-1.duckdb new file mode 100644 index 0000000000..95918267f7 --- /dev/null +++ b/Task/Loops-For/DuckDB/loops-for-1.duckdb @@ -0,0 +1,3 @@ +select list_transform(range(1,6), + i -> list_transform(range(1,i+1), + j -> '*').array_to_string('')) as stars; diff --git a/Task/Loops-For/DuckDB/loops-for-2.duckdb b/Task/Loops-For/DuckDB/loops-for-2.duckdb new file mode 100644 index 0000000000..e8935f320d --- /dev/null +++ b/Task/Loops-For/DuckDB/loops-for-2.duckdb @@ -0,0 +1,3 @@ +select (select string_agg('*', '') from range(1,i+1)) +from range(1,6) _(i) +order by i; diff --git a/Task/Loops-For/DuckDB/loops-for-3.duckdb b/Task/Loops-For/DuckDB/loops-for-3.duckdb new file mode 100644 index 0000000000..c402439422 --- /dev/null +++ b/Task/Loops-For/DuckDB/loops-for-3.duckdb @@ -0,0 +1,3 @@ +select (select string_agg(j, ',' order by j) from range(1,i+1) _(j)) +from range(1,6) _(i) +order by i; diff --git a/Task/Loops-For/Eiffel/loops-for.e b/Task/Loops-For/Eiffel/loops-for.e new file mode 100644 index 0000000000..a0eacbbcd5 --- /dev/null +++ b/Task/Loops-For/Eiffel/loops-for.e @@ -0,0 +1,17 @@ +class APPLICATION +create make +feature + make local + i, j: INTEGER + do from i := 1 + until i > 5 loop + from j := 1 + until j > i loop + print("*") + j := j + 1 + end + print("%N") + i := i + 1 + end + end +end diff --git a/Task/Loops-For/Extended-Color-BASIC/loops-for.basic b/Task/Loops-For/Extended-Color-BASIC/loops-for.basic new file mode 100644 index 0000000000..9e65d215a2 --- /dev/null +++ b/Task/Loops-For/Extended-Color-BASIC/loops-for.basic @@ -0,0 +1,6 @@ +10 FOR I = 1 TO 5 +20 FOR J = 1 TO I +30 PRINT "*"; +40 NEXT J +50 PRINT +60 NEXT I diff --git a/Task/Loops-For/Pluto/loops-for.pluto b/Task/Loops-For/Pluto/loops-for.pluto new file mode 100644 index 0000000000..1d0903c980 --- /dev/null +++ b/Task/Loops-For/Pluto/loops-for.pluto @@ -0,0 +1,4 @@ +for i = 1, 5 do + for _ = 1, i do io.write("*") end + print() +end diff --git a/Task/Loops-For/TAV/loops-for-1.tav b/Task/Loops-For/TAV/loops-for-1.tav new file mode 100644 index 0000000000..ef92582c88 --- /dev/null +++ b/Task/Loops-For/TAV/loops-for-1.tav @@ -0,0 +1,4 @@ + ?# i =: from 1 upto 5 + ?# j =: from 1 upto i + print '*' nonl + print '' diff --git a/Task/Loops-For/TAV/loops-for-2.tav b/Task/Loops-For/TAV/loops-for-2.tav new file mode 100644 index 0000000000..810edc9db7 --- /dev/null +++ b/Task/Loops-For/TAV/loops-for-2.tav @@ -0,0 +1,2 @@ + ?# i =: from 1 upto 5 + print string '*' times i diff --git a/Task/Loops-For/TAV/loops-for-3.tav b/Task/Loops-For/TAV/loops-for-3.tav new file mode 100644 index 0000000000..cedd6836f3 --- /dev/null +++ b/Task/Loops-For/TAV/loops-for-3.tav @@ -0,0 +1,4 @@ + ?# i =: from 0 upto 5 + ?# j =: from 1 upto i + print j nonl + print '' diff --git a/Task/Loops-Foreach/Pluto/loops-foreach.pluto b/Task/Loops-Foreach/Pluto/loops-foreach.pluto new file mode 100644 index 0000000000..66614dcf2c --- /dev/null +++ b/Task/Loops-Foreach/Pluto/loops-foreach.pluto @@ -0,0 +1,6 @@ +local languages = {"English", "French", "German", "Spanish"} +for languages as lang do print(lang) end +print() + +-- or alternatively: +languages:foreach(print) diff --git a/Task/Loops-Foreach/REBOL/loops-foreach.rebol b/Task/Loops-Foreach/REBOL/loops-foreach.rebol index 20666e1f96..3204f10127 100644 --- a/Task/Loops-Foreach/REBOL/loops-foreach.rebol +++ b/Task/Loops-Foreach/REBOL/loops-foreach.rebol @@ -3,11 +3,11 @@ REBOL [ URL: http://rosettacode.org/wiki/Loop/Foreach ] -x: [Sork Gun Blues Neds Thirst Fright Catur] +names: [Sork Gun Blues Neds Thirst Fright Catur] -foreach i x [prin rejoin [i "day "]] print "" +foreach name names [prin join name "day "] print "" -; REBOL also has the 'forall' construct, which provides the rest of +; Rebol also has the 'forall' construct, which provides the rest of ; the list from the current position. -forall x [prin rejoin [x/1 "day "]] print "" +forall names [prin join names/1 "day "] print "" diff --git a/Task/Loops-Increment-loop-index-within-loop-body/ARM-Assembly/loops-increment-loop-index-within-loop-body.arm b/Task/Loops-Increment-loop-index-within-loop-body/ARM-Assembly/loops-increment-loop-index-within-loop-body.arm index a6a9c71396..7048f58019 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/ARM-Assembly/loops-increment-loop-index-within-loop-body.arm +++ b/Task/Loops-Increment-loop-index-within-loop-body/ARM-Assembly/loops-increment-loop-index-within-loop-body.arm @@ -134,7 +134,7 @@ conversion10: /* division par 10 unsigned */ /***************************************************/ /* r0 dividende */ -/* r0 quotient */ +/* r0 quotient */ /* r1 remainder */ divisionpar10U: push {r2,r3,r4, lr} @@ -148,7 +148,7 @@ divisionpar10U: sub r1,r4,r2, lsl #1 @ r1 <- r4 - (r2 * 2) = r4 - (r0 * 10) pop {r2,r3,r4,lr} bx lr @ leave function -iMagicNumber: .int 0xCCCCCCCD +iMagicNumber: .int 0xCCCCCCCD /***************************************************/ /* number is prime ? */ /***************************************************/ @@ -306,7 +306,7 @@ moduloPuR96: mov r1,r12 msr cpsr_f, #0 @ no error overflow zero -> flags 100: @ end function - pop {r2-r12,lr} @ restaur registers + pop {r2-r12,lr} @ restaur registers bx lr @ return /***************************************************/ /* multiplication 2 registers (64 bits) unsigned */ @@ -342,13 +342,13 @@ multiplicationR96U: msr cpsr_f, #0 @ no error overflow zero -> flags b 100f 99: @ display message overflow - ldr r0,iAdrszMessMultOver @ - bl affichageMess + ldr r0,iAdrszMessMultOver @ + bl affichageMess mov r0,#0 mov r1,#0 msr cpsr_f, #1<<29 @ maj flag carry à 1 et tous les autres à 0 100: @ end function - pop {r3-r8,lr} @ restaur registers + pop {r3-r8,lr} @ restaur registers bx lr @ return iAdrszMessMultOver: .int szMessMultOver /***************************************************/ @@ -425,7 +425,7 @@ divisionReg96DU: mov r2,r6 @ high bits quotient 100: @ end function - pop {r5-r10,lr} @ restaur registers + pop {r5-r10,lr} @ restaur registers bx lr @ return /***************************************************/ @@ -445,7 +445,7 @@ conversionRegDoubleU: strb r3,[r5,r4] @ store digit in area index r4 sub r4,r4,#1 @ decrement index cmp r0,#0 @ low bits quotient = zero ? - bne 1b @ no -> loop + bne 1b @ no -> loop cmp r1,#0 @ high bits quotient = zero ? bne 1b @ no -> loop @ spaces -> begin area @@ -456,7 +456,7 @@ conversionRegDoubleU: bge 2b @ and loop if > zéro 100: @ end fonction - pop {r0-r5,lr} @ restaur registers + pop {r0-r5,lr} @ restaur registers bx lr @ return /***************************************************/ /* division number 64 bits / number 32 bits */ diff --git a/Task/Loops-Increment-loop-index-within-loop-body/Arturo/loops-increment-loop-index-within-loop-body.arturo b/Task/Loops-Increment-loop-index-within-loop-body/Arturo/loops-increment-loop-index-within-loop-body.arturo index d5fc676117..6ad7e18007 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/Arturo/loops-increment-loop-index-within-loop-body.arturo +++ b/Task/Loops-Increment-loop-index-within-loop-body/Arturo/loops-increment-loop-index-within-loop-body.arturo @@ -2,12 +2,12 @@ i: 42 n: 0 while [n<42][ - if? prime? i [ - n: n+1 - print ["n =" pad to :string n 2 pad to :string i 20] - i: i + i - ] - else [ - i: i + 1 - ] + if? prime? i [ + n: n+1 + print ["n =" pad to :string n 2 pad to :string i 20] + i: i + i + ] + else [ + i: i + 1 + ] ] diff --git a/Task/Loops-Increment-loop-index-within-loop-body/AutoHotkey/loops-increment-loop-index-within-loop-body.ahk b/Task/Loops-Increment-loop-index-within-loop-body/AutoHotkey/loops-increment-loop-index-within-loop-body.ahk index eae4048658..d3f1e50843 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/AutoHotkey/loops-increment-loop-index-within-loop-body.ahk +++ b/Task/Loops-Increment-loop-index-within-loop-body/AutoHotkey/loops-increment-loop-index-within-loop-body.ahk @@ -1,21 +1,21 @@ i:= 42, n:= 1, result := "" while (n<43){ - if isPrime(i) - result .= n ":`t" RegExReplace(i, "\B(?=(\d{3})+$)", ",") "`n", i*=2, n++ - else - i++ + if isPrime(i) + result .= n ":`t" RegExReplace(i, "\B(?=(\d{3})+$)", ",") "`n", i*=2, n++ + else + i++ } MsgBox, 262208, , % result return isPrime(num){ - if !Mod(num, 2) || !Mod(num, 3) - return false - lim := Sqrt(num), i := 5 - while (i i (isqrt n)) ; Break condition index exceeds its square root - (zerop (mod n i))) ; Break condition it is divisible - (not (zerop (mod n i)))))))) ; Returns not divisible, aka prime + (do* ((i 3 (incf i 2))) ; Initialize to 3 and increment by 2 on every loop + ((or (> i (isqrt n)) ; Break condition index exceeds its square root + (zerop (mod n i))) ; Break condition it is divisible + (not (zerop (mod n i)))))))) ; Returns not divisible, aka prime (do ((i 42) ; Initialize index to 42 (c 0)) ; Initialize count of primes to 0 ((= c 42)) ; Break condition when there are 42 primes (incf i) ; Increments index by unity (if (primep i)(progn (incf c) ; If prime increment count of primes - (format t "~&~5<~d~;->~>~20<~:d~>" c i) ; Display count of primes found and the prime - (incf i (decf i))))) ; Increment index to previous index plus the prime + (format t "~&~5<~d~;->~>~20<~:d~>" c i) ; Display count of primes found and the prime + (incf i (decf i))))) ; Increment index to previous index plus the prime diff --git a/Task/Loops-Increment-loop-index-within-loop-body/DuckDB/loops-increment-loop-index-within-loop-body.duckdb b/Task/Loops-Increment-loop-index-within-loop-body/DuckDB/loops-increment-loop-index-within-loop-body.duckdb new file mode 100644 index 0000000000..558cd86ad9 --- /dev/null +++ b/Task/Loops-Increment-loop-index-within-loop-body/DuckDB/loops-increment-loop-index-within-loop-body.duckdb @@ -0,0 +1,33 @@ +create or replace function primep(nnumber) as ( + select + case + when nnumber < 2 then false + when nnumber = 2 then true + else NOT exists + ( select * from + ( select (nnumber % anumber) as modNumber + from (select unnest(range(2, 1 + sqrt(nnumber)::BIGINT)) as anumber) + ) + where modNumber = 0 + ) + end +); + +create or replace function task(start, mx) as table ( + with recursive cte as ( + select start::HUGEINT as ix, primep(start) as primep0, 0::HUGEINT as n, + []::HUGEINT[] as display + union all + select if (primep0, ix+ix, ix+1) as ix, + if (primep0, primep(ix+ix), primep(ix+1)) as primep0, + if (primep0,1,0) + n as n, + if (primep0, [n+1, ix], []) as display + from cte + where n < mx + ) select display + from cte + where display != [] + limit mx +); + +from task(42, 42); diff --git a/Task/Loops-Increment-loop-index-within-loop-body/Icon/loops-increment-loop-index-within-loop-body.icon b/Task/Loops-Increment-loop-index-within-loop-body/Icon/loops-increment-loop-index-within-loop-body.icon index 225a4cef48..8b7552410d 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/Icon/loops-increment-loop-index-within-loop-body.icon +++ b/Task/Loops-Increment-loop-index-within-loop-body/Icon/loops-increment-loop-index-within-loop-body.icon @@ -10,7 +10,7 @@ procedure main() write(right(n,2),": ",comma_string(i)) i +:= i } else - i +:= 1 + i +:= 1 } end diff --git a/Task/Loops-Increment-loop-index-within-loop-body/Ksh/loops-increment-loop-index-within-loop-body.ksh b/Task/Loops-Increment-loop-index-within-loop-body/Ksh/loops-increment-loop-index-within-loop-body.ksh index b45d1ee715..6013a6b179 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/Ksh/loops-increment-loop-index-within-loop-body.ksh +++ b/Task/Loops-Increment-loop-index-within-loop-body/Ksh/loops-increment-loop-index-within-loop-body.ksh @@ -2,24 +2,24 @@ # Increment loop index within loop body -# # Variables: +# # Variables: # integer INDX_START=42 N_PRIMES=42 -# # Functions: +# # Functions: # -# # Function _isprime(n) return 1 for prime, 0 for not prime +# # Function _isprime(n) return 1 for prime, 0 for not prime # function _isprime { - typeset _n ; integer _n=$1 - typeset _i ; integer _i + typeset _n ; integer _n=$1 + typeset _i ; integer _i - (( _n < 2 )) && return 0 - for (( _i=2 ; _i*_i<=_n ; _i++ )); do - (( ! ( _n % _i ) )) && return 0 - done - return 1 + (( _n < 2 )) && return 0 + for (( _i=2 ; _i*_i<=_n ; _i++ )); do + (( ! ( _n % _i ) )) && return 0 + done + return 1 } ###### @@ -27,9 +27,9 @@ function _isprime { ###### integer i n=0 for ((i=INDX_START; n -n = 1 43 -n = 2 89 -n = 3 179 -n = 4 359 -n = 5 719 -n = 6 1439 -n = 7 2879 -n = 8 5779 -n = 9 11579 -n = 10 23159 -n = 11 46327 -n = 12 92657 -n = 13 185323 -n = 14 370661 -n = 15 741337 -n = 16 1482707 -n = 17 2965421 -n = 18 5930887 -n = 19 11861791 -n = 20 23723597 -n = 21 47447201 -n = 22 94894427 -n = 23 189788857 -n = 24 379577741 -n = 25 759155483 -n = 26 1518310967 -n = 27 3036621941 -n = 28 6073243889 -n = 29 12146487779 -n = 30 24292975649 -n = 31 48585951311 -n = 32 97171902629 -n = 33 194343805267 -n = 34 388687610539 -n = 35 777375221081 -n = 36 1554750442183 -n = 37 3109500884389 -n = 38 6219001768781 -n = 39 12438003537571 -n = 40 24876007075181 -n = 41 49752014150467 -n = 42 99504028301131 +n = 1 43 +n = 2 89 +n = 3 179 +n = 4 359 +n = 5 719 +n = 6 1439 +n = 7 2879 +n = 8 5779 +n = 9 11579 +n = 10 23159 +n = 11 46327 +n = 12 92657 +n = 13 185323 +n = 14 370661 +n = 15 741337 +n = 16 1482707 +n = 17 2965421 +n = 18 5930887 +n = 19 11861791 +n = 20 23723597 +n = 21 47447201 +n = 22 94894427 +n = 23 189788857 +n = 24 379577741 +n = 25 759155483 +n = 26 1518310967 +n = 27 3036621941 +n = 28 6073243889 +n = 29 12146487779 +n = 30 24292975649 +n = 31 48585951311 +n = 32 97171902629 +n = 33 194343805267 +n = 34 388687610539 +n = 35 777375221081 +n = 36 1554750442183 +n = 37 3109500884389 +n = 38 6219001768781 +n = 39 12438003537571 +n = 40 24876007075181 +n = 41 49752014150467 +n = 42 99504028301131 diff --git a/Task/Loops-Increment-loop-index-within-loop-body/Maple/loops-increment-loop-index-within-loop-body.maple b/Task/Loops-Increment-loop-index-within-loop-body/Maple/loops-increment-loop-index-within-loop-body.maple index ef938b3df1..8b0bfa576f 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/Maple/loops-increment-loop-index-within-loop-body.maple +++ b/Task/Loops-Increment-loop-index-within-loop-body/Maple/loops-increment-loop-index-within-loop-body.maple @@ -1,10 +1,10 @@ i := 42: count := 0: while(count < 42) do - i := i+1: - if type(i,prime) then - count := count + 1: - printf("n=%-2d %19d\n", count,i): - i := 2*i -1: - end if: + i := i+1: + if type(i,prime) then + count := count + 1: + printf("n=%-2d %19d\n", count,i): + i := 2*i -1: + end if: end do: diff --git a/Task/Loops-Increment-loop-index-within-loop-body/Pluto/loops-increment-loop-index-within-loop-body.pluto b/Task/Loops-Increment-loop-index-within-loop-body/Pluto/loops-increment-loop-index-within-loop-body.pluto new file mode 100644 index 0000000000..8ba1995dff --- /dev/null +++ b/Task/Loops-Increment-loop-index-within-loop-body/Pluto/loops-increment-loop-index-within-loop-body.pluto @@ -0,0 +1,27 @@ +local function is_prime(n) + assert(n % 1 == 0, "Argument must be an integer.") + if n < 2 then return false end + if n % 2 == 0 then return n == 2 end + if n % 3 == 0 then return n == 3 end + local d = 5 + while d * d <= n do + if n % d == 0 then return false end + d += 2 + if n % d == 0 then return false end + d += 4 + end + return true +end + +local count = 0 +local i = 42 +while count < 42 do + if is_prime(i) then + ++count + local str1 = string.format("%2d", count) + local str2 = string.format("%18s", string.formatint(i)) + print($"{str1}: {str2}") + i = 2 * i - 1 + end + ++i +end diff --git a/Task/Loops-Increment-loop-index-within-loop-body/REBOL/loops-increment-loop-index-within-loop-body.rebol b/Task/Loops-Increment-loop-index-within-loop-body/REBOL/loops-increment-loop-index-within-loop-body.rebol new file mode 100644 index 0000000000..672a4090cb --- /dev/null +++ b/Task/Loops-Increment-loop-index-within-loop-body/REBOL/loops-increment-loop-index-within-loop-body.rebol @@ -0,0 +1,50 @@ +Rebol [ + title: "Rosetta code: Increment loop index within loop body" + file: %Increment_loop_index_within_loop_body.r3 + url: https://rosettacode.org/wiki/Increment_loop_index_within_loop_body + needs: 3.0.0 +] + +;; prime? native function is available since 3.19.5 +if unset? 'prime? [ + ;; Naive Rebol implementation + prime?: function [n [integer!]] [ + if n < 2 [return false] + if zero? n % 2 [return n == 2] + if zero? n % 3 [return n == 3] + d: 5 + while [d * d <= n][ + if zero? n % d [return false] + d: d + 2 + if zero? n % d [return false] + d: d + 4 + ] + true + ] +] + +;; Helper to format number with commas +format-commas: function [num [integer!]] [ + str: reverse form num + while [not tail? str: skip str 3][ + str: insert str "," + ] + reverse head str +] + +;; Main logic +index: 42 ;; start index at 42 (before first increment) +count-primes: 0 ;; count of primes found +while [count-primes < 42] [ + index: index + 1 ;; increment index by 1 at iteration start + if prime? index [ + count-primes: count-primes + 1 + print rejoin [ + pad count-primes -2 + ": prime = " + pad format-commas index -18 + ] + ;; increment index by the prime itself (old index + prime) + index: index + index + ] () +] diff --git a/Task/Loops-Infinite/Eiffel/loops-infinite.e b/Task/Loops-Infinite/Eiffel/loops-infinite.e new file mode 100644 index 0000000000..787068335c --- /dev/null +++ b/Task/Loops-Infinite/Eiffel/loops-infinite.e @@ -0,0 +1,11 @@ +class APPLICATION +create make +feature + make do + from + until false + loop + IO.put_string ("SPAM%N") + end + end +end diff --git a/Task/Loops-Infinite/Pluto/loops-infinite.pluto b/Task/Loops-Infinite/Pluto/loops-infinite.pluto new file mode 100644 index 0000000000..ad46810b80 --- /dev/null +++ b/Task/Loops-Infinite/Pluto/loops-infinite.pluto @@ -0,0 +1 @@ +while true do print("SPAM") end diff --git a/Task/Loops-Infinite/REBOL/loops-infinite.rebol b/Task/Loops-Infinite/REBOL/loops-infinite-1.rebol similarity index 100% rename from Task/Loops-Infinite/REBOL/loops-infinite.rebol rename to Task/Loops-Infinite/REBOL/loops-infinite-1.rebol diff --git a/Task/Loops-Infinite/REBOL/loops-infinite-2.rebol b/Task/Loops-Infinite/REBOL/loops-infinite-2.rebol new file mode 100644 index 0000000000..3315e9d36f --- /dev/null +++ b/Task/Loops-Infinite/REBOL/loops-infinite-2.rebol @@ -0,0 +1 @@ +until [print "SPAM" false] diff --git a/Task/Loops-Infinite/REBOL/loops-infinite-3.rebol b/Task/Loops-Infinite/REBOL/loops-infinite-3.rebol new file mode 100644 index 0000000000..a24bd8f406 --- /dev/null +++ b/Task/Loops-Infinite/REBOL/loops-infinite-3.rebol @@ -0,0 +1 @@ +while[true][print "SPAM"] diff --git a/Task/Loops-Infinite/TAV/loops-infinite.tav b/Task/Loops-Infinite/TAV/loops-infinite.tav new file mode 100644 index 0000000000..0c791f4cb2 --- /dev/null +++ b/Task/Loops-Infinite/TAV/loops-infinite.tav @@ -0,0 +1,2 @@ + ?* \ a loop without condition runs forever (unless exited by '?>') + print 'SPAM' diff --git a/Task/Loops-N-plus-one-half/DuckDB/loops-n-plus-one-half.duckdb b/Task/Loops-N-plus-one-half/DuckDB/loops-n-plus-one-half.duckdb new file mode 100644 index 0000000000..124af5de19 --- /dev/null +++ b/Task/Loops-N-plus-one-half/DuckDB/loops-n-plus-one-half.duckdb @@ -0,0 +1,14 @@ +create or replace function list_join(lst, joiner) as ( + with recursive cte as ( + select 0 as ix, '' as s + union all + select ix+1 as ix, + if (s = '', '', s || joiner) || lst[ix+1]::VARCHAR) as s + from cte + where ix < length(lst) + ) + select last(s) + from cte +); + +select list_join(range(1,11), ', '); diff --git a/Task/Loops-N-plus-one-half/Pluto/loops-n-plus-one-half.pluto b/Task/Loops-N-plus-one-half/Pluto/loops-n-plus-one-half.pluto new file mode 100644 index 0000000000..debaa8bfa5 --- /dev/null +++ b/Task/Loops-N-plus-one-half/Pluto/loops-n-plus-one-half.pluto @@ -0,0 +1,4 @@ +for i = 1, 10 do + io.write(i) + io.write(i < 10 ? ", " : "\n") +end diff --git a/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-1.tav b/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-1.tav new file mode 100644 index 0000000000..86a2d8232d --- /dev/null +++ b/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-1.tav @@ -0,0 +1,6 @@ + ?# i =: from 1 upto 10 + print i nonl + ? i = 10 + ?> \ break loop + print ', ' nonl + print '' diff --git a/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-2.tav b/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-2.tav new file mode 100644 index 0000000000..54ca2e8769 --- /dev/null +++ b/Task/Loops-N-plus-one-half/TAV/loops-n-plus-one-half-2.tav @@ -0,0 +1,6 @@ + for i = from 1 upto 10 + print i nonl + if i = 10 + break + print ', ' nonl + print '' diff --git a/Task/Loops-Nested/DuckDB/loops-nested.duckdb b/Task/Loops-Nested/DuckDB/loops-nested.duckdb new file mode 100644 index 0000000000..fcc8011deb --- /dev/null +++ b/Task/Loops-Nested/DuckDB/loops-nested.duckdb @@ -0,0 +1,50 @@ +# PRN in range(0,n) +create or replace function prn(n) as + trunc(random() * n)::BIGINT; + +create or replace function random_array(n, twenty) as + list_transform(range(0,n), x-> 1+prn(twenty)); + +create or replace function random_matrix(m, n, twenty) as ( + list_transform(range(0,m), x -> random_array(n, twenty)) +); + +# Scanning the matrix row-wise, return a list of the cells up to +# but excluding n, or else []. +# WARNING: The matrix `matrix` should be materialized before entry! +# Note the type declaration for `matrix`. +create or replace function matrix_up_to(matrix, n) as ( + if (length(matrix) = 0, [], + (with recursive matrix_t as (select matrix::BIGINT[][] as m), + cte1 as ( + select 1 as ix, + coalesce(list_position(m[1], n), 0) as p, + [] as s + from matrix_t + union all + select ix+1 as ix, + if (p = 0, coalesce(list_position(m[ix+1], n), 0), + -1) as p, + (s || if (@p = 1, [], + if (p>0, m[ix][:p-1], + m[ix] ) )) as s + from cte1, matrix_t + where p != -1 and + ix <= length(m) + ) + -- for verification: select ((last(s), any_value(matrix))) + select last(s) + from cte1 + ) ) +); + +.mode list +.header off + +# Because of the way DuckDB inlines functions, the matrix produced +# by random_matrix() must be materialized before it can be properly handled. +# Using DuckDB V1.1, this can be done using SET VARIABLE: + +set variable matrix = random_matrix(10,5, 20); + +select matrix_up_to( getvariable('matrix'), 20 ) as head; diff --git a/Task/Loops-Nested/Pluto/loops-nested.pluto b/Task/Loops-Nested/Pluto/loops-nested.pluto new file mode 100644 index 0000000000..022fc1f303 --- /dev/null +++ b/Task/Loops-Nested/Pluto/loops-nested.pluto @@ -0,0 +1,18 @@ +local a = {} +for i = 1, 20 do + a[i] = {} + for j = 1, 20 do + a[i][j] = math.random(1, 20) + end +end + +for i = 1, 20 do + for j = 1, 20 do + io.write(string.format("%2d ", a[i][j])) + if a[i][j] == 20 then + print() + break 2 -- break from outer loop + end + if j % 10 == 0 then print() end + end +end diff --git a/Task/Loops-Nested/REBOL/loops-nested.rebol b/Task/Loops-Nested/REBOL/loops-nested.rebol index 0e0c58920f..b2ea53ae32 100644 --- a/Task/Loops-Nested/REBOL/loops-nested.rebol +++ b/Task/Loops-Nested/REBOL/loops-nested.rebol @@ -12,7 +12,7 @@ random/seed now ; Create array and fill with random numbers, range 1..20. soup: array [10 10] -repeat row soup [forall row [row/1: random 20]] +foreach row soup [forall row [row/1: random 20]] print "Loop break using state variable:" done: no diff --git a/Task/Loops-Nested/Zig/loops-nested.zig b/Task/Loops-Nested/Zig/loops-nested.zig new file mode 100644 index 0000000000..3fe5cf6098 --- /dev/null +++ b/Task/Loops-Nested/Zig/loops-nested.zig @@ -0,0 +1,38 @@ +const std = @import("std"); + +const ARR_ROWS = 10; +const ARR_COLS = 10; + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + var prng = std.Random.DefaultPrng.init(blk: { + var seed: u64 = undefined; + try std.posix.getrandom(std.mem.asBytes(&seed)); + break :blk seed; + }); + const rand = prng.random(); + var bi_arr: [ARR_ROWS][ARR_COLS]u8 = undefined; + + // generate values for the bi-dimensional array + for (0..ARR_ROWS) |row| { + for (0..ARR_COLS) |col| { + bi_arr[row][col] = rand.intRangeAtMost(u8, 0, 20); + } + } + + // search for the value 20 in the bi-dimensional array + const target: u8 = 20; + search: for (0..ARR_ROWS) |row| { + for (0..ARR_COLS) |col| { + try stdout.print("{d:2} ", .{bi_arr[row][col]}); + + if (bi_arr[row][col] == target) { + break :search; + } + } + + try stdout.print("\n", .{}); + } + + try stdout.print("\n", .{}); +} diff --git a/Task/Loops-While/DuckDB/loops-while.duckdb b/Task/Loops-While/DuckDB/loops-while.duckdb new file mode 100644 index 0000000000..11df13fc66 --- /dev/null +++ b/Task/Loops-While/DuckDB/loops-while.duckdb @@ -0,0 +1,15 @@ +# Start at `start` +create or replace function task(start) as table ( + with recursive cte as ( + select start::BIGINT as n + union all + select + n // 2 as n + from cte + where n > 0 -- "while n > 0" + ) + from cte + where n > 0 -- comment me out to include the last 0 +); + +from task(1024); diff --git a/Task/Loops-While/Mn/loops-while.mn b/Task/Loops-While/Mn/loops-while.mn new file mode 100644 index 0000000000..9080cea70b --- /dev/null +++ b/Task/Loops-While/Mn/loops-while.mn @@ -0,0 +1,6 @@ +1024 +(dup 1 >=) ( + puts + 2 / +) while +pop diff --git a/Task/Loops-While/Pluto/loops-while.pluto b/Task/Loops-While/Pluto/loops-while.pluto new file mode 100644 index 0000000000..8466074739 --- /dev/null +++ b/Task/Loops-While/Pluto/loops-while.pluto @@ -0,0 +1,5 @@ +local i = 1024 +while i > 0 do + print(i) + i //= 2 +end diff --git a/Task/Loops-While/REBOL/loops-while.rebol b/Task/Loops-While/REBOL/loops-while.rebol index 8c7f301587..c580644c20 100644 --- a/Task/Loops-While/REBOL/loops-while.rebol +++ b/Task/Loops-While/REBOL/loops-while.rebol @@ -6,5 +6,5 @@ REBOL [ value: 1024 while [value > 0][ print value - value: to-integer value / 2 + value: to integer! value / 2 ] diff --git a/Task/Loops-While/TAV/loops-while.tav b/Task/Loops-While/TAV/loops-while.tav new file mode 100644 index 0000000000..8a36401968 --- /dev/null +++ b/Task/Loops-While/TAV/loops-while.tav @@ -0,0 +1,4 @@ + i =: 1024 + ?* i >= 1 + print i + i =: i // 2 \ integer division" diff --git a/Task/Loops-While/Ursalang/loops-while.ursa b/Task/Loops-While/Ursalang/loops-while.ursa new file mode 100644 index 0000000000..ba129a5114 --- /dev/null +++ b/Task/Loops-While/Ursalang/loops-while.ursa @@ -0,0 +1,6 @@ +var n = 1024 +loop { + if not (n > 0) { break } + print(n) + n := n >>> 1 +} diff --git a/Task/Loops-While/Zig/loops-while.zig b/Task/Loops-While/Zig/loops-while.zig index a2011742c1..dca717a879 100644 --- a/Task/Loops-While/Zig/loops-while.zig +++ b/Task/Loops-While/Zig/loops-while.zig @@ -1,7 +1,10 @@ const std = @import("std"); -pub fn main() void { - var i: u11 = 1024; - while (i > 0) : (i /= 2) - std.debug.print("{}\n", .{i}); +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + + var n: u16 = 1024; + while (n > 0) : (n = @divTrunc(n, 2)) { + try stdout.print("{d}\n", .{n}); + } } diff --git a/Task/Loops-With-multiple-ranges/DuckDB/loops-with-multiple-ranges.duckdb b/Task/Loops-With-multiple-ranges/DuckDB/loops-with-multiple-ranges.duckdb new file mode 100644 index 0000000000..8e6b2c5cb3 --- /dev/null +++ b/Task/Loops-With-multiple-ranges/DuckDB/loops-with-multiple-ranges.duckdb @@ -0,0 +1,32 @@ +create or replace function ranges(x, y, z, one, three, seven) as ( + range(-three, ((1 + 3) ^ 3)::BIGINT, three) || + range( -seven, 1 + seven, x) || + range( 555, 1 + 550 - y) || + range( 22,-1 -28, -three) || + range(1927 , 1 + 1939 ) || + range(x , y, z) || + range((11 ^ x)::BIGINT, 1 + ( 11 ^ x)::BIGINT + one) +); + +create or replace function task(x,y,z, one, three, seven) as table ( + with recursive lst as (select ranges(x,y,z, one, three, seven) as lst), + cte as ( + select 1 as ix, -- index into ranges() + 0 as j, + 0 as sum, + 1 as prod -- start with a product of unity + union all + select ix + 1 as ix, + lst.lst[ix] as j, + (sum + (@j)) as sum, + if ((@prod) < (2 ^ 27)::BIGINT and j != 0, + prod * j, + prod) as prod + from cte, lst + where ix <= 1 + length(lst) + ) + select last(sum) as sum, last(prod) as prod + from cte +); + +from task(5, -5, -2, 1, 3, 7); diff --git a/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges.hs b/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-1.hs similarity index 100% rename from Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges.hs rename to Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-1.hs diff --git a/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-2.hs b/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-2.hs new file mode 100644 index 0000000000..56ab9d8f9a --- /dev/null +++ b/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-2.hs @@ -0,0 +1,30 @@ +procedure main() + prod := 1 + sum := 0 + x := +5 + y := -5 + z := -2 + one := 1 + three := 3 + seven := 7 + + every j := resultsof { + -three to 3^3 by three , + -seven to +seven by x , + 555 to 550 - y , + 22 to -28 by -three , + 1927 to 1939 , + x to y by z , + 11^x to 11^x + one + } do { + sum := sum + abs(j) + if abs(prod) < 2^27 & j ~= 0 then prod := prod*j + } + write(" sum = ", sum) + write("prod = ", prod) +end + +procedure resultsof(celist) + every ce := !celist do + while e := @ce do suspend e +end diff --git a/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-3.hs b/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-3.hs new file mode 100644 index 0000000000..14533b0f49 --- /dev/null +++ b/Task/Loops-With-multiple-ranges/Haskell/loops-with-multiple-ranges-3.hs @@ -0,0 +1,27 @@ +procedure main() + prod := 1 + sum := 0 + x := +5 + y := -5 + z := -2 + one := 1 + three := 3 + seven := 7 + + i_to_h_by_k := proc("...",3) # i_to_h_by_k(i,h,k) + # same as "i to h by k" + every j := i_to_h_by_k ! ![ + [ -three , 3^3 , three ] , + [ -seven , +seven , x ] , + [ 555 , 550 - y , one ] , # list of argument lists + [ 22 , -28 , -three ] , # (i,h,k) + [ 1927 , 1939 , one ] , + [ x , y , z ] , + [ 11^x , 11^x + one , one ] + ] do { + sum := sum + abs(j) + if abs(prod) < 2^27 & j ~= 0 then prod := prod*j + } + write(" sum = ", sum) + write("prod = ", prod) +end diff --git a/Task/Loops-With-multiple-ranges/Pluto/loops-with-multiple-ranges.pluto b/Task/Loops-With-multiple-ranges/Pluto/loops-with-multiple-ranges.pluto new file mode 100644 index 0000000000..7b6de5c7fc --- /dev/null +++ b/Task/Loops-With-multiple-ranges/Pluto/loops-with-multiple-ranges.pluto @@ -0,0 +1,60 @@ +local prod = 1 +local sum = 0 +local x = 5 +local y = -5 +local z = -2 +local one = 1 +local three = 3 +local seven = 7 +local p = math.round(11 ^ x) +local j = 0 + +local function process() + sum += math.abs(j) + if math.abs(prod) < (1 << 27) and j != 0 then prod *= j end +end + +j = -three +while j <= 3 ^ 3 do + process() + j += three +end + +j = -seven +while j <= seven do + process() + j += x +end + +j = 555 +while j <= 550 - y do + process() + ++j +end + +j = 22 +while j >= -28 do + process() + j -= three +end + +j = 1927 +while j <= 1939 do + process() + ++j +end + +j = x +while j >= y do + process() + j -= -z +end + +j = p +while j <= p + one do + process() + ++j +end + +print($"sum = {string.formatint(sum)}") +print($"prod = {string.formatint(prod)}") diff --git a/Task/Loops-With-multiple-ranges/REBOL/loops-with-multiple-ranges.rebol b/Task/Loops-With-multiple-ranges/REBOL/loops-with-multiple-ranges.rebol new file mode 100644 index 0000000000..2ac667dae9 --- /dev/null +++ b/Task/Loops-With-multiple-ranges/REBOL/loops-with-multiple-ranges.rebol @@ -0,0 +1,59 @@ +Rebol [ + title: "Rosetta code: Loops/With multiple ranges" + file: %Loops-With_multiple_ranges.r3 + url: https://rosettacode.org/wiki/Loops/With_multiple_ranges + needs: 3.0.0 + note: {Based on Rosetta Code Red language task solution} +] +;; Define a function that iterates over multiple ranges +for-ranges: function/with ['word ranges body][ + ;; Clear temporary buffer + inp: clear [] + ;; Bind ranges dialect to context of this function + bind ranges self + foreach c reduce ranges [append inp c] + foreach i inp [set word i do body] +] context [ + inp: copy [] + ;; Define a custom operator 'to' that creates a range from start to end + ;- Note: `to` function redefinition! + to: make op! function [start end][ + res: copy [] + repeat n 1 + absolute to-integer end - start [ + append res start + either start > end [1 - n][n - 1] + ] + ] + ;; Define a custom operator 'by' that extracts every nth element from a series + by: make op! function [s w] [extract s absolute w] +] + +;; Initialize variables + prod: 1 + sum: 0 + x: +5 + y: -5 + z: -2 + one: 1 +three: 3 +seven: 7 + +;; Execute for-ranges with variable 'j' over multiple range expressions +for-ranges j [ + 0 - three to (3 ** 3) by three + 0 - seven to seven by x + 555 to (550 - y) + 22 to -28 by (0 - three) + 1927 to 1939 + x to y by z + 11 ** x to (11 ** x + one) +][ + ;; Body of the loop executed for each value of j + ;; Add absolute value of j to sum + sum: to-integer sum + absolute j + ;; Multiply prod by j if conditions are met: + ;; - absolute value of prod is less than 2^27 (134,217,728) + ;; - j is not zero (to avoid making prod zero) + if all [(absolute prod) < power 2 27 j <> 0] [prod: prod * j] +] +;; Print the final results +print ["sum: " sum "^/prod:" prod] diff --git a/Task/Loops-Wrong-ranges/C++/loops-wrong-ranges.cpp b/Task/Loops-Wrong-ranges/C++/loops-wrong-ranges.cpp index ef6a43fd98..5d61ef35a6 100644 --- a/Task/Loops-Wrong-ranges/C++/loops-wrong-ranges.cpp +++ b/Task/Loops-Wrong-ranges/C++/loops-wrong-ranges.cpp @@ -5,44 +5,44 @@ #include struct LoopData { - int32_t start; - int32_t stop; - int32_t increment; - std::string comment; + int32_t start; + int32_t stop; + int32_t increment; + std::string comment; }; void print_vector(const std::vector& list) { - std::cout << "["; - for ( uint64_t i = 0; i < list.size(); ++i ) { - std::cout << list[i]; - if ( i < list.size() - 1 ) { - std::cout << ", "; - } - } - std::cout << "]"; + std::cout << "["; + for ( uint64_t i = 0; i < list.size(); ++i ) { + std::cout << list[i]; + if ( i < list.size() - 1 ) { + std::cout << ", "; + } + } + std::cout << "]"; } void runTest(const LoopData& loop_data) { - std::vector values{}; - for ( int32_t i = loop_data.start; i <= loop_data.stop; i += loop_data.increment ) { - values.emplace_back(i); - if ( values.size() >= 10 ) { - break; - } - } + std::vector values{}; + for ( int32_t i = loop_data.start; i <= loop_data.stop; i += loop_data.increment ) { + values.emplace_back(i); + if ( values.size() >= 10 ) { + break; + } + } - std::cout << std::left << std::setw(45) << loop_data.comment; print_vector(values); - std::cout << ( values.size() == 10 ? " (loops forever)" : "" ) << std::endl; + std::cout << std::left << std::setw(45) << loop_data.comment; print_vector(values); + std::cout << ( values.size() == 10 ? " (loops forever)" : "" ) << std::endl; } int main() { - runTest(LoopData(-2, 2, 1, "Normal")); - runTest(LoopData(-2, 2, 0, "Zero increment")); - runTest(LoopData(-2, 2, -1, "Increments away from stop value")); - runTest(LoopData(-2, 2, 10, "First increment is beyond stop value")); - runTest(LoopData(2, -2, 1, "Start more than stop: positive increment")); - runTest(LoopData(2, 2, 1, "Start equal stop: positive increment")); - runTest(LoopData(2, 2, -1, "Start equal stop: negative increment")); - runTest(LoopData(2, 2, 0, "Start equal stop: zero increment")); - runTest(LoopData(0, 0, 0, "Start equal stop equal zero: zero increment")); + runTest(LoopData(-2, 2, 1, "Normal")); + runTest(LoopData(-2, 2, 0, "Zero increment")); + runTest(LoopData(-2, 2, -1, "Increments away from stop value")); + runTest(LoopData(-2, 2, 10, "First increment is beyond stop value")); + runTest(LoopData(2, -2, 1, "Start more than stop: positive increment")); + runTest(LoopData(2, 2, 1, "Start equal stop: positive increment")); + runTest(LoopData(2, 2, -1, "Start equal stop: negative increment")); + runTest(LoopData(2, 2, 0, "Start equal stop: zero increment")); + runTest(LoopData(0, 0, 0, "Start equal stop equal zero: zero increment")); } diff --git a/Task/Loops-Wrong-ranges/Common-Lisp/loops-wrong-ranges.lisp b/Task/Loops-Wrong-ranges/Common-Lisp/loops-wrong-ranges.lisp index e651ee0ced..771e433bac 100644 --- a/Task/Loops-Wrong-ranges/Common-Lisp/loops-wrong-ranges.lisp +++ b/Task/Loops-Wrong-ranges/Common-Lisp/loops-wrong-ranges.lisp @@ -1,18 +1,18 @@ -(dolist (lst '((-2 2 1 "Normal") ; Iterate the parameters list `start' `stop' `increment' and `comment' - (-2 2 0 "Zero increment") - (-2 2 -1 "Increments away from stop value") - (-2 2 10 "First increment is beyond stop value") - ( 2 -2 1 "Start more than stop: positive increment") - ( 2 2 1 "Start equal stop: positive increment") - ( 2 2 -1 "Start equal stop: negative increment") - ( 2 2 0 "Start equal stop: zero increment") - ( 0 0 0 "Start equal stop equal zero: zero increment"))) +(dolist (lst '((-2 2 1 "Normal") ; Iterate the parameters list `start' `stop' `increment' and `comment' + (-2 2 0 "Zero increment") + (-2 2 -1 "Increments away from stop value") + (-2 2 10 "First increment is beyond stop value") + ( 2 -2 1 "Start more than stop: positive increment") + ( 2 2 1 "Start equal stop: positive increment") + ( 2 2 -1 "Start equal stop: negative increment") + ( 2 2 0 "Start equal stop: zero increment") + ( 0 0 0 "Start equal stop equal zero: zero increment"))) (do ((i (car lst) (incf i (caddr lst))) ; Initialize `start' and set `increment' - (result ()) ; Initialize the result list - (loop-max 0 (incf loop-max))) ; Initialize a loop limit - ((or (> i (cadr lst)) ; Break condition to `stop' - (> loop-max 10)) ; Break condition to loop limit - (format t "~&~44a: ~{~3d ~}" ; Finally print - (cadddr lst) ; The `comment' - (reverse result))) ; The in(de)creased numbers into result - (push i result))) ; Add the number to result + (result ()) ; Initialize the result list + (loop-max 0 (incf loop-max))) ; Initialize a loop limit + ((or (> i (cadr lst)) ; Break condition to `stop' + (> loop-max 10)) ; Break condition to loop limit + (format t "~&~44a: ~{~3d ~}" ; Finally print + (cadddr lst) ; The `comment' + (reverse result))) ; The in(de)creased numbers into result + (push i result))) ; Add the number to result diff --git a/Task/Loops-Wrong-ranges/Eiffel/loops-wrong-ranges.e b/Task/Loops-Wrong-ranges/Eiffel/loops-wrong-ranges.e index 5200ea6e78..d746f33052 100644 --- a/Task/Loops-Wrong-ranges/Eiffel/loops-wrong-ranges.e +++ b/Task/Loops-Wrong-ranges/Eiffel/loops-wrong-ranges.e @@ -1,13 +1,13 @@ example - -- Loops/Wrong ranges - do - ⟳ ic:(-2 |..| 2) ¦ do_nothing ⟲ -- 2 2 1 Normal - ⟳ ic:(-2 |..| 2).new_cursor + 0 ¦ do_nothing ⟲ -- -2 2 0 Zero increment - ⟳ ic:(-2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ -- -2 2 -1 Increments away from stop value - ⟳ ic:(-2 |..| 2).new_cursor + 10 ¦ do_nothing ⟲ -- -2 2 10 First increment is beyond stop value - ⟳ ic:(-2 |..| 2).new_cursor.reversed ¦ do_nothing ⟲ -- 2 -2 1 Start more than stop: positive increment - ⟳ ic:(2 |..| 2) ¦ do_nothing ⟲ -- 2 2 1 Start equal stop: positive increment - ⟳ ic:(2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ -- 2 2 -1 Start equal stop: negative increment - ⟳ ic:(2 |..| 2).new_cursor + 0 ¦ do_nothing ⟲ -- 2 2 0 Start equal stop: zero increment - ⟳ ic:(0 |..| 0).new_cursor + 0 ¦ do_nothing ⟲ -- 0 0 0 Start equal stop equal zero: zero increment - end + -- Loops/Wrong ranges + do + ⟳ ic:(-2 |..| 2) ¦ do_nothing ⟲ -- 2 2 1 Normal + ⟳ ic:(-2 |..| 2).new_cursor + 0 ¦ do_nothing ⟲ -- -2 2 0 Zero increment + ⟳ ic:(-2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ -- -2 2 -1 Increments away from stop value + ⟳ ic:(-2 |..| 2).new_cursor + 10 ¦ do_nothing ⟲ -- -2 2 10 First increment is beyond stop value + ⟳ ic:(-2 |..| 2).new_cursor.reversed ¦ do_nothing ⟲ -- 2 -2 1 Start more than stop: positive increment + ⟳ ic:(2 |..| 2) ¦ do_nothing ⟲ -- 2 2 1 Start equal stop: positive increment + ⟳ ic:(2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ -- 2 2 -1 Start equal stop: negative increment + ⟳ ic:(2 |..| 2).new_cursor + 0 ¦ do_nothing ⟲ -- 2 2 0 Start equal stop: zero increment + ⟳ ic:(0 |..| 0).new_cursor + 0 ¦ do_nothing ⟲ -- 0 0 0 Start equal stop equal zero: zero increment + end diff --git a/Task/Loops-Wrong-ranges/Icon/loops-wrong-ranges.icon b/Task/Loops-Wrong-ranges/Icon/loops-wrong-ranges.icon new file mode 100644 index 0000000000..40432a2145 --- /dev/null +++ b/Task/Loops-Wrong-ranges/Icon/loops-wrong-ranges.icon @@ -0,0 +1,39 @@ +procedure main() + testdata := [ + # args Comment + # start stop incr + [[-2, 2, 1], "Normal"], + [[-2, 2, 0], "Zero increment"], + [[-2, 2, -1], "Increments away from stop value"], + [[-2, 2, 10], "First increment is beyond stop value"], + [[ 2, -2, 1], "Start more than stop: positive increment"], + [[ 2, 2, 1], "Start equal stop: positive increment"], + [[ 2, 2, -1], "Start equal stop: negative increment"], + [[ 2, 2, 0], "Start equal stop: zero increment"], + [[ 0, 0, 0], "Start equal stop equal zero: zero increment"] + ] + + range := proc("...",3) ; # range(i,j,k) same as "i to j by k" + every argcom := !testdata do{ + write("\n",argcom[2]) + writes("range(",seqimage(argcom[1]),")") + &error := 1 + every elements := [] & put(elements, range ! argcom[1]) + if &errornumber then{ + write(" --->") + write("\tRun-time error ", &errornumber) + write("\t",&errortext) + write("\toffending value: ", image(&errorvalue)) + errorclear() + }else{ + &error := 0 + if *elements ~= 0 then write(" = ",seqimage(elements)) + else write(" (no result)") + } + } +end + +procedure seqimage(L) + every result := "" & result ||:= image(!L) || ", " + return result[1:-2] +end diff --git a/Task/Loops-Wrong-ranges/Pluto/loops-wrong-ranges.pluto b/Task/Loops-Wrong-ranges/Pluto/loops-wrong-ranges.pluto new file mode 100644 index 0000000000..d447208393 --- /dev/null +++ b/Task/Loops-Wrong-ranges/Pluto/loops-wrong-ranges.pluto @@ -0,0 +1,19 @@ +local function loop(start, stop, inc) + local f = "{%3d %3d %3d} -> " + io.write(string.format(f, start, stop, inc)) + local count = 0 + local limit = 10 + local i = start + while i <= stop do + io.write(string.format("%3d ", i)) + if ++count == limit then break end + i += inc + end + print() +end + +local tests = { + {-2, 2, 1}, {-2, 2, 0}, {-2, 2, -1}, {-2, 2, 10}, {2, -2, 1}, + { 2, 2, 1}, { 2, 2, -1}, { 2, 2, 0}, { 0, 0, 0} +} +for tests as test do loop(test[1], test[2], test[3]) end diff --git a/Task/Loops-Wrong-ranges/Python/loops-wrong-ranges.py b/Task/Loops-Wrong-ranges/Python/loops-wrong-ranges.py index debcbd4ef8..3046697673 100644 --- a/Task/Loops-Wrong-ranges/Python/loops-wrong-ranges.py +++ b/Task/Loops-Wrong-ranges/Python/loops-wrong-ranges.py @@ -5,16 +5,16 @@ from itertools import islice # To limit execution if it would generate huge valu data = ''' -start stop increment Comment --2 2 1 Normal --2 2 0 Zero increment --2 2 -1 Increments away from stop value --2 2 10 First increment is beyond stop value -2 -2 1 Start more than stop: positive increment -2 2 1 Start equal stop: positive increment -2 2 -1 Start equal stop: negative increment -2 2 0 Start equal stop: zero increment -0 0 0 Start equal stop equal zero: zero increment +start stop increment Comment +-2 2 1 Normal +-2 2 0 Zero increment +-2 2 -1 Increments away from stop value +-2 2 10 First increment is beyond stop value +2 -2 1 Start more than stop: positive increment +2 2 1 Start equal stop: positive increment +2 2 -1 Start equal stop: negative increment +2 2 0 Start equal stop: zero increment +0 0 0 Start equal stop equal zero: zero increment ''' table = [re.split(r'\s\s+', line.strip()) for line in data.strip().split('\n')] diff --git a/Task/Loops-Wrong-ranges/REBOL/loops-wrong-ranges.rebol b/Task/Loops-Wrong-ranges/REBOL/loops-wrong-ranges.rebol new file mode 100644 index 0000000000..07fea975ec --- /dev/null +++ b/Task/Loops-Wrong-ranges/REBOL/loops-wrong-ranges.rebol @@ -0,0 +1,30 @@ +Rebol [ + title: "Rosetta code: Loops/Wrong ranges" + file: %Loops-Wrong_ranges.r3 + url: https://rosettacode.org/wiki/Loops/Wrong_ranges + needs: 3.0.0 +] +make-range: function [start end step][ + res: copy [] + if zero? step [return none] + for i start end step [ + append res i + ] +] +foreach [start end step] [ + -2 2 1 ;Normal + -2 2 0 ;Zero increment + -2 2 -1 ;Increments away from stop value + -2 2 10 ;First increment is beyond stop value + 2 -2 1 ;Start more than stop: positive increment + 2 2 1 ;Start equal stop: positive increment + 2 2 -1 ;Start equal stop: negative increment + 2 2 0 ;Start equal stop: zero increment + 0 0 0 ;Start equal stop equal zero: zero incremen +][ + ;; Using format to pad numbers + prin format ["make-range" -3 -3 -3] reduce [start end step] + prin " ;== " + ;; Output 'make-range' function result + probe make-range start end step +] diff --git a/Task/Luhn-test-of-credit-card-numbers/DuckDB/luhn-test-of-credit-card-numbers.duckdb b/Task/Luhn-test-of-credit-card-numbers/DuckDB/luhn-test-of-credit-card-numbers.duckdb new file mode 100644 index 0000000000..0b20362701 --- /dev/null +++ b/Task/Luhn-test-of-credit-card-numbers/DuckDB/luhn-test-of-credit-card-numbers.duckdb @@ -0,0 +1,43 @@ +create or replace function odds(lst) as ( + list_filter(lst, (x,i) -> i%2=1) +); + +create or replace function evens(lst) as ( + list_filter(lst, (x,i) -> i%2=0) +); + +create or replace function digit_sum(i) as ( + regexp_extract_all(i::VARCHAR, '.') + .list_transform(x -> x::INT) + .list_sum() +); + +# Return boolean: true iff the list of digits passes +create or replace function list_luhn(lst) as ( + with odds_sum as ( + select list_reverse(lst).odds().list_sum() as odds_sum), + evens_reduce as ( + select list_reverse(lst).list_transform(x -> digit_sum(2*x)) + .list_sum() as evens_reduce) + select (odds_sum + evens_reduce ) % 10 = 0 as pass + from odds_sum, evens_reduce +); + +# The list of the digits of i (an integer or string) +create or replace function digits(i) as ( + regexp_extract_all(i::TEXT, '.').list_transform(x -> x::INT) +); + +# i can be an integer or string +create or replace function luhn(i) as ( + digits(i).list_luhn() +); + +## Examples:: +select n, luhn(n), luhn(n::TEXT) as "luhn(n::TEXT)" +from unnest( + [49927398716, + 49927398717, + 1234567812345678, + 1234567812345670 + ]) _(n); diff --git a/Task/Luhn-test-of-credit-card-numbers/Pluto/luhn-test-of-credit-card-numbers.pluto b/Task/Luhn-test-of-credit-card-numbers/Pluto/luhn-test-of-credit-card-numbers.pluto new file mode 100644 index 0000000000..fd67c11fad --- /dev/null +++ b/Task/Luhn-test-of-credit-card-numbers/Pluto/luhn-test-of-credit-card-numbers.pluto @@ -0,0 +1,22 @@ +function luhn(b) + local sum = 0 + local odd = true + for i = #b,1,-1 do + local n = tonumber(b[i]) + if odd then + sum += n + else + n *= 2 + sum += n//10 + n%10 + end + odd = !odd + end + return sum%10 == 0 +end + +a = {"49927398716", +"49927398717", +"1234567812345678", +"1234567812345670"} + +for a as i do print(luhn(i)) end diff --git a/Task/M-bius-function/C-sharp/m-bius-function.cs b/Task/M-bius-function/C-sharp/m-bius-function.cs new file mode 100644 index 0000000000..48a19a5f7c --- /dev/null +++ b/Task/M-bius-function/C-sharp/m-bius-function.cs @@ -0,0 +1,84 @@ +using System; + +namespace MobiusDemo +{ + class Program + { + // ----------------------------------------------------------------- + // Settings that are identical to the Java version + // ----------------------------------------------------------------- + private const int MU_MAX = 1_000_000; // same upper bound + private static int[] MU = null; // will hold the sieve + + static void Main(string[] args) + { + Console.WriteLine("First 199 terms of the möbius function are as follows:"); + Console.Write(" "); + + for (int n = 1; n < 200; n++) + { + Console.Write($"{MobiusFunction(n),2} "); + + // line‑break after every 20 numbers – exactly like the Java code + if ((n + 1) % 20 == 0) + Console.WriteLine(); + } + } + + // ----------------------------------------------------------------- + // Compute μ(n) using the same sieve algorithm that the Java code + // uses. The first call builds the whole table up to MU_MAX. + // ----------------------------------------------------------------- + private static int MobiusFunction(int n) + { + // If the sieve has already been built we can return the answer + // straight away. + if (MU != null) + return MU[n]; + + // ------------------------------------------------------------- + // Build the sieve (once) + // ------------------------------------------------------------- + MU = new int[MU_MAX + 1]; + + // initialise every entry with 1 – Java did this explicitly + for (int i = 0; i <= MU_MAX; i++) + MU[i] = 1; + + int sqrt = (int)Math.Sqrt(MU_MAX); + + // first pass: multiply by -p for each prime factor p, + // and mark multiples of p² as zero. + for (int i = 2; i <= sqrt; i++) + { + if (MU[i] == 1) // i is still “prime” + { + // flip the sign for every multiple of i + for (int j = i; j <= MU_MAX; j += i) + MU[j] *= -i; + + // any number that contains i² gets value 0 + int i2 = i * i; + for (int j = i2; j <= MU_MAX; j += i2) + MU[j] = 0; + } + } + + // second pass: reduce the encoded values to the final μ(n) + for (int i = 2; i <= MU_MAX; i++) + { + if (MU[i] == i) // only +i => μ = +1 + MU[i] = 1; + else if (MU[i] == -i) // only -i => μ = -1 + MU[i] = -1; + else if (MU[i] < 0) // product of an odd number of distinct primes + MU[i] = 1; + else if (MU[i] > 0) // product of an even number of distinct primes + MU[i] = -1; + // note: MU[i] == 0 stays 0 (square factor present) + } + + return MU[n]; + } + } +} diff --git a/Task/M-bius-function/Pascal-P/m-bius-function.pas b/Task/M-bius-function/Pascal-P/m-bius-function.pas new file mode 100644 index 0000000000..b517816160 --- /dev/null +++ b/Task/M-bius-function/Pascal-P/m-bius-function.pas @@ -0,0 +1,39 @@ +program moebius(output); + (* Moebius function *) + +var + t, u: integer; + + function moebius(n: integer): integer; + var + m, f: integer; + begin + m := 1; + if n <> 1 then + begin + f := 2; + repeat + if n mod (f * f) = 0 then + m := 0 + else + begin + if n mod f = 0 then + begin + m := -m; + n := n div f + end; + f := f + 1 + end + until (f > n) or (m = 0) + end; + moebius := m + end; + +begin + for t := 0 to 9 do + begin + for u := 1 to 10 do + write(moebius(10 * t + u): 2, ' '); + writeln + end +end. diff --git a/Task/M-bius-function/Pluto/m-bius-function.pluto b/Task/M-bius-function/Pluto/m-bius-function.pluto new file mode 100644 index 0000000000..2721fda354 --- /dev/null +++ b/Task/M-bius-function/Pluto/m-bius-function.pluto @@ -0,0 +1,35 @@ +local int = require "int" +local fmt = require "fmt" + +local function is_square_free(n) + local i = 2 + local sq = i * i + while sq <= n do + if n % sq == 0 then return false end + i = (i > 2) ? i + 2 : i + 1 + sq = i * i + end + return true +end + +local function mu(n) + assert(n >= 1, "Argument must be a positive integer") + if n == 1 then return 1 end + local sq_free = is_square_free(n) + local factors = int.factors(n) + if sq_free and #factors % 2 == 0 then return 1 end + if sq_free then return -1 end + return 0 +end + +print("The first 199 Möbius numbers are:") +for i = 0, 9 do + for j = 0, 19 do + if i == 0 and j == 0 then + io.write(" ") + else + fmt.write("% 3d ", mu(i * 20 + j)) + end + end + print() +end diff --git a/Task/M-bius-function/PowerShell/m-bius-function.psh b/Task/M-bius-function/PowerShell/m-bius-function.psh new file mode 100644 index 0000000000..9c70eee9de --- /dev/null +++ b/Task/M-bius-function/PowerShell/m-bius-function.psh @@ -0,0 +1,28 @@ +# Moebius function + +function Moebius([int]$N) { + [int]$m = 1 + if ($N -ne 1) { + [int]$f = 2 + do { + if ($N % ($f * $f) -eq 0) { + $m = 0 + } else { + if ($N % $f -eq 0) { + $m = -$m; + $N = [math]::Floor($N / $f) + } + $f += 1 + } + } while (($f -le $N) -and ($m -ne 0)) + } + return $m +} + +foreach ($t in 0..9) { + [string]$row = @() + foreach ($u in 1..10) { + $row += "{0,2} " -f $(Moebius(10 * $t + $u)) + } + Write-Output $row +} diff --git a/Task/M-bius-function/R/m-bius-function.r b/Task/M-bius-function/R/m-bius-function.r new file mode 100644 index 0000000000..e1818c4339 --- /dev/null +++ b/Task/M-bius-function/R/m-bius-function.r @@ -0,0 +1,28 @@ +# Moebius function + +Moebius <- function(n) { + if (n == 1) + return(1) + m <- 1 + f <- 2 + repeat { + if (n %% (f * f) == 0) + m <- 0 + else { + if (n %% f == 0) { + m <- -m + n <- n %/% f + } + f <- f + 1 + } + if (f > n || m == 0) + break + } + return(m) +} + +mb <- matrix(0, 10, 10) +for (t in 0:9) + for (u in 1:10) + mb[t + 1, u] <- Moebius(10 * t + u) +mb diff --git a/Task/M-bius-function/Tcl/m-bius-function.tcl b/Task/M-bius-function/Tcl/m-bius-function.tcl new file mode 100644 index 0000000000..8a46858a3d --- /dev/null +++ b/Task/M-bius-function/Tcl/m-bius-function.tcl @@ -0,0 +1,42 @@ +proc prime_factors {n} { + set d 1 + set factors [list] + while {$n > 1 && $d < $n} { + incr d + set d_squared [expr {$d * $d}] + while {$n % $d == 0} { + lappend factors $d + set n [expr {$n / $d}] + } + } + return $factors +} + +proc mobius {n} { + set p [prime_factors $n] + set unique_p [lsort -unique $p] + if {[llength $p] == [llength $unique_p]} { + if {[llength $p] % 2 == 0} { + return 1 + } else { + return -1 + } + } else { + return 0 + } +} + +set upto 199 +set moebius_sequence [list] +for {set i 1} {$i <= $upto} {incr i} { + lappend moebius_sequence [mobius $i] +} + +puts "Möbius sequence - First $upto terms:" +for {set i 0} {$i < $upto} {incr i} { + if {$i % 20 == 0 && $i != 0} { + puts "" + } + puts -nonewline [format "%4d" [lindex $moebius_sequence $i]] +} +puts "" diff --git a/Task/M-bius-function/Zig/m-bius-function.zig b/Task/M-bius-function/Zig/m-bius-function.zig new file mode 100644 index 0000000000..94c613a5c1 --- /dev/null +++ b/Task/M-bius-function/Zig/m-bius-function.zig @@ -0,0 +1,84 @@ +const std = @import("std"); +const print = std.debug.print; + +fn moebius(x_param: u64) i8 { + var x = x_param; + var prime_count: u32 = 0; + + // Helper function to divide x by a factor and count it + // Returns true if we should return 0 (factor appears twice) + const divideXBy = struct { + fn call(x_ptr: *u64, factor: u64, prime_count_ptr: *u32) bool { + if (x_ptr.* % factor == 0) { + x_ptr.* /= factor; + prime_count_ptr.* += 1; + if (x_ptr.* % factor == 0) { + return true; // Return 0 + } + } + return false; + } + }.call; + + // Handle 2 and 3 separately + if (divideXBy(&x, 2, &prime_count)) return 0; + if (divideXBy(&x, 3, &prime_count)) return 0; + + // Use a wheel sieve to check the remaining factors <= √x + var i: u64 = 5; + const sqrt_x = isqrt(x); + while (i <= sqrt_x) : (i += 6) { + if (divideXBy(&x, i, &prime_count)) return 0; + if (divideXBy(&x, i + 2, &prime_count)) return 0; + } + + // There can exist one prime factor larger than √x, + // in that case we can check if x is still larger than one, and then count it. + if (x > 1) { + prime_count += 1; + } + + if (prime_count % 2 == 0) { + return 1; + } else { + return -1; + } +} + +/// Returns the largest integer smaller than or equal to `√n` +fn isqrt(n: u64) u64 { + if (n <= 1) { + return n; + } else { + var x0: u64 = std.math.pow(u64, 2, @as(u32, @intFromFloat(@floor(@log2(@as(f64, @floatFromInt(n))) / 2.0))) + 1); + var x1: u64 = (x0 + n / x0) / 2; + while (x1 < x0) { + x0 = x1; + x1 = (x0 + n / x0) / 2; + } + return x0; + } +} + +pub fn main() void { + const ROWS: u64 = 10; + const COLS: u64 = 20; + print("Values of the Möbius function, μ(x), for x between 0 and {}:\n", .{COLS * ROWS}); + + for (0..ROWS) |i| { + for (0..COLS + 1) |j| { + const x = COLS * i + j; + const mu = moebius(x); + if (mu >= 0) { + // Print an extra space if there's no minus sign in front of the output + // in order to align the numbers in a nice grid. + print(" ", .{}); + } + print("{} ", .{mu}); + } + print("\n" , .{}); + } + + const x = std.math.maxInt(u64); + print("\nμ({}) = {}\n", .{ x, moebius(x) }); +} diff --git a/Task/MD5/DuckDB/md5.duckdb b/Task/MD5/DuckDB/md5.duckdb new file mode 100644 index 0000000000..1a949d0349 --- /dev/null +++ b/Task/MD5/DuckDB/md5.duckdb @@ -0,0 +1 @@ +SELECT MD5('The quick brown fox jumped over the lazy dog''s back') as md5; diff --git a/Task/MD5/JavaScript/md5.js b/Task/MD5/JavaScript/md5.js new file mode 100644 index 0000000000..bf4f48cdc1 --- /dev/null +++ b/Task/MD5/JavaScript/md5.js @@ -0,0 +1,149 @@ +class WBunion { + constructor() { + this._w = 0; + this.b = new Uint8Array(4); + } + + set w(value) { + this._w = value >>> 0; // Ensure unsigned 32-bit + this.b[0] = value & 0xFF; + this.b[1] = (value >>> 8) & 0xFF; + this.b[2] = (value >>> 16) & 0xFF; + this.b[3] = (value >>> 24) & 0xFF; + } + + get w() { + return this._w; + } +} + +function f0(abcd) { + return (abcd[1] & abcd[2]) | (~abcd[1] & abcd[3]); +} + +function f1(abcd) { + return (abcd[3] & abcd[1]) | (~abcd[3] & abcd[2]); +} + +function f2(abcd) { + return abcd[1] ^ abcd[2] ^ abcd[3]; +} + +function f3(abcd) { + return abcd[2] ^ (abcd[1] | ~abcd[3]); +} + +function calcKs(k) { + const pwr = Math.pow(2, 32); + for (let i = 0; i < 64; i++) { + const s = Math.abs(Math.sin(1 + i)); + k[i] = (s * pwr) >>> 0; // Ensure unsigned 32-bit + } + return k; +} + +// ROtate v Left by amt bits +function rol(v, amt) { + const msk1 = (1 << amt) - 1; + return (((v >>> (32 - amt)) & msk1) | ((v << amt) & ~msk1)) >>> 0; // Ensure unsigned 32-bit +} + +function md5(msg) { + const h0 = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476]; + const ff = [f0, f1, f2, f3]; + const M = [1, 5, 3, 7]; + const O = [0, 1, 5, 0]; + const rot0 = [7, 12, 17, 22]; + const rot1 = [5, 9, 14, 20]; + const rot2 = [4, 11, 16, 23]; + const rot3 = [6, 10, 15, 21]; + const rots = [rot0, rot1, rot2, rot3]; + const kspace = new Array(64); + let k = calcKs(kspace); + + const h = [...h0]; // Clone h0 + const abcd = new Array(4); + + // Convert string to byte array + const mlen = msg.length; + const grps = 1 + Math.floor((mlen + 8) / 64); + const msg2 = new Uint8Array(64 * grps); + + // Copy message to msg2 + for (let i = 0; i < mlen; i++) { + msg2[i] = msg.charCodeAt(i) & 0xFF; + } + + // Append padding bits + msg2[mlen] = 0x80; + + // Append length (in bits) + const bitLen = mlen * 8; + const offset = 64 * grps - 8; + msg2[offset] = bitLen & 0xFF; + msg2[offset + 1] = (bitLen >>> 8) & 0xFF; + msg2[offset + 2] = (bitLen >>> 16) & 0xFF; + msg2[offset + 3] = (bitLen >>> 24) & 0xFF; + + // Process message in 64-byte chunks + for (let grp = 0, os = 0; grp < grps; grp++, os += 64) { + const chunk = msg2.slice(os, os + 64); + const mm = { w: new Array(16) }; + + // Convert bytes to words + for (let i = 0; i < 16; i++) { + mm.w[i] = (chunk[i * 4] | + (chunk[i * 4 + 1] << 8) | + (chunk[i * 4 + 2] << 16) | + (chunk[i * 4 + 3] << 24)) >>> 0; + } + + // Initialize hash values for this chunk + for (let q = 0; q < 4; q++) { + abcd[q] = h[q]; + } + + // Main loop + for (let p = 0; p < 4; p++) { + const fctn = ff[p]; + const rotn = rots[p]; + const m = M[p]; + const o = O[p]; + + for (let q = 0; q < 16; q++) { + const g = (m * q + o) % 16; + const f = (abcd[1] + rol(abcd[0] + fctn(abcd) + k[q + 16 * p] + mm.w[g], rotn[q % 4])) >>> 0; + + abcd[0] = abcd[3]; + abcd[3] = abcd[2]; + abcd[2] = abcd[1]; + abcd[1] = f; + } + } + + // Add chunk's hash to result + for (let p = 0; p < 4; p++) { + h[p] = (h[p] + abcd[p]) >>> 0; + } + } + + return h; +} + +function main() { + const msg = "The quick brown fox jumps over the lazy dog."; + const d = md5(msg); + let result = "= 0x"; + + for (let j = 0; j < 4; j++) { + const u = new WBunion(); + u.w = d[j]; + for (let k = 0; k < 4; k++) { + result += u.b[k].toString(16).padStart(2, '0'); + } + } + + console.log(result); +} + +main(); diff --git a/Task/MD5/REBOL/md5-1.rebol b/Task/MD5/REBOL/md5-1.rebol new file mode 100644 index 0000000000..11644034b7 --- /dev/null +++ b/Task/MD5/REBOL/md5-1.rebol @@ -0,0 +1,2 @@ +checksum/method "The quick brown fox jumped over the lazy dog" 'md5 +;== #{08A008A01D498C404B0C30852B39D3B8} diff --git a/Task/MD5/REBOL/md5-2.rebol b/Task/MD5/REBOL/md5-2.rebol new file mode 100644 index 0000000000..c94f0418ac --- /dev/null +++ b/Task/MD5/REBOL/md5-2.rebol @@ -0,0 +1,2 @@ +checksum "The quick brown fox jumped over the lazy dog" 'md5 +;== #{08A008A01D498C404B0C30852B39D3B8} diff --git a/Task/MD5/REBOL/md5.rebol b/Task/MD5/REBOL/md5.rebol deleted file mode 100644 index 5fd63ed246..0000000000 --- a/Task/MD5/REBOL/md5.rebol +++ /dev/null @@ -1,2 +0,0 @@ ->> checksum/method "The quick brown fox jumped over the lazy dog" 'md5 -== #{08A008A01D498C404B0C30852B39D3B8} diff --git a/Task/Machine-code/Ada/machine-code.ada b/Task/Machine-code/Ada/machine-code.ada new file mode 100644 index 0000000000..32c7113c29 --- /dev/null +++ b/Task/Machine-code/Ada/machine-code.ada @@ -0,0 +1,68 @@ +-- Linux x86_64 with GNAT 15.1.0 + +with Ada.Unchecked_Conversion; +with Ada.Text_IO; +with Interfaces.C; +with System; + +-- Pull in primitive operations for unsigned int types to combine +-- flags with "or" +use type Interfaces.C.unsigned; + +procedure Machine_Code_Add is + -- The mmap interface provided by GNAT is limited, expecting only + -- reading and writing files rather than grabbing anonymous + -- executable memory regions. At that point it's easier just to + -- define our own interface. + + PROT_READ : constant Interfaces.C.unsigned := 1; + PROT_WRITE : constant Interfaces.C.unsigned := 2; + PROT_EXEC : constant Interfaces.C.unsigned := 4; + MAP_PRIVATE : constant Interfaces.C.unsigned := 2; + MAP_ANON : constant Interfaces.C.unsigned := 32; + + function Mmap (addr : System.Address; + len : Interfaces.C.size_t; + prot : Interfaces.C.unsigned; + flags : Interfaces.C.unsigned; + fd : Interfaces.C.unsigned; + off : Interfaces.C.long) return System.Address; + pragma Import (C, Mmap, "mmap"); + + function Munmap (addr : System.Address; + len : Interfaces.C.size_t) return Interfaces.C.int; + pragma Import (C, Munmap, "munmap"); + + function Memcpy (dest, src : System.Address; n : Interfaces.C.size_t) + return System.Address; + pragma Import (C, Memcpy, "memcpy"); + + type Add_Fn is access + function (A, B : Interfaces.C.long) return Interfaces.C.long + with Convention => C; + + function To_Add_Fn is + new Ada.Unchecked_Conversion (System.Address, Add_Fn); + + Code : constant array (Positive range 1 .. 7) + of Interfaces.C.unsigned_char := + (16#48#, 16#89#, 16#F8#, 16#48#, 16#01#, 16#F0#, 16#C3#); + + Len : constant Interfaces.C.size_t := Code'Length; + + Mem : constant System.Address := + Mmap (System.Null_Address, + Len, + PROT_READ or PROT_WRITE or PROT_EXEC, + MAP_PRIVATE or MAP_ANON, + -1, + 0); + + Add : constant Add_Fn := To_Add_Fn (Mem); + Dummy : System.Address := Memcpy (Mem, Code'Address, Len); + Dummy2 : Interfaces.C.int; + Sum : Interfaces.C.long := Add (12, 7); +begin + Ada.Text_IO.Put_Line ("12 + 7 =" & Interfaces.C.long'Image (Sum)); + Dummy2 := Munmap (Mem, Len); +end Machine_Code_Add; diff --git a/Task/Machine-code/Pluto/machine-code-1.pluto b/Task/Machine-code/Pluto/machine-code-1.pluto new file mode 100644 index 0000000000..a695c32dba --- /dev/null +++ b/Task/Machine-code/Pluto/machine-code-1.pluto @@ -0,0 +1,23 @@ +/* mclib.c */ + +// gcc -c -fpic mclib.c +// gcc -shared -o mclib.so mclib.o + +#include +#include + +typedef unsigned char uchar; + +extern uchar run_machine_code(const char *code, uchar a, uchar b, int len) { + void *buf; + uchar c; + /* copy code to executable buffer */ + buf = mmap (0, len, PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_PRIVATE | MAP_ANON, -1, 0); + memcpy (buf, code, len); + /* run code */ + c = ((uchar (*) (uchar, uchar))buf)(a, b); + /* free buffer */ + munmap (buf, len); + return c; +} diff --git a/Task/Machine-code/Pluto/machine-code-2.pluto b/Task/Machine-code/Pluto/machine-code-2.pluto new file mode 100644 index 0000000000..c84f17be8f --- /dev/null +++ b/Task/Machine-code/Pluto/machine-code-2.pluto @@ -0,0 +1,19 @@ +local ffi = require "pluto:ffi" +local lib = ffi.open("./mclib.so") +lib:cdef[[ +unsigned char run_machine_code(const char *code, unsigned char a, unsigned char b, int len); +]] + +local a = 7 +local b = 12 + +-- x64 opcodes for this task +local m = { + 0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d, + 0xfc, 0x89, 0x75, 0xf8, 0x8b, 0x75, + 0xfc, 0x03, 0x75, 0xf8, 0x89, 0x75, + 0xf4, 0x8b, 0x45, 0xf4, 0x5d, 0xc3 +} + +local code = m:mapped(|byte| -> string.char(byte)):concat("") +print($"{a} + {b} = {lib.run_machine_code(code, a, b, #m)}") diff --git a/Task/Magic-8-ball/Prolog/magic-8-ball.pro b/Task/Magic-8-ball/Prolog/magic-8-ball.pro new file mode 100644 index 0000000000..6ff6c7f4ac --- /dev/null +++ b/Task/Magic-8-ball/Prolog/magic-8-ball.pro @@ -0,0 +1,13 @@ +magic_8_ball :- + Responses = ["It is certain", "It is decidedly so", "Without a doubt", + "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", + "Outlook good", "Signs point to yes", "Yes", "Reply hazy, try again", + "Ask again later", "Better not tell you now", "Cannot predict now", + "Concentrate and ask again", "Don't bet on it", "My reply is no", + "My sources say no", "Outlook not so good", "Very doubtful"], + repeat, + format("Q: "), + read_line_to_codes(user_input, _), + random_member(Response, Responses), + format("A: ~s~n", [Response]), + fail. diff --git a/Task/Magic-constant/Pascal-P/magic-constant.pas b/Task/Magic-constant/Pascal-P/magic-constant.pas new file mode 100644 index 0000000000..0e81ec83dd --- /dev/null +++ b/Task/Magic-constant/Pascal-P/magic-constant.pas @@ -0,0 +1,35 @@ +program magicconstant(output); +(* Magic constant *) + +var + n: integer; + e: real; + + (* returns the magic constant of a magic square of order n + 2 *) + function a(n: integer): integer; + var + n2: integer; + begin + n2 := n + 2; + a := (n2 * ((n2 * n2) + 1)) div 2 + end; + + (* returns the order of the magic square whose magic constant is at least x *) + function inva(x: real): integer; + begin + inva := trunc(exp(ln((2.0 * x)) / 3) + 1) + end; + +begin + e := 1.0; + write('The first 20 magic constants are '); + for n := 1 to 20 do + write(a(n): 4, ' '); + writeln; + writeln('The 1,000th magic constant is ', a(1000)); + for n := 1 to 20 do + begin + e := e * 10; + writeln('10^', n: 2, ': ', inva(e): 9); + end +end. diff --git a/Task/Magic-squares-of-doubly-even-order/Objeck/magic-squares-of-doubly-even-order.objeck b/Task/Magic-squares-of-doubly-even-order/Objeck/magic-squares-of-doubly-even-order.objeck new file mode 100644 index 0000000000..a65dbc86eb --- /dev/null +++ b/Task/Magic-squares-of-doubly-even-order/Objeck/magic-squares-of-doubly-even-order.objeck @@ -0,0 +1,43 @@ +class Test { + function : Main(args : String[]) ~ Nil { + n := 8; + result := MagicSquareDoublyEven(n); + dim := result->Size(); + + for (i := 0; i < dim[0]; i++) + { + for (j := 0; j < dim[1]; j++) { + value := result[i, j]; + "{$value}\t"->Print(); + } + "\n"->Print(); + }; + + value := (n * n + 1) * n / 2; + "\nMagic constant: {$value}"->PrintLine(); + } + + function : MagicSquareDoublyEven(n:Int) ~ Int[,] { + if (n < 4 | n % 4 <> 0) { + "base must be a positive multiple of 4"->ErrorLine(); + System.Runtime->Exit(1); + }; + + # pattern of count-up vs count-down zones + bits := 0b1001011001101001; + size := n * n; + mult := n / 4; # how many multiples of 4 + + result := Int->New[n, n]; + + for (r := 0, i := 0; r < n; r++) + { + for (c := 0; c < n; c++, i++) + { + bitPos := c / mult + (r / mult) * 4; + result[r, c] := (bits and (1 << bitPos)) <> 0 ? i + 1 : size - i; + } + } + return result; + } +} diff --git a/Task/Magic-squares-of-doubly-even-order/Pluto/magic-squares-of-doubly-even-order.pluto b/Task/Magic-squares-of-doubly-even-order/Pluto/magic-squares-of-doubly-even-order.pluto new file mode 100644 index 0000000000..c8d9295e44 --- /dev/null +++ b/Task/Magic-squares-of-doubly-even-order/Pluto/magic-squares-of-doubly-even-order.pluto @@ -0,0 +1,29 @@ +local function magic_square_doubly_even(n) + assert(n > 0 and n % 4 == 0, "Base must be a positive multiple of 4") + + -- Pattern of count-up vs count-down zones. + local bits = 0b1001011001101001 + local size = n * n + local mult = n // 4 -- how many multiples of 4 + local result = {} + for i = 1, n do + result[i] = {} + for j = 1, n do result[i][j] = 0 end + end + local i = 0 + for r = 1, n do + for c = 1, n do + local bitpos = (c - 1) // mult + (r - 1) // mult * 4 + result[r][c] = ((bits & (1 << bitpos)) != 0) ? i + 1: size - i + ++i + end + end + return result +end + +local n = 8 +for magic_square_doubly_even(n) as ia do + for ia as i do io.write(string.format("%2d ", i)) end + print() +end +print($"\nMagic constant {(n * n + 1) * n // 2}") diff --git a/Task/Magic-squares-of-odd-order/Pluto/magic-squares-of-odd-order.pluto b/Task/Magic-squares-of-odd-order/Pluto/magic-squares-of-odd-order.pluto new file mode 100644 index 0000000000..523eabc7ee --- /dev/null +++ b/Task/Magic-squares-of-odd-order/Pluto/magic-squares-of-odd-order.pluto @@ -0,0 +1,28 @@ +local function ms(n) + local M = |x| -> (x + n - 1) % n + if n <= 0 or n & 1 == 0 then + n = 5 + print($"forcing size {n}") + end + local m = {} + for i = 1, n * n do m[i] = 0 end + local i = 0 + local j = n // 2 + for k = 1, n * n do + m[i * n + j + 1] = k + if m[M(i) * n + M(j) + 1] != 0 then + i = (i + 1) % n + else + i = M(i) + j = M(j) + end + end + return {n, m} +end + +local [n, m] = ms(5) +for i = 1, n do + for j = 1, n do io.write(string.format("%4d", m[(i - 1) * n + j])) end + print() +end +print($"\nMagic number : {(n * n + 1) // 2 * n}") diff --git a/Task/Magic-squares-of-singly-even-order/Pluto/magic-squares-of-singly-even-order.pluto b/Task/Magic-squares-of-singly-even-order/Pluto/magic-squares-of-singly-even-order.pluto new file mode 100644 index 0000000000..4566e01813 --- /dev/null +++ b/Task/Magic-squares-of-singly-even-order/Pluto/magic-squares-of-singly-even-order.pluto @@ -0,0 +1,73 @@ +local function magic_square_odd(n) + assert(n > 2 and n % 2 == 1, "Base must be odd and > 2." ) + local value = 1 + local grid_size = n * n + local c = n // 2 + 1 + local r = 1 + local result = {} + for i = 1, n do + result[i] = {} + for j = 1, n do result[i][j] = 0 end + end + while value <= grid_size do + result[r][c] = value + if r == 1 then + if c == n then + ++r + else + r = n + ++c + end + elseif c == n then + r -= 1 + c = 1 + elseif result[r - 1][c + 1] == 0 then + r -= 1 + c += 1 + else + ++r + end + ++value + end + return result +end + +local function magic_square_singly_even(n) + assert(n >= 6 and (n - 2) % 4 == 0, "Base must be a positive multiple of 4 plus 2.") + local size = n * n + local half_n = n // 2 + local sub_square_size = size // 4 + local sub_square = magic_square_odd(half_n) + local quadrant_factors = {0, 2, 3, 1} + local result = {} + for i = 1, n do + result[i] = {} + for j = 1, n do result[i][j] = 0 end + end + for r = 1, n do + for c = 1, n do + local quadrant = (r - 1) // half_n * 2 + (c - 1) // half_n + 1 + result[r][c] = sub_square[(r - 1) % half_n + 1][(c - 1) % half_n + 1] + result[r][c] += quadrant_factors[quadrant] * sub_square_size + end + end + local n_cols_left = half_n // 2 + 1 + local n_cols_right = n_cols_left - 1 + for r = 1, half_n do + for c = 1, n do + if c < n_cols_left or c > n - n_cols_right + 1 or (c == n_cols_left and r == n_cols_left) then + if c != 1 or r != n_cols_left then + result[r][c], result[r + half_n][c] = result[r + half_n][c], result[r][c] + end + end + end + end + return result +end + +local n = 6 +for magic_square_singly_even(n) as ia do + for ia as i do io.write(string.format("%2d ", i)) end + print() +end +print($"\nMagic constant {(n * n + 1) * n // 2}") diff --git a/Task/Main-step-of-GOST-28147-89/Zig/main-step-of-gost-28147-89.zig b/Task/Main-step-of-GOST-28147-89/Zig/main-step-of-gost-28147-89.zig new file mode 100644 index 0000000000..fa0f2e8012 --- /dev/null +++ b/Task/Main-step-of-GOST-28147-89/Zig/main-step-of-gost-28147-89.zig @@ -0,0 +1,218 @@ +const std = @import("std"); + +const REPLACEMENT_TABLE = [8][16]u8{ + [_]u8{ 4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3 }, + [_]u8{ 14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9 }, + [_]u8{ 5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9, 11 }, + [_]u8{ 7, 13, 10, 1, 0, 8, 9, 15, 14, 4, 6, 12, 11, 2, 5, 3 }, + [_]u8{ 6, 12, 7, 1, 5, 15, 13, 8, 4, 10, 9, 14, 0, 3, 11, 2 }, + [_]u8{ 4, 11, 10, 0, 7, 2, 1, 13, 3, 6, 8, 5, 9, 12, 15, 14 }, + [_]u8{ 13, 11, 4, 1, 3, 15, 5, 9, 0, 10, 14, 7, 6, 8, 2, 12 }, + [_]u8{ 1, 15, 13, 0, 5, 7, 10, 4, 9, 2, 3, 14, 6, 11, 8, 12 }, +}; + +const KEYS = [8]u32{ + 0xE2C1_04F9, + 0xE41D_7CDE, + 0x7FE5_E857, + 0x0602_65B4, + 0x281C_CC85, + 0x2E2C_929A, + 0x4746_4503, + 0xE00_CE510, +}; + +fn mainStep(text_block: []const u8, key_element: u32) ![8]u8 { + var n: [8]u8 = undefined; + @memcpy(&n, text_block[0..8]); + + var s: u32 = @as(u32, n[0]) << 24 | @as(u32, n[1]) << 16 | @as(u32, n[2]) << 8 | @as(u32, n[3]); + s = s +% key_element; + + var new_s: u32 = 0; + var mid: u32 = 0; + while (mid < 4) : (mid += 1) { + const cell = (s >> @as(u5, @as(u5, @intCast(mid)) << @as(u5, 3))) & 0xFF; + new_s += (@as(u32, REPLACEMENT_TABLE[(mid * 2)][(cell & 0x0f)]) + + (@as(u32, REPLACEMENT_TABLE[(mid * 2 + 1)][(cell >> 4)]) << 4)) << + @as(u5, @intCast(mid << 3) ); + } + + s = ((new_s << 11) +% (new_s >> 21)) ^ + (@as(u32, n[4]) << 24 | @as(u32, n[5]) << 16 | @as(u32, n[6]) << 8 | @as(u32, n[7])); + + n[4] = n[0]; + n[5] = n[1]; + n[6] = n[2]; + n[7] = n[3]; + n[0] = @intCast((s >> 24) & 0xFF); + n[1] = @intCast((s >> 16) & 0xFF); + n[2] = @intCast((s >> 8) & 0xFF); + n[3] = @intCast(s & 0xFF); + + return n; +} + +fn encode(allocator: std.mem.Allocator, text_block: []const u8) ![]u8 { + const step = try allocator.dupe(u8, text_block); + defer allocator.free(step); + + var result: [8]u8 = undefined; + @memcpy(&result, step); + + var i: usize = 0; + while (i < 24) : (i += 1) { + result = try mainStep(&result, KEYS[i % 8]); + } + + i = 8; + while (i > 0) : (i -= 1) { + result = try mainStep(&result, KEYS[i - 1]); + } + + return try allocator.dupe(u8, &result); +} + +fn decode(allocator: std.mem.Allocator, text_block: []const u8) ![]u8 { + var step: [8]u8 = undefined; + @memcpy(step[0..4], text_block[4..8]); + @memcpy(step[4..8], text_block[0..4]); + + for (KEYS) |key| { + step = try mainStep(&step, key); + } + + var i: usize = 24; + while (i > 0) : (i -= 1) { + step = try mainStep(&step, KEYS[(i - 1) % 8]); + } + + var ans: [8]u8 = undefined; + @memcpy(ans[0..4], step[4..8]); + @memcpy(ans[4..8], step[0..4]); + + return try allocator.dupe(u8, &ans); +} + +fn bytesToHexString(allocator: std.mem.Allocator, bytes: []const u8) ![]u8 { + var result = try allocator.alloc(u8, bytes.len * 3); + var i: usize = 0; + while (i < bytes.len) : (i += 1) { + _ = try std.fmt.bufPrint(result[(i * 3)..][0..3], "{X:0>2} ", .{bytes[i]}); + } + return result; +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const args = try std.process.argsAlloc(allocator); + defer std.process.argsFree(allocator, args); + + const stdout = std.io.getStdOut().writer(); + + if (args.len < 2) { + const plain_text = [_]u8{ 0x04, 0x3B, 0x04, 0x21, 0x04, 0x32, 0x04, 0x30 }; + + const hex_str = try bytesToHexString(allocator, &plain_text); + defer allocator.free(hex_str); + try stdout.print("Before one step: {s}\n\n", .{hex_str}); + + const encoded_text = try mainStep(&plain_text, KEYS[0]); + const encoded_hex = try bytesToHexString(allocator, &encoded_text); + defer allocator.free(encoded_hex); + try stdout.print("After one step : {s}\n\n", .{encoded_hex}); + } else { + const text = args[1]; + const padding = (8 - text.len % 8) % 8; + + var t = try allocator.alloc(u8, text.len + padding); + defer allocator.free(t); + + @memcpy(t[0..text.len], text); + @memset(t[text.len..], ' '); + + const chunks_count = t.len / 8; + var plain_text = std.ArrayList([]u8).init(allocator); + defer { + for (plain_text.items) |chunk| { + allocator.free(chunk); + } + plain_text.deinit(); + } + + var i: usize = 0; + try stdout.print("Plain text : ", .{}); + while (i < chunks_count) : (i += 1) { + const chunk = try allocator.dupe(u8, t[(i * 8)..][0..8]); + try plain_text.append(chunk); + + const hex = try bytesToHexString(allocator, chunk); + defer allocator.free(hex); + try stdout.print("[{s}]", .{hex[0..23]}); + } + try stdout.print("\n\n", .{}); + + var encoded_text = std.ArrayList([]u8).init(allocator); + defer { + for (encoded_text.items) |chunk| { + allocator.free(chunk); + } + encoded_text.deinit(); + } + + try stdout.print("Encoded text: ", .{}); + for (plain_text.items) |chunk| { + const encoded = try encode(allocator, chunk); + try encoded_text.append(encoded); + + const hex = try bytesToHexString(allocator, encoded); + defer allocator.free(hex); + try stdout.print("[{s}]", .{hex[0..23]}); + } + try stdout.print("\n\n", .{}); + + var decoded_text = std.ArrayList([]u8).init(allocator); + defer { + for (decoded_text.items) |chunk| { + allocator.free(chunk); + } + decoded_text.deinit(); + } + + try stdout.print("Decoded text: ", .{}); + for (encoded_text.items) |chunk| { + const decoded = try decode(allocator, chunk); + try decoded_text.append(decoded); + + const hex = try bytesToHexString(allocator, decoded); + defer allocator.free(hex); + try stdout.print("[{s}]", .{hex[0..23]}); + } + try stdout.print("\n\n", .{}); + + var total_size: usize = 0; + for (decoded_text.items) |chunk| { + total_size += chunk.len; + } + + var recovered_bytes = try allocator.alloc(u8, total_size); + defer allocator.free(recovered_bytes); + + var offset: usize = 0; + for (decoded_text.items) |chunk| { + @memcpy(recovered_bytes[offset..][0..chunk.len], chunk); + offset += chunk.len; + } + + // Remove padding spaces at the end + var end = recovered_bytes.len; + while (end > 0 and recovered_bytes[end - 1] == ' ') { + end -= 1; + } + + try stdout.print("Recovered text: {s}\n\n", .{recovered_bytes[0..end]}); + } +} diff --git a/Task/Mandelbrot-set/EasyLang/mandelbrot-set.easy b/Task/Mandelbrot-set/EasyLang/mandelbrot-set.easy index d5dae7370f..a80426e197 100644 --- a/Task/Mandelbrot-set/EasyLang/mandelbrot-set.easy +++ b/Task/Mandelbrot-set/EasyLang/mandelbrot-set.easy @@ -30,7 +30,7 @@ proc draw . cx = (scr_x - center_x) / scale it = iter cx cy maxiter if it < maxiter - gcolor3 it / 20 it / 100 it / 150 + gcolor3 it * 5 it it * 0.7 grect scr_x / res scr_y / res 1 / res 1 / res . . diff --git a/Task/Mandelbrot-set/Julia/mandelbrot-set-3.jl b/Task/Mandelbrot-set/Julia/mandelbrot-set-3.jl index 5731864e0a..846ad7105e 100644 --- a/Task/Mandelbrot-set/Julia/mandelbrot-set-3.jl +++ b/Task/Mandelbrot-set/Julia/mandelbrot-set-3.jl @@ -8,7 +8,7 @@ x = range(-1.0, 1.0, length=d+1) y = range(-h/d, h/d, length=h+1) C = 2.0 .* (x' .+ y .* im) .- 0.5 -Z, S = zero(C), zeros(size(C)) +S, Z = zeros(size(C)), zero(C) animation = Animation() smoothing = Animation() diff --git a/Task/Mandelbrot-set/Julia/mandelbrot-set-4.jl b/Task/Mandelbrot-set/Julia/mandelbrot-set-4.jl deleted file mode 100644 index 931311a1b2..0000000000 --- a/Task/Mandelbrot-set/Julia/mandelbrot-set-4.jl +++ /dev/null @@ -1,41 +0,0 @@ -using Plots -gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) - -d, h = 800, 500 # pixel density (= image width) and image height -n, r = 200, 500 # number of iterations and escape radius (r > 2) - -x = range(0, 2, length=d+1) -y = range(0, 2 * h / d, length=h+1) - -A, B = collect(x) .- 1, collect(y) .- h / d -C = 2.0 .* (A' .+ B .* im) .- 0.5 - -Z, dZ = zero(C), zero(C) -D, S, T = zeros(size(C)), zeros(size(C)), zeros(size(C)) - -for k in 1:n - M = abs.(Z) .< r - S[M], T[M] = S[M] .+ exp.(.- abs.(Z[M])), T[M] .+ 1 - Z[M], dZ[M] = Z[M] .^ 2 .+ C[M], 2 .* Z[M] .* dZ[M] .+ 1 -end - -heatmap(S .^ 0.1, c=:balance) -savefig("Mandelbrot_set_1.png") - -N = abs.(Z) .>= r # normalized iteration count -T[N] = T[N] .- log2.(log.(abs.(Z[N])) ./ log(r)) - -heatmap(T .^ 0.1, c=:balance) -savefig("Mandelbrot_set_2.png") - -N = abs.(Z) .> 2 # exterior distance estimation -D[N] = log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N]) - -heatmap(D .^ 0.1, c=:balance) -savefig("Mandelbrot_set_3.png") - -N, thickness = D .> 0, 0.01 # boundary detection -D[N] = max.(1 .- D[N] ./ thickness, 0) - -heatmap(D .^ 2.0, c=:binary) -savefig("Mandelbrot_set_4.png") diff --git a/Task/Mandelbrot-set/Julia/mandelbrot-set-5.jl b/Task/Mandelbrot-set/Julia/mandelbrot-set-5.jl deleted file mode 100644 index 8ca557e392..0000000000 --- a/Task/Mandelbrot-set/Julia/mandelbrot-set-5.jl +++ /dev/null @@ -1,41 +0,0 @@ -using Plots -gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) - -d, h = 800, 500 # pixel density (= image width) and image height -n, r = 200, 500 # number of iterations and escape radius (r > 2) - -direction, height = 45.0, 1.5 # direction and height of the light -density, intensity = 4.0, 0.5 # density and intensity of the stripes - -x = range(0, 2, length=d+1) -y = range(0, 2 * h / d, length=h+1) - -A, B = collect(x) .- 1, collect(y) .- h / d -C = (2.0 + 1.0im) .* (A' .+ B .* im) .- 0.5 - -Z, dZ, ddZ = zero(C), zero(C), zero(C) -D, S, T = zeros(size(C)), zeros(size(C)), zeros(size(C)) - -for k in 1:n - M = abs.(Z) .< r - S[M], T[M] = S[M] .+ sin.(density .* angle.(Z[M])), T[M] .+ 1 - Z[M], dZ[M], ddZ[M] = Z[M] .^ 2 .+ C[M], 2 .* Z[M] .* dZ[M] .+ 1, 2 .* (dZ[M] .^ 2 .+ Z[M] .* ddZ[M]) -end - -N = abs.(Z) .>= r # basic normal map effect and stripe average coloring (potential function) -P, Q = S[N] ./ T[N], (S[N] .+ sin.(density .* angle.(Z[N]))) ./ (T[N] .+ 1) -U, V = Z[N] ./ dZ[N], 1 .+ (log2.(log.(abs.(Z[N])) ./ log(r)) .* (P .- Q) .+ Q) .* intensity -U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and light vector -D[N] = max.((real.(U) .* real(v) .+ imag.(U) .* imag(v) .+ V .* height) ./ (1 + height), 0) - -heatmap(D .^ 1.0, c=:bone_1) -savefig("Mandelbrot_normal_map_1.png") - -N = abs.(Z) .> 2 # advanced normal map effect using higher derivatives (distance estimation) -H, K, L = abs.(Z[N] ./ dZ[N]), abs.(dZ[N] ./ ddZ[N]), log.(abs.(Z[N])) -U = Z[N] ./ dZ[N] .- (H ./ K) .^ 2 .* L ./ (1 .+ L) .* dZ[N] ./ ddZ[N] -U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and light vector -D[N] = max.((real.(U) .* real(v) .+ imag.(U) .* imag(v) .+ height) ./ (1 + height), 0) - -heatmap(D .^ 1.0, c=:afmhot) -savefig("Mandelbrot_normal_map_2.png") diff --git a/Task/Mandelbrot-set/Julia/mandelbrot-set-6.jl b/Task/Mandelbrot-set/Julia/mandelbrot-set-6.jl deleted file mode 100644 index b67d3b0276..0000000000 --- a/Task/Mandelbrot-set/Julia/mandelbrot-set-6.jl +++ /dev/null @@ -1,39 +0,0 @@ -using Plots -gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) - -d, h = 200, 1200 # pixel density (= image width) and image height -n, r = 8000, 10000 # number of iterations and escape radius (r > 2) - -a = -.743643887037158704752191506114774 # https://mathr.co.uk/web/m-location-analysis.html -b = 0.131825904205311970493132056385139 # try: a, b, n = -1.748764520194788535, 3e-13, 800 - -x = range(0, 2, length=d+1) -y = range(0, 2 * h / d, length=h+1) - -A, B = collect(x) .* pi, collect(y) .* pi -C = 8.0 .* exp.((A' .+ B .* im) .* im) .+ (a + b * im) - -Z, dZ = zero(C), zero(C) -D = zeros(size(C)) - -for k in 1:n - M = abs2.(Z) .< abs2(r) - Z[M], dZ[M] = Z[M] .^ 2 .+ C[M], 2 .* Z[M] .* dZ[M] .+ 1 -end - -N = abs.(Z) .> 2 # exterior distance estimation -D[N] = log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N]) - -heatmap(D' .^ 0.05, c=:nipy_spectral) -savefig("Mercator_Mandelbrot_map.png") - -X, Y = real(C), imag(C) # zoom images (adjust circle size 50 and zoom level 20 as needed) -R, c, z = 50 * (2 / d) * pi .* exp.(.- B), min(d, h) + 1, max(0, h - d) ÷ 20 - -gr(c=:nipy_spectral, axis=true, ticks=true, legend=false, markerstrokewidth=0) -p1 = scatter(X[1z+1:1z+c,1:d], Y[1z+1:1z+c,1:d], markersize=R[1:c].^.5, marker_z=D[1z+1:1z+c,1:d].^.5) -p2 = scatter(X[2z+1:2z+c,1:d], Y[2z+1:2z+c,1:d], markersize=R[1:c].^.5, marker_z=D[2z+1:2z+c,1:d].^.4) -p3 = scatter(X[3z+1:3z+c,1:d], Y[3z+1:3z+c,1:d], markersize=R[1:c].^.5, marker_z=D[3z+1:3z+c,1:d].^.3) -p4 = scatter(X[4z+1:4z+c,1:d], Y[4z+1:4z+c,1:d], markersize=R[1:c].^.5, marker_z=D[4z+1:4z+c,1:d].^.2) -plot(p1, p2, p3, p4, layout=(2, 2)) -savefig("Mercator_Mandelbrot_zoom.png") diff --git a/Task/Mandelbrot-set/Julia/mandelbrot-set-7.jl b/Task/Mandelbrot-set/Julia/mandelbrot-set-7.jl deleted file mode 100644 index 2dc45623ad..0000000000 --- a/Task/Mandelbrot-set/Julia/mandelbrot-set-7.jl +++ /dev/null @@ -1,71 +0,0 @@ -using Base.Threads -using Plots -gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) - -setprecision(BigFloat, 256) # set precision to 256 bits (default) -setrounding(BigFloat, RoundNearest) # set rounding mode (default) - -d, h = 50, 1000 # pixel density (= image width) and image height -n, r = 80000, 100000 # number of iterations and escape radius (r > 2) - -a = BigFloat("-1.256827152259138864846434197797294538253477389787308085590211144291") -b = BigFloat(".37933802890364143684096784819544060002129071484943239316486643285025") - -S = zeros(Complex{Float64}, n+1) -let c = a + b * im, z = zero(c) - for k in 1:n+1 - S[k] = z - if abs2(z) < abs2(r) - z = z ^ 2 + c - else - println("The reference sequence diverges within $(k-1) iterations.") - break - end - end -end - -x = range(0, 2, length=d+1) -y = range(0, 2 * h / d, length=h+1) - -A, B = collect(Float64, x) .* pi, collect(Float64, y) .* pi -C = (- 8.0) .* exp.((A' .+ B .* im) .* im) - -function iteration(C) - E, I, J = zero(C), ones(Int64, size(C)), ones(Int64, size(C)) - Z, dZ = zero(C), zero(C) - - function iterate(E, I, Z, dZ, C) - E, I = (2 .* S[I] .+ E) .* E .+ C, I .+ 1 - Z, dZ = S[I] .+ E, 2 .* Z .* dZ .+ 1 - return E, I, Z, dZ - end - - for k in 1:n - M = abs2.(Z) .< abs2.(E) - E[M], I[M] = Z[M], J[M] # rebase when z is closer to zero - M = abs2.(Z) .< abs2(r) - E[M], I[M], Z[M], dZ[M] = iterate(E[M], I[M], Z[M], dZ[M], C[M]) - end - - return E, I, Z, dZ -end - -function calculation(C) - E, I = zero(C), ones(Int64, size(C)) - Z, dZ = zero(C), zero(C) - - @threads for j in 1:size(C)[2] - E[:,j], I[:,j], Z[:,j], dZ[:,j] = iteration(C[:,j]) - end - - return E, I, Z, dZ -end - -E, I, Z, dZ = calculation(C) -D = zeros(Float64, size(C)) - -N = abs.(Z) .> 2 # exterior distance estimation -D[N] = log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N]) - -heatmap(D' .^ 0.015, c=:gist_ncar) -savefig("Mercator_Mandelbrot_deep_map.png") diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-10.py b/Task/Mandelbrot-set/Python/mandelbrot-set-10.py index 5da9f4d0dd..25cb9cf0fc 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-10.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-10.py @@ -1,5 +1,123 @@ -from functools import reduce +import numba +numba.config.CUDA_ENABLE_PYNVJITLINK = True # prevent cuda ptx version errors -def mandelbrot(x, y, c): return ' *'[abs(reduce(lambda z, _: z*z + c, range(99), 0)) < 2] +import numpy as np +import matplotlib.pyplot as plt -print('\n'.join(''.join(mandelbrot(x, y, x/50 + y/50j) for x in range(-100, 25)) for y in range(-50, 50))) +import cupy as cp +import numba.cuda as cuda + +import decimal as dc # decimal floating point arithmetic with arbitrary precision +dc.getcontext().prec = 80 # set precision to 80 digits (about 256 bits) + +d, h = 1600, 1000 # pixel density (= image width) and image height +n, r = 100000, 100000.0 # number of iterations and escape radius (r > 2) + +a = dc.Decimal("-1.256827152259138864846434197797294538253477389787308085590211144291") +b = dc.Decimal(".37933802890364143684096784819544060002129071484943239316486643285025") + +S = np.zeros(n+1, dtype=np.complex128) +u, v = dc.Decimal(0), dc.Decimal(0) + +for i in range(n+1): + S[i] = float(u) + float(v) * 1j + if u * u + v * v < r * r: + u, v = u * u - v * v + a, 2 * u * v + b + else: + print("The reference sequence diverges within %s iterations." % i) + break + +x = np.linspace(0, 2, num=d+1, dtype=np.float64) +y = np.linspace(0, 2 * h / d, num=h+1, dtype=np.float64) + +A, B = np.meshgrid(x - 1, y - h / d) +C = 5.0e-35 * (A + B * 1j) + +def iteration_cupy_cuda(S, C): + I = cp.zeros(C.shape, dtype=np.int32) + E, Z, dZ = cp.zeros_like(C), cp.zeros_like(C), cp.zeros_like(C) + + iteration = cp.RawKernel(""" + #include + + extern "C" __global__ + void iterate(int dim_x, int dim_y, int n, double r, + complex *S, complex *C, + int *I, complex *E, complex *Z, complex *dZ) { + + int x = blockIdx.x * blockDim.x + threadIdx.x; + int y = blockIdx.y * blockDim.y + threadIdx.y; + + if (x < dim_x and y < dim_y) { // prevent memory access errors + int x_y = x * dim_y + y; // cupy arrays are in row-major order + complex delta = C[x_y]; + + int index = I[x_y]; + complex epsilon = E[x_y]; + complex z = Z[x_y]; + complex dz = dZ[x_y]; + + double abs2_r = r * r; + double abs2_z, abs2_e; + + for (int i = 0; i < n; i++) { + abs2_z = z.real() * z.real() + z.imag() * z.imag(); + abs2_e = epsilon.real() * epsilon.real() + epsilon.imag() * epsilon.imag(); + + if (abs2_z < abs2_e) { // rebase when z is closer to zero + epsilon = z; index = 0; // reset reference orbit + } + if (abs2_z < abs2_r) { + epsilon = (2. * S[index] + epsilon) * epsilon + delta; index = index + 1; + dz = 2. * z * dz + 1.; z = S[index] + epsilon; + } + else { + break; + } + } + I[x_y] = index; E[x_y] = epsilon; Z[x_y] = z; dZ[x_y] = dz; + } + } + """, "iterate") + + griddim, blockdim = (h // 32 + 1, d // 32 + 1), (32, 32) + iteration(griddim, blockdim, (h+1, d+1, n, r, cp.asarray(S), cp.asarray(C), I, E, Z, dZ)) + return I.get(), E.get(), Z.get(), dZ.get() + +def iteration_numba_cuda(S, C): + I = cp.zeros(C.shape, dtype=np.int32) + E, Z, dZ = cp.zeros_like(C), cp.zeros_like(C), cp.zeros_like(C) + + @cuda.jit() + def iteration(S, C, I, E, Z, dZ): + x, y = cuda.grid(2) + + if x < h+1 and y < d+1: # prevent memory access errors + delta, index, epsilon, z, dz = C[x, y], I[x, y], E[x, y], Z[x, y], dZ[x, y] + + def abs2(z): + return z.real * z.real + z.imag * z.imag + + for i in range(n): + if abs2(z) < abs2(epsilon): # rebase when z is closer to zero + index, epsilon = 0, z # reset reference orbit + if abs2(z) < abs2(r): + index, epsilon = index + 1, (2 * S[index] + epsilon) * epsilon + delta + z, dz = S[index] + epsilon, 2 * z * dz + 1 + else: + break + + I[x, y], E[x, y], Z[x, y], dZ[x, y] = index, epsilon, z, dz + + griddim, blockdim = (h // 32 + 1, d // 32 + 1), (32, 32) + iteration[griddim, blockdim](cp.asarray(S), cp.asarray(C), I, E, Z, dZ) + return I.get(), E.get(), Z.get(), dZ.get() + +I, E, Z, dZ = iteration_numba_cuda(S, C) # use iteration_cupy_cuda or iteration_numba_cuda +D = np.zeros(C.shape, dtype=np.float64) + +N = abs(Z) > 2 # exterior distance estimation +D[N] = np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) + +plt.imshow(D ** 0.15, cmap=plt.cm.jet, origin="lower") +plt.savefig("Mandelbrot_deep_zoom.png", dpi=300) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-11.py b/Task/Mandelbrot-set/Python/mandelbrot-set-11.py new file mode 100644 index 0000000000..6cce0c0708 --- /dev/null +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-11.py @@ -0,0 +1,8 @@ +print( +'\n'.join( + ''.join( + ' *'[(z:=0, c:=x/50+y/50j, [z:=z*z+c for _ in range(99)], abs(z))[-1]<2] + for x in range(-100,25) + ) + for y in range(-50,50) +)) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-12.py b/Task/Mandelbrot-set/Python/mandelbrot-set-12.py new file mode 100644 index 0000000000..5da9f4d0dd --- /dev/null +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-12.py @@ -0,0 +1,5 @@ +from functools import reduce + +def mandelbrot(x, y, c): return ' *'[abs(reduce(lambda z, _: z*z + c, range(99), 0)) < 2] + +print('\n'.join(''.join(mandelbrot(x, y, x/50 + y/50j) for x in range(-100, 25)) for y in range(-50, 50))) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-5.py b/Task/Mandelbrot-set/Python/mandelbrot-set-5.py index e240ab78e6..37019f09c4 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-5.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-5.py @@ -10,13 +10,23 @@ y = np.linspace(0, 2 * h / d, num=h+1) A, B = np.meshgrid(x - 1, y - h / d) C = 2.0 * (A + B * 1j) - 0.5 -Z, dZ = np.zeros_like(C), np.zeros_like(C) -D, S, T = np.zeros(C.shape), np.zeros(C.shape), np.zeros(C.shape) +def iteration(C): + S, T = np.zeros(C.shape), np.zeros(C.shape) + Z, dZ = np.zeros_like(C), np.zeros_like(C) -for k in range(n): - M = abs(Z) < r - S[M], T[M] = S[M] + np.exp(- abs(Z[M])), T[M] + 1 - Z[M], dZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1 + def iterate(C, S, T, Z, dZ): + S, T = S + np.exp(- abs(Z)), T + 1 + Z, dZ = Z * Z + C, 2 * Z * dZ + 1 + return S, T, Z, dZ + + for i in range(n): + M = abs(Z) < r + S[M], T[M], Z[M], dZ[M] = iterate(C[M], S[M], T[M], Z[M], dZ[M]) + + return S, T, Z, dZ + +S, T, Z, dZ = iteration(C) +D = np.zeros(C.shape) plt.imshow(S ** 0.1, cmap=plt.cm.twilight_shifted, origin="lower") plt.savefig("Mandelbrot_set_1.png", dpi=200) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-6.py b/Task/Mandelbrot-set/Python/mandelbrot-set-6.py index 8173f62c10..f581e706b4 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-6.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-6.py @@ -13,13 +13,23 @@ y = np.linspace(0, 2 * h / d, num=h+1) A, B = np.meshgrid(x - 1, y - h / d) C = (2.0 + 1.0j) * (A + B * 1j) - 0.5 -Z, dZ, ddZ = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C) -D, S, T = np.zeros(C.shape), np.zeros(C.shape), np.zeros(C.shape) +def iteration(C): + S, T = np.zeros(C.shape), np.zeros(C.shape) + Z, dZ, ddZ = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C) -for k in range(n): - M = abs(Z) < r - S[M], T[M] = S[M] + np.sin(density * np.angle(Z[M])), T[M] + 1 - Z[M], dZ[M], ddZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1, 2 * (dZ[M] ** 2 + Z[M] * ddZ[M]) + def iterate(C, S, T, Z, dZ, ddZ): + S, T = S + np.sin(density * np.angle(Z)), T + 1 + Z, dZ, ddZ = Z * Z + C, 2 * Z * dZ + 1, 2 * (dZ * dZ + Z * ddZ) + return S, T, Z, dZ, ddZ + + for i in range(n): + M = abs(Z) < r + S[M], T[M], Z[M], dZ[M], ddZ[M] = iterate(C[M], S[M], T[M], Z[M], dZ[M], ddZ[M]) + + return S, T, Z, dZ, ddZ + +S, T, Z, dZ, ddZ = iteration(C) +D = np.zeros(C.shape) N = abs(Z) >= r # basic normal map effect and stripe average coloring (potential function) P, Q = S[N] / T[N], (S[N] + np.sin(density * np.angle(Z[N]))) / (T[N] + 1) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-7.py b/Task/Mandelbrot-set/Python/mandelbrot-set-7.py index 90e9a2d739..148ea3f25a 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-7.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-7.py @@ -4,8 +4,8 @@ import matplotlib.pyplot as plt d, h = 200, 1200 # pixel density (= image width) and image height n, r = 8000, 10000 # number of iterations and escape radius (r > 2) -a = -.743643887037158704752191506114774 # https://mathr.co.uk/web/m-location-analysis.html -b = 0.131825904205311970493132056385139 # try: a, b, n = -1.748764520194788535, 3e-13, 800 +a = -.743643887037158704752191506114774 # coordinates by github.com/josch +b = 0.131825904205311970493132056385139 # https://github.com/josch/mandelbrot x = np.linspace(0, 2, num=d+1) y = np.linspace(0, 2 * h / d, num=h+1) @@ -13,12 +13,21 @@ y = np.linspace(0, 2 * h / d, num=h+1) A, B = np.meshgrid(x * np.pi, y * np.pi) C = 8.0 * np.exp((A + B * 1j) * 1j) + (a + b * 1j) -Z, dZ = np.zeros_like(C), np.zeros_like(C) -D = np.zeros(C.shape) +def iteration(C): + Z, dZ = np.zeros_like(C), np.zeros_like(C) -for k in range(n): - M = Z.real ** 2 + Z.imag ** 2 < r ** 2 - Z[M], dZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1 + def iterate(C, Z, dZ): + Z, dZ = Z * Z + C, 2 * Z * dZ + 1 + return Z, dZ + + for i in range(n): + M = abs(Z) < r + Z[M], dZ[M] = iterate(C[M], Z[M], dZ[M]) + + return Z, dZ + +Z, dZ = iteration(C) +D = np.zeros(C.shape) N = abs(Z) > 2 # exterior distance estimation D[N] = np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) @@ -26,12 +35,14 @@ D[N] = np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) plt.imshow(D.T ** 0.05, cmap=plt.cm.nipy_spectral, origin="lower") plt.savefig("Mercator_Mandelbrot_map.png", dpi=200) -X, Y = C.real, C.imag # zoom images (adjust circle size 100 and zoom level 20 as needed) -R, c, z = 100 * (2 / d) * np.pi * np.exp(- B), min(d, h) + 1, max(0, h - d) // 20 +M = 50 * (2 / d) * np.pi * np.exp(- B) # adjust marker size 50 as needed +k, l = min(d, h) + 1, max(0, h - d) // 20 # adjust zoom level 20 as needed + +fig, axs = plt.subplots(2, 3, figsize=(12, 8)) +for i, ax in enumerate(axs.flat): + X, Y = C[i*l:i*l+k, 0:d].real, C[i*l:i*l+k, 0:d].imag + S, T = M[0:k, 0:d] ** 2, D[i*l:i*l+k, 0:d] ** 0.5 + ax.scatter(X, Y, s=S, c=T, cmap=plt.cm.nipy_spectral) + ax.axis('equal') -fig, ax = plt.subplots(2, 2, figsize=(12, 12)) -ax[0,0].scatter(X[1*z:1*z+c,0:d], Y[1*z:1*z+c,0:d], s=R[0:c,0:d]**2, c=D[1*z:1*z+c,0:d]**.5, cmap=plt.cm.nipy_spectral) -ax[0,1].scatter(X[2*z:2*z+c,0:d], Y[2*z:2*z+c,0:d], s=R[0:c,0:d]**2, c=D[2*z:2*z+c,0:d]**.4, cmap=plt.cm.nipy_spectral) -ax[1,0].scatter(X[3*z:3*z+c,0:d], Y[3*z:3*z+c,0:d], s=R[0:c,0:d]**2, c=D[3*z:3*z+c,0:d]**.3, cmap=plt.cm.nipy_spectral) -ax[1,1].scatter(X[4*z:4*z+c,0:d], Y[4*z:4*z+c,0:d], s=R[0:c,0:d]**2, c=D[4*z:4*z+c,0:d]**.2, cmap=plt.cm.nipy_spectral) plt.savefig("Mercator_Mandelbrot_zoom.png", dpi=100) diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-8.py b/Task/Mandelbrot-set/Python/mandelbrot-set-8.py index d4580ac79d..2af2697c11 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-8.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-8.py @@ -1,12 +1,13 @@ +import numba + import numpy as np -import numba as nb import matplotlib.pyplot as plt import decimal as dc # decimal floating point arithmetic with arbitrary precision dc.getcontext().prec = 80 # set precision to 80 digits (about 256 bits) d, h = 100, 2000 # pixel density (= image width) and image height -n, r = 80000, 100000 # number of iterations and escape radius (r > 2) +n, r = 80000, 100000.0 # number of iterations and escape radius (r > 2) a = dc.Decimal("-1.256827152259138864846434197797294538253477389787308085590211144291") b = dc.Decimal(".37933802890364143684096784819544060002129071484943239316486643285025") @@ -14,12 +15,12 @@ b = dc.Decimal(".379338028903641436840967848195440600021290714849432393164866432 S = np.zeros(n+1, dtype=np.complex128) u, v = dc.Decimal(0), dc.Decimal(0) -for k in range(n+1): - S[k] = float(u) + float(v) * 1j +for i in range(n+1): + S[i] = float(u) + float(v) * 1j if u * u + v * v < r * r: u, v = u * u - v * v + a, 2 * u * v + b else: - print("The reference sequence diverges within %s iterations." % k) + print("The reference sequence diverges within %s iterations." % i) break x = np.linspace(0, 2, num=d+1, dtype=np.float64) @@ -28,37 +29,37 @@ y = np.linspace(0, 2 * h / d, num=h+1, dtype=np.float64) A, B = np.meshgrid(x * np.pi, y * np.pi) C = (- 8.0) * np.exp((A + B * 1j) * 1j) -@nb.njit(parallel=True) -def calculation(C): - E, I = np.zeros_like(C), np.zeros(C.shape, dtype=np.int64) - Z, dZ = np.zeros_like(C), np.zeros_like(C) +@numba.njit(parallel=True) +def iteration_numba(S, C): + I = np.zeros(C.shape, dtype=np.intp) + E, Z, dZ = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C) - def iteration(C): - E, I = np.zeros_like(C), np.zeros(C.shape, dtype=np.int64) - Z, dZ = np.zeros_like(C), np.zeros_like(C) + def iteration(S, C): + I = np.zeros(C.shape, dtype=np.intp) + E, Z, dZ = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C) def abs2(z): return z.real * z.real + z.imag * z.imag - def iterate(E, I, Z, dZ, C): - E, I = (2 * S[I] + E) * E + C, I + 1 + def iterate(C, I, E, Z, dZ): + I, E = I + 1, (2 * S[I] + E) * E + C Z, dZ = S[I] + E, 2 * Z * dZ + 1 - return E, I, Z, dZ + return I, E, Z, dZ - for k in range(n): - M = abs2(Z) < abs2(E) - E[M], I[M] = Z[M], 0 # rebase when z is closer to zero + for i in range(n): + M = abs2(Z) < abs2(E) # rebase when z is closer to zero + I[M], E[M] = 0, Z[M] # reset the reference orbit M = abs2(Z) < abs2(r) - E[M], I[M], Z[M], dZ[M] = iterate(E[M], I[M], Z[M], dZ[M], C[M]) + I[M], E[M], Z[M], dZ[M] = iterate(C[M], I[M], E[M], Z[M], dZ[M]) - return E, I, Z, dZ + return I, E, Z, dZ - for j in nb.prange(C.shape[1]): - E[:,j], I[:,j], Z[:,j], dZ[:,j] = iteration(C[:,j]) + for j in numba.prange(d+1): + I[:, j], E[:, j], Z[:, j], dZ[:, j] = iteration(S, C[:, j]) - return E, I, Z, dZ + return I, E, Z, dZ -E, I, Z, dZ = calculation(C) +I, E, Z, dZ = iteration_numba(S, C) D = np.zeros(C.shape, dtype=np.float64) N = abs(Z) > 2 # exterior distance estimation diff --git a/Task/Mandelbrot-set/Python/mandelbrot-set-9.py b/Task/Mandelbrot-set/Python/mandelbrot-set-9.py index 6cce0c0708..57df19d043 100644 --- a/Task/Mandelbrot-set/Python/mandelbrot-set-9.py +++ b/Task/Mandelbrot-set/Python/mandelbrot-set-9.py @@ -1,8 +1,85 @@ -print( -'\n'.join( - ''.join( - ' *'[(z:=0, c:=x/50+y/50j, [z:=z*z+c for _ in range(99)], abs(z))[-1]<2] - for x in range(-100,25) - ) - for y in range(-50,50) -)) +import jax +jax.config.update("jax_enable_x64", True) # faster on GPU P100 than on GPU T4 + +import numpy as np +import matplotlib.pyplot as plt + +import cupy as cp +import jax.numpy as jnp + +import decimal as dc # decimal floating point arithmetic with arbitrary precision +dc.getcontext().prec = 80 # set precision to 80 digits (about 256 bits) + +d, h = 100, 2000 # pixel density (= image width) and image height +n, r = 100000, 100000.0 # number of iterations and escape radius (r > 2) + +a = dc.Decimal("-1.256827152259138864846434197797294538253477389787308085590211144291") +b = dc.Decimal(".37933802890364143684096784819544060002129071484943239316486643285025") + +S = np.zeros(n+1, dtype=np.complex128) +u, v = dc.Decimal(0), dc.Decimal(0) + +for i in range(n+1): + S[i] = float(u) + float(v) * 1j + if u * u + v * v < r * r: + u, v = u * u - v * v + a, 2 * u * v + b + else: + print("The reference sequence diverges within %s iterations." % i) + break + +x = np.linspace(0, 2, num=d+1, dtype=np.float64) +y = np.linspace(0, 2 * h / d, num=h+1, dtype=np.float64) + +A, B = np.meshgrid(x * np.pi, y * np.pi) +C = (- 8.0) * np.exp((A + B * 1j) * 1j) + +def iteration_cupy(S, C): + + def iteration(S, C): + I = cp.zeros(C.shape, dtype=np.intp) + E, Z, dZ = cp.zeros_like(C), cp.zeros_like(C), cp.zeros_like(C) + + for i in range(n): + M = cp.absolute(Z) < cp.absolute(E) # rebase when z is closer to zero + I, E = cp.where(M, 0, I), cp.where(M, Z, E) # reset reference orbit + M = cp.absolute(Z) < r + I, E = cp.where(M, I + 1, I), cp.where(M, (2 * S[I] + E) * E + C, E) + Z, dZ = cp.where(M, S[I] + E, Z), cp.where(M, 2 * Z * dZ + 1, dZ) + + return I, E, Z, dZ + + I, E, Z, dZ = iteration(cp.asarray(S), cp.asarray(C)) + return I.get(), E.get(), Z.get(), dZ.get() + +def iteration_jax(S, C): + + def iteration(S, C): + I = jnp.zeros(C.shape, dtype=np.intp) + E, Z, dZ = jnp.zeros_like(C), jnp.zeros_like(C), jnp.zeros_like(C) + + def abs2(z): + return z.real * z.real + z.imag * z.imag + + def iterate(i, V): + I, E, Z, dZ = V + M = abs2(Z) < abs2(E) # rebase when z is closer to zero + I, E = jnp.where(M, 0, I), jnp.where(M, Z, E) # reset reference orbit + M = abs2(Z) < abs2(r) + I, E = jnp.where(M, I + 1, I), jnp.where(M, (2 * S[I] + E) * E + C, E) + Z, dZ = jnp.where(M, S[I] + E, Z), jnp.where(M, 2 * Z * dZ + 1, dZ) + return I, E, Z, dZ + + I, E, Z, dZ = jax.lax.fori_loop(0, n, iterate, (I, E, Z, dZ), unroll=10) + return I, E, Z, dZ + + I, E, Z, dZ = iteration(jnp.asarray(S), jnp.asarray(C)) + return np.asarray(I), np.asarray(E), np.asarray(Z), np.asarray(dZ) + +I, E, Z, dZ = iteration_jax(S, C) # use iteration_cupy or iteration_jax +D = np.zeros(C.shape, dtype=np.float64) + +N = abs(Z) > 2 # exterior distance estimation +D[N] = np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) + +plt.imshow(D.T ** 0.015, cmap=plt.cm.gist_ncar, origin="lower") +plt.savefig("Mercator_Mandelbrot_deep_map.png", dpi=200) diff --git a/Task/Map-range/DuckDB/map-range.duckdb b/Task/Map-range/DuckDB/map-range.duckdb new file mode 100644 index 0000000000..412ed1b025 --- /dev/null +++ b/Task/Map-range/DuckDB/map-range.duckdb @@ -0,0 +1,9 @@ +# x is the value to be mapped. +# The ranges, a and b, should each be an array defining the +# left-most and right-most points of the range. +create or replace function maprange(a, b, x) as + b[1] + (((x - a[1]) * (b[2] - b[1]::DOUBLE)) / (a[2] - a[1]::DOUBLE)) ; + +# Example 1: a single value +# (Conversion to floating point will be automatic) +select maprange([0,10], [-1, 0], 6) as mapped; diff --git a/Task/Map-range/Pascal-P/map-range.pas b/Task/Map-range/Pascal-P/map-range.pas new file mode 100644 index 0000000000..72b09669a6 --- /dev/null +++ b/Task/Map-range/Pascal-P/map-range.pas @@ -0,0 +1,14 @@ +program map(output); +(* Map range *) +var + i: integer; + + function maprange(a1, a2, b1, b2: real; s: real): real; + begin + maprange := (s - a1) * (b2 - b1) / (a2 - a1) + b1; + end; + +begin + for i := 0 to 10 do + writeln(i: 2, ' maps to: ', maprange(0.0, 10.0, -1.0, 0.0, i): 10); +end. diff --git a/Task/Matrix-multiplication/DuckDB/matrix-multiplication-1.duckdb b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-1.duckdb new file mode 100644 index 0000000000..2046c86492 --- /dev/null +++ b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-1.duckdb @@ -0,0 +1,7 @@ +# Given two tables, A and B, representing two matrices in (i,j,value) format, the product +# can be computed as follows, with the result being in the same format. +SELECT A.i, B.j, + SUM(A.value * B.value) AS value + FROM A INNER JOIN B + ON A.j = B.i + GROUP BY A.i, B.j; diff --git a/Task/Matrix-multiplication/DuckDB/matrix-multiplication-2.duckdb b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-2.duckdb new file mode 100644 index 0000000000..2066a18e56 --- /dev/null +++ b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-2.duckdb @@ -0,0 +1,16 @@ +# The following SQL statement will convert a table A representing an m by n matrix +# in (i,j,value) format to a table with m rows and (n+1) columns, the first being the row id: +pivot A on j using max(value) order by i; + +# To exclude the row id column: +select columns(* exclude (i)) from (pivot A on j using max(value)) order by i; + +# To ensure the columns are presented in their natural order, +# the above 'select' statement may need to be adjusted. +# If n < 10, the following would suffice: +select columns(* exclude (i)) from (pivot A on j using max(value)) order by i; + +# For 10 to 99 columns: +select columns('^[1-9]$'), columns('^[1-9][0-9]') from (pivot A on j using max(value)) order by i; + +# If there are more than 99 columns, the above can be extended in the obvious way. diff --git a/Task/Matrix-multiplication/DuckDB/matrix-multiplication-3.duckdb b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-3.duckdb new file mode 100644 index 0000000000..abcb101633 --- /dev/null +++ b/Task/Matrix-multiplication/DuckDB/matrix-multiplication-3.duckdb @@ -0,0 +1,39 @@ +create or replace table A (i integer, j integer, value float ); +insert into A values + (1, 1, 1), + (1, 2, 2), + (1, 3, 3), + (2, 1, 2), + (2, 2, 5), + (2, 3, 7); + +create or replace table B (i integer, j integer, value float ); +insert into B values + (1, 1, 2), + (1, 2, 4), + (1, 3, 8), + (2, 1, 1), + (2, 2, 5), + (2, 3, -10), + (3, 1, 3), + (3, 2, 6), + (3, 3, 9); + +.print Display A in a matrix format including the row id +pivot A on j using max(value) order by i; + +.print Display B likewise +pivot B on j using max(value) order by i; + +. print Compute C = A * B +CREATE OR REPLACE table C as + SELECT A.i, B.j, + SUM(A.value * B.value) AS value + FROM A INNER JOIN B + ON A.j = B.i + GROUP BY A.i, B.j; + +.print Display C in matrix format excluding the row id +select columns(* exclude (i)) + from (pivot C on j using max(value)) + order by i; diff --git a/Task/Matrix-multiplication/Objeck/matrix-multiplication.objeck b/Task/Matrix-multiplication/Objeck/matrix-multiplication.objeck new file mode 100644 index 0000000000..ba55e96abe --- /dev/null +++ b/Task/Matrix-multiplication/Objeck/matrix-multiplication.objeck @@ -0,0 +1,8 @@ +class Test { + function : Main(args : String[]) ~ Nil { + a := [[1.0, 2.0], [3.0, 4.0], [3.0, 6.0]]; + b := [[-3.0, -8.0, 3.0,], [-2.0, 1.0, 4.0]]; + + System.ML.Matrix2D->DotProduct(a,b)->ToString()->PrintLine(); + } +} diff --git a/Task/Matrix-transposition/DuckDB/matrix-transposition-1.duckdb b/Task/Matrix-transposition/DuckDB/matrix-transposition-1.duckdb new file mode 100644 index 0000000000..ffa2bb0a1d --- /dev/null +++ b/Task/Matrix-transposition/DuckDB/matrix-transposition-1.duckdb @@ -0,0 +1 @@ +select j as i, i as j, value from A; diff --git a/Task/Matrix-transposition/DuckDB/matrix-transposition-2.duckdb b/Task/Matrix-transposition/DuckDB/matrix-transposition-2.duckdb new file mode 100644 index 0000000000..7744c88beb --- /dev/null +++ b/Task/Matrix-transposition/DuckDB/matrix-transposition-2.duckdb @@ -0,0 +1,22 @@ +create or replace table A (i integer, j integer, value float ); +insert into A values + (1, 1, 1), + (1, 2, 2), + (1, 3, 3), + (2, 1, 2), + (2, 2, 5), + (2, 3, 7); + +# transposition +create or replace table AT as + (select j as i, i as j, value from A); + +.print The matrix-like representation of A: +create or replace table AMatrix as (pivot A on j using max(value) order by i); +from AMatrix; + +.print Convert the matrix-like representation back to the (i,j,value) representation: +unpivot AMatrix on columns('^[1-9]') into name j VALUE value; + +.print The matrix-like representation of "A transpose": +pivot AT on j using max(value) order by i; diff --git a/Task/Matrix-transposition/DuckDB/matrix-transposition-3.duckdb b/Task/Matrix-transposition/DuckDB/matrix-transposition-3.duckdb new file mode 100644 index 0000000000..283efd0fab --- /dev/null +++ b/Task/Matrix-transposition/DuckDB/matrix-transposition-3.duckdb @@ -0,0 +1,5 @@ +# Note that if the input is not rectangular, the output might be lossy. +create or replace function transpose(lst) as ( + select list_transform( range(1, 1+length(lst[1])), + j -> list_transform(range(1, length(lst)+1), + i -> lst[i][j]) )); diff --git a/Task/Mayan-calendar/Rust/mayan-calendar.rs b/Task/Mayan-calendar/Rust/mayan-calendar.rs new file mode 100644 index 0000000000..ab94547baf --- /dev/null +++ b/Task/Mayan-calendar/Rust/mayan-calendar.rs @@ -0,0 +1,121 @@ +use chrono::{NaiveDate, Duration}; + +const TZOLKIN: [&str; 20] = [ + "Imix'", "Ik'", "Ak'bal", "K'an", "Chikchan", "Kimi", "Manik'", + "Lamat", "Muluk", "Ok", "Chuwen", "Eb", "Ben", "Hix", "Men", + "K'ib'", "Kaban", "Etz'nab'", "Kawak", "Ajaw" +]; + +const HAAB: [&str; 19] = [ + "Pop", "Wo'", "Sip", "Sotz'", "Sek", "Xul", "Yaxk'in", "Mol", + "Ch'en", "Yax", "Sak'", "Keh", "Mak", "K'ank'in", "Muwan", + "Pax", "K'ayab", "Kumk'u", "Wayeb'" +]; + +fn positive_modulus(base: i32, modulus: i32) -> i32 { + let result = base % modulus; + if result < 0 { + result + modulus + } else { + result + } +} + +fn create_date(iso_date: &str) -> NaiveDate { + let year: i32 = iso_date[0..4].parse().unwrap(); + let month: u32 = iso_date[5..7].parse().unwrap(); + let day: u32 = iso_date[8..10].parse().unwrap(); + + NaiveDate::from_ymd_opt(year, month, day).unwrap() +} + +fn days_per_mayan_month(month: &str) -> i32 { + if month == "Wayeb'" { 5 } else { 20 } +} + +fn tzolkin(gregorian: &NaiveDate) -> String { + let creation_tzolkin = create_date("2012-12-21"); + let days_between = (*gregorian - creation_tzolkin).num_days() as i32; + + let mut remainder = positive_modulus(days_between, 13); + remainder += if remainder <= 9 { 4 } else { -9 }; + + let tzolkin_name = TZOLKIN[positive_modulus(days_between - 1, 20) as usize]; + format!("{} {}", remainder, tzolkin_name) +} + +fn haab(gregorian: &NaiveDate) -> String { + let zero_haab = create_date("2019-04-02"); + let days_between = (*gregorian - zero_haab).num_days() as i32; + + let remainder = positive_modulus(days_between, 365); + let month = HAAB[positive_modulus(remainder + 1, 20) as usize]; + let day_of_month = remainder % 20 + 1; + + if day_of_month < days_per_mayan_month(month) { + format!("{} {}", day_of_month, month) + } else { + format!("Chum {}", month) + } +} + +fn long_count(gregorian: &NaiveDate) -> String { + let creation_tzolkin = create_date("2012-12-21"); + let mut days_between = (*gregorian - creation_tzolkin).num_days() as i32 + 13 * 360 * 400; + + let baktun = positive_modulus(days_between, 360 * 400); + days_between %= 360 * 400; + let katun = days_between / (20 * 360); + days_between %= 20 * 360; + let tun = days_between / 360; + days_between %= 360; + let winal = days_between / 20; + let kin = days_between % 20; + + let numbers = [baktun, katun, tun, winal, kin]; + let mut result = String::new(); + + for number in numbers { + let value = if number <= 9 { + format!("0{}.", number) + } else { + format!("{}.", number) + }; + result.push_str(&value); + } + + // Remove the last dot + result.pop(); + result +} + +fn lords_of_the_night(gregorian: &NaiveDate) -> String { + let creation_tzolkin = create_date("2012-12-21"); + let days_between = (*gregorian - creation_tzolkin).num_days() as i32; + let remainder = days_between % 9; + + let g_number = if remainder <= 0 { remainder + 9 } else { remainder }; + format!("G{}", g_number) +} + +fn main() { + let iso_dates = [ + "2004-06-19", "2012-12-18", "2012-12-21", "2019-01-19", + "2019-03-27", "2020-02-29", "2020-03-01", "2071-05-16", "2020-02-02" + ]; + + println!("Gregorian Long Count Tzolk'in Haab' Lords of the Night"); + println!("------------------------------------------------------------------------------"); + + for iso_date in &iso_dates { + let date = create_date(iso_date); + + println!("{:<15}{:<19}{:<12}{:<18}{}", + iso_date, + long_count(&date), + tzolkin(&date), + haab(&date), + lords_of_the_night(&date) + ); + } +} diff --git a/Task/Mayan-numerals/FutureBasic/mayan-numerals.basic b/Task/Mayan-numerals/FutureBasic/mayan-numerals.basic new file mode 100644 index 0000000000..7be7005742 --- /dev/null +++ b/Task/Mayan-numerals/FutureBasic/mayan-numerals.basic @@ -0,0 +1,117 @@ +// +// Mayan numbers cartouche +// +// FutureBasic 7.0.34 July 2025 R.W + +CFStringRef cartouche (7) // array for cartouche + +// This is how the cartouche layout will +// be. It consists of 8 printed lines. + +cartouche(0)= @"║ Θ ║" // the number 0 +cartouche(1)= @"║ ● ║" // the number 1 +cartouche(2)= @"║ ● ● ║" // the number 2 +cartouche(3)= @"║ ● ● ● ║" // the number 3 +cartouche(4)= @"║ ● ● ● ● ║" // the number 4 +cartouche(5)= @"║━━━━━━━━━║" // the number 5 +cartouche(6)= @"╔═════════╗" // top line +cartouche(7)= @"╚═════════╝" // bottom line + +// +// Converts decimal number to vigesimal +// +// On entry: n is a decimal number +// On exit: result as a string of vigesimal +// separated by space +// +local fn decToVigesimal(n as long) as CFStringRef + CFStringRef result + result = @"": if n == 0 then result = @" 0" + while n > 0 + result = concat(str(n % 20),result) + n = fix (n/20) + wend +end fn = result + +// +// Converts vigesimal to a Mayan cartouche +// +// On entry: n is a vigesimal string separated by spaces +// On exit: Mayan cartouche drawn (horizontally) +// + +local fn VigesimalToMayan(n as CFStringRef) + Int m, x, y, idx, al, ov + boolean done = _False + CFStringRef disg (6,15) + CFStringRef vn + CFArrayRef myArray + + myArray = fn StringComponentsSeparatedByString(n,@" ") + al = len(myArray) - 1 + + vn = @"" + for m = 1 to al + done = _False + vn = myArray [m] + idx = intval(vn) + ov = idx + disg (0,m) = cartouche(6) + + for x = 4 to 1 step -1 + + disg (x,m) = @"║ ║" + if ov == 0 + if !done then disg(x,m) = cartouche(0) + done = _True + end if + + if idx > 4 + disg(x,m) = cartouche(5) + idx = idx - 5 + else + y = idx % 5 + if y > 0 + if !done then disg(x,m) = cartouche (y) + done = _True + end if + end if + next x + disg (5,m) = cartouche(7) + next m + + for x = 0 to 5 + for m = 1 to al + print disg(x,m); + next m + print + next x +end fn + + +window 1 + +// Test data + +CFStringRef Vigesimal +print "Converting 4005 to Mayan" +Vigesimal = fn decToVigesimal(4005) +fn VigesimalToMayan (Vigesimal) + +print "Converting 8017 to Mayan" +Vigesimal = fn decToVigesimal(8017) +fn VigesimalToMayan (Vigesimal) + +print "Converting 326205 to Mayan" +Vigesimal = fn decToVigesimal(326205) +fn VigesimalToMayan (Vigesimal) + +print "Converting 886205 to Mayan" +Vigesimal = fn decToVigesimal(886205) +fn VigesimalToMayan (Vigesimal) + +print "Interesting looking Mayan number" +Vigesimal = fn decToVigesimal(717784) +fn VigesimalToMayan (Vigesimal) + +handleEvents diff --git a/Task/McNuggets-problem/Fortran/mcnuggets-problem.f b/Task/McNuggets-problem/Fortran/mcnuggets-problem.f new file mode 100644 index 0000000000..1010851e87 --- /dev/null +++ b/Task/McNuggets-problem/Fortran/mcnuggets-problem.f @@ -0,0 +1,64 @@ +program mcnugget + ! Program to find non-McNugget numbers (up to 100) that cannot be expressed as + ! 6x + 9y + 20z (with x, y, z non-negative integers). This version uses dynamic + ! programming to mark expressible numbers and then uses FINDLOC on a logical mask + ! (derived by applying .NOT. to the expressible array) to obtain the largest + ! non-expressible number. + + implicit none + integer, parameter :: n = 100 + logical :: expressible(0:n) ! Mark if each number 0:n is expressible. + integer :: max_val ! To store the largest non-expressible number. + integer :: i, j ! Loop indices. + integer :: denoms(3) ! Array of denominations: 6, 9, 20. + integer, allocatable :: loc(:) + ! 'loc' will store the indices returned by FINDLOC. + + !-------------------------------------------------------------------- + ! Initialize the denominations and print them. + !-------------------------------------------------------------------- + denoms = [6, 9, 20] + print *, 'Nugget pacet sizes: ', denoms + + !-------------------------------------------------------------------- + ! Initialize all numbers as non-expressible except 0. + ! 0 is expressible (with x = y = z = 0). + !-------------------------------------------------------------------- + expressible = .false. + expressible(0) = .true. + + !-------------------------------------------------------------------- + ! Dynamic programming: + ! For each denomination, if a number i is expressible then mark + ! i + denomination as expressible (provided it does not exceed n). + !-------------------------------------------------------------------- + do j = 1, 3 + do i = 0, n - denoms(j) + if (expressible(i)) then + expressible(i + denoms(j)) = .true. + end if + end do + end do + + !-------------------------------------------------------------------- + ! Instead of looping to count and store non-expressible numbers, + ! we use the FINDLOC intrinsic to get the largest index for which + ! the number is NOT expressible. + ! + ! The expression (.not. expressible) creates a logical mask that is .true. + ! when a number is non-expressible. FINDLOC with BACK=.TRUE. searches the + ! array in reverse order (from n down to 0), thus returning the maximum index. + !-------------------------------------------------------------------- + loc = findloc(.not. expressible, .true., back = .true.) + if (size(loc) > 0) then + max_val = loc(1) ! Retrieve the largest non-expressible number. + else + max_val = 0 ! In the unlikely event that every number is expressible. + end if + + !-------------------------------------------------------------------- + ! Output the result (only the largest non-McNugget number). + !-------------------------------------------------------------------- + print *, 'Maximum non-McNuggets number is ', max_val + +end program mcnugget diff --git a/Task/Meissel-Mertens-constant/JavaScript/meissel-mertens-constant.js b/Task/Meissel-Mertens-constant/JavaScript/meissel-mertens-constant.js new file mode 100644 index 0000000000..485e2c3aed --- /dev/null +++ b/Task/Meissel-Mertens-constant/JavaScript/meissel-mertens-constant.js @@ -0,0 +1,135 @@ +function main() { + // Use a smaller limit to avoid memory issues + // For demonstration, using 10 million instead of 1 billion + const limit = 10_000_000; + const primeReciprocals = listPrimeReciprocals(limit); + const euler = 0.577215664901532861; + let sum = 0.0; + + for (const reciprocal of primeReciprocals) { + sum += reciprocal + Math.log(1.0 - reciprocal); + } + + const meisselMertens = euler + sum; + console.log(`The Meissel-Mertens constant = ${meisselMertens.toFixed(9)}`); + console.log(`Calculated with primes up to: ${limit.toLocaleString()}`); +} + +function listPrimeReciprocals(limit) { + const segmentSize = Math.min(1_000_000, limit); // Process in 1M chunks + const result = []; + + // First, find all primes up to sqrt(limit) for marking composites + const sqrtLimit = Math.floor(Math.sqrt(limit)); + const basePrimes = sieveOfEratosthenes(sqrtLimit); + + // Process the range in segments + for (let segStart = 2; segStart <= limit; segStart += segmentSize) { + const segEnd = Math.min(segStart + segmentSize - 1, limit); + const segmentPrimes = segmentedSieve(segStart, segEnd, basePrimes); + + // Add reciprocals of primes found in this segment + for (const prime of segmentPrimes) { + result.push(1.0 / prime); + } + } + + return result; +} + +function sieveOfEratosthenes(limit) { + const sieve = new Array(limit + 1).fill(true); + sieve[0] = sieve[1] = false; + + for (let i = 2; i * i <= limit; i++) { + if (sieve[i]) { + for (let j = i * i; j <= limit; j += i) { + sieve[j] = false; + } + } + } + + const primes = []; + for (let i = 2; i <= limit; i++) { + if (sieve[i]) { + primes.push(i); + } + } + + return primes; +} + +function segmentedSieve(segStart, segEnd, basePrimes) { + const segmentSize = segEnd - segStart + 1; + const sieve = new Array(segmentSize).fill(true); + + // Mark multiples of each base prime in this segment + for (const prime of basePrimes) { + // Find the first multiple of prime >= segStart + let start = Math.max(prime * prime, Math.ceil(segStart / prime) * prime); + + // Mark all multiples in this segment + for (let j = start; j <= segEnd; j += prime) { + sieve[j - segStart] = false; + } + } + + // Collect primes from this segment + const primes = []; + for (let i = 0; i < segmentSize; i++) { + if (sieve[i] && (segStart + i) >= 2) { + primes.push(segStart + i); + } + } + + return primes; +} + +// Alternative version with even more memory efficiency +function mainMemoryEfficient() { + const limit = 100_000_000; // Can handle larger limits + const euler = 0.577215664901532861; + let sum = 0.0; + let primeCount = 0; + + // Process primes incrementally without storing them all + processPrimesInSegments(limit, (prime) => { + const reciprocal = 1.0 / prime; + sum += reciprocal + Math.log(1.0 - reciprocal); + primeCount++; + + // Progress indicator for large calculations + if (primeCount % 100000 === 0) { + console.log(`Processed ${primeCount.toLocaleString()} primes...`); + } + }); + + const meisselMertens = euler + sum; + console.log(`The Meissel-Mertens constant = ${meisselMertens.toFixed(9)}`); + console.log(`Calculated with ${primeCount.toLocaleString()} primes up to: ${limit.toLocaleString()}`); +} + +function processPrimesInSegments(limit, callback) { + const segmentSize = 1_000_000; + const sqrtLimit = Math.floor(Math.sqrt(limit)); + const basePrimes = sieveOfEratosthenes(sqrtLimit); + + // Process first segment (includes base primes) + for (const prime of basePrimes) { + callback(prime); + } + + // Process remaining segments + for (let segStart = sqrtLimit + 1; segStart <= limit; segStart += segmentSize) { + const segEnd = Math.min(segStart + segmentSize - 1, limit); + const segmentPrimes = segmentedSieve(segStart, segEnd, basePrimes); + + for (const prime of segmentPrimes) { + callback(prime); + } + } +} + +// Run the memory-efficient version +console.log("Running memory-efficient version..."); +mainMemoryEfficient(); diff --git a/Task/Meissel-Mertens-constant/REXX/meissel-mertens-constant.rexx b/Task/Meissel-Mertens-constant/REXX/meissel-mertens-constant.rexx index 1c5d19a827..58523cec16 100644 --- a/Task/Meissel-Mertens-constant/REXX/meissel-mertens-constant.rexx +++ b/Task/Meissel-Mertens-constant/REXX/meissel-mertens-constant.rexx @@ -1,13 +1,13 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings - -say 'MEISSEL-MERTENS CONSTANT' -say version -say arg n if n = '' then n = 16 numeric digits n + +say 'MEISSEL-MERTENS CONSTANT' +say version +say fact. = 0 call Time('r'); a = BruteForce(); e = Format(Time('e'),,3) say 'BruteForce' a '('e 'seconds)' @@ -20,7 +20,7 @@ say 'True value' a '('e 'seconds)' exit BruteForce: -procedure expose glob. +procedure expose Memo. numeric digits Digits()+2 y = 0.5-Ln(2) do n = 3 by 2 to 1000000 @@ -33,7 +33,7 @@ numeric digits Digits()-2 return y+0 UsingSieve: -procedure expose glob. prim. flag. +procedure expose Memo. prim. flag. numeric digits Digits()+2 n = Primes(1000000); y = 0 do i = 1 to n @@ -44,7 +44,7 @@ numeric digits Digits()-2 return y+0 Analytic: -procedure expose glob. fact. +procedure expose Memo. fact. numeric digits Digits()+2 y = 0; v = 0 do n = 2 to 1000 @@ -64,9 +64,4 @@ TrueValue: procedure return 0.261497212847642783755426838608695859051566648261199206192064213924924510897368209714142631434246651051617+0 -include Constants -include Functions -include Special -include Numbers -include Sequences -include Abend +include Math diff --git a/Task/Meissel-Mertens-constant/Rust/meissel-mertens-constant.rs b/Task/Meissel-Mertens-constant/Rust/meissel-mertens-constant.rs new file mode 100644 index 0000000000..99dea98352 --- /dev/null +++ b/Task/Meissel-Mertens-constant/Rust/meissel-mertens-constant.rs @@ -0,0 +1,39 @@ +fn list_prime_reciprocals(limit: i32) -> Vec { + let half_limit = if limit % 2 == 0 { limit / 2 } else { 1 + limit / 2 }; + let mut composite = vec![false; half_limit as usize]; + + for i in 1..half_limit as usize { + let p = 3 + 2 * (i as i32 - 1); + if !composite[i] { + let mut a = i + p as usize; + while a < half_limit as usize { + composite[a] = true; + a += p as usize; + } + } + } + + let mut result = Vec::with_capacity(half_limit as usize); + result.push(0.5); // Add 1/2 for prime number 2 + + for i in 1..half_limit as usize { + let p = 3 + 2 * (i as i32 - 1); + if !composite[i] { + result.push(1.0 / p as f64); + } + } + + result +} + +fn main() { + let prime_reciprocals = list_prime_reciprocals(100000000); + let euler = 0.577215664901532861; + + let sum: f64 = prime_reciprocals.iter() + .map(|&reciprocal| reciprocal + (1.0 - reciprocal).ln()) + .sum(); + + let meissel_mertens = euler + sum; + println!("The Meissel-Mertens constant = {:.8}", meissel_mertens); +} diff --git a/Task/Merge-and-aggregate-datasets/DuckDB/merge-and-aggregate-datasets.duckdb b/Task/Merge-and-aggregate-datasets/DuckDB/merge-and-aggregate-datasets.duckdb new file mode 100644 index 0000000000..1327975d1c --- /dev/null +++ b/Task/Merge-and-aggregate-datasets/DuckDB/merge-and-aggregate-datasets.duckdb @@ -0,0 +1,32 @@ +.print Since the patients.csv file is quite ordinary, it can be imported without fuss. + +create or replace table patients as + FROM 'patients.csv'; + +.print Taking the same approach with visits.csv illustrates how DuckDB correctly infers the types, including the date: + +create or replace table visits as + FROM 'visits.csv'; + +from visits; + +.print +.print Merge and group per patient id and last name, +.print get the maximum visit date, and +.print get the sum and average of the scores per patient to get the resulting dataset. + +SELECT + p.PATIENT_ID, + p.LASTNAME, + MAX(VISIT_DATE) AS LAST_VISIT, + SUM(SCORE) AS SCORE_SUM, + CAST(AVG(SCORE) AS DECIMAL(10,2)) AS SCORE_AVG +FROM + patients p + LEFT JOIN visits v + ON v.PATIENT_ID = p.PATIENT_ID +GROUP BY + p.PATIENT_ID, + p.LASTNAME +ORDER BY + p.PATIENT_ID; diff --git a/Task/Metallic-ratios/DuckDB/metallic-ratios-1.duckdb b/Task/Metallic-ratios/DuckDB/metallic-ratios-1.duckdb new file mode 100644 index 0000000000..ef559e03bb --- /dev/null +++ b/Task/Metallic-ratios/DuckDB/metallic-ratios-1.duckdb @@ -0,0 +1,5 @@ +create or replace table metals as + (select (row_number() over () - 1) as b, name + from unnest( + ['Platinum', 'Golden', 'Silver', 'Bronze', 'Copper','Nickel', 'Aluminium', 'Iron', 'Tin', 'Lead'] + ) _(name) ); diff --git a/Task/Metallic-ratios/DuckDB/metallic-ratios-2.duckdb b/Task/Metallic-ratios/DuckDB/metallic-ratios-2.duckdb new file mode 100644 index 0000000000..59306a60ac --- /dev/null +++ b/Task/Metallic-ratios/DuckDB/metallic-ratios-2.duckdb @@ -0,0 +1,24 @@ +# The Lucas-like function as per the task description +create or replace function lucas(b, n) as table ( + with recursive cte as ( + select 1 as ix, 1::HUGEINT as i, 1::HUGEINT as j + union all + select + ix+1, + j as i, + i + b*j as j + from cte + where ix < n) + select ix, i + from cte +); + +# The successive metallic ratio approximations +create or replace function metallic_ratio(b, n) as table ( + select i / (lag(i) over ()) + from lucas(b,n) +); + +.maxwidth 200 +select b, (select array_agg(i) from lucas(b, 15)) as "lucas-like" +from range(0, 10) _(b); diff --git a/Task/Metallic-ratios/DuckDB/metallic-ratios-3.duckdb b/Task/Metallic-ratios/DuckDB/metallic-ratios-3.duckdb new file mode 100644 index 0000000000..303b9058b4 --- /dev/null +++ b/Task/Metallic-ratios/DuckDB/metallic-ratios-3.duckdb @@ -0,0 +1,28 @@ +# ix serves both as a rowid and as the count of the number of +# iterations required to achieve the corresponding ratio +create or replace function metallic_ratio_to_quiescence(b) as ( + with recursive cte as ( + select + -1::HUGEINT as ix, + 1::HUGEINT as previ, + 1::HUGEINT as i, + 1::HUGEINT as j, + 1::DOUBLE as prevratio, + 1::DOUBLE as ratio + union all + select + ix+1, + i as previ, + j as i, + i + b*j as j, + ratio as prevratio, + (i::DOUBLE / previ) as ratio + from cte + where (ix < 4 or prevratio != ratio) + ) + select last((ix, ratio)) + from cte +); + +select b, name, metallic_ratio_to_quiescence(b) +from metals; diff --git a/Task/Metaprogramming/V-(Vlang)/metaprogramming.v b/Task/Metaprogramming/V-(Vlang)/metaprogramming.v new file mode 100644 index 0000000000..fd8e734c3b --- /dev/null +++ b/Task/Metaprogramming/V-(Vlang)/metaprogramming.v @@ -0,0 +1,30 @@ +@[heap] +struct Foo { +} + +fn (f Foo) test() int { + return 123 +} + +fn (f Foo) test2() string { + return "foo" +} + +fn main() { + foo := Foo{} + + $if ios || android {println("Running on a mobile device!")} + $if linux && x64 {println("64-bit Linux.")} + os := $if windows {"Windows"} $else {"Something Else"} + println("Using ${os}") + + $for m in Foo.methods { + $if m.return_type is int { + print("${m.name} returns int: ") + println(foo.$method()) + } $else $if m.return_type is string { + print("${m.name} returns string: ") + println(foo.$method()) + } + } +} diff --git a/Task/Mian-Chowla-sequence/Agena/mian-chowla-sequence.agena b/Task/Mian-Chowla-sequence/Agena/mian-chowla-sequence.agena new file mode 100644 index 0000000000..b81c43d6ff --- /dev/null +++ b/Task/Mian-Chowla-sequence/Agena/mian-chowla-sequence.agena @@ -0,0 +1,31 @@ +scope /* Find Mian-Chowla numbers: an + * where: ai = 1, + * and: an = smallest integer such that ai + aj is unique + * for all i, j in 1 .. n && i <= j + */ + + local maxMc, mcCount, mc, isSum := 100, 1, seq(), seq(); + for i while mcCount <= maxMc do + # assume i will be part of the sequence + mc[ mcCount ] := i; + # check the sums + local isUnique := true + for mcPos to mcCount while isUnique do + if isSum[ i + mc[ mcPos ] ] then + isUnique := false + fi + od; + if isUnique then + # i is a sequence element - store the sums + for k to mcCount do isSum[ i + mc[ k ] ] := true od; + mcCount +:= 1 + fi + od; + + # print parts of the sequence + printf( "Mian Chowla sequence elements 1..30:\n" ); + for i to 30 do printf( " %d", mc[ i ] ) od; + printf( "\nMian Chowla sequence elements 91..100:\n" ); + for i from 91 to 100 do printf( " %d", mc[ i ] ) od + +end diff --git a/Task/Mian-Chowla-sequence/Pluto/mian-chowla-sequence.pluto b/Task/Mian-Chowla-sequence/Pluto/mian-chowla-sequence.pluto new file mode 100644 index 0000000000..f4664e2ee8 --- /dev/null +++ b/Task/Mian-Chowla-sequence/Pluto/mian-chowla-sequence.pluto @@ -0,0 +1,35 @@ +do --[[ Find Mian-Chowla numbers: an + where: ai = 1, + and: an = smallest integer such that ai + aj is unique + for all i, j in 1 .. n && i <= j + ]] + local fmt = require( "fmt" ) + + local maxMc, mcCount, mc, isSum = 100, 1, {}, {} + local i = 0 + while mcCount <= maxMc do + ++ i + -- assume i will be part of the sequence + mc[ mcCount ] = i + -- check the sums + local isUnique = true + for mcPos = 1, mcCount do + if isSum[ i + mc[ mcPos ] ] then + isUnique = false + break + end + end + if isUnique then + -- i is a sequence element - store the sums + for k = 1, mcCount do isSum[ i + mc[ k ] ] = true end + ++ mcCount + end + end + + -- print parts of the sequence + io.write( "Mian Chowla sequence elements 1..30:\n " ) + fmt.lprint( table.slice( mc, 1, 30 ), " ", "" ) + io.write( "Mian Chowla sequence elements 91..100:\n " ) + fmt.lprint( table.slice( mc, 91, 100 ), " ", "" ) + +end diff --git a/Task/Middle-three-digits/DuckDB/middle-three-digits.duckdb b/Task/Middle-three-digits/DuckDB/middle-three-digits.duckdb new file mode 100644 index 0000000000..82b43f646d --- /dev/null +++ b/Task/Middle-three-digits/DuckDB/middle-three-digits.duckdb @@ -0,0 +1,22 @@ +create or replace function middle3digits_helper(s) as ( + select if (invalid_character, 'invalid character found', + if (invalid_n, 'invalid number of digits', + s[p+1 : p+3])) as result + from (select + regexp_matches(s, '[^0-9]') as invalid_character, + (length(s) < 3 or (length(s) % 2 = 0)) as invalid_n, + (length(s) - 3) // 2 as p + ) +); + +create or replace function middle3digits(number) as ( + middle3digits_helper(replace(trim(number::VARCHAR),'-','')) +); + +## Examples +select middle3digits('xyzzy'); + +select n, middle3digits(n) +from unnest( [ + 123, 12345, 1234567, 987654321, 10001, -10001, -123, -100, 100, -12345, + 1, 2, -1, -10, 2002, -2002, 0 ]) _(n) ; diff --git a/Task/Miller-Rabin-primality-test/Haskell/miller-rabin-primality-test-3.hs b/Task/Miller-Rabin-primality-test/Haskell/miller-rabin-primality-test-3.hs new file mode 100644 index 0000000000..0c755fd19d --- /dev/null +++ b/Task/Miller-Rabin-primality-test/Haskell/miller-rabin-primality-test-3.hs @@ -0,0 +1,15 @@ +mrt 2 = True +mrt x = odd x && all (\a -> work s x (expMod a d x) ) [2..(x-2)] where + (s,d) = sd (x-1) + +sd n = if odd n then (0,n) else (\(x,y) -> (x+1,y)) (sd (n `div` 2)) +work 0 n x = (x == 1) || (x == n-1) +work s n x + |(f == 1) && (x /= 1) && (x /= n-1) = False + |otherwise = work (s-1) n f where f = (x*x) `mod` n + + +expMod a 0 m = 1 +expMod a d m + | even d = expMod ((a * a) `mod` m) (d `div` 2) m + | otherwise = (a * expMod a (d - 1) m) `mod` m diff --git a/Task/Minesweeper-game/Liberty-BASIC/minesweeper-game.basic b/Task/Minesweeper-game/Liberty-BASIC/minesweeper-game.basic new file mode 100644 index 0000000000..d53ac07241 --- /dev/null +++ b/Task/Minesweeper-game/Liberty-BASIC/minesweeper-game.basic @@ -0,0 +1,422 @@ +' =============================== +' MINESWEEPER - Liberty BASIC +' =============================== + +' --- Constants --- +global cellSize, gridWidth, gridHeight, infoBarHeight +global totalMines, WindowWidth, WindowHeight, gameStatus$, minesLeft + +cellSize = 20 +gridWidth = 18 +gridHeight = 12 +infoBarHeight = 40 +totalMines = 16 + int(rnd(0)*4) + +WindowWidth = gridWidth * cellSize + 20 +WindowHeight = gridHeight * cellSize + infoBarHeight + 38 + +' --- Game State --- +dim mineGrid(gridWidth, gridHeight) +dim adjacentCount(gridWidth, gridHeight) +dim revealed(gridWidth, gridHeight) +dim marked(gridWidth, gridHeight) + +minesLeft = totalMines +gameStatus$ = "Playing..." + +' --- Start Program --- +call setupGame +call drawGameWindow + +wait + +' ------------------------------- +' SUB: Setup the Game +' ------------------------------- +sub setupGame + for x = 1 to gridWidth + for y = 1 to gridHeight + mineGrid(x, y) = 0 + adjacentCount(x, y) = 0 + revealed(x, y) = 0 + marked(x, y) = 0 + next + next + + minesPlaced = 0 + while minesPlaced < totalMines + rx = int(rnd(0) * gridWidth) + 1 + ry = int(rnd(0) * gridHeight) + 1 + + if mineGrid(rx, ry) = 0 then + mineGrid(rx, ry) = 1 + minesPlaced = minesPlaced + 1 + end if + wend + + for x = 1 to gridWidth + for y = 1 to gridHeight + if mineGrid(x, y) = 0 then + count = 0 + for dx = -1 to 1 + for dy = -1 to 1 + nx = x + dx + ny = y + dy + if nx >= 1 and nx <= gridWidth and ny >= 1 and ny <= gridHeight then + if mineGrid(nx, ny) = 1 then + count = count + 1 + end if + end if + next + next + adjacentCount(x, y) = count + end if + next + next +end sub + +' ------------------------------- +' SUB: Draw Game Window +' ------------------------------- +sub drawGameWindow + open "Minesweeper" for graphics_nf_nsb as #game + #game "down; fill white" + #game "trapclose [quit]" + #game "when leftButtonDown [leftClick]" + #game "when rightButtonDown [rightClick]" + + call drawInfoBar + call drawGrid +end sub + +' ------------------------------- +' SUB: Draw Info Bar +' ------------------------------- +sub drawInfoBar + #game "color black; backcolor white" + info$ = "Mines Left: "; minesLeft; " Status: "; gameStatus$ + #game "place 10 20" + #game "\"; info$ +end sub + +' ------------------------------- +' SUB: Draw Grid +' ------------------------------- +sub drawGrid + for x = 1 to gridWidth + for y = 1 to gridHeight + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + #game "color black; backcolor lightgray" + #game "place "; px; " "; py + #game "boxfilled "; px + cellSize; " "; py + cellSize + next + next +end sub + +' ------------------------------- +' HANDLER: Left Mouse Click +' ------------------------------- +[leftClick] + if gameStatus$ <> "Playing..." then + call askPlayAgain + wait + end if + + mouseX = MouseX + mouseY = MouseY + + gridLeft = 6 + gridTop = infoBarHeight + gridRight = gridLeft + gridWidth * cellSize + gridBottom = gridTop + gridHeight * cellSize + + if mouseX >= gridLeft and mouseX < gridRight and _ + mouseY >= gridTop and mouseY < gridBottom then + + cellX = int((mouseX - gridLeft) / cellSize) + 1 + cellY = int((mouseY - gridTop) / cellSize) + 1 + + call revealCell cellX, cellY + call checkWin + end if + + wait + +' ------------------------------- +' HANDLER: Right Mouse Click +' ------------------------------- +[rightClick] + if gameStatus$ <> "Playing..." then + call askPlayAgain + wait + end if + + mouseX = MouseX + mouseY = MouseY + + gridLeft = 6 + gridTop = infoBarHeight + gridRight = gridLeft + gridWidth * cellSize + gridBottom = gridTop + gridHeight * cellSize + + if mouseX >= gridLeft and mouseX < gridRight and _ + mouseY >= gridTop and mouseY < gridBottom then + + cellX = int((mouseX - gridLeft) / cellSize) + 1 + cellY = int((mouseY - gridTop) / cellSize) + 1 + + call toggleMark cellX, cellY + call checkWin + end if + + wait + +' ------------------------------- +' HANDLER: Close Window +' ------------------------------- +[quit] + close #game + end + +' ------------------------------- +' SUB: Reveal All Mines +' ------------------------------- +sub revealAllMines + for x = 1 to gridWidth + for y = 1 to gridHeight + if mineGrid(x, y) = 1 then + call drawMine x, y + end if + next + next +end sub + +' ------------------------------- +' SUB: Draw Mine Symbol +' ------------------------------- +sub drawMine x, y + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + #game "color black; backcolor lightgray" + #game "place "; px; " "; py + #game "boxfilled "; px + cellSize; " "; py + cellSize + + #game "color red" + tx = px + 5 + ty = py + 15 + #game "place "; tx; " "; ty + #game "\"; "M" +end sub + +' ------------------------------- +' SUB: Reveal All Numbers +' ------------------------------- +sub revealAllNumbers + for x = 1 to gridWidth + for y = 1 to gridHeight + if mineGrid(x, y) = 1 then + call drawMine x, y + else + call drawNumber x, y, adjacentCount(x, y) + end if + next + next +end sub + +' ------------------------------- +' SUB: Draw Cell Number +' ------------------------------- +sub drawNumber x, y, n + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + #game "color black; backcolor white" + #game "place "; px; " "; py + #game "boxfilled "; px + cellSize; " "; py + cellSize + + if n > 0 then + #game "color blue" + tx = px + 6 + ty = py + 15 + #game "place "; tx; " "; ty + #game "\"; str$(n) + end if +end sub + +' ------------------------------- +' SUB: Reveal a Single Cell +' ------------------------------- +sub revealCell x, y + if gameStatus$ <> "Playing..." then exit sub + if revealed(x, y) = 1 then exit sub + if marked(x, y) = 1 then exit sub + + revealed(x, y) = 1 + + if mineGrid(x, y) = 1 then + call animateBoom x, y + gameStatus$ = "BOOM!!! Game Over!" + call revealAllMines + call drawInfoBar + exit sub + end if + + call drawNumber x, y, adjacentCount(x, y) + + if adjacentCount(x, y) = 0 then + for dx = -1 to 1 + for dy = -1 to 1 + nx = x + dx + ny = y + dy + if nx >= 1 and nx <= gridWidth and ny >= 1 and ny <= gridHeight then + if revealed(nx, ny) = 0 then + call revealCell nx, ny + end if + end if + next + next + end if +end sub + +' ------------------------------- +' SUB: Check for Win Condition +' ------------------------------- +sub checkWin + safeCells = 0 + revealedSafeCells = 0 + + for x = 1 to gridWidth + for y = 1 to gridHeight + if mineGrid(x, y) = 0 then + safeCells = safeCells + 1 + if revealed(x, y) = 1 then + revealedSafeCells = revealedSafeCells + 1 + end if + end if + next + next + + if revealedSafeCells = safeCells then + gameStatus$ = "You Win!" + call drawInfoBar + call revealAllMines + end if +end sub + +' ------------------------------- +' SUB: Mark or unmark a cell +' ------------------------------- +sub toggleMark x, y + if gameStatus$ <> "Playing..." then exit sub + if revealed(x, y) = 1 then exit sub + + if marked(x, y) = 0 then + marked(x, y) = 1 + minesLeft = minesLeft - 1 + call drawMark x, y + else + marked(x, y) = 0 + minesLeft = minesLeft + 1 + call drawHidden x, y + end if + + call drawInfoBar +end sub + +' ------------------------------- +' SUB: Draw a Mark ("?") +' ------------------------------- +sub drawMark x, y + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + #game "color black; backcolor yellow" + #game "place "; px; " "; py + #game "boxfilled "; px + cellSize; " "; py + cellSize + + #game "color red" + tx = px + 6 + ty = py + 15 + #game "place "; tx; " "; ty + #game "\"; "?" +end sub + +' ------------------------------- +' SUB: Draw Hidden Cell +' ------------------------------- +sub drawHidden x, y + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + #game "color black; backcolor lightgray" + #game "place "; px; " "; py + #game "boxfilled "; px + cellSize; " "; py + cellSize +end sub + +' ------------------------------- +' SUB: Animate a Boom +' ------------------------------- +sub animateBoom x, y + #game "flush" + + px = 6 + (x - 1) * cellSize + py = infoBarHeight + (y - 1) * cellSize + + centerX = px + cellSize/2 + centerY = py + cellSize/2 + + #game "color red" + steps = 12 + + #game "backcolor red" + for i = 1 to steps + radius = i * 2 + #game "place "; centerX; " "; centerY + #game "circlefilled "; radius + timer 5, [continueBoom1] + wait + [continueBoom1] + timer 0 + next + + #game "backcolor white" + for i = 1 to steps + radius = i * 2 + #game "place "; centerX; " "; centerY + #game "circlefilled "; radius + timer 5, [continueBoom2] + wait + [continueBoom2] + timer 0 + next + + #game "redraw" +end sub + +' ------------------------------- +' SUB: Ask to Play Again +' ------------------------------- +sub askPlayAgain + confirm "Play again?"; answer + if answer = 1 then + call restartGame + else + close #game + end + end if +end sub + +' ------------------------------- +' SUB: Restart the Game +' ------------------------------- +sub restartGame + minesLeft = totalMines + gameStatus$ = "Playing..." + + call setupGame + call drawGrid + call drawInfoBar +end sub diff --git a/Task/Minimal-steps-down-to-1/Ada/minimal-steps-down-to-1.ada b/Task/Minimal-steps-down-to-1/Ada/minimal-steps-down-to-1.ada new file mode 100644 index 0000000000..6cc81a9446 --- /dev/null +++ b/Task/Minimal-steps-down-to-1/Ada/minimal-steps-down-to-1.ada @@ -0,0 +1,108 @@ +with Ada.Text_IO; + +procedure Steps_To_One is + type Steps_Array is array (Positive range <>) of Natural; + type Steps (N : Positive) is record + Div1, Div2, Sub : Positive; + Tab : Steps_Array (1 .. N); + end record; + + Table1 : Steps := + ( + N => 2000, + Div1 => 3, + Div2 => 2, + Sub => 1, + Tab => (1 => 0, others => Natural'Last) + ); + + Table2 : Steps := + ( + N => 2000, + Div1 => 3, + Div2 => 2, + Sub => 2, + Tab => (1 => 0, others => Natural'Last) + ); + + procedure Fill (Table : in out Steps) is + Min_Steps : Natural; + begin + for I in 2 .. Table.Tab'Last loop + Min_Steps := Natural'Last; + + if I mod Table.Div1 = 0 then + Min_Steps := Natural'Min (Min_Steps, Table.Tab (I / Table.Div1)); + end if; + + if I mod Table.Div2 = 0 then + Min_Steps := Natural'Min (Min_Steps, Table.Tab (I / Table.Div2)); + end if; + + if I - Table.Sub >= 1 then + Min_Steps := Natural'Min (Min_Steps, Table.Tab (I - Table.Sub)); + end if; + + Table.Tab (I) := 1 + Min_Steps; + end loop; + end Fill; + + procedure Show_Steps (Table : Steps; Limit : Positive) is + Min_Steps : Natural; + Trace : Positive; + begin + for I in 1 .. Limit loop + Min_Steps := Table.Tab (I); + Trace := I; + Ada.Text_IO.Put (I'Image & " [" & Min_Steps'Image & " steps ]: "); + + for J in 1 .. Table.Tab (I) loop + Ada.Text_IO.Put (Trace'Image); + Min_Steps := Table.Tab (Trace); + + if Trace mod Table.Div1 = 0 and then + Min_Steps = 1 + Table.Tab (Trace / Table.Div1) then + Ada.Text_IO.Put (" /" & Table.Div1'Image); + Trace := Trace / Table.Div1; + elsif Trace mod Table.Div2 = 0 and then + Min_Steps = 1 + Table.Tab (Trace / Table.Div2) then + Ada.Text_IO.Put ( " /" & Table.Div2'Image); + Trace := Trace / Table.Div2; + else + Ada.Text_IO.Put (" -" & Table.Sub'Image); + Trace := Trace - Table.Sub; + end if; + + Ada.Text_IO.Put (" =>"); + end loop; + + Ada.Text_IO.New_Line; + end loop; + end Show_Steps; + + procedure Show_Max_Min (Table : Steps) is + Max_Min : Natural := 0; + begin + for I of Table.Tab loop + Max_Min := Natural'Max (Max_Min, I); + end loop; + + Ada.Text_IO.Put ("Numbers with maximum minimal steps [" & Max_Min'Image & " ]: "); + + for I in Table.Tab'Range loop + if Max_Min = Table.Tab (I) then + Ada.Text_IO.Put (I'Image & ", "); + end if; + end loop; + + Ada.Text_IO.New_Line; + end Show_Max_Min; + +begin + Fill (Table1); + Show_Steps (Table1, 10); + Show_Max_Min (Table1); + Fill (Table2); + Show_Steps (Table2, 10); + Show_Max_Min (Table2); +end Steps_To_One; diff --git a/Task/Modular-arithmetic/00-TASK.txt b/Task/Modular-arithmetic/00-TASK.txt index 88e5dc547b..d2245933b1 100644 --- a/Task/Modular-arithmetic/00-TASK.txt +++ b/Task/Modular-arithmetic/00-TASK.txt @@ -1,10 +1,10 @@ '''[[wp:Modular arithmetic|Modular arithmetic]]''' is a form of arithmetic (a calculation technique involving the concepts of addition and multiplication) which is done on numbers with a defined [[wp:equivalence relation|equivalence relation]] called ''congruence''. -For any positive integer p called the ''congruence modulus'', -two numbers a and b are said to be ''congruent modulo p'' whenever there exists an integer k such that: -:a = b + k\,p +For any positive integer m called the ''congruence modulus'', +two numbers a and b are said to be ''congruent modulo m'' whenever there exists an integer k such that: +:a = b + k\,m -The corresponding set of [[wp:equivalence class|equivalence class]]es forms a [[wp:ring (mathematics)|ring]] denoted \frac{\Z}{p\Z}. When p is a prime number, this ring becomes a [[wp:field (mathematics)|field]] denoted \mathbb{F}_p, but you won't have to implement the [[wp:multiplicative inverse|multiplicative inverse]] for this task. +The corresponding set of [[wp:equivalence class|equivalence class]]es forms a [[wp:ring (mathematics)|ring]] denoted \Z/m\Z. When q=p^k \,(k>0) is a prime power, the ring \Z/q\Z becomes a [[wp:Finite field|finite field]], usually denoted \mathbb{F}_q or \mathrm{GF}(q), but you won't have to implement the [[wp:multiplicative inverse|multiplicative inverse]] for this task. Addition and multiplication on this ring have the same algebraic structure as in usual arithmetic, so that a function such as a polynomial expression could receive a ring element as argument and give a consistent result. @@ -22,3 +22,4 @@ In other words, the function is an algebraic expression that could be used with ;Related tasks: [[Modular exponentiation]]

    + diff --git a/Task/Modular-arithmetic/Common-Lisp/modular-arithmetic.lisp b/Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-1.lisp similarity index 100% rename from Task/Modular-arithmetic/Common-Lisp/modular-arithmetic.lisp rename to Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-1.lisp diff --git a/Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-2.lisp b/Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-2.lisp new file mode 100644 index 0000000000..3f60d21d14 --- /dev/null +++ b/Task/Modular-arithmetic/Common-Lisp/modular-arithmetic-2.lisp @@ -0,0 +1,25 @@ +(defpackage :rosetta-code/modular-arithmetic + (:use :cl)) + +(in-package :rosetta-code/modular-arithmetic) + +(defparameter *modulus* nil) + +(defun make-modular (op) + (lambda (&rest args) + (let ((result (apply op args))) + (if *modulus* + (mod result *modulus*) + result)))) + +(let ((ops '(+ expt))) ; add more operators as you need + (shadow ops) + (dolist (op ops) + (setf (symbol-function (find-symbol (symbol-name op))) + (make-modular (symbol-function (find-symbol (symbol-name op) :cl)))))) + +(defun f (x) + (+ (expt x 100) x 1)) + +(format t "No modulus: f(~a) = ~a~%" 10 (f 10)) +(format t "Modulus 13: f(~a) = ~a~%" 10 (let ((*modulus* 13)) (f 10))) diff --git a/Task/Modular-arithmetic/Rust/modular-arithmetic.rs b/Task/Modular-arithmetic/Rust/modular-arithmetic.rs new file mode 100644 index 0000000000..8995f8eb57 --- /dev/null +++ b/Task/Modular-arithmetic/Rust/modular-arithmetic.rs @@ -0,0 +1,177 @@ +use std::fmt; +use std::ops::{Add, Mul}; + +// Generic function f that works with any type T that implements the required traits +fn f(x: T) -> T +where + T: Copy + Add + From, + ModularInteger: From, + T: From, +{ + // Convert to ModularInteger to use the pow function, then convert back + let mod_int = ModularInteger::from(x); + let powered = mod_int.pow(100); + T::from(powered + ModularInteger::from(x) + ModularInteger::from(T::from(1))) +} + +// For the specific case of ModularInteger, we implement f directly +impl ModularInteger { + fn f_specific(self) -> Self { + self.pow(100) + self + ModularInteger::new(1, self.modulus) + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct ModularInteger { + value: i32, + modulus: i32, +} + +impl ModularInteger { + fn new(v: i32, m: i32) -> Self { + ModularInteger { + value: v.rem_euclid(m), // Use rem_euclid for proper modular arithmetic + modulus: m, + } + } + + fn get_value(&self) -> i32 { + self.value + } + + fn get_modulus(&self) -> i32 { + self.modulus + } + + fn validate_op(&self, rhs: &ModularInteger) -> Result<(), String> { + if self.modulus != rhs.modulus { + Err("Left-hand modulus does not match right-hand modulus.".to_string()) + } else { + Ok(()) + } + } + + fn pow(&self, mut exp: i32) -> Self { + if exp < 0 { + panic!("Power must not be negative."); + } + + let mut base = ModularInteger::new(1, self.modulus); + let mut current = *self; + + // Use fast exponentiation algorithm + while exp > 0 { + if exp % 2 == 1 { + base = base * current; + } + current = current * current; + exp /= 2; + } + base + } +} + +// Implement Add trait for ModularInteger + ModularInteger +impl Add for ModularInteger { + type Output = ModularInteger; + + fn add(self, rhs: ModularInteger) -> ModularInteger { + self.validate_op(&rhs).expect("Modulus mismatch"); + ModularInteger::new(self.value + rhs.value, self.modulus) + } +} + +// Implement Add trait for ModularInteger + i32 +impl Add for ModularInteger { + type Output = ModularInteger; + + fn add(self, rhs: i32) -> ModularInteger { + ModularInteger::new(self.value + rhs, self.modulus) + } +} + +// Implement Mul trait for ModularInteger * ModularInteger +impl Mul for ModularInteger { + type Output = ModularInteger; + + fn mul(self, rhs: ModularInteger) -> ModularInteger { + self.validate_op(&rhs).expect("Modulus mismatch"); + ModularInteger::new(self.value * rhs.value, self.modulus) + } +} + +// Implement Display trait for pretty printing +impl fmt::Display for ModularInteger { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ModularInteger({}, {})", self.value, self.modulus) + } +} + +// Conversion traits for the generic function +impl From for ModularInteger { + fn from(value: i32) -> Self { + ModularInteger::new(value, 13) // Default modulus for demonstration + } +} + +impl From for i32 { + fn from(mod_int: ModularInteger) -> Self { + mod_int.value + } +} + +fn main() { + let input = ModularInteger::new(10, 13); + let output = input.f_specific(); // Using the specific implementation for ModularInteger + println!("f({}) = {}", input, output); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_modular_integer_creation() { + let mi = ModularInteger::new(15, 13); + assert_eq!(mi.get_value(), 2); + assert_eq!(mi.get_modulus(), 13); + } + + #[test] + fn test_addition() { + let mi1 = ModularInteger::new(10, 13); + let mi2 = ModularInteger::new(5, 13); + let result = mi1 + mi2; + assert_eq!(result.get_value(), 2); // (10 + 5) % 13 = 2 + } + + #[test] + fn test_multiplication() { + let mi1 = ModularInteger::new(10, 13); + let mi2 = ModularInteger::new(5, 13); + let result = mi1 * mi2; + assert_eq!(result.get_value(), 11); // (10 * 5) % 13 = 11 + } + + #[test] + fn test_power() { + let mi = ModularInteger::new(2, 13); + let result = mi.pow(3); + assert_eq!(result.get_value(), 8); // 2^3 = 8 + } + + #[test] + #[should_panic(expected = "Modulus mismatch")] + fn test_mismatched_modulus() { + let mi1 = ModularInteger::new(10, 13); + let mi2 = ModularInteger::new(5, 17); + let _ = mi1 + mi2; + } + + #[test] + #[should_panic(expected = "Power must not be negative")] + fn test_negative_power() { + let mi = ModularInteger::new(2, 13); + mi.pow(-1); + } +} diff --git a/Task/Modular-arithmetic/Zig/modular-arithmetic.zig b/Task/Modular-arithmetic/Zig/modular-arithmetic.zig new file mode 100644 index 0000000000..22c6d4ffb0 --- /dev/null +++ b/Task/Modular-arithmetic/Zig/modular-arithmetic.zig @@ -0,0 +1,94 @@ +const std = @import("std"); +const print = std.debug.print; + +// Generic function f that works with any type T +fn f(comptime T: type, x: T) T { + const pow_result = pow(T, x, 100); + const temp = pow_result.add(x) catch unreachable; // Same modulus, won't error + return temp.addInt(1); +} + +// ModularInteger struct +const ModularInteger = struct { + value: i32, + modulus: i32, + + const Self = @This(); + + // Constructor + pub fn init(v: i32, m: i32) Self { + return Self{ + .value = @mod(v, m), + .modulus = m, + }; + } + + // Getter methods + pub fn getValue(self: Self) i32 { + return self.value; + } + + pub fn getModulus(self: Self) i32 { + return self.modulus; + } + + // Validation helper + fn validateOp(self: Self, rhs: Self) !void { + if (self.modulus != rhs.modulus) { + return error.ModulusMismatch; + } + } + + // Addition with another ModularInteger + pub fn add(self: Self, rhs: Self) !Self { + try self.validateOp(rhs); + return Self.init(self.value + rhs.value, self.modulus); + } + + // Addition with integer + pub fn addInt(self: Self, rhs: i32) Self { + return Self.init(self.value + rhs, self.modulus); + } + + // Multiplication with another ModularInteger + pub fn mul(self: Self, rhs: Self) !Self { + try self.validateOp(rhs); + return Self.init(self.value * rhs.value, self.modulus); + } + + // Format for printing + pub fn format( + self: Self, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + try writer.print("ModularInteger({}, {})", .{ self.value, self.modulus }); + } +}; + +// Power function for ModularInteger +fn pow(comptime T: type, base: T, power: i32) T { + if (power < 0) { + @panic("Power must not be negative."); + } + + var result = T.init(1, base.getModulus()); + var p = power; + while (p > 0) : (p -= 1) { + result = result.mul(base) catch unreachable; // Same modulus, won't error + } + return result; +} + +// Operator overloading using + syntax (though Zig doesn't have true operator overloading) +// We use methods instead, but you could create wrapper functions if desired + +pub fn main() !void { + const input = ModularInteger.init(10, 13); + const output = f(ModularInteger, input); + + print("f({}) = {}\n", .{ input, output }); +} diff --git a/Task/Modular-inverse/FutureBasic/modular-inverse.basic b/Task/Modular-inverse/FutureBasic/modular-inverse.basic new file mode 100644 index 0000000000..d7b33eefbe --- /dev/null +++ b/Task/Modular-inverse/FutureBasic/modular-inverse.basic @@ -0,0 +1,10 @@ +NSInteger local fn ModularInverse2( a as NSInteger, b as NSInteger ) + a %= b + for NSInteger x = 1 to b - 1 + if ( (a * x) % b == 1 ) then return x + next +end fn = -1 + +print fn ModularInverse2( 42, 2017 ) + +HandleEvents diff --git a/Task/Modular-inverse/Pluto/modular-inverse.pluto b/Task/Modular-inverse/Pluto/modular-inverse.pluto new file mode 100644 index 0000000000..dd25ad1e45 --- /dev/null +++ b/Task/Modular-inverse/Pluto/modular-inverse.pluto @@ -0,0 +1,5 @@ +local int = require "int" + +local a = 42 +local b = 2017 +print(int.modinv(a, b)) diff --git a/Task/Modular-inverse/Zig/modular-inverse.zig b/Task/Modular-inverse/Zig/modular-inverse.zig new file mode 100644 index 0000000000..ec1d91b5a3 --- /dev/null +++ b/Task/Modular-inverse/Zig/modular-inverse.zig @@ -0,0 +1,29 @@ +const std = @import("std"); + +fn mod_inv(a: isize, module: isize) isize { + var mn_0 = module; + var mn_1 = a; + var xy_0: isize = 0; + var xy_1: isize = 1; + + while (mn_1 != 0) { + const xy_0_temp = xy_1; + xy_1 = xy_0 - @divFloor(mn_0, mn_1) * xy_1; + xy_0 = xy_0_temp; + + const mn_0_temp = mn_1; + mn_1 = @rem(mn_0, mn_1); + mn_0 = mn_0_temp; + } + + while (xy_0 < 0) { + xy_0 += module; + } + + return xy_0; +} + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("{d}\n", .{mod_inv(42, 2017)}); +} diff --git a/Task/Monads-Writer-monad/Koka/monads-writer-monad.koka b/Task/Monads-Writer-monad/Koka/monads-writer-monad.koka new file mode 100644 index 0000000000..3780d1ec33 --- /dev/null +++ b/Task/Monads-Writer-monad/Koka/monads-writer-monad.koka @@ -0,0 +1,47 @@ +import std/num/float64 + +effect log + fun log(s: string): () + +fun write(s: string, f: float64): log float64 + log(s.pad-right(17) ++ ": " ++ f.show) + f + +fun root(d) write("Took square root", sqrt(d)) +fun half(d) write("Divided by two", d / 2.0) +fun add-one(d) write("Added one", d + 1.0) + +fun solution1() + var logv := [] + with handler + fun log(s) + logv := Cons(s, logv) + return(result) (result, logv.reverse) + write("Initial value", 5.0).root.add-one.half + +struct writer + wlog: list + v: v + +fun unit(s, v, ?show) + Writer([s.pad-right(17) ++ ": " ++ v.show], v) +fun bind(m, f) + val Writer(log, v') = f(m.v) + Writer(m.wlog ++ log, v') +fun root-v2(d) unit("Took square root", sqrt(d)) +fun half-v2(d) unit("Divided by two", d / 2.0) +fun add-one-v2(d) unit("Added one", d + 1.0) +fun solution2() + unit("Initial value", 5.0).bind(root-v2).bind(add-one-v2).bind(half-v2) + +fun main() + val (result, log) = solution1() + println("Version 1 (effect handlers):") + println("The Golden Ratio is " ++ result.show) + println("Derived as follows:") + println(log.map(" " ++ _).join("\n")) + val Writer(log2, result2) = solution2() + println("\nVersion 2 (monad):") + println("The Golden Ratio is " ++ result2.show) + println("Derived as follows:") + println(log2.map(" " ++ _).join("\n")) diff --git a/Task/Monte-Carlo-methods/APL/monte-carlo-methods.apl b/Task/Monte-Carlo-methods/APL/monte-carlo-methods.apl new file mode 100644 index 0000000000..c5963c28fe --- /dev/null +++ b/Task/Monte-Carlo-methods/APL/monte-carlo-methods.apl @@ -0,0 +1 @@ +mc_pi ← 4 × ⊢ ÷⍨ (+/1≥×⍨∘?+×⍨∘?)∘(/∘0) diff --git a/Task/Monte-Carlo-methods/C++/monte-carlo-methods.cpp b/Task/Monte-Carlo-methods/C++/monte-carlo-methods.cpp index 06bdaf0aaf..88435aba1a 100644 --- a/Task/Monte-Carlo-methods/C++/monte-carlo-methods.cpp +++ b/Task/Monte-Carlo-methods/C++/monte-carlo-methods.cpp @@ -1,21 +1,29 @@ -#include -#include -#include -#include +#include +#include -using namespace std; -int main(){ - int jmax=1000; // maximum value of HIT number. (Length of output file) - int imax=1000; // maximum value of random numbers for producing HITs. - double x,y; // Coordinates - int hit; // storage variable of number of HITs - srand(time(0)); - for (int j=0;j +#include + +[[nodiscard]] double monte_carlo_pi(std::size_t samples) noexcept { + std::mt19937_64 eng{ std::random_device{}() }; // consider using better seeding + std::uniform_real_distribution dst{}; + std::size_t hits = 0; + for (std::size_t i = 0; i < samples; ++i) { + if (std::hypot(dst(eng), dst(eng)) <= 1.0) ++hits; + } + return (static_cast(hits) / samples) * 4; +} + +int main() { + // using C++23's `std::println` in order to make printing `double`s accurate; + // this would also work with the classic `std::cout` + std::println("{}", monte_carlo_pi(10)); + std::println("{}", monte_carlo_pi(100)); + std::println("{}", monte_carlo_pi(1000)); + std::println("{}", monte_carlo_pi(10'000)); + std::println("{}", monte_carlo_pi(100'000)); + std::println("{}", monte_carlo_pi(1'000'000)); + std::println("{}", monte_carlo_pi(10'000'000)); + std::println("{}", monte_carlo_pi(100'000'000)); + std::println("{}", monte_carlo_pi(1'000'000'000)); } diff --git a/Task/Monte-Carlo-methods/DuckDB/monte-carlo-methods.duckdb b/Task/Monte-Carlo-methods/DuckDB/monte-carlo-methods.duckdb new file mode 100644 index 0000000000..aac96bec28 --- /dev/null +++ b/Task/Monte-Carlo-methods/DuckDB/monte-carlo-methods.duckdb @@ -0,0 +1,20 @@ +create or replace function mcPi(n) as ( + with recursive cte as ( + select -1 as i, 0 as count, NULL::DOUBLE as x, NULL::DOUBLE as y + union all + select i+1 as i, + count + if( x*x + y*y <= 1, 1, 0) as count, + random() as x, + random() as y + from cte + where i < n + ) + select last( 4 * count / n order by i) + from cte +); + +# Examples: + +select n, mcPi, format('{:.5f}', (mcPi - pi()) / pi()) as "relative error" +from (select n, mcPi(n) as mcPi + from (select unnest([100, 1000, 10000, 100000, 200000]) as n)); diff --git a/Task/Monte-Carlo-methods/FutureBasic/monte-carlo-methods.basic b/Task/Monte-Carlo-methods/FutureBasic/monte-carlo-methods.basic new file mode 100644 index 0000000000..91a23b917f --- /dev/null +++ b/Task/Monte-Carlo-methods/FutureBasic/monte-carlo-methods.basic @@ -0,0 +1,48 @@ +// Get PI using MonteCarlo method +// +// FutureBasic 7.0.34, August 2025 R.W + +// In my opinion, iteration below +// a hundred million won't even show anything +// remotely close to PI + +local fn MC_PI(rolls as double) as double + double i, inCircle, dist, MaxINT + double rndX, rndY, result + MaxINT = 2147483647.0 + inCircle = 0 + + for i = 1 TO rolls + // a square with a side of length 2 centered at 0 has + // x and y range of -1 to 1 + if i % 2 == 0 + rndX = (rnd(MaxINT)-1)/MaxINT + rndY = (rnd(MaxINT)-1)/MaxINT + else + rndX = (rnd(MaxINT)+1)/MaxINT + rndY = (rnd(MaxINT)+1)/MaxINT + end if + dist = rndX ^ 2 + rndY ^ 2 + if dist < 1.0 //circle with diameter of 2 has radius of 1 + inCircle++ + end if + next i + result = 4.0 * inCircle / rolls +end fn = result + + +window 1,@"Monte Carlo PI" +random +double pi2 + +pi2 = fn MC_PI(10^4) +print " 10,000 = ";pi2 + +pi2 = fn MC_PI(10^6) +print " 1,000,000 = ";pi2 + +pi2 = fn MC_PI(10^8) +print "100,000,000 = ";pi2 + + +HandleEvents diff --git a/Task/Monte-Carlo-methods/SETL/monte-carlo-methods.setl b/Task/Monte-Carlo-methods/SETL/monte-carlo-methods.setl new file mode 100644 index 0000000000..6eef64b350 --- /dev/null +++ b/Task/Monte-Carlo-methods/SETL/monte-carlo-methods.setl @@ -0,0 +1,21 @@ +program monte_carlo; + setrandom(0); + + loop for x in [5..8] do + throws := 10**x; + print(throws, " => ", calc_pi(throws)); + end loop; + + proc calc_pi(throws); + inside := 0; + loop init i := 0; while i { + data: [[f64; C]; R], +} + +impl Matrix { + fn new() -> Self { + Self { + data: [[0.0; C]; R], + } + } + + fn from_rows(values: &[&[f64]]) -> Self { + let mut matrix = Self::new(); + for (i, row) in values.iter().enumerate().take(R) { + for (j, &val) in row.iter().enumerate().take(C) { + matrix.data[i][j] = val; + } + } + matrix + } + + fn get(&self, row: usize, col: usize) -> f64 { + self.data[row][col] + } + + fn set(&mut self, row: usize, col: usize, value: f64) { + self.data[row][col] = value; + } + + fn get_row(&self, row: usize) -> [f64; C] { + self.data[row] + } + + fn set_row(&mut self, row: usize, values: &[f64; C]) { + self.data[row] = *values; + } + + fn multiply(&self, rhs: &Matrix) -> Matrix { + let mut result = Matrix::::new(); + for i in 0..R { + for j in 0..D { + for k in 0..C { + let prod = self.get(i, k) * rhs.get(k, j); + result.set(i, j, result.get(i, j) + prod); + } + } + } + result + } + + fn transpose(&self) -> Matrix { + let mut trans = Matrix::::new(); + for i in 0..R { + for j in 0..C { + trans.set(j, i, self.data[i][j]); + } + } + trans + } + + fn to_reduced_row_echelon_form(&mut self) { + let mut lead = 0; + for r in 0..R { + if C <= lead { + return; + } + let mut i = r; + + while self.get(i, lead) == 0.0 { + i += 1; + if R == i { + i = r; + lead += 1; + if C == lead { + return; + } + } + } + + // Swap rows + let temp = self.get_row(i); + self.set_row(i, &self.get_row(r)); + self.set_row(r, &temp); + + if self.get(r, lead) != 0.0 { + let div = self.get(r, lead); + for j in 0..C { + self.set(r, j, self.get(r, j) / div); + } + } + + for k in 0..R { + if k != r { + let mult = self.get(k, lead); + for j in 0..C { + let prod = self.get(r, j) * mult; + self.set(k, j, self.get(k, j) - prod); + } + } + } + + lead += 1; + } + } +} + +impl Matrix { + fn inverse(&self) -> Result, &'static str> { + if N == 0 { + return Err("Cannot invert empty matrix"); + } + + // Create augmented matrix using Vec for dynamic sizing + let mut aug = vec![vec![0.0; 2 * N]; N]; + + // Copy original matrix to left side of augmented matrix + for i in 0..N { + for j in 0..N { + aug[i][j] = self.get(i, j); + } + // Add identity matrix to right side + aug[i][i + N] = 1.0; + } + + // Perform Gauss-Jordan elimination + let mut lead = 0; + for r in 0..N { + if 2 * N <= lead { + return Err("Matrix is not invertible"); + } + let mut i = r; + + while aug[i][lead] == 0.0 { + i += 1; + if N == i { + i = r; + lead += 1; + if 2 * N == lead { + return Err("Matrix is not invertible"); + } + } + } + + // Swap rows + aug.swap(i, r); + + if aug[r][lead] != 0.0 { + let div = aug[r][lead]; + for j in 0..(2 * N) { + aug[r][j] /= div; + } + } + + for k in 0..N { + if k != r { + let mult = aug[k][lead]; + for j in 0..(2 * N) { + aug[k][j] -= aug[r][j] * mult; + } + } + } + + lead += 1; + } + + // Extract inverse from right side + let mut inv = Matrix::::new(); + for i in 0..N { + for j in 0..N { + inv.set(i, j, aug[i][j + N]); + } + } + Ok(inv) + } +} + +impl fmt::Display for Matrix { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + for i in 0..R { + write!(f, "[")?; + for j in 0..C { + if j > 0 { + write!(f, ", ")?; + } + write!(f, "{}", self.get(i, j))?; + } + writeln!(f, "]")?; + } + Ok(()) + } +} + +fn multiple_regression( + y: &[f64; C], + x: &Matrix, +) -> Result<[f64; R], &'static str> { + let mut tm = Matrix::<1, C>::new(); + for (i, &val) in y.iter().enumerate() { + tm.set(0, i, val); + } + + let cy = tm.transpose(); + let cx = x.transpose(); + let x_cx = x.multiply(&cx); + let inv = x_cx.inverse()?; + let result = inv.multiply(&x.multiply(&cy)).transpose(); + + Ok(result.get_row(0)) +} + +fn case1() -> Result<(), &'static str> { + let y = [1.0, 2.0, 3.0, 4.0, 5.0]; + let x = Matrix::<1, 5>::from_rows(&[&[2.0, 1.0, 3.0, 4.0, 5.0]]); + let v = multiple_regression(&y, &x)?; + println!("{:?}", v); + Ok(()) +} + +fn case2() -> Result<(), &'static str> { + let y = [3.0, 4.0, 5.0]; + let x = Matrix::<2, 3>::from_rows(&[ + &[1.0, 2.0, 1.0], + &[1.0, 1.0, 2.0], + ]); + let v = multiple_regression(&y, &x)?; + println!("{:?}", v); + Ok(()) +} + +fn case3() -> Result<(), &'static str> { + let y = [ + 52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, + 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46, + ]; + let a = [ + 1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, + 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83, + ]; + + let mut x = Matrix::<3, 15>::new(); + + // First row: all ones + for i in 0..15 { + x.set(0, i, 1.0); + } + + // Second row: values from array 'a' + for (i, &val) in a.iter().enumerate() { + x.set(1, i, val); + } + + // Third row: squared values from array 'a' + for (i, &val) in a.iter().enumerate() { + x.set(2, i, val * val); + } + + let v = multiple_regression(&y, &x)?; + println!("{:?}", v); + Ok(()) +} + +fn main() -> Result<(), &'static str> { + case1()?; + case2()?; + case3()?; + Ok(()) +} diff --git a/Task/Multiplication-tables/Agena/multiplication-tables.agena b/Task/Multiplication-tables/Agena/multiplication-tables.agena index 2127271ec5..d8231d1269 100644 --- a/Task/Multiplication-tables/Agena/multiplication-tables.agena +++ b/Task/Multiplication-tables/Agena/multiplication-tables.agena @@ -1,5 +1,4 @@ -scope - # print a school style multiplication table +scope # print a school style multiplication table # NB: print outputs a newline at the end, write and printf do not write( " " ); for i to 12 do printf( " %3d", i ) od; @@ -11,4 +10,4 @@ scope for j from i to 12 do printf( " %3d", i * j ) od; od; print() -epocs +end diff --git a/Task/Multiplication-tables/Pluto/multiplication-tables.pluto b/Task/Multiplication-tables/Pluto/multiplication-tables.pluto new file mode 100644 index 0000000000..7d210c9190 --- /dev/null +++ b/Task/Multiplication-tables/Pluto/multiplication-tables.pluto @@ -0,0 +1,13 @@ +do -- print a school style multiplication table + local fmt = require( "fmt" ) -- RC formattng library + io.write( " " ) + for i = 1, 12 do fmt.write( " %3d", i ) end + io.write( "\n +" ) + for _ = 1, 12 do io.write( "----" ) end + for i = 1, 12 do + fmt.write( "\n%3d|", i ) + for _ = 1, i - 1 do io.write( " " ) end + for j = i, 12 do fmt.write( " %3d", i * j ) end + end + io.write( "\n" ) +end diff --git a/Task/Multiplication-tables/TAV/multiplication-tables.tav b/Task/Multiplication-tables/TAV/multiplication-tables.tav new file mode 100644 index 0000000000..1131ae1241 --- /dev/null +++ b/Task/Multiplication-tables/TAV/multiplication-tables.tav @@ -0,0 +1,10 @@ +main (parms):+ + am =: string parms[1] as integer else 12 + ?# i =: from 1 upto am + print format '%4d;' i nonl + ?# j =: from 1 upto am + ? j >= i + print format '%4d;' i*j nonl + | + print ' ' nonl + print '' diff --git a/Task/Multiplicative-order/F-Sharp/multiplicative-order.fs b/Task/Multiplicative-order/F-Sharp/multiplicative-order.fs new file mode 100644 index 0000000000..834861e1ec --- /dev/null +++ b/Task/Multiplicative-order/F-Sharp/multiplicative-order.fs @@ -0,0 +1,8 @@ +// Multiplicative order. Nigel Galloway: August 5th., 2025 +let lcm(n:bigint seq)=MathNet.Numerics.Euclid.LeastCommonMultiple(n|>Array.ofSeq) +let factors(n:bigint)=Open.Numeric.Primes.Extensions.PrimeExtensions.PrimeFactors &n|>Seq.countBy id|>Seq.skip 1 +let rec fN i g e l=match i with i when i=1I->g |i->fN (expMod i e l) (g*e) e l +let localOrder n g l=factors(g)|>Seq.fold(fun r (q,e)->fN (expMod n (g/q**e) l) r q l) 1I +let order n g=factors(g)|>Seq.map(fun(p,k)->localOrder n ((p-1I)*p**(k-1)) (p**k))|>lcm +let tests=[(37I,1000I);(10I**100+1I,7919I);(10I**1000+1I,15485863I);(10I**10000-1I,22801763489I)] +tests|>List.iter(fun(n,g)->printfn "%A" (order n g)) diff --git a/Task/Munchausen-numbers/00-META.yaml b/Task/Munchausen-numbers/00-META.yaml index a5de31607a..1e2f7da316 100644 --- a/Task/Munchausen-numbers/00-META.yaml +++ b/Task/Munchausen-numbers/00-META.yaml @@ -1,2 +1,3 @@ --- from: http://rosettacode.org/wiki/Munchausen_numbers +note: Numbers diff --git a/Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark b/Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark new file mode 100644 index 0000000000..0e15253091 --- /dev/null +++ b/Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark @@ -0,0 +1,30 @@ +(import std.List) + +(let self-exponent (fun (x n acc) + (if (> n 0) + (self-exponent x (- n 1) (* x acc)) + acc))) + +(let cache (list:map (list:iota 0 10) (fun (x) (if (= x 0) 0 (self-exponent x x 1))))) + +(let is_munchausen (fun (number) { + (mut total 0) + (mut n number) + (mut continue true) + + (while (and (> n 0) continue) { + (let digit (mod n 10)) + (set total (+ total (@ cache digit))) + (if (> total number) + (set continue false) + (set n (math:floor (/ n 10)))) }) + + (= total number) })) + +(let max_val 5000) + +(mut i 1) +(while (< i max_val) { + (if (is_munchausen i) + (print i)) + (set i (+ 1 i)) }) diff --git a/Task/Munchausen-numbers/R/munchausen-numbers.r b/Task/Munchausen-numbers/R/munchausen-numbers.r index 8079ca1175..b3b8afcb33 100644 --- a/Task/Munchausen-numbers/R/munchausen-numbers.r +++ b/Task/Munchausen-numbers/R/munchausen-numbers.r @@ -1,9 +1,4 @@ -exp_digsum <- function(n){ - if(n>9){ - return((n%%10)^(n%%10)+exp_digsum(n%/%10)) - } - else return(n^n) -} +exp_digsum <- function(n) ifelse(n>9, (n%%10)^(n%%10)+exp_digsum(n%/%10), n^n) for(i in 1:5000){ if(exp_digsum(i)==i) print(i) diff --git a/Task/Munching-squares/EasyLang/munching-squares.easy b/Task/Munching-squares/EasyLang/munching-squares.easy index 78ae2c25f5..e038dc638c 100644 --- a/Task/Munching-squares/EasyLang/munching-squares.easy +++ b/Task/Munching-squares/EasyLang/munching-squares.easy @@ -1,8 +1,8 @@ sc = 100 / 64 for x = 0 to 63 for y = 0 to 63 - h = bitand bitxor x y 63 / 63 + h = 100 / 63 * bitand (bitxor x y) 63 gcolor3 h h h - grect x * sc y * sc sc + 0.1 sc + 0.1 + grect x * sc, y * sc, sc + 0.1, sc + 0.1 . . diff --git a/Task/Munching-squares/YAMLScript/munching-squares.ys b/Task/Munching-squares/YAMLScript/munching-squares.ys new file mode 100644 index 0000000000..7fbf2c26b9 --- /dev/null +++ b/Task/Munching-squares/YAMLScript/munching-squares.ys @@ -0,0 +1,14 @@ +!YS-v0 + +n =: 16 +loop i 0: + shell: 'clear' + each y range(n): + each x range(n): + print: + if bit-xor(x y) < i: + + "█" " " + print: "\n" + flush: + sleep: 0.15 + recur: i.++ % n.++ diff --git a/Task/Musical-scale/Java/musical-scale.java b/Task/Musical-scale/Java/musical-scale.java index 8ee6d59a24..625ef7d219 100644 --- a/Task/Musical-scale/Java/musical-scale.java +++ b/Task/Musical-scale/Java/musical-scale.java @@ -57,7 +57,7 @@ public final class MusicalScale { private static SourceDataLine sourceDataLine; - private static float SAMPLE_RATE = 8_000.0F; + private static final float SAMPLE_RATE = 8_000.0F; private static final int BYTE_OFFSET = 0; } diff --git a/Task/Mutex/FutureBasic/mutex.basic b/Task/Mutex/FutureBasic/mutex.basic new file mode 100644 index 0000000000..20bb7680c4 --- /dev/null +++ b/Task/Mutex/FutureBasic/mutex.basic @@ -0,0 +1,19 @@ +include "NSLog.incl" + +void local fn DoIt + LockRef m = fn LockInit + + LockingLock( m ) + + if ( fn LockTry( m ) ) + NSLog(@"lock acquired") // acquire a lock -- does not block if not acquired + else + NSLog(@"already locked, does not block") + end if + + LockingUnlock( m ) +end fn + +fn DoIt + +HandleEvents diff --git a/Task/Mutual-recursion/Pluto/mutual-recursion.pluto b/Task/Mutual-recursion/Pluto/mutual-recursion.pluto new file mode 100644 index 0000000000..4a557184fc --- /dev/null +++ b/Task/Mutual-recursion/Pluto/mutual-recursion.pluto @@ -0,0 +1,10 @@ +function F(n) + return n==0?1:n-M(F(n-1)) +end + +function M(n) + return n==0?0:n-F(M(n-1)) +end + +print(range(1,12):mapped(F):unpack()) +print(range(1,12):mapped(M):unpack()) diff --git a/Task/N-queens-problem/ArkScript/n-queens-problem.ark b/Task/N-queens-problem/ArkScript/n-queens-problem.ark new file mode 100644 index 0000000000..03e9c69265 --- /dev/null +++ b/Task/N-queens-problem/ArkScript/n-queens-problem.ark @@ -0,0 +1,32 @@ +(let queenPuzzle (fun (rows columns) + (if (<= rows 0) + [[]] + (addQueen (- rows 1) columns)))) + +(let addQueen (fun (newRow columns) { + (mut newSolutions []) + (let prev (queenPuzzle newRow columns)) + + (mut i 0) + (while (< i (len prev)) { + (let solution (@ prev i)) + (mut newColumn 0) + (while (< newColumn columns) { + (if (not (hasConflict newRow newColumn solution)) (append! newSolutions (append solution newColumn))) + (set newColumn (+ newColumn 1)) }) + + (set i (+ i 1)) }) + + newSolutions })) + +(let hasConflict (fun (newRow newColumn solution) { + (mut i 0) + (mut conflict false) + (while (and (< i newRow) (not conflict)) { + (if (or (= (@ solution i) newColumn) (= (+ (@ solution i) i) (+ newColumn newRow)) (= (- (@ solution i) i) (- newColumn newRow))) + (set conflict true)) + (set i (+ i 1)) }) + + conflict })) + +(print (queenPuzzle 4 4)) diff --git a/Task/Named-parameters/FutureBasic/named-parameters.basic b/Task/Named-parameters/FutureBasic/named-parameters.basic new file mode 100644 index 0000000000..7d42f183a2 --- /dev/null +++ b/Task/Named-parameters/FutureBasic/named-parameters.basic @@ -0,0 +1,9 @@ +include "NSLog.incl" + +CFStringRef local fn WelcomeToFutureBasic( person as CFStringRef, location as CFStringRef ) + return fn StringWithFormat( @"Welcome %@! Glad you could join us from %@.", person, location ) +end fn = NULL + +NSLog( @"%@", fn WelcomeToFutureBasic( @"John Codemeister", @"Hawaii" ) ) + +HandleEvents diff --git a/Task/Named-parameters/Icon/named-parameters.icon b/Task/Named-parameters/Icon/named-parameters.icon index 76bd6f5f7b..837e6f9bef 100644 --- a/Task/Named-parameters/Icon/named-parameters.icon +++ b/Task/Named-parameters/Icon/named-parameters.icon @@ -10,7 +10,7 @@ procedure testproc(A[]) #: demo to test named parameters while a := get(A) do # implement named parameters here (( a ? (v := =!["x","y","z"], =":=") | # valid parameter name? - stop("No parameter ",a)) & # . . no + stop(&output,"No parameter ",a)) & # . . no ((variable(a[1:-2]) := get(A)) | # assign runerr(205,a))) # . . problem diff --git a/Task/Named-parameters/Pluto/named-parameters.pluto b/Task/Named-parameters/Pluto/named-parameters.pluto new file mode 100644 index 0000000000..b119411e0b --- /dev/null +++ b/Task/Named-parameters/Pluto/named-parameters.pluto @@ -0,0 +1,7 @@ +local function print_name(forename, surname = "Trump"). + print($"{forename} {surname}") +end + +print_name(forename = "Abraham", surname = "Lincoln") +print_name(surname = "Trump", forename = "Donald") +print_name(forename = "Donald") diff --git a/Task/Naming-conventions/Ada/naming-conventions-1.ada b/Task/Naming-conventions/Ada/naming-conventions-1.ada new file mode 100644 index 0000000000..d0b1c4574d --- /dev/null +++ b/Task/Naming-conventions/Ada/naming-conventions-1.ada @@ -0,0 +1,8 @@ +function Max (Left, Right : Integer) return Integer is +begin + if Left < Right then + return Right; + else + return Left; + end if; +end Max; diff --git a/Task/Naming-conventions/Ada/naming-conventions-2.ada b/Task/Naming-conventions/Ada/naming-conventions-2.ada new file mode 100644 index 0000000000..0cd2b08010 --- /dev/null +++ b/Task/Naming-conventions/Ada/naming-conventions-2.ada @@ -0,0 +1,3 @@ +package My_Package is +... +end My_Package; diff --git a/Task/Naming-conventions/Ada/naming-conventions-3.ada b/Task/Naming-conventions/Ada/naming-conventions-3.ada new file mode 100644 index 0000000000..5f69399c3e --- /dev/null +++ b/Task/Naming-conventions/Ada/naming-conventions-3.ada @@ -0,0 +1,3 @@ +package body My_Package is +... +end My_Package; diff --git a/Task/Narcissistic-decimal-number/ALGOL-68/narcissistic-decimal-number.alg b/Task/Narcissistic-decimal-number/ALGOL-68/narcissistic-decimal-number.alg index 5ec6c51a24..3a614eaa17 100644 --- a/Task/Narcissistic-decimal-number/ALGOL-68/narcissistic-decimal-number.alg +++ b/Task/Narcissistic-decimal-number/ALGOL-68/narcissistic-decimal-number.alg @@ -1,33 +1,59 @@ -# find some narcissistic decimal numbers # +# print the first 25 narcissistic numbers # +BEGIN -# returns TRUE if n is narcissitic, FALSE otherwise; n should be >= 0 # -PROC is narcissistic = ( INT n )BOOL: - BEGIN - # count the number of digits in n # - INT digits := 0; - INT number := n; - WHILE digits +:= 1; - number OVERAB 10; - number > 0 - DO SKIP OD; - # sum the digits'th powers of the digits of n # - INT sum := 0; - number := n; - TO digits DO - sum +:= ( number MOD 10 ) ^ digits; - number OVERAB 10 - OD; - # n is narcissistic if n = sum # - n = sum - END # is narcissistic # ; + [ 0 : 9 ]INT power := ( []INT( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ) )[ AT 0 ]; + INT count := 0; + INT candidate := 0; + INT prev digits := 0; + INT digits := 0; -# print the first 25 narcissistic numbers # -INT count := 0; -FOR n FROM 0 WHILE count < 25 DO - IF is narcissistic( n ) THEN - # found another narcissistic number # - print( ( " ", whole( n, 0 ) ) ); - count +:= 1 - FI -OD; -print( ( newline ) ) + FOR d9 FROM 0 TO 2 DO + IF d9 > 0 AND digits < 9 THEN digits := 9 FI; + FOR d8 FROM 0 TO 9 DO + IF d8 > 0 AND digits < 8 THEN digits := 8 FI; + FOR d7 FROM 0 TO 9 DO + IF d7 > 0 AND digits < 7 THEN digits := 7 FI; + FOR d6 FROM 0 TO 9 DO + IF d6 > 0 AND digits < 6 THEN digits := 6 FI; + FOR d5 FROM 0 TO 9 DO + IF d5 > 0 AND digits < 5 THEN digits := 5 FI; + FOR d4 FROM 0 TO 9 DO + IF d4 > 0 AND digits < 4 THEN digits := 4 FI; + FOR d3 FROM 0 TO 9 DO + IF d3 > 0 AND digits < 3 THEN digits := 3 FI; + FOR d2 FROM 0 TO 9 DO + IF d2 > 0 AND digits < 2 THEN digits := 2 FI; + FOR d1 FROM 0 TO 9 DO + + IF prev digits /= digits THEN + # number of digits has increased - increase the powers # + prev digits := digits; + FOR i FROM 2 TO 9 DO power[ i ] *:= i OD + FI; + + # sum the digits'th powers of the # + # digits of candidate # + INT sum = power[ d1 ] + power[ d2 ] + power[ d3 ] + + power[ d4 ] + power[ d5 ] + power[ d6 ] + + power[ d7 ] + power[ d8 ] + power[ d9 ] + ; + IF candidate = sum THEN + # found another narcissistic decimal number # + print( ( " ", whole( candidate, 0 ) ) ); + count +:= + 1; + IF count >= 25 THEN GOTO done FI + FI; + candidate +:= 1 + OD + OD + OD + OD + OD + OD + OD + OD + OD; +done: + print( ( newline ) ) + +END diff --git a/Task/Narcissistic-decimal-number/Agena/narcissistic-decimal-number.agena b/Task/Narcissistic-decimal-number/Agena/narcissistic-decimal-number.agena index 9f621e8606..b744951649 100644 --- a/Task/Narcissistic-decimal-number/Agena/narcissistic-decimal-number.agena +++ b/Task/Narcissistic-decimal-number/Agena/narcissistic-decimal-number.agena @@ -24,12 +24,12 @@ scope if d3 > 0 and digits < 3 then digits := 3 fi; for d2 from 0 to 9 while count < maxCount do if d2 > 0 and digits < 2 then digits := 2 fi; + if prevDigits <> digits then + # number of digits has increased - increase the powers + prevDigits := digits; + for i from 2 to 9 do mul power[ i + 1 ], i od; + fi; for d1 from 0 to 9 do - if prevDigits <> digits then - # number of digits has increased - increase the powers - prevDigits := digits; - for i from 2 to 9 do mul power[ i + 1 ], i od; - fi; # sum the digits'th powers of the digits of candidate local sum := power[ d1 + 1 ] + power[ d2 + 1 ] + power[ d3 + 1 ] + power[ d4 + 1 ] + power[ d5 + 1 ] + power[ d6 + 1 ] diff --git a/Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number.lua b/Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-1.lua similarity index 100% rename from Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number.lua rename to Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-1.lua diff --git a/Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-2.lua b/Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-2.lua new file mode 100644 index 0000000000..2ca560eb19 --- /dev/null +++ b/Task/Narcissistic-decimal-number/Lua/narcissistic-decimal-number-2.lua @@ -0,0 +1,59 @@ +do + -- print the first 25 narcissistic numbers + + local power = { [0] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } + local count = 0 + local candidate = 0 + local prevDigits = 0 + local digits = 0 + + for d9 = 0, 2 do + if d9 > 0 and digits < 9 then digits = 9 end + for d8 = 0, 9 do + if d8 > 0 and digits < 8 then digits = 8 end + for d7 = 0, 9 do + if d7 > 0 and digits < 7 then digits = 7 end + for d6 = 0, 9 do + if d6 > 0 and digits < 6 then digits = 6 end + for d5 = 0, 9 do + if d5 > 0 and digits < 5 then digits = 5 end + for d4 = 0, 9 do + if d4 > 0 and digits < 4 then digits = 4 end + for d3 = 0, 9 do + if d3 > 0 and digits < 3 then digits = 3 end + for d2 = 0, 9 do + if d2 > 0 and digits < 2 then digits = 2 end + for d1 = 0, 9 do + + if prevDigits ~= digits then + -- number of digits has increased + -- - increase the powers + prevDigits = digits + for i = 2, 9 do power[ i ] = power[ i ] * i end + end + + -- sum the digits'th powers of the + -- digits of candidate + local sum = power[ d1 ] + power[ d2 ] + power[ d3 ] + + power[ d4 ] + power[ d5 ] + power[ d6 ] + + power[ d7 ] + power[ d8 ] + power[ d9 ] + if candidate == sum then + -- found another narcissistic + -- decimal number + io.write( " ", candidate ) + count = count + 1 + if count >= 25 then io.write( "\n" ); os.exit() end + end + candidate = candidate + 1 + end + end + end + end + end + end + end + end + end + io.write( "\n" ) + +end diff --git a/Task/Narcissistic-decimal-number/Pluto/narcissistic-decimal-number.pluto b/Task/Narcissistic-decimal-number/Pluto/narcissistic-decimal-number.pluto new file mode 100644 index 0000000000..cb78449247 --- /dev/null +++ b/Task/Narcissistic-decimal-number/Pluto/narcissistic-decimal-number.pluto @@ -0,0 +1,50 @@ +do -- print the first 25 narcissistic numbers + + local power = { [0] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } + local count, candidate, prevDigits, digits = 0, 0, 0, 0 + + for d9 = 0, 2 do + if d9 > 0 and digits < 9 then digits = 9 end + for d8 = 0, 9 do + if d8 > 0 and digits < 8 then digits = 8 end + for d7 = 0, 9 do + if d7 > 0 and digits < 7 then digits = 7 end + for d6 = 0, 9 do + if d6 > 0 and digits < 6 then digits = 6 end + for d5 = 0, 9 do + if d5 > 0 and digits < 5 then digits = 5 end + for d4 = 0, 9 do + if d4 > 0 and digits < 4 then digits = 4 end + for d3 = 0, 9 do + if d3 > 0 and digits < 3 then digits = 3 end + for d2 = 0, 9 do + if d2 > 0 and digits < 2 then digits = 2 end + if prevDigits != digits then + -- number of digits has increased - increase the powers + prevDigits = digits + for i = 2, 9 do power[ i ] *= i end + end + + for d1 = 0, 9 do + -- sum the digits'th powers of the digits of candidate + local sum = power[ d1 ] + power[ d2 ] + power[ d3 ] + + power[ d4 ] + power[ d5 ] + power[ d6 ] + + power[ d7 ] + power[ d8 ] + power[ d9 ] + if candidate == sum then + -- found another narcissistic decimal number + io.write( " ", candidate ) + ++ count + if count >= 25 then break 9 end + end + ++ candidate + end + end + end + end + end + end + end + end + end + io.write( "\n" ) +end diff --git a/Task/Nested-function/DuckDB/nested-function.duckdb b/Task/Nested-function/DuckDB/nested-function.duckdb new file mode 100644 index 0000000000..1a76a5257d --- /dev/null +++ b/Task/Nested-function/DuckDB/nested-function.duckdb @@ -0,0 +1,12 @@ +create or replace function MakeList(sep, n) as ( + select list_transform( range(1, n+1), + -- An inner function: + i -> format('{}{} {}', + i, + sep, + if(i=1, 'first', if (i=2, 'second', if (i=3, 'third' , '...')))) ) + .array_to_string(chr(10)) +); + +.mode list +select MakeList('.', 3) ; diff --git a/Task/Nested-templated-data/Pluto/nested-templated-data.pluto b/Task/Nested-templated-data/Pluto/nested-templated-data.pluto new file mode 100644 index 0000000000..cf73411179 --- /dev/null +++ b/Task/Nested-templated-data/Pluto/nested-templated-data.pluto @@ -0,0 +1,20 @@ +require "map" +local fmt = require "fmt" -- v1.0.1 or higher + +local function with_payload(template, payload, used) + return template:mapped( |item| -> do + if type(item) == "table" then + return with_payload(item, payload, used) + else + used:insert(item) + return $"'{payload[item + 1]}'" + end + end) +end + +local p = {"Payload#0", "Payload#1", "Payload#2", "Payload#3", "Payload#4", "Payload#5", "Payload#6"} +local t = {{{1, 2}, {3, 4, 1}, 5}} +local used = {} +fmt.lprint(with_payload(t, p, used)) +local unused = set.of(range(0, 6):unpack()):except(set.of(used:unpack())) +fmt.print("\nThe unused payloads have indices of %s.", unused) diff --git a/Task/Next-highest-int-from-digits/YAMLScript/next-highest-int-from-digits.ys b/Task/Next-highest-int-from-digits/YAMLScript/next-highest-int-from-digits.ys new file mode 100644 index 0000000000..6586cafa05 --- /dev/null +++ b/Task/Next-highest-int-from-digits/YAMLScript/next-highest-int-from-digits.ys @@ -0,0 +1,44 @@ +!YS-v0 + +defn main(n=nil): + if n: + say: next-highest-int-from-digits(n) + test: + +defn next-highest-int-from-digits(n): + ds =: n:digits + i =: + sub ds.#.--: + count: + ? for [i range(ds.#.-- 0 -1) + :while (ds.nth(i.--) >= ds.$i)] + : 1 + if i > 0: + then: + a c =: ds.split-at(i) + a b =: a.split-at(a.#.--) + c d =: c:sort.split-with(\(b.0 >= _)) + d e =: d.split-at(1) + e =: sort(b + c + e) + read-string: concat(a d e).map(str):join + else: 0 + +# Test code: +defn test(): + tests =:: + 0: 0 + 9: 0 + 12: 21 + 21: 0 + 12453: 12534 + 738440: 740348 + 45072010: 45072100 + 95322020: 95322200 + 9589776899767587796600: 9589776899767587900667 + + reduce-kv _ nil tests: + fn(_ k v): + n =: next-highest-int-from-digits(k) + if n == v: + say: "PASS - $k" + say: "FAIL - $n != $v" diff --git a/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f b/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f index 616030f1fa..6e5a6bddd3 100644 --- a/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f +++ b/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f @@ -18,10 +18,11 @@ MODULE Conversion END DO END FUNCTION ToDecimal - FUNCTION ToBase(base, number) + FUNCTION ToBase(base, number_in) CHARACTER(31) :: ToBase - INTEGER :: base, number, i, rem + INTEGER :: base, number_in, number, i, rem + number = number_in ToBase = " " DO i = 31, 1, -1 IF(number < base) THEN diff --git a/Task/Non-decimal-radices-Convert/Pluto/non-decimal-radices-convert.pluto b/Task/Non-decimal-radices-Convert/Pluto/non-decimal-radices-convert.pluto new file mode 100644 index 0000000000..648b0ec2c6 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Pluto/non-decimal-radices-convert.pluto @@ -0,0 +1,7 @@ +local fmt = require "fmt" + +print(fmt.itoa(26, 16)) +print(tonumber("1a", 16)) +print() +print(fmt.itoa(9124, 36)) +print(tonumber("71g", 36)) diff --git a/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx b/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx index fc32acaa42..9390008d84 100644 --- a/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx +++ b/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx @@ -1,15 +1,15 @@ +-- 28 Jul 2025 include Settings - -say 'NON-DECIMAL RADICES - 11 Mar 2025' -say version -say arg xx if xx = '' then xx = 255 + +say 'NON-DECIMAL RADICES CONVERT' +say version +say do n = 2 to 36 - say xx 'decimal =' Basenn(xx,n) 'base' n '=' Base10(Basenn(xx,n),n) 'decimal' + say xx 'decimal =' BaseNN(xx,n) 'base' n '=' Base10(BaseNN(xx,n),n) 'decimal' end exit -include Functions -include Abend +include Math diff --git a/Task/Nth-root/DuckDB/nth-root.duckdb b/Task/Nth-root/DuckDB/nth-root.duckdb new file mode 100644 index 0000000000..5da06426f1 --- /dev/null +++ b/Task/Nth-root/DuckDB/nth-root.duckdb @@ -0,0 +1,20 @@ +# Newton's method, assuming a > 0 and n > 0 +create or replace function nth_root(a,n) as ( + with recursive cte as ( + select 0 as ix, a::DOUBLE as x, (a-1.0)::DOUBLE as xprime + union all + select ix+1 as ix, + ((n - 1) * x / n ) + (a / (n * x ** (n-1))) as x, + x as xprime + from cte + where @(x - xprime) > 1e-15 + and ix<10 + ) + select last(x order by ix) + from cte +); + +select n, + 5.0 ^ (1 / cast(n as double)) as builtin, + nth_root(5.0, n) as nth_root +from unnest( [1,3,5,10,1000,10000] ) _(n); diff --git a/Task/Nth/DuckDB/nth.duckdb b/Task/Nth/DuckDB/nth.duckdb new file mode 100644 index 0000000000..10ed9b2bb7 --- /dev/null +++ b/Task/Nth/DuckDB/nth.duckdb @@ -0,0 +1,26 @@ +# ordinalize an integer, whether positive or negative +create or replace function ordinalize(x) as ( + x::VARCHAR + || '''' + || if( 11 <= (abs(x) % 100) and (abs(x) % 100) <= 13, 'th', + case abs(x) % 10 + when 1 then 'st' + when 2 then 'nd' + when 3 then 'rd' + else 'th' + end) +); + +create or replace function task(lst) as ( + select list_transform(lst, ix -> ordinalize(ix)) + .array_to_string(' ') +); + +## Examples +.header off +.maxwidth 300 +.mode list +select task(range(-5, -1)); +select task(range(0,26)); +select task(range(250,266)); +select task(range(1000,1026)); diff --git a/Task/Null-object/ArkScript/null-object.ark b/Task/Null-object/ArkScript/null-object.ark new file mode 100644 index 0000000000..873b62497f --- /dev/null +++ b/Task/Null-object/ArkScript/null-object.ark @@ -0,0 +1,5 @@ +(let a nil) +(let b 5) + +(print (nil? a)) +(print (nil? b)) diff --git a/Task/Null-object/Tcl/null-object-2.tcl b/Task/Null-object/Tcl/null-object-2.tcl index 1f86652b01..9094139b60 100644 --- a/Task/Null-object/Tcl/null-object-2.tcl +++ b/Task/Null-object/Tcl/null-object-2.tcl @@ -1,3 +1,7 @@ -if {![info exist nullvar]} ... -if {![info exists arr(nullval)]} ... -if {![dict exists $dic nullval]} ... +set p "" +set q {} +set n 0 +puts [expr {$p eq {}? true : false}] +puts [expr {$p eq ""? true : false}] +puts [expr {$p eq $q? true : false}] +puts [expr {$p eq 0? true : false}] diff --git a/Task/Null-object/Tcl/null-object-3.tcl b/Task/Null-object/Tcl/null-object-3.tcl new file mode 100644 index 0000000000..f04c56e61c --- /dev/null +++ b/Task/Null-object/Tcl/null-object-3.tcl @@ -0,0 +1,2 @@ + if {4.5} {...} ; # true + if {4.5 - 4.5} {...} ; # false diff --git a/Task/Null-object/Tcl/null-object-4.tcl b/Task/Null-object/Tcl/null-object-4.tcl new file mode 100644 index 0000000000..1ddf6d2639 --- /dev/null +++ b/Task/Null-object/Tcl/null-object-4.tcl @@ -0,0 +1,5 @@ +if {![info exist nullvar]} ... + +if {![info exists arr(nullval)]} ... + +if {![dict exists $dic nullval]} ... diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature-1.py b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature-1.py index a7c41e93f6..b5f99eb3f6 100644 --- a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature-1.py +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature-1.py @@ -1,97 +1,107 @@ -from numpy import * +from __future__ import print_function +from __future__ import division + +from numpy import array, exp, concatenate, cos, pi + + +def Legendre(n, x): + """Recursive generation of the Legendre polynomial of order n.""" + x = array(x) + if n == 0: + return x * 0 + 1.0 + elif n == 1: + return x + else: + return ( + (2.0 * n - 1.0) * x * Legendre(n - 1, x) - (n - 1) * Legendre(n - 2, x) + ) / n + + +def DLegendre(n, x): + """Derivative of the Legendre polynomials.""" + x = array(x) + if n == 0: + return x * 0 + elif n == 1: + return x * 0 + 1.0 + else: + return (n / (x**2 - 1.0)) * (x * Legendre(n, x) - Legendre(n - 1, x)) + + +def LegendreRoots(polyorder, tolerance=1e-20): + """Roots of the polynomial obtained using Newton-Raphson method.""" + if polyorder < 2: + err = 1 # bad polyorder no roots can be found + else: + roots = [] + # The polynomials are alternately even and odd functions. So we evaluate only half the number of roots. + for i in range(1, int(polyorder / 2 + 1)): + x = cos(pi * (i - 0.25) / (polyorder + 0.5)) + error = 10 * tolerance + iters = 0 + while (error > tolerance) and (iters < 1000): + dx = -Legendre(polyorder, x) / DLegendre(polyorder, x) + x = x + dx + iters = iters + 1 + error = abs(dx) + roots.append(x) + # Use symmetry to get the other roots + roots = array(roots) + if polyorder % 2 == 0: + roots = concatenate((-1.0 * roots, roots[::-1])) + else: + roots = concatenate((-1.0 * roots, [0.0], roots[::-1])) + err = 0 # successfully determined roots + return [roots, err] -################################################################## -# Recursive generation of the Legendre polynomial of order n -def Legendre(n,x): - x=array(x) - if (n==0): - return x*0+1.0 - elif (n==1): - return x - else: - return ((2.0*n-1.0)*x*Legendre(n-1,x)-(n-1)*Legendre(n-2,x))/n -################################################################## -# Derivative of the Legendre polynomials -def DLegendre(n,x): - x=array(x) - if (n==0): - return x*0 - elif (n==1): - return x*0+1.0 - else: - return (n/(x**2-1.0))*(x*Legendre(n,x)-Legendre(n-1,x)) -################################################################## -# Roots of the polynomial obtained using Newton-Raphson method -def LegendreRoots(polyorder,tolerance=1e-20): - if polyorder<2: - err=1 # bad polyorder no roots can be found - else: - roots=[] - # The polynomials are alternately even and odd functions. So we evaluate only half the number of roots. - for i in range(1,int(polyorder)/2 +1): - x=cos(pi*(i-0.25)/(polyorder+0.5)) - error=10*tolerance - iters=0 - while (error>tolerance) and (iters<1000): - dx=-Legendre(polyorder,x)/DLegendre(polyorder,x) - x=x+dx - iters=iters+1 - error=abs(dx) - roots.append(x) - # Use symmetry to get the other roots - roots=array(roots) - if polyorder%2==0: - roots=concatenate( (-1.0*roots, roots[::-1]) ) - else: - roots=concatenate( (-1.0*roots, [0.0], roots[::-1]) ) - err=0 # successfully determined roots - return [roots, err] -################################################################## -# Weight coefficients def GaussLegendreWeights(polyorder): - W=[] - [xis,err]=LegendreRoots(polyorder) - if err==0: - W=2.0/( (1.0-xis**2)*(DLegendre(polyorder,xis)**2) ) - err=0 - else: - err=1 # could not determine roots - so no weights - return [W, xis, err] -################################################################## -# The integral value -# func : the integrand -# a, b : lower and upper limits of the integral -# polyorder : order of the Legendre polynomial to be used -# -def GaussLegendreQuadrature(func, polyorder, a, b): - [Ws,xs, err]= GaussLegendreWeights(polyorder) - if err==0: - ans=(b-a)*0.5*sum( Ws*func( (b-a)*0.5*xs+ (b+a)*0.5 ) ) - else: - # (in case of error) - err=1 - ans=None - return [ans,err] -################################################################## -# The integrand - change as required -def func(x): - return exp(x) -################################################################## -# + """Weight coefficients.""" + W = [] + xis, err = LegendreRoots(polyorder) + if err == 0: + W = 2.0 / ((1.0 - xis**2) * (DLegendre(polyorder, xis) ** 2)) + err = 0 + else: + err = 1 # could not determine roots - so no weights + return [W, xis, err] -order=5 -[Ws,xs,err]=GaussLegendreWeights(order) -if err==0: - print "Order : ", order - print "Roots : ", xs - print "Weights : ", Ws + +def GaussLegendreQuadrature(func, polyorder, a, b): + """integral value + func : the integrand + a, b : lower and upper limits of the integral + polyorder : order of the Legendre polynomial to be used + """ + Ws, xs, err = GaussLegendreWeights(polyorder) + if err == 0: + ans = (b - a) * 0.5 * sum(Ws * func((b - a) * 0.5 * xs + (b + a) * 0.5)) + else: + # (in case of error) + err = 1 + ans = None + return [ans, err] + + +def func(x): + """The integrand - change as required""" + return exp(x) + + +order = 5 +Ws, xs, err = GaussLegendreWeights(order) + +if err == 0: + print("Order : ", order) + print("Roots : ", xs) + print("Weights : ", Ws) else: - print "Roots/Weights evaluation failed" + print("Roots/Weights evaluation failed") # Integrating the function -[ans,err]=GaussLegendreQuadrature(func , order, -3,3) -if err==0: - print "Integral : ", ans +ans, err = GaussLegendreQuadrature(func, order, -3, 3) + +if err == 0: + print("Integral : ", ans) else: - print "Integral evaluation failed" + print("Integral evaluation failed") diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/REXX/numerical-integration-gauss-legendre-quadrature-2.rexx b/Task/Numerical-integration-Gauss-Legendre-Quadrature/REXX/numerical-integration-gauss-legendre-quadrature-2.rexx index 55b09726ec..4c25856bd9 100644 --- a/Task/Numerical-integration-Gauss-Legendre-Quadrature/REXX/numerical-integration-gauss-legendre-quadrature-2.rexx +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/REXX/numerical-integration-gauss-legendre-quadrature-2.rexx @@ -1,9 +1,8 @@ --- 9 Jun 2025 +-- 28 Jul 2025 include Settings - arg digs if digs = '' then - digs=9 + digs=16 numeric digits digs say 'NUMERICAL INTEGRATION: GAUSS-LEGENDRE QUADRATURE' @@ -13,23 +12,26 @@ w=Digits()+2 say Left('Function',10) Left('Range',w+4) ' N', Left('Result',w) Left('True',w) Left(' Error',w) say +call Task 'Sin(x)', 0, 1, -Cos(1)+1 +call Task 'Sin(x)', 0, Pi()/1, 2 +call Task 'Sin(x)', 0, 10, -Cos(10)+1 +call Task 'Cos(x)', 0, 1, Sin(1) +call Task 'Cos(x)', 0, Pi()/1, 0 +call Task 'Cos(x)', 0, 10, Sin(10) +call Task 'Tan(x)', 0, 1, -Ln(Abs(Cos(1))) +call Task 'Tan(x)', 0, Pi()/1, 0 +call Task 'Tan(x)', 0, 10, -Ln(Abs(Cos(10))) call Task 'x**3', 0, 1, 1/4 call Task '1/x', 1, 100, Ln(100)/1 call Task 'x', 0, 5000, 12500000 call Task '4/(x**2+1)', 0, 1, Pi()/1 -call Task 'Sin(x)', 0, 1, -Cos(1)+1 -call Task 'Sin(x)', 0, Pi()/1, 2 -call Task 'Cos(x)', 0, 1, Sin(1) -call Task 'Cos(x)', 0, Pi()/1, 0 -call Task 'Tan(x)', 0, 1, -Ln(Abs(Cos(1))) -call Task 'Tan(x)', 0, Pi()/1, 0 call Task 'Exp(x)', -3, 3, Exp(3)-Exp(-3) call Task 'Gamma(x)', 1, 8, 2603.238829328642145 call Timer exit Task: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,true w=Digits()+2 do nn = 1 to 20 @@ -41,7 +43,7 @@ say return GaussQuad: -procedure expose glob. +procedure expose Memo. -- Gaussion-Legendre quadrature on function f in range a...b taking n points arg ff,aa,bb,nn -- Legendre polynomials @@ -88,8 +90,4 @@ do i = 1 to nn end return bm*zz -include Functions -include Special -include Constants -include Helper -include Abend +include Math diff --git a/Task/Numerical-integration/Pluto/numerical-integration.pluto b/Task/Numerical-integration/Pluto/numerical-integration.pluto new file mode 100644 index 0000000000..d2431ba7a7 --- /dev/null +++ b/Task/Numerical-integration/Pluto/numerical-integration.pluto @@ -0,0 +1,20 @@ +local function integrate(a, b, n, f) + local h = (b - a) / n + local sum = {0, 0, 0, 0, 0} + for i = 1, n do + local x = a + (i - 1) * h + sum[1] += f(x) + sum[2] += f(x + h / 2) + sum[3] += f(x + h) + sum[4] += (f(x) + f(x + h)) / 2 + sum[5] += (f(x) + 4 * f(x + h / 2) + f(x + h)) / 6 + end + local methods = {"LeftRect ", "MidRect ", "RightRect", "Trapezium", "Simpson "} + for i = 1, 5 do print($"{methods[i]} = {sum[i] * h}") end + print() +end + +integrate(0, 1, 100, |v| -> v * v * v) +integrate(1, 100, 1_000, |v| -> 1 / v) +integrate(0, 5_000, 5_000_000, |v| -> v) +integrate(0, 6_000, 6_000_000, |v| -> v) diff --git a/Task/Numerical-integration/REXX/numerical-integration.rexx b/Task/Numerical-integration/REXX/numerical-integration.rexx index dcaa344a38..ef991abe55 100644 --- a/Task/Numerical-integration/REXX/numerical-integration.rexx +++ b/Task/Numerical-integration/REXX/numerical-integration.rexx @@ -1,4 +1,4 @@ --- 8 Jun 2025 +-- 28 Jul 2025 include Settings arg digs if digs = '' then @@ -32,7 +32,7 @@ call Timer exit Task: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps,true w=Digits()+2 res=LeftRect(ff,aa,bb,steps); diff=res-true @@ -50,59 +50,79 @@ say Left(ff,11) Left(aa '-' bb,w+4) Left('Trapezoid',9) Left(steps,7), res=Simpson(ff,aa,bb,steps); diff=res-true say Left(ff,11) Left(aa '-' bb,w+4) Left('Simpson',9) Left(steps,7), Left(Std(res),w) Left(true,w) Format(diff,2,4,,0) +res=Boole(ff,aa,bb,steps); diff=res-true +say Left(ff,11) Left(aa '-' bb,w+4) Left('Boole',9) Left(steps,7), + Left(Std(res),w) Left(true,w) Format(diff,2,4,,0) say return LeftRect: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps -h=(bb-aa)/steps; s=0 +h=(bb-aa)/steps +s=0 do n = 0 to steps-1 s=s+Eval(ff,aa+n*h) end return s*h MidRect: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps -h=(bb-aa)/steps; s=0; aa=aa-h/2 +h=(bb-aa)/steps; aa=aa-h/2 +s=0 do n = 1 to steps s=s+Eval(ff,aa+n*h) end return s*h RightRect: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps -h=(bb-aa)/steps; s=0 +h=(bb-aa)/steps +s=0 do n = 1 to steps s=s+Eval(ff,aa+n*h) end return s*h Trapezoid: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps -h=(bb-aa)/steps; s=0.5*(Eval(ff,aa)+Eval(ff,bb)) +h=(bb-aa)/steps +s=0.5*(Eval(ff,aa)+Eval(ff,bb)) do n = 1 to steps-1 s=s+Eval(ff,aa+n*h) end return s*h Simpson: -procedure expose glob. +procedure expose Memo. arg ff,aa,bb,steps -h=(bb-aa)/steps; s=Eval(ff,aa)+Eval(ff,bb) +h=(bb-aa)/steps +s0=Eval(ff,aa)+Eval(ff,bb); s1=0; s2=0 do n = 1 by 2 to steps-1 - s=s+4*Eval(ff,aa+n*h) + s1=s1+Eval(ff,aa+n*h) end -do n = 2 by 2 to steps-1 - s=s+2*Eval(ff,aa+n*h) +do n = 2 by 2 to steps-2 + s2=s2+Eval(ff,aa+n*h) end -return s*h/3 +return (s0+4*s1+2*s2)*h/3 -include Functions -include Special -include Constants -include Helper -include Abend +Boole: +procedure expose Memo. +arg ff,aa,bb,steps +h=(bb-aa)/steps +s0=7*(Eval(ff,aa)+Eval(ff,bb)); s1=0; s2=0; s3=0 +do n = 1 by 2 to steps-1 + s1=s1+Eval(ff,aa+n*h) +end +do n = 2 by 4 to steps-2 + s2=s2+Eval(ff,aa+n*h) +end +do n = 4 by 4 to steps-4 + s3=s3+Eval(ff,aa+n*h) +end +return (s0+32*s1+12*s2+14*s3)*2*h/45 + +include Math diff --git a/Task/OLE-automation/Julia/ole-automation.jl b/Task/OLE-automation/Julia/ole-automation.jl new file mode 100644 index 0000000000..f93c3c259c --- /dev/null +++ b/Task/OLE-automation/Julia/ole-automation.jl @@ -0,0 +1,34 @@ +using PyCall + +function demoCOM() + # Import Python's win32com.client and time modules + win32com = pyimport("win32com.client") + + # Initialize COM + win32com.CoInitialize() + + # Create Word.Application object + word = win32com.Dispatch("Word.Application") + + # set up new document + word.Visible = true + documents = word.Documents + document = documents.Add() + content = document.Content + paragraphs = content.Paragraphs + + # add the new paragraph of text + paragraph = paragraphs.Add() + rnge = paragraph.Range + rnge.Text = "This is a Rosetta Code test document." + + # wait for Windows to run the requests, then close + sleep(5) + document.Saved = true + document.Close(false) + + word.Quit() + win32com.CoUninitialize() +end + +demoCOM() diff --git a/Task/Object-serialization/C++/object-serialization.cpp b/Task/Object-serialization/C++/object-serialization.cpp index b0c9bb597d..4cd843cf40 100644 --- a/Task/Object-serialization/C++/object-serialization.cpp +++ b/Task/Object-serialization/C++/object-serialization.cpp @@ -12,7 +12,7 @@ public : Employee ( const std::string &dep , const std::string &namen ) : department( dep ) , name( namen ) { - my_id = count++ ; + my_id = count++ ; } std::string getName( ) const { @@ -47,9 +47,9 @@ private : template void serialize( Archive &ar, const unsigned int version ) { - ar & my_id ; - ar & name ; - ar & department ; + ar & my_id ; + ar & name ; + ar & department ; } } ; @@ -57,7 +57,7 @@ private : class Worker : public Employee { public : Worker( const std::string & dep, const std::string &namen , - double hourlyPay ) : Employee( dep , namen ) , salary( hourlyPay) { } + double hourlyPay ) : Employee( dep , namen ) , salary( hourlyPay) { } Worker( ) { } @@ -67,7 +67,7 @@ public : void setSalary( double pay ) { if ( pay > 0 ) - salary = pay ; + salary = pay ; } virtual void print( ) { @@ -79,8 +79,8 @@ private : friend class boost::serialization::access ; template void serialize ( Archive & ar, const unsigned int version ) { - ar & boost::serialization::base_object( *this ) ; - ar & salary ; + ar & boost::serialization::base_object( *this ) ; + ar & salary ; } } ; diff --git a/Task/Object-serialization/EchoLisp/object-serialization-1.l b/Task/Object-serialization/EchoLisp/object-serialization-1.l index 62c373d399..12c37e0687 100644 --- a/Task/Object-serialization/EchoLisp/object-serialization-1.l +++ b/Task/Object-serialization/EchoLisp/object-serialization-1.l @@ -1,11 +1,11 @@ (define (person->string self) (format "%a : person." (person-name self))) (define (writer->string self) (format "%a: writer of %a." - (person-name self) - (writer-books self))) + (person-name self) + (writer-books self))) (define (father->string self) (format "%a: father of %a." - (person-name self) - (map person-name (father-children self)))) - + (person-name self) + (map person-name (father-children self)))) + ; 'classes' definition, with inheritance. ; a writer is a person, too. (struct person (name) #:tostring person->string) diff --git a/Task/Object-serialization/Erlang/object-serialization.erl b/Task/Object-serialization/Erlang/object-serialization.erl index f7b0f04e10..6a69470a99 100644 --- a/Task/Object-serialization/Erlang/object-serialization.erl +++ b/Task/Object-serialization/Erlang/object-serialization.erl @@ -6,23 +6,23 @@ -record( person, {entity, email} ). task() -> - Person = #person{entity=#entity{name="Cletus", date=20080808}, email="test+1@localhost.localdomain"}, - print( Person ), - Entity = #entity{name="Entity", date=20111111}, - print( Entity ), - ok = file:write_file( "objects.dat", erlang:term_to_binary([Person, Entity]) ), - {ok, Binary} = file:read_file( "objects.dat" ), - [New_person, New_entity] = erlang:binary_to_term( Binary ), - io:fwrite( "Deserialized\n" ), - print( New_person ), - print( New_entity ). - + Person = #person{entity=#entity{name="Cletus", date=20080808}, email="test+1@localhost.localdomain"}, + print( Person ), + Entity = #entity{name="Entity", date=20111111}, + print( Entity ), + ok = file:write_file( "objects.dat", erlang:term_to_binary([Person, Entity]) ), + {ok, Binary} = file:read_file( "objects.dat" ), + [New_person, New_entity] = erlang:binary_to_term( Binary ), + io:fwrite( "Deserialized\n" ), + print( New_person ), + print( New_entity ). + print( #entity{name=Name, date=Date} ) -> - io:fwrite( "Entity: " ), - io:fwrite( "name: ~p, date: ~p~n", [Name, Date] ); + io:fwrite( "Entity: " ), + io:fwrite( "name: ~p, date: ~p~n", [Name, Date] ); print( #person{entity=Entity, email=Email} ) -> - io:fwrite( "Person: " ), - print( Entity ), - io:fwrite( "\temail: ~p~n", [Email] ). + io:fwrite( "Person: " ), + print( Entity ), + io:fwrite( "\temail: ~p~n", [Email] ). diff --git a/Task/Object-serialization/Objective-C/object-serialization.m b/Task/Object-serialization/Objective-C/object-serialization.m index d6b6aecd64..28009c1150 100644 --- a/Task/Object-serialization/Objective-C/object-serialization.m +++ b/Task/Object-serialization/Objective-C/object-serialization.m @@ -102,17 +102,17 @@ int main() // let us create a fantasy animal Animal *anAnimal = [[Animal alloc] - initWithName: @"Eptohippos" - andLegs: 7 - ]; + initWithName: @"Eptohippos" + andLegs: 7 + ]; // for some reason an Eptohippos is not an horse with 7 legs, // and it is not a mammal, of course... // let us create a fantasy mammal (which is an animal too) Mammal *aMammal = [[Mammal alloc] - initWithName: @"Mammaluc" - hasFur: YES - ]; + initWithName: @"Mammaluc" + hasFur: YES + ]; // let us add some eaten stuff... [aMammal addEatenThing: @"lamb"]; [aMammal addEatenThing: @"table"]; @@ -129,7 +129,7 @@ int main() // now let us store the objects... NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *arch = [[NSKeyedArchiver alloc] - initForWritingWithMutableData: data]; + initForWritingWithMutableData: data]; [arch encodeObject: anAnimal forKey: @"Eptohippos"]; [arch encodeObject: aMammal forKey: @"Mammaluc"]; [arch finishEncoding]; @@ -137,9 +137,9 @@ int main() // now we want to retrieve the saved objects... NSData *ldata = [[NSData alloc] - initWithContentsOfFile: @"objects.dat"]; + initWithContentsOfFile: @"objects.dat"]; NSKeyedUnarchived *darch = [[NSKeyedUnarchiver alloc] - initForReadingWithData: ldata]; + initForReadingWithData: ldata]; Animal *archivedAnimal = [darch decodeObjectForKey: @"Eptohippos"]; Mammal *archivedMammal = [darch decodeObjectForKey: @"Mammaluc"]; [darch finishDecoding]; diff --git a/Task/Object-serialization/Python/object-serialization.py b/Task/Object-serialization/Python/object-serialization.py index 4ad7458567..9b2e5b9324 100644 --- a/Task/Object-serialization/Python/object-serialization.py +++ b/Task/Object-serialization/Python/object-serialization.py @@ -6,14 +6,14 @@ import pickle class Entity: - def __init__(self): - self.name = "Entity" - def printName(self): - print self.name + def __init__(self): + self.name = "Entity" + def printName(self): + print self.name class Person(Entity): #OldMan inherits from Entity - def __init__(self): #override constructor - self.name = "Cletus" + def __init__(self): #override constructor + self.name = "Cletus" instance1 = Person() instance1.printName() diff --git a/Task/Object-serialization/REBOL/object-serialization.rebol b/Task/Object-serialization/REBOL/object-serialization.rebol new file mode 100644 index 0000000000..751b30aa2d --- /dev/null +++ b/Task/Object-serialization/REBOL/object-serialization.rebol @@ -0,0 +1,84 @@ +Rebol [ + title: "Rosetta code: Object serialization" + file: %Object_serialization.r3 + url: https://rosettacode.org/wiki/Object_serialization + needs: 2.7.0 +] +; ---------------------------- +; Define a base "class" Person +; ---------------------------- +; In Rebol, `make object! [...]` creates an object with defined fields (and optionally functions). +; Here, Person has two properties: name (string) and age (integer). +Person: make object! [ + name: "" + age: 0 +] + +; ------------------------------------------------ +; "Inherit" a subclass Student from Person +; ------------------------------------------------ +; Since Rebol doesn't have classical inheritance, `make Person [...]` +; makes a copy of the Person object and lets you add or override fields. +; Student adds an extra property: grade (e.g., "A", "B", etc.) +Student: make Person [ + grade: "" +] + +; ------------------------------------------------ +; Inherit another subclass Teacher from Person +; ------------------------------------------------ +; Teacher adds an extra property: subject (teaching subject) +Teacher: make Person [ + subject: "" +] + +; ---------------------------------- +; Create specific instances of each +; ---------------------------------- +; Values in brackets override default properties when creating the object. +john: make Person [name: "John" age: 40] +sally: make Student [name: "Sally" age: 18 grade: "A"] +bob: make Teacher [name: "Bob" age: 50 subject: "Math"] + +; ------------------------------------------------ +; Print text in yellow (assuming ANSI color functions are set up) +; ------------------------------------------------ +print "Original instances:" + +; ------------------------------------------------ +; `probe` prints the value in developer-readable format and returns it +; This is useful for quickly seeing object content +; ------------------------------------------------ +probe john +probe sally +probe bob + +; ------------------------------------------------ +; Create a block containing all three objects +; `reduce` evaluates each word and inserts its value into the block +; ------------------------------------------------ +objects: reduce [john sally bob] + +; ------------------------------------------------ +; Save all object data (including words, values, and types) to a file +; `save/all` preserves the complete object structure +; ------------------------------------------------ +save/all %objects.dat objects + +; ------------------------------------------------ +; Show header for loaded instances +; ------------------------------------------------ +print "Loaded instances:" + +; ------------------------------------------------ +; Load objects back from the file +; `load` reconstructs the original structures from the saved format +; ------------------------------------------------ +read-objects: load %objects.dat + +; ------------------------------------------------ +; Iterate over loaded objects and display them +; ------------------------------------------------ +foreach obj read-objects [ + probe obj +] diff --git a/Task/Odd-word-problem/Nom/odd-word-problem.num b/Task/Odd-word-problem/Nom/odd-word-problem.num new file mode 100644 index 0000000000..ab7a43f37b --- /dev/null +++ b/Task/Odd-word-problem/Nom/odd-word-problem.num @@ -0,0 +1,23 @@ +#* +GRAMMAR PARSE TOKENS + no tokens required, except to store odd/even state + +HISTORY + 13 sept 2021: written + +*# + + begin { add "odd*"; push; } + read; + [:alpha:] { + pop; + B"odd*" { push; get; put; clear; } + B"even*" { push; swap; get; put; clear; } + } + ![:alpha:].!"" { + pop; + B"odd*" { replace "odd*" "even*"; push; } + B"even*" { replace "even*" "odd*"; push; } + swap; print; clear; swap; print; clear; + } + (eof) { get; print; } diff --git a/Task/Old-Russian-measure-of-length/ANSI-BASIC/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/ANSI-BASIC/old-russian-measure-of-length.basic new file mode 100644 index 0000000000..1e53a70baa --- /dev/null +++ b/Task/Old-Russian-measure-of-length/ANSI-BASIC/old-russian-measure-of-length.basic @@ -0,0 +1,47 @@ +100 REM Old Russian measure of length +110 LET UnitsLength = 13 +120 DIM Units$(1 TO 13), Convs(1 TO 13) +130 REM DIM Units$(1 TO UnitsLength), Convs(1 TO UnitsLength) allowed in some implementations +140 FOR I = 1 TO UnitsLength +150 READ Units$(I) +160 NEXT I +170 DATA tochka, liniya, dyuim, vershok, piad, fut +180 DATA arshin, sazhen, versta, milia, centimeter, meter, kilometer +190 REM All expressed in centimeters +200 FOR I = 1 TO UnitsLength +210 READ Convs(I) +220 NEXT I +230 DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48 +240 DATA 71.12, 213.36, 106680, 746760, 1, 100, 100000 +250 DO +260 PRINT "------------" +270 PRINT +280 FOR I = 1 TO UnitsLength +290 PRINT USING "## ": I; +300 PRINT Units$(I) +310 NEXT I +320 PRINT +330 DO +340 INPUT PROMPT "Please choose a unit 1 to " & STR$(UnitsLength) & " :": Unit +350 LOOP UNTIL (Unit >= 1) AND (Unit <= UnitsLength) +360 DO +370 INPUT PROMPT "Now enter a value in that unit :": Value +380 LOOP UNTIL Value > 0 +390 PRINT +400 PRINT "The equivalent in the remaining units is:" +410 PRINT +420 FOR I = 1 TO UnitsLength +430 IF I <> Unit THEN +440 PRINT USING "#######.######## ": Value * Convs(Unit) / Convs(I); +450 PRINT Units$(I); "(s)" +460 END IF +470 NEXT I +480 PRINT +490 DO +500 INPUT PROMPT "Do another one y/n :": YN$ +510 LET YN$ = LCASE$(YN$) +520 LOOP UNTIL (YN$ = "y") OR (YN$ = "n") +530 PRINT +540 LOOP UNTIL YN$ = "n" +550 PRINT "End of story" +560 END diff --git a/Task/Old-Russian-measure-of-length/ASIC/old-russian-measure-of-length.asic b/Task/Old-Russian-measure-of-length/ASIC/old-russian-measure-of-length.asic new file mode 100644 index 0000000000..2c083f3305 --- /dev/null +++ b/Task/Old-Russian-measure-of-length/ASIC/old-russian-measure-of-length.asic @@ -0,0 +1,65 @@ +REM Old Russian measure of length +DIM Units$(12) +DIM Convs@(12) +DATA "tochka", "liniya", "dyuim", "vershok", "piad", "fut" +DATA "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer" +DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48 +DATA 71.12, 213.36, 106680.0, 746760.0, 1.0, 100.0, 100000.0 +MaxIndex = 12 +NumOfUnits = MaxIndex + 1 +FOR I = 0 TO MaxIndex + READ Units$(I) +NEXT I +FOR I = 0 TO MaxIndex + READ Convs@(I) +NEXT I +Start: + CLS + PRINT + FOR I = 0 TO MaxIndex + IPl1 = I + 1 + PRINT IPl1; + PRINT " "; + PRINT Units$(I) + NEXT I + NU$ = STR$(NumOfUnits) + NU$ = LTRIM$(NU$) + ChooseUnit: + PRINT "Please choose a unit from 1 to "; + PRINT NU$; + PRINT ": "; + INPUT Unit + IF Unit > NumOfUnits THEN ChooseUnit: + IF Unit < 1 THEN ChooseUnit: + Unit = Unit - 1 + EnterVal: + PRINT "Now enter a value in that unit: "; + INPUT V@ + IF V@ <= 0 THEN EnterVal: + CLS + PRINT + PRINT V@; + PRINT " "; + PRINT Units$(Unit); + PRINT "(s) in the remaining units is:" + FOR I = 0 TO MaxIndex + IF I <> Unit THEN + Equiv@ = V@ * Convs@(Unit) + Equiv@ = Equiv@ / Convs@(I) + PRINT Equiv@; + PRINT " "; + PRINT Units$(I); + PRINT "(s)" + ENDIF + NEXT I + AskDoAnother: + PRINT "Do another one y/n"; + INPUT YN$ + YN$ = LCASE$(YN$) + IF YN$ = "n" THEN EndOfStory: + IF YN$ = "y" THEN Start: + GOTO AskDoAnother: + PRINT +EndOfStory: +PRINT "End of story." +END diff --git a/Task/Old-Russian-measure-of-length/BASIC256/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/BASIC256/old-russian-measure-of-length.basic index 1ded06cd1e..cfe373328b 100644 --- a/Task/Old-Russian-measure-of-length/BASIC256/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/BASIC256/old-russian-measure-of-length.basic @@ -1,7 +1,7 @@ arraybase 1 dim units = {"tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"} # all expressed in centimeters -dim convs = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000} +dim convs = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 106680, 746760, 1, 100, 100000} do cls diff --git a/Task/Old-Russian-measure-of-length/Delphi/old-russian-measure-of-length.pas b/Task/Old-Russian-measure-of-length/Delphi/old-russian-measure-of-length.pas index 3171a11df1..0282743228 100644 --- a/Task/Old-Russian-measure-of-length/Delphi/old-russian-measure-of-length.pas +++ b/Task/Old-Russian-measure-of-length/Delphi/old-russian-measure-of-length.pas @@ -10,7 +10,7 @@ const 'piad', 'fut', 'arshin', 'sazhen', 'versta', 'milia', 'centimeter', 'meter', 'kilometer'); convs: array[0..12] of double = (0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, - 71.12, 213.36, 10668, 74676, 1, 100, 10000); + 71.12, 213.36, 106680, 746760, 1, 100, 100000); function ReadInt(): integer; var diff --git a/Task/Old-Russian-measure-of-length/EasyLang/old-russian-measure-of-length.easy b/Task/Old-Russian-measure-of-length/EasyLang/old-russian-measure-of-length.easy index e8f85bebf6..5a81e31690 100644 --- a/Task/Old-Russian-measure-of-length/EasyLang/old-russian-measure-of-length.easy +++ b/Task/Old-Russian-measure-of-length/EasyLang/old-russian-measure-of-length.easy @@ -1,5 +1,5 @@ units$[] = [ "tochka" "liniya" "dyuim" "vershok" "piad" "fut" "arshin" "sazhen" "versta" "milia" "centimeter" "meter" "kilometer" ] -convs[] = [ 0.254 0.254 2.54 4.445 17.78 30.48 71.12 213.36 10668 74676 1 100 10000 ] +convs[] = [ 0.254 0.254 2.54 4.445 17.78 30.48 71.12 213.36 106680 746760 1 100 100000 ] for i to len units$[] print i & ") " & units$[i] . diff --git a/Task/Old-Russian-measure-of-length/FreeBASIC/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/FreeBASIC/old-russian-measure-of-length.basic index 78a3cccda5..77ea8551dc 100644 --- a/Task/Old-Russian-measure-of-length/FreeBASIC/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/FreeBASIC/old-russian-measure-of-length.basic @@ -6,8 +6,8 @@ Dim units(1 To 13) As String = {"tochka", "liniya", "dyuim", "vershok", "piad", ' all expressed in centimeters Dim convs(1 To 13) As Single = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, _ - 71.12, 213.36, 10668, 74676, _ - 1, 100, 10000} + 71.12, 213.36, 106680, 746760, _ + 1, 100, 100000} Dim unit As Integer Dim value As Single Dim yn As String diff --git a/Task/Old-Russian-measure-of-length/GW-BASIC/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/GW-BASIC/old-russian-measure-of-length.basic new file mode 100644 index 0000000000..8ba8978205 --- /dev/null +++ b/Task/Old-Russian-measure-of-length/GW-BASIC/old-russian-measure-of-length.basic @@ -0,0 +1,35 @@ +100 REM Old Russian measure of length +110 MAX.INDEX = 12 +120 DIM UNITS$(MAX.INDEX), CONVS(MAX.INDEX) +130 DATA tochka, liniya, dyuim, vershok, piad, fut +140 DATA arshin, sazhen, versta, milia, centimeter, meter, kilometer +150 DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48 +160 DATA 71.12, 213.36, 106680, 746760, 1, 100, 100000 +170 FOR I = 0 TO MAX.INDEX +180 READ UNITS$(I) +190 NEXT I +200 FOR I = 0 TO MAX.INDEX +210 READ CONVS(I) +220 NEXT I +230 FOR I = 0 TO MAX.INDEX +240 PRINT USING "## "; I + 1; +250 PRINT UNITS$(I) +260 NEXT I +270 PRINT +280 PRINT "Please choose a unit 1 to"; MAX.INDEX + 1;: INPUT " :", UNIT: IF (UNIT < 1) OR (UNIT > MAX.INDEX + 1) THEN 280 +290 UNIT = UNIT - 1 +300 INPUT "Now enter a value in that unit:", VALUE: IF VALUE <= 0 THEN 300 +310 PRINT +320 PRINT "The equivalent in the remaining units is:" +330 PRINT +340 FOR I = 0 TO MAX.INDEX +350 IF I <> UNIT THEN PRINT USING "#######.######## "; VALUE * CONVS(UNIT) / CONVS(I);: PRINT UNITS$(I); "(s)" +360 NEXT I +370 PRINT +380 INPUT "Do another one y/n"; YN$ +390 IF UN$ <> "" THEN YN$ = CHR$(ASC(LEFT$(YN$, 1)) OR 32) ' GW-BASIC does not have LCASE$ +400 IF (YN$ <> "y") AND (YN$ <> "n") THEN 380 +410 PRINT +420 IF YN$ <> "n" THEN 230 +430 PRINT "End of story." +440 END diff --git a/Task/Old-Russian-measure-of-length/Gambas/old-russian-measure-of-length.gambas b/Task/Old-Russian-measure-of-length/Gambas/old-russian-measure-of-length.gambas index db197da004..c9c0027691 100644 --- a/Task/Old-Russian-measure-of-length/Gambas/old-russian-measure-of-length.gambas +++ b/Task/Old-Russian-measure-of-length/Gambas/old-russian-measure-of-length.gambas @@ -3,7 +3,7 @@ Public Sub Main() Dim units As String[] = ["tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"] ' all expressed in centimeters - Dim convs As Single[] = [0.254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000] + Dim convs As Single[] = [0.254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 106680, 746760, 1, 100, 100000] Dim i, unit As Integer Dim value As Single Dim yn As String diff --git a/Task/Old-Russian-measure-of-length/Go/old-russian-measure-of-length.go b/Task/Old-Russian-measure-of-length/Go/old-russian-measure-of-length.go index 012f04d87c..2de3caed73 100644 --- a/Task/Old-Russian-measure-of-length/Go/old-russian-measure-of-length.go +++ b/Task/Old-Russian-measure-of-length/Go/old-russian-measure-of-length.go @@ -17,8 +17,8 @@ func main() { convs := []float32{ 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, - 71.12, 213.36, 10668, 74676, - 1, 100, 10000, + 71.12, 213.36, 106680, 746760, + 1, 100, 100000, } scanner := bufio.NewScanner(os.Stdin) diff --git a/Task/Old-Russian-measure-of-length/Kotlin/old-russian-measure-of-length.kts b/Task/Old-Russian-measure-of-length/Kotlin/old-russian-measure-of-length.kts index db0d0e8116..80b757bc91 100644 --- a/Task/Old-Russian-measure-of-length/Kotlin/old-russian-measure-of-length.kts +++ b/Task/Old-Russian-measure-of-length/Kotlin/old-russian-measure-of-length.kts @@ -8,8 +8,8 @@ fun main(args: Array) { "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer") val convs = arrayOf(0.0254f, 0.254f, 2.54f, 4.445f, 17.78f, 30.48f, - 71.12f, 213.36f, 10668.0f, 74676.0f, - 1.0f, 100.0f, 10000.0f) + 71.12f, 213.36f, 106680.0f, 746760.0f, + 1.0f, 100.0f, 100000.0f) var unit: Int var value: Float var yn : String diff --git a/Task/Old-Russian-measure-of-length/Nascom-BASIC/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/Nascom-BASIC/old-russian-measure-of-length.basic new file mode 100644 index 0000000000..a7471c0567 --- /dev/null +++ b/Task/Old-Russian-measure-of-length/Nascom-BASIC/old-russian-measure-of-length.basic @@ -0,0 +1,31 @@ +10 REM Old Russian measure of length +20 M=12 +30 DIM U$(12),C(12) +40 DATA tochka,liniya,dyuim,vershok,piad,fut +50 DATA arshin,sazhen,versta,milia,centimeter +60 DATA meter,kilometer +70 DATA 0.0254,0.254,2.54,4.445,17.78,30.48 +80 DATA 71.12,213.36,106680,746760,1,100,100000 +90 FOR I=0 TO M:READ U$(I):NEXT I +100 FOR I=0 TO M:READ C(I):NEXT I +110 FOR I=0 TO M:PRINT I+1;U$(I):NEXT I +120 PRINT "Please choose a unit 1 to";M+1; +130 INPUT IU +140 IF (IU<1) OR (IU>M+1) GOTO 120 +150 IU=IU-1 +160 INPUT "Now enter a value in that unit";V +170 IF V<=0 GOTO 160 +180 CLS +190 PRINT V;U$(IU);"(s) in the remaining "; +200 PRINT "units is:" +210 FOR I=0 TO M +220 IF I=IU GOTO 240 +230 PRINT V*C(IU)/C(I);U$(I);"(s)" +240 NEXT I +250 INPUT "Do another one y/n";YN$ +260 IF YN$="" GOTO 250 +270 YN$=CHR$(ASC(LEFT$(YN$,1)) OR 32) +280 IF (YN$<>"n") AND (YN$<>"y") GOTO 250 +290 IF YN$<>"n" GOTO 110 +300 PRINT "End of story." +310 END diff --git a/Task/Old-Russian-measure-of-length/Pluto/old-russian-measure-of-length.pluto b/Task/Old-Russian-measure-of-length/Pluto/old-russian-measure-of-length.pluto new file mode 100644 index 0000000000..17023e3a5e --- /dev/null +++ b/Task/Old-Russian-measure-of-length/Pluto/old-russian-measure-of-length.pluto @@ -0,0 +1,35 @@ +local fmt = require "fmt" +require "io2" + +local units = { + "tochka", "liniya", "dyuim", "vershok", "piad", "fut", + "arshin", "sazhen", "versta", "milia", + "centimeter", "meter", "kilometer" +} + +local convs = { + 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, + 71.12, 213.36, 106680, 746760, + 1, 100, 100000 +} + +while true do + local i = 0 + for units as u do + fmt.print("%2d %s", i + 1, u) + ++i + end + print() + local unit = io.readInt("Please choose a unit 1 to 13 : ", 1, 13) + local value = io.readNum("Now enter a value in that unit : ", 0) + print("\nThe equivalent in the remaining units is:\n") + for ix, u in units do + if ix != unit then + fmt.print(" %10s : %16.8f", u, value * convs[unit] / convs[ix]) + end + end + print() + local yn = io.readOpt("Do another one y/n : ", "ynYN":split("")) + if yn:lower() == "n" then break end + print() +end diff --git a/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-1.pro b/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-1.pro new file mode 100644 index 0000000000..f97a1c0195 --- /dev/null +++ b/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-1.pro @@ -0,0 +1,101 @@ +:- module(old_russian_unit_conversion, [convert/2]). +:- set_prolog_flag(prefer_rationals, true). % Int/Int --> Rational +:- set_prolog_flag(rational_syntax, natural). % Write as `1/3` +:- use_module(library(clpq)). + +% The core conversion logic + +convert(A, B) :- convert_shag(A, S), convert_shag(B, S). + +convert_shag(tochka(T), S) :- { S / T = 1 / 2800 }. +convert_shag(millimetre(MM), S) :- { S / MM = 10 / 7112 }. +convert_shag(liniya(L), S) :- { S / L = 1 / 280 }. +convert_shag(centimetre(CM), S) :- { S / CM = 100 / 7112 }. +convert_shag(dyuym(D), S) :- { S / D = 1 / 28 }. +convert_shag(vyershok(V), S) :- { S / V = 1 / 16 }. +convert_shag(ladon(L), S) :- { S / L = 3 / 28 }. +convert_shag(pyad(P), S) :- { S / P = 1 / 4 }. +convert_shag(fut(F), S) :- { S / F = 3 / 7 }. +convert_shag(lokot(L), S) :- { S / L = 9 / 14 }. +convert_shag(shag(S), S). +convert_shag(metre(M), S) :- { M / S = 7112 / 10000 }. +convert_shag(sazhen(Sz), S) :- { Sz / S = 1 / 3 }. +convert_shag(kilometre(KM), S) :- { KM / S = 10668 / 15000000 }. +convert_shag(vyersta(V), S) :- { V / S = 1 / 1500 }. + +% The command line interface + +:- initialization(main, main). + +main([AmountA, UnitA]) :- + atom_number(AmountA, NumberA), + build_term(UnitA, NumberA, TermA), + !, + format("~w ~w is~n", [AmountA, UnitA]), + functor(TermA, NormalisedA, _), + foreach( + ( convert(TermA, TermB), + TermB =.. [UnitB, NumberB], + UnitB \= NormalisedA + ), + format("~|~` t~f~20+ ~w~n", [NumberB, UnitB]) + ). + +main([AmountA, UnitA, UnitB]) :- + atom_number(AmountA, NumberA), + build_term(UnitA, NumberA, TermA), + build_term(UnitB, NumberB, TermB), + !, + convert(TermA, TermB), + format("~w ~w is ~f ~w~n", [AmountA, UnitA, NumberB, UnitB]). + +main(_) :- with_output_to(user_error, format("Invalid argument~n", [])), halt(22). + +build_term(A0, N, T) :- normalise(A0, A), T =.. [A, N]. + +% user input normalisation + +normalise(millimetre, millimetre). +normalise(millimeter, millimetre). +normalise(millimetres, millimetre). +normalise(millimeters, millimetre). +normalise(centimetre, centimetre). +normalise(centimeter, centimetre). +normalise(centimetre, centimetre). +normalise(centimetres, centimetre). +normalise(metre, metre). +normalise(meter, metre). +normalise(meters, metre). +normalise(metres, metre). +normalise(kilometre, kilometre). +normalise(kilometer, kilometre). +normalise(kilometers, kilometre). +normalise(kilometres, kilometre). +normalise(tochka, tochka). +normalise(точка, tochka). +normalise(liniya, liniya). +normalise(линия, liniya). +normalise(dyuym, dyuym). +normalise(дюйм, dyuym). +normalise(pyerst, dyuym). +normalise(перст, dyuym). +normalise(vyershok, vyershok). +normalise(вершок, vyershok). +normalise(ladon, ladon). +normalise(ладонь, ladon). +normalise(pyad, pyad). +normalise(пядь, pyad). +normalise(четверть, pyad). +normalise(chyetvyert, pyad). +normalise(fut, fut). +normalise(фут, fut). +normalise(lokot, lokot). +normalise(локоть, lokot). +normalise(shag, shag). +normalise(шаг, shag). +normalise(arshin, shag). +normalise(аршин, shag). +normalise(sazhen, sazhen). +normalise(сажень, sazhen). +normalise(vyersta, vyersta). +normalise(верста, vyersta). diff --git a/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-2.pro b/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-2.pro new file mode 100644 index 0000000000..8d8e400625 --- /dev/null +++ b/Task/Old-Russian-measure-of-length/Prolog/old-russian-measure-of-length-2.pro @@ -0,0 +1,19 @@ +?- convert(centimetre(42), fut(Fut)). +Fut = 175/127. + +?- convert(centimetre(42), Unit). +Unit = tochka(210000/127) ; +Unit = millimetre(420) ; +Unit = liniya(21000/127) ; +Unit = centimetre(42) ; +Unit = dyuym(2100/127) ; +Unit = vyershok(1200/127) ; +Unit = ladon(700/127) ; +Unit = pyad(300/127) ; +Unit = fut(175/127) ; +Unit = lokot(350/381) ; +Unit = shag(75/127) ; +Unit = metre(21/50) ; +Unit = sazhen(25/127) ; +Unit = kilometre(21/50000) ; +Unit = vyersta(1/2540). diff --git a/Task/Old-Russian-measure-of-length/QBasic/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/QBasic/old-russian-measure-of-length.basic index e16f753855..48b4f5df09 100644 --- a/Task/Old-Russian-measure-of-length/QBasic/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/QBasic/old-russian-measure-of-length.basic @@ -9,7 +9,7 @@ DIM convs(1 TO 13) AS SINGLE FOR i = 1 TO 13 READ convs(i) NEXT i -DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000 +DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 106680, 746760, 1, 100, 100000 DIM unit AS INTEGER DIM value AS SINGLE DIM yn AS STRING diff --git a/Task/Old-Russian-measure-of-length/R/old-russian-measure-of-length.r b/Task/Old-Russian-measure-of-length/R/old-russian-measure-of-length.r index d22b8c0b1d..4ac8464612 100644 --- a/Task/Old-Russian-measure-of-length/R/old-russian-measure-of-length.r +++ b/Task/Old-Russian-measure-of-length/R/old-russian-measure-of-length.r @@ -3,10 +3,7 @@ russian_units <- c(1066.8, 2.1336, 0.7112, 0.04445) names(russian_units) <- c("verst", "sazhen", "arshin", "vershok") #Expand this vector to a matrix with one column each for values in km, m, and cm -metric_expand <- function(x){ - return(cbind(x/1000, x, x*100)) -} - +metric_expand <- function(x) cbind(x/1000, x, x*100) conv_matrix <- metric_expand(russian_units) colnames(conv_matrix) <- c("km", "m", "cm") diff --git a/Task/Old-Russian-measure-of-length/Ring/old-russian-measure-of-length.ring b/Task/Old-Russian-measure-of-length/Ring/old-russian-measure-of-length.ring index e877ded79c..6092a78987 100644 --- a/Task/Old-Russian-measure-of-length/Ring/old-russian-measure-of-length.ring +++ b/Task/Old-Russian-measure-of-length/Ring/old-russian-measure-of-length.ring @@ -6,8 +6,8 @@ units = ["tochka", "liniya", "dyuim", "vershok", "piad", "fut", "centimeter", "meter", "kilometer"] convs = [0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, - 71.12, 213.36, 10668, 74676, - 1, 100, 10000] + 71.12, 213.36, 106680, 746760, + 1, 100, 100000] yn = "y" unit = 1 diff --git a/Task/Old-Russian-measure-of-length/True-BASIC/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/True-BASIC/old-russian-measure-of-length.basic index 1f32a3a3d1..658baadb48 100644 --- a/Task/Old-Russian-measure-of-length/True-BASIC/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/True-BASIC/old-russian-measure-of-length.basic @@ -9,7 +9,7 @@ DIM convs(1 TO 13) FOR i = 1 TO 13 READ convs(i) NEXT i -DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000 +DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 106680, 746760, 1, 100, 100000 DO CLEAR diff --git a/Task/Old-Russian-measure-of-length/Wren/old-russian-measure-of-length.wren b/Task/Old-Russian-measure-of-length/Wren/old-russian-measure-of-length.wren index 0dfbdaa38b..d689d976f3 100644 --- a/Task/Old-Russian-measure-of-length/Wren/old-russian-measure-of-length.wren +++ b/Task/Old-Russian-measure-of-length/Wren/old-russian-measure-of-length.wren @@ -10,8 +10,8 @@ var units = [ var convs = [ 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, - 71.12, 213.36, 10668, 74676, - 1, 100, 10000 + 71.12, 213.36, 106680, 746760, + 1, 100, 100000 ] while (true) { @@ -39,7 +39,7 @@ while (true) { System.print("\nThe equivalent in the remaining units is:\n") i = 0 for (u in units) { - if (i != unit) Fmt.print(" $10s : $15.8g", u, value*convs[unit]/convs[i]) + if (i != unit) Fmt.print(" $10s : $16.8g", u, value*convs[unit]/convs[i]) i = i + 1 } System.print() diff --git a/Task/Old-Russian-measure-of-length/XBasic/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/XBasic/old-russian-measure-of-length.basic index 2686352008..ab91040d79 100644 --- a/Task/Old-Russian-measure-of-length/XBasic/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/XBasic/old-russian-measure-of-length.basic @@ -14,10 +14,10 @@ units$[13] = "kilometer " ' all expressed in centimeters DIM convs![14] -convs![1] = 0.0254 : convs![2] = 0.254 : convs![3] = 2.54 -convs![4] = 4.445 : convs![5] = 17.78 : convs![6] = 30.48 -convs![7] = 71.12 : convs![8] = 213.36 : convs![9] = 10668 -convs![10] = 74676 : convs![11] = 1 : convs![12] = 100 : convs![13] = 10000 +convs![1] = 0.0254 : convs![2] = 0.254 : convs![3] = 2.54 +convs![4] = 4.445 : convs![5] = 17.78 : convs![6] = 30.48 +convs![7] = 71.12 : convs![8] = 213.36 : convs![9] = 106680 +convs![10] = 746760 : convs![11] = 1 : convs![12] = 100 : convs![13] = 100000 DO PRINT diff --git a/Task/Old-Russian-measure-of-length/XPL0/old-russian-measure-of-length.xpl0 b/Task/Old-Russian-measure-of-length/XPL0/old-russian-measure-of-length.xpl0 index b8502af775..ee625e467d 100644 --- a/Task/Old-Russian-measure-of-length/XPL0/old-russian-measure-of-length.xpl0 +++ b/Task/Old-Russian-measure-of-length/XPL0/old-russian-measure-of-length.xpl0 @@ -6,8 +6,8 @@ real Convs, Value; "centimeter", "meter", "kilometer"]; Convs:= [0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, - 71.12, 213.36, 10668., 74676., - 1., 100., 10000.]; + 71.12, 213.36, 106680., 746760., + 1., 100., 100000.]; loop [for I:= 0 to 13-1 do [if I+1 < 10 then ChOut(0, ^ ); IntOut(0, I+1); diff --git a/Task/Old-Russian-measure-of-length/Yabasic/old-russian-measure-of-length.basic b/Task/Old-Russian-measure-of-length/Yabasic/old-russian-measure-of-length.basic index cffccf5896..90672dafbd 100644 --- a/Task/Old-Russian-measure-of-length/Yabasic/old-russian-measure-of-length.basic +++ b/Task/Old-Russian-measure-of-length/Yabasic/old-russian-measure-of-length.basic @@ -9,8 +9,8 @@ units$(13) = "kilometer" dim convs(14) convs(1) = 0.0254 : convs(2) = 0.254 : convs(3) = 2.54 convs(4) = 4.445 : convs(5) = 17.78 : convs(6) = 30.48 -convs(7) = 71.12 : convs(8) = 213.36 : convs(9) = 10668 -convs(10) = 74676 : convs(11) = 1 : convs(12) = 100 : convs(13) = 10000 +convs(7) = 71.12 : convs(8) = 213.36 : convs(9) = 106680 +convs(10) = 746760 : convs(11) = 1 : convs(12) = 100 : convs(13) = 100000 repeat clear screen diff --git a/Task/One-dimensional-cellular-automata/YAMLScript/one-dimensional-cellular-automata.ys b/Task/One-dimensional-cellular-automata/YAMLScript/one-dimensional-cellular-automata.ys new file mode 100644 index 0000000000..0befa5d1da --- /dev/null +++ b/Task/One-dimensional-cellular-automata/YAMLScript/one-dimensional-cellular-automata.ys @@ -0,0 +1,17 @@ +!YS-v0 + +defn main(): + each line generate(10 '_###_##_#_#_#_#__#__'): + say: line + +defn generate(n cells): + when n.?: + cons cells: + generate n.--: + loop cs cells, ncs subs(cells 0 1): + if cs.# >= 3: + recur cs.subs(1): + ncs +: + filter(\(_:S == '#') cs.subs(0 3)) + .#.eq(2).if('#' '_') + else: ncs + cs.subs(1) diff --git a/Task/One-of-n-lines-in-a-file/DuckDB/one-of-n-lines-in-a-file.duckdb b/Task/One-of-n-lines-in-a-file/DuckDB/one-of-n-lines-in-a-file.duckdb new file mode 100644 index 0000000000..a4c4a53126 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/DuckDB/one-of-n-lines-in-a-file.duckdb @@ -0,0 +1,4 @@ +FROM read_csv('input.txt', + header=false, sep='', quote='', escape='', + columns={'line': VARCHAR}, auto_detect=false) +USING SAMPLE 1; diff --git a/Task/Order-by-pair-comparisons/Pluto/order-by-pair-comparisons.pluto b/Task/Order-by-pair-comparisons/Pluto/order-by-pair-comparisons.pluto new file mode 100644 index 0000000000..703536c1a0 --- /dev/null +++ b/Task/Order-by-pair-comparisons/Pluto/order-by-pair-comparisons.pluto @@ -0,0 +1,37 @@ +require "io2" +local fmt = require "fmt" + +-- Inserts item x in list a, and keeps it sorted assuming a is already sorted. +-- If x is already in a, inserts it to the right of the rightmost x. +local function insort_right(a, x, q) + local lo = 1 + local hi = #a + 1 + local yn = "ynYN":split("") + while lo < hi do + local mid = (lo + hi) // 2 + ++q + local prompt = string.format("%2d: Is %6s less than %6s ? y/n: ", q, x, a[mid]) + local less = string.lower(io.readOpt(prompt, yn)) == "y" + if less then + hi = mid + else + lo = mid + 1 + end + end + a:insert(lo, x) + return q +end + +local function order(items) + local ordered = {} + local q = 0 + for items as item do + q = insort_right(ordered, item, q) + end + return ordered +end + +local items = "violet red green indigo blue yellow orange":split(" ") +local ordered = order(items) +print("\nThe colors of the rainbow, in sorted order, are:") +fmt.lprint(ordered) diff --git a/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-1.pro b/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-1.pro new file mode 100644 index 0000000000..afde62e867 --- /dev/null +++ b/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-1.pro @@ -0,0 +1,12 @@ +ask_sort(List, Sorted) :- predsort(ask, List, Sorted). + +ask(Cmp, Left, Right) :- + format("Comparing ~w with ~w: ", [Left, Right]), + get_single_char(Cmp0), + char_code(Cmp1, Cmp0), + ( memberchk(Cmp1, [<, =, >]) + -> Cmp = Cmp1, + writeln(Cmp1) + ; format("Please answer <, = or >."), + ask(Cmp, Left, Right) + ). diff --git a/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-2.pro b/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-2.pro new file mode 100644 index 0000000000..4603eb6939 --- /dev/null +++ b/Task/Order-by-pair-comparisons/Prolog/order-by-pair-comparisons-2.pro @@ -0,0 +1,15 @@ +?- ask_sort(["violet", "red", "green", "indigo", "blue", "yellow", "orange"], Sorted). +Comparing red with green: < +Comparing violet with red: > +Comparing violet with green: > +Comparing indigo with blue: > +Comparing yellow with orange: > +Comparing blue with orange: > +Comparing blue with yellow: > +Comparing red with orange: < +Comparing green with orange: > +Comparing green with yellow: > +Comparing green with blue: < +Comparing violet with blue: > +Comparing violet with indigo: > +Sorted = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]. diff --git a/Task/Order-two-numerical-lists/DuckDB/order-two-numerical-lists.duckdb b/Task/Order-two-numerical-lists/DuckDB/order-two-numerical-lists.duckdb new file mode 100644 index 0000000000..f1f10753c0 --- /dev/null +++ b/Task/Order-two-numerical-lists/DuckDB/order-two-numerical-lists.duckdb @@ -0,0 +1,3 @@ +select [1,2,3] < [1,2,3,4]; +select [1,2,3] < [1,2,4]; +select [1,2,3] < [1,2,3]; diff --git a/Task/Ordered-words/DuckDB/ordered-words.duckdb b/Task/Ordered-words/DuckDB/ordered-words.duckdb new file mode 100644 index 0000000000..e143274fd4 --- /dev/null +++ b/Task/Ordered-words/DuckDB/ordered-words.duckdb @@ -0,0 +1,20 @@ +create or replace function is_sorted(str) as ( + select not exists ( + from (select (c > (lead(c) over ())) as outoforder + from (select unnest(regexp_extract_all(str, '.')) as c)) + where outoforder = true ) +); + +create or replace function longest_ordered_words(file) as table ( + with words as ( + from read_csv_auto( + file, header=false, sep='', quote='', columns={'word': VARCHAR}) + where is_sorted(word)), + mx as (select max(length(word)) as mx from words) + select word + from words, mx + where length(word) = mx + order by word +); + +from longest_ordered_words('unixdict.txt'); diff --git a/Task/Ordered-words/TAV/ordered-words.tav b/Task/Ordered-words/TAV/ordered-words.tav new file mode 100644 index 0000000000..62e3dc8217 --- /dev/null +++ b/Task/Ordered-words/TAV/ordered-words.tav @@ -0,0 +1,20 @@ +main(params):+ + res =: [] \ to hold the words + maxw =: 0 \ maximum wordlength + ?# w =: file 'unixdict.txt' give lines + fault w print stop \ message and stop if error + ? (is ordered w) & w.count >= maxw + ? w.count > maxw \ longer word, + res =: [] \ reset list + res[] =: w \ store at next index in list + maxw =: w.count \ update + print row res join values by ' ' + +\ check word (w) +is ordered (w): + cc =: ' ' \ smallest character + ?# i =: from 1 upto w.count + ? w[i] < cc + :> ?- \ failed + cc =: w[i] + :> ?+ diff --git a/Task/Own-digits-power-sum/Scheme/own-digits-power-sum.scm b/Task/Own-digits-power-sum/Scheme/own-digits-power-sum.scm new file mode 100644 index 0000000000..dfd1ebffcf --- /dev/null +++ b/Task/Own-digits-power-sum/Scheme/own-digits-power-sum.scm @@ -0,0 +1,46 @@ +; checks if all characters in numbers lst1 and lst2 (coverted to lists) are the same + + (define (check_list lst1 lst2) + ; do checks each car of remaining list for equality with char=? + (do ((remaining lst1 (cdr remaining)) + (remaining2 lst2 (cdr remaining2)) + (final-val #t (char=? (car remaining) (car remaining2))) + ) + ( (or (equal? #f final-val) (null? remaining)) + (if (equal? #f final-val) + #f + #t + )) + )) + + ; main function to check +(define (own_pow x) + (let* ( + (test x) + ; length of x as a string + (len (string-length (number->string x))) + ; powers of digits + (powers (apply + (map (lambda (x) (expt x len)) (map string->number (map string (string->list (number->string x) )))))) + ; powers as list of characters + (res (string->list (number->string powers))) + ) + ; checks if sum of powers and the number have the same length as strings + (if (= len (length (string->list (number->string powers)))) + ; if true goes to function check_list + (if (check_list (string->list (number->string x)) res) + #t + #f + ) + #f + ) + ) + ) + +(define limit 10000000) +; loop from 100 to limit + (let loop ((i 100)) + (cond ((<= limit i) 'ok) + (else (if (own_pow i) + (print i) + ) + (loop (+ i 1))))) diff --git a/Task/Padovan-sequence/Julia/padovan-sequence.jl b/Task/Padovan-sequence/Julia/padovan-sequence-1.jl similarity index 92% rename from Task/Padovan-sequence/Julia/padovan-sequence.jl rename to Task/Padovan-sequence/Julia/padovan-sequence-1.jl index 49bbf54add..9767436280 100644 --- a/Task/Padovan-sequence/Julia/padovan-sequence.jl +++ b/Task/Padovan-sequence/Julia/padovan-sequence-1.jl @@ -1,5 +1,5 @@ """ Recursive Padovan """ -rPadovan(n) = (n < 4) ? one(n) : rPadovan(n - 3) + rPadovan(n - 2) +rPadovan(n) = (n < 4) ? oneunit(n) : rPadovan(n - 3) + rPadovan(n - 2) """ Floor function calculation Padovan """ function fPadovan(n)::Int diff --git a/Task/Padovan-sequence/Julia/padovan-sequence-2.jl b/Task/Padovan-sequence/Julia/padovan-sequence-2.jl new file mode 100644 index 0000000000..80958cc378 --- /dev/null +++ b/Task/Padovan-sequence/Julia/padovan-sequence-2.jl @@ -0,0 +1 @@ +padovan(n) = last(BigInt[0 1 1; 1 0 0; 0 1 0] ^ n * BigInt[1, 1, 1]) diff --git a/Task/Padovan-sequence/Phix/padovan-sequence-2.phix b/Task/Padovan-sequence/Phix/padovan-sequence-2.phix index ef5ba05ff2..31a9a813a4 100644 --- a/Task/Padovan-sequence/Phix/padovan-sequence-2.phix +++ b/Task/Padovan-sequence/Phix/padovan-sequence-2.phix @@ -1,49 +1,61 @@ -from math import floor -from collections import deque -from typing import Dict, Generator +%! padovan_recurrent(-P) is multi. +padovan_recurrent(1). +padovan_recurrent(1). +padovan_recurrent(P) :- padovan_recurrent(1, 1, 1, P). +padovan_recurrent( _, _, P , P). +padovan_recurrent(P0, P1, P2, P) :- P3 is P0 + P1, padovan_recurrent(P1, P2, P3, P). -def padovan_r() -> Generator[int, None, None]: - last = deque([1, 1, 1], 4) - while True: - last.append(last[-2] + last[-3]) - yield last.popleft() +%! padovan_truncated(+N, -P) is det. +padovan_truncated(N, P) :- + P is floor(1.324717957244746 ^ (N - 1) / 1.0453567932525329623 + 0.5). -_p, _s = 1.324717957244746025960908854, 1.0453567932525329623 +padovan_l_system(['B' | LS]) --> ['A'], padovan_l_system(LS). +padovan_l_system(['C' | LS]) --> ['B'], padovan_l_system(LS). +padovan_l_system(['A', 'B' | LS]) --> ['C'], padovan_l_system(LS). +padovan_l_system([]) --> []. -def padovan_f(n: int) -> int: - return floor(_p**(n-1) / _s + .5) +fibonacci_l_system(['B' | LS]) --> ['A'], fibonacci_l_system(LS). +fibonacci_l_system(['A', 'B' | LS]) --> ['B'], fibonacci_l_system(LS). +fibonacci_l_system([]) --> []. -def padovan_l(start: str='A', - rules: Dict[str, str]=dict(A='B', B='C', C='AB') - ) -> Generator[str, None, None]: - axiom = start - while True: - yield axiom - axiom = ''.join(rules[ch] for ch in axiom) +l_system(_, String, String). +l_system(DCG, String0, String) :- + once(phrase(call(DCG, String1), String0)), + l_system(DCG, String1, String). +:- meta_predicate l_system(3, -). +%! l_system(:DCG, +String) is multi. +l_system(DCG, String) :- l_system(DCG, ['A'], String). -if __name__ == "__main__": - from itertools import islice +task :- + format("The first 20 Padovan numbers are:~n"), + foreach( + limit(20, padovan_recurrent(Padovan)), + format("~d ", [Padovan]) + ), + format("~nThe first 10 strings produced by the L-system are:~n"), + foreach( + limit(10, l_system(padovan_l_system, LString)), + format("~s ", [LString]) + ), + nl, + run_tests(padovan_sequence). - print("The first twenty terms of the sequence.") - print(str([padovan_f(n) for n in range(20)])[1:-1]) +:- begin_tests(padovan_sequence). - r_generator = padovan_r() - if all(next(r_generator) == padovan_f(n) for n in range(64)): - print("\nThe recurrence and floor based algorithms match to n=63 .") - else: - print("\nThe recurrence and floor based algorithms DIFFER!") +test(recurrence_and_floor_are_same_sequence) :- + once(findnsols(64, PR, padovan_recurrent(PR), PRs)), + numlist(0, 63, Ns), + maplist(padovan_truncated, Ns, PTs), + assertion(PRs == PTs). - print("\nThe first 10 L-system string-lengths and strings") - l_generator = padovan_l(start='A', rules=dict(A='B', B='C', C='AB')) - print('\n'.join(f" {len(string):3} {repr(string)}" - for string in islice(l_generator, 10))) +test(lengths_of_first_32_strings_is_Padovan_sequence) :- + once(findnsols(32, PR, padovan_recurrent(PR), PRs)), + once(findnsols(32, PL, ( + l_system(padovan_l_system, String), + length(String, PL) + ), PLs)), + assertion(PRs == PLs). - r_generator = padovan_r() - l_generator = padovan_l(start='A', rules=dict(A='B', B='C', C='AB')) - if all(len(next(l_generator)) == padovan_f(n) == next(r_generator) - for n in range(32)): - print("\nThe L-system, recurrence and floor based algorithms match to n=31 .") - else: - print("\nThe L-system, recurrence and floor based algorithms DIFFER!") +:- end_tests(padovan_sequence). diff --git a/Task/Padovan-sequence/Phix/padovan-sequence-3.phix b/Task/Padovan-sequence/Phix/padovan-sequence-3.phix index 28d825fdf7..ef5ba05ff2 100644 --- a/Task/Padovan-sequence/Phix/padovan-sequence-3.phix +++ b/Task/Padovan-sequence/Phix/padovan-sequence-3.phix @@ -1,136 +1,49 @@ -'''Padovan series''' - -from itertools import chain, islice from math import floor -from operator import eq +from collections import deque +from typing import Dict, Generator -# padovans :: [Int] -def padovans(): - '''Non-finite series of Padovan numbers, - defined in terms of recurrence relations. - ''' - def recurrence(abc): - a, b, c = abc - return a, (b, c, a + b) +def padovan_r() -> Generator[int, None, None]: + last = deque([1, 1, 1], 4) + while True: + last.append(last[-2] + last[-3]) + yield last.popleft() - return unfoldr(recurrence)( - (1, 1, 1) - ) +_p, _s = 1.324717957244746025960908854, 1.0453567932525329623 + +def padovan_f(n: int) -> int: + return floor(_p**(n-1) / _s + .5) + +def padovan_l(start: str='A', + rules: Dict[str, str]=dict(A='B', B='C', C='AB') + ) -> Generator[str, None, None]: + axiom = start + while True: + yield axiom + axiom = ''.join(rules[ch] for ch in axiom) -# padovanFloor :: [Int] -def padovanFloor(): - '''The Padovan series, defined in terms - of a floor function. - ''' - p = 1.324717957244746025960908854 - s = 1.0453567932525329623 +if __name__ == "__main__": + from itertools import islice - def f(n): - return floor(p ** (n - 1) / s + 0.5), 1 + n + print("The first twenty terms of the sequence.") + print(str([padovan_f(n) for n in range(20)])[1:-1]) - return unfoldr(f)(0) + r_generator = padovan_r() + if all(next(r_generator) == padovan_f(n) for n in range(64)): + print("\nThe recurrence and floor based algorithms match to n=63 .") + else: + print("\nThe recurrence and floor based algorithms DIFFER!") + print("\nThe first 10 L-system string-lengths and strings") + l_generator = padovan_l(start='A', rules=dict(A='B', B='C', C='AB')) + print('\n'.join(f" {len(string):3} {repr(string)}" + for string in islice(l_generator, 10))) -# padovanLSystem : [Int] -def padovanLSystem(): - '''An L-system generating terms whose lengths - are the values of the Padovan integer series. - ''' - def rule(c): - return 'B' if 'A' == c else ( - 'C' if 'B' == c else 'AB' - ) - - def f(s): - return s, ''.join(list(concatMap(rule)(s))) - - return unfoldr(f)('A') - - -# ------------------------- TEST ------------------------- - -# prefixesMatch :: [a] -> [a] -> Bool -def prefixesMatch(xs, ys, n): - '''True if the first n items of each - series are the same. - ''' - return all(map(eq, take(n)(xs), ys)) - - -# main :: IO () -def main(): - '''Test three Padovan functions for - equivalence and expected results. - ''' - print('\n'.join([ - "First 20 padovans:\n", - repr(take(20)(padovans())), - - "\nThe recurrence and floor-based functions" + ( - " match over 64 terms:\n" - ), - repr(prefixesMatch( - padovans(), - padovanFloor(), - 64 - )), - - "\nFirst 10 L-System strings:\n", - repr(take(10)(padovanLSystem())), - - "\nThe lengths of the first 32 L-System strings", - "match the Padovan sequence:\n", - repr(prefixesMatch( - padovans(), - (len(x) for x in padovanLSystem()), - 32 - )) - ])) - - -# ----------------------- GENERIC ------------------------ - -# concatMap :: (a -> [b]) -> [a] -> [b] -def concatMap(f): - '''A concatenated map''' - def go(xs): - return chain.from_iterable(map(f, xs)) - return go - - -# unfoldr :: (b -> Maybe (a, b)) -> b -> [a] -def unfoldr(f): - '''A lazy (generator) list unfolded from a seed value - by repeated application of f until no residue remains. - Dual to fold/reduce. - f returns either None, or just (value, residue). - For a strict output list, wrap the result with list() - ''' - def go(x): - valueResidue = f(x) - while None is not valueResidue: - yield valueResidue[0] - valueResidue = f(valueResidue[1]) - return go - - -# take :: Int -> [a] -> [a] -# take :: Int -> String -> String -def take(n): - '''The prefix of xs of length n, - or xs itself if n > length xs. - ''' - def go(xs): - return ( - xs[0:n] - if isinstance(xs, (list, tuple)) - else list(islice(xs, n)) - ) - return go - - -# MAIN --- -if __name__ == '__main__': - main() + r_generator = padovan_r() + l_generator = padovan_l(start='A', rules=dict(A='B', B='C', C='AB')) + if all(len(next(l_generator)) == padovan_f(n) == next(r_generator) + for n in range(32)): + print("\nThe L-system, recurrence and floor based algorithms match to n=31 .") + else: + print("\nThe L-system, recurrence and floor based algorithms DIFFER!") diff --git a/Task/Padovan-sequence/Phix/padovan-sequence-4.phix b/Task/Padovan-sequence/Phix/padovan-sequence-4.phix new file mode 100644 index 0000000000..28d825fdf7 --- /dev/null +++ b/Task/Padovan-sequence/Phix/padovan-sequence-4.phix @@ -0,0 +1,136 @@ +'''Padovan series''' + +from itertools import chain, islice +from math import floor +from operator import eq + + +# padovans :: [Int] +def padovans(): + '''Non-finite series of Padovan numbers, + defined in terms of recurrence relations. + ''' + def recurrence(abc): + a, b, c = abc + return a, (b, c, a + b) + + return unfoldr(recurrence)( + (1, 1, 1) + ) + + +# padovanFloor :: [Int] +def padovanFloor(): + '''The Padovan series, defined in terms + of a floor function. + ''' + p = 1.324717957244746025960908854 + s = 1.0453567932525329623 + + def f(n): + return floor(p ** (n - 1) / s + 0.5), 1 + n + + return unfoldr(f)(0) + + +# padovanLSystem : [Int] +def padovanLSystem(): + '''An L-system generating terms whose lengths + are the values of the Padovan integer series. + ''' + def rule(c): + return 'B' if 'A' == c else ( + 'C' if 'B' == c else 'AB' + ) + + def f(s): + return s, ''.join(list(concatMap(rule)(s))) + + return unfoldr(f)('A') + + +# ------------------------- TEST ------------------------- + +# prefixesMatch :: [a] -> [a] -> Bool +def prefixesMatch(xs, ys, n): + '''True if the first n items of each + series are the same. + ''' + return all(map(eq, take(n)(xs), ys)) + + +# main :: IO () +def main(): + '''Test three Padovan functions for + equivalence and expected results. + ''' + print('\n'.join([ + "First 20 padovans:\n", + repr(take(20)(padovans())), + + "\nThe recurrence and floor-based functions" + ( + " match over 64 terms:\n" + ), + repr(prefixesMatch( + padovans(), + padovanFloor(), + 64 + )), + + "\nFirst 10 L-System strings:\n", + repr(take(10)(padovanLSystem())), + + "\nThe lengths of the first 32 L-System strings", + "match the Padovan sequence:\n", + repr(prefixesMatch( + padovans(), + (len(x) for x in padovanLSystem()), + 32 + )) + ])) + + +# ----------------------- GENERIC ------------------------ + +# concatMap :: (a -> [b]) -> [a] -> [b] +def concatMap(f): + '''A concatenated map''' + def go(xs): + return chain.from_iterable(map(f, xs)) + return go + + +# unfoldr :: (b -> Maybe (a, b)) -> b -> [a] +def unfoldr(f): + '''A lazy (generator) list unfolded from a seed value + by repeated application of f until no residue remains. + Dual to fold/reduce. + f returns either None, or just (value, residue). + For a strict output list, wrap the result with list() + ''' + def go(x): + valueResidue = f(x) + while None is not valueResidue: + yield valueResidue[0] + valueResidue = f(valueResidue[1]) + return go + + +# take :: Int -> [a] -> [a] +# take :: Int -> String -> String +def take(n): + '''The prefix of xs of length n, + or xs itself if n > length xs. + ''' + def go(xs): + return ( + xs[0:n] + if isinstance(xs, (list, tuple)) + else list(islice(xs, n)) + ) + return go + + +# MAIN --- +if __name__ == '__main__': + main() diff --git a/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg b/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg index 0d7bcdafa8..4b9af86f42 100644 --- a/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg +++ b/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg @@ -2,8 +2,8 @@ PROC palindrome = (STRING s)BOOL:( FOR i TO UPB s OVER 2 DO IF s[i] /= s[UPB s-i+1] THEN GO TO return false FI - OD;Power - else: TRUE EXIT + OD; + TRUE EXIT return false: FALSE ); @@ -16,7 +16,6 @@ PROC palindrome r = (STRING s)BOOL: ; # Test # -main: ( STRING t = "ingirumimusnocteetconsumimurigni"; FORMAT template = $"sequence """g""" "b("is","isnt")" a palindrome"l$; diff --git a/Task/Palindrome-detection/DuckDB/palindrome-detection.duckdb b/Task/Palindrome-detection/DuckDB/palindrome-detection.duckdb new file mode 100644 index 0000000000..848be022a3 --- /dev/null +++ b/Task/Palindrome-detection/DuckDB/palindrome-detection.duckdb @@ -0,0 +1,31 @@ +# One way to create a reference to a string literal is by defining a DuckDB function: +D create or replace function s() as (select 'In girum imus nocte et consumimur igni'); + +D select reverse(s()); +┌────────────────────────────────────────┐ +│ reverse(s()) │ +│ varchar │ +├────────────────────────────────────────┤ +│ ingi rumimusnoc te etcon sumi murig nI │ +└────────────────────────────────────────┘ + +D create or replace function isPalindrome(s) as (SELECT REVERSE(s) = s); + +D select isPalindrome('pip'); +┌─────────────────────┐ +│ ispalindrome('pip') │ +│ boolean │ +├─────────────────────┤ +│ true │ +└─────────────────────┘ + +D create or replace function isQuasiPalindrome(str) as + (isPalindrome( (select regexp_replace(str, ' ', '', 'g')) )); + +D select isQuasiPalindrome('to be bot'); +┌────────────────────────────────┐ +│ isquasipalindrome('to be bot') │ +│ boolean │ +├────────────────────────────────┤ +│ true │ +└────────────────────────────────┘ diff --git a/Task/Palindrome-detection/Pluto/palindrome-detection.pluto b/Task/Palindrome-detection/Pluto/palindrome-detection.pluto new file mode 100644 index 0000000000..71143fae81 --- /dev/null +++ b/Task/Palindrome-detection/Pluto/palindrome-detection.pluto @@ -0,0 +1,7 @@ +function is_palindrome(s) + return s == s:reverse() +end + +print(is_palindrome('rotor')) +print(is_palindrome('racecar')) +print(is_palindrome('rosetta')) diff --git a/Task/Pancake-numbers/Free-Pascal-Lazarus/pancake-numbers.pas b/Task/Pancake-numbers/Free-Pascal-Lazarus/pancake-numbers.pas new file mode 100644 index 0000000000..2a8944a07d --- /dev/null +++ b/Task/Pancake-numbers/Free-Pascal-Lazarus/pancake-numbers.pas @@ -0,0 +1,31 @@ +program pc; + +function pancake(n:integer):integer; +var + gap, sum, adj:integer; +begin + gap := 2; + sum := 2; + adj := -1; + while sum < n do + begin + inc(adj); + gap := gap*2 - 1; + sum := sum + gap; + end; + pancake := n + adj; +end; + +var + i,j,n:integer; +begin + for i := 0 to 3 do + begin + for j := 1 to 5 do + begin + n := i*5 + j; + writeln('p',n:2,pancake(n):5); + end; + writeln; + end +end. diff --git a/Task/Pancake-numbers/FreeBASIC/pancake-numbers.basic b/Task/Pancake-numbers/FreeBASIC/pancake-numbers-1.basic similarity index 100% rename from Task/Pancake-numbers/FreeBASIC/pancake-numbers.basic rename to Task/Pancake-numbers/FreeBASIC/pancake-numbers-1.basic diff --git a/Task/Pancake-numbers/FreeBASIC/pancake-numbers-2.basic b/Task/Pancake-numbers/FreeBASIC/pancake-numbers-2.basic new file mode 100644 index 0000000000..ab2bdc910f --- /dev/null +++ b/Task/Pancake-numbers/FreeBASIC/pancake-numbers-2.basic @@ -0,0 +1,105 @@ +' Reverses the first k elements of a string +Function flipString(s As String, k As Integer) As String + Dim As String res = "" + For i As Integer = k To 1 Step -1 + res &= Mid(s, i, 1) + Next + res &= Mid(s, k + 1) + Return res +End Function + +' Calculate the lexicographic rank of a permutation +Function permutationRank(s As String, n As Integer, fact() As Integer) As Integer + Dim As Integer rank = 0 + For i As Integer = 0 To n - 2 + Dim As Integer cnt = 0 + For j As Integer = i + 1 To n - 1 + If Mid(s, j + 1, 1) < Mid(s, i + 1, 1) Then cnt += 1 + Next + rank += cnt * fact(n - i - 1) + Next + Return rank +End Function + +' Calculate the maximum number of flips for n elements +Sub pancakeNumber(n As Integer) + Dim As Integer i + ' Pre-calculate factorials + Dim As Integer fact(0 To n) + fact(0) = 1 + For i = 1 To n: fact(i) = fact(i - 1) * i: Next + + Dim As Integer totalStates = fact(n) + Dim As Boolean visited(0 To totalStates - 1) + Dim As Integer dist(0 To totalStates - 1) + Dim As String permString(0 To totalStates - 1) + + ' Initial state: ordered permutation + Dim As String start = "" + For i = 1 To n: start &= Str(i): Next + + Dim As Integer startRank = permutationRank(start, n, fact()) + visited(startRank) = True + dist(startRank) = 0 + permString(startRank) = start + + Dim As String queue(0 To totalStates - 1) + Dim As Integer head = 0, tail = 0 + queue(tail) = start + tail += 1 + + ' BFS (Breadth-First Search) to determine the maximum distance from any permutation to the ordinate + While head < tail + Dim As String p = queue(head) + head += 1 + Dim As Integer currentRank = permutationRank(p, n, fact()) + + ' Generar todos los flips posibles + ' Generate all possible flips + For i As Integer = 2 To n + Dim As String q = flipString(p, i) + Dim As Integer r = permutationRank(q, n, fact()) + + If Not visited(r) Then + visited(r) = True + dist(r) = dist(currentRank) + 1 + permString(r) = q + queue(tail) = q + tail += 1 + End If + Next + Wend + + ' Find the maximum distance + Dim As Integer maxDist = 0 + Dim As String maxPerm = "" + For i = 0 To totalStates - 1 + If visited(i) Andalso dist(i) > maxDist Then + maxDist = dist(i) + maxPerm = permString(i) + End If + Next + + ' If no permutation was found (case n=1), use the ordinate + If Len(maxPerm) = 0 Then + For i = 1 To n: maxPerm &= Str(i): Next + End If + + Print Using "Maximum number of flips to sort # elements is ##_. e.g ["; n; maxDist; + For i = 1 To Len(maxPerm) + If i > 1 Then Print "; "; + Print Mid(maxPerm, i, 1); + Next + Print "] -> ["; + For i = 1 To n + If i > 1 Then Print "; "; + Print Str(i); + Next + Print "]" +End Sub + +For n As Integer = 1 To 9 + pancakeNumber(n) +Next + +Sleep diff --git a/Task/Pancake-numbers/Julia/pancake-numbers-1.jl b/Task/Pancake-numbers/Julia/pancake-numbers-1.jl deleted file mode 100644 index aec090ebde..0000000000 --- a/Task/Pancake-numbers/Julia/pancake-numbers-1.jl +++ /dev/null @@ -1,14 +0,0 @@ -function pancake(len) - gap, gapsum, adj = 2, 2, -1 - while gapsum < len - adj += 1 - gap = gap * 2 - 1 - gapsum += gap - end - return len + adj -end - -for i in 1:25 - print("pancake(", lpad(i, 2), ") = ", rpad(pancake(i), 5)) - i % 5 == 0 && println() -end diff --git a/Task/Pancake-numbers/Julia/pancake-numbers-2.jl b/Task/Pancake-numbers/Julia/pancake-numbers.jl similarity index 100% rename from Task/Pancake-numbers/Julia/pancake-numbers-2.jl rename to Task/Pancake-numbers/Julia/pancake-numbers.jl diff --git a/Task/Pancake-numbers/Phix/pancake-numbers-4.phix b/Task/Pancake-numbers/Phix/pancake-numbers-4.phix new file mode 100644 index 0000000000..ab55eb78b0 --- /dev/null +++ b/Task/Pancake-numbers/Phix/pancake-numbers-4.phix @@ -0,0 +1,90 @@ +with javascript_semantics +function permuten(integer i, bool bFinal=true) + -- generate base i+1 representations of the permutes of tagset(i), + -- eg i=3 -> {0(4)123,0(4)132,0(4)213,0(4)231,0(4)312,0(4)321} + -- which in decimal would look like this: {27,30,39,45,54,57} + -- if bFinal is false (internal/recursive use) each element of + -- res is instead a sequence of the individual base i+1 digits. + if i=1 then return iff(bFinal?{1}:{{1}}) end if -- (nb i>0 only) + sequence s = permuten(i-1,false), res = {}, r = repeat(0,i) + integer base = i+1 + for k=1 to i do + r[1] = k + for si in s do + for j=2 to i do + integer sj = si[j-1] + r[j] = sj+(sj>=k) + end for + if bFinal then + atom rd = 0 + for d=1 to i do + rd = rd*base + r[d] + end for + res &= rd + else + res = append(res,deep_copy(r)) + end if + end for + end for + return res +end function + +function flip_base(atom n, integer i, base) + -- flip first i digits of n in specified base, + -- eg 0(11)123456789a,2,11 => 0(11)213456789a + -- aside: round() needed for 64-bit, else + -- eg 11^8 is out by ~5e-11 + atom p = round(power(base,base-i-1)), + h = floor(n/p), r = 0 + for i=1 to i do + r = r*base + rmdr(h,base) + h = floor(h/base) + end for + return r*p+rmdr(n,p) -- (eg 21<1 and flips[fdx]=0 then + flips[fdx] = ft + tdx += 1 + todo[tdx] = fdx + if time()>t1 then + printf(1,"%d/%d...\r",{tdx,length(p)}) + t1 = time()+1 + end if + end if + end for + end for + integer max_flips = largest(flips,return_index:=true) + return {n,flips[max_flips],sprintf("%a",{{base,p[max_flips]}})} +-- return {n,flips[max_flips],p[max_flips]} +end function + +atom t0 = time() +for n=1 to 10 do + printf(1,"pancake(%d):%d, eg %v\n",pancake(n)) +end for +?elapsed(time()-t0) diff --git a/Task/Pancake-numbers/Pluto/pancake-numbers-1.pluto b/Task/Pancake-numbers/Pluto/pancake-numbers-1.pluto new file mode 100644 index 0000000000..61f49ad0dc --- /dev/null +++ b/Task/Pancake-numbers/Pluto/pancake-numbers-1.pluto @@ -0,0 +1,22 @@ +local fmt = require "fmt" + +local function pancake(n) + local gap = 2 + local pg = 1 + local sum_gaps = gap + local adj = -1 + while sum_gaps < n do + ++adj + pg, gap = gap, gap + pg + sum_gaps += gap + end + return n + adj +end + +for i = 0, 3 do + for j = 1, 5 do + local n = i * 5 + j + fmt.write("p(%2d) = %2d ", n, pancake(n)) + end + print() +end diff --git a/Task/Pancake-numbers/Pluto/pancake-numbers-2.pluto b/Task/Pancake-numbers/Pluto/pancake-numbers-2.pluto new file mode 100644 index 0000000000..46e7867776 --- /dev/null +++ b/Task/Pancake-numbers/Pluto/pancake-numbers-2.pluto @@ -0,0 +1,63 @@ +local fmt = require "fmt" + +-- Converts a string of the form "{1, 2}" into an array: {1, 2} +local function as_array(s) + local split = s:sub(2, -2):split(", ") + return split:map(|ss| -> tonumber(ss)) +end + +-- Merges two maps into one. If the same key is present in both maps +-- its value will be the one in the second map. +local function merge_maps(m1, m2) + local m3 = {} + for k, v in m1 do m3[k] = v end + for k, v in m2 do m3[k] = v end + return m3 +end + +-- Finds the maximum value in 'dict' and returns the first key +-- it finds (iteration order is undefined) with that value. +local function find_max(dict) + local max = -1 + local max_key = nil + for k, v in dict do + if v > max then + max = v + max_key = k + end + end + return max_key +end + +local function pancake(len) + local num_stacks = 1 + local goal_stack = fmt.swrite(range(1, len)) + local stacks = {[goal_stack] = 0} + local new_stacks = {[goal_stack] = 0} + for i = 1, 1000 do + local next_stacks = {} + for new_stacks:keys() as key do + local arr = as_array(key) + local pos = 2 + while pos <= len do + local new_stack = arr:slice(1, pos):reverse() + table.move(arr, pos + 1, #arr, pos + 1, new_stack) + new_stack = fmt.swrite(new_stack) + if !stacks[new_stack] then next_stacks[new_stack] = i end + ++pos + end + end + new_stacks = next_stacks + stacks = merge_maps(stacks, new_stacks) + local perms = stacks:size() + if perms == num_stacks then + return {find_max(stacks), i - 1} + end + num_stacks = perms + end +end + +for i = 1, 9 do + local [example, steps] = pancake(i) + fmt.print("pancake(%d) = %-2d example: %s", i, steps, example) +end diff --git a/Task/Pancake-numbers/Pluto/pancake-numbers-3.pluto b/Task/Pancake-numbers/Pluto/pancake-numbers-3.pluto new file mode 100644 index 0000000000..da8732a959 --- /dev/null +++ b/Task/Pancake-numbers/Pluto/pancake-numbers-3.pluto @@ -0,0 +1,51 @@ +local fmt = require "fmt" +require "queue" + +-- Flip the stack of pancakes at the given position. +local function flip(pancakes, pos) + local s = tostring(pancakes) + return tonumber(s:sub(1, pos):reverse() .. s:sub(pos + 1)) +end + +-- Finds the maximum value in 'map' and returns the first key +-- it finds (iteration order is undefined) with that value +-- and the value itself. +local function find_max(map) + local max = -1 + local max_key = nil + for k, v in map do + if v > max then + max = v + max_key = k + end + end + return {max_key, max} +end + +-- Return the nth pancake number. +local function pancake(n) + local init_stack = tonumber(range(1, n):concat("")) + local stack_flips = {[init_stack] = 0} + local queue = new queue() + queue:push(init_stack) + while !queue:empty() do + local stack = queue:pop() + local flips = stack_flips[stack] + 1 + for i = 2, n do + local flipped = flip(stack, i) + if !stack_flips[flipped] then + stack_flips[flipped] = flips + queue:push(flipped) + end + end + end + return find_max(stack_flips) +end + +for n = 1, 9 do + local [pancakes, p] = pancake(n) + local t = {} + for c in tostring(pancakes):gmatch("%d") do t:insert(c) end + pancakes = "{" .. t:concat(", ") .. "}" + fmt.print("pancake(%d) = %-2d example: %s", n, p, pancakes) +end diff --git a/Task/Pancake-numbers/Pluto/pancake-numbers-4.pluto b/Task/Pancake-numbers/Pluto/pancake-numbers-4.pluto new file mode 100644 index 0000000000..f4a9274865 --- /dev/null +++ b/Task/Pancake-numbers/Pluto/pancake-numbers-4.pluto @@ -0,0 +1,55 @@ +local fmt = require "fmt" +require "queue" + +-- Flip the stack of pancakes at the given position. +local function flip(pancakes, pos, n) + local s = tostring(pancakes) + if n == 10 and #s == 9 do s = "0" .. s end + return tonumber(s:sub(1, pos):reverse() .. s:sub(pos + 1)) +end + +-- Finds the maximum value in 'map' and returns the first key +-- it finds (iteration order is undefined) with that value +-- and the value itself. +local function find_max(map) + local max = -1 + local max_key = nil + for k, v in map do + if v > max then + max = v + max_key = k + end + end + return {max_key, max} +end + +-- Return the nth pancake number. +local function pancake(n) + local init_stack = n < 10 ? tonumber(range(1, n):concat("")) : + tonumber(range(1, 9):concat("")) .. "0" + local stack_flips = {[init_stack] = 0} + local queue = new queue() + queue:push(init_stack) + while !queue:empty() do + local stack = queue:pop() + local flips = stack_flips[stack] + 1 + for i = 2, n do + local flipped = flip(stack, i, n) + if !stack_flips[flipped] then + stack_flips[flipped] = flips + queue:push(flipped) + end + end + end + return find_max(stack_flips) +end + +for n = 1, 10 do + local [pancakes, p] = pancake(n) + local t = {} + for c in tostring(pancakes):gmatch("%d") do t:insert(c) end + if n == 10 and #t == 9 then t:insert(1, "0") end + pancakes = "{" .. t:concat(", ") .. "}" + pancakes = pancakes:replace("0", "10") + fmt.print("pancake(%2d) = %-2d example: %s", n, p, pancakes) +end diff --git a/Task/Pancake-numbers/Ruby/pancake-numbers-1.rb b/Task/Pancake-numbers/Ruby/pancake-numbers-1.rb new file mode 100644 index 0000000000..ec6609f336 --- /dev/null +++ b/Task/Pancake-numbers/Ruby/pancake-numbers-1.rb @@ -0,0 +1,26 @@ +def pancake(n) + init = (1..n).to_a + stack_flips = { init => 0 } + queue = [init] + + until queue.empty? + # NOTE: Ruby does not reallocate the entire array for every call to `shift`. + stack = queue.shift + flips = stack_flips[stack] + 1 + + (2..n).each do |i| + flipped = [*stack[...i].reverse, *stack[i..]] + unless stack_flips.key?(flipped) + stack_flips[flipped] = flips + queue.push(flipped) + end + end + end + + stack_flips.max_by { |_, v| v } +end + +(1...10).each do |n| + pancakes, p = pancake(n) + printf("pancake(%d) = %2d. Example %s\n", n, p, pancakes) +end diff --git a/Task/Pancake-numbers/Ruby/pancake-numbers-2.rb b/Task/Pancake-numbers/Ruby/pancake-numbers-2.rb new file mode 100644 index 0000000000..9ed4e7af66 --- /dev/null +++ b/Task/Pancake-numbers/Ruby/pancake-numbers-2.rb @@ -0,0 +1,22 @@ +def pancake(n) + gap = 2 + pg = 1 + sum = 2 + adj = -1 + while sum < n + adj = adj + 1 + t = pg + pg = gap + gap = gap + t + sum = sum + gap + end + return n + adj +end + +for i in 0..3 + for j in 1..5 + n = i * 5 + j + print "p(%2d) = %2d " % [n, pancake(n)] + end + print "\n" +end diff --git a/Task/Pancake-numbers/Ruby/pancake-numbers.rb b/Task/Pancake-numbers/Ruby/pancake-numbers.rb deleted file mode 100644 index 3f3e3dbe1a..0000000000 --- a/Task/Pancake-numbers/Ruby/pancake-numbers.rb +++ /dev/null @@ -1,19 +0,0 @@ -def pancake(n) - gap = 2 - sum = 2 - adj = -1 - while sum < n - adj = adj + 1 - gap = gap * 2 - 1 - sum = sum + gap - end - return n + adj -end - -for i in 0 .. 3 - for j in 1 .. 5 - n = i * 5 + j - print "p(%2d) = %2d " % [n, pancake(n)] - end - print "\n" -end diff --git a/Task/Pancake-numbers/Wren/pancake-numbers-1.wren b/Task/Pancake-numbers/Wren/pancake-numbers-1.wren index 0cf934127d..a066f24a3a 100644 --- a/Task/Pancake-numbers/Wren/pancake-numbers-1.wren +++ b/Task/Pancake-numbers/Wren/pancake-numbers-1.wren @@ -2,12 +2,15 @@ import "./fmt" for Fmt var pancake = Fn.new { |n| var gap = 2 - var sum = 2 + var pg = 1 + var sumGaps = gap var adj = -1 - while (sum < n) { + while (sumGaps < n) { adj = adj + 1 - gap = gap*2 - 1 - sum = sum + gap + var t = pg + pg = gap + gap = gap + t + sumGaps = sumGaps + gap } return n + adj } diff --git a/Task/Pancake-numbers/Wren/pancake-numbers-3.wren b/Task/Pancake-numbers/Wren/pancake-numbers-3.wren new file mode 100644 index 0000000000..997a6313b3 --- /dev/null +++ b/Task/Pancake-numbers/Wren/pancake-numbers-3.wren @@ -0,0 +1,86 @@ +import "./fmt" for Fmt + +class Queue { + construct new(limit) { + _limit = limit + _first = 0 + _last = -1 + _list = [] + } + + isEmpty { _first > _last } + + push(v) { + _last = _last + 1 + _list.add(v) + } + + // Doesn't actually remove the first element from the internal list. + // Just changes a pointer so that the next element (if any) becomes the first. + // However, when the number of popped elements reaches _limit, they are + // cleared out and the pointers reset. + pop() { + if (isEmpty) Fiber.abort("Queue is empty.") + var value = _list[_first] + _first = _first + 1 + if (_first == _limit) { + _list = _list[_first..-1] + _first = 0 + _last = _last - _limit + } + return value + } +} + +// Flip the stack of pancakes at the given position. +var flip = Fn.new { |pancakes, pos| + pancakes = pancakes.toString + return Num.fromString(pancakes[0...pos][-1..0] + pancakes[pos..-1]) +} + +// Finds the maximum value in 'map' and returns the first key +// it finds (iteration order is undefined) with that value +// and the value itself. +var findMax = Fn.new { |map| + var max = -1 + var maxKey = null + for (me in map) { + if (me.value > max) { + max = me.value + maxKey = me.key + } + } + return [maxKey, max] +} + +// Return the nth pancake number. +var pancake = Fn.new { |n| + var initStack = Num.fromString((1..n).join("")) + var stackFlips = { initStack: 0 } + var queue = Queue.new(100000) // say + queue.push(initStack) + while (!queue.isEmpty) { + var stack = queue.pop() + var flips = stackFlips[stack] + 1 + var i = 2 + while (i <= n) { + var flipped = flip.call(stack, i) + if (!stackFlips.containsKey(flipped)) { + stackFlips[flipped] = flips + queue.push(flipped) + } + i = i + 1 + } + } + return findMax.call(stackFlips) +} + +var start = System.clock +System.print("The maximum number of flips to sort a given number of elements is:") +for (n in 1..9) { + var res = pancake.call(n) + var pancakes = "[" + res[0].toString.map{ |c| c }.join(", ") + "]" + var p = res[1] + Fmt.print("pancake($d) = $-2d example: $n", n, p, pancakes) +} +System.print("\nTook %(System.clock - start) seconds.") diff --git a/Task/Pancake-numbers/Wren/pancake-numbers-4.wren b/Task/Pancake-numbers/Wren/pancake-numbers-4.wren new file mode 100644 index 0000000000..b257ee6379 --- /dev/null +++ b/Task/Pancake-numbers/Wren/pancake-numbers-4.wren @@ -0,0 +1,91 @@ +import "./fmt" for Fmt + +class Queue { + construct new(limit) { + _limit = limit + _first = 0 + _last = -1 + _list = [] + } + + isEmpty { _first > _last } + + push(v) { + _last = _last + 1 + _list.add(v) + } + + // Doesn't actually remove the first element from the internal list. + // Just changes a pointer so that the next element (if any) becomes the first. + // However, when the number of popped elements reaches _limit, they are + // cleared out and the pointers reset. + pop() { + if (isEmpty) Fiber.abort("Queue is empty.") + var value = _list[_first] + _first = _first + 1 + if (_first == _limit) { + _list = _list[_first..-1] + _first = 0 + _last = _last - _limit + } + return value + } +} + +// Flip the stack of pancakes at the given position. +var flip = Fn.new { |pancakes, pos, n| + pancakes = pancakes.toString + if (n == 10 && pancakes.count == 9) pancakes = "0" + pancakes + return Num.fromString(pancakes[0...pos][-1..0] + pancakes[pos..-1]) +} + +// Finds the maximum value in 'map' and returns the first key +// it finds (iteration order is undefined) with that value +// and the value itself. +var findMax = Fn.new { |map| + var max = -1 + var maxKey = null + for (me in map) { + if (me.value > max) { + max = me.value + maxKey = me.key + } + } + return [maxKey, max] +} + +// Return the nth pancake number. +var pancake = Fn.new { |n| + var initStack = n < 10 ? (1..n).join("") : (1..9).join("") + "0" + initStack = Num.fromString(initStack) + var stackFlips = { initStack: 0 } + var queue = Queue.new(100000) // say + queue.push(initStack) + while (!queue.isEmpty) { + var stack = queue.pop() + var flips = stackFlips[stack] + 1 + var i = 2 + while (i <= n) { + var flipped = flip.call(stack, i, n) + if (!stackFlips.containsKey(flipped)) { + stackFlips[flipped] = flips + queue.push(flipped) + } + i = i + 1 + } + } + return findMax.call(stackFlips) +} + +var start = System.clock +System.print("The maximum number of flips to sort a given number of elements is:") +for (n in 1..10) { + var res = pancake.call(n) + res[0] = res[0].toString.map{ |c| c }.toList + if (n == 10 && res[0].count == 9) res[0].insert(0, "0") + var pancakes = "[" + res[0].join(", ") + "]" + if (n == 10) pancakes = pancakes.replace("0", "10") + var p = res[1] + Fmt.print("pancake($2d) = $-2d example: $n", n, p, pancakes) +} +System.print("\nTook %(System.clock - start) seconds.") diff --git a/Task/Parameterized-SQL-statement/DuckDB/parameterized-sql-statement.duckdb b/Task/Parameterized-SQL-statement/DuckDB/parameterized-sql-statement.duckdb new file mode 100644 index 0000000000..d65ef43e9e --- /dev/null +++ b/Task/Parameterized-SQL-statement/DuckDB/parameterized-sql-statement.duckdb @@ -0,0 +1,17 @@ +# Setup +create or replace table players + (name VARCHAR, score INTEGER, active BOOLEAN, jerseyNum UINTEGER); + +insert into players values (NULL, NULL, NULL, 99); + +# Parameterized SQL +prepare update_players as + -- (name, score, active, jerseyNum) + UPDATE players + SET name = $1, score = $2, active = $3 + WHERE jerseyNum = $4 +; + +execute update_players('Lynx', 10, true, '99'); + +from players; diff --git a/Task/Parse-an-IP-Address/Dart/parse-an-ip-address.dart b/Task/Parse-an-IP-Address/Dart/parse-an-ip-address.dart new file mode 100644 index 0000000000..4845ebdd65 --- /dev/null +++ b/Task/Parse-an-IP-Address/Dart/parse-an-ip-address.dart @@ -0,0 +1,128 @@ +import 'dart:io'; + +class ParseIPAddress { + static final RegExp _ipv4Pat = RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+)(?::(\d+))?$'); + static final RegExp _ipv6DoubleColPat = RegExp(r'^\[?([0-9a-f:]*)::([0-9a-f:]*)(?:\]:(\d+))?$'); + static late final RegExp _ipv6Pat; + + static void _initializeIPv6Pattern() { + String ipv6Pattern = r'^\[?'; + for (int i = 1; i <= 7; i++) { + ipv6Pattern += r'([0-9a-f]+):'; + } + ipv6Pattern += r'([0-9a-f]+)(?:\]:(\d+))?$'; + _ipv6Pat = RegExp(ipv6Pattern); + } + + static void main() { + // Initialize the IPv6 pattern + _initializeIPv6Pattern(); + + List tests = [ + "192.168.0.1", + "127.0.0.1", + "256.0.0.1", + "127.0.0.1:80", + "::1", + "[::1]:80", + "[32e::12f]:80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80", + "2001:db8:85a3:0:0:8a2e:370:7334" + ]; + + print('${'Test Case'.padRight(40)} ${'Hex Address'.padRight(32)} Port'); + + for (String ip in tests) { + try { + List parsed = _parseIP(ip); + print('${ip.padRight(40)} ${parsed[0].padRight(32)} ${parsed[1]}'); + } catch (e) { + print('${ip.padRight(40)} Invalid address: ${e.toString()}'); + } + } + } + + static List _parseIP(String ip) { + String hex = ""; + String port = ""; + + // IPv4 + RegExpMatch? ipv4Match = _ipv4Pat.firstMatch(ip); + if (ipv4Match != null) { + for (int i = 1; i <= 4; i++) { + hex += _toHex4(ipv4Match.group(i)!); + } + if (ipv4Match.group(5) != null) { + port = ipv4Match.group(5)!; + } + return [hex, port]; + } + + // IPv6, double colon + RegExpMatch? ipv6DoubleColonMatch = _ipv6DoubleColPat.firstMatch(ip); + if (ipv6DoubleColonMatch != null) { + String p1 = ipv6DoubleColonMatch.group(1) ?? ""; + if (p1.isEmpty) { + p1 = "0"; + } + String p2 = ipv6DoubleColonMatch.group(2) ?? ""; + if (p2.isEmpty) { + p2 = "0"; + } + ip = p1 + _getZero(8 - _numCount(p1) - _numCount(p2)) + p2; + if (ipv6DoubleColonMatch.group(3) != null) { + ip = "[$ip]:${ipv6DoubleColonMatch.group(3)}"; + } + } + + // IPv6 + RegExpMatch? ipv6Match = _ipv6Pat.firstMatch(ip); + if (ipv6Match != null) { + for (int i = 1; i <= 8; i++) { + String hexPart = _toHex6(ipv6Match.group(i)!); + hex += hexPart.padLeft(4, '0'); + } + if (ipv6Match.group(9) != null) { + port = ipv6Match.group(9)!; + } + return [hex, port]; + } + + throw ArgumentError("ERROR 103: Unknown address: $ip"); + } + + static int _numCount(String s) { + return s.split(':').length; + } + + static String _getZero(int count) { + StringBuffer sb = StringBuffer(); + sb.write(":"); + while (count > 0) { + sb.write("0:"); + count--; + } + return sb.toString(); + } + + static String _toHex4(String s) { + int val = int.parse(s); + if (val < 0 || val > 255) { + throw ArgumentError("ERROR 101: Invalid value: $s"); + } + return val.toRadixString(16).toUpperCase().padLeft(2, '0'); + } + + static String _toHex6(String s) { + int val = int.parse(s, radix: 16); + if (val < 0 || val > 65536) { + throw ArgumentError("ERROR 102: Invalid hex value: $s"); + } + return s; + } +} + +void main() { + ParseIPAddress.main(); +} diff --git a/Task/Parse-an-IP-Address/Elixir/parse-an-ip-address.ex b/Task/Parse-an-IP-Address/Elixir/parse-an-ip-address.ex new file mode 100644 index 0000000000..bda1085cf3 --- /dev/null +++ b/Task/Parse-an-IP-Address/Elixir/parse-an-ip-address.ex @@ -0,0 +1,83 @@ +#!/usr/bin/env elixir + +defmodule IPParse do + @moduledoc """ + IP address parser that handles IPv4 and IPv6 addresses with optional ports + """ + + def main(args \\ []) do + addresses = if Enum.empty?(args), do: data(), else: args + + for addr <- addresses do + print(addr, parse(addr)) + end + + System.halt(0) + end + + @spec parse(String.t()) :: + {String.t(), binary(), String.t()} | + {String.t(), binary()} + def parse("[" <> addr0) do + case String.split(addr0, "]", parts: 2) do + [addr] -> + {"IPv6", to_hex(:inet.parse_address(String.to_charlist(addr)))} + + [addr, ":" <> port] -> + {"IPv6", to_hex(:inet.parse_address(String.to_charlist(addr))), port} + end + end + + def parse(addr0) do + case :inet.parse_address(String.to_charlist(addr0)) do + {:error, :einval} -> + [addr, port] = String.split(addr0, ":", parts: 2) + {"IPv4", to_hex(:inet.parse_address(String.to_charlist(addr))), port} + + {:ok, v6_addr} -> + {"IPv6", to_hex({:ok, v6_addr})} + end + end + + @spec to_hex({:ok, :inet.ip_address()}) :: binary() + def to_hex({:ok, {a, b, c, d}}) do + Base.encode16(<>) + end + + def to_hex({:ok, {a, b, c, d, e, f, g, h}}) do + Base.encode16(<>) + end + + def print(input, {family, hex, port}) do + IO.puts("Input: #{input}") + IO.puts("Family: #{family}") + IO.puts("Hex: #{hex}") + IO.puts("Port: #{port}") + IO.puts("") + end + + def print(input, {family, hex}) do + IO.puts("Input: #{input}") + IO.puts("Family: #{family}") + IO.puts("Hex: #{hex}") + IO.puts("") + end + + defp data do + [ + "127.0.0.1", + "127.0.0.1:80", + "::ffff:127.0.0.1", + "::1", + "[::1]:80", + "1::80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80" + ] + end +end + +# Run the main function if this script is executed directly +if __ENV__.file == Path.absname(:escript.script_name()) do + IPParse.main(System.argv()) +end diff --git a/Task/Parse-an-IP-Address/Fortran/parse-an-ip-address.f b/Task/Parse-an-IP-Address/Fortran/parse-an-ip-address.f new file mode 100644 index 0000000000..90429db2f4 --- /dev/null +++ b/Task/Parse-an-IP-Address/Fortran/parse-an-ip-address.f @@ -0,0 +1,320 @@ +program parse_ip_address + implicit none + + ! Parameters + integer, parameter :: MAX_TESTS = 10 + integer, parameter :: MAX_STR_LEN = 100 + integer, parameter :: MAX_HEX_LEN = 32 + + ! Variables + character(len=MAX_STR_LEN), dimension(MAX_TESTS) :: test_cases + character(len=MAX_HEX_LEN) :: hex_address + character(len=10) :: port_str + integer :: i, status + + ! Initialize test cases + test_cases(1) = '192.168.0.1' + test_cases(2) = '127.0.0.1' + test_cases(3) = '256.0.0.1' + test_cases(4) = '127.0.0.1:80' + test_cases(5) = '::1' + test_cases(6) = '[::1]:80' + test_cases(7) = '[32e::12f]:80' + test_cases(8) = '2605:2700:0:3::4713:93e3' + test_cases(9) = '[2605:2700:0:3::4713:93e3]:80' + test_cases(10) = '2001:db8:85a3:0:0:8a2e:370:7334' + + ! Print header + write(*,'(A40,1X,A32,3X,A)') 'Test Case', 'Hex Address', 'Port' + write(*,'(A40,1X,A32,3X,A)') repeat('-',40), repeat('-',32), repeat('-',4) + + ! Process each test case + do i = 1, MAX_TESTS + call parse_ip(trim(test_cases(i)), hex_address, port_str, status) + if (status == 0) then + write(*,'(A40,1X,A32,3X,A)') trim(test_cases(i)), trim(hex_address), trim(port_str) + else + write(*,'(A40,1X,A)') trim(test_cases(i)), 'Invalid address' + end if + end do + +end program parse_ip_address + +! Main parsing subroutine +subroutine parse_ip(ip_str, hex_address, port_str, status) + implicit none + character(len=*), intent(in) :: ip_str + character(len=*), intent(out) :: hex_address, port_str + integer, intent(out) :: status + + ! Try IPv4 first + call parse_ipv4(ip_str, hex_address, port_str, status) + if (status == 0) return + + ! Try IPv6 + call parse_ipv6(ip_str, hex_address, port_str, status) + if (status == 0) return + + ! If neither worked, return error + status = -1 + +end subroutine parse_ip + +! Parse IPv4 address +subroutine parse_ipv4(ip_str, hex_address, port_str, status) + implicit none + character(len=*), intent(in) :: ip_str + character(len=*), intent(out) :: hex_address, port_str + integer, intent(out) :: status + + character(len=100) :: work_str + integer :: dot_pos(3), colon_pos + integer :: octets(4) + integer :: i, start_pos, end_pos, port_val + character(len=2) :: hex_part + + work_str = trim(ip_str) + hex_address = '' + port_str = '' + status = 0 + + ! Find colon for port (if present) + colon_pos = index(work_str, ':', .true.) ! Find last colon + if (colon_pos > 0) then + ! Extract port + read(work_str(colon_pos+1:), *, iostat=status) port_val + if (status /= 0) then + status = -1 + return + end if + write(port_str, '(I0)') port_val + work_str = work_str(1:colon_pos-1) + end if + + ! Find dots + dot_pos(1) = index(work_str, '.') + if (dot_pos(1) == 0) then + status = -1 + return + end if + + dot_pos(2) = index(work_str(dot_pos(1)+1:), '.') + dot_pos(1) + if (dot_pos(2) == dot_pos(1)) then + status = -1 + return + end if + + dot_pos(3) = index(work_str(dot_pos(2)+1:), '.') + dot_pos(2) + if (dot_pos(3) == dot_pos(2)) then + status = -1 + return + end if + + ! Parse octets + read(work_str(1:dot_pos(1)-1), *, iostat=status) octets(1) + if (status /= 0 .or. octets(1) < 0 .or. octets(1) > 255) then + status = -1 + return + end if + + read(work_str(dot_pos(1)+1:dot_pos(2)-1), *, iostat=status) octets(2) + if (status /= 0 .or. octets(2) < 0 .or. octets(2) > 255) then + status = -1 + return + end if + + read(work_str(dot_pos(2)+1:dot_pos(3)-1), *, iostat=status) octets(3) + if (status /= 0 .or. octets(3) < 0 .or. octets(3) > 255) then + status = -1 + return + end if + + read(work_str(dot_pos(3)+1:), *, iostat=status) octets(4) + if (status /= 0 .or. octets(4) < 0 .or. octets(4) > 255) then + status = -1 + return + end if + + ! Convert to hex + do i = 1, 4 + call int_to_hex2(octets(i), hex_part) + hex_address = trim(hex_address) // hex_part + end do + + status = 0 + +end subroutine parse_ipv4 + +! Parse IPv6 address (simplified version) +subroutine parse_ipv6(ip_str, hex_address, port_str, status) + implicit none + character(len=*), intent(in) :: ip_str + character(len=*), intent(out) :: hex_address, port_str + integer, intent(out) :: status + + character(len=100) :: work_str, expanded_str + integer :: bracket_start, bracket_end, colon_pos + integer :: port_val + + work_str = trim(ip_str) + hex_address = '' + port_str = '' + status = 0 + + ! Handle bracketed IPv6 with port + bracket_start = index(work_str, '[') + bracket_end = index(work_str, ']') + + if (bracket_start > 0 .and. bracket_end > bracket_start) then + ! Extract IPv6 part + work_str = work_str(bracket_start+1:bracket_end-1) + + ! Check for port after bracket + colon_pos = index(ip_str(bracket_end+1:), ':') + if (colon_pos > 0) then + read(ip_str(bracket_end+colon_pos+1:), *, iostat=status) port_val + if (status /= 0) then + status = -1 + return + end if + write(port_str, '(I0)') port_val + end if + end if + + ! Expand double colon if present + call expand_ipv6(work_str, expanded_str, status) + if (status /= 0) return + + ! Convert expanded IPv6 to hex + call ipv6_to_hex(expanded_str, hex_address, status) + +end subroutine parse_ipv6 + +! Expand IPv6 double colon notation +subroutine expand_ipv6(ipv6_str, expanded_str, status) + implicit none + character(len=*), intent(in) :: ipv6_str + character(len=*), intent(out) :: expanded_str + integer, intent(out) :: status + + character(len=100) :: work_str + integer :: double_colon_pos, colon_count, zeros_needed + integer :: i, pos + + work_str = trim(ipv6_str) + expanded_str = '' + status = 0 + + ! Find double colon + double_colon_pos = index(work_str, '::') + + if (double_colon_pos == 0) then + ! No double colon, just copy + expanded_str = work_str + return + end if + + ! Count existing colons (excluding the double colon) + colon_count = 0 + do i = 1, len_trim(work_str) + if (work_str(i:i) == ':') colon_count = colon_count + 1 + end do + colon_count = colon_count - 2 ! Subtract the double colon + + ! Calculate zeros needed + zeros_needed = 8 - colon_count - 1 + if (double_colon_pos == 1) zeros_needed = zeros_needed + 1 + if (double_colon_pos == len_trim(work_str)-1) zeros_needed = zeros_needed + 1 + + ! Build expanded string + if (double_colon_pos == 1) then + expanded_str = '0' + do i = 1, zeros_needed - 1 + expanded_str = trim(expanded_str) // ':0' + end do + if (len_trim(work_str) > 2) then + expanded_str = trim(expanded_str) // work_str(3:) + end if + else if (double_colon_pos == len_trim(work_str)-1) then + expanded_str = work_str(1:double_colon_pos-1) + do i = 1, zeros_needed + expanded_str = trim(expanded_str) // ':0' + end do + else + expanded_str = work_str(1:double_colon_pos-1) + do i = 1, zeros_needed + expanded_str = trim(expanded_str) // ':0' + end do + expanded_str = trim(expanded_str) // work_str(double_colon_pos+2:) + end if + +end subroutine expand_ipv6 + +! Convert expanded IPv6 to hex +subroutine ipv6_to_hex(ipv6_str, hex_address, status) + implicit none + character(len=*), intent(in) :: ipv6_str + character(len=*), intent(out) :: hex_address + integer, intent(out) :: status + + character(len=100) :: work_str + character(len=10) :: segment + character(len=4) :: hex_segment + integer :: colon_pos, start_pos, i + + work_str = trim(ipv6_str) // ':' ! Add trailing colon for easier parsing + hex_address = '' + start_pos = 1 + status = 0 + + do i = 1, 8 + colon_pos = index(work_str(start_pos:), ':') + if (colon_pos == 0) then + status = -1 + return + end if + colon_pos = colon_pos + start_pos - 1 + + segment = work_str(start_pos:colon_pos-1) + if (len_trim(segment) == 0) segment = '0' + + ! Pad to 4 hex digits + write(hex_segment, '(A4)') segment + call pad_hex(hex_segment) + hex_address = trim(hex_address) // hex_segment + + start_pos = colon_pos + 1 + end do + +end subroutine ipv6_to_hex + +! Convert integer to 2-digit hex +subroutine int_to_hex2(val, hex_str) + implicit none + integer, intent(in) :: val + character(len=2), intent(out) :: hex_str + + character(len=16), parameter :: hex_digits = '0123456789abcdef' + + hex_str(1:1) = hex_digits(val/16 + 1:val/16 + 1) + hex_str(2:2) = hex_digits(mod(val,16) + 1:mod(val,16) + 1) + +end subroutine int_to_hex2 + +! Pad hex string with leading zeros +subroutine pad_hex(hex_str) + implicit none + character(len=4), intent(inout) :: hex_str + + integer :: i, j + character(len=4) :: temp_str + + ! Remove leading spaces and pad with zeros + temp_str = adjustl(hex_str) + hex_str = '0000' + j = 4 - len_trim(temp_str) + 1 + if (j <= 4) then + hex_str(j:4) = trim(temp_str) + end if + +end subroutine pad_hex diff --git a/Task/Parse-an-IP-Address/JavaScript/parse-an-ip-address.js b/Task/Parse-an-IP-Address/JavaScript/parse-an-ip-address.js new file mode 100644 index 0000000000..638eb461b9 --- /dev/null +++ b/Task/Parse-an-IP-Address/JavaScript/parse-an-ip-address.js @@ -0,0 +1,123 @@ +// IP Address Parser in JavaScript +class ParseIPAddress { + constructor() { + this.IPV4_PAT = /^(\d+)\.(\d+)\.(\d+)\.(\d+)(?::(\d+))?$/; + this.IPV6_DOUBL_COL_PAT = /^\[?([0-9a-f:]*)::([0-9a-f:]*)(?:\]:(\d+))?$/; + + // Build IPv6 pattern dynamically + let ipv6Pattern = "^\\[?"; + for (let i = 1; i <= 7; i++) { + ipv6Pattern += "([0-9a-f]+):"; + } + ipv6Pattern += "([0-9a-f]+)(?:\\]:(\\d+))?$"; + this.IPV6_PAT = new RegExp(ipv6Pattern); + } + + static main() { + const tests = [ + "192.168.0.1", + "127.0.0.1", + "256.0.0.1", + "127.0.0.1:80", + "::1", + "[::1]:80", + "[32e::12f]:80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80", + "2001:db8:85a3:0:0:8a2e:370:7334" + ]; + + const parser = new ParseIPAddress(); + + console.log(`${"Test Case".padEnd(40)} ${"Hex Address".padEnd(32)} Port`); + + for (const ip of tests) { + try { + const parsed = parser.parseIP(ip); + console.log(`${ip.padEnd(40)} ${parsed[0].padEnd(32)} ${parsed[1]}`); + } catch (e) { + console.log(`${ip.padEnd(40)} Invalid address: ${e.message}`); + } + } + } + + parseIP(ip) { + let hex = ""; + let port = ""; + + // IPv4 + const ipv4Match = ip.match(this.IPV4_PAT); + if (ipv4Match) { + for (let i = 1; i <= 4; i++) { + hex += this.toHex4(ipv4Match[i]); + } + if (ipv4Match[5] !== undefined) { + port = ipv4Match[5]; + } + return [hex, port]; + } + + // IPv6, double colon + const ipv6DoubleColonMatch = ip.match(this.IPV6_DOUBL_COL_PAT); + if (ipv6DoubleColonMatch) { + let p1 = ipv6DoubleColonMatch[1]; + if (p1 === "") { + p1 = "0"; + } + let p2 = ipv6DoubleColonMatch[2]; + if (p2 === "") { + p2 = "0"; + } + ip = p1 + this.getZero(8 - this.numCount(p1) - this.numCount(p2)) + p2; + if (ipv6DoubleColonMatch[3] !== undefined) { + ip = "[" + ip + "]:" + ipv6DoubleColonMatch[3]; + } + } + + // IPv6 + const ipv6Match = ip.match(this.IPV6_PAT); + if (ipv6Match) { + for (let i = 1; i <= 8; i++) { + hex += this.toHex6(ipv6Match[i]).padStart(4, "0"); + } + if (ipv6Match[9] !== undefined) { + port = ipv6Match[9]; + } + return [hex, port]; + } + + throw new Error("ERROR 103: Unknown address: " + ip); + } + + numCount(s) { + return s.split(":").length; + } + + getZero(count) { + let result = ":"; + while (count > 0) { + result += "0:"; + count--; + } + return result; + } + + toHex4(s) { + const val = parseInt(s, 10); + if (val < 0 || val > 255) { + throw new Error("ERROR 101: Invalid value : " + s); + } + return val.toString(16).padStart(2, "0"); + } + + toHex6(s) { + const val = parseInt(s, 16); + if (val < 0 || val > 65536) { + throw new Error("ERROR 102: Invalid hex value : " + s); + } + return s; + } +} + +// Run the main function +ParseIPAddress.main(); diff --git a/Task/Parse-an-IP-Address/Mathematica/parse-an-ip-address.math b/Task/Parse-an-IP-Address/Mathematica/parse-an-ip-address.math new file mode 100644 index 0000000000..5ad915d5f0 --- /dev/null +++ b/Task/Parse-an-IP-Address/Mathematica/parse-an-ip-address.math @@ -0,0 +1,100 @@ +testdata = {"127.0.0.1", "127.0.0.1:80", "::1", "[::1]:80", + "2605:2700:0:3::4713:93e3", "[2605:2700:0:3::4713:93e3]:80", + "::ffff:192.168.173.22", "[::ffff:192.168.173.22]:80", + "1::", "[1::]:80", "::", "[::]:80"}; + +maybev4[ip_] := StringCount[ip, "."] > 0 && StringCount[ip, ":"] < 2 + +maybev6[ip_] := StringCount[ip, ":"] > 1 + +parseip[ip_] := Module[{mat, port, ipaddr, iphex, addressspace}, + (* Try to match IPv6 with brackets and port *) + mat = StringCases[ip, + RegularExpression["^\\[([:.\\da-fA-F]+)\\]:(\\d+)$"] -> {"$1", "$2"}]; + + If[Length[mat] > 0, + {ipaddr, port} = First[mat], + (* Try to match IPv4 with port *) + mat = StringCases[ip, + RegularExpression["^([\\d.]+)[:/](\\d+)$"] -> {"$1", "$2"}]; + If[Length[mat] > 0, + {ipaddr, port} = First[mat], + (* No port found *) + {ipaddr, port} = {ip, "none"} + ] + ]; + + If[maybev4[ipaddr], + Print["Processing ip v4 ", ipaddr]; + (* Convert IPv4 to hex *) + Module[{octets, ipint}, + octets = ToExpression /@ StringSplit[ipaddr, "."]; + ipint = Total[MapIndexed[#1*256^(4 - First[#2]) &, octets]]; + iphex = IntegerString[ipint, 16]; + ]; + addressspace = "IPv4", + + If[maybev6[ipaddr], + Print["Processing ip v6 ", ipaddr]; + (* Convert IPv6 to hex *) + Module[{cleanip, parts, expandedparts, fullhex}, + cleanip = StringReplace[ipaddr, {"[" -> "", "]" -> ""}]; + + (* Handle embedded IPv4 addresses *) + If[StringContainsQ[cleanip, "."], + Module[{parts, ipv4part, ipv6parts, ipv4octets, ipv4hex}, + parts = StringSplit[cleanip, ":"]; + (* Find the part with dots (IPv4) *) + ipv4part = SelectFirst[parts, StringContainsQ[#, "."] &]; + ipv6parts = DeleteCases[parts, ipv4part]; + + If[ipv4part =!= Missing["NotFound"], + ipv4octets = ToExpression /@ StringSplit[ipv4part, "."]; + (* Convert IPv4 to two 16-bit hex values *) + ipv4hex = { + IntegerString[ipv4octets[[1]]*256 + ipv4octets[[2]], 16], + IntegerString[ipv4octets[[3]]*256 + ipv4octets[[4]], 16] + }; + cleanip = StringJoin[Riffle[Join[ipv6parts, ipv4hex], ":"]]; + ] + ] + ]; + + (* Handle :: expansion *) + If[StringContainsQ[cleanip, "::"], + parts = StringSplit[cleanip, "::"]; + If[Length[parts] == 2, + Module[{left, right, leftparts, rightparts, missing}, + left = If[parts[[1]] == "", {}, StringSplit[parts[[1]], ":"]]; + right = If[parts[[2]] == "", {}, StringSplit[parts[[2]], ":"]]; + missing = 8 - Length[left] - Length[right]; + expandedparts = Join[left, Table["0", missing], right]; + ], + expandedparts = StringSplit[cleanip, ":"] + ], + expandedparts = StringSplit[cleanip, ":"] + ]; + + (* Pad each part to 4 hex digits and join *) + expandedparts = StringPadLeft[#, 4, "0"] & /@ expandedparts; + fullhex = StringJoin[expandedparts]; + + (* Remove leading zeros for final output *) + iphex = IntegerString[FromDigits[fullhex, 16], 16]; + ]; + addressspace = "IPv6", + + (* Neither IPv4 nor IPv6 *) + Throw["Bad IP address argument " <> ipaddr] + ] + ]; + + {iphex, addressspace, port} +] + +(* Test the function *) +Do[ + {hx, add, por} = parseip[ip]; + Print["For input ", ip, ", IP in hex is ", hx, ", address space ", add, ", port ", por, "."], + {ip, testdata} +] diff --git a/Task/Parse-an-IP-Address/OCaml/parse-an-ip-address.ml b/Task/Parse-an-IP-Address/OCaml/parse-an-ip-address.ml new file mode 100644 index 0000000000..6d0fddb066 --- /dev/null +++ b/Task/Parse-an-IP-Address/OCaml/parse-an-ip-address.ml @@ -0,0 +1,192 @@ +open Printf + +(* Custom exception for invalid addresses *) +exception Invalid_address of string + +(* Helper functions for string parsing *) +let is_digit c = c >= '0' && c <= '9' +let is_hex_digit c = is_digit c || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') + +let split_string s delimiter = + let len = String.length s in + let rec aux acc start i = + if i >= len then + if start < len then (String.sub s start (len - start)) :: acc + else acc + else if s.[i] = delimiter then + let part = String.sub s start (i - start) in + aux (part :: acc) (i + 1) (i + 1) + else + aux acc start (i + 1) + in + List.rev (aux [] 0 0) + +let string_contains s substr = + let s_len = String.length s in + let substr_len = String.length substr in + let rec aux i = + if i > s_len - substr_len then false + else if String.sub s i substr_len = substr then true + else aux (i + 1) + in + if substr_len = 0 then true else aux 0 + +(* Check if string contains only digits *) +let is_numeric s = + let len = String.length s in + len > 0 && + let rec aux i = + if i >= len then true + else if is_digit s.[i] then aux (i + 1) + else false + in + aux 0 + +(* Check if string contains only hex digits *) +let is_hex s = + let len = String.length s in + len > 0 && + let rec aux i = + if i >= len then true + else if is_hex_digit (Char.lowercase_ascii s.[i]) then aux (i + 1) + else false + in + aux 0 + +(* Convert decimal string to 2-digit hex for IPv4 *) +let to_hex4 s = + if not (is_numeric s) then + raise (Invalid_address ("ERROR 101: Invalid value : " ^ s)); + let val_int = int_of_string s in + if val_int < 0 || val_int > 255 then + raise (Invalid_address ("ERROR 101: Invalid value : " ^ s)) + else + Printf.sprintf "%02x" val_int + +(* Validate and return hex string for IPv6 *) +let to_hex6 s = + if not (is_hex s) then + raise (Invalid_address ("ERROR 102: Invalid hex value : " ^ s)); + let val_int = int_of_string ("0x" ^ s) in + if val_int < 0 || val_int > 65535 then + raise (Invalid_address ("ERROR 102: Invalid hex value : " ^ s)) + else + s + +(* Parse IPv4 address *) +let parse_ipv4 ip = + let parts = split_string ip '.' in + match parts with + | [p1; p2; p3; p4_port] -> + (* Check if last part has port *) + if string_contains p4_port ":" then + let port_parts = split_string p4_port ':' in + (match port_parts with + | [p4; port] when is_numeric p4 && is_numeric port -> + let hex = (to_hex4 p1) ^ (to_hex4 p2) ^ (to_hex4 p3) ^ (to_hex4 p4) in + (hex, port) + | _ -> raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip))) + else if is_numeric p4_port then + let hex = (to_hex4 p1) ^ (to_hex4 p2) ^ (to_hex4 p3) ^ (to_hex4 p4_port) in + (hex, "") + else + raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + | _ -> raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + +(* Parse IPv6 address *) +let parse_ipv6 ip = + let (clean_ip, port) = + if String.length ip > 0 && ip.[0] = '[' then + (* Bracketed IPv6 with possible port *) + try + let bracket_end = String.index ip ']' in + let addr_part = String.sub ip 1 (bracket_end - 1) in + if bracket_end + 1 < String.length ip && ip.[bracket_end + 1] = ':' then + let port_part = String.sub ip (bracket_end + 2) (String.length ip - bracket_end - 2) in + (addr_part, port_part) + else + (addr_part, "") + with Not_found -> + raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + else + (ip, "") in + + (* Handle double colon expansion *) + let expanded_ip = + if string_contains clean_ip "::" then + (* Split on :: to get before and after parts *) + let double_colon_pos = + let rec find_pos i = + if i >= String.length clean_ip - 1 then -1 + else if clean_ip.[i] = ':' && clean_ip.[i+1] = ':' then i + else find_pos (i + 1) + in + find_pos 0 in + + if double_colon_pos = -1 then + raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + else + let before_part = + if double_colon_pos = 0 then "" + else String.sub clean_ip 0 double_colon_pos in + let after_part = + let start = double_colon_pos + 2 in + if start >= String.length clean_ip then "" + else String.sub clean_ip start (String.length clean_ip - start) in + + let before_groups = if before_part = "" then [] else split_string before_part ':' in + let after_groups = if after_part = "" then [] else split_string after_part ':' in + let total_existing = List.length before_groups + List.length after_groups in + let zeros_needed = 8 - total_existing in + let zero_groups = List.init zeros_needed (fun _ -> "0") in + + String.concat ":" (before_groups @ zero_groups @ after_groups) + else + clean_ip in + + (* Parse the expanded IPv6 *) + let hex_parts = split_string expanded_ip ':' in + if List.length hex_parts = 8 then + let hex = String.concat "" (List.map (fun part -> + Printf.sprintf "%04s" (to_hex6 part) |> + String.map (function ' ' -> '0' | c -> c)) hex_parts) in + (hex, port) + else + raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + +(* Main parsing function *) +let parse_ip ip = + (* Check if it looks like IPv4 (contains dots but no colons except maybe one for port) *) + if string_contains ip "." && + (not (string_contains ip ":") || + (let colon_count = List.length (split_string ip ':') - 1 in colon_count = 1)) then + parse_ipv4 ip + else if string_contains ip ":" then + parse_ipv6 ip + else + raise (Invalid_address ("ERROR 103: Unknown address: " ^ ip)) + +(* Test cases *) +let tests = [| + "192.168.0.1"; + "127.0.0.1"; + "256.0.0.1"; + "127.0.0.1:80"; + "::1"; + "[::1]:80"; + "[32e::12f]:80"; + "2605:2700:0:3::4713:93e3"; + "[2605:2700:0:3::4713:93e3]:80"; + "2001:db8:85a3:0:0:8a2e:370:7334" +|] + +(* Main function *) +let () = + printf "%-40s %-32s %s\n" "Test Case" "Hex Address" "Port"; + Array.iter (fun ip -> + try + let (hex_addr, port) = parse_ip ip in + printf "%-40s %-32s %s\n" ip hex_addr port + with Invalid_address msg -> + printf "%-40s Invalid address: %s\n" ip msg + ) tests diff --git a/Task/Parse-an-IP-Address/R/parse-an-ip-address.r b/Task/Parse-an-IP-Address/R/parse-an-ip-address.r new file mode 100644 index 0000000000..8c2dcc1b56 --- /dev/null +++ b/Task/Parse-an-IP-Address/R/parse-an-ip-address.r @@ -0,0 +1,127 @@ +# IP Address Parser in R +library(stringr) + +# Helper function to convert decimal to 2-digit hex (for IPv4) +to_hex4 <- function(s) { + val <- as.integer(s) + if (is.na(val) || val < 0 || val > 255) { + stop(paste("ERROR 101: Invalid value:", s)) + } + sprintf("%02x", val) +} + +# Helper function to validate and return hex value (for IPv6) +to_hex6 <- function(s) { + val <- strtoi(s, base = 16) + if (is.na(val) || val < 0 || val > 65535) { # Fixed: should be 65535, not 65536 + stop(paste("ERROR 102: Invalid hex value:", s)) + } + return(s) +} + +# Helper function to count number of parts separated by colons +num_count <- function(s) { + if (s == "") return(0) + length(strsplit(s, ":")[[1]]) +} + +# Helper function to generate zero padding for IPv6 double colon expansion +get_zero <- function(count) { + if (count <= 0) return("") + paste0(":", paste(rep("0", count), collapse = ":"), ":") +} + +# Main parsing function +parse_ip <- function(ip) { + hex <- "" + port <- "" + + # IPv4 pattern: xxx.xxx.xxx.xxx with optional :port + ipv4_pattern <- "^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)(?::(\\d+))?$" + ipv4_match <- str_match(ip, ipv4_pattern) + + if (!is.na(ipv4_match[1])) { + # Extract IPv4 components + for (i in 2:5) { + hex <- paste0(hex, to_hex4(ipv4_match[i])) + } + if (!is.na(ipv4_match[6])) { + port <- ipv4_match[6] + } + return(c(hex, port)) + } + + # IPv6 with double colon pattern + ipv6_double_colon_pattern <- "^\\[?([0-9a-f:]*)::([0-9a-f:]*)(?:\\]:(\\d+))?$" + ipv6_dc_match <- str_match(tolower(ip), ipv6_double_colon_pattern) + + if (!is.na(ipv6_dc_match[1])) { + p1 <- ipv6_dc_match[2] + if (p1 == "") p1 <- "0" + + p2 <- ipv6_dc_match[3] + if (p2 == "") p2 <- "0" + + # Expand the double colon + zero_count <- 8 - num_count(p1) - num_count(p2) + expanded_ip <- paste0(p1, get_zero(zero_count), p2) + + # Add port back if it exists + if (!is.na(ipv6_dc_match[4])) { + expanded_ip <- paste0("[", expanded_ip, "]:", ipv6_dc_match[4]) + } + + ip <- expanded_ip + } + + # IPv6 full pattern (8 groups of hex digits) + ipv6_pattern <- "^\\[?([0-9a-f]+):([0-9a-f]+):([0-9a-f]+):([0-9a-f]+):([0-9a-f]+):([0-9a-f]+):([0-9a-f]+):([0-9a-f]+)(?:\\]:(\\d+))?$" + ipv6_match <- str_match(tolower(ip), ipv6_pattern) + + if (!is.na(ipv6_match[1])) { + # Extract IPv6 components + for (i in 2:9) { + hex_part <- to_hex6(ipv6_match[i]) + # Pad to 4 characters + hex <- paste0(hex, sprintf("%04s", hex_part)) + } + hex <- str_replace_all(hex, " ", "0") + + if (!is.na(ipv6_match[10])) { + port <- ipv6_match[10] + } + return(c(hex, port)) + } + + stop(paste("ERROR 103: Unknown address:", ip)) +} + +# Main execution +main <- function() { + tests <- c( + "192.168.0.1", + "127.0.0.1", + "256.0.0.1", + "127.0.0.1:80", + "::1", + "[::1]:80", + "[32e::12f]:80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80", + "2001:db8:85a3:0:0:8a2e:370:7334" + ) + + cat(sprintf("%-40s %-32s %s\n", "Test Case", "Hex Address", "Port")) + + for (ip in tests) { + tryCatch({ + parsed <- parse_ip(ip) + cat(sprintf("%-40s %-32s %s\n", ip, parsed[1], parsed[2])) + }, error = function(e) { + cat(sprintf("%-40s Invalid address: %s\n", ip, e$message)) + }) + } +} + +# Run the main function +main() diff --git a/Task/Parse-an-IP-Address/Rust/parse-an-ip-address.rs b/Task/Parse-an-IP-Address/Rust/parse-an-ip-address-1.rs similarity index 100% rename from Task/Parse-an-IP-Address/Rust/parse-an-ip-address.rs rename to Task/Parse-an-IP-Address/Rust/parse-an-ip-address-1.rs diff --git a/Task/Parse-an-IP-Address/Rust/parse-an-ip-address-2.rs b/Task/Parse-an-IP-Address/Rust/parse-an-ip-address-2.rs new file mode 100644 index 0000000000..df2add4c63 --- /dev/null +++ b/Task/Parse-an-IP-Address/Rust/parse-an-ip-address-2.rs @@ -0,0 +1,354 @@ +use std::net::{Ipv4Addr, Ipv6Addr}; + +#[derive(Debug, Clone, Copy)] +pub enum IpAddr { + V4([u8; 4]), + V6([u8; 16]), +} + +#[derive(Debug)] +pub struct ParseResult { + pub addr: IpAddr, + pub port: Option, + pub consumed: usize, +} + +pub struct Parser<'a> { + input: &'a str, + cursor: usize, +} + +impl<'a> Parser<'a> { + fn new(input: &'a str) -> Self { + Self { input, cursor: 0 } + } + + fn current_char(&self) -> Option { + self.input.chars().nth(self.cursor) + } + + fn peek_char(&self, offset: usize) -> Option { + self.input.chars().nth(self.cursor + offset) + } + + fn advance(&mut self) { + if self.cursor < self.input.len() { + self.cursor += 1; + } + } + + fn find_char(&self, ch: char) -> Option { + self.input[self.cursor..].find(ch).map(|pos| self.cursor + pos) + } + + fn parse_decimal(&mut self) -> Result { + let start = self.cursor; + let mut val = 0u32; + + while let Some(ch) = self.current_char() { + if ch.is_ascii_digit() { + val = val.checked_mul(10).ok_or("decimal overflow")?; + val = val.checked_add((ch as u32) - ('0' as u32)).ok_or("decimal overflow")?; + self.advance(); + } else { + break; + } + } + + if self.cursor == start { + Err("no digits found") + } else { + Ok(val) + } + } + + fn parse_hex(&mut self) -> Result { + let start = self.cursor; + let mut val = 0u32; + + while let Some(ch) = self.current_char() { + let digit = match ch { + '0'..='9' => (ch as u32) - ('0' as u32), + 'a'..='f' => (ch as u32) - ('a' as u32) + 10, + 'A'..='F' => (ch as u32) - ('A' as u32) + 10, + _ => break, + }; + + val = val.checked_shl(4).ok_or("hex overflow")?; + val = val.checked_add(digit).ok_or("hex overflow")?; + self.advance(); + } + + if self.cursor == start { + Err("no hex digits found") + } else { + Ok(val) + } + } + + fn parse_ipv4(&mut self) -> Result<[u8; 4], &'static str> { + let mut addr = [0u8; 4]; + + for i in 0..4 { + let val = self.parse_decimal()?; + if val > 255 { + return Err("IPv4 octet out of range"); + } + addr[i] = val as u8; + + if i < 3 { + if self.current_char() != Some('.') { + return Err("expected '.' in IPv4 address"); + } + self.advance(); + } + } + + Ok(addr) + } + + fn parse_ipv6(&mut self) -> Result<[u8; 16], &'static str> { + let mut addr = [0u8; 16]; + let mut groups = Vec::new(); + let mut compression_pos = None; + let mut has_ipv4_suffix = false; + + // Handle brackets + let has_brackets = self.current_char() == Some('['); + if has_brackets { + self.advance(); + } + + // Parse groups + loop { + let start_cursor = self.cursor; + + // Check for empty group (compression) + if self.current_char() == Some(':') { + if compression_pos.is_some() { + // Check if this is the end of the address + if groups.len() == 0 || (groups.len() == 1 && compression_pos == Some(0)) { + break; + } + return Err("multiple :: compressions not allowed"); + } + + compression_pos = Some(groups.len()); + self.advance(); + + // Handle leading :: + if groups.is_empty() && self.current_char() == Some(':') { + self.advance(); + } + continue; + } + + // Try to parse hex + match self.parse_hex() { + Ok(val) => { + if val > 0xFFFF { + return Err("IPv6 group out of range"); + } + + // Check for IPv4 suffix + if self.current_char() == Some('.') { + // Rewind and parse as IPv4 + self.cursor = start_cursor; + let ipv4_addr = self.parse_ipv4()?; + + // Validate IPv4-mapped IPv6 prefix + if groups.len() != 6 || + groups[0..5] != [0, 0, 0, 0, 0] || + groups[5] != 0xFFFF { + return Err("IPv4 suffix only allowed in ::ffff: mapping"); + } + + // Add IPv4 bytes as two 16-bit groups + groups.push(((ipv4_addr[0] as u16) << 8) | (ipv4_addr[1] as u16)); + groups.push(((ipv4_addr[2] as u16) << 8) | (ipv4_addr[3] as u16)); + has_ipv4_suffix = true; + break; + } + + groups.push(val as u16); + + // Check for continuation + if self.current_char() == Some(':') { + self.advance(); + } else { + break; + } + } + Err(_) => { + if groups.is_empty() { + return Err("invalid IPv6 format"); + } + break; + } + } + } + + // Handle compression + if let Some(pos) = compression_pos { + let groups_after = groups.len() - pos; + let zeros_needed = 8 - groups.len(); + + if zeros_needed > 0 { + let mut new_groups = Vec::new(); + new_groups.extend_from_slice(&groups[..pos]); + new_groups.resize(new_groups.len() + zeros_needed, 0); + new_groups.extend_from_slice(&groups[pos..]); + groups = new_groups; + } + } + + if groups.len() != 8 { + return Err("IPv6 address must have 8 groups"); + } + + // Convert to bytes + for (i, &group) in groups.iter().enumerate() { + addr[i * 2] = (group >> 8) as u8; + addr[i * 2 + 1] = (group & 0xFF) as u8; + } + + // Validate IPv4-mapped address + if has_ipv4_suffix { + let ipv4_mapped_prefix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]; + if addr[..12] != ipv4_mapped_prefix { + return Err("invalid IPv4-mapped IPv6 address"); + } + } + + // Handle closing bracket + if has_brackets { + if self.current_char() != Some(']') { + return Err("expected closing bracket"); + } + self.advance(); + } + + Ok(addr) + } + + fn parse_port(&mut self) -> Result { + if self.current_char() != Some(':') { + return Err("expected ':' before port"); + } + self.advance(); + + let port = self.parse_decimal()?; + if port > 65535 { + return Err("port out of range"); + } + + Ok(port as u16) + } +} + +pub fn parse_ipv4_or_ipv6(input: &str) -> Result { + let mut parser = Parser::new(input); + + // Determine if this looks like IPv6 + let colon_pos = parser.find_char(':'); + let dot_pos = parser.find_char('.'); + let bracket_pos = parser.find_char('['); + + let is_ipv6 = bracket_pos.is_some() + || dot_pos.is_none() + || (colon_pos.is_some() && (dot_pos.is_none() || colon_pos < dot_pos)); + + let addr = if is_ipv6 { + IpAddr::V6(parser.parse_ipv6()?) + } else { + IpAddr::V4(parser.parse_ipv4()?) + }; + + let port = if parser.current_char() == Some(':') { + Some(parser.parse_port()?) + } else { + None + }; + + Ok(ParseResult { + addr, + port, + consumed: parser.cursor, + }) +} + +// Helper function for compatibility +pub fn parse_ipv4_or_ipv6_simple(input: &str) -> Result<(IpAddr, Option, bool), &'static str> { + let result = parse_ipv4_or_ipv6(input)?; + let is_ipv6 = matches!(result.addr, IpAddr::V6(_)); + Ok((result.addr, result.port, is_ipv6)) +} + +fn dump_bytes(bytes: &[u8]) { + for &byte in bytes { + print!("{:02x}", byte); + } +} + +fn test_case(input: &str) { + println!("Test case '{}'", input); + + match parse_ipv4_or_ipv6(input) { + Ok(result) => { + print!("addr: "); + match result.addr { + IpAddr::V4(addr) => dump_bytes(&addr), + IpAddr::V6(addr) => dump_bytes(&addr), + } + println!(); + + if let Some(port) = result.port { + println!("port: {}", port); + } else { + println!("port absent"); + } + } + Err(e) => { + println!("parse failed: {}", e); + } + } + println!(); +} + +fn main() { + // The "localhost" IPv4 address + test_case("127.0.0.1"); + + // The "localhost" IPv4 address, with a specified port (80) + test_case("127.0.0.1:80"); + + // The "localhost" IPv6 address + test_case("::1"); + + // The "localhost" IPv6 address, with a specified port (80) + test_case("[::1]:80"); + + // Rosetta Code's primary server's public IPv6 address + test_case("2605:2700:0:3::4713:93e3"); + + // Rosetta Code's primary server's public IPv6 address, with a specified port (80) + test_case("[2605:2700:0:3::4713:93e3]:80"); + + // IPv4 space + test_case("::ffff:192.168.173.22"); + + // IPv4 space with port + test_case("[::ffff:192.168.173.22]:80"); + + // Trailing compression + test_case("1::"); + + // Trailing compression with port + test_case("[1::]:80"); + + // 'any' address compression + test_case("::"); + + // 'any' address compression with port + test_case("[::]:80"); +} diff --git a/Task/Parse-an-IP-Address/Swift/parse-an-ip-address.swift b/Task/Parse-an-IP-Address/Swift/parse-an-ip-address.swift new file mode 100644 index 0000000000..4421446979 --- /dev/null +++ b/Task/Parse-an-IP-Address/Swift/parse-an-ip-address.swift @@ -0,0 +1,187 @@ +import Foundation + +struct IPParseResult { + let hexAddress: String + let port: String +} + +enum IPParseError: Error { + case invalidValue(String) + case invalidHexValue(String) + case unknownAddress(String) + + var localizedDescription: String { + switch self { + case .invalidValue(let value): + return "ERROR 101: Invalid value: \(value)" + case .invalidHexValue(let value): + return "ERROR 102: Invalid hex value: \(value)" + case .unknownAddress(let address): + return "ERROR 103: Unknown address: \(address)" + } + } +} + +class ParseIPAddress { + + // IPv4 pattern: matches IP with optional port + private static let ipv4Pattern = #"^(\d+)\.(\d+)\.(\d+)\.(\d+)(?::(\d+))?$"# + + // IPv6 double colon pattern: matches compressed IPv6 with optional port + private static let ipv6DoubleColonPattern = #"^\[?([0-9a-f:]*)::([0-9a-f:]*)(?:\]:(\d+))?$"# + + // IPv6 full pattern: dynamically built for full IPv6 addresses + private static let ipv6Pattern: String = { + var pattern = #"^\[?"# + for i in 1...7 { + pattern += #"([0-9a-f]+):"# + } + pattern += #"([0-9a-f]+)(?:\]:(\d+))?$"# + return pattern + }() + + static func main() { + let tests = [ + "192.168.0.1", + "127.0.0.1", + "256.0.0.1", + "127.0.0.1:80", + "::1", + "[::1]:80", + "[32e::12f]:80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80", + "2001:db8:85a3:0:0:8a2e:370:7334" + ] + + // Print header with proper padding + let header = "Test Case".padding(toLength: 40, withPad: " ", startingAt: 0) + + "Hex Address".padding(toLength: 32, withPad: " ", startingAt: 0) + + " Port" + print(header) + + for ip in tests { + do { + let result = try parseIP(ip) + let output = ip.padding(toLength: 40, withPad: " ", startingAt: 0) + + result.hexAddress.padding(toLength: 32, withPad: " ", startingAt: 0) + + " " + result.port + print(output) + } catch { + let output = ip.padding(toLength: 40, withPad: " ", startingAt: 0) + + "Invalid address: " + error.localizedDescription + print(output) + } + } + } + + private static func parseIP(_ ip: String) throws -> IPParseResult { + var hex = "" + var port = "" + + // Try IPv4 first + if let ipv4Regex = try? NSRegularExpression(pattern: ipv4Pattern, options: [.caseInsensitive]) { + let range = NSRange(location: 0, length: ip.utf16.count) + if let match = ipv4Regex.firstMatch(in: ip, options: [], range: range) { + // Extract the 4 octets + for i in 1...4 { + let groupRange = match.range(at: i) + let octet = String(ip[Range(groupRange, in: ip)!]) + hex += try toHex4(octet) + } + + // Check for port + let portRange = match.range(at: 5) + if portRange.location != NSNotFound { + port = String(ip[Range(portRange, in: ip)!]) + } + + return IPParseResult(hexAddress: hex, port: port) + } + } + + var modifiedIP = ip + + // Try IPv6 with double colon + if let ipv6DoubleColonRegex = try? NSRegularExpression(pattern: ipv6DoubleColonPattern, options: [.caseInsensitive]) { + let range = NSRange(location: 0, length: ip.utf16.count) + if let match = ipv6DoubleColonRegex.firstMatch(in: ip, options: [], range: range) { + let p1Range = match.range(at: 1) + let p2Range = match.range(at: 2) + let portRange = match.range(at: 3) + + var p1 = p1Range.location != NSNotFound ? String(ip[Range(p1Range, in: ip)!]) : "" + var p2 = p2Range.location != NSNotFound ? String(ip[Range(p2Range, in: ip)!]) : "" + + if p1.isEmpty { + p1 = "0" + } + if p2.isEmpty { + p2 = "0" + } + + let zeroCount = 8 - numCount(p1) - numCount(p2) + modifiedIP = p1 + getZero(zeroCount) + p2 + + if portRange.location != NSNotFound { + let portStr = String(ip[Range(portRange, in: ip)!]) + modifiedIP = "[\(modifiedIP)]:\(portStr)" + } + } + } + + // Try full IPv6 + if let ipv6Regex = try? NSRegularExpression(pattern: ipv6Pattern, options: [.caseInsensitive]) { + let range = NSRange(location: 0, length: modifiedIP.utf16.count) + if let match = ipv6Regex.firstMatch(in: modifiedIP, options: [], range: range) { + // Extract the 8 groups + for i in 1...8 { + let groupRange = match.range(at: i) + let group = String(modifiedIP[Range(groupRange, in: modifiedIP)!]) + let hexGroup = try toHex6(group) + let paddedHex = hexGroup.padding(toLength: 4, withPad: "0", startingAt: 0) + hex += paddedHex + } + + // Check for port + let portRange = match.range(at: 9) + if portRange.location != NSNotFound { + port = String(modifiedIP[Range(portRange, in: modifiedIP)!]) + } + + return IPParseResult(hexAddress: hex, port: port) + } + } + + throw IPParseError.unknownAddress(ip) + } + + private static func numCount(_ s: String) -> Int { + return s.components(separatedBy: ":").count + } + + private static func getZero(_ count: Int) -> String { + var result = ":" + for _ in 0.. String { + guard let val = Int(s), val >= 0 && val <= 255 else { + throw IPParseError.invalidValue(s) + } + return String(format: "%02x", val) + } + + private static func toHex6(_ s: String) throws -> String { + guard let val = Int(s, radix: 16), val >= 0 && val <= 65535 else { + throw IPParseError.invalidHexValue(s) + } + return s + } +} + +// Run the program +ParseIPAddress.main() diff --git a/Task/Parse-an-IP-Address/Zig/parse-an-ip-address.zig b/Task/Parse-an-IP-Address/Zig/parse-an-ip-address.zig new file mode 100644 index 0000000000..c3479774f5 --- /dev/null +++ b/Task/Parse-an-IP-Address/Zig/parse-an-ip-address.zig @@ -0,0 +1,238 @@ +const std = @import("std"); +const print = std.debug.print; +const Allocator = std.mem.Allocator; +const ArrayList = std.ArrayList; + +const ParseError = error{ + InvalidAddress, + InvalidValue, + InvalidHexValue, + OutOfMemory, +}; + +const ParseResult = struct { + hex_address: []const u8, + port: []const u8, + + fn deinit(self: ParseResult, allocator: Allocator) void { + allocator.free(self.hex_address); + allocator.free(self.port); + } +}; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const tests = [_][]const u8{ + "192.168.0.1", + "127.0.0.1", + "256.0.0.1", + "127.0.0.1:80", + "::1", + "[::1]:80", + "[32e::12f]:80", + "2605:2700:0:3::4713:93e3", + "[2605:2700:0:3::4713:93e3]:80", + "2001:db8:85a3:0:0:8a2e:370:7334" + }; + + print("{s:<40} {s:<32} {s}\n", .{ "Test Case", "Hex Address", "Port" }); + + for (tests) |ip| { + const result = parseIP(allocator, ip) catch |err| { + const error_msg = switch (err) { + ParseError.InvalidAddress => "Unknown address", + ParseError.InvalidValue => "Invalid value", + ParseError.InvalidHexValue => "Invalid hex value", + else => "Parse error", + }; + print("{s:<40} Invalid address: {s}\n", .{ ip, error_msg }); + continue; + }; + defer result.deinit(allocator); + + print("{s:<40} {s:<32} {s}\n", .{ ip, result.hex_address, result.port }); + } +} + +fn parseIP(allocator: Allocator, ip: []const u8) !ParseResult { + // Try IPv4 first + if (parseIPv4(allocator, ip)) |result| { + return result; + } else |_| {} + + // Try IPv6 with double colon + if (parseIPv6DoubleColon(allocator, ip)) |result| { + return result; + } else |_| {} + + // Try regular IPv6 + if (parseIPv6(allocator, ip)) |result| { + return result; + } else |_| {} + + return ParseError.InvalidAddress; +} + +fn parseIPv4(allocator: Allocator, ip: []const u8) !ParseResult { + var parts = std.mem.splitSequence(u8, ip, "."); + var octets: [4]u8 = undefined; + var port_str: []const u8 = ""; + var i: usize = 0; + + while (parts.next()) |part| { + if (i >= 4) return ParseError.InvalidAddress; + + // Check if this part contains a port (last octet with colon) + if (i == 3) { + if (std.mem.indexOf(u8, part, ":")) |colon_pos| { + const octet_str = part[0..colon_pos]; + port_str = part[colon_pos + 1..]; + + const octet = std.fmt.parseInt(u8, octet_str, 10) catch return ParseError.InvalidValue; + octets[i] = octet; + } else { + const octet = std.fmt.parseInt(u8, part, 10) catch return ParseError.InvalidValue; + octets[i] = octet; + } + } else { + const octet = std.fmt.parseInt(u8, part, 10) catch return ParseError.InvalidValue; + octets[i] = octet; + } + i += 1; + } + + if (i != 4) return ParseError.InvalidAddress; + + // Convert to hex + var hex = ArrayList(u8).init(allocator); + defer hex.deinit(); + + for (octets) |octet| { + try hex.writer().print("{x:0>2}", .{octet}); + } + + const port_copy = try allocator.dupe(u8, port_str); + + return ParseResult{ + .hex_address = try hex.toOwnedSlice(), + .port = port_copy, + }; +} + +fn parseIPv6DoubleColon(allocator: Allocator, ip: []const u8) !ParseResult { + var working_ip = ip; + var port_str: []const u8 = ""; + + // Handle brackets and port + if (std.mem.startsWith(u8, working_ip, "[")) { + if (std.mem.lastIndexOf(u8, working_ip, "]:")) |bracket_pos| { + port_str = working_ip[bracket_pos + 2..]; + working_ip = working_ip[1..bracket_pos]; + } else if (std.mem.endsWith(u8, working_ip, "]")) { + working_ip = working_ip[1..working_ip.len - 1]; + } + } + + // Check if it contains :: + const double_colon_pos = std.mem.indexOf(u8, working_ip, "::") orelse return ParseError.InvalidAddress; + + const p1 = working_ip[0..double_colon_pos]; + const p2 = working_ip[double_colon_pos + 2..]; + + const p1_count = if (p1.len == 0) 0 else countColons(p1) + 1; + const p2_count = if (p2.len == 0) 0 else countColons(p2) + 1; + + const zeros_needed = 8 - p1_count - p2_count; + + // Reconstruct the full IPv6 address + var full_ip = ArrayList(u8).init(allocator); + defer full_ip.deinit(); + + if (p1.len > 0) { + try full_ip.appendSlice(p1); + try full_ip.append(':'); + } + + for (0..zeros_needed) |_| { + try full_ip.appendSlice("0:"); + } + + if (p2.len > 0) { + try full_ip.appendSlice(p2); + } else { + // Remove trailing colon if p2 is empty + if (full_ip.items.len > 0 and full_ip.items[full_ip.items.len - 1] == ':') { + _ = full_ip.pop(); + } + } + + const reconstructed = try full_ip.toOwnedSlice(); + defer allocator.free(reconstructed); + + return parseIPv6WithPort(allocator, reconstructed, port_str); +} + +fn parseIPv6(allocator: Allocator, ip: []const u8) !ParseResult { + return parseIPv6WithPort(allocator, ip, ""); +} + +fn parseIPv6WithPort(allocator: Allocator, ip: []const u8, port_override: []const u8) !ParseResult { + var working_ip = ip; + var port_str = port_override; + + // Handle brackets and port if not overridden + if (port_override.len == 0) { + if (std.mem.startsWith(u8, working_ip, "[")) { + if (std.mem.lastIndexOf(u8, working_ip, "]:")) |bracket_pos| { + port_str = working_ip[bracket_pos + 2..]; + working_ip = working_ip[1..bracket_pos]; + } else if (std.mem.endsWith(u8, working_ip, "]")) { + working_ip = working_ip[1..working_ip.len - 1]; + } + } + } + + var parts = std.mem.splitSequence(u8, working_ip, ":"); + var groups: [8][]const u8 = undefined; + var i: usize = 0; + + while (parts.next()) |part| { + if (i >= 8) return ParseError.InvalidAddress; + groups[i] = part; + i += 1; + } + + if (i != 8) return ParseError.InvalidAddress; + + // Convert to hex + var hex = ArrayList(u8).init(allocator); + defer hex.deinit(); + + for (groups) |group| { + if (group.len == 0) { + try hex.appendSlice("0000"); + } else { + // Validate hex and pad to 4 digits + const val = std.fmt.parseInt(u16, group, 16) catch return ParseError.InvalidHexValue; + try hex.writer().print("{x:0>4}", .{val}); + } + } + + const port_copy = try allocator.dupe(u8, port_str); + + return ParseResult{ + .hex_address = try hex.toOwnedSlice(), + .port = port_copy, + }; +} + +fn countColons(s: []const u8) usize { + var count: usize = 0; + for (s) |c| { + if (c == ':') count += 1; + } + return count; +} diff --git a/Task/Parsing-RPN-calculator-algorithm/Crystal/parsing-rpn-calculator-algorithm.cr b/Task/Parsing-RPN-calculator-algorithm/Crystal/parsing-rpn-calculator-algorithm.cr new file mode 100644 index 0000000000..26e3ce76f7 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Crystal/parsing-rpn-calculator-algorithm.cr @@ -0,0 +1,26 @@ +def rpn_calc (tokens) + stack = [] of Float64 + tokens.each do |token| + if token.is_a?(Float64) + stack.push token + else + x = stack.pop + y = stack.pop + case token + when "+" then stack.push(y + x) + when "-" then stack.push(y - x) + when "*" then stack.push(y * x) + when "/" then stack.push(y / x) + when "^" then stack.push(y ** x) + else raise "unknown operator: #{token}" + end + end + puts "%4s %s" % {token, stack} + end +end + +def tokenize (s) + s.split.map {|t| t.to_f rescue t } +end + +rpn_calc tokenize "3 4 2 * 1 5 - 2 3 ^ ^ / +" diff --git a/Task/Parsing-RPN-calculator-algorithm/Pluto/parsing-rpn-calculator-algorithm.pluto b/Task/Parsing-RPN-calculator-algorithm/Pluto/parsing-rpn-calculator-algorithm.pluto new file mode 100644 index 0000000000..7ae6961dd7 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Pluto/parsing-rpn-calculator-algorithm.pluto @@ -0,0 +1,33 @@ +require "queue" +local fmt = require "fmt" + +local function rpn_calculate(expr) + assert(#expr > 0, "expression cannot be empty") + print($"For expression = {expr}\n") + print("Token Action Stack") + local tokens = expr:split(" "):filter(|t| -> #t > 0):reorder() + local stk = new stack() + for tokens as token do + local d = tonumber(token) + if d then + stk:push(d) + fmt.print(" %d Push num onto top of stack %s", d, fmt.swrite(stk:toarray())) + elseif #token > 1 or !(token in "+-*/^") then + error($"{token} is not a valid token.") + elseif stk:size() < 2 then + error("Stack contains too few operands.") + else + local d1 = stk:pop() + local d2 = stk:pop() + stk:push(token == "+" ? d2 + d1 : + token == "-" ? d2 - d1 : + token == "*" ? d2 * d1 : + token == "/" ? d2 / d1 : d2 ^ d1) + fmt.print(" %s Apply op to top of stack %s", token, fmt.swrite(stk:toarray())) + end + end + fmt.print("\nThe final value is %0.14g", stk:pop()) +end + +local expr = "3 4 2 * 1 5 - 2 3 ^ ^ / +" +rpn_calculate(expr) diff --git a/Task/Parsing-RPN-calculator-algorithm/Red/parsing-rpn-calculator-algorithm.red b/Task/Parsing-RPN-calculator-algorithm/Red/parsing-rpn-calculator-algorithm.red new file mode 100644 index 0000000000..30608a1656 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Red/parsing-rpn-calculator-algorithm.red @@ -0,0 +1,21 @@ +Red [ "RPN Eval - Hinjo, July 25, 2025" ] +rpn-exec: func [exp [string!]] [ + stack: copy [] + blk: load exp ; convert into block + foreach tok blk [ + print [mold stack tok] + case [ + number? tok [append stack tok] + find [+ - * / ^] tok [ + if (length? stack) < 2 [ + print "Error: Two operands required!" exit ] + if tok = '^ [tok: '**] + b: take/last stack + a: take/last stack + append stack do compose [a (tok) b] + ] + ] + ] +] +; in Red, "^" is an escape char, so, it must be written as ^^ +rpn-exec "3 4 2 * 1 5 - 2 3 ^^ ^^ / +" diff --git a/Task/Parsing-RPN-to-infix-conversion/Red/parsing-rpn-to-infix-conversion.red b/Task/Parsing-RPN-to-infix-conversion/Red/parsing-rpn-to-infix-conversion.red new file mode 100644 index 0000000000..554fe499b0 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Red/parsing-rpn-to-infix-conversion.red @@ -0,0 +1,58 @@ +Red [ "RPN to Infix - Hinjo, 26 July 2025" ] + +rpn-to-infix: func [exp [string!]] [ + blk: load exp ; convert into block + stack: copy [] + stack-op: copy [] + + printstack: func [] [ + foreach x stack [ + prin rejoin [x " "] + ] + ] + push: func [val op] [ + append stack val + append stack-op op + ] + pop: function [] [ + val: take/last stack + op: take/last stack-op + compose [(val) (op)] + ] + + foreach tok blk [ + print rejoin [printstack] + case [ + number? tok [push tok 'n] + find [+ - * / ^] tok [ + b: pop + a: pop + if tok = '^ [ + if string? a/1 [ + if find "+-*/^^" a/2 + [a/1: rejoin ["(" a/1 ")"]] + ] + if string? b/1 [ + if find "+-*/" b/2 + [b/1: rejoin ["(" b/1 ")"]] + ] + ] + if find "*/" tok [ + if string? a/1 [ + if find "+-" a/2 + [a/1: rejoin ["(" a/1 ")"]] ] + if string? b/1 [ + if find "+-" b/2 + [b/1: rejoin ["(" b/1 ")"]] ] ] + + expr: rejoin compose [""(rejoin [(a/1)" "(tok)" "(b/1)])""] + push expr tok + ] + ] + ] + printstack print "" +] + +; in Red, "^" is an escape char, so, it must be written as ^^ +rpn-to-infix "3 4 2 * 1 5 - 2 3 ^^ ^^ / +" +rpn-to-infix "1 2 + 3 4 + ^^ 5 6 + ^^" diff --git a/Task/Parsing-Shunting-yard-algorithm/Red/parsing-shunting-yard-algorithm.red b/Task/Parsing-Shunting-yard-algorithm/Red/parsing-shunting-yard-algorithm.red new file mode 100644 index 0000000000..030fcaf0a9 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Red/parsing-shunting-yard-algorithm.red @@ -0,0 +1,90 @@ +Red [ "Shunting-Yard Infix to RPN - Hinjo, July 2025" ] + +; no error handling, assumed expr is spaced and correct +shunting: function [expr [string!] /trace] [ + output: copy [] ops: copy [] + prec: #["+" 2 "-" 2 "*" 3 "/" 3 "^^" 4 ] ; precedence + asc: #["+" "L" "-" "L" "*" "L" "/" "L" "^^" "R"] ; association + + stats: function [t] [ ; display basic tracing + if not trace [exit] + print [t "|" pad act 35 "|" pad (form output) 30 pad/left (reverse form ops) 15] + ] + + tokens: split expr " " + while [not empty? tokens] [ + tok: first tokens tokens: next tokens + case [ + find "0123456789" tok [ ; add numbers to output + act: "(a) Add number to output" append output tok stats tok + ] + find "(" tok [ ; push "(" to stack + act: "(b) Push ( to stack" append ops tok stats tok + ] + find ")" tok [ ; pop stack to output until "(" + while [(last ops) <> "("] [ ; assume input is correct! + act: "(c) Pop op to output" append output (take/last ops) stats tok + ] + act: "(d) Discard ( from stack" take/last ops stats " " ; should be ")" + ] + find "+-*/^^" tok [ + ; Pop higher or equal-left operators from stack + while [not empty? ops] [ + last-op: last ops + if (none? last-op) [break] + if (last-op = "(") [break] ; skip, we're in () + if (prec/:last-op < prec/:tok) [break] + if (asc/:last-op <> "L") [break] + act: "(e) Pop higher/equal op to output" append output take/last ops stats " " + ] + ; Now push current operator + act: "(f) Push op to stack" append ops tok stats tok + ] + ] + ] + ; flush the stack to output + act: "Finished. Flush ops:" stats " " + while [not empty? ops] [ + act: "(g) Pop op to output" append output (take/last ops) stats " " + ] + ; return output + form output +] + +; assumed input is space separated! ('^' is escape char!) +print "Some test for input and output with trace:" +print ["^/" s: "3 + 4 * 2 / ( 1 - 5 ) ^^ 2 ^^ 3"] shunting/trace s +print ["^/" s: "( ( 1 + 2 ) ^^ ( 3 + 4 ) ) ^^ ( 5 + 6 )"] shunting/trace s +print ["^/" s: "1 + 2 * 3 / 4 + 5"] shunting/trace s + +check: function [s t u][ + print [pad s 40 "|" pad t 30 "|" pad u 30 "|" t = u] +] + +print "^/Print input, validation and the output:" +s: "1 + 2 * 3 / 4 + 5" t: "1 2 3 * 4 / + 5 +" u: shunting s check s t u +s: "3 + 4 * 2 / ( 1 - 5 ) ^^ 2 ^^ 3" t: "3 4 2 * 1 5 - 2 3 ^^ ^^ / +" u: shunting s check s t u +s: "( ( 1 + 2 ) ^^ ( 3 + 4 ) ) ^^ ( 5 + 6 )" t: "1 2 + 3 4 + ^^ 5 6 + ^^" u: shunting s check s t u +s: "( 1 + 2 ) ^^ ( 3 + 4 ) ^^ ( 5 + 6 )" t: "1 2 + 3 4 + 5 6 + ^^ ^^" u: shunting s check s t u +s: "( ( 3 ^^ 4 ) ^^ 2 ^^ 9 ) ^^ 2 ^^ 5" t: "3 4 ^^ 2 9 ^^ ^^ 2 5 ^^ ^^" u: shunting s check s t u +s: "( 1 + 4 ) * ( 5 + 3 ) * 2 * 3" t: "1 4 + 5 3 + * 2 * 3 *" u: shunting s check s t u +s: "1 * 2 * 3 * 4" t: "1 2 * 3 * 4 *" u: shunting s check s t u +s: "1 + 2 + 3 + 4" t: "1 2 + 3 + 4 +" u: shunting s check s t u +s: "( 1 + 2 ) ^^ ( 3 + 4 )" t: "1 2 + 3 4 + ^^" u: shunting s check s t u +s: "( 5 ^^ 6 ) ^^ 7" t: "5 6 ^^ 7 ^^" u: shunting s check s t u +s: "5 ^^ 4 ^^ 3 ^^ 2" t: "5 4 3 2 ^^ ^^ ^^" u: shunting s check s t u +s: "1 + 2 + 3" t: "1 2 + 3 +" u: shunting s check s t u +s: "1 ^^ 2 ^^ 3" t: "1 2 3 ^^ ^^" u: shunting s check s t u +s: "( 1 ^^ 2 ) ^^ 3" t: "1 2 ^^ 3 ^^" u: shunting s check s t u +s: "1 - 1 + 3" t: "1 1 - 3 +" u: shunting s check s t u +s: "3 + 1 - 1" t: "3 1 + 1 -" u: shunting s check s t u +s: "1 - ( 2 + 3 )" t: "1 2 3 + -" u: shunting s check s t u +s: "4 + 3 + 2" t: "4 3 + 2 +" u: shunting s check s t u +s: "5 + 4 + 3 + 2" t: "5 4 + 3 + 2 +" u: shunting s check s t u +s: "5 * 4 * 3 * 2" t: "5 4 * 3 * 2 *" u: shunting s check s t u +s: "5 + 4 - ( 3 + 2 )" t: "5 4 + 3 2 + -" u: shunting s check s t u +s: "3 - 4 * 5" t: "3 4 5 * -" u: shunting s check s t u +s: "3 * ( 4 - 5 )" t: "3 4 5 - *" u: shunting s check s t u +s: "( 3 - 4 ) * 5" t: "3 4 - 5 *" u: shunting s check s t u +s: "4 * 2 + 1 - 5" t: "4 2 * 1 + 5 -" u: shunting s check s t u +s: "4 * 2 / ( 1 - 5 ) ^^ 2" t: "4 2 * 1 5 - 2 ^^ /" u: shunting s check s t u diff --git a/Task/Pascals-triangle-Puzzle/EasyLang/pascals-triangle-puzzle.easy b/Task/Pascals-triangle-Puzzle/EasyLang/pascals-triangle-puzzle.easy new file mode 100644 index 0000000000..6ee8467121 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/EasyLang/pascals-triangle-puzzle.easy @@ -0,0 +1,29 @@ +# Known: +# [ 151] +# [a ][b ] +# [40][c ][d ] +# [e ][f ][g ][h ] +# [ X][11][ Y][ 4][ Z] +# +# Y = X + Z +# +repeat + x += 1 + e = x + 11 + f = 40 - e + y = f - 11 + g = y + 4 + c = f + g + a = c + 40 + b = 151 - a + d = b - c + h = d - g + z = h - 4 + until y = x + z +. +numfmt 3 0 +print " " & 151 +print " " & a & b +print " " & 40 & c & d +print " " & e & f & g & h +print x & 11 & y & 4 & z diff --git a/Task/Pascals-triangle-Puzzle/Fortran/pascals-triangle-puzzle.f b/Task/Pascals-triangle-Puzzle/Fortran/pascals-triangle-puzzle.f new file mode 100644 index 0000000000..47bd5d10b1 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Fortran/pascals-triangle-puzzle.f @@ -0,0 +1,124 @@ +! +module solve_pyramid_gauss + implicit none +contains + subroutine gauss + implicit none + integer, parameter :: n = 3 + real(kind=8) :: a(n, n), b(n), x(n) + integer :: i, j, k + real(kind=8) :: factor, tmp_row(n), tmp_b + + ! Build the 3×3 system + a = 0.0d0 + b = 0.0d0 + + ! Eq1: X + Y = 18 + a(1, 1) = 1 + a(1, 2) = 1 + b(1) = 18 + + ! Eq2: X + 6Y + Z = 91 + a(2, 1) = 1 + a(2, 2) = 6 + a(2, 3) = 1 + b(2) = 91 + + ! Eq3: -X + Y - Z = 0 + a(3, 1) = -1 + a(3, 2) = 1 + a(3, 3) = -1 + b(3) = 0 + + ! Gaussian elimination with manual pivot swap + do k = 1, n - 1 + ! if pivot is near zero, swap with next row + if (abs(a(k, k)) < 1e-12) then + tmp_row = a(k, :) + a(k, :) = a(k + 1, :) + a(k + 1, :) = tmp_row + tmp_b = b(k) + b(k) = b(k + 1) + b(k + 1) = tmp_b + end if + + ! eliminate below + do i = k + 1, n + factor = a(i, k) / a(k, k) + do j = k, n + a(i, j) = a(i, j) - factor * a(k, j) + end do + b(i) = b(i) - factor * b(k) + end do + end do + + ! back substitution + x(n) = b(n) / a(n, n) + do i = n - 1, 1, -1 + factor = 0.0d0 + do j = i + 1, n + factor = factor + a(i, j) * x(j) + end do + x(i) = (b(i) - factor) / a(i, i) + end do + + print "(/,1X,A)", "Gaussian Solution:" + print "(2(A,1x,I0,3x),a,1x,i0)", " X =", int(x(1)), " Y =", int(x(2)), " Z =", int(x(3)) + + end subroutine gauss + +end module solve_pyramid_gauss +program solve_pyramid + use solve_pyramid_gauss + implicit none + + integer, parameter :: maxval = 100 + integer :: x, y, z + integer :: a(5), b(4), c(3), d(2), e + + ! Brute-force X and Z in [0, MAXVAL] + do x = 0, maxval + do z = 0, maxval + y = x + z + + ! Base row: [ X, 11, Y, 4, Z ] + a = (/ x, 11, y, 4, z /) + + ! Build level 4 + b(1) = a(1) + a(2) + b(2) = a(2) + a(3) + b(3) = a(3) + a(4) + b(4) = a(4) + a(5) + + ! Build level 3 + c(1) = b(1) + b(2) + c(2) = b(2) + b(3) + c(3) = b(3) + b(4) + + ! Check the known middle-upper constraint + if (c(1) == 40) then + + ! Build level 2 and apex + d(1) = c(1) + c(2) + d(2) = c(2) + c(3) + e = d(1) + d(2) + + ! Check the apex constraint + if (e == 151) then + print *, "Solution found:" + print "(2(A,1x,I0,3x),a,1x,i0)", " X =", x, " Y =", y, " Z =", z + print *, " Pyramid:" + print *, " Top: [", e, "]" + print *, " Level 2: [", d(1), " ", d(2), "]" + print *, " Level 3: [", c(1), " ", c(2), " ", c(3), "]" + print *, " Level 4: [", b(1), " ", b(2), " ", b(3), " ", b(4), "]" + print *, " Base row: [", a(1), " ", a(2), " ", a(3), " ", & + a(4), " ", a(5), "]" + end if + + end if + + end do + end do + call gauss +end program solve_pyramid diff --git a/Task/Pascals-triangle-Puzzle/JavaScript/pascals-triangle-puzzle.js b/Task/Pascals-triangle-Puzzle/JavaScript/pascals-triangle-puzzle.js new file mode 100644 index 0000000000..7284dc445d --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/JavaScript/pascals-triangle-puzzle.js @@ -0,0 +1,102 @@ +class Matrix { + constructor(...lists) { + if (lists.length === 1 && Array.isArray(lists[0][0])) { + this.matrix = lists[0]; + } else { + this.matrix = lists; + } + } + + toString() { + return JSON.stringify(this.matrix); + } + + determinant() { + if (this.matrix.length === 1) { + return this.get(0, 0); + } + if (this.matrix.length === 2) { + return this.get(0, 0) * this.get(1, 1) - this.get(0, 1) * this.get(1, 0); + } + let sum = 0; + let sign = 1; + for (let i = 0; i < this.matrix.length; i++) { + sum += sign * this.get(0, i) * this.coFactor(0, i).determinant(); + sign *= -1; + } + return sum; + } + + coFactor(row, col) { + const mat = []; + for (let i = 0; i < this.matrix.length; i++) { + if (i === row) { + continue; + } + const list = []; + for (let j = 0; j < this.matrix.length; j++) { + if (j === col) { + continue; + } + list.push(this.get(i, j)); + } + mat.push(list); + } + return new Matrix(mat); + } + + replaceColumn(b, column) { + const mat = []; + for (let row = 0; row < this.matrix.length; row++) { + const list = []; + for (let col = 0; col < this.matrix.length; col++) { + let value = this.get(row, col); + if (col === column) { + value = b[row]; + } + list.push(value); + } + mat.push(list); + } + return new Matrix(mat); + } + + get(row, col) { + return this.matrix[row][col]; + } +} + +function cramersRule(matrix, b) { + const denominator = matrix.determinant(); + const result = []; + for (let i = 0; i < b.length; i++) { + result.push(matrix.replaceColumn(b, i).determinant() / denominator); + } + return result; +} + +function main() { + const mat = new Matrix( + [1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0], + [0, 0, 0, 0, 0, 0, 0, 0, -1, 1, -1], + [0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0], + [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 1, 1, 0, -1, 0, 0, 0, 0, 0, 0], + [0, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0], + [0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 0, -1, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0] + ); + + const b = [11, 11, 0, 4, 4, 40, 0, 0, 40, 0, 151]; + const solution = cramersRule(mat, b); + + console.log("Solution =", solution); + console.log(`X = ${solution[8].toFixed(2)}`); + console.log(`Y = ${solution[9].toFixed(2)}`); + console.log(`Z = ${solution[10].toFixed(2)}`); +} + +main(); diff --git a/Task/Pascals-triangle-Puzzle/Pluto/pascals-triangle-puzzle.pluto b/Task/Pascals-triangle-Puzzle/Pluto/pascals-triangle-puzzle.pluto new file mode 100644 index 0000000000..594ed3afb6 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Pluto/pascals-triangle-puzzle.pluto @@ -0,0 +1,19 @@ +local function is_integral(x, tol) + local frac = {math.modf(x)}[2] + return math.abs(frac) <= tol +end + +local function pascal(a, b, mid, top) + local yd = (top - 4 * (a + b)) / 7 + if !is_integral(yd, 0.0001) then return {0, 0, 0} end + local y = math.floor(yd) + local x = mid - 2 * a - y + return {x, y, y - x} +end + +local sol = pascal(11, 4, 40, 151) +if sol[0] != 0 then + print(string.format("Solution is: x = %d, y = %d, z = %d", sol[1], sol[2], sol[3])) +else + print("There is no solution") +end diff --git a/Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb b/Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb new file mode 100644 index 0000000000..5b61f4dd94 --- /dev/null +++ b/Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb @@ -0,0 +1,16 @@ +create or replace function pascal_triangle(n) as table ( + with recursive cte as ( + SELECT 0 as i, [1]::BIGINT[] as row, + UNION ALL + SELECT i+1 as i, + ([1] || list_transform(row, (x,ix) -> x + (coalesce(row[ix+1], 0)))) as row + FROM cte + WHERE i < n + ) + select row as "pascal_triangle" FROM cte + order by i +); + +.print The results for all n<=0 are the same: +select * as "pascal_triangle(0)" from pascal_triangle(0); +from pascal_triangle(4) _("pascal_triangle(4)"); diff --git a/Task/Pathological-floating-point-problems/ALGOL-68/pathological-floating-point-problems.alg b/Task/Pathological-floating-point-problems/ALGOL-68/pathological-floating-point-problems.alg index 341dc7dfc3..77c11b77f3 100644 --- a/Task/Pathological-floating-point-problems/ALGOL-68/pathological-floating-point-problems.alg +++ b/Task/Pathological-floating-point-problems/ALGOL-68/pathological-floating-point-problems.alg @@ -1,9 +1,16 @@ BEGIN + + # show the sizes of REAL, LONG REAL and LONG LONG real # + print( ( "Approximate sizes of real numbers available: " ) ); + print( ( "REAL: ", whole( real width, 0 ) ) ); + print( ( ", LONG REAL: ", whole( long real width, 0 ) ) ); + print( ( ", default for LONG LONG REAL: ", whole( long long real width, 0 ) ) ); + print( ( newline, newline ) ); + # task 1 # BEGIN - PR precision 32 PR - print( ( " 32 digit REAL numbers", newline ) ); - [ 1 : 100 ]LONG LONG REAL v; + print( ( whole( long real width, -4 ), " digit REAL numbers", newline ) ); + [ 1 : 100 ]LONG REAL v; v[ 1 ] := 2; v[ 2 ] := -4; FOR n FROM 3 TO UPB v DO v[ n ] := 111 - ( 1130 / v[ n - 1 ] ) + ( 3000 / ( v[ n - 1 ] * v[ n - 2 ] ) ) OD; @@ -12,8 +19,7 @@ BEGIN print( ( "n = 100 ", fixed( v[ 100 ], -22, 16 ), newline ) ) END; BEGIN - PR precision 120 PR - print( ( "120 digit REAL numbers", newline ) ); + print( ( whole( long long real width, -4 ), " digit REAL numbers", newline ) ); [ 1 : 100 ]LONG LONG REAL v; v[ 1 ] := 2; v[ 2 ] := -4; @@ -23,25 +29,24 @@ BEGIN print( ( newline ) ); # task 2 # BEGIN - print( ( "single precision REAL numbers...", newline ) ); + print( ( "standard precision REAL numbers...", newline ) ); REAL chaotic balance := exp( 1 ) - 1; - print( ( "initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); + print( ( " initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); FOR i FROM 1 TO 25 DO ( chaotic balance *:= i ) -:= 1 OD; - print( ( "25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) + print( ( " 25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) END; BEGIN - print( ( "double precision REAL numbers...", newline ) ); + print( ( "double precision LONG REAL numbers...", newline ) ); LONG REAL chaotic balance := long exp( 1 ) - 1; - print( ( "initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); + print( ( " initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); FOR i FROM 1 TO 25 DO ( chaotic balance *:= i ) -:= 1 OD; - print( ( "25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) + print( ( " 25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) END; BEGIN - PR precision 32 PR - print( ( " 32 digit REAL numbers...", newline ) ); + print( ( whole( long long real width, -10 ), " digit LONG LONG REAL numbers...", newline ) ); LONG LONG REAL chaotic balance := long long exp( 1 ) - 1; - print( ( "initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); + print( ( " initial chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ); FOR i FROM 1 TO 25 DO ( chaotic balance *:= i ) -:= 1 OD; - print( ( "25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) + print( ( " 25 year chaotic balance: ", fixed( chaotic balance, -22, 16 ), newline ) ) END END diff --git a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-1.rexx b/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-1.rexx deleted file mode 100644 index b369f06758..0000000000 --- a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-1.rexx +++ /dev/null @@ -1,15 +0,0 @@ -/*REXX pgm (pathological FP problem): a sequence that might converge to a wrong limit. */ -parse arg digs show . /*obtain optional arguments from the CL*/ -if digs=='' | digs=="," then digs= 150 /*Not specified? Then use the default.*/ -if show=='' | show=="," then show= 20 /* " " " " " " */ -numeric digits digs /*have REXX use "digs" decimal digits. */ -#= 2 4 5 6 7 8 9 20 30 50 100 /*the indices to display value of V.n */ -fin= word(#, words(#) ) /*find the last (largest) index number.*/ -w= length(fin) /* " " length (in dec digs) of FIN.*/ -v.1= 2 /*the value of the first V element. */ -v.2=-4 /* " " " " second " " */ - do n=3 to fin; nm1= n-1; nm2= n-2 /*compute some values of the V elements*/ - v.n= 111 - 1130/v.nm1 + 3000/(v.nm1*v.nm2) /* " a value of a " element.*/ - /*display digs past the dec. point───┐ */ - if wordpos(n, #)\==0 then say 'v.'left(n, w) "=" format(v.n, , show) - end /*n*/ /*stick a fork in it, we're all done. */ diff --git a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-2.rexx b/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-2.rexx deleted file mode 100644 index 1378f5331a..0000000000 --- a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-2.rexx +++ /dev/null @@ -1,18 +0,0 @@ -/*REXX pgm (pathological FP problem): the chaotic bank society offering a new investment*/ -e=2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713, - ||8217852516642742746639193200305992181741359662904357290033429526059563073813232862794, - ||3490763233829880753195251019011573834187930702154089149934884167509244761460668082264, - ||8001684774118537423454424371075390777449920695517027618386062613313845830007520449338 -d = length(e) - length(.) /*subtract one for the decimal point. */ -parse arg digs show y . /*obtain optional arguments from the CL*/ -if digs=='' | digs=="," then digs= d /*Not specified? Then use the default.*/ -if show=='' | show=="," then show= 20 /* " " " " " " */ -if y=='' | y=="," then y= 25 /* " " " " " " */ -numeric digits digs /*have REXX use "digs" decimal digits. */ -$= e - 1 /*subtract $1 from e, that's da deposit*/ - /* [↑] value of newly opened account. */ - do n=1 for y /*compute the value of the account/year*/ - $= $*n - 1 /* " " " " " account now.*/ - end /*n*/ -@@@= 'With ' d " decimal digits, the balance after " y ' years is: ' -say @@@ '$'format($, , show) / 1 /*stick a fork in it, we're all done. */ diff --git a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-3.rexx b/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-3.rexx deleted file mode 100644 index c0da0ee523..0000000000 --- a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems-3.rexx +++ /dev/null @@ -1,13 +0,0 @@ -/*REXX pgm (pathological FP problem): the Siegfried Rump's example (problem dated 1988).*/ -parse arg digs show . /*obtain optional arguments from the CL*/ -if digs=='' | digs=="," then digs=150 /*Not specified? Then use the default.*/ -if show=='' | show=="," then show= 20 /* " " " " " " */ -numeric digits digs /*have REXX use "digs" decimal digits. */ -a= 77617.0 /*initialize A to it's defined value.*/ -b= 33096.0 /* " B " " " " */ - /*display SHOW digits past the dec. pt.*/ -say 'f(a,b)=' format( f(a,b), , show) /*display result from the F function.*/ -exit /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -f: procedure; parse arg a,b; return 333.75* b**6 + a**2 * (11* a**2* b**2 - b**6, - - 121*b**4 - 2) + 5.5*b**8 + a / (2*b) diff --git a/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems.rexx b/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems.rexx new file mode 100644 index 0000000000..fe792b679e --- /dev/null +++ b/Task/Pathological-floating-point-problems/REXX/pathological-floating-point-problems.rexx @@ -0,0 +1,51 @@ +-- 28 Jul 2025 +include Settings +arg digs +if digs = '' then + digs=9 +numeric digits digs + +say 'PATHOLOGICAL FLOATING POINT PROBLEMS' +say version +say digs 'digits precision' +say +call Sequence +call Society +call Rump +call Timer +exit + +Sequence: +procedure +say 'Sequence goes to wrong limit...' +show='3 4 5 6 7 8 20 30 50 100' +a=2; b=-4 +do n = 3 to 100 + c=111-1130/b+3000/(a*b); a=b; b=c + if Wordpos(n,show) > 0 then + say 'n =' Right(n,3) Left(c,19) +end +say +return + +Society: +procedure expose Memo. +say 'The Chaotic Bank Society...' +e=e()/1; b=e-1 +say Right(0,2) Left(b,18) +do n = 1 to 25 + b=b*n-1 + say Right(n,2) Left(b,18) +end +say +return + +Rump: +procedure +say 'Siegfried Rumps''s example...' +a=77617; b=33096 +say Left(333.75*b**6 + a**2*(11*a**2*b**2-b**6-121*b**4-2) + 5.5*b**8 + a/(2*b),18) +say +return + +include Math diff --git a/Task/Pell-numbers/Julia/pell-numbers.jl b/Task/Pell-numbers/Julia/pell-numbers-1.jl similarity index 100% rename from Task/Pell-numbers/Julia/pell-numbers.jl rename to Task/Pell-numbers/Julia/pell-numbers-1.jl diff --git a/Task/Pell-numbers/Julia/pell-numbers-2.jl b/Task/Pell-numbers/Julia/pell-numbers-2.jl new file mode 100644 index 0000000000..9884f44748 --- /dev/null +++ b/Task/Pell-numbers/Julia/pell-numbers-2.jl @@ -0,0 +1,2 @@ +pell(n::Integer) = last(BigInt[2 1; 1 0] ^ n * BigInt[1, 0]) +pelllucas(n::Integer) = last(BigInt[2 1; 1 0] ^ n * BigInt[2, 2]) diff --git a/Task/Pell-numbers/PARI-GP/pell-numbers.parigp b/Task/Pell-numbers/PARI-GP/pell-numbers.parigp new file mode 100644 index 0000000000..f2e163f191 --- /dev/null +++ b/Task/Pell-numbers/PARI-GP/pell-numbers.parigp @@ -0,0 +1,59 @@ +\\--- pell.gp ------------------------------------------------------------ + +\\ 1) Define Pell numbers and Pell–Lucas numbers by simple recursion + +pell(n) = +{ + if (n==0, return(0)); + if (n==1, return(1)); + return(2*pell(n-1) + pell(n-2)); +} + +pellL(n) = +{ + if (n==0, return(2)); + if (n==1, return(2)); + return(2*pellL(n-1) + pellL(n-2)); +} + +\\ 2) Compute the first 10 Pell and Pell–Lucas numbers +pns = vector(10, i, pell(i-1)); \\ pell(0) .. pell(9) +plns = vector(10, i, pellL(i-1)); \\ pellL(0) .. pellL(9) + +print("Pell numbers (n=0..9): ", pns); +print("Pell–Lucas numbers (n=0..9): ", plns); + +\\ 3) Form the ratios (Pell–Lucas)/2 over Pell, skipping n=0 +\\ i.e. for n=1..9 +denom = vector(9, i, pns[i+1]); \\ pns[2..10] +numr = vector(9, i, plns[i+1]/2); \\ plns[2..10]/2 +approx = vector(9, i, numr[i]/denom[i]); + +print("Ratios (pellL(n)/2) / pell(n) for n=1..9:"); +for (i=1,9, print(i, ": ", approx[i])); +print("Numeric floats:"); +for (i=1,9, print(i, ": ", real(approx[i]))); + +\\ 4) List (n, pell(n)) for n=0..100 and pick the first 10 where pell(n) is prime +plist = vector(101, i, [i-1, pell(i-1)]); +primespell = select(x->isprime(x[2]), plist); +print("First 10 Pell(n) that are prime:"); +for (i=1,10, print(primespell[i])); + +\\ 5) Define PellS(n) = If[n==0,1, pell(2n) + pell(2n+1)] +pellS(n) = if(n==0, 1, pell(2*n) + pell(2*n+1)); +print("PellS(n) for n=0..19:"); +print(vector(20, n, pellS(n))); + +\\ 6) Generate Pythagorean triples from Pell numbers: +\\ short = sum_{k=1..2n} pell(k), long = short+1, hypo = pell(2n+1) +pythag(n) = +{ + short = sum(k=1, 2*n, pell(k)); + long = short + 1; + hypo = pell(2*n + 1); + return([short, long, hypo]); +} + +print("Pythagorean triples for n=0..9:"); +for (n=0,9, print(n, ": ", pythag(n))); diff --git a/Task/Perfect-numbers/00-TASK.txt b/Task/Perfect-numbers/00-TASK.txt index 7d242fe208..1f06bae42d 100644 --- a/Task/Perfect-numbers/00-TASK.txt +++ b/Task/Perfect-numbers/00-TASK.txt @@ -1,6 +1,6 @@ [[category:Discrete math]] {{task|Prime Numbers}} - +{{task|Numbers}} Write a function which says whether a number is perfect.
    diff --git a/Task/Perfect-shuffle/FutureBasic/perfect-shuffle.basic b/Task/Perfect-shuffle/FutureBasic/perfect-shuffle.basic new file mode 100644 index 0000000000..1d22506d8c --- /dev/null +++ b/Task/Perfect-shuffle/FutureBasic/perfect-shuffle.basic @@ -0,0 +1,81 @@ +// +// Perfect Shuffle +// +// FutureBasic 7.0.34, August 2025 R.W +// uses MDA arrays + +_deck = 1 //the MDA tag for the deck array +_shuffled = 2 //the MDA tag for shuffled deck + +Window 1 + +// +// fill MDA des array with +// number from 1 to n +void local fn fillDeck(des as Int, n as Int) + Int x + mda_clear des + for x = 1 to n + mda des(x) = x + next x +end fn + +// +// check if deck in MDA tag array +// is in order + +local fn inOrder (tag as Int,siz as Int) as boolean + boolean isInOrder = _True + int x, lo, hi + for x = 1 to siz - 1 + lo = mda tag(x) + hi = mda tag(x + 1) + if lo > hi then return _False + next x +end fn = isInOrder + +// +// faro out shuffle +// the deck is halves then both halves interweaved 1 by 1 + +local fn faroShuffle(src as Int, des as Int, n as Int) + Int i + mda_clear des + // uses temporary shuffled deck array + for i = 1 to n/2 + mda des(2 * i - 1) = mda src(i) + mda des(2 * i) = mda src( n / 2 + i) + next i + for i = 1 to n //put it back + mda src(i) = mda des(i) + next i +end fn + +// shuffles needed for a perfect +// shuffle given siz + +local fn neededShuffle(siz as Int) as Int + Int s + s = 0 + fn fillDeck(_deck, siz) + do + fn faroShuffle (_deck, _shuffled, siz) + s++ + until fn inOrder(_deck, siz) == _True +end fn = s + +window 1,@"Perfect Shuffle" + +Int testData(7) = {0, 8, 24, 52, 100, 1020, 1024, 10000} + +print "CARDS SHUFFLES" +print "-------------------" + +Int x, k +for x = 1 to 7 + print using "##### ";testData(x); "needs "; ¬ + fn neededShuffle(testData(x)) +next x + +handleEvents +// diff --git a/Task/Perfect-shuffle/Pluto/perfect-shuffle.pluto b/Task/Perfect-shuffle/Pluto/perfect-shuffle.pluto new file mode 100644 index 0000000000..eec5f4ed25 --- /dev/null +++ b/Task/Perfect-shuffle/Pluto/perfect-shuffle.pluto @@ -0,0 +1,45 @@ +local fmt = require "fmt" +require "table2" + +local function are_same(a, b) + for i = 1, #a do + if a[i] != b[i] then return false end + end + return true +end + +local function perfect_shuffle(a) + local n = #a + local b = table.rep(n, 0) + local hsize = n // 2 + for i = 1, hsize do b[i * 2 - 1] = a[i] end + local j = 2 + for i = hsize + 1, n do + b[j] = a[i] + j += 2 + end + return b +end + +local function count_shuffles(a) + local n = #a + assert(n % 2 == 0 and n > 1, "Array must be even-sized and non-empty.") + local b = a + local count = 0 + while true do + local c = perfect_shuffle(b) + ++count + if are_same(a, c) then return count end + b = c + end +end + +print("Deck size Num shuffles") +print("--------- ------------") +local sizes = {8, 24, 52, 100, 1020, 1024, 10000} +for sizes as size do + local a = {0} + for i = 2, size do a[i] = i - 1 end + local count = count_shuffles(a) + fmt.print("%-9d %d", size, count) +end diff --git a/Task/Perlin-noise/EasyLang/perlin-noise.easy b/Task/Perlin-noise/EasyLang/perlin-noise.easy index 8fd4b68670..7e5f02c004 100644 --- a/Task/Perlin-noise/EasyLang/perlin-noise.easy +++ b/Task/Perlin-noise/EasyLang/perlin-noise.easy @@ -66,7 +66,7 @@ print noise 3.14 42 7 # demo for y = 0 to 199 for x = 0 to 199 - p = noise (x / 30) (y / 30) 0.1 + p = 100 * noise (x / 30) (y / 30) 0.1 gcolor3 p p p grect x / 2 y / 2 0.6 0.6 . diff --git a/Task/Perlin-noise/Zig/perlin-noise.zig b/Task/Perlin-noise/Zig/perlin-noise.zig index fe94c95c9d..8362d0011f 100644 --- a/Task/Perlin-noise/Zig/perlin-noise.zig +++ b/Task/Perlin-noise/Zig/perlin-noise.zig @@ -1,4 +1,4 @@ -// Made for Zig 0.10.0 +// Made for Zig 0.14.1 // This implementation works with generic float types const std = @import("std"); @@ -13,9 +13,9 @@ pub fn noise3D(comptime T: type, x: T, y: T, z: T) T { @setRuntimeSafety(false); // Truncate float to u8 (256 possible values) - const x_i = @intCast(u8, @floatToInt(isize, @floor(x)) & 255); - const y_i = @intCast(u8, @floatToInt(isize, @floor(y)) & 255); - const z_i = @intCast(u8, @floatToInt(isize, @floor(z)) & 255); + const x_i: u8 = @truncate(@as(usize, @bitCast(@as(isize, @intFromFloat(@floor(x)))))); + const y_i: u8 = @truncate(@as(usize, @bitCast(@as(isize, @intFromFloat(@floor(y)))))); + const z_i: u8 = @truncate(@as(usize, @bitCast(@as(isize, @intFromFloat(@floor(z)))))); // Float remainder of coords (eg: 5.34 -> 0.34) const x_r = x - @floor(x); diff --git a/Task/Permutations-Derangements/DuckDB/permutations-derangements.duckdb b/Task/Permutations-Derangements/DuckDB/permutations-derangements.duckdb new file mode 100644 index 0000000000..7af4d1f4a5 --- /dev/null +++ b/Task/Permutations-Derangements/DuckDB/permutations-derangements.duckdb @@ -0,0 +1,49 @@ +# Report whether lst is deranged, i.e. if lst[i] = i for any i +# The following might achieve short-circuit semantics as it uses `LIMIT 1` +CREATE OR REPLACE FUNCTION deranged(lst) as ( + select not exists + (from (select unnest(lst) as x, generate_subscripts(lst, 1) as ix) + where x = ix + limit 1) +); + +CREATE OR REPLACE FUNCTION derangements(lst) as table ( + WITH RECURSIVE permute(perm, remaining) as ( + -- base case + SELECT + [] as perm, + lst as remaining + UNION ALL + -- recursive case: add one element from remaining to perm and remove it from remaining + SELECT + (perm || [element]) AS perm, + list_filter(remaining, x -> x != element) AS remaining + FROM (select *, unnest(remaining) AS element + FROM permute) + where deranged(perm || [element]) + ) + SELECT perm + FROM permute + WHERE length(remaining) = 0 +); + +CREATE OR REPLACE FUNCTION subfact(num) as table ( + with recursive cte(n,psub,sub) as ( + -- psub means `previous sub` + select 0 as n, 1::HUGEINT as psub, 1::HUGEINT as sub + union all + select + n+1 as n, + sub as psub, + (n * (sub + psub)) as sub + from cte + where n < num + ) + select n, sub from cte + order by n +) ; + +select t.n, + sub as subfactorial, + (select count(*) from derangements(range(1, 1+t.n))) as count +from range(0,10) t(n) positional join (from subfact(9)) ; diff --git a/Task/Permutations-by-swapping/Zig/permutations-by-swapping.zig b/Task/Permutations-by-swapping/Zig/permutations-by-swapping.zig new file mode 100644 index 0000000000..e97e9dd5e8 --- /dev/null +++ b/Task/Permutations-by-swapping/Zig/permutations-by-swapping.zig @@ -0,0 +1,50 @@ +const std = @import("std"); + +// Generic function to generate permutations +fn generate(comptime T: type, a: []T, output: fn ([]const T, i64) void) void { + const n = a.len; + var c = std.heap.page_allocator.alloc(usize, n) catch unreachable; + defer std.heap.page_allocator.free(c); + + @memset(c, 0); + + var i: usize = 1; + var sign: i64 = 1; + output(a, sign); + + while (i < n) { + if (c[i] < i) { + if ((i & 1) == 0) { + std.mem.swap(T, &a[0], &a[i]); + } else { + std.mem.swap(T, &a[c[i]], &a[i]); + } + sign = -sign; + output(a, sign); + c[i] += 1; + i = 1; + } else { + c[i] = 0; + i += 1; + } + } +} + +// Function to print permutation and its sign +fn printPermutation(comptime T: type) fn ([]const T, i64) void { + return struct { + fn inner(a: []const T, sign: i64) void { + std.debug.print("{any} {}\n", .{ a, sign }); + } + }.inner; +} + +pub fn main() !void { + std.debug.print("Permutations and signs for three items:\n", .{}); + var a = [_]i32{ 0, 1, 2 }; + generate(i32, &a, printPermutation(i32)); + + std.debug.print("\nPermutations and signs for four items:\n", .{}); + var b = [_]i32{ 0, 1, 2, 3 }; + generate(i32, &b, printPermutation(i32)); +} diff --git a/Task/Permutations/DuckDB/permutations.duckdb b/Task/Permutations/DuckDB/permutations.duckdb new file mode 100644 index 0000000000..240bf78912 --- /dev/null +++ b/Task/Permutations/DuckDB/permutations.duckdb @@ -0,0 +1,18 @@ +CREATE OR REPLACE FUNCTION permute(lst) as table ( + WITH RECURSIVE permute(perm, remaining) as ( + -- base case + SELECT + [] as perm, + lst as remaining + UNION ALL + -- recursive case: add one element from remaining to perm and remove it from remaining + SELECT + (perm || [element]) AS perm, + (remaining[1:i-1] || remaining[i+1:]) AS remaining + FROM (select *, unnest(remaining) AS element, generate_subscripts(remaining,1) as i + FROM permute) + ) + SELECT perm + FROM permute + WHERE length(remaining) = 0 +); diff --git a/Task/Permutations/Pluto/permutations.pluto b/Task/Permutations/Pluto/permutations.pluto new file mode 100644 index 0000000000..ae63f8ec8d --- /dev/null +++ b/Task/Permutations/Pluto/permutations.pluto @@ -0,0 +1,6 @@ +require "perm" +local fmt = require "fmt" + +local a = {1, 2, 3} +print($"There are {perm.count(#a)} permutations of {fmt.swrite(a)}, namely:") +fmt.lprint(perm.list(a)) diff --git a/Task/Permutations/TAV/permutations-1.tav b/Task/Permutations/TAV/permutations-1.tav new file mode 100644 index 0000000000..f512ce3260 --- /dev/null +++ b/Task/Permutations/TAV/permutations-1.tav @@ -0,0 +1,24 @@ +\( Calculate all permutations of integers 1..n + + General variant: simple, single array, recursive, not in lexical order + A row with n places is used, initially 0. + The current element l replaces the free places one by one, + and the next element l+1 is probed with the array. +\) +\C Use publication mode with keywords instead of symbols +permute1 (l) to (n) fill (r): + if l > n + print join r \ output requires most of CPU time + return + for j = from 1 upto n + if r[j] == 0 + r[j] = l + permute1 l+1 to n fill r + r[j] = 0 + +\( command line parameter is number of elements +\) +main (parms):+ + n = string parms[1] as integer else 3 + r = new row size n init 0 + permute1 1 to n fill r diff --git a/Task/Permutations/TAV/permutations-2.tav b/Task/Permutations/TAV/permutations-2.tav new file mode 100644 index 0000000000..662653d8e2 --- /dev/null +++ b/Task/Permutations/TAV/permutations-2.tav @@ -0,0 +1,28 @@ +\( Calculate all permutations of integers 1..n + + Second variant: two arrays, recursive, reverse lexical order. + Array (a) has the remaining elements which are each appended to the + array (t), removed and the rest applied to the expanded (t). + The elements of row (a) may have any value; only void or not void is used. +\) +\c Use native mode (symbols instead of keywords, class functions) +permute2 (a) to (t): + l =: a.Count \ number of non-void elements + ? l > 0 + ?# i =: row a give keys \ of non-void elements only + t[l] =: i + a[i] =: () \ decrements a.Count + permute2 a to t + a[i] =: i \ any non-void value + :> + \ print result in reverse order; output requires most CPU time + print tuple t::as tuple transpose + + +\( command line parameter is number of elements +\) +main (parms):+ + n =: string parms[1] as integer else 3 + a =: new row from 1 upto n \ fill 1..n + t =: new row size n \ intially void + permute2 a to t diff --git a/Task/Permutations/TAV/permutations-3.tav b/Task/Permutations/TAV/permutations-3.tav new file mode 100644 index 0000000000..706452cc6f --- /dev/null +++ b/Task/Permutations/TAV/permutations-3.tav @@ -0,0 +1,17 @@ +\C Publication syntax +permute (k) list (l): + if k == l.Count + print row l as tuple + return + for i = from k upto l.Count + row l swap i with k + permute k+1 list l + row l swap k with i + +row (l) swap (i) with (k): + t = l[i] + l[i] = l[k] + l[k] = t + +main (parms):+ + permute 1 list [1, 2, 3] \ row literal, not tuple diff --git a/Task/Permutations/TAV/permutations-4.tav b/Task/Permutations/TAV/permutations-4.tav new file mode 100644 index 0000000000..6462e04c21 --- /dev/null +++ b/Task/Permutations/TAV/permutations-4.tav @@ -0,0 +1,44 @@ +\( Two arrays, iterative, not in lexical order. + Input row (a) provides for each element where it was inserted last. +\) +\C Publication syntax +permute iterative (n): + a = new row size n \ state of last number + r = new row size n \ output row + l = 1 + while l > 0 \ need to start over + \ find the key of a void element + k = 0 \ if not found + for j = from a[l] + 1 upto n + if r[j] == () \ void in result + k = j \ use it + continue + \ evaluate + if k != 0 + \ key for void cell to be set + r[k] = l + a[l] = k + if l == n + \ permuation complete + print join r + \ backup + k = a[l] + r[k] = () + continue + l += 1 + continue \ next level + \ no void cell found + if l == 1 + break \ done, no more permutations + \ backup + a[l] = 0 + l -= 1 + k = a[l] + r[k] = () + continue + +\( command line parameter: number of elements +\) +main (parms):+ + n =: string parms[1] as integer else 3 + p =: permute iterative n diff --git a/Task/Pernicious-numbers/Agena/pernicious-numbers.agena b/Task/Pernicious-numbers/Agena/pernicious-numbers.agena new file mode 100644 index 0000000000..d85685a300 --- /dev/null +++ b/Task/Pernicious-numbers/Agena/pernicious-numbers.agena @@ -0,0 +1,32 @@ +scope # find some pernicious numbers - numbers with a prime population count + + local procedure populationCount( n :: number ) :: number + local v, count := abs n, 0; + while v > 0 do + if v && 1 = 1 then count +:= 1 fi; + v := v >>> 1 + od; + return count + end; + + local procedure isPernicious( p :: number ) :: boolean + return p > 0 and numtheory.isprime( populationCount( p ) ) + end + + scope # task + # show the first 25 pernicious numbers + local pCount := 0 + for p25 from 2 while pCount < 25 do # 0 and 1 aren't pernicious, so we start at 2 + if isPernicious( p25 ) then + pCount +:= 1; + printf( " %d", p25 ) + fi + od; + print(); + # find the pernicious numbers between 888 888 877 and 888 888 888 + for p from 888888877 to 888888888 do + if isPernicious( p ) then printf( " %d", p ) fi + od; + print() + end +end diff --git a/Task/Pernicious-numbers/Pluto/pernicious-numbers.pluto b/Task/Pernicious-numbers/Pluto/pernicious-numbers.pluto new file mode 100644 index 0000000000..b70010670b --- /dev/null +++ b/Task/Pernicious-numbers/Pluto/pernicious-numbers.pluto @@ -0,0 +1,38 @@ +do -- find some pernicious numbers - numbers with a prime population count + + local fmt = require( "fmt" ) -- RC Pluto formatting library + local int = require( "int" ) -- RC Pluto integer library, inc. prime utilities + + -- returns the population count (number of set bits) of n + local function populationCount( n : number ) : number + local v, count = math.abs( n ), 0 + while v > 0 do + if v & 1 == 1 then ++ count end + v >>= 1 + end + return count + end + + -- returns true if p is pernicious, false otherwise + local function isPernicious ( p : number ) : boolean + return p > 0 and int.isprime( populationCount( p ) ) + end + + do -- find the pernicious numbers + -- show the first 25 pernicious numbers + local p25, pCount = 2, 0 -- 0 and 1 aren't pernicious, so we start at 2 + while pCount < 25 do + if isPernicious( p25 ) then + ++ pCount + fmt.write( " %d", p25 ) + end + ++ p25 + end + print() + -- find the pernicious numbers between 888 888 877 and 888 888 888 + for p = 888888877, 888888888 do + if isPernicious( p ) then fmt.write( " %d", p ) end + end + print() + end +end diff --git a/Task/Pernicious-numbers/REXX/pernicious-numbers.rexx b/Task/Pernicious-numbers/REXX/pernicious-numbers.rexx index 878d9c865f..e8305e76f3 100644 --- a/Task/Pernicious-numbers/REXX/pernicious-numbers.rexx +++ b/Task/Pernicious-numbers/REXX/pernicious-numbers.rexx @@ -1,10 +1,10 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings +numeric digits 100 say 'PERNICIOUS NUMBERS' say version say -numeric digits 100 call Show 1,36 call Show 888888877,888888888 exit @@ -33,7 +33,4 @@ say Format(Time('e'),,3) 'seconds' say return -include Numbers -include Functions -include Special -include Abend +include Math diff --git a/Task/Phrase-reversals/Prolog/phrase-reversals.pro b/Task/Phrase-reversals/Prolog/phrase-reversals.pro new file mode 100644 index 0000000000..a47e262814 --- /dev/null +++ b/Task/Phrase-reversals/Prolog/phrase-reversals.pro @@ -0,0 +1,20 @@ +:- set_prolog_flag(double_quotes, chars). +:- use_module(library(dcg/basics)). +:- use_module(library(dcg/high_order)). + +%! string_words(+String, -Words) is det. +%! string_words(-String, +Words) is det. +% Relates a string to the list of space-separated words in that string. +string_words(String, Words) :- + once(phrase(sequence(nonblanks, " ", Words), String)). + +phrase_reversals(String) :- + reverse(String, Reversed), + string_words(String, Words), + maplist(reverse, Words, ReversedWords), + string_words(ReversedWordsString, ReversedWords), + reverse(Words, ReversedPhraseWords), + string_words(ReversedPhrase, ReversedPhraseWords), + format("~s~n~s~n~s~n~s~n", [String, Reversed, ReversedWordsString, ReversedPhrase]). + +?- phrase_reversals("rosetta code phrase reversal"). diff --git a/Task/Pick-random-element/DuckDB/pick-random-element.duckdb b/Task/Pick-random-element/DuckDB/pick-random-element.duckdb new file mode 100644 index 0000000000..b07f63cdcc --- /dev/null +++ b/Task/Pick-random-element/DuckDB/pick-random-element.duckdb @@ -0,0 +1,9 @@ +# PRN in range(0,n) +create or replace function prn(n) as trunc(random() * n)::BIGINT; + +create or replace function list_random(lst) as + lst[ 1 + prn(length(lst)) ] ; + +## Example: +select histogram( r ) + from (select list_random( [1,2,3] ) as r from range(0,1000) _(n)); diff --git a/Task/Pick-random-element/Pluto/pick-random-element.pluto b/Task/Pick-random-element/Pluto/pick-random-element.pluto new file mode 100644 index 0000000000..aa31eb925a --- /dev/null +++ b/Task/Pick-random-element/Pluto/pick-random-element.pluto @@ -0,0 +1,4 @@ +local ordinals = {"first", "second", "third", "fourth", "fifth", "sixth"} +for _ = 1, 6 do + print(ordinals[math.random(1, #ordinals)]) +end diff --git a/Task/Pick-random-element/Scheme/pick-random-element.scm b/Task/Pick-random-element/Scheme/pick-random-element.scm new file mode 100644 index 0000000000..bcfa5e7f93 --- /dev/null +++ b/Task/Pick-random-element/Scheme/pick-random-element.scm @@ -0,0 +1,6 @@ +; for Chicken Scheme +(import (chicken random)) + +(define (pick_random x) + (list-ref x (pseudo-random-integer (length x))) + ) diff --git a/Task/Pick-random-element/Tcl/pick-random-element.tcl b/Task/Pick-random-element/Tcl/pick-random-element-1.tcl similarity index 100% rename from Task/Pick-random-element/Tcl/pick-random-element.tcl rename to Task/Pick-random-element/Tcl/pick-random-element-1.tcl diff --git a/Task/Pick-random-element/Tcl/pick-random-element-2.tcl b/Task/Pick-random-element/Tcl/pick-random-element-2.tcl new file mode 100644 index 0000000000..7ebf4cd2c5 --- /dev/null +++ b/Task/Pick-random-element/Tcl/pick-random-element-2.tcl @@ -0,0 +1,79 @@ +# seed rng +set seed [expr { srand([clock clicks]) }] + +# return a list of random selections of items from a list +proc random_items { item_list {n 1} {dups no} } { + + # use item_list in place as items + upvar 1 $item_list items + + set result {} + set max [llength $items] + + if { $n > $max} {set n $max} + + set count 0 + + while { $count < $n } { + + # random integer index 0..len-1 + set idx [expr { int(rand() * $max)} ] + + # pick item + set item [lindex $items $idx] + + # check for dups + if {$dups eq no} { + set srch [lsearch $result $item] + if {$srch > -1} { continue } + } + + lappend result $item + incr count + } + return $result + } + +# randomize a list in place +proc randomize {item_list} { + upvar 1 $item_list items + set len [llength $items] + set items [random_items items $len] +} + +# return a new shuffled list +proc shuffle {items} { + set len [llength $items] + return [random_items items $len] +} + +# test cases + +set animals { + dog cat bird ant fish + horse pig cow snake mouse + whale worm bug spider deer + bee bear human gecko octopus +} + +# 1 item default +set guess [random_items animals] + +puts stdout "guess: $guess \n" + +# in place shuffle +randomize animals + +# list of 4 random items, no dups +set A [random_items animals 4] +set B [random_items animals 5] +set C [random_items animals 6] + +set dashline [string repeat "-" 30] + +foreach a {$A $B $C} { + puts stdout $dashline + puts stdout "${a}" +} + +puts stdout $dashline diff --git a/Task/Pierpont-primes/Python/pierpont-primes.py b/Task/Pierpont-primes/Python/pierpont-primes.py index 521b859a70..2357266bec 100644 --- a/Task/Pierpont-primes/Python/pierpont-primes.py +++ b/Task/Pierpont-primes/Python/pierpont-primes.py @@ -44,8 +44,8 @@ def pierpont(ulim, vlim, first): p2 = 1 p3 = 1 pp = [] - for v in xrange(vlim): - for u in xrange(ulim): + for v in range(vlim): + for u in range(ulim): p = p2 * p3 if first: p = p + 1 @@ -60,19 +60,19 @@ def pierpont(ulim, vlim, first): return pp def main(): - print "First 50 Pierpont primes of the first kind:" + print("First 50 Pierpont primes of the first kind:") pp = pierpont(120, 80, True) - for i in xrange(50): - print "%8d " % pp[i], + for i in range(50): + print("%8d " % pp[i], end="") if (i - 9) % 10 == 0: - print - print "First 50 Pierpont primes of the second kind:" + print("") + print("First 50 Pierpont primes of the second kind:") pp2 = pierpont(120, 80, False) - for i in xrange(50): - print "%8d " % pp2[i], + for i in range(50): + print ("%8d " % pp2[i], end="") if (i - 9) % 10 == 0: - print - print "250th Pierpont prime of the first kind:", pp[249] - print "250th Pierpont prime of the second kind:", pp2[249] + print("") + print("250th Pierpont prime of the first kind:", pp[249]) + print("250th Pierpont prime of the second kind:", pp2[249]) main() diff --git a/Task/Pierpont-primes/REXX/pierpont-primes-1.rexx b/Task/Pierpont-primes/REXX/pierpont-primes-1.rexx index 9893ca2589..7b53acb5f2 100644 --- a/Task/Pierpont-primes/REXX/pierpont-primes-1.rexx +++ b/Task/Pierpont-primes/REXX/pierpont-primes-1.rexx @@ -1,11 +1,11 @@ --- 11 Apr 2025 +-- 28 Jul 2025 include Settings +numeric digits 40 call Time('r') say 'PIERPOINT PRIMES (BRUTE FORCE)' say version say -numeric digits 40 call GetPierpont call Sort 'firs.' call Sort 'seco.' @@ -14,7 +14,7 @@ say Format(Time('e'),,3) 'seconds'; say exit GetPierpont: -procedure expose firs. glob. seco. +procedure expose firs. Memo. seco. say 'Get Pierpont primes...' n1 = 0; firs. = 0; n2 = 0; seco. = 0 p = 0; m = 1e40 @@ -70,7 +70,4 @@ say seco.250 say return -include Numbers -include Functions -include Helper -include Abend +include Math diff --git a/Task/Pierpont-primes/REXX/pierpont-primes-2.rexx b/Task/Pierpont-primes/REXX/pierpont-primes-2.rexx index c6f72e9921..fdebc4b1da 100644 --- a/Task/Pierpont-primes/REXX/pierpont-primes-2.rexx +++ b/Task/Pierpont-primes/REXX/pierpont-primes-2.rexx @@ -1,11 +1,11 @@ --- 11 Apr 2025 +-- 28 Jul 2025 include Settings +numeric digits 40 call Time('r') say 'PIERPOINT PRIMES (USING 3-SMOOTH NUMBERS)' say version say -numeric digits 40 call GetSmooth call GetPierpont call ShowPierpont @@ -21,7 +21,7 @@ say return GetPierpont: -procedure expose smoo. firs. seco. glob. +procedure expose smoo. firs. seco. Memo. say 'Get Pierpont primes...' n1 = 0; firs. = 0; n2 = 0; seco. = 0; p = 0 do i = 1 to smoo.0 @@ -65,8 +65,4 @@ say seco.250 say return -include Numbers -include Constants -include Sequences -include Functions -include Abend +include Math diff --git a/Task/Pisano-period/Agena/pisano-period.agena b/Task/Pisano-period/Agena/pisano-period.agena new file mode 100644 index 0000000000..f2c13d2239 --- /dev/null +++ b/Task/Pisano-period/Agena/pisano-period.agena @@ -0,0 +1,32 @@ +scope # find the Pisano period of some primes and composites + + local procedure pisano( m :: number ) :: number # returns the Pisano period of m + local p, c := 0, 1; + for i from 0 to ( m * m ) - 1 do + p, c := c, ( p + c ) mod m; + if p = 0 and c = 1 then return i + 1 fi + od; + return 1 + end; + + # returns the Pisano period of p^k or 0 if p is not prime or k < 1 + local procedure pisanoPrime( p :: number, k :: number ) :: number + return if not numtheory.isprime( p ) or k < 1 then 0 else entier ( p ^ ( k - 1 ) * pisano( p ) ) fi + end; + + print( "Pisano period of p^2 where p is a prime < 15:" ); + for p to 15 do + if numtheory.isprime( p ) then printf( " %d:%d", p, pisanoPrime( p, 2 ) ) fi + od; + printf( "\nPisano period of primes up to 180, non-primes shown as \"*\":\n" ); + for p to 180 do + if not numtheory.isprime( p ) then printf( " *" ) else printf( "%4d", pisanoPrime( p, 1 ) ) fi; + if p mod 10 = 0 then print() fi + od; + print( "\nPisano period of positive integers up to 180:" ); + for n to 180 do + printf( "%4d", pisano( n ) ); + if n mod 10 = 0 then print() fi + od + +end diff --git a/Task/Pisano-period/Pluto/pisano-period.pluto b/Task/Pisano-period/Pluto/pisano-period.pluto new file mode 100644 index 0000000000..5f5ec2931f --- /dev/null +++ b/Task/Pisano-period/Pluto/pisano-period.pluto @@ -0,0 +1,42 @@ +do -- find the Pisano period of some primes and composites + + local fmt = require( "fmt" ) -- RC Pluto formatting library + local int = require( "int" ) -- RC Pluto integer library - inc. some prime utilities + + local maxNumber = 180 + local isComposite = int.arecomps( maxNumber ) + + local function pisano( m ) -- returns the Pisano period of m + local p, c = 0, 1 + for i = 0, ( m * m ) - 1 do + p, c = c, ( p + c ) % m + if p == 0 and c == 1 then return i + 1 end + end + return 1 + end + + -- returns the Pisano period of p^k or 0 if p is not prime or k < 1 + local function pisanoPrime( p, k ) + return if isComposite[ p ] or k < 1 then 0 else math.floor( p ^ ( k - 1 ) * pisano( p ) ) end + end + + local function d4( n ) -- returns n formatted in 4 characcters + return string.format( "%4d", n ) + end + + io.write( "Pisano period of p^2 where p is a prime < 15:\n" ) + for p = 1, 15 do + if not isComposite[ p ] then fmt.write( " %d:%d", p, pisanoPrime( p, 2 ) ) end + end + io.write( "\nPisano period of primes up to 180, non-primes shown as \"*\":\n" ) + for p = 1, 180 do + io.write( if isComposite[ p ] then " *" else d4( pisanoPrime( p, 1 ) ) end ) + if p % 10 == 0 then io.write( "\n" ) end + end + io.write( "\nPisano period of positive integers up to 180:\n" ) + for n = 1, 180 do + io.write( d4( pisano( n ) ) ) + if n % 10 == 0 then io.write( "\n" ) end + end + +end diff --git a/Task/Plasma-effect/EasyLang/plasma-effect.easy b/Task/Plasma-effect/EasyLang/plasma-effect.easy index 6ced409589..889a7c06ed 100644 --- a/Task/Plasma-effect/EasyLang/plasma-effect.easy +++ b/Task/Plasma-effect/EasyLang/plasma-effect.easy @@ -11,8 +11,8 @@ on animate val += sin dist x y 25 25 val += sin (dist x (y + time / 7) 75 50 * 1.2) val += sin dist x y 75 40 - col = (val + 4) / 16 - gcolor3 col col * 2 1 - col + col = (val + 4) * 6 + gcolor3 col col * 2 100 - col grect x y 0.5 0.5 . . diff --git a/Task/Play-recorded-sounds/FuncSug/play-recorded-sounds.funcsug b/Task/Play-recorded-sounds/FuncSug/play-recorded-sounds.funcsug new file mode 100644 index 0000000000..228c48d0c0 --- /dev/null +++ b/Task/Play-recorded-sounds/FuncSug/play-recorded-sounds.funcsug @@ -0,0 +1,30 @@ +# play the sounds sequentially +playSoundFile('rattle.mp3') +playSoundFile('tactactac.mp3') +playSoundFile('dingding.mp3') + +# play the sounds simultaneously +parallel || + playSoundFile('rattle.mp3') +|| + playSoundFile('tactactac.mp3') +|| + playSoundFile('dingding.mp3') + +# loop a sound +while true: + playSoundFile('rattle.mp3') + +# stop before the end of the sound +parallel exitWith branch 1 || + waitSeconds(4) +|| + playSoundFile('dingding.mp3') + +# stop all the sounds when the shortest one is finished +parallel exitAfter 1 finished || + playSoundFile('rattle.mp3') +|| + playSoundFile('tactactac.mp3') +|| + playSoundFile('dingding.mp3') diff --git a/Task/Play-recorded-sounds/Raku/play-recorded-sounds.raku b/Task/Play-recorded-sounds/Raku/play-recorded-sounds.raku new file mode 100644 index 0000000000..73e8d5dc1f --- /dev/null +++ b/Task/Play-recorded-sounds/Raku/play-recorded-sounds.raku @@ -0,0 +1,31 @@ +# 20250723 Raku programming solution + +use Audio::Sndfile; +use Audio::PortAudio; + +sub play-wavs(Str $filename) { + my $sf = Audio::Sndfile.new(:filename($filename), :r); + die "Failed to open $filename" unless $sf; + my $sample-rate = $sf.samplerate; + my $channels = $sf.channels; + my $pa = Audio::PortAudio.new; + my $stream = $pa.open-default-stream( + 0, $channels, + Audio::PortAudio::StreamFormat::Float32, + $sample-rate, 512 + ); + $stream.start; + loop { + my ($buffer, $frames) = $sf.read-float(512, :raw); + $stream.write($buffer, $frames); + last if $frames < 512; + } + $stream.close; + $sf.close; +} + +sub MAIN(*@files) { + die "No files provided" unless @files; + + await Promise.allof( @files.map: { start { .&play-wavs } } ) +} diff --git a/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy b/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy index 2d3e711232..40ec7f9b33 100644 --- a/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy +++ b/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy @@ -1,15 +1,12 @@ x[] = [ 0 1 2 3 4 5 6 7 8 9 ] y[] = [ 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 ] # -gclear glinewidth 0.5 gline 10 5 10 97 gline 10 5 95 5 gtextsize 3 n = len x[] -for i = 1 to n - max = higher y[i] max -. +for i to n : max = higher y[i] max glinewidth 0.1 sty = max div 9 stx = x[n] div 9 @@ -21,10 +18,9 @@ for i range0 10 . color 900 linewidth 0.5 +gpenup for i = 1 to n - xp = x - yp = y x = x[i] * 9 / stx + 10 y = y[i] / sty * 10 + 5 - if i > 1 : gline xp yp x y + glineto x y . diff --git a/Task/Polymorphism/M2000-Interpreter/polymorphism-1.m2000 b/Task/Polymorphism/M2000-Interpreter/polymorphism-1.m2000 deleted file mode 100644 index ad240d902c..0000000000 --- a/Task/Polymorphism/M2000-Interpreter/polymorphism-1.m2000 +++ /dev/null @@ -1,6 +0,0 @@ -\\ block For This {}, or For object [, object2] { }, where object is a group, or a pointer to group, or an item from an array contains a group -\\ This is "this context". -For This { -\\ any new definition here has a temporary use -\\ can be nested, but if we use object then we can use dots to access members of it. If we use a second one then we have to use double dots (..x for second object, for access to x member) -} diff --git a/Task/Polymorphism/M2000-Interpreter/polymorphism-2.m2000 b/Task/Polymorphism/M2000-Interpreter/polymorphism-2.m2000 deleted file mode 100644 index 7f05b1ec8c..0000000000 --- a/Task/Polymorphism/M2000-Interpreter/polymorphism-2.m2000 +++ /dev/null @@ -1,76 +0,0 @@ -Class PointA { - Property x=0~ - Property Y=0~ - Operator "=" (n1) { - n=group(n1) - if n.x=.x Then if n.y=.y then push true : exit - push false - } - Module Print { - Print "Point" , .x, .y - } -Class: - Module PointA { - \\ ? means optionally - Read ? .[x], .[y] - } -} -Class Circle { - Property R=300~ ' type single - Operator "=" (n1) { - n=group(n1) - n2=This ' get a copy of this to check n against n2 - if valid(@n as n2) else push false :exit - if n.x=.x Then if n.y=.y then if n.r=.r then push true : exit - push false - } - Module Print { - Print "Circle", .x, .y, .r - } -Class: - Module Circle { - if match("nn") then { - M=PointA(Number, Number) - } Else.if match("G") then { - M=PointA() - Read M - } Else M=PointA() - M=This -\\ If match("N") then Read M.r \\ check if a number is in top of stack -\\ Read ? M.r \\ optionally - Read M.r \\ for this example, r has value, so this used if stack is empty. - This=M - } -} -A=PointA(10,3) -C=Circle(20,10,5) -D=Circle(A, 100) -B=A -K=PointA() -Z=Circle(A) -P=PointA(600,700) - -\\ N is a pointer to array -N=(A, B, C, D, K, P, Z) -M=each(N) -While M { - For This { - \\ a copy in MM - MM=Array(M) - MM.Print - Print A=MM, D=MM ' using MM=A interpreter use "=" from MM - } -} - -\\ pA is a pointer to D (a named group) -pA->D -Print pA=D, pA=Z -pA=>Print -\\ pA is a pointer to a copy of D (a float group) -pA->(D) -Print pA=D, pA=Z -pA=>Print - -\\ rA is a reference to D (& is optional in Link statement) -Link &D to &rA -rA.Print diff --git a/Task/Polymorphism/M2000-Interpreter/polymorphism-3.m2000 b/Task/Polymorphism/M2000-Interpreter/polymorphism-3.m2000 deleted file mode 100644 index fc2f0b2b45..0000000000 --- a/Task/Polymorphism/M2000-Interpreter/polymorphism-3.m2000 +++ /dev/null @@ -1,67 +0,0 @@ -Class PointA { - X=0~, Y=0~ - Module Print { - Print "Point" , .x, .y - } -Class: - Module PointA { - Read ? .x, .y - } -} -Class Circle { - Property R { - Value, - Set { - If Value>1000 then Value=1000 - } - }=300~ - Module Print { - Print "Circle", .x, .y, .r - } -Class: - Module Circle { - if match("nn") then { - M=PointA(Number, Number) - } Else.if match("G") then { - M=PointA() - Read M - } Else M=PointA() - M=This - This=M - Read ? .r - } -} -A=PointA(10,3) -C=Circle(20,10,5) -D=Circle(A, 100) -B=A -K=PointA() -Z=Circle(A) -P=PointA(600,700) - - \\ N is a pointer to stack -N=Stack:=A, B, C, D, K, P, Z -\\ M is a pointer to an iterator -M=each(N) -While M { - For This { - \\ a copy in MM - MM=StackItem(M) - MM.Print - } -} -\\ NN is a pointer to Inventory -Inventory NN= 1:=A, 2:=B, 3:=C, 4:=D, 5:=K, 6:=P,7:= Z -M=each(NN) -While M { - For This { - \\ a copy in MM - MM=Eval(M) - MM.Print - } -} -\\ we can call NN(3).print -Print "NN(3).Print" -NN(3).Print -NN(3).R=5000 -NN(3).Print diff --git a/Task/Polymorphism/M2000-Interpreter/polymorphism.m2000 b/Task/Polymorphism/M2000-Interpreter/polymorphism.m2000 new file mode 100644 index 0000000000..39d1adf57e --- /dev/null +++ b/Task/Polymorphism/M2000-Interpreter/polymorphism.m2000 @@ -0,0 +1,108 @@ +Module Polymorphism { + Class Point { + private: + double x, y + public: + module print { + Print "x="+.x, "y="+.y + } + class: + module Point (.x, .y) { + } + } + + Class Circle as Point { + private: + double r + public: + group radius { + value { + link parent r to r + =r + } + Set { + Error "No Set for radius" + } + } + module print { + Print "x="+.x, "y="+.y, "r="+.r + } + class: + module Circle (.x, .y, .r) { + } + } + + Class Circle2{ + { ' a different constructor - Version 14 + read xa=0, ya=0, ra=0 + if ra=0 then ra=1 + } + public: + Property r { + value, ' we can read it + set { ' we can change if is >0 + if value<=0 then exit ' skip + } + }=ra + Point Inner(xa, ya) + // add a function to Inner to read private X and Y + Group Inner { + function readXY { + =.x, .y + } + } + Group CircleType { ' an inner object which return a value of type circle + Value { ' return a Circle type + link parent Inner to that + link parent r to ra + =Circle(!that.readXY(), ra) + } + } + module print { + (x,y)=.inner.readXY() + Print "x="+x, "y="+y, "r="+.r + } + } + + A=Point(10, 20) + B=Circle(2,3,5) + doit(A) + doit(B) + print B is type Point = true + print B is type Circle = true + C=Circle2(12,13,15) + C.r=0 + Print "C radius = ";C.r + print C is type Circle2 = true + doit(C.CircleType) + // Circle2 has a Point object + doit(C.Inner) + D=C.CircleType + print "D radious = ";d.radius + try { + d.radius=100 + } + print error$ + print D is type Point = true + print D is type Circle = true + print D is type Circle2 = false + doit(D) + doit2(&D) + doit3(pointer(D)) ' we pass a weak reference - pointer((D)) is a real pointer of a copy of D + Z->Point(10, 20) ' same as Z=Pointer(Point(10,20)), it is a real pointer + doit4(&Z) + End + sub doit(a as Point) ' pass by value + a.print + end sub + sub doit2(&a as Point) ' pass by reference + a.print + end sub + sub doit3(a as *Point) ' pass by value a pointer (weak reference or real pointer) + a=>print + end sub + sub doit4(&a as *Point) ' pass by reference a pointer (weak reference or real pointer) + a=>print + end sub +} +Polymorphism diff --git a/Task/Polymorphism/Rhombus/polymorphism-1.rhombus b/Task/Polymorphism/Rhombus/polymorphism-1.rhombus new file mode 100644 index 0000000000..cbaa7b99a0 --- /dev/null +++ b/Task/Polymorphism/Rhombus/polymorphism-1.rhombus @@ -0,0 +1,11 @@ +#lang rhombus/static + +class Point(~x = 0, ~y = 0): + nonfinal + method print(): + println(@str{Point at @(x),@(y)}) + +class Circle(~r = 1): + extends Point + override method print(): + println(@str{Circle at @(x),@(y) with radius @(r)}) diff --git a/Task/Polymorphism/Rhombus/polymorphism-2.rhombus b/Task/Polymorphism/Rhombus/polymorphism-2.rhombus new file mode 100644 index 0000000000..5808495570 --- /dev/null +++ b/Task/Polymorphism/Rhombus/polymorphism-2.rhombus @@ -0,0 +1,13 @@ +def p = Point() +p.print() // Point at 0,0 +println(p.x) // 0 + +def p2 = Point(~y: 1) +p2.print() // Point at 0,1 + +def c = Circle(~y: 3, ~r: 2) +c.print() // Circle at 0,3 with radius 2 +println(c.r) // 2 + +def c2 = Circle(~y: 5) +c2.print() // Circle at 0,5 with radius 5 diff --git a/Task/Polynomial-long-division/REXX/polynomial-long-division-2.rexx b/Task/Polynomial-long-division/REXX/polynomial-long-division-2.rexx index 5846bb92c0..eb933688ab 100644 --- a/Task/Polynomial-long-division/REXX/polynomial-long-division-2.rexx +++ b/Task/Polynomial-long-division/REXX/polynomial-long-division-2.rexx @@ -1,6 +1,7 @@ +-- 30 Jul 2025 include Settings -say 'POLYNOMIAL LONG DIVISION - 2 Mar 2025' +say 'POLYNOMIAL LONG DIVISION' say version say call Divide '1 -12 0 -42','1 -3' @@ -15,12 +16,9 @@ exit Divide: arg x,y -z = Pdiv(x,y); parse var z q','r -say 'Formula:' Plst2form(x) '/' Plst2form(y) '=' Plst2form(q) 'Rem' Plst2form(r) -say 'Check :' Plst2form(q) '*' Plst2form(y) '+' Plst2form(r) '=' Plst2form(Padd(Pmul(q,y),r)) -say +z = DivP(x,y); parse var z q','r +say 'Formula:' Lst2FormP(x) '/' Lst2FormP(y) '=' Lst2FormP(q) 'Rem' Lst2FormP(r) +say 'Check :' Lst2FormP(q) '*' Lst2FormP(y) '+' Lst2FormP(r) '=' Lst2FormP(AddP(MulP(q,y),r)) return -include Polynomial -include Functions -include Abend +include Math diff --git a/Task/Polyspiral/EasyLang/polyspiral.easy b/Task/Polyspiral/EasyLang/polyspiral.easy index 0a2d0116c7..d7558c66a5 100644 --- a/Task/Polyspiral/EasyLang/polyspiral.easy +++ b/Task/Polyspiral/EasyLang/polyspiral.easy @@ -5,14 +5,13 @@ on animate incr = (incr + 0.05) mod 360 x = 50 y = 50 + glineto x y length = 1 angle = incr for i = 1 to 150 - xp = x - yp = y x += cos angle * length y += sin angle * length - gline xp yp x y + glineto x y length += 1 angle += incr . diff --git a/Task/Polyspiral/REBOL/polyspiral.rebol b/Task/Polyspiral/REBOL/polyspiral.rebol new file mode 100644 index 0000000000..7997e03fe3 --- /dev/null +++ b/Task/Polyspiral/REBOL/polyspiral.rebol @@ -0,0 +1,42 @@ +Rebol [ + title: "Rosetta code: Polyspiral" + file: %Polyspiral.r3 + url: https://rosettacode.org/wiki/Polyspiral + needs: 3.10.2 + note: [ + https://github.com/Oldes/Rebol3/releases + https://github.com/Siskin-framework/Rebol-Blend2D + ] +] +import blend2d ;; Import Blend2D extension used to draw + +incr: 0.0 ;; Initialize increment variable to 0.0 +image: make image! 800x800 ;; Create an 800x800 pixel image canvas +pi2: 2 * PI ;; Calculate 2π (full circle in radians), for angle calculations +random/seed 4 + +;; animation loop (repeats 4 times to create progressive spiral states) +loop 4 [ + x: image/size/x / 2 ;; Set x to center of image (horizontal) + y: image/size/y / 2 ;; Set y to center of image (vertical) + length: 5 ;; Starting length/step for spiral arms + incr: (incr + 5) % pi2 ;; Increment the angle step (modulo 2π to ensure it wraps correctly) + angle: incr + commands: clear [] ;; Clear previous drawing commands + color: 100.100.100 + random 155.155.155 + append commands [line-width 1 pen :color line] ;; Start a new line with width 1 and random pen color + + ;; spiral loop (generates points for the spiral) + loop 150 [ + x: x + (length * (cos angle)) ;; Move x along the current angle by current length + y: y + (length * (sin angle)) ;; Move y along the current angle by current length + append commands as-pair x y ;; Add the new (x, y) point to the command list + length: length + 5 ;; Increase the step size for spiral effect + angle: (angle + incr) % pi2 ;; Progress the angle for the spiral's curvature (modulo 2π) + ] + + draw image commands ;; Render the spiral on the image with the accumulated commands +] + +try [save %polyspiral.png image] ;; Save the image as PNG +try [view image] ;; Display the final image window with drawn spirals diff --git a/Task/Population-count/Prolog/population-count.pro b/Task/Population-count/Prolog/population-count.pro new file mode 100644 index 0000000000..3ed3711a67 --- /dev/null +++ b/Task/Population-count/Prolog/population-count.pro @@ -0,0 +1,12 @@ +is_evil(Number) :- popcount(Number) mod 2 =:= 0. + +:- numlist(0, 29, Powers), + maplist([P0, P] >> (P is popcount(3 ^ P0)), Powers, PowerPopcounts), + numlist(0, 59, Numbers), + partition(is_evil, Numbers, EvilNumbers, OdiousNumbers), + writeln('The pop counts of the first 30 powers of 3 are:'), + writeln(PowerPopcounts), + writeln('The first 30 evil numbers are:'), + writeln(EvilNumbers), + writeln('The first 30 odious numbers are:'), + writeln(OdiousNumbers). diff --git a/Task/Power-set/Pluto/power-set.pluto b/Task/Power-set/Pluto/power-set.pluto new file mode 100644 index 0000000000..dd495babab --- /dev/null +++ b/Task/Power-set/Pluto/power-set.pluto @@ -0,0 +1,9 @@ +require "perm" +local fmt = require "fmt" + +local sets = { {1, 2, 3, 4}, {}, {{}} } +for sets as set do + print($"The power set of {fmt.swrite(set)} is:") + fmt.lprint(powerset.list(set)) + print() +end diff --git a/Task/Primality-by-Wilsons-theorem/REXX/primality-by-wilsons-theorem.rexx b/Task/Primality-by-Wilsons-theorem/REXX/primality-by-wilsons-theorem.rexx index 7e3c3bfd7e..c59b8abf9c 100644 --- a/Task/Primality-by-Wilsons-theorem/REXX/primality-by-wilsons-theorem.rexx +++ b/Task/Primality-by-Wilsons-theorem/REXX/primality-by-wilsons-theorem.rexx @@ -1,4 +1,4 @@ --- 26 Mar 2025 +-- 28 Jul 2025 include Settings numeric digits 10 @@ -14,7 +14,7 @@ end exit ShowWilson: -procedure expose glob. +procedure expose Memo. arg xx,yy call Time('r') say 'Primes between' Std(xx) 'and' Std(yy) @@ -50,7 +50,7 @@ say 'For n between' Right(Std(xx),7) 'and' Right(Std(yy),7), return Isprime: -procedure expose glob. +procedure expose Memo. arg xx if xx < 2 then return 0 @@ -67,8 +67,4 @@ if f = x1 then else return 0 -include Sequences -include Numbers -include Functions -include Constants -include Abend +include Math diff --git a/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg b/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg index c1d43c9374..4ec46c729d 100644 --- a/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg +++ b/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg @@ -1,10 +1,20 @@ -main:( +BEGIN + PROC is prime = ( INT p )BOOL: + IF p <= 1 OR ( NOT ODD p AND p/= 2) THEN + FALSE + ELSE + BOOL prime := TRUE; + FOR i FROM 3 BY 2 TO ENTIER sqrt(p) + WHILE prime := p MOD i /= 0 DO SKIP OD; + prime + FI; + INT upb=100; - printf(($" The primes up to "g(-3)" are:"l$,upb)); + print((" The primes up to ", whole(upb,-3) ," are:")); FOR i TO upb DO IF is prime(i) THEN - printf(($g(-4)$,i)) + print((" ",whole(i,0))) FI OD; - printf($l$) -) + print((newline)) +END diff --git a/Task/Primality-by-trial-division/Agena/primality-by-trial-division.agena b/Task/Primality-by-trial-division/Agena/primality-by-trial-division.agena new file mode 100644 index 0000000000..7c01119817 --- /dev/null +++ b/Task/Primality-by-trial-division/Agena/primality-by-trial-division.agena @@ -0,0 +1,13 @@ +scope # find some primes by trial division + + local constant is_prime := proc( n :: number ) :: boolean + local result := n = 2 or ( odd n and n > 1 ); + for k from 3 to entier sqrt( n ) by 2 while result do + result := n mod k <> 0 + od; + return result + end; + + for p from 0 to 100 do if is_prime( p ) then printf( " %d", p ) fi od + +end diff --git a/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-1.duckdb b/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-1.duckdb new file mode 100644 index 0000000000..6f8023e2e4 --- /dev/null +++ b/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-1.duckdb @@ -0,0 +1,29 @@ +create or replace function n() as 514229; + +create or replace function primep(nnumber) as ( +with recursive cte(number) as +( + select 2 + union all + select number+1 + from cte + where number+1 < nnumber +) +select + case + when nnumber < 2 then false + when nnumber = 2 then true + when exists + ( select * + from + ( select number, nnumber % number modNumber + from cte + ) tmp + where tmp.modNumber = 0 + ) + then false + else true + end primalityTest +); + +select n, primep(n) from (select n() as n); diff --git a/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-2.duckdb b/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-2.duckdb new file mode 100644 index 0000000000..558678d804 --- /dev/null +++ b/Task/Primality-by-trial-division/DuckDB/primality-by-trial-division-2.duckdb @@ -0,0 +1,18 @@ +create or replace function n() as 514229; + +create or replace function primep(nnumber) as ( + select + case + when nnumber < 2 then false + when nnumber = 2 then true + else NOT exists + ( select * from + ( select (nnumber % anumber) as modNumber + from (select unnest(range(2, 1 + sqrt(nnumber)::BIGINT)) as anumber) + ) + where modNumber = 0 + ) + end +); + +select n, primep(n) from (select n() as n); diff --git a/Task/Primality-by-trial-division/Pluto/primality-by-trial-division.pluto b/Task/Primality-by-trial-division/Pluto/primality-by-trial-division.pluto new file mode 100644 index 0000000000..45cf5165e7 --- /dev/null +++ b/Task/Primality-by-trial-division/Pluto/primality-by-trial-division.pluto @@ -0,0 +1,13 @@ +function isprime(n) + if n<2 then return false end + for i=2,math.sqrt(n) do + if n%i==0 do return false end + end + return true +end + +for i = 1,20 do + if isprime(i) then + io.write(i,'\t') + end +end diff --git a/Task/Primality-by-trial-division/REXX/primality-by-trial-division.rexx b/Task/Primality-by-trial-division/REXX/primality-by-trial-division.rexx index f823f29a39..43b4557b7d 100644 --- a/Task/Primality-by-trial-division/REXX/primality-by-trial-division.rexx +++ b/Task/Primality-by-trial-division/REXX/primality-by-trial-division.rexx @@ -1,4 +1,4 @@ --- 26 Mar 2025 +-- 28 Jul 2025 include Settings numeric digits 15 @@ -15,7 +15,7 @@ exit ShowTrial: procedure -arg xx,yy +arg xx,yy,zz call Time('r') say 'Primes between' std(xx) 'and' std(yy) 'by trial division' n = 0; w = Xpon(yy)+2 @@ -34,7 +34,7 @@ return ShowMR: procedure -arg xx,yy +arg xx,yy,zz call Time('r') say 'Primes between' std(xx) 'and' std(yy) 'by Miller-Rabin' n = 0; w = Xpon(yy)+2 @@ -83,8 +83,4 @@ do i = 3 by 2 to Isqrt(xx) end return 1 -include Sequences -include Numbers -include Functions -include Constants -include Abend +include Math diff --git a/Task/Prime-decomposition/DuckDB/prime-decomposition.duckdb b/Task/Prime-decomposition/DuckDB/prime-decomposition.duckdb new file mode 100644 index 0000000000..e95b2fd280 --- /dev/null +++ b/Task/Prime-decomposition/DuckDB/prime-decomposition.duckdb @@ -0,0 +1,29 @@ +create or replace function prime_factors(nn) as table ( + with recursive cte(p, q, valid, s) as ( + select 2::UHUGEINT as p, nn::UHUGEINT as q, false as valid, null::DOUBLE as s + union all + select unnest( + if (q = 1, (0, 0, false, null), + if (q % p = 0, (p, q // p, true, null), + if (p = 2, (3, q, false, s), + if (p + 2 <= coalesce(s, sqrt(q)), + (p + 2, q, false, coalesce(s, sqrt(q))), + (q, 1, true, null) )))) ) + from cte + where p != 0 + ) + select p + from cte + where valid +); + +## Examples + +.print The prime factors of 24: +from prime_factors(24); + +.print The prime factors of 2**29-1 = 536870911 +from prime_factors(536870911); + +.print Counting the prime factors of 9007199254740992: +select count(*) from prime_factors(9007199254740992); diff --git a/Task/Prime-decomposition/OoRexx/prime-decomposition.rexx b/Task/Prime-decomposition/OoRexx/prime-decomposition.rexx new file mode 100644 index 0000000000..6a12d13754 --- /dev/null +++ b/Task/Prime-decomposition/OoRexx/prime-decomposition.rexx @@ -0,0 +1,36 @@ +.local~digits=50 +numeric digits .local~digits +say 'PRIME DECOMPOSITION' +parse version version +say version +call ShowFactors 100,120 +call ShowFactors 720720 +call ShowFactors 9007199254740991 +call ShowFactors 2543821448263974486045199 +call ShowFactors 340282366920938463463374607431768211455 +exit + +ShowFactors: +Call time 'R' +arg xx,yy +if yy = '' then + yy = xx +do i = xx to yy + call Charout ,i '= ' + f = factors(i) + if f = 1 then + call Charout ,'Prime' + else do + do j = 1 to f + call Charout ,GetFact(,j) + if j < f then + call Charout ,' x ' + end + end + say +end +say Format(Time('e'),,3) 'seconds' +say +return + +::REQUIRES math.cls diff --git a/Task/Priority-queue/Pluto/priority-queue.pluto b/Task/Priority-queue/Pluto/priority-queue.pluto new file mode 100644 index 0000000000..30771d4b63 --- /dev/null +++ b/Task/Priority-queue/Pluto/priority-queue.pluto @@ -0,0 +1,12 @@ +require "queue" + +local tasks = new pqueue() +tasks:push(3, "Clear drains") +tasks:push(4, "Feed cat") +tasks:push(5, "Make tea") +tasks:push(1, "Solve RC tasks") +tasks:push(2, "Tax return") +while !tasks:empty() do + local [p, v] = tasks:pop() + print($"{p} {v}") +end diff --git a/Task/Probabilistic-choice/DuckDB/probabilistic-choice.duckdb b/Task/Probabilistic-choice/DuckDB/probabilistic-choice.duckdb new file mode 100644 index 0000000000..dfd02ca56b --- /dev/null +++ b/Task/Probabilistic-choice/DuckDB/probabilistic-choice.duckdb @@ -0,0 +1,65 @@ +set variable letters = ['aleph', 'beth', 'gimel', 'daleth', 'he', 'waw', 'zayin', 'heth']; + +# The list of probabilities - last value must be given but will be ignored: +set variable probs = [1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 0]; + +create or replace function cumulative_probabilities(probs) as ( + with recursive cte0 as + (select 1 as ix, probs[1]::double as cum + union all + select ix+1 as ix, + cum + probs[ix + 1] as cum + from cte0 + where ix < length(probs)) + select array_agg(cum order by ix) + from cte0 +); + +# It is imperative to materialize rand because of DuckDB's "inlining" +create or replace function choice(rand, cumProbs) as ( + with r as materialized(select rand as r) + select + if (r <= cumProbs[1], 1, + if (r <= cumProbs[2], 2, + if (r <= cumProbs[3], 3, + if (r <= cumProbs[4], 4, + if (r <= cumProbs[5], 5, + if (r <= cumProbs[6], 6, + if (r <= cumProbs[7], 7, 8) )))))) + from r +); + +# Infer the expected value for the last category +create or replace function expectations(probs, n) as ( + with ns as (select list_transform(probs[0:-2], x -> x*n) as ns), + subtotal as (select list_sum(ns) as subtotal from ns) + select ns || [ n - subtotal ] + from ns, subtotal +); + +# Generate the histogram of observed letters +create or replace function play(mx) as table ( + with recursive cumProbs as (select cumulative_probabilities(getvariable('probs')) as cumProbs), + cte as ( + select 1 as n, choice(random(), cumProbs) as cat + from cumProbs + union all + select n+1 as n, choice(random(), cumProbs) as cat + from cte, cumProbs + where n < mx) + select histogram(cat) as histogram + from cte +); + +create or replace function synopsis(n) as table ( + e as (select expectations(getvariable('probs'),n) as e) + + select i as n, + getvariable('letters')[i] as letter, + e[i]::DECIMAL(10,2) as expected, + coalesce(histogram[i],0) as observed, + ((observed - expected)^2/expected)::DECIMAL(10,2) as "(o-e)^2/e" + from e, play(n), range(1, 1 + length(getvariable('probs'))) _(i) ) +); + +from synopsis(1000000); diff --git a/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy b/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy index de27f6f500..445a258d63 100644 --- a/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy +++ b/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy @@ -41,12 +41,11 @@ solve c1[] c2[] c3[] -1 -1 -1 r2[] print r2[] # proc circ x0 y0 r . + gpenup for a = 0 to 360 - xp = x - yp = y x = x0 + sin a * r y = y0 + cos a * r - if a > 0 : gline xp yp x y + glineto x y . . proc draw col c[] . diff --git a/Task/Program-termination/ArkScript/program-termination.ark b/Task/Program-termination/ArkScript/program-termination.ark new file mode 100644 index 0000000000..1d50c12ef3 --- /dev/null +++ b/Task/Program-termination/ArkScript/program-termination.ark @@ -0,0 +1,3 @@ +(sys:exit 0) # exit code 0 + +# any code after won't be executed diff --git a/Task/Proper-divisors/DuckDB/proper-divisors.duckdb b/Task/Proper-divisors/DuckDB/proper-divisors.duckdb new file mode 100644 index 0000000000..ec6feab5ae --- /dev/null +++ b/Task/Proper-divisors/DuckDB/proper-divisors.duckdb @@ -0,0 +1,33 @@ +# A table (i) of distinct BIGINT proper divisors, not necessarily sorted +create or replace function proper_divisors(n) as table ( + select 1 where n > 1 + union all + select distinct i + from (select unnest( [ j, n // j]) as i + from range(2, 1 + sqrt(n).floor()::BIGINT) as t(j) + where (n % j) == 0) +); + +# Still not necessarily sorted +create or replace function list_of_proper_divisors(n) as ( + select coalesce(array_agg(i), []) + from proper_divisors(n) _(i) +); + +create or replace function maximally_many_proper_divisors(mx) as table ( + with cte as ( + select n, length(list_of_proper_divisors(n)) as length + from range(1,mx+1) _(n)), + maxlength as (select max(length) as maxlength from cte) + select n, length + from cte, maxlength + where length = maxlength.maxlength + order by n +); + +.print A sampling of proper divisors: +from range(1,11) _(n) +select n, list_of_proper_divisors(n); + +.print The positive integers less than or equal to 20,000 with the most distinct proper divisors: +from maximally_many_proper_divisors(20000); diff --git a/Task/Pseudo-random-numbers-Middle-square-method/DuckDB/pseudo-random-numbers-middle-square-method.duckdb b/Task/Pseudo-random-numbers-Middle-square-method/DuckDB/pseudo-random-numbers-middle-square-method.duckdb new file mode 100644 index 0000000000..5f9e588792 --- /dev/null +++ b/Task/Pseudo-random-numbers-Middle-square-method/DuckDB/pseudo-random-numbers-middle-square-method.duckdb @@ -0,0 +1,20 @@ +# `seed` should be a positive integer or numeric string representing a positive integer; +# `mx` is the maximum number of rows +# Output: a table of the "middle-squares" as HUGEINT values +create or replace function middle_square(seed, mx) as table ( + with recursive n as (select length(seed::VARCHAR) as n, (n // 2) as n2), + cte as ( + select 0 as ix, + seed::VARCHAR as ms + from n + union all + select ix+1 as ix, + format('{:0>{}}', (ms::HUGEINT * ms::HUGEINT)::VARCHAR, 2*n)[ n2 + 1 : n2 + n ] as ms + from cte, n + where ix < mx and NOT ms ~ '0*' + ) + select ms::HUGEINT + from cte offset 1 +); + +from middle_square(675248, 10) _(ms); diff --git a/Task/Pythagoras-tree/EasyLang/pythagoras-tree.easy b/Task/Pythagoras-tree/EasyLang/pythagoras-tree.easy index 17eec9353f..b018db9c7c 100644 --- a/Task/Pythagoras-tree/EasyLang/pythagoras-tree.easy +++ b/Task/Pythagoras-tree/EasyLang/pythagoras-tree.easy @@ -8,7 +8,7 @@ proc tree x1 y1 x2 y2 depth . y4 = y1 + dx x5 = x4 + 0.5 * (dx + dy) y5 = y4 + 0.5 * (dx - dy) - gcolor3 0.3 0.2 + depth / 18 0.1 + gcolor3 30 20 + depth * 6 10 gpolygon [ x1 y1 x2 y2 x3 y3 x4 y4 ] gpolygon [ x3 y3 x4 y4 x5 y5 ] tree x4 y4 x5 y5 depth + 1 diff --git a/Task/Pythagoras-tree/JavaScript/pythagoras-tree-2.js b/Task/Pythagoras-tree/JavaScript/pythagoras-tree-2.js index 8e9c4abb97..c8a4836a30 100644 --- a/Task/Pythagoras-tree/JavaScript/pythagoras-tree-2.js +++ b/Task/Pythagoras-tree/JavaScript/pythagoras-tree-2.js @@ -1,4 +1,4 @@ -const base = [[[-200, 0], [200, 0]],]; +var base = [[[-200, 0], [200, 0]],]; document.documentElement.innerHTML = [...Array(12)].reduce((svg_a, _, lvl) => { const rg = step => (80 + (lvl - 2) * step) & 255; return svg_a + base.splice(0).reduce((g_a, [a, b]) => { diff --git a/Task/Quaternion-type/REXX/quaternion-type.rexx b/Task/Quaternion-type/REXX/quaternion-type.rexx index 6d6eb480da..e472ad5072 100644 --- a/Task/Quaternion-type/REXX/quaternion-type.rexx +++ b/Task/Quaternion-type/REXX/quaternion-type.rexx @@ -1,4 +1,4 @@ --- 19 May 2025 +-- 28 Jul 2025 include Settings say 'QUATERNION TYPE' @@ -7,36 +7,35 @@ say i = '0 1'; j = '0 0 1'; k = '0 0 0 1' q = '1 2 3 4'; q1 = '2 3 4 5'; q2 = '3 4 5 6'; r = 7 say 'VALUES' -say 'i =' Hlst2Form(i) -say 'j =' Hlst2Form(j) -say 'k =' Hlst2Form(k) -say 'q =' Hlst2Form(q) -say 'q1 =' Hlst2Form(q1) -say 'q2 =' Hlst2Form(q2) -say 'r =' Hlst2Form(r) +say 'i =' Lst2FormH(i) +say 'j =' Lst2FormH(j) +say 'k =' Lst2FormH(k) +say 'q =' Lst2FormH(q) +say 'q1 =' Lst2FormH(q1) +say 'q2 =' Lst2FormH(q2) +say 'r =' Lst2FormH(r) say say 'BASICS' -say 'i*i =' Hlst2Form(Hsquare(i)) -say 'j*j =' Hlst2Form(Hsquare(j)) -say 'k*k =' Hlst2Form(Hsquare(k)) -say 'i*j*k =' Hlst2Form(Hmul(i,j,k)) -say '||q|| =' Std(Hnorm(q)) -say '-q =' Hlst2Form(Hneg(q)) -say 'q* =' Hlst2Form(Hconj(q)) -say 'q+r =' Hlst2Form(Hadd(q,r)) -say 'r+q =' Hlst2Form(Hadd(r,q)) -say 'q1+q2 =' Hlst2Form(Hadd(q1,q2)) -say 'q2+q1 =' Hlst2Form(Hadd(q2,q1)) -say 'q*r =' Hlst2Form(Hmul(q,r)) -say 'r*q =' Hlst2Form(Hmul(r,q)) -say 'q1*q2 =' Hlst2Form(Hmul(q1,q2)) -say 'q2*q1 =' Hlst2Form(Hmul(q2,q1)) +say 'i*i =' Lst2FormH(SquareH(i)) +say 'j*j =' Lst2FormH(SquareH(j)) +say 'k*k =' Lst2FormH(SquareH(k)) +say 'i*j*k =' Lst2FormH(MulH(i,j,k)) +say '||q|| =' Std(NormH(q)) +say '-q =' Lst2FormH(NegH(q)) +say 'q* =' Lst2FormH(ConjH(q)) +say 'q+r =' Lst2FormH(AddH(q,r)) +say 'r+q =' Lst2FormH(AddH(r,q)) +say 'q1+q2 =' Lst2FormH(AddH(q1,q2)) +say 'q2+q1 =' Lst2FormH(AddH(q2,q1)) +say 'q*r =' Lst2FormH(MulH(q,r)) +say 'r*q =' Lst2FormH(MulH(r,q)) +say 'q1*q2 =' Lst2FormH(MulH(q1,q2)) 'does not' +say 'q2*q1 =' Lst2FormH(MulH(q2,q1)) 'commute!' say say 'BONUS' -say 'q/r =' Hlst2Form(Hdiv(q,r)) -say '1/q =' Hlst2Form(Hinv(q)) +say '1/q =' Lst2FormH(InvH(q)) +say 'q1/q2 =' Lst2FormH(DivLeftH(q1,q2)) 'left division' +say 'q1/q2 =' Lst2FormH(DivRightH(q1,q2)) 'right division' exit -include Quaternion -include Functions -include Abend +include Math diff --git a/Task/Queue-Definition/ALGOL-68/queue-definition.alg b/Task/Queue-Definition/ALGOL-68/queue-definition-1.alg similarity index 100% rename from Task/Queue-Definition/ALGOL-68/queue-definition.alg rename to Task/Queue-Definition/ALGOL-68/queue-definition-1.alg diff --git a/Task/Queue-Definition/ALGOL-68/queue-definition-2.alg b/Task/Queue-Definition/ALGOL-68/queue-definition-2.alg new file mode 100644 index 0000000000..343dc52a8e --- /dev/null +++ b/Task/Queue-Definition/ALGOL-68/queue-definition-2.alg @@ -0,0 +1,7 @@ + MODE OBJLINK = STRUCT( + REF OBJLINK next, + REF OBJLINK prev, + OBJVALUE value # ... etc. required # + ); + PROC obj link new = REF OBJLINK: HEAP OBJLINK; + PROC obj link free = (REF OBJLINK free)VOID: SKIP diff --git a/Task/Quickselect-algorithm/YAMLScript/quickselect-algorithm.ys b/Task/Quickselect-algorithm/YAMLScript/quickselect-algorithm.ys new file mode 100644 index 0000000000..b2d6c26b17 --- /dev/null +++ b/Task/Quickselect-algorithm/YAMLScript/quickselect-algorithm.ys @@ -0,0 +1,25 @@ +!YS-v0 + +v =: +[9 8 7 6 5 0 1 2 3 4] + +defn main(): + say: + map \(quickselect v _): + v.#:range + +defn quickselect(a k): + loop arr a:V, current-k k: + pivot-idx =: arr.#:rand-int + pivot =: arr.$pivot-idx + remaining =: + concat subvec(arr 0 pivot-idx): + subvec(arr pivot-idx.++) + left =: remaining.filter(\(_ < pivot)) + right =: remaining.filter(\(_ >= pivot)) + left-count =: left.# + cond: + current-k == left-count: pivot + current-k < left-count: + recur: left:V current-k + else: + recur right:V: (current-k - left-count).-- diff --git a/Task/Quine/Extended-Color-BASIC/quine.basic b/Task/Quine/Extended-Color-BASIC/quine.basic new file mode 100644 index 0000000000..1b05437302 --- /dev/null +++ b/Task/Quine/Extended-Color-BASIC/quine.basic @@ -0,0 +1 @@ +10 LIST diff --git a/Task/Quine/REBOL/quine-1.rebol b/Task/Quine/REBOL/quine-1.rebol new file mode 100644 index 0000000000..29ab92349a --- /dev/null +++ b/Task/Quine/REBOL/quine-1.rebol @@ -0,0 +1 @@ +Rebol [] q: [print ["Rebol [] q:" mold q "do q"]] do q diff --git a/Task/Quine/REBOL/quine-2.rebol b/Task/Quine/REBOL/quine-2.rebol new file mode 100644 index 0000000000..53e06495b6 --- /dev/null +++ b/Task/Quine/REBOL/quine-2.rebol @@ -0,0 +1,14 @@ +;; A Rebol quine - a program that outputs its own source code +;; This demonstrates self-referential code and metaprogramming concepts + +Rebol [] ;; Standard Rebol header (minimal version) + +q: [ ;; Define q as a block containing the program logic + print [ ;; Print function to output the result + "Rebol [] q:" ;; First part: literal string for the header and variable declaration + mold q ;; Second part: convert the block q back to its source representation + "do q" ;; Third part: literal string for the execution command + ] +] + +do q ;; Execute the block q, which prints the entire program diff --git a/Task/Quine/REBOL/quine.rebol b/Task/Quine/REBOL/quine.rebol deleted file mode 100644 index 8bb89956fa..0000000000 --- a/Task/Quine/REBOL/quine.rebol +++ /dev/null @@ -1 +0,0 @@ -rebol [] q: [print ["rebol [] q:" mold q "do q"]] do q diff --git a/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-1.pro b/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-1.pro new file mode 100644 index 0000000000..9a273f4501 --- /dev/null +++ b/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-1.pro @@ -0,0 +1,16 @@ +generate_stat(Stat) :- + length(DiceRolls, 4), + maplist(random_between(1, 6), DiceRolls), + sum_list(DiceRolls, Sum), + min_list(DiceRolls, Min), + Stat is Sum - Min. + +generate_stats(Stats) :- + once((repeat, + length(Stats, 6), + maplist(generate_stat, Stats), + sum_list(Stats, Total), + Total >= 75, + aggregate_all(count, ( member(Stat, Stats), Stat > 15 ), Count), + Count >= 2 + )). diff --git a/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-2.pro b/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-2.pro new file mode 100644 index 0000000000..7444b41352 --- /dev/null +++ b/Task/RPG-attributes-generator/Prolog/rpg-attributes-generator-2.pro @@ -0,0 +1,8 @@ +?- generate_stats(Stats). +Stats = [15, 13, 12, 16, 17, 15]. + +?- generate_stats(Stats). +Stats = [16, 9, 15, 16, 10, 10]. + +?- generate_stats(Stats). +Stats = [14, 15, 16, 16, 6, 11]. diff --git a/Task/Ramanujan-primes-twins/Rust/ramanujan-primes-twins.rs b/Task/Ramanujan-primes-twins/Rust/ramanujan-primes-twins.rs new file mode 100644 index 0000000000..00716f7937 --- /dev/null +++ b/Task/Ramanujan-primes-twins/Rust/ramanujan-primes-twins.rs @@ -0,0 +1,121 @@ +fn ramanujan_maximum(number: i32) -> i32 { + (4.0 * number as f64 * (4.0 * number as f64).ln()).ceil() as i32 +} + +fn initialise_prime_pi(limit: i32) -> Vec { + let mut result = vec![1; limit as usize]; + result[0] = 0; + result[1] = 0; + + // Mark even numbers as composite + for i in (4..limit).step_by(2) { + result[i as usize] = 0; + } + + // Sieve of Eratosthenes for odd numbers + let mut p = 3; + let mut square = 9; + while square < limit { + if result[p as usize] != 0 { + let mut q = square; + while q < limit { + result[q as usize] = 0; + q += p << 1; + } + } + square += (p + 1) << 2; + p += 2; + } + + // Convert to cumulative sum (prime counting function) + for i in 1..result.len() { + result[i] += result[i - 1]; + } + + result +} + +fn ramanujan_prime(prime_pi: &[i32], number: i32) -> i32 { + let mut maximum = ramanujan_maximum(number); + if (maximum & 1) == 1 { + maximum -= 1; + } + + let mut index = maximum; + while prime_pi[index as usize] - prime_pi[(index / 2) as usize] >= number { + index -= 1; + } + index + 1 +} + +fn list_primes_less_than(limit: i32) -> Vec { + let mut composite = vec![false; limit as usize]; + let mut n = 3; + let mut n_squared = 9; + + while n_squared <= limit { + if !composite[n as usize] { + let mut k = n_squared; + while k < limit { + composite[k as usize] = true; + k += 2 * n; + } + } + n_squared += (n + 1) << 2; + n += 2; + } + + let mut result = Vec::new(); + result.push(2); + for i in (3..limit).step_by(2) { + if !composite[i as usize] { + result.push(i); + } + } + + result +} + +fn main() { + const LIMIT: i32 = 1_000_000; + let prime_pi = initialise_prime_pi(ramanujan_maximum(LIMIT) + 1); + let millionth_ramanujan_prime = ramanujan_prime(&prime_pi, LIMIT); + println!("The 1,000,000th Ramanujan prime is {}", millionth_ramanujan_prime); + + let primes = list_primes_less_than(millionth_ramanujan_prime); + let mut ramanujan_prime_indexes: Vec = primes + .iter() + .map(|&p| prime_pi[p as usize] - prime_pi[(p / 2) as usize]) + .collect(); + + // Filter ramanujan prime indexes to keep only strictly decreasing values + let mut lower_limit = ramanujan_prime_indexes[ramanujan_prime_indexes.len() - 1]; + for i in (0..ramanujan_prime_indexes.len() - 1).rev() { + if ramanujan_prime_indexes[i] < lower_limit { + lower_limit = ramanujan_prime_indexes[i]; + } else { + ramanujan_prime_indexes[i] = 0; + } + } + + // Collect the actual Ramanujan primes + let ramanujan_primes: Vec = primes + .iter() + .enumerate() + .filter_map(|(i, &prime)| { + if ramanujan_prime_indexes[i] != 0 { + Some(prime) + } else { + None + } + }) + .collect(); + + // Count twin primes + let twins_count = ramanujan_primes + .windows(2) + .filter(|pair| pair[0] + 2 == pair[1]) + .count(); + + println!("There are {} twins in the first {} Ramanujan primes.", twins_count, LIMIT); +} diff --git a/Task/Ramanujans-constant/REXX/ramanujans-constant.rexx b/Task/Ramanujans-constant/REXX/ramanujans-constant.rexx index 7639f2025b..7bd38feb44 100644 --- a/Task/Ramanujans-constant/REXX/ramanujans-constant.rexx +++ b/Task/Ramanujans-constant/REXX/ramanujans-constant.rexx @@ -1,6 +1,7 @@ +-- 28 Jul 2025 include Settings -say 'RAMANUJAN''S CONSTANT - 6 Mar 2025' +say 'RAMANUJAN''S CONSTANT' say version say call Formula @@ -28,6 +29,4 @@ end say Format(Time('e'),,3) 'seconds' return -include Constants -include Functions -include Abend +include Math diff --git a/Task/Ramer-Douglas-Peucker-line-simplification/Pascal-P/ramer-douglas-peucker-line-simplification.pas b/Task/Ramer-Douglas-Peucker-line-simplification/Pascal-P/ramer-douglas-peucker-line-simplification.pas new file mode 100644 index 0000000000..b481aeeb56 --- /dev/null +++ b/Task/Ramer-Douglas-Peucker-line-simplification/Pascal-P/ramer-douglas-peucker-line-simplification.pas @@ -0,0 +1,94 @@ +program rdpalgor (output); +(* Ramer-Douglas-Peucker line simplification *) +const + len = 10; + +type + tpnt = record + x, y: real; + end; + tpnts = array [0 .. len] of tpnt; + +var + pntsin, pntsout: tpnts; + n: integer; + + procedure writepnts(pnts: tpnts; n: integer); + var + i: integer; + begin + write('(', pnts[0].x: 8, ', ', pnts[0].y: 8, ')'); + for i := 1 to n - 1 do + write(' (', pnts[i].x: 8, ', ', pnts[i].y: 8, ')'); + writeln; + end; + + (* Returns the distance from point P to the line between P1 and P2 *) + function perpdist(p, p1, p2: tpnt): real; + var + dx, dy, d: real; + begin + dx := p2.x - p1.x; + dy := p2.y - p1.y; + d := sqrt(dx * dx + dy * dy); + perpdist := abs(p.x * dy - p.y * dx + p2.x * p1.y - p2.y * p1.x) / d; + end; + + (* Simplify an array of points using the Ramer-Douglas-Peucker algorithm. *) + (* Returns the number of output points. *) + function rdp(src: tpnts; srcfrom, srclen: integer; eps: real; + var dest: tpnts; destfrom, destlen: integer): integer; + var + dist, maxdist : real; + n1, n2, i, maxdisti, srcto: integer; + src1len, src2len, src2from: integer; + begin + maxdist := 0.0; + maxdisti := srcfrom; + srcto := srcfrom + srclen - 1; + for i := srcfrom + 1 to srcto - 1 do + begin + dist := perpdist(src[i], src[srcfrom], src[srcto]); + if dist > maxdist then + begin + maxdist := dist; + maxdisti := i + end; + end; + src2from := maxdisti; + src1len := maxdisti - srcfrom + 1; + src2len := srclen - src1len + 1; + if maxdist > eps then + begin + n1 := rdp(src, srcfrom, src1len, eps, dest, destfrom, destlen); + if destlen >= n1 - 1 then + n2 := rdp(src, src2from, src2len, eps, dest, destfrom + n1 - 1, destlen - n1 + 1) + else + n2 := rdp(src, src2from, src2len, eps, dest, destfrom, 0); + rdp := n1 + n2 - 1; + end + else + begin + if destlen > 1 then + begin + dest[destfrom] := src[srcfrom]; + dest[destfrom + 1] := src[srcto]; + end; + rdp := 2; + end; + end; + +begin + pntsin[0].x := 0.0; pntsin[0].y := 0.0; + pntsin[1].x := 1.0; pntsin[1].y := 0.1; + pntsin[2].x := 2.0; pntsin[2].y := -0.1; + pntsin[3].x := 3.0; pntsin[3].y := 5.0; + pntsin[4].x := 4.0; pntsin[4].y := 6.0; + pntsin[5].x := 5.0; pntsin[5].y := 7.0; + pntsin[6].x := 6.0; pntsin[6].y := 8.1; + pntsin[7].x := 7.0; pntsin[7].y := 9.0; + pntsin[8].x := 8.0; pntsin[8].y := 9.0; + pntsin[9].x := 9.0; pntsin[9].y := 9.0; + n := rdp(pntsin, 0, len, 1.0, pntsout, 0, len); + writepnts(pntsout, n); +end. diff --git a/Task/Random-number-generator-device-/REXX/random-number-generator-device-.rexx b/Task/Random-number-generator-device-/REXX/random-number-generator-device-.rexx index b0e65ac572..f913b8880b 100644 --- a/Task/Random-number-generator-device-/REXX/random-number-generator-device-.rexx +++ b/Task/Random-number-generator-device-/REXX/random-number-generator-device-.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings numeric digits 12 @@ -24,7 +24,7 @@ say return Examples: -procedure expose glob. +procedure expose Memo. say 'Randu() = ' Right(Randu(),14) 'Real, uniform distributed over (0,1)' say 'Randu(100) = ' Right(Randu(100),14) 'Integer, between 0 and 100' say 'Randu(-10,10) = ' Right(Randu(-10,10),14) 'Integer, between -10 and 10' @@ -32,7 +32,4 @@ say 'Randn() = ' Right(Randn(),14) 'Real, normal distributed, average 0 a say return -include Functions -include Constants -include Helper -include Abend +include Math diff --git a/Task/Random-numbers/DuckDB/random-numbers.duckdb b/Task/Random-numbers/DuckDB/random-numbers.duckdb new file mode 100644 index 0000000000..d26ebde75c --- /dev/null +++ b/Task/Random-numbers/DuckDB/random-numbers.duckdb @@ -0,0 +1,14 @@ +# The Box-Muller method +create or replace function rnv(mean, sd, u, v) as + (select ( sqrt(-2 * ln(u)) * cos(2 * pi() * v) * sd) + mean); + +create or replace table t as + (with rows as (select random() as u, random() as v from unnest(range(0,1000))) + select rnv(0, 0.5, u, v) as rnv from rows); + +from t limit 5; + +select avg(rnv) as average, + stddev_samp(rnv) as 'sample stddev', + stddev_pop(rnv) as 'population stddev' +from t; diff --git a/Task/Random-numbers/REXX/random-numbers.rexx b/Task/Random-numbers/REXX/random-numbers.rexx index cfd8734f63..08f943d031 100644 --- a/Task/Random-numbers/REXX/random-numbers.rexx +++ b/Task/Random-numbers/REXX/random-numbers.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings say 'RANDOM NUMBERS' @@ -19,53 +19,53 @@ call Timer exit GetUniform: -procedure expose glob. work. +procedure expose Memo. Work. arg xx say 'Get' xx 'uniform distributed Random numbers...' -work. = 0 +Work. = 0 do n = 1 to xx - work.n = Randu() + Work.n = Randu() end -work.0 = xx +Work.0 = xx say 'Done' say return GetNormal: -procedure expose glob. work. +procedure expose Memo. Work. arg xx say 'Get' xx 'normal(1,1/2) distributed Random numbers...' -work. = 0 +Work. = 0 do n = 1 to xx - work.n = Randn(1,0.5) + Work.n = Randn(1,0.5) end -work.0 = xx +Work.0 = xx say 'Done' say return ShowFirst: -procedure expose work. +procedure expose Work. say 'First 5 items...' do i = 1 to 5 - call CharOut ,work.i/1' ' + call CharOut ,Work.i/1' ' end say; say return ShowStats: -procedure expose work. -say 'Statistics for' work.0 'items...' +procedure expose Memo. Work. +say 'Statistics for' Work.0 'items...' sum = 0 -do n = 1 to work.0 - sum = sum+work.n +do n = 1 to Work.0 + sum = sum+Work.n end -avg = sum/work.0 +avg = sum/Work.0 sum = 0 -do n = 1 to work.0 - sum = sum+(work.n-avg)**2 +do n = 1 to Work.0 + sum = sum+(Work.n-avg)**2 end -varia = sum/work.0; stdev = SqRt(varia)/1 +varia = sum/Work.0; stdev = SqRt(varia)/1 say 'Average ' Std(avg) say 'Deviation' Std(stdev) say 'Variance ' Std(varia) @@ -73,7 +73,7 @@ say return ShowExact: -procedure expose work. +procedure expose Memo. say 'Exact statistics for infinite items...' say 'Average ' 1/2 '(1/2)' say 'Deviation' Std(SqRt(1/12)) '(SqRt(1/12))' @@ -81,7 +81,4 @@ say 'Variance ' 1/12 '(1/12)' say return -include Functions -include Constants -include Helper -include Abend +include Math diff --git a/Task/Range-expansion/DuckDB/range-expansion.duckdb b/Task/Range-expansion/DuckDB/range-expansion.duckdb new file mode 100644 index 0000000000..e769dc33f7 --- /dev/null +++ b/Task/Range-expansion/DuckDB/range-expansion.duckdb @@ -0,0 +1,10 @@ +create or replace function range_expansion(s) as ( + regexp_extract_all(s, '[^,]+') + .list_transform( x -> + regexp_extract(x, '(-?[0-9]+)-(-?[0-9]+)|(.*)', ['a', 'b', 'c']) ) + .list_transform( x -> if (x.a = '', [x.c::BIGINT], + range( x.a::INT, x.b::INT + 1) ) ) + .flatten() +); + +select range_expansion( '-6,-3--1,3-5,7-11,14,15,17-20') as range; diff --git a/Task/Range-extraction/DuckDB/range-extraction.duckdb b/Task/Range-extraction/DuckDB/range-extraction.duckdb new file mode 100644 index 0000000000..ce820ccfce --- /dev/null +++ b/Task/Range-extraction/DuckDB/range-extraction.duckdb @@ -0,0 +1,43 @@ +# pretty-print the list returned by list_extract_range() +# being mindful of the 'at least two' rule: +create or replace function list_range_pp(state) as ( + list_transform(state, + x -> if( length(x)=2, + if (x[1] = x[2]::HUGEINT - 1, + format('{},{}', x[1], x[2]), + format('{}-{}', x[1], x[2])), + format('{}', x[1]) ) ) + .array_to_string(',') +); + +create or replace function list_extract_range(lst) as table ( + with recursive cte as ( + -- `state` is a list of lists in which [n] represents an integer and [start, end] a range + select 1 as ix, + [lst[0:0][0:0]][0:0] as state -- i.e. [] of the appropriate type + union all + select ix+1 as ix, + if (length(state) = 0, + [[ lst[ix] ]], + if (length(state[-1]) = 2, + if (state[-1][2] + 1 = lst[ix], + state[0:-2] || [[ state[-1][1], lst[ix]]], + state || [[ lst[ix]] ]), + if ( state[-1][1] + 1 = lst[ix], + state[0:-2] || [[ state[-1][1], lst[ix]]], + state || [[ lst[ix] ]] ) ) ) as state + from cte + where ix <= length(lst)) + select last(state order by ix).list_range_pp() as range + from cte +); + +### Examples +from list_extract_range( [ + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 + ]); + +from list_extract_range( [1.0, 2.0, 3.0, 10.0, 11.0] ); diff --git a/Task/Read-a-file-character-by-character-UTF8/Ada/read-a-file-character-by-character-utf8.ada b/Task/Read-a-file-character-by-character-UTF8/Ada/read-a-file-character-by-character-utf8.ada new file mode 100644 index 0000000000..b517e1000c --- /dev/null +++ b/Task/Read-a-file-character-by-character-UTF8/Ada/read-a-file-character-by-character-utf8.ada @@ -0,0 +1,21 @@ +with Ada.Wide_Wide_Text_IO; + +use Ada.Wide_Wide_Text_IO; + +procedure Read_UTF8 is + procedure Read (Filename : String) is + File : File_Type; + C : Wide_Wide_Character; + begin + Open (File, In_File, Filename); + Set_Input (File); + while not End_Of_File loop + Get (C); + Put (C); + end loop; + Close (File); + end Read; + +begin + Read ("input.txt"); +end Read_UTF8; diff --git a/Task/Read-a-file-line-by-line/DuckDB/read-a-file-line-by-line.duckdb b/Task/Read-a-file-line-by-line/DuckDB/read-a-file-line-by-line.duckdb new file mode 100644 index 0000000000..fca28f6ec3 --- /dev/null +++ b/Task/Read-a-file-line-by-line/DuckDB/read-a-file-line-by-line.duckdb @@ -0,0 +1,3 @@ +select count(*) from read_csv('unixdict.txt', + header=false, sep='', columns={'line': VARCHAR}, escape='', + null_padding=true); diff --git a/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-1.pluto b/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-1.pluto new file mode 100644 index 0000000000..4798163d1f --- /dev/null +++ b/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-1.pluto @@ -0,0 +1,8 @@ +filename = "input.txt" +fp = io.open( filename, "r" ) + +for line in fp:lines() do + print( line ) +end + +fp:close() diff --git a/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-2.pluto b/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-2.pluto new file mode 100644 index 0000000000..68dc9a3888 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Pluto/read-a-file-line-by-line-2.pluto @@ -0,0 +1,3 @@ +for line in io.lines("input.txt") do + print(line) +end diff --git a/Task/Read-a-specific-line-from-a-file/REBOL/read-a-specific-line-from-a-file.rebol b/Task/Read-a-specific-line-from-a-file/REBOL/read-a-specific-line-from-a-file.rebol index 22915a7820..28ab83f6fb 100644 --- a/Task/Read-a-specific-line-from-a-file/REBOL/read-a-specific-line-from-a-file.rebol +++ b/Task/Read-a-specific-line-from-a-file/REBOL/read-a-specific-line-from-a-file.rebol @@ -1,2 +1,2 @@ -x: pick read/lines request-file/only 7 -either x [print x] [print "No seventh line"] +line: pick read/lines %file.txt 7 +print any [line "No seventh line"] diff --git a/Task/Read-entire-file/ArkScript/read-entire-file.ark b/Task/Read-entire-file/ArkScript/read-entire-file.ark new file mode 100644 index 0000000000..e06189aaab --- /dev/null +++ b/Task/Read-entire-file/ArkScript/read-entire-file.ark @@ -0,0 +1 @@ +(let content (io:readFile "input.txt")) diff --git a/Task/Real-constants-and-functions/Maxima/real-constants-and-functions.maxima b/Task/Real-constants-and-functions/Maxima/real-constants-and-functions.maxima new file mode 100644 index 0000000000..68fb0bba48 --- /dev/null +++ b/Task/Real-constants-and-functions/Maxima/real-constants-and-functions.maxima @@ -0,0 +1,10 @@ +%e$ /* e */ +%pi$ /* pi */ +sqrt(x)$ /* square root */ +log(x)$ /* natural logarithm */ +/* logarithms for all other bases are not built-in and have to be defined in terms of log(x) */ +exp(x)$ /* exponential */ +abs(x)$ /* magnitude */ +floor(x)$ /* floor */ +ceiling(x)$ /* ceiling */ +x^y$ /* power */ diff --git a/Task/Real-constants-and-functions/TAV/real-constants-and-functions.tav b/Task/Real-constants-and-functions/TAV/real-constants-and-functions.tav new file mode 100644 index 0000000000..db0c7d7810 --- /dev/null +++ b/Task/Real-constants-and-functions/TAV/real-constants-and-functions.tav @@ -0,0 +1,13 @@ + print 'pi =', #Pi + print 'e =', #E + x =: 12.3456 + y =: 1.11 + print 'x =', x, 'y =', y + print 'sqrt(x) =', math sqrt x + print 'log(x) =', math log x \ base e + print 'log10(x) =', math lg x \ base 10 + print 'exp(x) =', math exp x + print 'abs(x) =', x.abs + print 'floor(x) =', x.floor + print 'ceil(x) =', x.ceil + print 'x ^ y =', x ^ y diff --git a/Task/Reflection-List-methods/DuckDB/reflection-list-methods.duckdb b/Task/Reflection-List-methods/DuckDB/reflection-list-methods.duckdb new file mode 100644 index 0000000000..f97160413c --- /dev/null +++ b/Task/Reflection-List-methods/DuckDB/reflection-list-methods.duckdb @@ -0,0 +1,14 @@ +create or replace function methods( type ) as table ( + select function_name, parameter_types + from duckdb_functions() + where upper(parameter_types[1]) = upper(type) + order by function_name +); + +create or replace function functions_with_signature( ds ) as table ( + with uc as (select list_transform(ds, x->upper(x)) as uc) + select function_name + from duckdb_functions(), uc + where list_transform(parameter_types, x->upper(x)) = uc + order by function_name +); diff --git a/Task/Reflection-List-properties/DuckDB/reflection-list-properties.duckdb b/Task/Reflection-List-properties/DuckDB/reflection-list-properties.duckdb new file mode 100644 index 0000000000..729b194281 --- /dev/null +++ b/Task/Reflection-List-properties/DuckDB/reflection-list-properties.duckdb @@ -0,0 +1 @@ +select column_name from (describe TABLE); diff --git a/Task/Regular-expressions/Maxima/regular-expressions.maxima b/Task/Regular-expressions/Maxima/regular-expressions.maxima new file mode 100644 index 0000000000..2c980b591c --- /dev/null +++ b/Task/Regular-expressions/Maxima/regular-expressions.maxima @@ -0,0 +1,5 @@ +load("sregex")$ +regex_match("\\W[A-Z]", "Hello World!"); /* returns matched substring */ +regex_match("\\W[A-Z]", "Hello world!"); /* returns false if no match */ +regex_subst_first("4", "[Aa]", "Abracadabra!"); /* replaces first match */ +regex_subst("4", "[Aa]", "Abracadabra!"); /* replaces all matches */ diff --git a/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-1.duckdb b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-1.duckdb new file mode 100644 index 0000000000..7ca77f8f20 --- /dev/null +++ b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-1.duckdb @@ -0,0 +1 @@ +select distinct(*) from unnest( [3,9,1,10,3,7,6,5,2,7,4,7,4,2,2,2,2,8,2,10,4,9,2,4,9,3,4,3,4,7] ); diff --git a/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-2.duckdb b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-2.duckdb new file mode 100644 index 0000000000..6d0ef3ff67 --- /dev/null +++ b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-2.duckdb @@ -0,0 +1 @@ +select array_agg(unnest) as distinct from (select distinct(*) from unnest( [3,9,1,10,3,7,6,5,2,7,4,7,4,2,2,2,2,8,2,10,4,9,2,4,9,3,4,3,4,7] )); diff --git a/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-3.duckdb b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-3.duckdb new file mode 100644 index 0000000000..2e6213bb6d --- /dev/null +++ b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-3.duckdb @@ -0,0 +1,6 @@ +CREATE OR REPLACE MACRO firsts(l) as ( + WITH + t as (SELECT unnest(l) as x, generate_subscripts(l, 1) as index), + s as (SELECT x, min(index) as index FROM t GROUP BY x) + SELECT list(x ORDER BY index) + FROM s ) ; diff --git a/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-4.duckdb b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-4.duckdb new file mode 100644 index 0000000000..100d913138 --- /dev/null +++ b/Task/Remove-duplicate-elements/DuckDB/remove-duplicate-elements-4.duckdb @@ -0,0 +1 @@ +select firsts( [3,9,1,10,3,7,6,5,2,7,4,7,4,2,2,2,2,8,2,10,4,9,2,4,9,3,4,3,4,7]) as firsts; diff --git a/Task/Rename-a-file/Maxima/rename-a-file.maxima b/Task/Rename-a-file/Maxima/rename-a-file.maxima new file mode 100644 index 0000000000..001ce224f8 --- /dev/null +++ b/Task/Rename-a-file/Maxima/rename-a-file.maxima @@ -0,0 +1,5 @@ +load("operatingsystem")$ +rename_file("input.txt", "output.txt")$ +rename_file("/input.txt", "/output.txt")$ +rename_file("docs", "mydocs")$ +rename_file("/docs", "/mydocs")$ diff --git a/Task/Rename-a-file/Pluto/rename-a-file.pluto b/Task/Rename-a-file/Pluto/rename-a-file.pluto new file mode 100644 index 0000000000..dfc95df6ba --- /dev/null +++ b/Task/Rename-a-file/Pluto/rename-a-file.pluto @@ -0,0 +1,5 @@ +os.rename("input.txt", "output.txt") +os.rename("/input.txt", "/output.txt") + +os.rename("docs", "mydocs") +os.rename("/docs", "/mydocs") diff --git a/Task/Rename-a-file/R/rename-a-file.r b/Task/Rename-a-file/R/rename-a-file.r new file mode 100644 index 0000000000..077c4db78e --- /dev/null +++ b/Task/Rename-a-file/R/rename-a-file.r @@ -0,0 +1,4 @@ +file.rename("input.txt","output.txt") +file.rename("~/input.txt","~/output.txt") +file.rename("docs","mydocs") +file.rename("~/docs","~/mydocs") diff --git a/Task/Rep-string/DuckDB/rep-string.duckdb b/Task/Rep-string/DuckDB/rep-string.duckdb new file mode 100644 index 0000000000..fde7e300cf --- /dev/null +++ b/Task/Rep-string/DuckDB/rep-string.duckdb @@ -0,0 +1,36 @@ +create or replace function repString(s) as ( + if (length(s) < 2, null, + (with recursive size_t as (select length(s) as size), + cte as + (select ((size % 2) + (size // 2)) as len, '' as t, false as found + from size_t + union all + select len-1 as len, + s[1:len] as t, + s == (repeat(s[1:len], (size // len)) + || coalesce(t[1:(size % len)], '')) + as found + from cte, size_t + where len > 0 and found = false + ) + select first(t) + from cte + where found + )) +); + +select s, repString(s) +from unnest( + [ + '1001110011', + '1110111011', + '0010010010', + '1010101010', + '1111111111', + '0100101101', + '0100100', + '101', + '11', + '00', + '1' + ]) _(s); diff --git a/Task/Repeat-a-string/DuckDB/repeat-a-string-1.duckdb b/Task/Repeat-a-string/DuckDB/repeat-a-string-1.duckdb new file mode 100644 index 0000000000..86a8b536e6 --- /dev/null +++ b/Task/Repeat-a-string/DuckDB/repeat-a-string-1.duckdb @@ -0,0 +1,2 @@ +select repeat('abc', 5) as five, + (repeat('abc', 0) = '') as zero; diff --git a/Task/Repeat-a-string/DuckDB/repeat-a-string-2.duckdb b/Task/Repeat-a-string/DuckDB/repeat-a-string-2.duckdb new file mode 100644 index 0000000000..5691e3508b --- /dev/null +++ b/Task/Repeat-a-string/DuckDB/repeat-a-string-2.duckdb @@ -0,0 +1 @@ +select string_agg('a',' ') as a from range(0,5); diff --git a/Task/Repeat-a-string/Pluto/repeat-a-string.pluto b/Task/Repeat-a-string/Pluto/repeat-a-string.pluto new file mode 100644 index 0000000000..66a4abe738 --- /dev/null +++ b/Task/Repeat-a-string/Pluto/repeat-a-string.pluto @@ -0,0 +1 @@ +print('ha':rep(5)) diff --git a/Task/Repunit-primes/R/repunit-primes.r b/Task/Repunit-primes/R/repunit-primes.r new file mode 100644 index 0000000000..89ba6164db --- /dev/null +++ b/Task/Repunit-primes/R/repunit-primes.r @@ -0,0 +1,8 @@ +library(gmp) + +nth_repunit <- function(n, base) (as.bigz(base)^n-1)/(base-1) +repunit_primes <- function(base) which(isprime(nth_repunit(1:1000, base))!=0) +primes_list <- lapply(2:16, repunit_primes) +names(primes_list) <- sapply(2:16, function(k) paste("Base", k)) +for(i in 1:15) if(length(primes_list[[i]])==0) primes_list[[i]] <- "None" +print(primes_list, quote=FALSE) diff --git a/Task/Retrieve-and-search-chat-history/R/retrieve-and-search-chat-history.r b/Task/Retrieve-and-search-chat-history/R/retrieve-and-search-chat-history.r new file mode 100644 index 0000000000..2485cd0915 --- /dev/null +++ b/Task/Retrieve-and-search-chat-history/R/retrieve-and-search-chat-history.r @@ -0,0 +1,19 @@ +#Retrieving +url_day <- function(n) sprintf("http://tclers.tk/conferences/tcl/%s.tcl", Sys.Date()-n) +retrieve <- function(n) readLines(con=url(url_day(n))) +#Adding an extra day to deal with time zone issue +logs <- lapply(-1:9, retrieve) +names(logs) <- sapply(-1:9, url_day) +if("URL Not Found" %in% logs[[1]]) logs[[1]] <- NULL + +#Searching +results <- lapply(seq_along(logs), function(n) grep(s, logs[[n]], fixed=TRUE, value=TRUE)) +names(results) <- names(logs) + +for(i in seq_along(results)){ + if(length(results[[i]])==0){ + results[[i]] <- "No results found" + } +} + +print(results, quote=FALSE) diff --git a/Task/Return-multiple-values/DuckDB/return-multiple-values-1.duckdb b/Task/Return-multiple-values/DuckDB/return-multiple-values-1.duckdb new file mode 100644 index 0000000000..9a82b8ae27 --- /dev/null +++ b/Task/Return-multiple-values/DuckDB/return-multiple-values-1.duckdb @@ -0,0 +1,4 @@ +# If i is a non-zero number, the first item of the returned tuple will be of type HUGEINT. +create or replace function divmod(n, i) as ( + (((n - mod(n, i)) / i)::HUGEINT, mod(n,i) ) +); diff --git a/Task/Return-multiple-values/DuckDB/return-multiple-values-2.duckdb b/Task/Return-multiple-values/DuckDB/return-multiple-values-2.duckdb new file mode 100644 index 0000000000..907f254fd6 --- /dev/null +++ b/Task/Return-multiple-values/DuckDB/return-multiple-values-2.duckdb @@ -0,0 +1,9 @@ +create or replace table test(n HUGEINT, i INTEGER); + +insert into test values + (7,3), + (1,0), + (123456789123456789, 23); + +select n, i, divmod(n, i) as divmod, (divmod[1] * i + divmod[2]) = n +from test; diff --git a/Task/Reverse-a-string/ArkScript/reverse-a-string.ark b/Task/Reverse-a-string/ArkScript/reverse-a-string.ark new file mode 100644 index 0000000000..606f4a9101 --- /dev/null +++ b/Task/Reverse-a-string/ArkScript/reverse-a-string.ark @@ -0,0 +1,3 @@ +(import std.String :reverse) + +(print (reverse "asdf")) diff --git a/Task/Reverse-a-string/DuckDB/reverse-a-string.duckdb b/Task/Reverse-a-string/DuckDB/reverse-a-string.duckdb new file mode 100644 index 0000000000..7b3a2c6280 --- /dev/null +++ b/Task/Reverse-a-string/DuckDB/reverse-a-string.duckdb @@ -0,0 +1,7 @@ +create or replace table t (s varchar, expected varchar); +insert into t values + ('asdf', 'fdsa'), + ('as⃝df̅', 'f̅ds⃝a'); + +select s, expected, reverse(s) as reversed, (expected=reversed) as equal + from t; diff --git a/Task/Reverse-a-string/Nom/reverse-a-string.num b/Task/Reverse-a-string/Nom/reverse-a-string.num new file mode 100644 index 0000000000..06830b5d71 --- /dev/null +++ b/Task/Reverse-a-string/Nom/reverse-a-string.num @@ -0,0 +1 @@ +read; get; put; clear; (eof) { get; print; } diff --git a/Task/Reverse-a-string/Pluto/reverse-a-string.pluto b/Task/Reverse-a-string/Pluto/reverse-a-string.pluto new file mode 100644 index 0000000000..1c3732a91f --- /dev/null +++ b/Task/Reverse-a-string/Pluto/reverse-a-string.pluto @@ -0,0 +1,10 @@ +require "uchar" +require "gchar" + +for {"asdf", "josé", "møøse", "was it a car or a cat I saw", "😀🚂🦊"} as word do + print(uchar.of(word):reverse()) +end + +for {"as⃝df̅", "ℵΑΩ 駱駝道 🤔 🇸🇧 🇺🇸 🇬🇧‍ 👨‍👩‍👧‍👦🆗🗺"} as word do + print(gchar.of(word):reverse()) +end diff --git a/Task/Reverse-a-string/TAV/reverse-a-string.tav b/Task/Reverse-a-string/TAV/reverse-a-string.tav new file mode 100644 index 0000000000..57f02fec68 --- /dev/null +++ b/Task/Reverse-a-string/TAV/reverse-a-string.tav @@ -0,0 +1,3 @@ + str =: 'asdf' + rstr =: str::from -1 step -1 + print str, rstr diff --git a/Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas b/Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas index d37e9a9155..f40a454f5b 100644 --- a/Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas +++ b/Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas @@ -1,3 +1,29 @@ -## -var s:='Hey you, Bub!'; -s.ToWords.Reverse.Print; +begin + var lines := new string[] + ( + '---------- Ice and Fire ------------', + '', + 'fire, in end will world the say Some', + 'ice. in say Some', + 'desire of tasted I''ve what From', + 'fire. favor who those with hold I', + '', + '... elided paragraph last ...', + '', + 'Frost Robert -----------------------' + ); + + foreach var line in lines do + begin + // Разбиваем строку на слова (по пробелам), фильтруем пустые + var words := line.Split(' ').Where(w -> w <> '').ToArray(); + + // Меняем порядок слов на обратный + words := words.Reverse().ToArray(); + + // Собираем обратно в строку через пробел + var reversedLine := String.Join(' ', words); + + Writeln(reversedLine); + end; +end. diff --git a/Task/Reverse-words-in-a-string/Pluto/reverse-words-in-a-string.pluto b/Task/Reverse-words-in-a-string/Pluto/reverse-words-in-a-string.pluto new file mode 100644 index 0000000000..62339693d2 --- /dev/null +++ b/Task/Reverse-words-in-a-string/Pluto/reverse-words-in-a-string.pluto @@ -0,0 +1,16 @@ +local lines = { + "---------- Ice and Fire ------------", + " ", + "fire, in end will world the say Some", + "ice. in say Some ", + "desire of tasted I've what From ", + "fire. favor who those with hold I ", + " ", + "... elided paragraph last ... ", + " ", + "Frost Robert -----------------------" +} + +for lines as line do + print(line:strip(" "):split(" "):reverse():concat(" ")) +end diff --git a/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode-1.pas b/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode-1.pas index d41482fd30..7c3d0eab27 100644 --- a/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode-1.pas +++ b/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode-1.pas @@ -1,39 +1,20 @@ -function Rim2Arab(S : String) : Integer; -const //римские числа на соответствующие десятичные числа -R : array[1..14] of String[2] = ('M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I',' '); -A : array[1..14] of Integer = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0); +function romanDecode(roman: string): integer; begin - var i := 1; + var values := Dict('I' to 1, 'V' to 5, 'X' to 10, 'L' to 50, 'C' to 100, 'D' to 500, 'M' to 1000); Result := 0; - while S.Length > 0 do - begin - while S.IndexOf(R[i]) = 0 do - begin - S := S.Remove(0, R[i].Length); - Result += A[i] - end; - i += 1; - end; + var prev := 0; + for var i := roman.Length downto 1 do + begin + var curr := values[roman[i]]; + if curr < prev + then Result -= curr + else Result += curr; + prev := curr; + end; end; - -const - L = 'IVXLCDM'; begin - var S := 'MDCLXVI';//'roman numeral:'; - Write(S,': '); - var index := 1; - repeat - if L.IndexOf(S[index]) < 0 then - index += 1 - else - begin - var Rim : String := ''; - repeat - Rim += S[index]; - S := S.Remove(index - 1, 1); - until (S.Length < index) or (L.IndexOf(S[index]) < 0); - S := S.Insert(index - 1, Rim2Arab(Rim).ToString); - end; - until index > S.Length; - WriteLn(S); + var romans := |'I', 'III', 'IV', 'VIII', 'XLIX', 'CCII', + 'CDXXXIII', 'MCMXC', 'MMVIII', 'MDCLXVI'|; + foreach var roman in romans do + writeln(roman:8, romanDecode(roman):7); end. diff --git a/Task/Roman-numerals-Encode/Pluto/roman-numerals-encode.pluto b/Task/Roman-numerals-Encode/Pluto/roman-numerals-encode.pluto new file mode 100644 index 0000000000..d9b6de58f8 --- /dev/null +++ b/Task/Roman-numerals-Encode/Pluto/roman-numerals-encode.pluto @@ -0,0 +1,3 @@ +local fmt = require "fmt" + +for {1990, 1666, 2008, 2020, 2025} as n do print(fmt.roman(n)) end diff --git a/Task/Roots-of-a-function/EasyLang/roots-of-a-function.easy b/Task/Roots-of-a-function/EasyLang/roots-of-a-function.easy index 7c73b64b86..bee95e22c6 100644 --- a/Task/Roots-of-a-function/EasyLang/roots-of-a-function.easy +++ b/Task/Roots-of-a-function/EasyLang/roots-of-a-function.easy @@ -15,14 +15,10 @@ proc findroot start stop step . x += step . . -xp = 0 / 0 -yp = 0 proc lineto x y . x = x * 10 + 50 y = y * 10 + 50 - if xp = xp : gline xp yp x y - xp = x - yp = y + glineto x y . proc drawfunc start stop . glinewidth 0.3 @@ -30,6 +26,7 @@ proc drawfunc start stop . gline 50 0 50 100 drawgrid x = start + gpenup while x <= stop lineto x f x x += 0.1 diff --git a/Task/Roots-of-a-quadratic-function/Pluto/roots-of-a-quadratic-function.pluto b/Task/Roots-of-a-quadratic-function/Pluto/roots-of-a-quadratic-function.pluto new file mode 100644 index 0000000000..d3744aefba --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Pluto/roots-of-a-quadratic-function.pluto @@ -0,0 +1,44 @@ +require "complex" + +local function quadratic(a, b, c) + local d = b * b - 4 * a * c + if d == 0 then + -- single root + return {{-b / (2 * a)}, nil} + end + if d > 0 then + -- two real roots + local sr = math.sqrt(d) + d = b < 0 ? sr - b : -sr - b + return {{d / (2 * a), 2 * c / d}, nil} + end + -- two complex roots + local den = 1 / (2 * a) + local t1 = complex.of(-b * den, 0) + local t2 = complex.of(0, math.sqrt(-d)) * den + return {{}, {t1 + t2, t1 - t2}} +end + +local function test(a, b, c) + io.write($"coefficients: {a}, {b}, {c} -> ") + local roots = quadratic(a, b, c) + local r = roots[1] + if #r == 1 then + print($"one real root: {r[1]}") + elseif #r == 2 then + print($"two real roots: {r[1]} and {r[2]}") + else + local i = roots[2] + print($"two complex roots: {i[1]:tostring()} and {i[2]:tostring()}") + end +end + +local coeffs = { + {1, -2, 1}, + {1, 0, 1}, + {1, -10, 1}, + {1, -1000, 1}, + {1, -1e9, 1} +} + +for coeffs as c do test(c[1], c[2], c[3]) end diff --git a/Task/Roots-of-unity/DuckDB/roots-of-unity.duckdb b/Task/Roots-of-unity/DuckDB/roots-of-unity.duckdb new file mode 100644 index 0000000000..a301f16384 --- /dev/null +++ b/Task/Roots-of-unity/DuckDB/roots-of-unity.duckdb @@ -0,0 +1,11 @@ +create or replace function nthroots(n) as table ( + with twopi as (select 2*pi() as twopi), + etc as ( + select ((twopi * i) / n) as angle, cos(angle), sin(angle) + from range(0,n) t(i), twopi + ) + select COLUMNS(* EXCLUDE (angle)) + from etc +); + +from nthroots(10); diff --git a/Task/Roots-of-unity/Pluto/roots-of-unity.pluto b/Task/Roots-of-unity/Pluto/roots-of-unity.pluto new file mode 100644 index 0000000000..85a3e765f3 --- /dev/null +++ b/Task/Roots-of-unity/Pluto/roots-of-unity.pluto @@ -0,0 +1,12 @@ +require "complex" + +local function roots(n) + local r = {} + for i = 1, n do r[i] = complex.polar(1, 2 * math.pi * (i - 1) / n) end + return r +end + +for n = 2, 5 do + print($"{n} roots of 1:") + for roots(n) as r do print(r:format(" % 0.14f", "%0.14f")) end +end diff --git a/Task/Rosetta-Code-Count-examples/Raku/rosetta-code-count-examples.raku b/Task/Rosetta-Code-Count-examples/Raku/rosetta-code-count-examples.raku index 72ab33eafb..3b63207a34 100644 --- a/Task/Rosetta-Code-Count-examples/Raku/rosetta-code-count-examples.raku +++ b/Task/Rosetta-Code-Count-examples/Raku/rosetta-code-count-examples.raku @@ -11,7 +11,7 @@ my %cat = ( 'Draft_Programming_Tasks' => 'Draft' ); -my $client = HTTP::UserAgent.new; +my $client = HTTP::UserAgent.new(:useragent('Rosetta Code Task bot')); $client.timeout = 10; my $url = 'https://rosettacode.org/w'; diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Ring/rosetta-code-find-unimplemented-tasks.ring b/Task/Rosetta-Code-Find-unimplemented-tasks/Ring/rosetta-code-find-unimplemented-tasks.ring index ecba0f6e9b..67c11fbb7f 100644 --- a/Task/Rosetta-Code-Find-unimplemented-tasks/Ring/rosetta-code-find-unimplemented-tasks.ring +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Ring/rosetta-code-find-unimplemented-tasks.ring @@ -49,11 +49,3 @@ func searchtitle(sn) see "" + num + ". " + rosname + nl ok return sn - -func count(cstring,dstring) - sum = 0 - while substr(cstring,dstring) > 0 - sum = sum + 1 - cstring = substr(cstring,substr(cstring,dstring)+len(string(sum))) - end - return sum diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Raku/rosetta-code-rank-languages-by-popularity-1.raku b/Task/Rosetta-Code-Rank-languages-by-popularity/Raku/rosetta-code-rank-languages-by-popularity-1.raku index 8d27b23439..559e4b1c35 100644 --- a/Task/Rosetta-Code-Rank-languages-by-popularity/Raku/rosetta-code-rank-languages-by-popularity-1.raku +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Raku/rosetta-code-rank-languages-by-popularity-1.raku @@ -3,7 +3,7 @@ use URI::Escape; use JSON::Fast; use Sort::Naturally; -my $client = HTTP::UserAgent.new; +my $client = HTTP::UserAgent.new(:useragent('Rosetta Code Task bot')); my $url = 'https://rosettacode.org/w'; diff --git a/Task/Rot-13/Crystal/rot-13.cr b/Task/Rot-13/Crystal/rot-13.cr new file mode 100644 index 0000000000..1fee64a08c --- /dev/null +++ b/Task/Rot-13/Crystal/rot-13.cr @@ -0,0 +1,5 @@ +from = ['A'..'Z', 'a'..'z'].flat_map(&.to_a).join +to = ['N'..'Z', 'A'..'M', 'n'..'z', 'a'..'m'].flat_map(&.to_a).join +while line = ARGF.gets + puts line.tr from, to +end diff --git a/Task/Rot-13/Lua/rot-13-1.lua b/Task/Rot-13/Lua/rot-13-1.lua index 2d55a69cac..b58dd54201 100644 --- a/Task/Rot-13/Lua/rot-13-1.lua +++ b/Task/Rot-13/Lua/rot-13-1.lua @@ -3,3 +3,5 @@ function rot13(s) local b = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm" return (s:gsub("%a", function(c) return b:sub(a:find(c)) end)) end + +print(rot13("nowhere ABJURER")) diff --git a/Task/Rot-13/Lua/rot-13-2.lua b/Task/Rot-13/Lua/rot-13-2.lua index 79cd59dcf7..eff6e9239d 100644 --- a/Task/Rot-13/Lua/rot-13-2.lua +++ b/Task/Rot-13/Lua/rot-13-2.lua @@ -1,3 +1,5 @@ function rot13(s) return (s:gsub("%a", function(c) c=c:byte() return string.char(c+(c%32<14 and 13 or -13)) end)) end + +print(rot13("nowhere ABJURER")) diff --git a/Task/Rot-13/Pluto/rot-13.pluto b/Task/Rot-13/Pluto/rot-13.pluto new file mode 100644 index 0000000000..38c8e47174 --- /dev/null +++ b/Task/Rot-13/Pluto/rot-13.pluto @@ -0,0 +1,14 @@ +local function rot13(s) + local bytes = {s:byte(1, #s)} + for i = 1, #bytes do + local c = bytes[i] + if (c >= 65 and c <= 77) or (c >= 97 and c <= 109) then + bytes[i] = c + 13 + elseif (c >= 78 and c <= 90) or (c >= 110 and c <= 122) then + bytes[i] = c - 13 + end + end + return string.char(bytes:unpack()) +end + +print(rot13("nowhere ABJURER")) diff --git a/Task/Rot-13/Rhombus/rot-13.rhombus b/Task/Rot-13/Rhombus/rot-13.rhombus new file mode 100644 index 0000000000..590cf6a5dc --- /dev/null +++ b/Task/Rot-13/Rhombus/rot-13.rhombus @@ -0,0 +1,23 @@ +#lang rhombus/static + +import lib("racket/base.rkt") expose: + #{string->list} as string_to_list + #{list->string} as list_to_string + modulo + +fun rot13_char(char :: Char): + let char_int = char.to_int() + fun rot13_by_case(char_int, a_char :: Char) :: Int : + modulo(char_int - a_char.to_int() + 13, 26) + a_char.to_int() + if char.is_alphabetic(): + | if char.is_lowercase(): + | Char.from_int(rot13_by_case(char_int, Char"a")) + | Char.from_int(rot13_by_case(char_int, Char"A")) + | char + +fun rot13_string(str :: String) :: String : + let chars :: PairList = string_to_list(str) + let str :: MutableString = list_to_string(chars.map(rot13_char)) + str.snapshot() + +rot13_string("Hello, World!") // Output: "Uryyb, Jbeyq!"" diff --git a/Task/Rot-13/S-BASIC/rot-13.basic b/Task/Rot-13/S-BASIC/rot-13.basic index 2285ebf169..f60275b37d 100644 --- a/Task/Rot-13/S-BASIC/rot-13.basic +++ b/Task/Rot-13/S-BASIC/rot-13.basic @@ -21,7 +21,7 @@ rem - exercise the function var plain, encoded = string -plain = "The quick brown fox jumps over the lazy red dog." +plain = "The quick brown fox jumps over the lazy dog." encoded = rot13(plain) print "Plain text: "; plain print "Encoded : "; encoded diff --git a/Task/Run-length-encoding/DuckDB/run-length-encoding-1.duckdb b/Task/Run-length-encoding/DuckDB/run-length-encoding-1.duckdb new file mode 100644 index 0000000000..f88b7634f0 --- /dev/null +++ b/Task/Run-length-encoding/DuckDB/run-length-encoding-1.duckdb @@ -0,0 +1,23 @@ +create or replace function run_length_encode(str) as table + (WITH RECURSIVE cte AS ( + SELECT + 1 AS pos, + 1 AS counter, + SUBSTRING(str, 1, 1) AS char, + SUBSTRING(str, 2, 1) AS nextc, + UNION ALL + SELECT + pos + 1 as pos, + CASE + WHEN nextc = char THEN counter + 1 + ELSE 1 + END as counter, + nextc as char, + SUBSTRING(str, 2 + pos, 1) as nextc + FROM cte + WHERE pos < LENGTH(str) + ) + SELECT STRING_AGG( counter || char, '' ORDER BY pos) AS encoded_string + FROM cte + WHERE nextc != char + ); diff --git a/Task/Run-length-encoding/DuckDB/run-length-encoding-2.duckdb b/Task/Run-length-encoding/DuckDB/run-length-encoding-2.duckdb new file mode 100644 index 0000000000..15a06b1b33 --- /dev/null +++ b/Task/Run-length-encoding/DuckDB/run-length-encoding-2.duckdb @@ -0,0 +1 @@ +from run_length_encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'); diff --git a/Task/Runge-Kutta-method/Pluto/runge-kutta-method.pluto b/Task/Runge-Kutta-method/Pluto/runge-kutta-method.pluto new file mode 100644 index 0000000000..597b4e14b9 --- /dev/null +++ b/Task/Runge-Kutta-method/Pluto/runge-kutta-method.pluto @@ -0,0 +1,30 @@ +local fmt = require "fmt" + +local function runge_kutta4(t0, tz, dt, y, yd) + local tn = t0 + local yn = y(tn) + local z = (tz - t0) // dt + for i = 0, z do + if i % 10 == 0 then + local exact = y(tn) + local err = yn - exact + fmt.print("%4.1f %10f %10f %9f", tn, yn, exact, err) + end + if i == z then break end + local dy1 = dt * yd(tn, yn) + local dy2 = dt * yd(tn + 0.5 * dt, yn + 0.5 * dy1) + local dy3 = dt * yd(tn + 0.5 * dt, yn + 0.5 * dy2) + local dy4 = dt * yd(tn + dt, yn + dy3) + yn += (dy1 + 2.0 * dy2 + 2.0 * dy3 + dy4) / 6.0 + tn += dt + end +end + +print(" T RK4 Exact Error") +print("---- --------- ---------- ---------") +local function y(t) + local x = t * t + 4.0 + return x * x / 16.0 +end +local yd = |t, yt| -> t * math.sqrt(yt) +runge_kutta4(0, 10, 0.1, y, yd) diff --git a/Task/Runge-Kutta-method/REXX/runge-kutta-method.rexx b/Task/Runge-Kutta-method/REXX/runge-kutta-method.rexx index 9d04f0a647..7d3fb38294 100644 --- a/Task/Runge-Kutta-method/REXX/runge-kutta-method.rexx +++ b/Task/Runge-Kutta-method/REXX/runge-kutta-method.rexx @@ -1,28 +1,51 @@ -/*REXX program uses the Runge─Kutta method to solve the equation: y'(t) = t² √[y(t)] */ -numeric digits 40; f= digits() % 4 /*use 40 decimal digs, but only show 10*/ -x0= 0; x1= 10; dx= .1 /*define variables: X0 X1 DX */ -n=1 + (x1-x0) / dx -y.=1; do m=1 for n-1; p= m - 1; y.m= RK4(dx, x0 + dx*p, y.p) - end /*m*/ /* [↑] use 4th order Runge─Kutta. */ -w= digits() % 2 /*W: width used for displaying numbers.*/ -say center('X', f, "═") center('Y', w+2, "═") center("relative error", w+8, '═') /*hdr*/ +-- 28 Jul 2025 +include Settings - do i=0 to n-1 by 10; x= (x0 + dx*i) / 1; $= y.i / (x*x/4+1)**2 - 1 - say center(x, f) fmt(y.i) left('', 2 + ($>=0) ) fmt($) - end /*i*/ /*└┴┴┴───◄─────── aligns positive #'s. */ -exit /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -fmt: parse arg z; z= right( format(z, w, f), w); hasE= pos('E', z)>0; has.= pos(., z)>0 - jus= has. & \hasE; T= 'T'; if jus then z= left( strip( strip(z, T, 0), T, .), w) - return translate( right(z, (z>=0) + w + 5*hasE + 2*(jus & (z<0) ) ), 'e', "E") -/*──────────────────────────────────────────────────────────────────────────────────────*/ -RK4: procedure; parse arg dx,x,y; dxH= dx/2; k1= dx * (x ) * sqrt(y ) - k2= dx * (x + dxH) * sqrt(y + k1/2) - k3= dx * (x + dxH) * sqrt(y + k2/2) - k4= dx * (x + dx ) * sqrt(y + k3 ) - return y + (k1 + k2*2 + k3*2 + k4) / 6 -/*──────────────────────────────────────────────────────────────────────────────────────*/ -sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); m.=9; numeric form; h=d+6 - numeric digits; parse value format(x,2,1,,0) 'E0' with g 'E' _ .; g=g * .5'e'_ % 2 - do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/ - do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g)*.5; end /*k*/; return g +say "RUNGE-KUTTA METHOD FOR ODE y'=x*SqRt(y)" +say version +say +numeric digits 9 +call Task 0,10,1/10,1 +numeric digits 16 +call Task 0,10,1/10,1 +numeric digits 9 +call Task 0,10,1/20,1 +numeric digits 16 +call Task 0,10,1/20,1 +call Timer +exit + +Task: +procedure expose Memo. +arg x0,xn,dx,y0 +x=x0; y=y0 +say 'From' x0 'to' xn 'step' dx 'with' Digits() 'digits' +say ' x Calc y True y Abs error Rel error' +call Show x,y +do until x >= xn + dy1=dx*DyDx(x,y) + dy2=dx*DyDx(x+dx/2,y+dy1/2) + dy3=dx*DyDx(x+dx/2,y+dy2/2) + dy4=dx*DyDx(x+dx,y+dy3) + x=x+dx; y=y+(dy1+2*dy2+2*dy3+dy4)/6 + if Integer(x) then + call Show x,y +end +say +return + +DyDx: +arg xx,yy +return xx*SqRt(yy) + +True: +arg xx +return (xx**2+4)**2/16 + +Show: +arg xx,yy +say Format(xx,2,0) Format(yy,3,8) Format(True(xx),3,8), + Left(Std(Abs(yy-True(xx))),10) Left(Std(Abs(yy/True(xx)-1)),10) +return + +include Math diff --git a/Task/Ruth-Aaron-numbers/Python/ruth-aaron-numbers.py b/Task/Ruth-Aaron-numbers/Python/ruth-aaron-numbers.py new file mode 100644 index 0000000000..16ea510fb8 --- /dev/null +++ b/Task/Ruth-Aaron-numbers/Python/ruth-aaron-numbers.py @@ -0,0 +1,104 @@ +from collections import deque +from itertools import count +from itertools import islice +from pprint import pprint +from typing import Iterable +from typing import Iterator +from typing import TypeVar + + +def prime_factors(n: int) -> Iterator[int]: + """Return the prime factors of 'n' in order using a wheel with basis [2, 3, 5]. + + Translation of `primeFactors` from https://rosettacode.org/wiki/Category_talk:Wren-math. + """ + if n < 2: + return + + inc = [4, 2, 4, 2, 4, 6, 2, 6] + + while n % 2 == 0: + yield 2 + n //= 2 + + while n % 3 == 0: + yield 3 + n //= 3 + + while n % 5 == 0: + yield 5 + n //= 5 + + k = 7 + i = 0 + + while k * k <= n: + if n % k == 0: + yield k + n //= k + else: + k += inc[i] + i = (i + 1) % 8 + + if n > 1: + yield n + + +_T = TypeVar("_T") + + +def sliding_window(it: Iterable[_T], n: int) -> Iterator[tuple[_T, ...]]: + it = iter(it) + window = deque(islice(it, n - 1), maxlen=n) + for x in it: + window.append(x) + yield tuple(window) + + +def ruth_aaron_numbers_factors() -> Iterator[int]: + for (i, a), (_, b) in sliding_window( + ((n, sum(prime_factors(n))) for n in count(2)), 2 + ): + if a == b: + yield i + + +def ruth_aaron_numbers_divisors() -> Iterator[int]: + for (i, a), (_, b) in sliding_window( + ((n, sum(set(prime_factors(n)))) for n in count(2)), 2 + ): + if a == b: + yield i + + +def ruth_aaron_triples_factors() -> Iterator[int]: + for (i, a), (_, b), (_, c) in sliding_window( + ((n, sum(prime_factors(n))) for n in count(2)), 3 + ): + if a == b == c: + yield i + + +def ruth_aaron_triples_divisors() -> Iterator[int]: + for (i, a), (_, b), (_, c) in sliding_window( + ((n, sum(set(prime_factors(n)))) for n in count(2)), 3 + ): + if a == b == c: + yield i + + +if __name__ == "__main__": + print("First 30 Ruth-Aaron numbers (factors):") + pprint(list(islice(ruth_aaron_numbers_factors(), 30)), compact=True) + print("") + + print("First 30 Ruth-Aaron numbers (divisors):") + pprint(list(islice(ruth_aaron_numbers_divisors(), 30)), compact=True) + print("") + + print("First Ruth-Aaron triple (factors):") + print(next(ruth_aaron_triples_factors())) + print("") + + print("First Ruth-Aaron triple (divisors):") + print(next(ruth_aaron_triples_divisors())) diff --git a/Task/SEDOLs/Prolog/sedols-1.pro b/Task/SEDOLs/Prolog/sedols-1.pro new file mode 100644 index 0000000000..82aaf1ee0d --- /dev/null +++ b/Task/SEDOLs/Prolog/sedols-1.pro @@ -0,0 +1,40 @@ +:- set_prolog_flag(double_quotes, codes). +:- use_module(library(clpfd)). + +sedol --> + sdigit(S1), sdigit(S2), sdigit(S3), sdigit(S4), sdigit(S5), sdigit(S6), sdigit(S7), + { S7 in 0..9, + (S1 + S2 * 3 + S3 + S4 * 7 + S5 * 3 + S6 * 9 + S7) mod 10 #= 0 + }. + +sdigit(Value) --> [Code], + { Value in 0..35, + Code in 48..57\/66..68\/70..72\/74..78\/80..84\/86..90, + Code in 48..57 #<==> Value #= Code - 48, + Code in 66..90 #<==> Value #= Code - 55 + }. + +add_checksum_digit(SEDOL6, SEDOL7) :- + append(SEDOL6, [_], SEDOL7), + phrase(sedol, SEDOL7), + once(label(SEDOL7)). + +% adds the checksum digits to each number and removes any invalid numbers +task(SEDOL6s) :- + convlist(add_checksum_digit, SEDOL6s, SEDOL7s), + foreach(member(SEDOL7, SEDOL7s), format("~s~n", [SEDOL7])). + +?- task([ + "710889", + "B0YBKJ", + "406566", + "B0YBLH", + "228276", + "B0YBKL", + "557910", + "B0YBKR", + "585284", + "B0YBKT", + "BOYBKT", % Ill formed test case - illegal vowel. + "B00030" + ]). diff --git a/Task/SEDOLs/Prolog/sedols-2.pro b/Task/SEDOLs/Prolog/sedols-2.pro new file mode 100644 index 0000000000..c08bcdfb76 --- /dev/null +++ b/Task/SEDOLs/Prolog/sedols-2.pro @@ -0,0 +1,5 @@ +?- SEDOL = [0'7, _, 0'0, 0'8, 0'8, 0'9, 0'9], phrase(sedol, SEDOL), label(SEDOL). +SEDOL = "7108899" ; +SEDOL = "7B08899" ; +SEDOL = "7L08899" ; +SEDOL = "7V08899". diff --git a/Task/SEDOLs/Prolog/sedols-3.pro b/Task/SEDOLs/Prolog/sedols-3.pro new file mode 100644 index 0000000000..ad9ef5772c --- /dev/null +++ b/Task/SEDOLs/Prolog/sedols-3.pro @@ -0,0 +1,21 @@ +?- phrase(sedol, SEDOL), label(SEDOL). +SEDOL = "0000000" ; +SEDOL = "0000011" ; +SEDOL = "0000022" ; +SEDOL = "0000033" ; +SEDOL = "0000044" ; +SEDOL = "0000055" ; +SEDOL = "0000066" ; +SEDOL = "0000077" ; +SEDOL = "0000088" ; +SEDOL = "0000099" ; +SEDOL = "00000B1" ; +SEDOL = "00000C2" ; +SEDOL = "00000D3" ; +SEDOL = "00000F5" ; +SEDOL = "00000G6" ; +SEDOL = "00000H7" ; +SEDOL = "00000J9" ; +SEDOL = "00000K0" ; +SEDOL = "00000L1" ; +SEDOL = "00000M2" . % etc... diff --git a/Task/SHA-1/C++/sha-1-2.cpp b/Task/SHA-1/C++/sha-1-2.cpp index 5efd04ae81..c0697e96ba 100644 --- a/Task/SHA-1/C++/sha-1-2.cpp +++ b/Task/SHA-1/C++/sha-1-2.cpp @@ -8,67 +8,67 @@ class SHA1 { public: - std::string message_digest(const std::string& message) { - std::vector state = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; + std::string message_digest(const std::string& message) { + std::vector state = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; - const std::vector bytes = add_padding(message); - for ( uint64_t i = 0; i < bytes.size() / BLOCK_LENGTH; ++i ) { - std::vector values(80, 0); - for ( uint32_t j = 0; j < BLOCK_LENGTH; ++j ) { - values[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); - } - for ( uint32_t j = 16; j < 80; ++j ) { - uint32_t value = values[j - 3] ^ values[j - 8] ^ values[j - 14] ^ values[j - 16]; - values[j] = std::rotl(value, 1); - } + const std::vector bytes = add_padding(message); + for ( uint64_t i = 0; i < bytes.size() / BLOCK_LENGTH; ++i ) { + std::vector values(80, 0); + for ( uint32_t j = 0; j < BLOCK_LENGTH; ++j ) { + values[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); + } + for ( uint32_t j = 16; j < 80; ++j ) { + uint32_t value = values[j - 3] ^ values[j - 8] ^ values[j - 14] ^ values[j - 16]; + values[j] = std::rotl(value, 1); + } - uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; - uint32_t f = 0, k = 0; - for ( uint32_t j = 0; j < 80; ++j ) { - switch ( j / 20 ) { - case 0 : { f = ( b & c ) | ( ~b & d ); k = 0x5a827999; break; } - case 1 : { f = b ^ c ^ d; k = 0x6ed9eba1; break; } - case 2 : { f = ( b & c ) | ( b & d ) | ( c & d ); k = 0x8f1bbcdc; break; } - case 3 : { f = b ^ c ^ d; k = 0xca62c1d6; break; } - } + uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; + uint32_t f = 0, k = 0; + for ( uint32_t j = 0; j < 80; ++j ) { + switch ( j / 20 ) { + case 0 : { f = ( b & c ) | ( ~b & d ); k = 0x5a827999; break; } + case 1 : { f = b ^ c ^ d; k = 0x6ed9eba1; break; } + case 2 : { f = ( b & c ) | ( b & d ) | ( c & d ); k = 0x8f1bbcdc; break; } + case 3 : { f = b ^ c ^ d; k = 0xca62c1d6; break; } + } - uint32_t temp = std::rotl(a, 5) + f + e + k + values[j]; - e = d; d = c; c = std::rotl(b, 30); b = a; a = temp; - } + uint32_t temp = std::rotl(a, 5) + f + e + k + values[j]; + e = d; d = c; c = std::rotl(b, 30); b = a; a = temp; + } - state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; - } + state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; + } - std::stringstream stream; - for ( uint32_t i = 0; i < 20; ++i ) { - int8_t byte_value = static_cast(state[i / 4] >> ( 24 - ( i % 4 ) * 8)); - stream << std::setfill('0') << std::setw(2) << std::hex << ( byte_value & 0xff ); - } - return stream.str(); - } + std::stringstream stream; + for ( uint32_t i = 0; i < 20; ++i ) { + int8_t byte_value = static_cast(state[i / 4] >> ( 24 - ( i % 4 ) * 8)); + stream << std::setfill('0') << std::setw(2) << std::hex << ( byte_value & 0xff ); + } + return stream.str(); + } private: - std::vector add_padding(const std::string& message) { - std::vector bytes(message.begin(), message.end()); - bytes.emplace_back(static_cast(0x80)); + std::vector add_padding(const std::string& message) { + std::vector bytes(message.begin(), message.end()); + bytes.emplace_back(static_cast(0x80)); - uint32_t padding = BLOCK_LENGTH - ( bytes.size() % BLOCK_LENGTH ); - if ( padding < 8 ) { - padding += BLOCK_LENGTH; - } - bytes.resize(bytes.size() + padding - 8, static_cast(0x0)); + uint32_t padding = BLOCK_LENGTH - ( bytes.size() % BLOCK_LENGTH ); + if ( padding < 8 ) { + padding += BLOCK_LENGTH; + } + bytes.resize(bytes.size() + padding - 8, static_cast(0x0)); - const uint64_t bit_length = 8 * message.length(); - for ( int32_t i = 7; i >= 0; --i ) { - bytes.emplace_back(static_cast(bit_length >> ( 8 * i ))); - } - return bytes; - } + const uint64_t bit_length = 8 * message.length(); + for ( int32_t i = 7; i >= 0; --i ) { + bytes.emplace_back(static_cast(bit_length >> ( 8 * i ))); + } + return bytes; + } - const uint32_t BLOCK_LENGTH = 64; + const uint32_t BLOCK_LENGTH = 64; }; int main() { - SHA1 sha1; - std::cout << sha1.message_digest("Rosetta Code") << std::endl; + SHA1 sha1; + std::cout << sha1.message_digest("Rosetta Code") << std::endl; } diff --git a/Task/SHA-1/Hare/sha-1.hare b/Task/SHA-1/Hare/sha-1.hare index a6f6419c1e..64ac39bd10 100644 --- a/Task/SHA-1/Hare/sha-1.hare +++ b/Task/SHA-1/Hare/sha-1.hare @@ -6,11 +6,11 @@ use os; use strings; export fn main() void = { - const sha = sha1::sha1(); - hash::write(&sha, strings::toutf8("Rosetta Code")); + const sha = sha1::sha1(); + hash::write(&sha, strings::toutf8("Rosetta Code")); - let sum: [sha1::SIZE]u8 = [0...]; - hash::sum(&sha, sum); - hex::encode(os::stdout, sum)!; - fmt::println()!; + let sum: [sha1::SIZE]u8 = [0...]; + hash::sum(&sha, sum); + hex::encode(os::stdout, sum)!; + fmt::println()!; }; diff --git a/Task/SHA-1/Haxe/sha-1.haxe b/Task/SHA-1/Haxe/sha-1.haxe index 751e75218f..56e12fee6b 100644 --- a/Task/SHA-1/Haxe/sha-1.haxe +++ b/Task/SHA-1/Haxe/sha-1.haxe @@ -1,7 +1,7 @@ import haxe.crypto.Sha1; class Main { - static function main() { + static function main() { var sha1 = Sha1.encode("Rosetta Code"); Sys.println(sha1); } diff --git a/Task/SHA-1/Java/sha-1.java b/Task/SHA-1/Java/sha-1.java index 98030f5393..fd7ec7e47b 100644 --- a/Task/SHA-1/Java/sha-1.java +++ b/Task/SHA-1/Java/sha-1.java @@ -3,69 +3,69 @@ import java.util.Arrays; public final class SHA1Task { - public static void main(String[] args) { - System.out.println(SHA1.messageDigest("Rosetta Code")); - } + public static void main(String[] args) { + System.out.println(SHA1.messageDigest("Rosetta Code")); + } } final class SHA1 { - - public static String messageDigest(String message) { - int[] state = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; - - byte[] bytes = addPadding(message); - for ( int i = 0; i < bytes.length / BLOCK_LENGTH; i++ ) { - int[] values = new int[80]; - for ( int j = 0; j < BLOCK_LENGTH; j++ ) { - values[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); - } - for ( int j = 16; j < 80; j++ ) { - values[j] = Integer.rotateLeft(values[j - 3] ^ values[j - 8] ^ values[j - 14] ^ values[j - 16], 1); - } - - int a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; - int f = 0, k = 0; - for ( int j = 0; j < 80; j++ ) { - switch ( j / 20 ) { - case 0 -> { f = ( b & c ) | ( ~b & d ); k = 0x5a827999; } - case 1 -> { f = b ^ c ^ d; k = 0x6ed9eba1; } - case 2 -> { f = ( b & c ) | ( b & d ) | ( c & d ); k = 0x8f1bbcdc; } - case 3 -> { f = b ^ c ^ d; k = 0xca62c1d6; } - } - int temp = Integer.rotateLeft(a, 5) + f + e + k + values[j]; - e = d; d = c; c = Integer.rotateLeft(b, 30); b = a; a = temp; - } - - state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; - } - - StringBuilder result = new StringBuilder(); + public static String messageDigest(String message) { + int[] state = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; + + byte[] bytes = addPadding(message); + for ( int i = 0; i < bytes.length / BLOCK_LENGTH; i++ ) { + int[] values = new int[80]; + for ( int j = 0; j < BLOCK_LENGTH; j++ ) { + values[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); + } + for ( int j = 16; j < 80; j++ ) { + values[j] = Integer.rotateLeft(values[j - 3] ^ values[j - 8] ^ values[j - 14] ^ values[j - 16], 1); + } + + int a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; + int f = 0, k = 0; + for ( int j = 0; j < 80; j++ ) { + switch ( j / 20 ) { + case 0 -> { f = ( b & c ) | ( ~b & d ); k = 0x5a827999; } + case 1 -> { f = b ^ c ^ d; k = 0x6ed9eba1; } + case 2 -> { f = ( b & c ) | ( b & d ) | ( c & d ); k = 0x8f1bbcdc; } + case 3 -> { f = b ^ c ^ d; k = 0xca62c1d6; } + } + + int temp = Integer.rotateLeft(a, 5) + f + e + k + values[j]; + e = d; d = c; c = Integer.rotateLeft(b, 30); b = a; a = temp; + } + + state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; + } + + StringBuilder result = new StringBuilder(); for ( int i = 0; i < 20; i++ ) { - result.append(String.format("%02x", ( state[i / 4] >>> 24 - ( i % 4 ) * 8 ) & 0xFF )); + result.append(String.format("%02x", ( state[i / 4] >>> 24 - ( i % 4 ) * 8 ) & 0xFF )); } return result.toString(); - } - - private static byte[] addPadding(String message) { - byte[] bytes = message.getBytes(StandardCharsets.UTF_8); - bytes = Arrays.copyOf(bytes, bytes.length + 1); - bytes[bytes.length - 1] = (byte) 0x80; - - int padding = BLOCK_LENGTH - ( bytes.length % BLOCK_LENGTH ); - if ( padding < 8 ) { - padding += BLOCK_LENGTH; - } - bytes = Arrays.copyOf(bytes, bytes.length + padding); - - final long bitLength = message.length() * 8; - for ( int i = 0; i < 8; i++ ) { - bytes[bytes.length - 1 - i] = (byte) ( bitLength >>> ( 8 * i ) ); - } - return bytes; - } - - private static final int BLOCK_LENGTH = 64; - + } + + private static byte[] addPadding(String message) { + byte[] bytes = message.getBytes(StandardCharsets.UTF_8); + bytes = Arrays.copyOf(bytes, bytes.length + 1); + bytes[bytes.length - 1] = (byte) 0x80; + + int padding = BLOCK_LENGTH - ( bytes.length % BLOCK_LENGTH ); + if ( padding < 8 ) { + padding += BLOCK_LENGTH; + } + bytes = Arrays.copyOf(bytes, bytes.length + padding); + + final long bitLength = message.length() * 8; + for ( int i = 0; i < 8; i++ ) { + bytes[bytes.length - 1 - i] = (byte) ( bitLength >>> ( 8 * i ) ); + } + return bytes; + } + + private static final int BLOCK_LENGTH = 64; + } diff --git a/Task/SHA-1/REBOL/sha-1-1.rebol b/Task/SHA-1/REBOL/sha-1-1.rebol new file mode 100644 index 0000000000..467d578cc5 --- /dev/null +++ b/Task/SHA-1/REBOL/sha-1-1.rebol @@ -0,0 +1 @@ +checksum/method "Rosetta Code" 'sha1 diff --git a/Task/SHA-1/REBOL/sha-1-2.rebol b/Task/SHA-1/REBOL/sha-1-2.rebol new file mode 100644 index 0000000000..5e2a23937d --- /dev/null +++ b/Task/SHA-1/REBOL/sha-1-2.rebol @@ -0,0 +1 @@ +checksum "Rosetta Code" 'sha1 diff --git a/Task/SHA-256/C++/sha-256-1.cpp b/Task/SHA-256/C++/sha-256-1.cpp index 0ccc8e6aa7..bc4251b0c1 100644 --- a/Task/SHA-256/C++/sha-256-1.cpp +++ b/Task/SHA-256/C++/sha-256-1.cpp @@ -4,16 +4,16 @@ #include int main(int argc, char **argv){ - CryptoPP::SHA256 hash; - std::string digest; - std::string message = "Rosetta code"; + CryptoPP::SHA256 hash; + std::string digest; + std::string message = "Rosetta code"; - CryptoPP::StringSource s(message, true, - new CryptoPP::HashFilter(hash, - new CryptoPP::HexEncoder( - new CryptoPP::StringSink(digest)))); + CryptoPP::StringSource s(message, true, + new CryptoPP::HashFilter(hash, + new CryptoPP::HexEncoder( + new CryptoPP::StringSink(digest)))); - std::cout << digest << std::endl; + std::cout << digest << std::endl; - return 0; + return 0; } diff --git a/Task/SHA-256/C++/sha-256-2.cpp b/Task/SHA-256/C++/sha-256-2.cpp index 35d2a6b832..964de7b0c6 100644 --- a/Task/SHA-256/C++/sha-256-2.cpp +++ b/Task/SHA-256/C++/sha-256-2.cpp @@ -8,84 +8,84 @@ class SHA256 { public: - std::string message_digest(const std::string& message) { - std::vector hash = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + std::string message_digest(const std::string& message) { + std::vector hash = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; - const std::vector bytes = add_padding(message); - for ( uint64_t i = 0; i < bytes.size() / BLOCK_LENGTH; ++i ) { - std::vector words(BLOCK_LENGTH, 0); - for ( int32_t j = 0; j < BLOCK_LENGTH; ++j ) { - words[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); - } - for ( int32_t j = 16; j < BLOCK_LENGTH; j++ ) { - words[j] = sigma(3, words[j - 2]) + words[j - 7] + sigma(2, words[j - 15]) + words[j - 16]; - } + const std::vector bytes = add_padding(message); + for ( uint64_t i = 0; i < bytes.size() / BLOCK_LENGTH; ++i ) { + std::vector words(BLOCK_LENGTH, 0); + for ( int32_t j = 0; j < BLOCK_LENGTH; ++j ) { + words[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); + } + for ( int32_t j = 16; j < BLOCK_LENGTH; j++ ) { + words[j] = sigma(3, words[j - 2]) + words[j - 7] + sigma(2, words[j - 15]) + words[j - 16]; + } - int32_t a = hash[0], b = hash[1], c = hash[2], d = hash[3], - e = hash[4], f = hash[5], g = hash[6], h = hash[7]; + int32_t a = hash[0], b = hash[1], c = hash[2], d = hash[3], + e = hash[4], f = hash[5], g = hash[6], h = hash[7]; - for ( int32_t j = 0; j < BLOCK_LENGTH; ++j ) { - int32_t t = h + sigma(1, e) + ch(e, f, g) + kk[j] + words[j]; - int32_t tt = sigma(0, a) + maj(a, b, c); - h = g; g = f; f = e; - e = d + t; - d = c; c = b; b = a; - a = t + tt; - } + for ( int32_t j = 0; j < BLOCK_LENGTH; ++j ) { + int32_t t = h + sigma(1, e) + ch(e, f, g) + kk[j] + words[j]; + int32_t tt = sigma(0, a) + maj(a, b, c); + h = g; g = f; f = e; + e = d + t; + d = c; c = b; b = a; + a = t + tt; + } - hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; - hash[4] += e; hash[5] += f; hash[6] += g; hash[7] += h; - } + hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; + hash[4] += e; hash[5] += f; hash[6] += g; hash[7] += h; + } - std::stringstream stream; - for ( int32_t i = 0; i < BLOCK_LENGTH; ++i ) { - int8_t byte_value = static_cast(hash[i / 8] >> ( 7 - i % 8 ) * 4); - stream << std::hex << ( byte_value & 0xf ); - } - return stream.str(); - } + std::stringstream stream; + for ( int32_t i = 0; i < BLOCK_LENGTH; ++i ) { + int8_t byte_value = static_cast(hash[i / 8] >> ( 7 - i % 8 ) * 4); + stream << std::hex << ( byte_value & 0xf ); + } + return stream.str(); + } private: - std::vector add_padding(const std::string& message) { - std::vector bytes(message.begin(), message.end()); - bytes.emplace_back(static_cast(0x80)); + std::vector add_padding(const std::string& message) { + std::vector bytes(message.begin(), message.end()); + bytes.emplace_back(static_cast(0x80)); - uint32_t padding = BLOCK_LENGTH - ( bytes.size() % BLOCK_LENGTH ); - if ( padding < 8 ) { - padding += BLOCK_LENGTH; - } - bytes.resize(bytes.size() + padding - 8, static_cast(0x0)); + uint32_t padding = BLOCK_LENGTH - ( bytes.size() % BLOCK_LENGTH ); + if ( padding < 8 ) { + padding += BLOCK_LENGTH; + } + bytes.resize(bytes.size() + padding - 8, static_cast(0x0)); - const uint64_t bit_length = 8 * message.length(); - for ( int32_t i = 7; i >= 0; --i ) { - bytes.emplace_back(static_cast(bit_length >> ( 8 * i ))); - } - return bytes; - } + const uint64_t bit_length = 8 * message.length(); + for ( int32_t i = 7; i >= 0; --i ) { + bytes.emplace_back(static_cast(bit_length >> ( 8 * i ))); + } + return bytes; + } - int32_t sigma(const uint32_t& group, const uint32_t& x) { - int32_t result; - switch ( group ) { - case 0 : result = std::rotr(x, 2) ^ std::rotr(x, 13) ^ std::rotr(x, 22); break; - case 1 : result = std::rotr(x, 6) ^ std::rotr(x, 11) ^ std::rotr(x, 25); break; - case 2 : result = std::rotr(x, 7) ^ std::rotr(x, 18) ^ ( x >> 3 ); break; - case 3 : result = std::rotr(x, 17) ^ std::rotr(x, 19) ^ ( x >> 10 ); break; - default : throw std::invalid_argument("Unexpected argument for sigma: " + std::to_string(group)); - } - return result; - } + int32_t sigma(const uint32_t& group, const uint32_t& x) { + int32_t result; + switch ( group ) { + case 0 : result = std::rotr(x, 2) ^ std::rotr(x, 13) ^ std::rotr(x, 22); break; + case 1 : result = std::rotr(x, 6) ^ std::rotr(x, 11) ^ std::rotr(x, 25); break; + case 2 : result = std::rotr(x, 7) ^ std::rotr(x, 18) ^ ( x >> 3 ); break; + case 3 : result = std::rotr(x, 17) ^ std::rotr(x, 19) ^ ( x >> 10 ); break; + default : throw std::invalid_argument("Unexpected argument for sigma: " + std::to_string(group)); + } + return result; + } - int32_t ch(const int32_t& x, const int32_t y, const int32_t z) { - return ( x & y ) ^ ( ~x & z ); - } + int32_t ch(const int32_t& x, const int32_t y, const int32_t z) { + return ( x & y ) ^ ( ~x & z ); + } - int32_t maj(const int32_t& x, const int32_t y, const int32_t z) { - return ( x & y ) ^ ( x & z ) ^ ( y & z ); - } + int32_t maj(const int32_t& x, const int32_t y, const int32_t z) { + return ( x & y ) ^ ( x & z ) ^ ( y & z ); + } - const std::vector kk = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + const std::vector kk = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, @@ -94,10 +94,10 @@ private: 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; - const int32_t BLOCK_LENGTH = 64; + const int32_t BLOCK_LENGTH = 64; }; int main() { - SHA256 sha256; - std::cout << sha256.message_digest("Rosetta code") << std::endl; + SHA256 sha256; + std::cout << sha256.message_digest("Rosetta code") << std::endl; } diff --git a/Task/SHA-256/C/sha-256.c b/Task/SHA-256/C/sha-256.c index 688dd2911d..8af297e0ab 100644 --- a/Task/SHA-256/C/sha-256.c +++ b/Task/SHA-256/C/sha-256.c @@ -3,13 +3,13 @@ #include int main (void) { - const char *s = "Rosetta code"; - unsigned char *d = SHA256(s, strlen(s), 0); + const char *s = "Rosetta code"; + unsigned char *d = SHA256(s, strlen(s), 0); - int i; - for (i = 0; i < SHA256_DIGEST_LENGTH; i++) - printf("%02x", d[i]); - putchar('\n'); + int i; + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) + printf("%02x", d[i]); + putchar('\n'); - return 0; + return 0; } diff --git a/Task/SHA-256/FutureBasic/sha-256.basic b/Task/SHA-256/FutureBasic/sha-256.basic index d63eade7d7..44fa12b300 100644 --- a/Task/SHA-256/FutureBasic/sha-256.basic +++ b/Task/SHA-256/FutureBasic/sha-256.basic @@ -11,7 +11,7 @@ void local fn DoIt MutableStringAppendFormat( res, @"%02x", buf(i) ) next NSLog(@"Input:\n%@\n",msg) - NSLog(@"Output:\n%@", res) + NSLog(@"Output:\n%@", res) end fn fn DoIt diff --git a/Task/SHA-256/Haxe/sha-256.haxe b/Task/SHA-256/Haxe/sha-256.haxe index d99b3edeb4..adbcee5c38 100644 --- a/Task/SHA-256/Haxe/sha-256.haxe +++ b/Task/SHA-256/Haxe/sha-256.haxe @@ -1,7 +1,7 @@ import haxe.crypto.Sha256; class Main { - static function main() { + static function main() { var sha256 = Sha256.encode("Rosetta code"); Sys.println(sha256); } diff --git a/Task/SHA-256/Java/sha-256.java b/Task/SHA-256/Java/sha-256.java index 40dfd1b2f9..1702aaa6e4 100644 --- a/Task/SHA-256/Java/sha-256.java +++ b/Task/SHA-256/Java/sha-256.java @@ -3,97 +3,97 @@ import java.util.Arrays; public final class SHA256Task { - public static void main(String[] args) { - System.out.println(SHA256.messageDigest("Rosetta code")); - } + public static void main(String[] args) { + System.out.println(SHA256.messageDigest("Rosetta code")); + } } final class SHA256 { - - public static String messageDigest(String message) { - int[] hash = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; - - final byte[] bytes = addPadding(message); - for ( int i = 0; i < bytes.length / BLOCK_LENGTH; i++ ) { - int[] words = new int[BLOCK_LENGTH]; - for ( int j = 0; j < BLOCK_LENGTH; j++ ) { - words[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); - } - for ( int j = 16; j < BLOCK_LENGTH; j++ ) { - words[j] = sigma(3, words[j - 2]) + words[j - 7] + sigma(2, words[j - 15]) + words[j - 16]; - } - - int a = hash[0], b = hash[1], c = hash[2], d = hash[3], - e = hash[4], f = hash[5], g = hash[6], h = hash[7]; - - for ( int j = 0; j < BLOCK_LENGTH; j++ ) { - int t = h + sigma(1, e) + ch(e, f, g) + kk[j] + words[j]; - int tt = sigma(0, a) + maj(a, b, c); - h = g; g = f; f = e; - e = d + t; - d = c; c = b; b = a; - a = t + tt; - } - hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; - hash[4] += e; hash[5] += f; hash[6] += g; hash[7] += h; - } - - StringBuilder result = new StringBuilder(); + public static String messageDigest(String message) { + int[] hash = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + + final byte[] bytes = addPadding(message); + for ( int i = 0; i < bytes.length / BLOCK_LENGTH; i++ ) { + int[] words = new int[BLOCK_LENGTH]; + for ( int j = 0; j < BLOCK_LENGTH; j++ ) { + words[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 ); + } + for ( int j = 16; j < BLOCK_LENGTH; j++ ) { + words[j] = sigma(3, words[j - 2]) + words[j - 7] + sigma(2, words[j - 15]) + words[j - 16]; + } + + int a = hash[0], b = hash[1], c = hash[2], d = hash[3], + e = hash[4], f = hash[5], g = hash[6], h = hash[7]; + + for ( int j = 0; j < BLOCK_LENGTH; j++ ) { + int t = h + sigma(1, e) + ch(e, f, g) + kk[j] + words[j]; + int tt = sigma(0, a) + maj(a, b, c); + h = g; g = f; f = e; + e = d + t; + d = c; c = b; b = a; + a = t + tt; + } + + hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; + hash[4] += e; hash[5] += f; hash[6] += g; hash[7] += h; + } + + StringBuilder result = new StringBuilder(); for ( int i = 0; i < BLOCK_LENGTH; i++ ) { - result.append(String.format("%1x", ( hash[i / 8] >>> ( 7 - i % 8 ) * 4 ) & 0xf )); + result.append(String.format("%1x", ( hash[i / 8] >>> ( 7 - i % 8 ) * 4 ) & 0xf )); } - return result.toString(); - } - - private static byte[] addPadding(String message) { - byte[] bytes = message.getBytes(StandardCharsets.ISO_8859_1); - bytes = Arrays.copyOf(bytes, bytes.length + 1); - bytes[bytes.length - 1] = (byte) 0x80; - - int padding = BLOCK_LENGTH - ( bytes.length % BLOCK_LENGTH ); - if ( padding < 8 ) { - padding += BLOCK_LENGTH; - } - bytes = Arrays.copyOf(bytes, bytes.length + padding); - - final long bitLength = message.length() * 8; - for ( int i = 0; i < 8; i++ ) { - bytes[bytes.length - 1 - i] = (byte) ( bitLength >>> ( 8 * i ) ); - } - return bytes; - } - - private static int sigma(int group, int x) { - return switch ( group ) { - case 0 -> Integer.rotateRight(x, 2) ^ Integer.rotateRight(x, 13) ^ Integer.rotateRight(x, 22); - case 1 -> Integer.rotateRight(x, 6) ^ Integer.rotateRight(x, 11) ^ Integer.rotateRight(x, 25); - case 2 -> Integer.rotateRight(x, 7) ^ Integer.rotateRight(x, 18) ^ ( x >>> 3 ); - case 3 -> Integer.rotateRight(x, 17) ^ Integer.rotateRight(x, 19) ^ ( x >>> 10 ); - default -> throw new AssertionError("Unexpected argument for sigma: " + group); - }; - } - - private static int ch(int x, int y, int z) { - return ( x & y ) ^ ( ~x & z ); - } + return result.toString(); + } - private static int maj(int x, int y, int z) { - return ( x & y ) ^ ( x & z ) ^ ( y & z ); - } - - private static final int[] kk = new int[] { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + private static byte[] addPadding(String message) { + byte[] bytes = message.getBytes(StandardCharsets.ISO_8859_1); + bytes = Arrays.copyOf(bytes, bytes.length + 1); + bytes[bytes.length - 1] = (byte) 0x80; + + int padding = BLOCK_LENGTH - ( bytes.length % BLOCK_LENGTH ); + if ( padding < 8 ) { + padding += BLOCK_LENGTH; + } + bytes = Arrays.copyOf(bytes, bytes.length + padding); + + final long bitLength = message.length() * 8; + for ( int i = 0; i < 8; i++ ) { + bytes[bytes.length - 1 - i] = (byte) ( bitLength >>> ( 8 * i ) ); + } + return bytes; + } + + private static int sigma(int group, int x) { + return switch ( group ) { + case 0 -> Integer.rotateRight(x, 2) ^ Integer.rotateRight(x, 13) ^ Integer.rotateRight(x, 22); + case 1 -> Integer.rotateRight(x, 6) ^ Integer.rotateRight(x, 11) ^ Integer.rotateRight(x, 25); + case 2 -> Integer.rotateRight(x, 7) ^ Integer.rotateRight(x, 18) ^ ( x >>> 3 ); + case 3 -> Integer.rotateRight(x, 17) ^ Integer.rotateRight(x, 19) ^ ( x >>> 10 ); + default -> throw new AssertionError("Unexpected argument for sigma: " + group); + }; + } + + private static int ch(int x, int y, int z) { + return ( x & y ) ^ ( ~x & z ); + } + + private static int maj(int x, int y, int z) { + return ( x & y ) ^ ( x & z ) ^ ( y & z ); + } + + private static final int[] kk = new int[] { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; - - private static final int BLOCK_LENGTH = 64; - + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; + + private static final int BLOCK_LENGTH = 64; + } diff --git a/Task/SHA-256/Perl/sha-256-2.pl b/Task/SHA-256/Perl/sha-256-2.pl index 19aefad802..a631643f16 100644 --- a/Task/SHA-256/Perl/sha-256-2.pl +++ b/Task/SHA-256/Perl/sha-256-2.pl @@ -10,130 +10,130 @@ my @h; my @k; for my $p ( 2 .. 311 ) { - # Horrible primality test, but sufficient for this task. - next if ("1" x $p) =~ /^(11+?)\1+$/; - # The choice to generate h and k instead of hard coding - # them is inspired by the Raku implementation. - my $c = $p ** ( 1/3 ); - push @k, int( ($c - int $c) * WORD ); - next if @h == 8; - my $s = $p ** ( 1/2 ); - push @h, int( ($s - int $s) * WORD ); + # Horrible primality test, but sufficient for this task. + next if ("1" x $p) =~ /^(11+?)\1+$/; + # The choice to generate h and k instead of hard coding + # them is inspired by the Raku implementation. + my $c = $p ** ( 1/3 ); + push @k, int( ($c - int $c) * WORD ); + next if @h == 8; + my $s = $p ** ( 1/2 ); + push @h, int( ($s - int $s) * WORD ); } sub new { - my %self = ( state => [@h], str => "", len => 0 ); - bless \%self, shift; + my %self = ( state => [@h], str => "", len => 0 ); + bless \%self, shift; } my $rightrotate = sub { - my $lo = $_[0] >> $_[1]; - my $hi = $_[0] << (32 - $_[1]); - ($hi | $lo); + my $lo = $_[0] >> $_[1]; + my $hi = $_[0] << (32 - $_[1]); + ($hi | $lo); }; # This is adapted from the wikipedia entry on SHA2. my $compress = sub { - my ($state, $bytes) = @_; - my @w = unpack 'N*', $bytes; - @w == 16 or die 'internal error'; - my ($a, $b, $c, $d, $e, $f, $g, $h) = @$state; - until( @w == 64 ) { - my $s0 = $w[-15] >> 3; - my $s1 = $w[-2] >> 10; - $s0 ^= $rightrotate->($w[-15], $_) for 7, 18; - $s1 ^= $rightrotate->($w[-2], $_) for 17, 19; - push @w, ($w[-16] + $s0 + $w[-7] + $s1) & MASK; - } - my $i = 0; - for my $w (@w) { - my $ch = ($e & $f) ^ ((~$e) & $g); - my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); - my ($S0, $S1) = (0, 0); - $S1 ^= $rightrotate->( $e, $_ ) for 6, 11, 25; - $S0 ^= $rightrotate->( $a, $_ ) for 2, 13, 22; - my $temp1 = $h + $S1 + $ch + $k[$i++] + $w; - my $temp2 = $S0 + $maj; - ($h, $g, $f, $e, $d, $c, $b, $a) = - ($g, $f, $e, ($d+$temp1)&MASK, $c, $b, $a, ($temp1+$temp2)&MASK); - } - my $j = 0; - $state->[$j++] += $_ for $a, $b, $c, $d, $e, $f, $g, $h; + my ($state, $bytes) = @_; + my @w = unpack 'N*', $bytes; + @w == 16 or die 'internal error'; + my ($a, $b, $c, $d, $e, $f, $g, $h) = @$state; + until( @w == 64 ) { + my $s0 = $w[-15] >> 3; + my $s1 = $w[-2] >> 10; + $s0 ^= $rightrotate->($w[-15], $_) for 7, 18; + $s1 ^= $rightrotate->($w[-2], $_) for 17, 19; + push @w, ($w[-16] + $s0 + $w[-7] + $s1) & MASK; + } + my $i = 0; + for my $w (@w) { + my $ch = ($e & $f) ^ ((~$e) & $g); + my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); + my ($S0, $S1) = (0, 0); + $S1 ^= $rightrotate->( $e, $_ ) for 6, 11, 25; + $S0 ^= $rightrotate->( $a, $_ ) for 2, 13, 22; + my $temp1 = $h + $S1 + $ch + $k[$i++] + $w; + my $temp2 = $S0 + $maj; + ($h, $g, $f, $e, $d, $c, $b, $a) = + ($g, $f, $e, ($d+$temp1)&MASK, $c, $b, $a, ($temp1+$temp2)&MASK); + } + my $j = 0; + $state->[$j++] += $_ for $a, $b, $c, $d, $e, $f, $g, $h; }; use constant can_Q => eval { length pack 'Q>', 0 }; sub add { - my ($self, $bytes) = @_; - $self->{len} += 8 * length $bytes; - if( !can_Q and $self->{len} >= WORD ) { - my $hi = int( $self->{len} / WORD ); - $self->{big} += $hi; - $self->{len} -= $hi * WORD; - } - my $len = length $self->{str}; - if( ($len + length $bytes) < 64 ) { - $self->{str} .= $bytes; - return $self; - } - my $off = 64 - $len; - $compress->( $self->{state}, $self->{str} . substr( $bytes, 0, $off ) ); - $len = length $_[0]; - while( $off+64 <= $len ) { - $compress->( $self->{state}, substr( $bytes, $off, 64 ) ); - $off += 64; - } - $self->{str} = substr( $bytes, $off ); - $self; + my ($self, $bytes) = @_; + $self->{len} += 8 * length $bytes; + if( !can_Q and $self->{len} >= WORD ) { + my $hi = int( $self->{len} / WORD ); + $self->{big} += $hi; + $self->{len} -= $hi * WORD; + } + my $len = length $self->{str}; + if( ($len + length $bytes) < 64 ) { + $self->{str} .= $bytes; + return $self; + } + my $off = 64 - $len; + $compress->( $self->{state}, $self->{str} . substr( $bytes, 0, $off ) ); + $len = length $_[0]; + while( $off+64 <= $len ) { + $compress->( $self->{state}, substr( $bytes, $off, 64 ) ); + $off += 64; + } + $self->{str} = substr( $bytes, $off ); + $self; } sub addfile { - my ($self, $fh) = @_; - my $s = ""; - while( read( $fh, $s, 2**13 ) ) { - $self->add( $s ); - } - $self; + my ($self, $fh) = @_; + my $s = ""; + while( read( $fh, $s, 2**13 ) ) { + $self->add( $s ); + } + $self; } sub digest { - my $self = shift; - my $final = $self->{str}; - $final .= chr 0x80; - while( ( 8+length $final ) % 64 ) { - $final .= chr 0; - } - if( can_Q ) { - $final .= pack 'Q>', $self->{len}; - } else { - $self->{big} ||= 0; - $final .= pack 'NN', $self->{big}, $self->{len}; - } - $compress->( $self->{state}, substr $final, 0, 64, "" ) while length $final; - if( wantarray ) { - map pack('N', $_), @{ $self->{state} }; - } else { - pack 'N*', @{ $self->{state} }; - } + my $self = shift; + my $final = $self->{str}; + $final .= chr 0x80; + while( ( 8+length $final ) % 64 ) { + $final .= chr 0; + } + if( can_Q ) { + $final .= pack 'Q>', $self->{len}; + } else { + $self->{big} ||= 0; + $final .= pack 'NN', $self->{big}, $self->{len}; + } + $compress->( $self->{state}, substr $final, 0, 64, "" ) while length $final; + if( wantarray ) { + map pack('N', $_), @{ $self->{state} }; + } else { + pack 'N*', @{ $self->{state} }; + } } sub hexdigest { - if( wantarray ) { - map unpack( 'H*', $_), &digest; - } else { - unpack 'H*', &digest; - } + if( wantarray ) { + map unpack( 'H*', $_), &digest; + } else { + unpack 'H*', &digest; + } } unless( caller ) { - my @testwith = (@ARGV ? @ARGV : 'Rosetta code'); - for my $str (@testwith) { - my $digester = __PACKAGE__->new; - $digester->add($str); - print "'$str':\n"; - print join(" ", $digester->hexdigest), "\n"; - } + my @testwith = (@ARGV ? @ARGV : 'Rosetta code'); + for my $str (@testwith) { + my $digester = __PACKAGE__->new; + $digester->add($str); + print "'$str':\n"; + print join(" ", $digester->hexdigest), "\n"; + } } 1; diff --git a/Task/SHA-256/REBOL/sha-256.rebol b/Task/SHA-256/REBOL/sha-256.rebol new file mode 100644 index 0000000000..ec065d3542 --- /dev/null +++ b/Task/SHA-256/REBOL/sha-256.rebol @@ -0,0 +1 @@ +checksum "Rosetta code" 'sha256 diff --git a/Task/SHA-256/Raku/sha-256-1.raku b/Task/SHA-256/Raku/sha-256-1.raku index feb02e9bca..2382d1b6c2 100644 --- a/Task/SHA-256/Raku/sha-256-1.raku +++ b/Task/SHA-256/Raku/sha-256-1.raku @@ -15,28 +15,28 @@ multi sha256(blob8 $data) { return blob8.new: map |*.polymod(256 xx 3).reverse, - |reduce -> $H, $block { - blob32.new: $H[] Z+ - reduce -> $h, $j { - my uint32 ($T1, $T2) = - $h[7] + Σ1($h[4]) + Ch(|$h[4..6]) - + (BEGIN init(* **(1/3))[^64])[$j] + - ( - (state buf32 $w .= new)[$j] = $j < 16 ?? $block[$j] !! - σ0($w[$j-15]) + $w[$j-7] + σ1($w[$j-2]) + $w[$j-16] - ), - Σ0($h[0]) + Maj(|$h[0..2]); - blob32.new: $T1 + $T2, |$h[0..2], $h[3] + $T1, |$h[4..6]; - }, $H, |^64; - }, - (BEGIN init(&sqrt)[^8]), - |blob32.new( - blob8.new( - @$data, - 0x80, - 0 xx (-($data + 1 + 8) mod 64), - (8*$data).polymod(256 xx 7).reverse - ).rotor(4) - .map: { :256[@$_] } - ).rotor(16) + |reduce -> $H, $block { + blob32.new: $H[] Z+ + reduce -> $h, $j { + my uint32 ($T1, $T2) = + $h[7] + Σ1($h[4]) + Ch(|$h[4..6]) + + (BEGIN init(* **(1/3))[^64])[$j] + + ( + (state buf32 $w .= new)[$j] = $j < 16 ?? $block[$j] !! + σ0($w[$j-15]) + $w[$j-7] + σ1($w[$j-2]) + $w[$j-16] + ), + Σ0($h[0]) + Maj(|$h[0..2]); + blob32.new: $T1 + $T2, |$h[0..2], $h[3] + $T1, |$h[4..6]; + }, $H, |^64; + }, + (BEGIN init(&sqrt)[^8]), + |blob32.new( + blob8.new( + @$data, + 0x80, + 0 xx (-($data + 1 + 8) mod 64), + (8*$data).polymod(256 xx 7).reverse + ).rotor(4) + .map: { :256[@$_] } + ).rotor(16) } diff --git a/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-1.duckdb b/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-1.duckdb new file mode 100644 index 0000000000..e11dc512bb --- /dev/null +++ b/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-1.duckdb @@ -0,0 +1,5 @@ +create or replace table african_capitals( + name varchar(100), population_in_millions decimal(6,2) ); + +insert into african_capitals + from read_json_auto('input.json'); diff --git a/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-2.duckdb b/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-2.duckdb new file mode 100644 index 0000000000..fdf42c3e27 --- /dev/null +++ b/Task/Search-a-list-of-records/DuckDB/search-a-list-of-records-2.duckdb @@ -0,0 +1,2 @@ +create or replace table african_capitals as + FROM read_json_auto('rc-search-a-list-of-records.json'); diff --git a/Task/Search-a-list-of-records/Icon/search-a-list-of-records.icon b/Task/Search-a-list-of-records/Icon/search-a-list-of-records.icon new file mode 100644 index 0000000000..e1c8db8712 --- /dev/null +++ b/Task/Search-a-list-of-records/Icon/search-a-list-of-records.icon @@ -0,0 +1,19 @@ +record City(name,population) + +procedure main() + citydata := [ + City( "Lagos", 21.0 ), + City( "Cairo", 15.2 ), + City( "Kinshasa-Brazzaville", 11.3 ), + City( "Greater Johannesburg", 7.55 ), + City( "Mogadishu", 5.85 ), + City( "Khartoum-Omdurman", 4.98 ), + City( "Dar Es Salaam", 4.7 ), + City( "Alexandria", 4.58 ), + City( "Abidjan", 4.4 ), + City( "Casablanca", 3.98 ) + ] + if i := 1 to *citydata & citydata[i].name == "Dar Es Salaam" then write(i-1) + if city := !citydata & city.population < 5.0 then write(city.name) + if city := !citydata & city.name[1] == "A" then write(city.population) +end diff --git a/Task/Self-numbers/Pluto/self-numbers.pluto b/Task/Self-numbers/Pluto/self-numbers.pluto new file mode 100644 index 0000000000..28a3c4c409 --- /dev/null +++ b/Task/Self-numbers/Pluto/self-numbers.pluto @@ -0,0 +1,83 @@ +local start_index, end_index, counter +local current_self +local output + +local function done_after_adding(interval, n) + -- Advance to the next self number in the sequence, append it to the output if required, indicate if finished. + for _ = 1, n do + current_self += interval + ++counter + if counter >= start_index then + output:insert(current_self) + end + if counter == end_index then return true end + end + return false +end + +local function self_numbers(index_range) + start_index = index_range[1] + end_index = index_range:back() + counter = 0 + current_self = -1 + output = {} + + -- Main process. Start with the single-digit odd numbers and first run. + if done_after_adding(2, 5) then return output end + if done_after_adding(11, 9) then return output end + + -- If necessary, fast forward to last self number before the lowest-order block containing first number required. + if counter < start_index then + -- The highest-order blocks whose ends this handles correctly contain 9,777,777,778 self numbers. + -- The difference between equivalently positioned numbers in these blocks is 100,000,000,001. + -- The figures for successively lower-order blocks have successively fewer 7s and 0s! + local index_diff = 9777777778 + local numeric_diff = 100000000001 + while index_diff >= 98 and counter != start_index do + if counter + index_diff < start_index then + counter += index_diff + current_self += numeric_diff + else + index_diff = (index_diff + 2) / 10 -- (..78->80->8) + numeric_diff = (numeric_diff + 9) /10 -- (..01->10->1) + end + end + end + + -- Sequencing loop, per lowest-order block. + while true do + -- Eight ten-number runs, each at a numeric interval of 2 from the end of the previous one. + for _ = 1, 8 do + if done_after_adding(2, 1) then return output end + if done_after_adding(11, 9) then return output end + end + -- Two shorter runs, the second at an interval inversely related to their length. + local shorter_run_length = 8 + local temp = current_self // 1000 + -- Work out a shorter run length based on the most significant digit change about to happen. + while temp % 10 == 9 do + shorter_run_length -= 1 + temp //= 10 + end + + local interval = 2 + for _ = 1, 2 do + if done_after_adding(interval, 1) then return output end + if done_after_adding(11, shorter_run_length) then return output end + interval += (9 - shorter_run_length) * 13 + end + end +end + +print("The first 50 self numbers are:\n") +for i, sn in self_numbers({1, 50}) do + io.write(string.format("%3d ", sn)) + if i % 10 == 0 then print() end +end +print() +for p = 8, 9 do + local n = math.round(10 ^ p) + local ord = string.formatint(n) + local sn = string.formatint(math.round(self_numbers({n})[1])) + print($"The {ord}th self number is {sn}") +end diff --git a/Task/Semordnilap/ArkScript/semordnilap.ark b/Task/Semordnilap/ArkScript/semordnilap.ark new file mode 100644 index 0000000000..abd55ead82 --- /dev/null +++ b/Task/Semordnilap/ArkScript/semordnilap.ark @@ -0,0 +1,14 @@ +(import std.IO) +(import std.String) +(import std.Dict) +(import std.List) + +(let words (string:split (io:readFile "tests/unittests/resources/RosettaSuite/res/unixdict.txt") "\n")) + +(let d (dict)) +(list:forEach words (fun (word) (dict:add d word true))) +(let keep (list:filter words (fun (word) + (and (< word (string:reverse word)) (not (nil? (dict:get d (string:reverse word)))))))) + +(print (len keep)) +(print (list:slice keep 0 5 1)) diff --git a/Task/Semordnilap/AutoHotkey/semordnilap.ahk b/Task/Semordnilap/AutoHotkey/semordnilap.ahk index c0cf75c659..049f361aa4 100644 --- a/Task/Semordnilap/AutoHotkey/semordnilap.ahk +++ b/Task/Semordnilap/AutoHotkey/semordnilap.ahk @@ -3,20 +3,20 @@ S := [], M := [] FileRead, dict, unixdict.txt Loop, Parse, dict, `n, `r`n { - r := Reverse(A_LoopField) - if (S[r]) - M.Insert(r " / " A_LoopField) - else - S[A_LoopField] := 1 + r := Reverse(A_LoopField) + if (S[r]) + M.Insert(r " / " A_LoopField) + else + S[A_LoopField] := 1 } Loop, 5 - Out .= "`t" M[A_Index] "`n" + Out .= "`t" M[A_Index] "`n" MsgBox, % "5 Examples:`n" Out "`nTotal Pairs:`n`t" M.MaxIndex() Reverse(s) { - Loop, Parse, s - r := A_LoopField . r - return r + Loop, Parse, s + r := A_LoopField . r + return r } diff --git a/Task/Semordnilap/EchoLisp/semordnilap.l b/Task/Semordnilap/EchoLisp/semordnilap.l index 3ef572acc5..c0aa633721 100644 --- a/Task/Semordnilap/EchoLisp/semordnilap.l +++ b/Task/Semordnilap/EchoLisp/semordnilap.l @@ -8,18 +8,18 @@ ;; check reverse r of w is a word ;; take only one pair : r < w (define (semordnilap? w) - (define r (list->string (reverse (string->list w)))) - (and (word? r) (stringstring (reverse (string->list w)))) + (and (word? r) (string (string-length a) (string-length b))) - + (define (task) ;; select unique words into the list 'mots' (define mots (make-set (words-select #:any null 999999))) (define semordnilap - (list-sort string-sort (for/list ((w mots)) - #:when (semordnilap? w) - w ))) + (list-sort string-sort (for/list ((w mots)) + #:when (semordnilap? w) + w ))) (writeln 'pairs '→ (length semordnilap)) (writeln 'longest '→ (take semordnilap 5))) diff --git a/Task/Semordnilap/Eiffel/semordnilap-1.e b/Task/Semordnilap/Eiffel/semordnilap-1.e index f53e49ea51..9bcdd4aed4 100644 --- a/Task/Semordnilap/Eiffel/semordnilap-1.e +++ b/Task/Semordnilap/Eiffel/semordnilap-1.e @@ -1,79 +1,79 @@ class - SEMORDNILAP + SEMORDNILAP create - make + make feature - make - --Semordnilaps in 'solution'. - local - count, i, middle, upper, lower: INTEGER - reverse: STRING - do - read_wordlist - create solution.make_empty - from - i := 1 - until - i > word_array.count - loop - word_array [i].mirror - reverse := word_array [i] - from - lower := i + 1 - upper := word_array.count - until - lower >= upper - loop - middle := (upper - lower) // 2 + lower - if reverse.same_string (word_array [middle]) then - count := count + 1 - upper := 0 - lower := 1 - solution.force (word_array [i], count) - elseif reverse.is_less (word_array [middle]) then - upper := middle - 1 - else - lower := middle + 1 - end - end - if lower < word_array.count and then reverse.same_string (word_array [lower]) then - count := count + 1 - upper := 0 - lower := 1 - solution.force (word_array [i], count) - end - i := i + 1 - end - end + make + --Semordnilaps in 'solution'. + local + count, i, middle, upper, lower: INTEGER + reverse: STRING + do + read_wordlist + create solution.make_empty + from + i := 1 + until + i > word_array.count + loop + word_array [i].mirror + reverse := word_array [i] + from + lower := i + 1 + upper := word_array.count + until + lower >= upper + loop + middle := (upper - lower) // 2 + lower + if reverse.same_string (word_array [middle]) then + count := count + 1 + upper := 0 + lower := 1 + solution.force (word_array [i], count) + elseif reverse.is_less (word_array [middle]) then + upper := middle - 1 + else + lower := middle + 1 + end + end + if lower < word_array.count and then reverse.same_string (word_array [lower]) then + count := count + 1 + upper := 0 + lower := 1 + solution.force (word_array [i], count) + end + i := i + 1 + end + end - solution: ARRAY [STRING] + solution: ARRAY [STRING] - original_list: STRING = "unixdict.txt" + original_list: STRING = "unixdict.txt" feature {NONE} - read_wordlist - -- Preprocessed word_array for finding Semordnilaps. - local - l_file: PLAIN_TEXT_FILE - wordlist: LIST [STRING] - do - create l_file.make_open_read_write (original_list) - l_file.read_stream (l_file.count) - wordlist := l_file.last_string.split ('%N') - l_file.close - create word_array.make_empty - across - 1 |..| wordlist.count as i - loop - word_array.force (wordlist.at (i.item), i.item) - end - end + read_wordlist + -- Preprocessed word_array for finding Semordnilaps. + local + l_file: PLAIN_TEXT_FILE + wordlist: LIST [STRING] + do + create l_file.make_open_read_write (original_list) + l_file.read_stream (l_file.count) + wordlist := l_file.last_string.split ('%N') + l_file.close + create word_array.make_empty + across + 1 |..| wordlist.count as i + loop + word_array.force (wordlist.at (i.item), i.item) + end + end - word_array: ARRAY [STRING] + word_array: ARRAY [STRING] end diff --git a/Task/Semordnilap/Eiffel/semordnilap-2.e b/Task/Semordnilap/Eiffel/semordnilap-2.e index 00b10484c5..0e9ec0ef20 100644 --- a/Task/Semordnilap/Eiffel/semordnilap-2.e +++ b/Task/Semordnilap/Eiffel/semordnilap-2.e @@ -1,34 +1,34 @@ class - APPLICATION + APPLICATION create - make + make feature - make - local - test: ARRAY [STRING] - s: STRING - do - create se.make - test := se.solution - create sort.sort (test) - across - test.subarray (1, 5) as t - loop - s := t.item - io.put_string (t.item + "%T") - s.mirror - io.put_string (s) - io.new_line - end - io.put_string ("Total number of semordnilaps: ") - io.put_integer (test.count) - end + make + local + test: ARRAY [STRING] + s: STRING + do + create se.make + test := se.solution + create sort.sort (test) + across + test.subarray (1, 5) as t + loop + s := t.item + io.put_string (t.item + "%T") + s.mirror + io.put_string (s) + io.new_line + end + io.put_string ("Total number of semordnilaps: ") + io.put_integer (test.count) + end - se: SEMORDNILAP + se: SEMORDNILAP - sort: MERGE_SORT [STRING] + sort: MERGE_SORT [STRING] end diff --git a/Task/Semordnilap/Forth/semordnilap.fth b/Task/Semordnilap/Forth/semordnilap.fth index 509d459659..148c009c56 100644 --- a/Task/Semordnilap/Forth/semordnilap.fth +++ b/Task/Semordnilap/Forth/semordnilap.fth @@ -3,30 +3,30 @@ wordlist constant dict : load-dict ( c-addr u -- ) r/o open-file throw >r begin - pad 1024 r@ read-line throw while - pad swap ['] create execute-parsing + pad 1024 r@ read-line throw while + pad swap ['] create execute-parsing repeat drop r> close-file throw ; : xreverse {: c-addr u -- c-addr2 u :} u allocate throw u + c-addr swap over u + >r begin ( from to r:end) - over r@ u< while - over r@ over - x-size dup >r - 2dup r@ cmove - swap r> + swap repeat + over r@ u< while + over r@ over - x-size dup >r - 2dup r@ cmove + swap r> + swap repeat r> drop nip u ; : .example ( c-addr u u1 -- ) 5 < if - cr 2dup type space 2dup xreverse 2dup type drop free throw then + cr 2dup type space 2dup xreverse 2dup type drop free throw then 2drop ; : nt-semicheck ( u1 nt -- u2 f ) dup >r name>string xreverse 2dup dict find-name-in dup if ( u1 c-addr u nt2) - r@ < if ( u1 c-addr u ) \ count pairs only once and not palindromes - 2dup 4 pick .example - rot 1+ -rot then + r@ < if ( u1 c-addr u ) \ count pairs only once and not palindromes + 2dup 4 pick .example + rot 1+ -rot then else - drop then + drop then drop free throw r> drop true ; get-current dict set-current s" unixdict.txt" load-dict set-current diff --git a/Task/Semordnilap/Julia/semordnilap.jl b/Task/Semordnilap/Julia/semordnilap.jl index c4b414f4b6..aa7873b755 100644 --- a/Task/Semordnilap/Julia/semordnilap.jl +++ b/Task/Semordnilap/Julia/semordnilap.jl @@ -1,4 +1,4 @@ -raw = readdlm("unixdict.txt",String)[:] +raw = readlines("unixdict.txt") inter = intersect(raw,map(reverse,raw)) #find the matching strings/revstrings res = String[b == 1 && a != reverse(a) && a < reverse(a) ? a : reverse(a) for a in inter, b in 1:2] #create pairs res = res[res[:,1] .!= res[:,2],:] #get rid of duplicates, palindromes diff --git a/Task/Semordnilap/Ksh/semordnilap.ksh b/Task/Semordnilap/Ksh/semordnilap.ksh index 2a1873fdb7..baf24ff7b8 100644 --- a/Task/Semordnilap/Ksh/semordnilap.ksh +++ b/Task/Semordnilap/Ksh/semordnilap.ksh @@ -2,7 +2,7 @@ # Semordnilap -# # Variables: +# # Variables: # integer MIN_WORD_LEN=1 TRUE=1 FALSE=0 dict='/home/ostrande/prj/roscode/unixdict.txt' @@ -10,62 +10,62 @@ dict='/home/ostrande/prj/roscode/unixdict.txt' integer i j=0 k=0 typeset -A word -# # Functions: +# # Functions: # -# # Function _flipit(string) - return flipped string +# # Function _flipit(string) - return flipped string # function _flipit { - typeset _buf ; _buf="$1" - typeset _tmp ; unset _tmp + typeset _buf ; _buf="$1" + typeset _tmp ; unset _tmp - for (( _i=$(( ${#_buf}-1 )); _i>=0; _i-- )); do - _tmp="${_tmp}${_buf:${_i}:1}" - done + for (( _i=$(( ${#_buf}-1 )); _i>=0; _i-- )); do + _tmp="${_tmp}${_buf:${_i}:1}" + done - echo "${_tmp}" + echo "${_tmp}" } -# # Function _isword(word, wordlist) - return 1 if word in wordlist +# # Function _isword(word, wordlist) - return 1 if word in wordlist # function _isword { - typeset _word ; _word="$1" - typeset _wordlist ; nameref _wordlist="$2" + typeset _word ; _word="$1" + typeset _wordlist ; nameref _wordlist="$2" - [[ ${_word} == @(${_wordlist}) ]] && return $TRUE - return $FALSE + [[ ${_word} == @(${_wordlist}) ]] && return $TRUE + return $FALSE } ###### # main # ###### -# # Due to the large number of words in unixdist.txt subgroup by 1st letter and length -# # only accept words containing alpha chars and > 1 chars +# # Due to the large number of words in unixdist.txt subgroup by 1st letter and length +# # only accept words containing alpha chars and > 1 chars # while read; do - [[ $REPLY != *+(\W)* ]] && [[ $REPLY != *+(\d)* ]] && \ - (( ${#REPLY} > MIN_WORD_LEN )) && word[${REPLY:0:1}][${#REPLY}]+=( $REPLY ) + [[ $REPLY != *+(\W)* ]] && [[ $REPLY != *+(\d)* ]] && \ + (( ${#REPLY} > MIN_WORD_LEN )) && word[${REPLY:0:1}][${#REPLY}]+=( $REPLY ) done < ${dict} print Examples: -for fl in ${!word[*]}; do # Over $fl first letter - for len in ${!word[${fl}][*]}; do # Over $len word length - for ((i=0; i<${#word[${fl}][${len}][*]}; i++)); do - Word=${word[${fl}][${len}][i]} # dummy - Try=$(_flipit ${Word}) - if [[ ${Try} != ${Word} ]]; then # no palindromes - unset words - oldIFS="$IFS" ; IFS='|' ; words=${word[${Try:0:1}][${#Try}][*]} ; IFS="${oldIFS}" - _isword "${Try}" words - if (( $? )); then - if [[ ${Try} != @(${uniq%\|*}) ]]; then - ((++j)) - (( ${#Word} >= 5 )) && (( k<=5 )) && print $((++k)). ${Word} ${Try} - uniq+="${Try}|${Word}|" - fi - fi - fi - done - done +for fl in ${!word[*]}; do # Over $fl first letter + for len in ${!word[${fl}][*]}; do # Over $len word length + for ((i=0; i<${#word[${fl}][${len}][*]}; i++)); do + Word=${word[${fl}][${len}][i]} # dummy + Try=$(_flipit ${Word}) + if [[ ${Try} != ${Word} ]]; then # no palindromes + unset words + oldIFS="$IFS" ; IFS='|' ; words=${word[${Try:0:1}][${#Try}][*]} ; IFS="${oldIFS}" + _isword "${Try}" words + if (( $? )); then + if [[ ${Try} != @(${uniq%\|*}) ]]; then + ((++j)) + (( ${#Word} >= 5 )) && (( k<=5 )) && print $((++k)). ${Word} ${Try} + uniq+="${Try}|${Word}|" + fi + fi + fi + done + done done echo ; print ${j} pairs found. diff --git a/Task/Semordnilap/Lasso/semordnilap.lasso b/Task/Semordnilap/Lasso/semordnilap.lasso index 2cd9770010..cd47131783 100644 --- a/Task/Semordnilap/Lasso/semordnilap.lasso +++ b/Task/Semordnilap/Lasso/semordnilap.lasso @@ -1,27 +1,27 @@ local( - words = string(include_url('http://www.puzzlers.org/pub/wordlists/unixdict.txt')) -> split('\n'), - semordnilaps = array, - found_size, - example, - haveexamples = false, - examples = array + words = string(include_url('http://www.puzzlers.org/pub/wordlists/unixdict.txt')) -> split('\n'), + semordnilaps = array, + found_size, + example, + haveexamples = false, + examples = array ) #words -> removeall('') with word in #words do { - local(reversed = string(#word) -> reverse&) - if(not(#word == #reversed) and not(#semordnilaps >> #word) and not(#semordnilaps >> #reversed) and #words >> #reversed) => { - #semordnilaps -> insert(#word = #reversed) - } + local(reversed = string(#word) -> reverse&) + if(not(#word == #reversed) and not(#semordnilaps >> #word) and not(#semordnilaps >> #reversed) and #words >> #reversed) => { + #semordnilaps -> insert(#word = #reversed) + } } #found_size = #semordnilaps -> size while(not(#haveexamples)) => { - #example = #semordnilaps -> get(integer_random(#found_size, 1)) - not(#examples >> #example -> name) ? #examples -> insert(#example) - #examples -> size >= 5 ? #haveexamples = true + #example = #semordnilaps -> get(integer_random(#found_size, 1)) + not(#examples >> #example -> name) ? #examples -> insert(#example) + #examples -> size >= 5 ? #haveexamples = true } 'Total found: ' #found_size diff --git a/Task/Semordnilap/Lua/semordnilap.lua b/Task/Semordnilap/Lua/semordnilap.lua index d67015ca14..3bff64e789 100644 --- a/Task/Semordnilap/Lua/semordnilap.lua +++ b/Task/Semordnilap/Lua/semordnilap.lua @@ -22,13 +22,18 @@ end -- print the report print("There are " .. #semordnilaps .. " semordnilaps in " .. dictfile .. ". Here are " .. sample_size .. ":") -math.randomseed( os.time() ) -for i = 1, sample_size do - local j - repeat - j = math.random(1,#semordnilaps) - until semordnilaps[j] - local f, r = unpack(semordnilaps[j]) - semordnilaps[j] = nil - print(f .. " -> " .. r) +do + -- unpack is in table in Lua 5.4 + local unpack = table.unpack or unpack + + math.randomseed( os.time() ) + for i = 1, sample_size do + local j + repeat + j = math.random(1,#semordnilaps) + until semordnilaps[j] + local f, r = unpack(semordnilaps[j]) + semordnilaps[j] = nil + print(f .. " -> " .. r) + end end diff --git a/Task/Semordnilap/NewLISP/semordnilap.l b/Task/Semordnilap/NewLISP/semordnilap.l index b3f0078923..5debafbeb6 100644 --- a/Task/Semordnilap/NewLISP/semordnilap.l +++ b/Task/Semordnilap/NewLISP/semordnilap.l @@ -1,26 +1,26 @@ -;;; Get the words as a list, splitting at newline +;;; Get the words as a list, splitting at newline (setq data - (parse (get-url "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") - "\n")) + (parse (get-url "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") + "\n")) ; -;;; destructive reverse wrapped into a function +;;; destructive reverse wrapped into a function (define (get-reverse x) (reverse x)) ; -;;; stack of the results +;;; stack of the results (setq res '()) ; -;;; Find the semordlinap and put them on the stack +;;; Find the semordlinap and put them on the stack (dolist (x data) - (let (y (get-reverse x)) - (if (and - (member y data) ; reverse is a dictionary word - (!= x y) ; but not a palindrome - (not (member y res))) ; not already stacked - (push x res -1)))) + (let (y (get-reverse x)) + (if (and + (member y data) ; reverse is a dictionary word + (!= x y) ; but not a palindrome + (not (member y res))) ; not already stacked + (push x res -1)))) ; -;;; Count results +;;; Count results (println "Found " (length res) " pairs.") (println) -;;; Show the longest ones +;;; Show the longest ones (dolist (x res) - (if (> (length x) 4) (println x " -- " (get-reverse x)))) + (if (> (length x) 4) (println x " -- " (get-reverse x)))) diff --git a/Task/Semordnilap/Perl/semordnilap.pl b/Task/Semordnilap/Perl/semordnilap.pl index 1236f1bbb9..05431dbcee 100644 --- a/Task/Semordnilap/Perl/semordnilap.pl +++ b/Task/Semordnilap/Perl/semordnilap.pl @@ -1,7 +1,7 @@ while (<>) { - chomp; - my $r = reverse; - $seen{$r}++ and $c++ < 5 and print "$_ $r\n" or $seen{$_}++; + chomp; + my $r = reverse; + $seen{$r}++ and $c++ < 5 and print "$_ $r\n" or $seen{$_}++; } print "$c\n" diff --git a/Task/Semordnilap/Phixmonti/semordnilap.phixmonti b/Task/Semordnilap/Phixmonti/semordnilap.phixmonti index e97a46a2b3..560c1f466f 100644 --- a/Task/Semordnilap/Phixmonti/semordnilap.phixmonti +++ b/Task/Semordnilap/Phixmonti/semordnilap.phixmonti @@ -5,30 +5,30 @@ include ..\Utilitys.pmt "unixdict.txt" "r" fopen var f true while - f fgets - dup -1 == if - drop - f fclose - false - else - -1 del - 0 put - true - endif + f fgets + dup -1 == if + drop + f fclose + false + else + -1 del + 0 put + true + endif endwhile len while - len 1 > if - pop swap reverse find dup - if - extract rot swap 0 put swap - else - drop - endif - true - else - drop false - endif + len 1 > if + pop swap reverse find dup + if + extract rot swap 0 put swap + else + drop + endif + true + else + drop false + endif endwhile ( 50 54 ) for get dup reverse print " -> " print ? endfor nl diff --git a/Task/Semordnilap/Pluto/semordnilap.pluto b/Task/Semordnilap/Pluto/semordnilap.pluto new file mode 100644 index 0000000000..7032043314 --- /dev/null +++ b/Task/Semordnilap/Pluto/semordnilap.pluto @@ -0,0 +1,21 @@ +local file = io.open("unixdict.txt", "r") +local wmap = {} +for word in file:lines() do wmap[word] = true end +local pairs = {} +local used = {} +file:seek("set") +for word in file:lines() do + if word != "" then + local pal = string.reverse(word) + if word != pal and wmap[pal] and !used[pal] then + pairs:insert({word, pal}) + used[word] = true + end + end +end +file:close() +print($"There are {#pairs} unique semordnilap pairs in the dictionary.") +print("\nIn sorted order, the first five are:") +for i = 1, 5 do print($" {pairs[i][1]}, {pairs[i][2]}") end +print("\nand the last five are:") +for i = #pairs - 4, #pairs do print($" {pairs[i][1]}, {pairs[i][2]}") end diff --git a/Task/Semordnilap/Prolog/semordnilap.pro b/Task/Semordnilap/Prolog/semordnilap.pro new file mode 100644 index 0000000000..03f05e2dc1 --- /dev/null +++ b/Task/Semordnilap/Prolog/semordnilap.pro @@ -0,0 +1,28 @@ +:- initialization(main, main). +:- use_module(library(apply)). +:- use_module(library(dcg/basics)). +:- use_module(library(dcg/high_order)). +:- use_module(library(ordsets)). + +load(Filename, Words) :- once(phrase_from_file(sequence(word, Words), Filename)). +word(Word) --> nonblanks(Word), eol, { Word \= [] }. + +find_all_semordnilaps(Words, Semordnilaps) :- + convlist([Word, Reversed] >> ( + reverse(Word, Reversed), + Reversed @< Word + ), Words, ReversedWords0), + sort(ReversedWords0, ReversedWords), + ord_intersection(Words, ReversedWords, Semordnilaps). + +main([Filename]) :- + load(Filename, Words), + find_all_semordnilaps(Words, Semordnilaps), + length(Semordnilaps, Count), + format("~d~n", Count), + length(FirstFive, 5), + prefix(FirstFive, Semordnilaps), + maplist([Word] >> ( + reverse(Word, Reversed), + format("~s / ~s~n", [Word, Reversed]) + ), FirstFive). diff --git a/Task/Semordnilap/Python/semordnilap-1.py b/Task/Semordnilap/Python/semordnilap-1.py index 0e1fa9ed3c..6acbb2e6d9 100644 --- a/Task/Semordnilap/Python/semordnilap-1.py +++ b/Task/Semordnilap/Python/semordnilap-1.py @@ -1,5 +1,5 @@ >>> with open('unixdict.txt') as f: - wordset = set(f.read().strip().split()) + wordset = set(f.read().strip().split()) >>> revlist = (''.join(word[::-1]) for word in wordset) >>> pairs = set((word, rev) for word, rev in zip(wordset, revlist) diff --git a/Task/Semordnilap/R/semordnilap.r b/Task/Semordnilap/R/semordnilap.r index e0cd0022e9..425f6d70bc 100644 --- a/Task/Semordnilap/R/semordnilap.r +++ b/Task/Semordnilap/R/semordnilap.r @@ -1,6 +1,6 @@ library(stringi) -unixdict <- read.table("unixdict.txt", col.names="forwards") +unixdict <- read.table("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", col.names="forwards") unixdict$backwards <- stri_reverse(unixdict$forwards) #Remove all actual palindromes, as we do not want those diff --git a/Task/Semordnilap/REBOL/semordnilap-1.rebol b/Task/Semordnilap/REBOL/semordnilap-1.rebol new file mode 100644 index 0000000000..b1dd74d3c1 --- /dev/null +++ b/Task/Semordnilap/REBOL/semordnilap-1.rebol @@ -0,0 +1,26 @@ +Rebol [ + title: "Rosetta code: Semordnilap" + file: %Semordnilap.r + url: https://rosettacode.org/wiki/Semordnilap + needs: 2.7.0 +] + +words: read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt +seen: make hash! 200 +count: 0 + +print ["Number of input words: " length? words LF] + +foreach word words [ + reversed: reverse copy word + either find seen reversed [ + count: count + 1 + if count <= 5 [ + print [word "is reversed:" reversed] + ] + ][ + append seen word + ] +] + +print [LF "Found total" count "pairs."] diff --git a/Task/Semordnilap/REBOL/semordnilap-2.rebol b/Task/Semordnilap/REBOL/semordnilap-2.rebol new file mode 100644 index 0000000000..026971ea27 --- /dev/null +++ b/Task/Semordnilap/REBOL/semordnilap-2.rebol @@ -0,0 +1,25 @@ +Rebol [ + title: "Rosetta code: Semordnilap" + file: %Semordnilap.r3 + url: https://rosettacode.org/wiki/Semordnilap + needs: 3.14.0 +] + +words: read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt +seen: make map! 200 +count: 0 + +print ["Number of input words: " length? words LF] + +foreach word words [ + reversed: reverse copy word + either find seen reversed [ + if ++ count <= 5 [ + print [word "is reversed:" reversed] + ] + ][ + put seen word reversed + ] +] + +print [LF "Found total" count "pairs."] diff --git a/Task/Semordnilap/SNOBOL4/semordnilap.sno b/Task/Semordnilap/SNOBOL4/semordnilap.sno index 795ca4e677..ffa5b12f6a 100644 --- a/Task/Semordnilap/SNOBOL4/semordnilap.sno +++ b/Task/Semordnilap/SNOBOL4/semordnilap.sno @@ -7,28 +7,28 @@ * Reads file unixdict.txt * Comment: Tested using the Spitbol for Linux version of SNOBOL4 - output = "Some Semordnilap Pairs from File unixdict.txt" - atable = table(25200,,-1) - ntable = table(25200,,-2) + output = "Some Semordnilap Pairs from File unixdict.txt" + atable = table(25200,,-1) + ntable = table(25200,,-2) * Read dictionary file into memory in1 - word = input :f(p1) - count = count + 1 - atable[word] = word - ntable[count] = word - :(in1) + word = input :f(p1) + count = count + 1 + atable[word] = word + ntable[count] = word + :(in1) * Process dictionary to find unique semordnilaps p1 - i = lt(i,count) i + 1 :f(p2) - newword = atable[reverse(ntable[i])] - leq(newword,-1) :s(p1) - ident(ntable[i],newword) :s(p1) - output = lt(outcount,5) ntable[i] ', ' newword - atable[ntable[i]] = atable[newword] = -1 - outcount = outcount + 1 - :(p1) + i = lt(i,count) i + 1 :f(p2) + newword = atable[reverse(ntable[i])] + leq(newword,-1) :s(p1) + ident(ntable[i],newword) :s(p1) + output = lt(outcount,5) ntable[i] ', ' newword + atable[ntable[i]] = atable[newword] = -1 + outcount = outcount + 1 + :(p1) p2 - output = 'The number of semordnilap pairs is: ' outcount + output = 'The number of semordnilap pairs is: ' outcount END diff --git a/Task/Semordnilap/TAV/semordnilap.tav b/Task/Semordnilap/TAV/semordnilap.tav new file mode 100644 index 0000000000..7b26db7ad4 --- /dev/null +++ b/Task/Semordnilap/TAV/semordnilap.tav @@ -0,0 +1,22 @@ +main(params):+ + seen =: new map + inwrds =: 0 + pairs =: 0 + palindromes =: 0 + ?# line =: file 'unixdict.txt' give lines + inwrds =+ 1 + wrd =: string line case to lower + rwrd =: string wrd from -1 length wrd.Count step -1 + ? wrd = rwrd + palindromes =+ 1 + ?^ + ? seen{rwrd} = () + seen{wrd} =: line \ not yet seen, remember + | + pairs =+ 1 + ? pairs < 7 + print wrd __ rwrd + + print pairs, "pairs, " nonl + print palindromes, "palindromes, " nonl + print inwrds, "input words." diff --git a/Task/Semordnilap/Tcl/semordnilap.tcl b/Task/Semordnilap/Tcl/semordnilap.tcl index 9fea9f4850..79c9bd49bc 100644 --- a/Task/Semordnilap/Tcl/semordnilap.tcl +++ b/Task/Semordnilap/Tcl/semordnilap.tcl @@ -14,10 +14,10 @@ foreach word $wordlist { # Find where a reversal exists foreach word $wordlist { if {[info exists reversed($word)] && $word ne [string reverse $word]} { - # Remove to prevent pairs from being printed twice - unset reversed([string reverse $word]) - # Add to collection of pairs - set pairs($word/[string reverse $word]) "dummy" + # Remove to prevent pairs from being printed twice + unset reversed([string reverse $word]) + # Add to collection of pairs + set pairs($word/[string reverse $word]) "dummy" } } set pairlist [array names pairs] ;# NB: pairs are in *arbitrary* order diff --git a/Task/Semordnilap/VBScript/semordnilap.vb b/Task/Semordnilap/VBScript/semordnilap.vb index f56f78ccdf..83c8f216a2 100644 --- a/Task/Semordnilap/VBScript/semordnilap.vb +++ b/Task/Semordnilap/VBScript/semordnilap.vb @@ -1,30 +1,30 @@ Set objFSO = CreateObject("Scripting.FileSystemObject") Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ - "\unixdict.txt",1) + "\unixdict.txt",1) Set objUnixDict = CreateObject("Scripting.Dictionary") Set objSemordnilap = CreateObject("Scripting.Dictionary") Do Until objInFile.AtEndOfStream - line = objInFile.ReadLine - If Len(line) > 1 Then - objUnixDict.Add line,"" - End If - reverse_line = StrReverse(line) - If reverse_line <> line And objUnixDict.Exists(reverse_line) Then - objSemordnilap.Add line, reverse_line - End If -Loop + line = objInFile.ReadLine + If Len(line) > 1 Then + objUnixDict.Add line,"" + End If + reverse_line = StrReverse(line) + If reverse_line <> line And objUnixDict.Exists(reverse_line) Then + objSemordnilap.Add line, reverse_line + End If +Loop 'Display the first 5 keys. k = 0 For Each Key In objSemordnilap.Keys - WScript.StdOut.Write Key & " - " & objSemordnilap.Item(Key) - WScript.StdOut.WriteLine - k = k + 1 - If k = 5 Then - Exit For - End If + WScript.StdOut.Write Key & " - " & objSemordnilap.Item(Key) + WScript.StdOut.WriteLine + k = k + 1 + If k = 5 Then + Exit For + End If Next WScript.StdOut.Write "Total Count: " & objSemordnilap.Count diff --git a/Task/Sequence-of-primes-by-trial-division/Agena/sequence-of-primes-by-trial-division.agena b/Task/Sequence-of-primes-by-trial-division/Agena/sequence-of-primes-by-trial-division.agena new file mode 100644 index 0000000000..01a42e41f5 --- /dev/null +++ b/Task/Sequence-of-primes-by-trial-division/Agena/sequence-of-primes-by-trial-division.agena @@ -0,0 +1,35 @@ +scope # get sequences of primes using trial division + + # returns true if n is prime, false otherwise + local constant is_prime := proc( n :: number ) :: boolean + local result := n = 2 or ( odd n and n > 1 ); + for k from 3 to entier sqrt( n ) by 2 while result do + result := n mod k <> 0 + od; + return result + end; + + # returns the sequence of primes between p_start and p_end + local constant prime_sequence := proc( p_start :: number, p_end :: number ) :: sequence + local constant result := seq(); + for p from p_start to p_end do + if is_prime( p ) then result[ size result + 1 ] := p fi; + od; + return result + end; + + # test prime_sequence + local test_sequence, p_count; + test_sequence, p_count := prime_sequence( -9, 150 ), 0; + for p from 1 to size test_sequence do + printf( " %3d", test_sequence[ p ] ); + p_count +:= 1; if p_count mod 20 = 0 then print() fi + od; + print( " ..." ); + test_sequence, p_count := prime_sequence( 410, 550 ), 0; + for p from 1 to size test_sequence do + printf( " %3d", test_sequence[ p ] ); + p_count +:= 1; if p_count mod 20 = 0 then print() fi + od + +end diff --git a/Task/Sequence-of-primes-by-trial-division/Pluto/sequence-of-primes-by-trial-division.pluto b/Task/Sequence-of-primes-by-trial-division/Pluto/sequence-of-primes-by-trial-division.pluto new file mode 100644 index 0000000000..2184ebfaa7 --- /dev/null +++ b/Task/Sequence-of-primes-by-trial-division/Pluto/sequence-of-primes-by-trial-division.pluto @@ -0,0 +1,29 @@ +do -- get sequences of primes using trial division + + local fmt = require( "fmt" ) -- RC formatting module + + -- returns true if n is prime, false otherwise + local function isPrime( n : number ) : boolean + local result : boolean = n == 2 or ( n % 2 == 1 and n > 1 ) + for k = 3, math.floor( math.sqrt( n ) ), 2 do + if not result then break end + result = n % k != 0 + end + return result + end + + -- returns the sequence of primes between pStart and pEnd + local function primeSequence( pStart : number, pEnd : number ) : table + local result : table = {} + for p = pStart, pEnd do + if isPrime( p ) then result:insert( p ) end + end + return result + end + + -- test primeSequence + fmt.tprint( " %3d", primeSequence( -9, 174 ), 20, "", "" ) + print( " ..." ) + fmt.tprint( " %3d", primeSequence( 410, 550 ), 20, "", "" ) + +end diff --git a/Task/Sequence-of-primes-by-trial-division/REXX/sequence-of-primes-by-trial-division.rexx b/Task/Sequence-of-primes-by-trial-division/REXX/sequence-of-primes-by-trial-division.rexx index 0e8372a795..bf6619e4ec 100644 --- a/Task/Sequence-of-primes-by-trial-division/REXX/sequence-of-primes-by-trial-division.rexx +++ b/Task/Sequence-of-primes-by-trial-division/REXX/sequence-of-primes-by-trial-division.rexx @@ -1,4 +1,4 @@ --- 12 Apr 2025 +-- 28 Jul 2025 include Settings numeric digits 30 @@ -71,8 +71,4 @@ do i = 3 by 2 to Isqrt(xx) end return 1 -include Sequences -include Numbers -include Functions -include Constants -include Abend +include Math diff --git a/Task/Sequence-of-primorial-primes/REXX/sequence-of-primorial-primes.rexx b/Task/Sequence-of-primorial-primes/REXX/sequence-of-primorial-primes.rexx index d702668cb5..99f85cdbc1 100644 --- a/Task/Sequence-of-primorial-primes/REXX/sequence-of-primorial-primes.rexx +++ b/Task/Sequence-of-primorial-primes/REXX/sequence-of-primorial-primes.rexx @@ -1,7 +1,6 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings -call Time('r') say 'SEQUENCE OF PRIMORIAL PRIMES' say version say @@ -11,7 +10,7 @@ say Format(Time('e'),,3) 'seconds' exit GetPrimorials: -procedure expose prim. prmo. glob. +procedure expose prim. prmo. Memo. arg xx say 'Get enough primorials...' call Primorials(-xx) @@ -20,7 +19,7 @@ say return ShowPrimes: -procedure expose prmo. glob. +procedure expose prmo. Memo. arg xx say 'Index of first 15 primorial primes is...' n = 0 @@ -42,9 +41,4 @@ say n 'Miller-Rabin primality tests performed' say return -include Sequences -include Numbers -include Functions -include Special -include Constants -include Abend +include Math diff --git a/Task/Set-consolidation/DuckDB/set-consolidation-1.duckdb b/Task/Set-consolidation/DuckDB/set-consolidation-1.duckdb new file mode 100644 index 0000000000..bd087e9c78 --- /dev/null +++ b/Task/Set-consolidation/DuckDB/set-consolidation-1.duckdb @@ -0,0 +1 @@ +create type set as VARCHAR[]; diff --git a/Task/Set-consolidation/DuckDB/set-consolidation-2.duckdb b/Task/Set-consolidation/DuckDB/set-consolidation-2.duckdb new file mode 100644 index 0000000000..c5198f03a2 --- /dev/null +++ b/Task/Set-consolidation/DuckDB/set-consolidation-2.duckdb @@ -0,0 +1,17 @@ +create or replace function to_set(lst) as ( + list_sort(list_distinct(lst)) +); + +create or replace function list_update(lst, i, value) as ( + lst[1:i-1] || [value] || lst[i+1:] +); + +# This will work even if set1 and set2 are just lists +create or replace function set_intersection(set1, set2) as ( + list_sort(list_intersect(set1, set2)) +); + +# This will work even if set1 and set2 are just lists +create or replace function set_union(set1, set2) as ( + to_set( ( set1 || set2 ) ) +); diff --git a/Task/Set-consolidation/DuckDB/set-consolidation-3.duckdb b/Task/Set-consolidation/DuckDB/set-consolidation-3.duckdb new file mode 100644 index 0000000000..3761646cab --- /dev/null +++ b/Task/Set-consolidation/DuckDB/set-consolidation-3.duckdb @@ -0,0 +1,61 @@ +# If listofsets[j] can be merged with listofsets[i] +# then set the former to [] and the latter to the merger +create or replace function merge(listofsets, i, j) as ( + if (i=j, + listofsets, + case when list_has_any(listofsets[i]::set, listofsets[j]::set) -- casts needed here + then list_update( + list_update(listofsets, + i, + set_union(listofsets[i], listofsets[j])), + j, + []) + else listofsets + end) +); + +create or replace function merge_i(listofsets, i) as table ( + with recursive cte(j,s) as ( + select 1, listofsets::SET[] -- advisable!! + union all + select j+1, merge(s, i, j) + from cte + where j <= length(listofsets) + ) + select last(s order by j) as s from cte +); + +# Compute the consolidation as a set +# Note: as of DuckDB V1.1, the CTE here must be given a different name from the one in merge_i +create or replace function consolidation(listofsets) as ( + with recursive cte1(i,s) as ( + select 1, listofsets::SET[] + union all + select i+1, (from merge_i(s, i) limit 1) as s + from cte1 + where i <= length(listofsets) + ) + select to_set( + list_transform( + list_filter(last(s order by i), x -> length(x)>0), + x -> to_set(x))) as consolidation from cte1 +); + +# Verify that the consolidation of x is equal to to_set(y), +# so be sure that each of the elements of y is in fact a set. +create or replace function verify(x,y) as ( + select consolidation(x) = to_set(y) +); + +.print Example 1: +select verify( [ ['A','B'], ['C','D']], [ ['A','B'], ['C','D']] ) as "Example 1"; + +.print Example 2: +select verify( [ ['A','B'], ['B','D'] ], [['A', 'B','D']]) as "Example 2"; + +.print Example 3: +select verify( [['A','B'], ['C','D'], ['D','B']], [['A','B','C','D']]) as "Example 3"; + +.print Example 4: +select verify( [['H','I','K'], ['A','B'], ['C','D'], ['D','B'], ['F','G','H'] ], + [['A', 'B', 'C', 'D'], ['F', 'G', 'H', 'I', 'K']] ) as "Example 4"; diff --git a/Task/Set-consolidation/Pluto/set-consolidation.pluto b/Task/Set-consolidation/Pluto/set-consolidation.pluto new file mode 100644 index 0000000000..be665b398f --- /dev/null +++ b/Task/Set-consolidation/Pluto/set-consolidation.pluto @@ -0,0 +1,38 @@ +require "map" +require "table2" +local fmt = require "fmt" + +local function consolidate_sets(sets) + local size = #sets + local consolidated = table.rep(size, false) + for i = 1, size - 1 do + if !consolidated[i] then + repeat + local intersects = 0 + for j = i + 1, size do + if !consolidated[j] then + if !sets[i]:intersect(sets[j]):empty() then + sets[i]:merge(sets[j]) + consolidated[j] = true + ++intersects + end + end + end + until intersects == 0 + end + end + return range(1, size):filter(|i| -> !consolidated[i]):reorder():map(|i| -> sets[i]) +end + +local unconsolidated_sets = { + {set.of("A", "B"), set.of("C", "D")}, + {set.of("A", "B"), set.of("B", "D")}, + {set.of("A", "B"), set.of("C", "D"), set.of("D", "B")}, + {set.of("H", "I", "K"), set.of("A", "B"), set.of("C", "D"), + set.of("D", "B"), set.of("F", "G", "H")} +} +for unconsolidated_sets as sets do + fmt.print("Unconsolidated: %s", fmt.swrite(sets)) + fmt.print("Consolidated : %s", fmt.swrite(consolidate_sets(sets))) + print() +end diff --git a/Task/Set-consolidation/Wren/set-consolidation.wren b/Task/Set-consolidation/Wren/set-consolidation.wren index f5125e2bc8..bb9190b133 100644 --- a/Task/Set-consolidation/Wren/set-consolidation.wren +++ b/Task/Set-consolidation/Wren/set-consolidation.wren @@ -34,5 +34,5 @@ var unconsolidatedSets = [ ] for (sets in unconsolidatedSets) { System.print("Unconsolidated: %(sets)") - System.print("Cosolidated : %(consolidateSets.call(sets))\n") + System.print("Consolidated : %(consolidateSets.call(sets))\n") } diff --git a/Task/Set/DuckDB/set-1.duckdb b/Task/Set/DuckDB/set-1.duckdb new file mode 100644 index 0000000000..a0c39ee2d9 --- /dev/null +++ b/Task/Set/DuckDB/set-1.duckdb @@ -0,0 +1,5 @@ +create or replace table s (id INTEGER UNIQUE NOT NULL); +create or replace table t (id INTEGER UNIQUE NOT NULL); + +insert into s from generate_series(1,10); +insert into t from generate_series(5,15); diff --git a/Task/Set/DuckDB/set-2.duckdb b/Task/Set/DuckDB/set-2.duckdb new file mode 100644 index 0000000000..fc1c23c607 --- /dev/null +++ b/Task/Set/DuckDB/set-2.duckdb @@ -0,0 +1 @@ +from s union from t; diff --git a/Task/Set/DuckDB/set-3.duckdb b/Task/Set/DuckDB/set-3.duckdb new file mode 100644 index 0000000000..e520ef4afc --- /dev/null +++ b/Task/Set/DuckDB/set-3.duckdb @@ -0,0 +1 @@ +from s INTERSECT from t; diff --git a/Task/Set/DuckDB/set-4.duckdb b/Task/Set/DuckDB/set-4.duckdb new file mode 100644 index 0000000000..3684447a62 --- /dev/null +++ b/Task/Set/DuckDB/set-4.duckdb @@ -0,0 +1 @@ +select count() as n from (from s INTERSECT from t); diff --git a/Task/Set/DuckDB/set-5.duckdb b/Task/Set/DuckDB/set-5.duckdb new file mode 100644 index 0000000000..61893f127c --- /dev/null +++ b/Task/Set/DuckDB/set-5.duckdb @@ -0,0 +1 @@ +from s EXCEPT from t; diff --git a/Task/Set/DuckDB/set-6.duckdb b/Task/Set/DuckDB/set-6.duckdb new file mode 100644 index 0000000000..d79bd0f24d --- /dev/null +++ b/Task/Set/DuckDB/set-6.duckdb @@ -0,0 +1,2 @@ +select count() from + ( (from s EXCEPT from t) UNION (from t EXCEPT from s)); diff --git a/Task/Set/DuckDB/set-7.duckdb b/Task/Set/DuckDB/set-7.duckdb new file mode 100644 index 0000000000..dc01c7332a --- /dev/null +++ b/Task/Set/DuckDB/set-7.duckdb @@ -0,0 +1,2 @@ +select (EXISTS (from s where NOT EXISTS (from t where s.id=t.id))) or + (EXISTS (from t where NOT EXISTS (from s where s.id=t.id)) ); diff --git a/Task/Set/DuckDB/set-8.duckdb b/Task/Set/DuckDB/set-8.duckdb new file mode 100644 index 0000000000..ab49eb533d --- /dev/null +++ b/Task/Set/DuckDB/set-8.duckdb @@ -0,0 +1,2 @@ +select NOT EXISTS + (from s where NOT EXISTS (from t where s.id = t.id)); diff --git a/Task/Set/DuckDB/set-9.duckdb b/Task/Set/DuckDB/set-9.duckdb new file mode 100644 index 0000000000..cc3b678d11 --- /dev/null +++ b/Task/Set/DuckDB/set-9.duckdb @@ -0,0 +1 @@ +select NOT EXISTS (from s EXCEPT from t); diff --git a/Task/Set/Pluto/set.pluto b/Task/Set/Pluto/set.pluto new file mode 100644 index 0000000000..6c2563fb62 --- /dev/null +++ b/Task/Set/Pluto/set.pluto @@ -0,0 +1,46 @@ +require "map" +local fmt = require "fmt" + +local fruits = new set() +fruits:add("apple", "pear", "orange", "banana") +fmt.print("fruits : %s", fruits) +local fruits2 = new set() +fruits2:add("melon", "orange", "lemon", "gooseberry") +fmt.print("fruits2 : %s", fruits2) +print() +fmt.print("fruits contains 'banana' : %s", fruits:contains("banana")) +fmt.print("fruits2 contains 'elderberry' : %s", fruits2:contains("elderberry")) +print() + +fmt.print("Union : %s", fruits:union(fruits2)) +fmt.print("Intersection : %s", fruits:intersect(fruits2)) +fmt.print("Difference : %s", fruits:except(fruits2)) +print() + +fmt.print("fruits2 is a subset of fruits : %s", fruits2:subset(fruits)) +print() + +local fruits3 = fruits:copy() +fmt.print("fruits3 : %s", fruits3) +print() + +fmt.print("fruits2 and fruits are equal : %s", fruits2:same(fruits)) +fmt.print("fruits3 and fruits are equal : %s", fruits3:same(fruits)) +print() + +local fruits4 = new set() +fruits4:add("apple", "orange") +fmt.print("fruits4 : %s", fruits4) +print() +fmt.print("fruits3 is a proper subset of fruits : %s", fruits3:subset(fruits, true)) +fmt.print("fruits4 is a proper subset of fruits : %s", fruits4:subset(fruits, true)) +print() + +local fruits5 = new set() +fruits5:add("cherry", "blueberry", "raspberry") +fmt.print("fruits5 : %s", fruits5) +print() +fruits5:add("guava") +fmt.print("fruits5 + 'guava' : %s", fruits5) +fruits5:remove("cherry") +fmt.print("fruits5 - 'cherry' : %s", fruits5) diff --git a/Task/Shell-one-liner/ArkScript/shell-one-liner.ark b/Task/Shell-one-liner/ArkScript/shell-one-liner.ark new file mode 100644 index 0000000000..cea479c91c --- /dev/null +++ b/Task/Shell-one-liner/ArkScript/shell-one-liner.ark @@ -0,0 +1 @@ +$ arkscript -e '(print "hello world")' diff --git a/Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area.jl b/Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-1.jl similarity index 100% rename from Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area.jl rename to Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-1.jl diff --git a/Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-2.jl b/Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-2.jl new file mode 100644 index 0000000000..a4e5cdf49f --- /dev/null +++ b/Task/Shoelace-formula-for-polygonal-area/Julia/shoelace-formula-for-polygonal-area-2.jl @@ -0,0 +1,10 @@ +function shoelacearea2(x, y) + n = length(x) + abs(sum(x[mod1(i-1, n)] * y[i] - x[i] * y[mod1(i-1, n)] for i in 1:n)) / 2 +end + +x, y = [3, 5, 12, 9, 5], [4, 11, 8, 5, 6] + +using BenchmarkTools +@btime shoelacearea(x, y) +@btime shoelacearea2(x, y) diff --git a/Task/Shoelace-formula-for-polygonal-area/R/shoelace-formula-for-polygonal-area.r b/Task/Shoelace-formula-for-polygonal-area/R/shoelace-formula-for-polygonal-area.r new file mode 100644 index 0000000000..b924e4fa3b --- /dev/null +++ b/Task/Shoelace-formula-for-polygonal-area/R/shoelace-formula-for-polygonal-area.r @@ -0,0 +1,10 @@ +shoelace <- function(...){ + coords_list <- list(...) + xcoords <- sapply(coords_list, function(v) v[1]) + ycoords <- sapply(coords_list, function(v) v[2]) + lsum <- sum(xcoords*c(ycoords[-1], ycoords[1])) + rsum <- sum(ycoords*c(xcoords[-1], xcoords[1])) + abs(lsum-rsum)/2 +} + +shoelace(c(3,4), c(5,11), c(12,8), c(9,5), c(5,6)) diff --git a/Task/Short-circuit-evaluation/ArkScript/short-circuit-evaluation.ark b/Task/Short-circuit-evaluation/ArkScript/short-circuit-evaluation.ark new file mode 100644 index 0000000000..904db6e8a5 --- /dev/null +++ b/Task/Short-circuit-evaluation/ArkScript/short-circuit-evaluation.ark @@ -0,0 +1,17 @@ +(let a (fun (v) { + (print "a(" v ")") + v })) + +(let b (fun (v) { + (print "b(" v ")") + v })) + +(print "---") (and (a true) (b true)) +(print "---") (and (a false) (b true)) +(print "---") (and (a true) (b false)) +(print "---") (and (a false) (b false)) + +(print "---") (or (a true) (b true)) +(print "---") (or (a false) (b true)) +(print "---") (or (a true) (b false)) +(print "---") (or (a false) (b false)) diff --git a/Task/Show-ASCII-table/ArkScript/show-ascii-table.ark b/Task/Show-ASCII-table/ArkScript/show-ascii-table.ark new file mode 100644 index 0000000000..b489ed92ea --- /dev/null +++ b/Task/Show-ASCII-table/ArkScript/show-ascii-table.ark @@ -0,0 +1,15 @@ +(mut i 0) +(while (< i 16) { + (mut j (+ 32 i)) + (while (< j 128) { + (let k + (if (= 32 j) + "Spc" + (if (= 127 j) + "Del" + (string:chr j)))) + (puts (string:format "{:3} : {:<3}" j k)) + (set j (+ 16 j) )}) + (print "") + + (set i (+ 1 i)) }) diff --git a/Task/Show-the-epoch/DuckDB/show-the-epoch.duckdb b/Task/Show-the-epoch/DuckDB/show-the-epoch.duckdb new file mode 100644 index 0000000000..733dcc02cc --- /dev/null +++ b/Task/Show-the-epoch/DuckDB/show-the-epoch.duckdb @@ -0,0 +1 @@ +select to_timestamp(0); diff --git a/Task/Sierpinski-arrowhead-curve/EasyLang/sierpinski-arrowhead-curve.easy b/Task/Sierpinski-arrowhead-curve/EasyLang/sierpinski-arrowhead-curve.easy index a10991eb9c..8e75d38f54 100644 --- a/Task/Sierpinski-arrowhead-curve/EasyLang/sierpinski-arrowhead-curve.easy +++ b/Task/Sierpinski-arrowhead-curve/EasyLang/sierpinski-arrowhead-curve.easy @@ -2,14 +2,13 @@ x = 5 y = 10 ang = 60 glinewidth 0.5 +glineto x y # proc curv o l a . if o = 0 - px = x - py = y x += cos ang * l y += sin ang * l - gline px py x y + glineto x y else o -= 1 l /= 2 diff --git a/Task/Sierpinski-pentagon/EasyLang/sierpinski-pentagon.easy b/Task/Sierpinski-pentagon/EasyLang/sierpinski-pentagon.easy index 6e916e0a21..2bde0fa3a2 100644 --- a/Task/Sierpinski-pentagon/EasyLang/sierpinski-pentagon.easy +++ b/Task/Sierpinski-pentagon/EasyLang/sierpinski-pentagon.easy @@ -6,13 +6,12 @@ scale = 1 / (2 + cos 72 * 2) # proc pentagon x y side depth . if depth = 0 - move x y + gpenup + glineto x y for angle = 0 step 72 to 288 - px = x - py = y x += cos angle * side y += sin angle * side - gline px py x y + glineto x y . else side *= scale diff --git a/Task/Sierpinski-pentagon/FutureBasic/sierpinski-pentagon.basic b/Task/Sierpinski-pentagon/FutureBasic/sierpinski-pentagon.basic new file mode 100644 index 0000000000..c0c8fd2b80 --- /dev/null +++ b/Task/Sierpinski-pentagon/FutureBasic/sierpinski-pentagon.basic @@ -0,0 +1,77 @@ +// +// SIERPINSKY PENTAFLAKE +// +// FutureBasic 7.0.34, August 2025 R.W. +// + +Int mySize, margin, radius, pentas, myside +mySize = 560/2: margin = 6: pentas = 6 +radius = mySize - 2 * margin +dim as double myScale +//long side +CGFloat red, green, blue +CGFloat deg72 +deg72 = 72.0 * PI / 180 // 72 degrees in radians +colorref Colr + +// Create main window + +void local fn BuildMainWindow(wTag as NSInteger) + colorref wco + CGRect r + SInt32 wndStyleMask + wco = fn ColorBlack + wndStyleMask = NSWindowStyleMaskTitled + wndStyleMask += NSWindowStyleMaskClosable + r = fn CGRectMake( 0, 0, 560, 540 ) + window wTag, @" Sierpinsky PentaFlake ", r, wndStyleMask + WindowSetBackgroundColor(wTag, wco) + ViewSetFlipped( _WindowContentViewTag, YES ) + windowcenter (wTag) + AppSetAppearance(fn AppearanceNamed(NSAppearanceNameDarkAqua)) +end fn + +// Draw the pentagon recursively + +local fn DrawPentagon( xpos as int, ypos as int, side as Int, depth as long ) + int i + Float angle, dist + angle = 3 * deg72 + if depth == 0 + // get some funky colors + red = 0.2 + (rnd(65536)-1)/65536.0 + green = 0.2 + (rnd(65536)-1)/65536.0 + blue = 1 // on the bluish hue + Colr = fn ColorWithRGB(red,green,blue,1.0) + pen 1.0, Colr + line xpos, ypos + Oval fill (xpos, ypos, 1.0, 1.0),Colr + for i = 0 to 4 + xpos = xpos + int(side * cos(angle)) + ypos = ypos - int(side * sin(angle)) + line to xpos, ypos + angle = angle + deg72 + next + else + side = side * myScale + dist = side * (1 + cos(deg72) * 2) + for i = 0 to 4 + xpos = xpos + int(dist * cos(angle)) + ypos = ypos - int(dist * sin(angle)) + fn DrawPentagon( xpos, ypos, side, depth - 1 ) + angle = angle + deg72 + next + end if +end fn +// +//----------- main ---------------- +// + +fn BuildMainWindow(1) + +myScale = 1 / (2 + cos(deg72) * 2) +myside = radius * sin(pi/5) * 2 + +fn DrawPentagon( mySize, 3 * margin, myside, pentas-1 ) + +handleEvents diff --git a/Task/Sieve-of-Eratosthenes/DuckDB/sieve-of-eratosthenes.duckdb b/Task/Sieve-of-Eratosthenes/DuckDB/sieve-of-eratosthenes.duckdb new file mode 100644 index 0000000000..c75d3ba217 --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/DuckDB/sieve-of-eratosthenes.duckdb @@ -0,0 +1,20 @@ +# Produce a table of primes less than or equal to mx +create or replace function sieve(mx) as table ( + with recursive + sieve(prime, n) AS ( + -- Base case: a table wherein the column labeled n ranges from 2 through mx. + -- The condition `prime = n` will serve as a flag that n is prime. + select 2, unnest(range(2, 1+mx)) as n + union all + -- remove multiples of the current prime + select prime + (case when prime = 2 then 1 else 2 end), n + from sieve + where n % prime != 0 + and prime <= mx -- constrain the recursion + ) + select prime + from sieve + where n = prime +); + +from sieve(19); diff --git a/Task/Sieve-of-Eratosthenes/Odin/sieve-of-eratosthenes.odin b/Task/Sieve-of-Eratosthenes/Odin/sieve-of-eratosthenes.odin index e3834b9432..8b622e9c35 100644 --- a/Task/Sieve-of-Eratosthenes/Odin/sieve-of-eratosthenes.odin +++ b/Task/Sieve-of-Eratosthenes/Odin/sieve-of-eratosthenes.odin @@ -1,36 +1,58 @@ +#+feature dynamic-literals package main import "core:fmt" import "core:math" - +import "core:os" +import "core:strconv" main :: proc() { - n :: 120 - // outer loop with square root as limit - limit := i32(math.round_f16(math.sqrt_f16(n))) + // start with sieve.exe 120 to get primes until 120 + n:=0 + ok:=false + assert(len(os.args)==2,"Give integer as argument!") + if len(os.args) == 2 { + argument := os.args[1] + n, ok = strconv.parse_int(argument) + assert(ok, "Second argument was not an integer") + assert(n>2, "n must be bigger than two") + } - array : [n]i32 + result := [dynamic]i64{0} + defer delete(result) + + for i:=1;iwin + +main (args):+ + GTK init args + GTK main setup main window diff --git a/Task/Simulate-input-Keyboard/Julia/simulate-input-keyboard.jl b/Task/Simulate-input-Keyboard/Julia/simulate-input-keyboard.jl new file mode 100644 index 0000000000..c6486c39b6 --- /dev/null +++ b/Task/Simulate-input-Keyboard/Julia/simulate-input-keyboard.jl @@ -0,0 +1,85 @@ +using Gtk4 +using Gtk4.GLib + + +""" App to create and initialize the GTK app object and set up the main window """ +mutable struct AppState + target_window::GtkWindow + target_widget::GtkTextView + target_buffer::GtkTextBuffer + function AppState() + window = GtkWindow("Keystroke Target Window") + set_gtk_property!(window, :default_width, 800) + set_gtk_property!(window, :default_height, 800) + set_gtk_property!(window, :resizable, true) + set_gtk_property!(window, :visible, true) + set_gtk_property!(window, :title, "Keystroke Simulation Target") + set_gtk_property!(window, :border_width, 10) + set_gtk_property!(window, :destroy_with_parent, true) + set_gtk_property!(window, :can_focus, true) + buffer = GtkTextBuffer() + set_gtk_property!(buffer, :text, "This is a target text area.\nSimulated keystrokes will appear here.\n\n") + widget = GtkTextView(buffer) + set_gtk_property!(widget, :can_focus, true) + set_gtk_property!(widget, :editable, true) + set_gtk_property!(widget, :cursor_visible, true) + scrolled = GtkScrolledWindow() + scrolled[] = widget + set_gtk_property!(scrolled, :margin_start, 10) + set_gtk_property!(scrolled, :margin_end, 10) + set_gtk_property!(scrolled, :margin_top, 10) + set_gtk_property!(scrolled, :margin_bottom, 10) + window[] = scrolled + show(window) + return new(window, widget, buffer) + end +end + +# the app +const APP = AppState() + +""" Send keystroke or char to a TextView widget using synthetic key events """ +function sendsynthetickey(widget, keychar::Char) + Gtk4.grab_focus(widget) + if isa(widget, GtkTextView) + buf = APP.target_buffer + cursor_iter = Gtk4.G_.get_iter_at_mark(buf, Gtk4.G_.get_insert(buf)) + Gtk4.insert!(buf, Ref(cursor_iter), string(keychar)) + return true + else + println("Widget is not a text view, cannot insert character directly.") + return false + end +end + +""" Send a string of text to the target widget """ +function typetowidget(text::AbstractString; delay = 0.4) + println("Sending text: \"$text\"") + for char in text + sendsynthetickey(APP.target_widget, char) + sleep(delay * rand() * rand()) + end +end + + +# Run a demo +println("Julia Keystroke Simulation with Gtk4.jl") +println("Press Ctrl+C to exit or close the target window.") +println("=======================================") +sleep(2) # Give time to see the window +try + typetowidget("Hello from Gtk4.jl!\n") + sleep(1) + typetowidget("This is a demonstration of simulated human typing input.\n") + typetowidget("Special characters: !@#\$%^&*()\n") + typetowidget("You can close this window to stop the simulation.\n\n") + while get_gtk_property(APP.target_window, :visible, Bool) + typetowidget(string(rand(['a':'z'; collect(" "); '\n']))) + end +catch e + print("Caught exception: $e...") +finally + print("Cleaning up...") + !isnothing(APP.target_window) && close(APP.target_window) + println("Done.") +end diff --git a/Task/Simulate-input-Mouse/FuncSug/simulate-input-mouse.funcsug b/Task/Simulate-input-Mouse/FuncSug/simulate-input-mouse.funcsug new file mode 100644 index 0000000000..8242a2a3f2 --- /dev/null +++ b/Task/Simulate-input-Mouse/FuncSug/simulate-input-mouse.funcsug @@ -0,0 +1,16 @@ +displayNewMessage(`Don't click the button. It will be clicked by the program.`) +waitSeconds(2) +displayNewMessage(``) + +parallel(select 1) || +||==================== + awaitClickBeep('#mybutton') +...--- + displayNewMessage('The button has been clicked') +||==================== + waitSeconds(2) + + # Simulate the click of a mouse + generateUserEvent('#mybutton', 'click') +...--- + displayNewMessage("I know you didn't do it!") diff --git a/Task/Singleton/Rust/singleton.rs b/Task/Singleton/Rust/singleton.rs new file mode 100644 index 0000000000..8dd6d79a52 --- /dev/null +++ b/Task/Singleton/Rust/singleton.rs @@ -0,0 +1,110 @@ +use std::sync::{Arc, Mutex, OnceLock}; + +// Thread-safe singleton using OnceLock (stable since Rust 1.70) +pub struct GlobalSingleton { + data: String, + counter: u32, +} + +impl GlobalSingleton { + // Private constructor + fn new() -> Self { + Self { + data: String::from("Singleton initialized"), + counter: 0, + } + } + + // Get the singleton instance + pub fn instance() -> Arc> { + static INSTANCE: OnceLock>> = OnceLock::new(); + + INSTANCE.get_or_init(|| { + Arc::new(Mutex::new(GlobalSingleton::new())) + }).clone() + } + + // Non-static methods that operate on the singleton instance + pub fn get_data(&self) -> &str { + &self.data + } + + pub fn set_data(&mut self, new_data: String) { + self.data = new_data; + } + + pub fn increment_counter(&mut self) { + self.counter += 1; + } + + pub fn get_counter(&self) -> u32 { + self.counter + } +} + +// Alternative implementation using std::sync::LazyLock (stable since Rust 1.80) +// This is the most modern and clean approach +use std::sync::LazyLock; + +static LAZY_SINGLETON: LazyLock>> = LazyLock::new(|| { + Arc::new(Mutex::new(GlobalSingleton::new())) +}); + +impl GlobalSingleton { + // Alternative method using LazyLock + pub fn lazy_instance() -> Arc> { + LAZY_SINGLETON.clone() + } +} + +fn main() { + // Usage example with OnceLock + { + let singleton = GlobalSingleton::instance(); + let mut instance = singleton.lock().unwrap(); + println!("Initial data: {}", instance.get_data()); + instance.increment_counter(); + instance.set_data("Modified data".to_string()); + println!("Counter: {}", instance.get_counter()); + } + + // Access from another scope - same instance + { + let singleton = GlobalSingleton::instance(); + let instance = singleton.lock().unwrap(); + println!("Data from another scope: {}", instance.get_data()); + println!("Counter from another scope: {}", instance.get_counter()); + } + + // Demonstrate thread safety + use std::thread; + + let handles: Vec<_> = (0..3) + .map(|i| { + thread::spawn(move || { + let singleton = GlobalSingleton::instance(); + let mut instance = singleton.lock().unwrap(); + instance.increment_counter(); + println!("Thread {} incremented counter to: {}", i, instance.get_counter()); + }) + }) + .collect(); + + for handle in handles { + handle.join().unwrap(); + } + + // Final state + let singleton = GlobalSingleton::instance(); + let instance = singleton.lock().unwrap(); + println!("Final counter value: {}", instance.get_counter()); + + // Demonstrate LazyLock alternative + println!("\n--- Using LazyLock alternative ---"); + { + let singleton = GlobalSingleton::lazy_instance(); + let mut instance = singleton.lock().unwrap(); + instance.set_data("LazyLock data".to_string()); + println!("LazyLock data: {}", instance.get_data()); + } +} diff --git a/Task/Singly-linked-list-Element-definition/Crystal/singly-linked-list-element-definition.cr b/Task/Singly-linked-list-Element-definition/Crystal/singly-linked-list-element-definition.cr new file mode 100644 index 0000000000..54836eaf67 --- /dev/null +++ b/Task/Singly-linked-list-Element-definition/Crystal/singly-linked-list-element-definition.cr @@ -0,0 +1,7 @@ +class Node (T) + property data : T + property next : Node(T)? + + def initialize (@data, @next = nil) + end +end diff --git a/Task/Singly-linked-list-Element-definition/Pluto/singly-linked-list-element-definition.pluto b/Task/Singly-linked-list-Element-definition/Pluto/singly-linked-list-element-definition.pluto new file mode 100644 index 0000000000..3f7c87bb5b --- /dev/null +++ b/Task/Singly-linked-list-Element-definition/Pluto/singly-linked-list-element-definition.pluto @@ -0,0 +1,7 @@ +require "list" + +local s = slist.of(1, 2) +local n1 = s:node(1) +local n2 = s:node(2) +print($"node 1: value = {n1.value}, next = {tostring(n1.next?.value)}") +print($"node 2: value = {n2.value}, next = {tostring(n2.next?.value)}") diff --git a/Task/Singly-linked-list-Element-insertion/Crystal/singly-linked-list-element-insertion.cr b/Task/Singly-linked-list-Element-insertion/Crystal/singly-linked-list-element-insertion.cr new file mode 100644 index 0000000000..9438d84a74 --- /dev/null +++ b/Task/Singly-linked-list-Element-insertion/Crystal/singly-linked-list-element-insertion.cr @@ -0,0 +1,26 @@ +class Node (T) + property data : T + property next : Node(T)? + + def initialize (@data, @next = nil) + end + + def insert_after (new_data) + n = Node.new(new_data, @next) + @next = n + end + + def to_s (io) + io << data << "->" + if @next + @next.to_s(io) + else + io << "." + end + end +end + +n = Node.new('A', Node.new('B', Node.new('D'))) +puts n +n.insert_after('C') +puts n diff --git a/Task/Singly-linked-list-Element-insertion/Pluto/singly-linked-list-element-insertion.pluto b/Task/Singly-linked-list-Element-insertion/Pluto/singly-linked-list-element-insertion.pluto new file mode 100644 index 0000000000..b0fe671fbb --- /dev/null +++ b/Task/Singly-linked-list-Element-insertion/Pluto/singly-linked-list-element-insertion.pluto @@ -0,0 +1,8 @@ +require "list" + +local s = slist.of("A", "B") +local ixs = s:find("A") -- always returns an array of indices even if we only want the first +if #ixs > 0 then + s:insert(ixs[1] + 1, "C") + print(s) +end diff --git a/Task/Singly-linked-list-Traversal/Julia/singly-linked-list-traversal.jl b/Task/Singly-linked-list-Traversal/Julia/singly-linked-list-traversal.jl index 94e8e839d1..afc8bf9680 100644 --- a/Task/Singly-linked-list-Traversal/Julia/singly-linked-list-traversal.jl +++ b/Task/Singly-linked-list-Traversal/Julia/singly-linked-list-traversal.jl @@ -1,6 +1,9 @@ -Base.start(ll::LinkedList) = ll.head -Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode -Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next +Base.iterate(ll::LinkedList) = iterate(ll, ll.head) +Base.iterate(::LinkedList, st::Node) = st.data, st.next +Base.iterate(::LinkedList, ::EmptyNode) = nothing +Base.length(ll::LinkedList) = 1 + length(ll.next) +Base.length(ll::EmptyNode) = 0 +Base.eltype(::LinkedList{T}) where {T} = T lst = LinkedList{Int}() push!(lst, 1) diff --git a/Task/Singly-linked-list-Traversal/Pluto/singly-linked-list-traversal.pluto b/Task/Singly-linked-list-Traversal/Pluto/singly-linked-list-traversal.pluto new file mode 100644 index 0000000000..ecbff4bc4b --- /dev/null +++ b/Task/Singly-linked-list-Traversal/Pluto/singly-linked-list-traversal.pluto @@ -0,0 +1,14 @@ +require "list" +local fmt = require "fmt" + +-- Create a singly-linked list containing the first 50 positive integers. +local s = slist.of(range(1, 50):unpack()) + +-- Now traverse and print them in tabular form. +local node = s:node(1) +local count = 0 +while node do + fmt.write("%4d ", node.value) + node = node.next + if ++count % 10 == 0 then print() end +end diff --git a/Task/Sleep/ArkScript/sleep.ark b/Task/Sleep/ArkScript/sleep.ark new file mode 100644 index 0000000000..6192fd5ea5 --- /dev/null +++ b/Task/Sleep/ArkScript/sleep.ark @@ -0,0 +1,4 @@ +(let amount (toNumber (input "ms to sleep for> "))) +(print "Sleeping...") +(sys:sleep amount) +(print "Awake!") diff --git a/Task/Sleep/FutureBasic/sleep.basic b/Task/Sleep/FutureBasic/sleep.basic new file mode 100644 index 0000000000..422f9faf93 --- /dev/null +++ b/Task/Sleep/FutureBasic/sleep.basic @@ -0,0 +1,14 @@ +include "NSlog.incl" + +local fn Sleep + printf @"\nReady to sleep...\n" + CFStringRef secondsToSleep = input %(100,100), @"Enter seconds to sleep: ", @"0123456789", YES, 3, _formatUnsignedFloat + fn ThreadSleepForTimeInterval( fn StringFloatValue( secondsToSleep ) ) + printf @"Waking from %@ seconds of sleep...", secondsToSleep +end fn + +window 1 + +fn Sleep + +HandleEvents diff --git a/Task/Sleep/Pluto/sleep.pluto b/Task/Sleep/Pluto/sleep.pluto new file mode 100644 index 0000000000..c9b9c71554 --- /dev/null +++ b/Task/Sleep/Pluto/sleep.pluto @@ -0,0 +1,5 @@ +io.write("Enter the amout of time to sleep in milliseconds: ") +local ms = io.read("n") +print("Sleeping...") +os.sleep(ms) -- pause this thread for 'ms' milliseconds. +print("Awake!") diff --git a/Task/Smarandache-prime-digital-sequence/ALGOL-68/smarandache-prime-digital-sequence.alg b/Task/Smarandache-prime-digital-sequence/ALGOL-68/smarandache-prime-digital-sequence.alg index c893723766..97508ec59c 100644 --- a/Task/Smarandache-prime-digital-sequence/ALGOL-68/smarandache-prime-digital-sequence.alg +++ b/Task/Smarandache-prime-digital-sequence/ALGOL-68/smarandache-prime-digital-sequence.alg @@ -87,16 +87,8 @@ BEGIN FI OD; print( ( newline ) ); - print( ( "100th Smarandache prime: ", whole( s100, 0 ), newline ) ); - print( ( "1000th Smarandache prime: ", whole( s1000, 0 ), newline ) ); - print( ( "Largest Smarandache prime under " - , whole( prime max, 0 ) - , ": " - , whole( s last, 0 ) - , " (Smarandache prime " - , whole( p last, 0 ) - , ")" - , newline - ) - ) + print( ( " 100th Smarandache prime: ", whole( s100, 0 ), newline ) ); + print( ( " 1000th Smarandache prime: ", whole( s1000, 0 ), newline ) ); + print( ( "Largest Smarandache prime under ", whole( prime max, 0 ) ) ); + print( ( ": ", whole( s last, 0 ), " (Smarandache prime ", whole( p last, 0 ), ")", newline ) ) END diff --git a/Task/Smarandache-prime-digital-sequence/Agena/smarandache-prime-digital-sequence.agena b/Task/Smarandache-prime-digital-sequence/Agena/smarandache-prime-digital-sequence.agena new file mode 100644 index 0000000000..7f3ab56397 --- /dev/null +++ b/Task/Smarandache-prime-digital-sequence/Agena/smarandache-prime-digital-sequence.agena @@ -0,0 +1,90 @@ +# find elements of the Smarandache prime-digital sequence +# - primes whose digits are all primes +# Uses the observations that the final digit of 2 or more digit Smarandache +# primes must be 3 or 7 and the only prime_digits are 2, 3, 5 and 7 +scope + # construct a sieve of primes up to 10 000 000 + local constant prime_max := 10_000_000; + local prime; create register prime( prime_max ); + for i to prime_max do prime[ i ] := i mod 2 = 1 od; + prime[ 1 ], prime[ 2 ] := false, true; + for s from 3 to entier sqrt( prime_max ) by 2 do + if prime[ s ] then + for p from s * s to prime_max by s do prime[ p ] := false od + fi + od; + # consruct the Smarandache primes up to 10 000 000 + local smarandache; create register smarandache( prime_max ); + for i to size prime do smarandache[ i ] := false od; + local constant prime_digits := reg( 2, 3, 5, 7 ); + local digits := reg( 0, 0, 0, 0, 0, 0, 0 ); + + # tests whether the current digits form a Smarandache prime + local constant try_smarandache := proc() is + local possible_prime := 0; + for i to size digits do + possible_prime *:= 10; + possible_prime +:= digits[ i ] + od; + smarandache[ possible_prime ] := prime[ possible_prime ] + end; + # tests whether the current digits plus 3 or 7 form a Smarandache prime + local constant try_smarandache_3_or_7 := proc() is + digits[ size digits ] := 3; + try_smarandache(); + digits[ size digits ] := 7; + try_smarandache(); + end; + # the 1 digit primes are all Smarandache primes + for d7 to size prime_digits do smarandache[ prime_digits[ d7 ] ] := true od; + # try the possible 2, 3, etc. digit numbers composed of prime_digits + for d6 to size prime_digits do + digits[ 6 ] := prime_digits[ d6 ]; + try_smarandache_3_or_7(); + for d5 to size prime_digits do + digits[ 5 ] := prime_digits[ d5 ]; + try_smarandache_3_or_7(); + for d4 to size prime_digits do + digits[ 4 ] := prime_digits[ d4 ]; + try_smarandache_3_or_7(); + for d3 to size prime_digits do + digits[ 3 ] := prime_digits[ d3 ]; + try_smarandache_3_or_7(); + for d2 to size prime_digits do + digits[ 2 ] := prime_digits[ d2 ]; + try_smarandache_3_or_7(); + for d1 to size prime_digits do + digits[ 1 ] := prime_digits[ d1 ]; + try_smarandache_3_or_7(); + od; + digits[ 1 ] := 0 + od; + digits[ 2 ] := 0 + od; + digits[ 3 ] := 0 + od; + digits[ 4 ] := 0 + od; + digits[ 5 ] := 0 + od; + # print some Smarandache primes + local count, s100, s1000, s_last, p_last := 0, 0, 0, 0, 0; + io.write( "First 25 Smarandache primes:\n" ); + for i to size smarandache do + if smarandache[ i ] then + count +:= 1; + s_last, p_last := i, count; + if count <= 25 then + printf( " %d", i ) + elif count = 100 then + s100 := i + elif count = 1000 then + s1000 := i + fi + fi + od; + printf( "\n 100th Smarandache prime: %d", s100 ); + printf( "\n 1000th Smarandache prime: %d", s1000 ); + printf( "\nLargest Smarandache prime under %d: %d", prime_max, s_last ) + printf( " (Smarandache prime %d)\n" , p_last ) +end diff --git a/Task/Smarandache-prime-digital-sequence/Pluto/smarandache-prime-digital-sequence.pluto b/Task/Smarandache-prime-digital-sequence/Pluto/smarandache-prime-digital-sequence.pluto new file mode 100644 index 0000000000..3c611ffcb9 --- /dev/null +++ b/Task/Smarandache-prime-digital-sequence/Pluto/smarandache-prime-digital-sequence.pluto @@ -0,0 +1,27 @@ +do --[[ find elements of the Smarandache prime-digital sequence + - primes whose digits are all primes + Translated from the Lua sample, extending to the 1000th Smarandache prime + ]] + + -- SIEVE: sieve the primes to 5 000 000 + local sieve, S = {}, 5_000_000 + for i = 2,S do sieve[i]=true end + for i = 2,S do + if sieve[i] then + for j=i*i,S,i do sieve[j]=nil end + end + end + + -- TASKS: + local digs, cans, spds, N = {2,3,5,7}, {0}, {}, 1000 + -- the first trip through the following loop adds the single digit primes to cans + -- subsequent trips add the previous candidates * 10 + the final prime digits + while #spds < N do + local c = cans:remove(1) + for _,d in ipairs(digs) do cans:insert(c*10+d) end + if sieve[c] then spds:insert(c) end + end + print(" 1-25: " .. spds:slice(1,25):concat(" ")) + print(" 100th: " .. spds[ 100]) + print("1000th: " .. spds[1000]) +end diff --git a/Task/Snake/Liberty-BASIC/snake.basic b/Task/Snake/Liberty-BASIC/snake.basic new file mode 100644 index 0000000000..e8916fe2bf --- /dev/null +++ b/Task/Snake/Liberty-BASIC/snake.basic @@ -0,0 +1,191 @@ +' ================================ +' SIMPLE SNAKE GAME - Liberty BASIC +' ================================ + +' Graphics constants +global cellSize, gridWidth, gridHeight +global snakeLength, foodX, foodY, gamespeed +global gridOffsetY, score + +cellSize = 20 +gridWidth = 20 +gridHeight = 20 +gridOffsetY = 20 +foodX = 0 +foodY = 0 +gamespeed = 333 +score = 0 + +' Movement directions +global dirX, dirY +dirX = 1 : dirY = 0 ' start moving right + +' Snake body array +dim snakeX(400) +dim snakeY(400) +snakeLength = 5 + +' Initialize snake position in center +for i = 1 to snakeLength + snakeX(i) = 10 - i + snakeY(i) = 10 +next + +' Create first food position +call newFood + +' Open graphics window +WindowWidth = cellSize * gridWidth + 10 +WindowHeight = cellSize * gridHeight + 60 +open "SNAKE GAME - WASD to Move" for graphics_nsb_nf as #g +#g "trapclose [quit]" +#g "down; fill white; flush" + +' Force focus +#g "setfocus" + +' Enable character input +#g "when characterInput [keypress]" + +' Start game timer +[startGame] +timer gamespeed, [gameTick] + +wait + +[gameTick] + + ' Move snake segments + for i = snakeLength to 2 step -1 + snakeX(i) = snakeX(i-1) + snakeY(i) = snakeY(i-1) + next + + ' Head moves in current direction + snakeX(1) = snakeX(1) + dirX + snakeY(1) = snakeY(1) + dirY + + ' Wall collision ends game + if snakeX(1) < 0 or snakeX(1) >= gridWidth _ + or snakeY(1) < 0 or snakeY(1) >= gridHeight then + call gameOver + wait + end if + + ' Check self collision + for i = 2 to snakeLength + if snakeX(1) = snakeX(i) and snakeY(1) = snakeY(i) then + call gameOver + wait + end if + next + + ' Check food collision + if snakeX(1) = foodX and snakeY(1) = foodY then + snakeLength = snakeLength + 1 + score = score + 10 + + ' Initialize new tail segment at same spot as previous tail + snakeX(snakeLength) = snakeX(snakeLength - 1) + snakeY(snakeLength) = snakeY(snakeLength - 1) + + ' Speed up the game + timer 0 + gamespeed = max(gamespeed - 5, 150) + timer gamespeed, [gameTick] + + call newFood + end if + + call redraw +wait + +[keypress] + key$ = Inkey$ + key$ = lower$(key$) + select case key$ + case "w" + if dirY <> 1 then dirX = 0 : dirY = -1 + case "a" + if dirX <> 1 then dirX = -1 : dirY = 0 + case "s" + if dirY <> -1 then dirX = 0 : dirY = 1 + case "d" + if dirX <> -1 then dirX = 1 : dirY = 0 + case chr$(27) ' ESC + call gameOver + wait + end select +wait + +[quit] + close #g + end + +sub redraw + ' Clear screen + #g "cls" + + ' Draw top banner background + #g "color lightgray" + #g, "backcolor lightgray" + #g "place 0 0" + #g "boxfilled "; (gridWidth * cellSize); " "; gridOffsetY + + ' Draw banner text + #g "color black" + #g "font Courier_New 10" + #g "place 5 15" + #g "\"; "Score: "; score; " Speed: "; gamespeed; "ms" + + ' Draw food + call drawBlock foodX, foodY, "red" + + ' Draw snake + for i = 1 to snakeLength + call drawBlock snakeX(i), snakeY(i), "green" + next + + #g "flush" +end sub + +sub drawBlock x, y, color$ + x1 = x * cellSize + y1 = gridOffsetY + y * cellSize + x2 = x1 + cellSize + y2 = y1 + cellSize + + #g "color "; color$ + #g, "backcolor "; color$ + #g "place "; x1; " "; y1 + #g "boxfilled "; x2; " "; y2 +end sub + +sub newFood + overlap = 1 + while overlap = 1 + foodX = int(rnd(0) * gridWidth) + foodY = int(rnd(0) * gridHeight) + overlap = 0 + for i = 1 to snakeLength + if foodX = snakeX(i) and foodY = snakeY(i) then + overlap = 1 + exit for + end if + next + wend +end sub + +sub gameOver + timer 0 + #g "cls" + #g "color black" + #g, "backcolor white" + #g "place 110 200" + #g "font Courier_New 24 bold" + #g "\"; "GAME OVER!" + #g "place 110 250" + #g "font Courier_New 16" + #g "\"; "Score: "; score + #g "flush" +end sub diff --git a/Task/Sokoban/JavaScript/sokoban.js b/Task/Sokoban/JavaScript/sokoban.js new file mode 100644 index 0000000000..f5889d7643 --- /dev/null +++ b/Task/Sokoban/JavaScript/sokoban.js @@ -0,0 +1,130 @@ +class Sokoban { + constructor(board) { + this.nCols = board[0].length; + let destBuf = ''; + let currBuf = ''; + + for (let r = 0; r < board.length; r++) { + for (let c = 0; c < this.nCols; c++) { + const ch = board[r].charAt(c); + + destBuf += (ch !== '$' && ch !== '@') ? ch : ' '; + currBuf += (ch !== '.') ? ch : ' '; + + if (ch === '@') { + this.playerX = c; + this.playerY = r; + } + } + } + this.destBoard = destBuf; + this.currBoard = currBuf; + } + + move(x, y, dx, dy, trialBoard) { + const newPlayerPos = (y + dy) * this.nCols + x + dx; + + if (trialBoard.charAt(newPlayerPos) !== ' ') { + return null; + } + + const trial = trialBoard.split(''); + trial[y * this.nCols + x] = ' '; + trial[newPlayerPos] = '@'; + + return trial.join(''); + } + + push(x, y, dx, dy, trialBoard) { + const newBoxPos = (y + 2 * dy) * this.nCols + x + 2 * dx; + + if (trialBoard.charAt(newBoxPos) !== ' ') { + return null; + } + + const trial = trialBoard.split(''); + trial[y * this.nCols + x] = ' '; + trial[(y + dy) * this.nCols + x + dx] = '@'; + trial[newBoxPos] = '$'; + + return trial.join(''); + } + + isSolved(trialBoard) { + for (let i = 0; i < trialBoard.length; i++) { + if ((this.destBoard.charAt(i) === '.') !== (trialBoard.charAt(i) === '$')) { + return false; + } + } + return true; + } + + solve() { + class Board { + constructor(cur, sol, x, y) { + this.cur = cur; + this.sol = sol; + this.x = x; + this.y = y; + } + } + + const dirLabels = [['u', 'U'], ['r', 'R'], ['d', 'D'], ['l', 'L']]; + const dirs = [[0, -1], [1, 0], [0, 1], [-1, 0]]; + + const history = new Set(); + const open = []; + + history.add(this.currBoard); + open.push(new Board(this.currBoard, "", this.playerX, this.playerY)); + + while (open.length > 0) { + const item = open.shift(); // poll() equivalent + const cur = item.cur; + const sol = item.sol; + const x = item.x; + const y = item.y; + + for (let i = 0; i < dirs.length; i++) { + let trial = cur; + const dx = dirs[i][0]; + const dy = dirs[i][1]; + + // are we standing next to a box? + if (trial.charAt((y + dy) * this.nCols + x + dx) === '$') { + // can we push it? + trial = this.push(x, y, dx, dy, trial); + if (trial !== null) { + // or did we already try this one? + if (!history.has(trial)) { + const newSol = sol + dirLabels[i][1]; + + if (this.isSolved(trial)) { + return newSol; + } + + open.push(new Board(trial, newSol, x + dx, y + dy)); + history.add(trial); + } + } + // otherwise try changing position + } else { + trial = this.move(x, y, dx, dy, trial); + if (trial !== null) { + if (!history.has(trial)) { + const newSol = sol + dirLabels[i][0]; + open.push(new Board(trial, newSol, x + dx, y + dy)); + history.add(trial); + } + } + } + } + } + return "No solution"; + } +} + +// Example usage +const level = "#######,# #,# #,#. # #,#. $$ #,#.$$ #,#.# @#,#######"; +const sokoban = new Sokoban(level.split(",")); +console.log(sokoban.solve()); diff --git a/Task/Sokoban/Rust/sokoban.rs b/Task/Sokoban/Rust/sokoban.rs new file mode 100644 index 0000000000..3996412185 --- /dev/null +++ b/Task/Sokoban/Rust/sokoban.rs @@ -0,0 +1,173 @@ +use std::collections::{HashSet, VecDeque}; +use regex::Regex; + +#[derive(Debug, Clone)] +struct Board { + s_data: Vec>, + d_data: Vec>, + px: usize, + py: usize, +} + +impl Board { + fn new(board_str: &str) -> Self { + let pattern = Regex::new(r"([^\n]+)\n?").unwrap(); + let mut data = Vec::new(); + let mut w = 0; + + for cap in pattern.captures_iter(board_str) { + let line = cap[1].to_string(); + w = w.max(line.len()); + data.push(line); + } + + let mut s_data = Vec::new(); + let mut d_data = Vec::new(); + let mut px = 0; + let mut py = 0; + + for (v, line) in data.iter().enumerate() { + let mut s_temp = Vec::new(); + let mut d_temp = Vec::new(); + + for u in 0..w { + let (s, d) = if u >= line.len() { + (' ', ' ') + } else { + let c = line.chars().nth(u).unwrap(); + let mut s = ' '; + let mut d = ' '; + + match c { + '#' => s = '#', + '.' | '*' | '+' => s = '.', + _ => {} + } + + match c { + '@' | '+' => { + d = '@'; + px = u; + py = v; + } + '$' | '*' => d = '*', + _ => {} + } + + (s, d) + }; + + s_temp.push(s); + d_temp.push(d); + } + + s_data.push(s_temp); + d_data.push(d_temp); + } + + Board { + s_data, + d_data, + px, + py, + } + } + + fn move_player(&self, x: usize, y: usize, dx: i32, dy: i32, data: &mut Vec>) -> bool { + let new_x = (x as i32 + dx) as usize; + let new_y = (y as i32 + dy) as usize; + + if self.s_data[new_y][new_x] == '#' || data[new_y][new_x] != ' ' { + return false; + } + + data[y][x] = ' '; + data[new_y][new_x] = '@'; + + true + } + + fn push_box(&self, x: usize, y: usize, dx: i32, dy: i32, data: &mut Vec>) -> bool { + let new_x = (x as i32 + dx) as usize; + let new_y = (y as i32 + dy) as usize; + let box_x = (x as i32 + 2 * dx) as usize; + let box_y = (y as i32 + 2 * dy) as usize; + + if self.s_data[box_y][box_x] == '#' || data[box_y][box_x] != ' ' { + return false; + } + + data[y][x] = ' '; + data[new_y][new_x] = '@'; + data[box_y][box_x] = '*'; + + true + } + + fn is_solved(&self, data: &Vec>) -> bool { + for (v, row) in data.iter().enumerate() { + for (u, &cell) in row.iter().enumerate() { + if (self.s_data[v][u] == '.') != (cell == '*') { + return false; + } + } + } + true + } + + fn solve(&self) -> String { + let mut visited = HashSet::new(); + let mut open = VecDeque::new(); + + open.push_back((self.d_data.clone(), String::new(), self.px, self.py)); + visited.insert(self.d_data.clone()); + + let dirs = [ + (0, -1, 'u', 'U'), + (1, 0, 'r', 'R'), + (0, 1, 'd', 'D'), + (-1, 0, 'l', 'L'), + ]; + + while let Some((cur, c_sol, x, y)) = open.pop_front() { + for &(dx, dy, move_char, push_char) in &dirs { + let mut temp = cur.clone(); + let new_x = (x as i32 + dx) as usize; + let new_y = (y as i32 + dy) as usize; + + if temp[new_y][new_x] == '*' { + if self.push_box(x, y, dx, dy, &mut temp) && !visited.contains(&temp) { + if self.is_solved(&temp) { + return c_sol + &push_char.to_string(); + } + open.push_back((temp.clone(), c_sol.clone() + &push_char.to_string(), new_x, new_y)); + visited.insert(temp); + } + } else if self.move_player(x, y, dx, dy, &mut temp) && !visited.contains(&temp) { + if self.is_solved(&temp) { + return c_sol + &move_char.to_string(); + } + open.push_back((temp.clone(), c_sol.clone() + &move_char.to_string(), new_x, new_y)); + visited.insert(temp); + } + } + } + + "No solution".to_string() + } +} + +fn main() { + let level = "#######\n\ + # #\n\ + # #\n\ + #. # #\n\ + #. $$ #\n\ + #.$$ #\n\ + #.# @#\n\ + #######"; + + let board = Board::new(level); + println!("{}\n", level); + println!("{}", board.solve()); +} diff --git a/Task/Soloways-recurring-rainfall/ALGOL-68/soloways-recurring-rainfall.alg b/Task/Soloways-recurring-rainfall/ALGOL-68/soloways-recurring-rainfall.alg index 9f56d61de4..6dc094d11d 100644 --- a/Task/Soloways-recurring-rainfall/ALGOL-68/soloways-recurring-rainfall.alg +++ b/Task/Soloways-recurring-rainfall/ALGOL-68/soloways-recurring-rainfall.alg @@ -1,4 +1,4 @@ -BEGIN # read a sequence of integers, terminated by 99999 and outpout their average # +BEGIN # read a sequence of integers, terminated by 99999 and output their average # INT end value = 99999; INT sum := 0; INT count := 0; diff --git a/Task/Soloways-recurring-rainfall/AWK/soloways-recurring-rainfall.awk b/Task/Soloways-recurring-rainfall/AWK/soloways-recurring-rainfall.awk new file mode 100644 index 0000000000..0bea5f41a6 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/AWK/soloways-recurring-rainfall.awk @@ -0,0 +1,24 @@ +BEGIN { + if (!sentinel) sentinel = 99999 + print("Enter the rainfall values (" sentinel " to quit):") +} + +$0 == sentinel { + exit +} + +/^-?[0-9]+$/ { + total += $1 + count++ + next +} + +{ + print("Ignoring \"" $0 "\", please enter only integers.") +} + +END { + if (count > 0) { + print("The average rainfall is", total / count) + } +} diff --git a/Task/Soloways-recurring-rainfall/Agena/soloways-recurring-rainfall.agena b/Task/Soloways-recurring-rainfall/Agena/soloways-recurring-rainfall.agena new file mode 100644 index 0000000000..eefa3f5725 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/Agena/soloways-recurring-rainfall.agena @@ -0,0 +1,27 @@ +scope # read a sequence of integers, terminated by 99999 and output their average + local constant endValue := 99999; + local sum, count, n := 0, 0, 0; + + while n <> endValue do + printf( "Enter rainfall (integer) or %d to quit: ", endValue ); + try + local v := io.read(); + if v = null then + print( "End of input detected" ); + n := endValue + else + n := tonumber( v ); + if not isint( n ) then + error( "Not an integer" ) + elif n <> endValue then + sum +:= n; + count +:= 1; + printf( "\t\t\t\t\t\tNew average: %f\n", sum / count ) + fi + fi + catch + print( "Please enter an integer" ); + n := 0 + yrt + od +end diff --git a/Task/Soloways-recurring-rainfall/COBOL/soloways-recurring-rainfall.cobol b/Task/Soloways-recurring-rainfall/COBOL/soloways-recurring-rainfall.cobol new file mode 100644 index 0000000000..94fe0c07b8 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/COBOL/soloways-recurring-rainfall.cobol @@ -0,0 +1,22 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. SOLOWAY. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 AVERAGE PIC 9(9)V9(9) VALUE ZERO. + 01 AMOUNT PIC 9(9) VALUE ZERO. + 01 CURRENT PIC 9(9). + 01 OUTPUT-VAL PIC Z(8)9.9(9). + + PROCEDURE DIVISION. + READ-VALUE. + ACCEPT CURRENT. + IF CURRENT IS EQUAL TO 99999, GO TO DONE. + ADD 1 TO AMOUNT. + COMPUTE AVERAGE = + AVERAGE * (AMOUNT - 1) / AMOUNT + CURRENT / AMOUNT. + GO TO READ-VALUE. + DONE. + MOVE AVERAGE TO OUTPUT-VAL. + DISPLAY OUTPUT-VAL. + STOP RUN. diff --git a/Task/Soloways-recurring-rainfall/Crystal/soloways-recurring-rainfall.cr b/Task/Soloways-recurring-rainfall/Crystal/soloways-recurring-rainfall.cr new file mode 100644 index 0000000000..026e8330b8 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/Crystal/soloways-recurring-rainfall.cr @@ -0,0 +1,20 @@ +require "big" + +sum = 0.to_big_i +cnt = 0 + +puts "At each prompt enter an integer between -2³¹ and 2³¹-1" +puts "and I'll tell you the cumulative average. Enter 99999 to quit." + +loop do + print "> "; STDOUT.flush + begin + num = (gets || break).to_i + break if num == 99999 + sum += num + cnt += 1 + puts "CA=#{sum / cnt}" + rescue + puts "invalid input ignored" + end +end diff --git a/Task/Soloways-recurring-rainfall/Pluto/soloways-recurring-rainfall.pluto b/Task/Soloways-recurring-rainfall/Pluto/soloways-recurring-rainfall.pluto new file mode 100644 index 0000000000..286d039fd3 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/Pluto/soloways-recurring-rainfall.pluto @@ -0,0 +1,14 @@ +local n = 0 +local sum = 0 +while true do + io.write("Enter integral rainfall (99999 to quit): ") + local i = tonumber(io.read()) + if !(i and i % 1 == 0) then + print("Must be an integer, try again.") + continue + end + if i == 99999 then break end + ++n + sum += i + print($" The current average rainfall is {sum / n}") +end diff --git a/Task/Soloways-recurring-rainfall/R/soloways-recurring-rainfall.r b/Task/Soloways-recurring-rainfall/R/soloways-recurring-rainfall.r new file mode 100644 index 0000000000..8ecb9b9c83 --- /dev/null +++ b/Task/Soloways-recurring-rainfall/R/soloways-recurring-rainfall.r @@ -0,0 +1,22 @@ +soloway <- function(){ + vals <- numeric(0) + repeat{ + entry <- readline(prompt="Enter integer rainfall value (99999 to quit): ") + if(is.na(as.numeric(entry))){ + cat("Input must be numeric, please re-enter", "\n") + entry <- NULL + } + entry <- as.numeric(entry) + if(length(entry)>0){ + if(entry%%1!=0){ + cat("Input must be an integer, please re-enter", "\n") + entry <- NULL + } + } + vals <- c(vals, entry) + if(99999 %in% vals) break + cat("Average rainfall:", mean(vals)) + } +} + +soloway() diff --git a/Task/Solve-a-Hopido-puzzle/JavaScript/solve-a-hopido-puzzle.js b/Task/Solve-a-Hopido-puzzle/JavaScript/solve-a-hopido-puzzle.js new file mode 100644 index 0000000000..a9d30c8b93 --- /dev/null +++ b/Task/Solve-a-Hopido-puzzle/JavaScript/solve-a-hopido-puzzle.js @@ -0,0 +1,146 @@ +class Node { + constructor() { + this.val = 0; + this.neighbors = 0; + } +} + +class NSolver { + constructor() { + this.dx = new Array(8); + this.dy = new Array(8); + this.wid = 0; + this.hei = 0; + this.max = 0; + this.arr = null; + + this.dx[0] = -2; this.dy[0] = -2; this.dx[1] = -2; this.dy[1] = 2; + this.dx[2] = 2; this.dy[2] = -2; this.dx[3] = 2; this.dy[3] = 2; + this.dx[4] = -3; this.dy[4] = 0; this.dx[5] = 3; this.dy[5] = 0; + this.dx[6] = 0; this.dy[6] = -3; this.dx[7] = 0; this.dy[7] = 3; + } + + solve(puzz, maxWid) { + if (puzz.length < 1) return; + + this.wid = maxWid; + this.hei = Math.floor(puzz.length / this.wid); + const len = this.wid * this.hei; + let c = 0; + this.max = len; + + this.arr = new Array(len); + for (let i = 0; i < len; i++) { + this.arr[i] = new Node(); + } + + for (let i = 0; i < puzz.length; i++) { + if (puzz[i] === "*") { + this.max--; + this.arr[c++].val = -1; + continue; + } + // Handle both "." and number cases properly + this.arr[c].val = puzz[i] === "." ? 0 : parseInt(puzz[i]); + c++; + } + + this.solveIt(); + + c = 0; + for (let i = 0; i < puzz.length; i++) { + if (puzz[i] === ".") { + puzz[i] = this.arr[c].val.toString(); + } + c++; + } + + return puzz; + } + + search(x, y, w) { + if (w > this.max) return true; + + const n = this.arr[x + y * this.wid]; + n.neighbors = this.getNeighbors(x, y); + + for (let d = 0; d < 8; d++) { + if (n.neighbors & (1 << d)) { + const a = x + this.dx[d]; + const b = y + this.dy[d]; + if (this.arr[a + b * this.wid].val === 0) { + this.arr[a + b * this.wid].val = w; + if (this.search(a, b, w + 1)) return true; + this.arr[a + b * this.wid].val = 0; + } + } + } + return false; + } + + getNeighbors(x, y) { + let c = 0; + for (let xx = 0; xx < 8; xx++) { + const a = x + this.dx[xx]; + const b = y + this.dy[xx]; + if (a < 0 || b < 0 || a >= this.wid || b >= this.hei) continue; + if (this.arr[a + b * this.wid].val > -1) c |= (1 << xx); + } + return c; + } + + solveIt() { + const result = this.findStart(); + if (result.z === 99999) { + console.log("\nCan't find start point!\n"); + return; + } + this.search(result.x, result.y, result.z + 1); + } + + findStart() { + for (let b = 0; b < this.hei; b++) { + for (let a = 0; a < this.wid; a++) { + if (this.arr[a + this.wid * b].val === 0) { + const x = a; + const y = b; + const z = 1; + this.arr[a + this.wid * b].val = z; + return { x, y, z }; + } + } + } + return { x: 0, y: 0, z: 99999 }; + } +} + +function main() { + const wid = 7; + const p = "* . . * . . * . . . . . . . . . . . . . . * . . . . . * * * . . . * * * * * . * * *"; + const puzz = p.split(" "); + + const solver = new NSolver(); + const result = solver.solve(puzz, wid); + + let c = 0; + let output = ""; + + for (let i = 0; i < result.length; i++) { + if (result[i] !== "*" && result[i] !== ".") { + const num = parseInt(result[i]); + if (!isNaN(num) && num < 10) output += "0"; + output += result[i] + " "; + } else { + output += " "; + } + + if (++c >= wid) { + output += "\n"; + c = 0; + } + } + + console.log(output); +} + +main(); diff --git a/Task/Solve-a-Numbrix-puzzle/Python/solve-a-numbrix-puzzle-1.py b/Task/Solve-a-Numbrix-puzzle/Python/solve-a-numbrix-puzzle-1.py index fdc2e475cb..46a462c40b 100644 --- a/Task/Solve-a-Numbrix-puzzle/Python/solve-a-numbrix-puzzle-1.py +++ b/Task/Solve-a-Numbrix-puzzle/Python/solve-a-numbrix-puzzle-1.py @@ -1,98 +1,152 @@ -from sys import stdout -neighbours = [[-1, 0], [0, -1], [1, 0], [0, 1]] -exists = [] -lastNumber = 0 -wid = 0 -hei = 0 +import re -def find_next(pa, x, y, z): - for i in range(4): - a = x + neighbours[i][0] - b = y + neighbours[i][1] - if wid > a > -1 and hei > b > -1: - if pa[a][b] == z: - return a, b +class HidatoPuzzle: + """ Generic Hidato type puzzle solver, used here for Numbrix puzzles """ - return -1, -1 + def __init__(self, board_text: str, allowed_moves: list[list[int]]): + """ initialize the puzzle from a board and the move rules + . means blocked, 0 or _ means open, numeric > 0 are fixed points + """ + lines = board_text.strip().split('\n') + self.nrows, self.ncols = len(lines), len(re.split(r'\s+', lines[0])) + self.board = [[-1] * self.ncols for _ in range(self.nrows)] + self.allowed_moves = allowed_moves + self.starts = [] + self.fixed = [] + self.solutions = [] + self.maxmoves = 0 + for i, line in enumerate(lines): + for j, s in enumerate(re.split(r'\s+', line.strip())): + c = s[0] + if c == '_' or c == '0' and len(s) == 1: + self.board[i][j] = 0 + self.maxmoves += 1 + elif c == '.': + continue # remains -1, blocked + else: # get digits and add to fixed numeric positions as > 0 + self.board[i][j] = int(s) + self.fixed.append(self.board[i][j]) + if self.board[i][j] == 1: + self.starts.append((i, j)) + self.maxmoves += 1 + self.fixed.sort() + if len(self.starts) != 1: # 1 is not fixed, so we can start at any (0) + self.starts = [] + for i in range(self.nrows): + for j in range(self.ncols): + if self.board[i][j] == 0: + self.starts.append((i, j)) -def find_solution(pa, x, y, z): - if z > lastNumber: - return 1 - if exists[z] == 1: - s = find_next(pa, x, y, z) - if s[0] < 0: - return 0 - return find_solution(pa, s[0], s[1], z + 1) + def solve(self): + """ solve puzzle: if start (1) not fixed may give multiple solutions """ + for xy in self.starts: + saved = self.board + self.board = [r[:] for r in self.board] + if self.dfs(xy[0], xy[1], 1): + self.solutions.append(self.board) + self.board = saved - for i in range(4): - a = x + neighbours[i][0] - b = y + neighbours[i][1] - if wid > a > -1 and hei > b > -1: - if pa[a][b] == 0: - pa[a][b] = z - r = find_solution(pa, a, b, z + 1) - if r == 1: - return 1 - pa[a][b] = 0 + return len(self.solutions) > 0 - return 0 + def dfs(self, row, col, current_target): + """ depth first search for a solution """ + if current_target > self.maxmoves: + return True + n = self.board[row][col] + if not n in (0, current_target) or n == 0 and current_target in self.fixed: + return False + backnum = n # backup board[row][col] value before trying change + self.board[row][col] = current_target + for move in self.allowed_moves: + i, j = row + move[0], col + move[1] + if 0 <= i < self.nrows and 0 <= j < self.ncols and \ + self.dfs(i, j, current_target + 1): + return True + self.board[row][col] = backnum # restore board to original state + return False -def solve(pz, w, h): - global lastNumber, wid, hei, exists + def print_matrix(self, mat, emptysquare=" 0 ", blocked=" . "): + """ pretty print 2D matrix with substitution for 0 or blocked values """ + d = {-1: blocked, 0: emptysquare, -2: '\n'} + for i in range(self.nrows * self.ncols): + d[i + 1] = str(i + 1).center(3, ' ') - lastNumber = w * h - wid = w - hei = h - exists = [0 for j in range(lastNumber + 1)] - - pa = [[0 for j in range(h)] for i in range(w)] - st = pz.split() - idx = 0 - for j in range(h): - for i in range(w): - if st[idx] == ".": - idx += 1 - else: - pa[i][j] = int(st[idx]) - exists[pa[i][j]] = 1 - idx += 1 - - x = 0 - y = 0 - t = w * h + 1 - for j in range(h): - for i in range(w): - if pa[i][j] != 0 and pa[i][j] < t: - t = pa[i][j] - x = i - y = j - - return find_solution(pa, x, y, t + 1), pa - - -def show_result(r): - if r[0] == 1: - for j in range(hei): - for i in range(wid): - stdout.write(" {:0{}d}".format(r[1][i][j], 2)) + for r in range(self.nrows): + for c in range(self.ncols): + print(d[mat[r][c]], end='') print() - else: - stdout.write("No Solution!\n") - print() + def print_starting_board(self): + """ print input board """ + self.print_matrix(self.board) + + def is_solved(self): + """ true if there is at least 1 solution """ + return len(self.solutions) > 0 + + def print_solution(self, print_all=True): + """ print solution board(s) """ + n_solutions = len(self.solutions) + print(f"\n{n_solutions} solution{'s' if n_solutions != 1 else ''} found.") + for b in self.solutions: + self.print_matrix(b, '__ ') + if not print_all: + break + print() -r = solve(". . . . . . . . . . . 46 45 . 55 74 . . . 38 . . 43 . . 78 . . 35 . . . . . 71 . . . 33 . . . 59 . . . 17" - " . . . . . 67 . . 18 . . 11 . . 64 . . . 24 21 . 1 2 . . . . . . . . . . .", 9, 9) -show_result(r) +if __name__ == '__main__': + NUMBRIX_TESTS = [ + """ + 0 0 0 0 0 0 0 0 0 + 0 0 46 45 0 55 74 0 0 + 0 38 0 0 43 0 0 78 0 + 0 35 0 0 0 0 0 71 0 + 0 0 33 0 0 0 59 0 0 + 0 17 0 0 0 0 0 67 0 + 0 18 0 0 11 0 0 64 0 + 0 0 24 21 0 1 2 0 0 + 0 0 0 0 0 0 0 0 0 + """, + """ + 0 0 0 0 0 0 0 0 0 + 0 11 12 15 18 21 62 61 0 + 0 6 0 0 0 0 0 60 0 + 0 33 0 0 0 0 0 57 0 + 0 32 0 0 0 0 0 56 0 + 0 37 0 1 0 0 0 73 0 + 0 38 0 0 0 0 0 72 0 + 0 43 44 47 48 51 76 77 0 + 0 0 0 0 0 0 0 0 0 + """, + """ + 17 0 0 0 11 0 0 0 59 + 0 15 0 0 6 0 0 61 0 + 0 0 3 0 0 0 63 0 0 + 0 0 0 0 66 0 0 0 0 + 23 24 0 68 67 78 0 54 55 + 0 0 0 0 72 0 0 0 0 + 0 0 35 0 0 0 49 0 0 + 0 29 0 0 40 0 0 47 0 + 31 0 0 0 39 0 0 0 45 + """, + """ + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 3 + 0 0 0 0 0 + 0 0 0 0 0 + """, + ] -r = solve(". . . . . . . . . . 11 12 15 18 21 62 61 . . 6 . . . . . 60 . . 33 . . . . . 57 . . 32 . . . . . 56 . . 37" - " . 1 . . . 73 . . 38 . . . . . 72 . . 43 44 47 48 51 76 77 . . . . . . . . . .", 9, 9) -show_result(r) + NUMBRIX_MOVES = [[-1, 0], [0, -1], [0, 1], [1, 0]] -r = solve("17 . . . 11 . . . 59 . 15 . . 6 . . 61 . . . 3 . . . 63 . . . . . . 66 . . . . 23 24 . 68 67 78 . 54 55" - " . . . . 72 . . . . . . 35 . . . 49 . . . 29 . . 40 . . 47 . 31 . . . 39 . . . 45", 9, 9) -show_result(r) + for t in NUMBRIX_TESTS: + puzzle = HidatoPuzzle(t.strip(), NUMBRIX_MOVES) + print("\nStarting position:") + puzzle.print_starting_board() + puzzle.solve() + puzzle.print_solution() diff --git a/Task/Sort-an-array-of-composite-structures/DuckDB/sort-an-array-of-composite-structures.duckdb b/Task/Sort-an-array-of-composite-structures/DuckDB/sort-an-array-of-composite-structures.duckdb new file mode 100644 index 0000000000..8894010528 --- /dev/null +++ b/Task/Sort-an-array-of-composite-structures/DuckDB/sort-an-array-of-composite-structures.duckdb @@ -0,0 +1,6 @@ +create table pairs (name varchar(16), value varchar(16)); +insert into pairs values ('Fluffy', 'cat'); +insert into pairs values ('Fido', 'dog'); +insert into pairs values ('Francis', 'fish'); +-- order them by name +select * from pairs order by name; diff --git a/Task/Sort-an-integer-array/Pluto/sort-an-integer-array.pluto b/Task/Sort-an-integer-array/Pluto/sort-an-integer-array.pluto new file mode 100644 index 0000000000..451ea6e294 --- /dev/null +++ b/Task/Sort-an-integer-array/Pluto/sort-an-integer-array.pluto @@ -0,0 +1,2 @@ +a = {2,4,3,1,2} +print(a:sort():unpack()) diff --git a/Task/Sort-an-outline-at-every-level/EasyLang/sort-an-outline-at-every-level.easy b/Task/Sort-an-outline-at-every-level/EasyLang/sort-an-outline-at-every-level.easy index f6ffbc327d..119aaf9a25 100644 --- a/Task/Sort-an-outline-at-every-level/EasyLang/sort-an-outline-at-every-level.easy +++ b/Task/Sort-an-outline-at-every-level/EasyLang/sort-an-outline-at-every-level.easy @@ -73,7 +73,7 @@ func$[] outline . . proc run dir . sortdir = dir - call init + init nextline for s$ in outline : print s$ print "" diff --git a/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-1.duckdb b/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-1.duckdb new file mode 100644 index 0000000000..e114ea138c --- /dev/null +++ b/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-1.duckdb @@ -0,0 +1,7 @@ +create or replace function lexorderedsequence(n) as table ( + with cte as ( + select i, i::VARCHAR as s + from range(1, n+1) t(i) + ) + select i from cte order by s +); diff --git a/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-2.duckdb b/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-2.duckdb new file mode 100644 index 0000000000..0f9de652e9 --- /dev/null +++ b/Task/Sort-numbers-lexicographically/DuckDB/sort-numbers-lexicographically-2.duckdb @@ -0,0 +1 @@ +select array_agg(i order by s) as lex from lexorderedsequence(13); diff --git a/Task/Sort-numbers-lexicographically/Icon/sort-numbers-lexicographically.icon b/Task/Sort-numbers-lexicographically/Icon/sort-numbers-lexicographically.icon new file mode 100644 index 0000000000..3842c62229 --- /dev/null +++ b/Task/Sort-numbers-lexicographically/Icon/sort-numbers-lexicographically.icon @@ -0,0 +1,9 @@ +link sort # for isort + +procedure main() + n := 13 + every a := [] & put(a, n to 1 by -1) + writes("before sort:") ; every writes(" ",!a) ; write() + a := isort(a,string) + writes("after sort: ") ; every writes(" ",!a) ; write() +end diff --git a/Task/Sort-three-variables/Prolog/sort-three-variables.pro b/Task/Sort-three-variables/Prolog/sort-three-variables.pro new file mode 100644 index 0000000000..de2b8582ac --- /dev/null +++ b/Task/Sort-three-variables/Prolog/sort-three-variables.pro @@ -0,0 +1,9 @@ +?- msort(['lions, tigers, and', 'bears, oh my!', '(from the "Wizard of OZ")'], [X, Y, Z]). +X = '(from the "Wizard of OZ")', +Y = 'bears, oh my!', +Z = 'lions, tigers, and'. + +?- msort([77444, -12, 0], [X, Y, Z]). +X = -12, +Y = 0, +Z = 77444. diff --git a/Task/Sorting-algorithms-Insertion-sort/FutureBasic/sorting-algorithms-insertion-sort.basic b/Task/Sorting-algorithms-Insertion-sort/FutureBasic/sorting-algorithms-insertion-sort.basic new file mode 100644 index 0000000000..627f9d81bf --- /dev/null +++ b/Task/Sorting-algorithms-Insertion-sort/FutureBasic/sorting-algorithms-insertion-sort.basic @@ -0,0 +1,62 @@ +// +// Insertion Sort in FutureBasic +// + +_maxDim = 99 // size of array + +dim theArray(_maxDim) as Int +dim x as Int + +// sorts array "theArray" +// in ascending order + +void local function insertionSort(arr(_maxDim) as Int, siz as Int) +dim as Int j,k,s + +for x = 0 to siz + j = x - 1 + s = 1 + k = arr(x) + while (j => 0) && (s == 1) + arr(j + 1) = arr(j) + s = 0 + if arr(j) > k + arr(j + 1) = arr(j) + j-- + s = 1 + end if + wend + arr(j + 1) = k +next x + +end fn +// + +// +// main +// +window 1,@"Insertion Sort" + +// load array with random 0-99 + +for x = 0 to 99 + theArray(x) = rnd(100)-1 +next x + +print "Unsorted:" +for x = 1 to 100 + print theArray(x-1); + if x MOD 20 then print "-"; else print +next x + +print + +fn insertionSort(@theArray(0),99) + +print "Sorted:" +for x = 1 to 100 + print theArray(x-1); + if x MOD 20 then print "-"; else print +next x + +handleevents diff --git a/Task/Sorting-algorithms-Insertion-sort/S-BASIC/sorting-algorithms-insertion-sort.basic b/Task/Sorting-algorithms-Insertion-sort/S-BASIC/sorting-algorithms-insertion-sort.basic new file mode 100644 index 0000000000..fb294242e9 --- /dev/null +++ b/Task/Sorting-algorithms-Insertion-sort/S-BASIC/sorting-algorithms-insertion-sort.basic @@ -0,0 +1,36 @@ +$constant NUM_ITEMS = 10 + +dim integer items(NUM_ITEMS) +var i, j, t = integer + +rem - create a randomly-ordered list of numbers +for i = 1 to NUM_ITEMS + items(i) = int(rnd(1) * 100) + 1 +next i + +rem - show unsorted list +print "Unsorted list: "; +for i = 1 to NUM_ITEMS + print items(i); +next i +print + +rem - sort the list +for i = 1 to NUM_ITEMS + j = i + while j > 1 and items(j-1) > items(j) do + begin + t = items(j) + items(j) = items(j-1) + items(j-1) = t + j = j - 1 + end +next i + +rem - show the sorted list +print "Sorted list : "; +for i = 1 to NUM_ITEMS + print items(i); +next i + +end diff --git a/Task/Sorting-algorithms-Quicksort/ArkScript/sorting-algorithms-quicksort.ark b/Task/Sorting-algorithms-Quicksort/ArkScript/sorting-algorithms-quicksort.ark new file mode 100644 index 0000000000..b856e3eae7 --- /dev/null +++ b/Task/Sorting-algorithms-Quicksort/ArkScript/sorting-algorithms-quicksort.ark @@ -0,0 +1,25 @@ +(import std.List :filter) + +(let quicksort (fun (array) { + (if (empty? array) + # if the given list is empty, return it + [] + # otherwise, sort it + { + # the pivot will be the first element + (let pivot (head array)) + + # call quicksort on a smaller array containing all the elements less than the pivot + (mut less (quicksort (filter (tail array) (fun (e) (< e pivot))))) + + # and after that, call quicksort on a smaller array containing all the elements greater or equal to the pivot + (let more (quicksort (filter (tail array) (fun (e) (>= e pivot))))) + + (concat! less [pivot] more) + # return a concatenation of arrays + less }) })) + +# an unsorted list to sort +(let a [3 6 1 5 1 65 324 765 1 6 3 0 6 9 6 5 3 2 5 6 7 64 645 7 345 432 432 4 324 23]) + +(assert (= (quicksort a) [0 1 1 1 2 3 3 3 4 5 5 5 6 6 6 6 6 7 7 9 23 64 65 324 324 345 432 432 645 765]) "(quicksort a) is sorted") diff --git a/Task/Sorting-algorithms-Sleep-sort/FutureBasic/sorting-algorithms-sleep-sort.basic b/Task/Sorting-algorithms-Sleep-sort/FutureBasic/sorting-algorithms-sleep-sort.basic new file mode 100644 index 0000000000..0b6846db6c --- /dev/null +++ b/Task/Sorting-algorithms-Sleep-sort/FutureBasic/sorting-algorithms-sleep-sort.basic @@ -0,0 +1,21 @@ +include "Tlbx Dispatch.incl" + +include "NSLog.incl" + +local fn SleepSort + CFArrayRef unsorted = @[@35, @21, @11, @1, @2, @27, @32, @7, @42, @20, @50, @42, @25, @41, @43, @14, @46, @20, @30] + + dispatchglobal + for int i = 0 to len(unsorted) - 1 + CFArrayRef sorted = fn ArraySortedArrayUsingSelector( unsorted, @"compare:" ) + dispatchmain + NSLog( @"%@", sorted[i] ) + dispatchend + ThreadSleepForTimeInterval( 0.5 ) + next + dispatchend +end fn + +fn SleepSort + +HandleEvents diff --git a/Task/Sorting-algorithms-Sleep-sort/OCaml/sorting-algorithms-sleep-sort.ml b/Task/Sorting-algorithms-Sleep-sort/OCaml/sorting-algorithms-sleep-sort.ml new file mode 100644 index 0000000000..9bd8dbbeb7 --- /dev/null +++ b/Task/Sorting-algorithms-Sleep-sort/OCaml/sorting-algorithms-sleep-sort.ml @@ -0,0 +1,6 @@ +#directory "+unix";; +#directory "+threads";; +#load "unix.cma";; +#load "threads.cma";; + +List.iter Thread.join (List.map (fun x -> Thread.create (fun x -> Thread.delay (float_of_int x);Printf.printf "%i\n%!" x) x;) (List.map int_of_string (List.tl (Array.to_list Sys.argv))));; diff --git a/Task/Sorting-algorithms-Stooge-sort/Julia/sorting-algorithms-stooge-sort.jl b/Task/Sorting-algorithms-Stooge-sort/Julia/sorting-algorithms-stooge-sort.jl index b8e84a9908..bcc9635bcc 100644 --- a/Task/Sorting-algorithms-Stooge-sort/Julia/sorting-algorithms-stooge-sort.jl +++ b/Task/Sorting-algorithms-Stooge-sort/Julia/sorting-algorithms-stooge-sort.jl @@ -4,7 +4,7 @@ function stoogesort!(a::Array, i::Int=1, j::Int=length(a)) end if (j - i) > 1 - t = round(Int, (j - i + 1) / 3) + t = (j - i + 1) ÷ 3 a = stoogesort!(a, i, j - t) a = stoogesort!(a, i + t, j) a = stoogesort!(a, i, j - t) diff --git a/Task/Sorting-algorithms-Stooge-sort/Maxima/sorting-algorithms-stooge-sort.maxima b/Task/Sorting-algorithms-Stooge-sort/Maxima/sorting-algorithms-stooge-sort.maxima new file mode 100644 index 0000000000..dfd8c5024e --- /dev/null +++ b/Task/Sorting-algorithms-Stooge-sort/Maxima/sorting-algorithms-stooge-sort.maxima @@ -0,0 +1,14 @@ +stoogesort(list, i, j) := block( +if(list[j]1) then block( + t: floor((j-i+1)/3), + stoogesort(list, i, j-t), + stoogesort(list, i+t, j), + stoogesort(list, i, j-t)), +list)$ + +test_list: makelist(random(21),20); + +stooge(list) := stoogesort(list, 1, length(list))$ + +stooge(test_list); diff --git a/Task/Sorting-algorithms-Stooge-sort/R/sorting-algorithms-stooge-sort.r b/Task/Sorting-algorithms-Stooge-sort/R/sorting-algorithms-stooge-sort.r index d24cbe6f87..3386c265a7 100644 --- a/Task/Sorting-algorithms-Stooge-sort/R/sorting-algorithms-stooge-sort.r +++ b/Task/Sorting-algorithms-Stooge-sort/R/sorting-algorithms-stooge-sort.r @@ -1,17 +1,15 @@ stoogesort = function(vect) { - i = 1 - j = length(vect) - if(vect[j] < vect[i]) vect[c(j, i)] = vect[c(i, j)] + i <- 1 + j <- length(vect) + if(vect[j] < vect[i]) vect[c(j, i)] <- vect[c(i, j)] if(j - i > 1) { - t = (j - i + 1) %/% 3 - vect[i:(j - t)] = stoogesort(vect[i:(j - t)]) - vect[(i + t):j] = stoogesort(vect[(i + t):j]) - vect[i:(j - t)] = stoogesort(vect[i:(j - t)]) + t <- (j - i + 1) %/% 3 + vect[i:(j - t)] <- stoogesort(vect[i:(j - t)]) + vect[(i + t):j] <- stoogesort(vect[(i + t):j]) + vect[i:(j - t)] <- stoogesort(vect[i:(j - t)]) } vect } -v = sample(21, 20) -k = stoogesort(v) -v -k +v <- print(sample(21, 20)) +stoogesort(v) diff --git a/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-1.logo b/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-1.logo new file mode 100644 index 0000000000..2db36cf0d6 --- /dev/null +++ b/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-1.logo @@ -0,0 +1,42 @@ +to create.list :string + output parse map [ifelse equalp ? ", ["\ ] [?]] :string +end + +to max :a :b + output ifelse lessequalp :a :b [:b] [:a] +end + +to min :a :b + output ifelse greaterequalp :a :b [:b] [:a] +end + +to sparklines :lists :bars :out + openwrite :out + setwrite :out + foreach :lists [sparkline create.list ? :bars] + close :out + setwrite [] +end + +to sparkline :list :bars + local [min max range nchar] + make "max reduce "max :list + make "min reduce "min :list + make "range difference :max :min + make "nchar count :bars + (type :list "\ ->\ ) + make "list map [1 + ifelse lessequalp difference :nchar 1 + int (product (quotient difference ? :min :range) :nchar) + [difference :nchar 1] + [int (product (quotient difference ? :min :range) :nchar)]] :list + foreach :list [type item ? :bars] + print " +end + +make "str1 "1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 7\ 6\ 5\ 4\ 3\ 2\ 1 +make "str2 "1.5,\ 0.5\ 3.5,\ 2.5\ 5.5,\ 4.5\ 7.5,\ 6.5 +make "str3 "0,\ 1,\ 19,\ 20 +make "str4 "0,\ 999,\ 4000,\ 4999,\ 7000,\ 7999 +make "lists (list :str1 :str2 :str3 :str4) + +make "bars [▁ ▂ ▃ ▄ ▅ ▆ ▇ █] diff --git a/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-2.logo b/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-2.logo new file mode 100644 index 0000000000..156fe143da --- /dev/null +++ b/Task/Sparkline-in-unicode/Logo/sparkline-in-unicode-2.logo @@ -0,0 +1,3 @@ +load "sparkline.lg + +sparklines :lists :bars "sparkline.txt diff --git a/Task/Sparkline-in-unicode/YAMLScript/sparkline-in-unicode.ys b/Task/Sparkline-in-unicode/YAMLScript/sparkline-in-unicode.ys new file mode 100644 index 0000000000..105f9d0240 --- /dev/null +++ b/Task/Sparkline-in-unicode/YAMLScript/sparkline-in-unicode.ys @@ -0,0 +1,14 @@ +!YS-v0 + +defn main(input): + each line input:lines: + say: line:words.map(N):sparkline + +defn sparkline(nums): + sparks =: '▁▂▃▄▅▆▇█' + high =: max(nums*) + low =: min(nums*) + spread =: high - low + quantize =: + \(round(sparks.#.-- * ((_ - low) / spread))) + apply str: nums.map(\(nth sparks quantize(_))) diff --git a/Task/Split-a-character-string-based-on-change-of-character/R/split-a-character-string-based-on-change-of-character.r b/Task/Split-a-character-string-based-on-change-of-character/R/split-a-character-string-based-on-change-of-character.r new file mode 100644 index 0000000000..3a3e9d02a9 --- /dev/null +++ b/Task/Split-a-character-string-based-on-change-of-character/R/split-a-character-string-based-on-change-of-character.r @@ -0,0 +1,7 @@ +split_by_char <- function(s){ + chars <- strsplit(s,"") |> unlist() |> rle() + chunks <- strrep(chars$values, chars$lengths) + cat(chunks, sep=", ") +} + +split_by_char("gHHH5YY++///\\ ,,") diff --git a/Task/Square-form-factorization/REXX/square-form-factorization.rexx b/Task/Square-form-factorization/REXX/square-form-factorization.rexx index cb88ddad6f..68b25d05c1 100644 --- a/Task/Square-form-factorization/REXX/square-form-factorization.rexx +++ b/Task/Square-form-factorization/REXX/square-form-factorization.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings numeric digits 40 @@ -25,7 +25,7 @@ test.0 = i-1 return Selected: -procedure expose mult. test. glob. +procedure expose mult. test. Memo. call Time('r') say 'Find a factor for 28 selected numbers...' do t = 1 for test.0 @@ -55,7 +55,7 @@ say return Randomized: -procedure expose mult. glob. +procedure expose mult. Memo. say 'Find a factor for 28 random numbers...' x = 0 do until x = 28 @@ -89,6 +89,4 @@ end say return -include Numbers -include Functions -include Abend +include Math diff --git a/Task/Stack-traces/FutureBasic/stack-traces.basic b/Task/Stack-traces/FutureBasic/stack-traces.basic new file mode 100644 index 0000000000..29325975d7 --- /dev/null +++ b/Task/Stack-traces/FutureBasic/stack-traces.basic @@ -0,0 +1,14 @@ +output file @"Rosetta Code Stack Traces" + +include "NSLog.incl" + +void local fn StackTrace + CFArrayRef stackSymbols = fn ThreadCallStackSymbols + for CFStringRef symbol in stackSymbols + NSLog( @"%@", symbol ) + next +end fn + +fn StackTrace + +HandleEvents diff --git a/Task/Stack/OoRexx/stack.rexx b/Task/Stack/OoRexx/stack.rexx index 9916fb8815..01deff92ae 100644 --- a/Task/Stack/OoRexx/stack.rexx +++ b/Task/Stack/OoRexx/stack.rexx @@ -1,6 +1,9 @@ stack = .queue~of(123, 234) -- creates a stack with a couple of items stack~push("Abc") -- pushing value = stack~pull -- popping +say 'popped:' value value = stack~peek -- peeking +say 'peeked:' value -- the is empty test if stack~isEmpty then say "The stack is empty" +Else say stack~items 'items are on the stack' diff --git a/Task/Stack/Pluto/stack.pluto b/Task/Stack/Pluto/stack.pluto new file mode 100644 index 0000000000..17486a799a --- /dev/null +++ b/Task/Stack/Pluto/stack.pluto @@ -0,0 +1,4 @@ +stack = {} +table.insert(stack, 11) -- push +table.remove(stack) -- pop +print(#stack == 0) -- empty diff --git a/Task/Stack/REXX/stack-1.rexx b/Task/Stack/REXX/stack-1.rexx deleted file mode 100644 index 1b85ae47de..0000000000 --- a/Task/Stack/REXX/stack-1.rexx +++ /dev/null @@ -1,7 +0,0 @@ -y=123 /*define a REXX variable, value is 123 */ -push y /*pushes 123 onto the stack. */ -pull g /*pops last value stacked & removes it. */ -q=empty() /*invokes the EMPTY subroutine (below)*/ -exit /*stick a fork in it, we're done. */ - -empty: return queued() /*subroutine returns # of stacked items.*/ diff --git a/Task/Stack/REXX/stack-2.rexx b/Task/Stack/REXX/stack.rexx similarity index 82% rename from Task/Stack/REXX/stack-2.rexx rename to Task/Stack/REXX/stack.rexx index 0ebf18a3f5..3a3bf6e8fd 100644 --- a/Task/Stack/REXX/stack-2.rexx +++ b/Task/Stack/REXX/stack.rexx @@ -3,10 +3,10 @@ * 11.08.2013 Walter Pachl **********************************************************************/ stk.=0 -Call push 123 +Call push 123 /*pushes 123 onto the stack. */ Say empty() say peek() -say pull() +say pull() /*pops last value stacked & removes it. */ Say empty() say peek() say push(456) diff --git a/Task/Stack/TAV/stack-1.tav b/Task/Stack/TAV/stack-1.tav new file mode 100644 index 0000000000..ed582a9393 --- /dev/null +++ b/Task/Stack/TAV/stack-1.tav @@ -0,0 +1,6 @@ +row (@) push (val): + @[@.Count+1] =: val \ increments .Count +row (@) pop: + rv =: @[@.Count] \ void if .Count = 0 + @[@.Count] =: () \ assigning void decrements .Count + :> rv diff --git a/Task/Stack/TAV/stack-2.tav b/Task/Stack/TAV/stack-2.tav new file mode 100644 index 0000000000..b95a0b9d3f --- /dev/null +++ b/Task/Stack/TAV/stack-2.tav @@ -0,0 +1,9 @@ +main(params):+ + stack =: new row \ a row is a nice stack + ?# v =: tuple 1,3,5,7,11,13 give values + row stack push v \ push some primes + print '*' _ stack[stack.Count] \ get top + ?# i =: from 1 upto 7 + ? i %% 3 = 0 + print '*' _ stack[stack.Count] + print stack::pop \ class function syntax used diff --git a/Task/Statistics-Basic/DuckDB/statistics-basic.duckdb b/Task/Statistics-Basic/DuckDB/statistics-basic.duckdb new file mode 100644 index 0000000000..bbc5b6c183 --- /dev/null +++ b/Task/Statistics-Basic/DuckDB/statistics-basic.duckdb @@ -0,0 +1,12 @@ +create or replace function basics(n) as table ( + select n, avg(x), stddev_pop(x), stddev_samp(x) + from (select random() as x from range(0,n)) +); + +from basics(100) +union all from basics(1000) +union all from basics(10000) +union all from basics(1000000000); + +with cte as (select random() as x from range(0,100)) +from histogram(cte, x) ; diff --git a/Task/Statistics-Basic/Maxima/statistics-basic.maxima b/Task/Statistics-Basic/Maxima/statistics-basic.maxima new file mode 100644 index 0000000000..b3ff47633e --- /dev/null +++ b/Task/Statistics-Basic/Maxima/statistics-basic.maxima @@ -0,0 +1,10 @@ +load("descriptive")$ +gen_sample(n) := makelist(random(1.0), n)$ +test_samples: map(gen_sample, [100, 1000, 10000])$ + +map(mean, test_samples); +map(std, test_samples); + +histogram(test_samples[1])$ +histogram(test_samples[2])$ +histogram(test_samples[3])$ diff --git a/Task/Stem-and-leaf-plot/Prolog/stem-and-leaf-plot.pro b/Task/Stem-and-leaf-plot/Prolog/stem-and-leaf-plot.pro new file mode 100644 index 0000000000..acc16b92c5 --- /dev/null +++ b/Task/Stem-and-leaf-plot/Prolog/stem-and-leaf-plot.pro @@ -0,0 +1,37 @@ +:- initialization(main, main). +:- use_module(library(dcg/basics), [blanks/2, eol/2, integer/3]). +:- use_module(library(dcg/high_order), [sequence/4, sequence/5]). + +%! numbers_to_stem_leaves(+Numbers, -StemLeaves) is det. +% Converts a list of Numbers to a list of Stem-Leaves pairs. +numbers_to_stem_leaves(Numbers, StemLeaves) :- + findall(Stem - Leaves, ( + group_by(Stem, Leaf, ( + member(Number, Numbers), + divmod(Number, 10, Stem, Leaf) + ), Leaves0), + msort(Leaves0, Leaves) + ), StemLeaves). + +stem_leaf_plot(StemLeaves) --> sequence(stem_leaves, StemLeaves). + +stem_leaves(Stem - Leaves) --> rpad_integer(4, Stem), " | ", sequence(integer, " ", Leaves), "\n". + +rpad_integer(Pad, N) --> + ( { Pad0 is Pad - 1, N < 10 ^ Pad0, \+ ( Pad = 1, N = 0 ) } + -> " ", rpad_integer(Pad0, N) + ; integer(N) + ). + +%! display_stem_leaf_plot(Numbers) is det. +% Prints the stem-and-leaf plot of a list of Numbers. +display_stem_leaf_plot(Numbers) :- + numbers_to_stem_leaves(Numbers, StemLeaves), + once(phrase(stem_leaf_plot(StemLeaves), Codes)), + format("~s", [Codes]). + +int(N) --> integer(N), blanks. + +main([Filename]) :- + phrase_from_file((blanks, sequence(int, Numbers)), Filename), + display_stem_leaf_plot(Numbers). diff --git a/Task/Stern-Brocot-sequence/Zig/stern-brocot-sequence.zig b/Task/Stern-Brocot-sequence/Zig/stern-brocot-sequence.zig new file mode 100644 index 0000000000..8883a3ef63 --- /dev/null +++ b/Task/Stern-Brocot-sequence/Zig/stern-brocot-sequence.zig @@ -0,0 +1,81 @@ +const std = @import("std"); + +fn gcd(a: u64, b: u64) u64 { + if (b == 0) return a; + return gcd(b, a % b); +} + +fn sternBrocot(allocator: std.mem.Allocator, up_to: u64) !std.ArrayList(u64) { + var seq = std.ArrayList(u64).init(allocator); + try seq.append(1); + try seq.append(1); + + var last: u64 = 1; + var idx: usize = 1; + + while (last < up_to) { + last = seq.items[idx]; + try seq.append(last + seq.items[idx - 1]); + try seq.append(last); + idx += 1; + } + + return seq; +} + +fn testSternBrocot() !void { + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena.deinit(); + const allocator = arena.allocator(); + + var seq = try sternBrocot(allocator, 100); + + // Print first 15 in sequence + std.debug.print("First 15 in sequence: ", .{}); + std.debug.print("[", .{}); + for (seq.items[0..15], 0..) |val, i| { + if (i > 0) std.debug.print(", ", .{}); + std.debug.print("{d}", .{val}); + } + std.debug.print("]\n", .{}); + + // Print first positions of integers 1 through 10 + std.debug.print("First positions of integers 1 through 10:\n", .{}); + for (1..11) |i| { + const i_u64 = @as(u64, i); + var found = false; + for (seq.items, 0..) |val, pos| { + if (val == i_u64) { + std.debug.print(" {d:>2} at position {d}\n", .{i, pos + 1}); + found = true; + break; + } + } + if (!found) { + std.debug.print("Error finding position of {d}\n", .{i}); + } + } + + // Find position of 100 + for (seq.items, 0..) |val, pos| { + if (val == 100) { + std.debug.print(" 100 at position {d}\n", .{pos + 1}); + break; + } + } + + // Check if first 999 consecutive pairs have gcd of 1 + var all_gcd_one = true; + for (1..1000) |i| { + if (i >= seq.items.len) break; + if (gcd(seq.items[i - 1], seq.items[i]) != 1) { + all_gcd_one = false; + break; + } + } + std.debug.print("The first 999 consecutive pairs have gcd of 1: {any}.\n", .{all_gcd_one}); +} + +pub fn main() !void { + try testSternBrocot(); +} diff --git a/Task/Straddling-checkerboard/EasyLang/straddling-checkerboard.easy b/Task/Straddling-checkerboard/EasyLang/straddling-checkerboard.easy new file mode 100644 index 0000000000..796a84f3f6 --- /dev/null +++ b/Task/Straddling-checkerboard/EasyLang/straddling-checkerboard.easy @@ -0,0 +1,73 @@ +board$ = "ET AON RISBCDFGHJKLMPQ/UVWXYZ." +len encode[] 128 +len decode$[] 128 +arrbase encode[] 0 +arrbase decode$[] 0 +len row[] 2 +proc init s$ . + s$[] = strchars s$ + for i = 1 to 30 + if s$[i] = " " + if row[1] = 0 + row[1] = i - 1 + else + row[2] = i - 1 + . + else + code = 0 + if i > 20 + code = row[2] + elif i > 10 + code = row[1] + . + code = code * 10 + (i - 1) mod 10 + encode[strcode s$[i]] = code + decode$[code] = s$[i] + . + . +. +func$ encipher in$ . + for c$ in strchars in$ + c = strcode c$ + if c >= 48 and c <= 57 + code = encode[strcode "."] + r$ &= code + r$ &= c$ + else + c = bitand c 0xdf + if c <> 0 + if c >= 65 and c <= 90 + code = encode[c] + else + code = encode[strcode "/"] + . + r$ &= code + . + . + . + return r$ +. +func$ decipher in$ . + in$[] = strchars in$ + for i to len in$[] + c$ = in$[i] + c = strcode c$ - 48 + if c = row[1] or c = row[2] + i += 1 + c = c * 10 + strcode in$[i] - 48 + . + c$ = decode$[c] + if c$ = "." + i += 1 + c$ = in$[i] + . + r$ &= c$ + . + return r$ +. +init board$ +msg$ = "In the winter 1965/we were hungry/just barely alive" +print msg$ +ciph$ = encipher msg$ +print ciph$ +print decipher ciph$ diff --git a/Task/String-append/ArkScript/string-append.ark b/Task/String-append/ArkScript/string-append.ark new file mode 100644 index 0000000000..19856313f3 --- /dev/null +++ b/Task/String-append/ArkScript/string-append.ark @@ -0,0 +1,2 @@ +(let s "12345678") +(print (+ s "9!")) diff --git a/Task/String-append/DuckDB/string-append-1.duckdb b/Task/String-append/DuckDB/string-append-1.duckdb new file mode 100644 index 0000000000..3de0351a7b --- /dev/null +++ b/Task/String-append/DuckDB/string-append-1.duckdb @@ -0,0 +1,8 @@ +with recursive t(i, s) as ( + select 0, 'foo' + union all + select i+1, s || 'bar' + from t + where i < 1) +select last(s order by i) as s +from t; diff --git a/Task/String-append/DuckDB/string-append-2.duckdb b/Task/String-append/DuckDB/string-append-2.duckdb new file mode 100644 index 0000000000..0a2fcf1c67 --- /dev/null +++ b/Task/String-append/DuckDB/string-append-2.duckdb @@ -0,0 +1,2 @@ +set variable s = 'Hello'; +set variable s = getvariable('s') || ' world'; diff --git a/Task/String-case/ArkScript/string-case.ark b/Task/String-case/ArkScript/string-case.ark new file mode 100644 index 0000000000..df08409105 --- /dev/null +++ b/Task/String-case/ArkScript/string-case.ark @@ -0,0 +1,5 @@ +(import std.String) + +(let s "alphaBETA") +(print (string:toUpper s)) +(print (string:toLower s)) diff --git a/Task/String-case/DuckDB/string-case.duckdb b/Task/String-case/DuckDB/string-case.duckdb new file mode 100644 index 0000000000..5a95354989 --- /dev/null +++ b/Task/String-case/DuckDB/string-case.duckdb @@ -0,0 +1 @@ +select 'alphaBETA' as s, lower(s), upper(s); diff --git a/Task/String-comparison/DuckDB/string-comparison.duckdb b/Task/String-comparison/DuckDB/string-comparison.duckdb new file mode 100644 index 0000000000..052f767117 --- /dev/null +++ b/Task/String-comparison/DuckDB/string-comparison.duckdb @@ -0,0 +1,10 @@ +select s, + t, + s == t, + s != t, + s < t, + s > t, + upper(s) = upper(uppers) as "case insenstive", + '2' < '1e10', + s ilike uppers +from (select 'abc' as s, 'def' as t, 'ABC' as uppers ); diff --git a/Task/String-concatenation/ArkScript/string-concatenation.ark b/Task/String-concatenation/ArkScript/string-concatenation.ark new file mode 100644 index 0000000000..24485a7056 --- /dev/null +++ b/Task/String-concatenation/ArkScript/string-concatenation.ark @@ -0,0 +1,6 @@ +(let s "hello") +(print (+ s " world!")) + +(let w " there") +(let v (+ s w)) +(print v) diff --git a/Task/String-concatenation/Prolog/string-concatenation.pro b/Task/String-concatenation/Prolog/string-concatenation.pro new file mode 100644 index 0000000000..96ca451636 --- /dev/null +++ b/Task/String-concatenation/Prolog/string-concatenation.pro @@ -0,0 +1,9 @@ +:- set_prolog_flag(double_quotes, chars). + +println([]) :- write('\n'). +println([Char | Chars]) :- write(Char), println(Chars). + +:- S0 = "Hello, ", + S1 = "world!", + append(S0, S1, S), + println(S). diff --git a/Task/String-concatenation/Tcl/string-concatenation-3.tcl b/Task/String-concatenation/Tcl/string-concatenation-3.tcl new file mode 100644 index 0000000000..d98b4783f1 --- /dev/null +++ b/Task/String-concatenation/Tcl/string-concatenation-3.tcl @@ -0,0 +1,6 @@ +set s "Hello" +set w "World" +set hw "$s $w" ; # "hello world" +set hw [concat $s $w] ; # {hello world}, same as above +set hw [string cat $s $w] ; # "helloworld" +set hw [join [list $s $w] " "] ; # "hello world" \w space delimiter diff --git a/Task/String-interpolation-included-/ArkScript/string-interpolation-included-.ark b/Task/String-interpolation-included-/ArkScript/string-interpolation-included-.ark new file mode 100644 index 0000000000..87c666c268 --- /dev/null +++ b/Task/String-interpolation-included-/ArkScript/string-interpolation-included-.ark @@ -0,0 +1,4 @@ +(print (string:format "Mary had a {} lamb." "little")) + +(let replacement "medium-sized") +(print (string:format "Mary had a {} lamb." replacement)) diff --git a/Task/String-interpolation-included-/Crystal/string-interpolation-included-.cr b/Task/String-interpolation-included-/Crystal/string-interpolation-included-.cr new file mode 100644 index 0000000000..82a646236f --- /dev/null +++ b/Task/String-interpolation-included-/Crystal/string-interpolation-included-.cr @@ -0,0 +1,6 @@ +icr:1> extra = "little" + => "little" +icr:2> "Mary had a #{extra} lamb" + => "Mary had a little lamb" +icr:3> "Mary had a %s lamb" % extra + => "Mary had a little lamb" diff --git a/Task/String-interpolation-included-/DuckDB/string-interpolation-included-.duckdb b/Task/String-interpolation-included-/DuckDB/string-interpolation-included-.duckdb new file mode 100644 index 0000000000..d44ba7106b --- /dev/null +++ b/Task/String-interpolation-included-/DuckDB/string-interpolation-included-.duckdb @@ -0,0 +1 @@ +select replace( 'Mary had a , lamb.', '', getvariable('adjective')); diff --git a/Task/String-interpolation-included-/PascalABC.NET/string-interpolation-included-.pas b/Task/String-interpolation-included-/PascalABC.NET/string-interpolation-included-.pas index 8bb50800b2..ad45cd88fd 100644 --- a/Task/String-interpolation-included-/PascalABC.NET/string-interpolation-included-.pas +++ b/Task/String-interpolation-included-/PascalABC.NET/string-interpolation-included-.pas @@ -1,3 +1,3 @@ -var extra := 'little'; +## var extra := 'little'; var formatted := $'Mary has a {extra} lamb.'; Print(formatted); diff --git a/Task/String-interpolation-included-/Pluto/string-interpolation-included-.pluto b/Task/String-interpolation-included-/Pluto/string-interpolation-included-.pluto new file mode 100644 index 0000000000..bc2475bac6 --- /dev/null +++ b/Task/String-interpolation-included-/Pluto/string-interpolation-included-.pluto @@ -0,0 +1,3 @@ +local adjective = "little" +local sentence = $"Mary had a {adjective} lamb" +print(sentence) diff --git a/Task/String-interpolation-included-/R/string-interpolation-included-.r b/Task/String-interpolation-included-/R/string-interpolation-included-.r new file mode 100644 index 0000000000..f34371c1b4 --- /dev/null +++ b/Task/String-interpolation-included-/R/string-interpolation-included-.r @@ -0,0 +1,2 @@ +adj <- "little" +sprintf("Mary had a %s lamb", adj) diff --git a/Task/String-length/ArkScript/string-length.ark b/Task/String-length/ArkScript/string-length.ark new file mode 100644 index 0000000000..be20734ba6 --- /dev/null +++ b/Task/String-length/ArkScript/string-length.ark @@ -0,0 +1 @@ +(print (len "åéèàâêç")) diff --git a/Task/String-length/DuckDB/string-length.duckdb b/Task/String-length/DuckDB/string-length.duckdb new file mode 100644 index 0000000000..3f34f5d47d --- /dev/null +++ b/Task/String-length/DuckDB/string-length.duckdb @@ -0,0 +1,2 @@ +select s, length(s), strlen(s) as '# bytes' from + (select unnest(['J̲o̲s̲é̲', '𝔘𝔫𝔦𝔠𝔬𝔡𝔢']) as s); diff --git a/Task/String-length/FutureBasic/string-length.basic b/Task/String-length/FutureBasic/string-length.basic new file mode 100644 index 0000000000..10db65c468 --- /dev/null +++ b/Task/String-length/FutureBasic/string-length.basic @@ -0,0 +1,17 @@ +CFStringRef s + +s = @"møøse" +printf @"\"%@\"",s +print @"character length:",len(s) +print @"unicode length:",,len(s,_kLenUnicode) +print @"byte length UTF8:",len(s,_kLenBytesUTF8) +print @"byte length UTF16:",len(s,_kLenBytesUTF16) + +print + +s = @"𝔘𝔫𝔦𝔠𝔬𝔡𝔢" +printf @"\"%@\"",s +print @"character length:",len(s) +print @"unicode length:",,len(s,_kLenUnicode) +print @"byte length UTF8:",len(s,_kLenBytesUTF8) +print @"byte length UTF16:",len(s,_kLenBytesUTF16) diff --git a/Task/String-length/Pluto/string-length.pluto b/Task/String-length/Pluto/string-length.pluto new file mode 100644 index 0000000000..ea7a1d954b --- /dev/null +++ b/Task/String-length/Pluto/string-length.pluto @@ -0,0 +1,12 @@ +require "gchar" +local fmt = require "fmt" + +local moose = "møøse" +local unicode = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢" +local jose = "J\u{332}o\u{332}s\u{332}e\u{301}\u{332}" + +local f = "%5s %7s %5s" +fmt.print("Strings : " .. f, moose, unicode, jose) +fmt.print("\nBytes : " .. f, #moose, #unicode, #jose) +fmt.print("\nCodepoints: " .. f, utf8.len(moose), utf8.len(unicode), utf8.len(jose)) +fmt.print("\nGraphemes : " .. f, gchar.of(moose):len(), gchar.of(unicode):len(), gchar.of(jose):len()) diff --git a/Task/String-length/TAV/string-length.tav b/Task/String-length/TAV/string-length.tav new file mode 100644 index 0000000000..b25087178d --- /dev/null +++ b/Task/String-length/TAV/string-length.tav @@ -0,0 +1,6 @@ + s =: "𝔘𝔫𝔦𝔠𝔬𝔡𝔢" + print (quote s), s.Count, s.Bytes + s =: "José&e10;" + print (quote s), s.Count, s.Bytes + s =: "J̲o̲s̲é̲" + print (quote s), s.Count, s.Bytes diff --git a/Task/String-length/Wren/string-length-1.wren b/Task/String-length/Wren/string-length-1.wren index 303227ac8f..ca90697ca5 100644 --- a/Task/String-length/Wren/string-length-1.wren +++ b/Task/String-length/Wren/string-length-1.wren @@ -1,3 +1,4 @@ System.print("møøse".bytes.count) System.print("𝔘𝔫𝔦𝔠𝔬𝔡𝔢".bytes.count) -System.print("J̲o̲s̲é̲".bytes.count) +var jose = "J\u0332o\u0332s\u0332e\u0301\u0332" +System.print(jose.bytes.count) diff --git a/Task/String-length/Wren/string-length-2.wren b/Task/String-length/Wren/string-length-2.wren index 5daeb0b24c..edf949d867 100644 --- a/Task/String-length/Wren/string-length-2.wren +++ b/Task/String-length/Wren/string-length-2.wren @@ -1,3 +1,4 @@ System.print("møøse".count) System.print("𝔘𝔫𝔦𝔠𝔬𝔡𝔢".count) -System.print("J̲o̲s̲é̲".count) +var jose = "J\u0332o\u0332s\u0332e\u0301\u0332" +System.print(jose.count) diff --git a/Task/String-length/Wren/string-length-3.wren b/Task/String-length/Wren/string-length-3.wren index 333b1fc9b8..e89f0a995a 100644 --- a/Task/String-length/Wren/string-length-3.wren +++ b/Task/String-length/Wren/string-length-3.wren @@ -2,4 +2,5 @@ import "./upc" for Graphemes System.print(Graphemes.clusterCount("møøse")) System.print(Graphemes.clusterCount("𝔘𝔫𝔦𝔠𝔬𝔡𝔢")) -System.print(Graphemes.clusterCount("J̲o̲s̲é̲")) +var jose = "J\u0332o\u0332s\u0332e\u0301\u0332" +System.print(Graphemes.clusterCount(jose)) diff --git a/Task/String-matching/ArkScript/string-matching.ark b/Task/String-matching/ArkScript/string-matching.ark new file mode 100644 index 0000000000..1952605aa1 --- /dev/null +++ b/Task/String-matching/ArkScript/string-matching.ark @@ -0,0 +1,6 @@ +(assert (= 0 (string:find "abcd" "ab")) "abcd starts with ab") +(assert (= 6 (string:find "hello world" "world")) "world is located at 6") +(assert (= -1 (string:find "abcd" "zn")) "abcd does not contain zn") +(assert (= -1 (string:find "abab" "bb")) "abab does not contain bb") +(assert (= 0 (string:find "abab" "ab")) "abab contains ab") +(assert (= 2 (string:find "abab" "ab" 1)) "starting lookup at index 1, we found ab at position 2") diff --git a/Task/String-matching/DuckDB/string-matching.duckdb b/Task/String-matching/DuckDB/string-matching.duckdb new file mode 100644 index 0000000000..09e75c1cd5 --- /dev/null +++ b/Task/String-matching/DuckDB/string-matching.duckdb @@ -0,0 +1,17 @@ +# Return a list of the indices of all occurrences (including overlapping occurrences) +create or replace function string_positions(haystack, needle) as ( + WITH RECURSIVE etc AS ( + SELECT + position(needle IN haystack) AS start_pos, + 0 as s + UNION ALL + SELECT + position(needle IN substr(haystack, start_pos + 1)) + start_pos AS start_pos, + start_pos as s + FROM etc + WHERE start_pos != s + ) + SELECT coalesce(array_agg(start_pos order by start_pos),[]::BIGINT[]) + FROM etc + WHERE start_pos > 0 and s != start_pos +); diff --git a/Task/String-matching/R/string-matching.r b/Task/String-matching/R/string-matching.r new file mode 100644 index 0000000000..214497a816 --- /dev/null +++ b/Task/String-matching/R/string-matching.r @@ -0,0 +1,14 @@ +startsWith("foobar", "foo") +startsWith("barbaz", "bax") +grepl("bar", "foobarqux") #Note order of arguments isn't always the same +grepl("baz", "foobarqux") +endsWith("foobar", "bar") +endsWith("foobar", "baz") + +regexpr("bar", "barbazbarbax") #Only returns position of first match + +regexpr("foo", "barbazbarbax") #Returns -1 if no match exists + +gregexpr("bar", "barbazbarbax") #Returns positions of all matches + +gregexpr("foo", "barbazbarbax") #Same output as regexpr() if no match, but as a length-1 list rather than a vector diff --git a/Task/String-prepend/ArkScript/string-prepend.ark b/Task/String-prepend/ArkScript/string-prepend.ark new file mode 100644 index 0000000000..7b212ed915 --- /dev/null +++ b/Task/String-prepend/ArkScript/string-prepend.ark @@ -0,0 +1,3 @@ +(let s "012345678") +(let v (+ "#~" s)) +(print v) diff --git a/Task/String-prepend/DuckDB/string-prepend-1.duckdb b/Task/String-prepend/DuckDB/string-prepend-1.duckdb new file mode 100644 index 0000000000..102dcdc902 --- /dev/null +++ b/Task/String-prepend/DuckDB/string-prepend-1.duckdb @@ -0,0 +1 @@ +select 'Hello ' || s FROM (select 'world!' as s); diff --git a/Task/String-prepend/DuckDB/string-prepend-2.duckdb b/Task/String-prepend/DuckDB/string-prepend-2.duckdb new file mode 100644 index 0000000000..9f1d92c4f0 --- /dev/null +++ b/Task/String-prepend/DuckDB/string-prepend-2.duckdb @@ -0,0 +1 @@ +select format('{} {}', 'Hello', s) FROM (select 'world!' as s); diff --git a/Task/String-prepend/DuckDB/string-prepend-3.duckdb b/Task/String-prepend/DuckDB/string-prepend-3.duckdb new file mode 100644 index 0000000000..1926a1f04c --- /dev/null +++ b/Task/String-prepend/DuckDB/string-prepend-3.duckdb @@ -0,0 +1,2 @@ +set variable s = 'world!'; +select 'Hello ' || getvariable('s') diff --git a/Task/Strip-a-set-of-characters-from-a-string/DuckDB/strip-a-set-of-characters-from-a-string.duckdb b/Task/Strip-a-set-of-characters-from-a-string/DuckDB/strip-a-set-of-characters-from-a-string.duckdb new file mode 100644 index 0000000000..20c738e7cd --- /dev/null +++ b/Task/Strip-a-set-of-characters-from-a-string/DuckDB/strip-a-set-of-characters-from-a-string.duckdb @@ -0,0 +1,10 @@ +# Omit from `str` each of the characters in `omit` : +create or replace function string_strip(str, omit) as ( + array_to_string( + regexp_split_to_array( + str, + '[' || regexp_escape( omit ) || ']'), '') +); + +# Example: +select string_strip('She was a soul stripper. She took my heart!', 'aei') as translated; diff --git a/Task/Strip-comments-from-a-string/DuckDB/strip-comments-from-a-string.duckdb b/Task/Strip-comments-from-a-string/DuckDB/strip-comments-from-a-string.duckdb new file mode 100644 index 0000000000..1cfe9dbfd7 --- /dev/null +++ b/Task/Strip-comments-from-a-string/DuckDB/strip-comments-from-a-string.duckdb @@ -0,0 +1,16 @@ +# `sep` can be a single character or a string but it will be interpreted +# as part of a regexp within square brackets, so be careful if characters +# such as `-` are used. +create or replace function remove_comment(s, sep) as ( + regexp_replace(s, '\s*[' || sep || '].*', '') +); + +# Examples + +select s, + remove_comment(s, '#') as decommented, + regexp_replace(decommented, ' ', '_','g') as visible +from unnest( + ['apples ; pears # and bananas', + 'apples # pears ; and bananas'] + ) _s(s); diff --git a/Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB/strip-control-codes-and-extended-characters-from-a-string.duckdb b/Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB/strip-control-codes-and-extended-characters-from-a-string.duckdb new file mode 100644 index 0000000000..9b264a1f36 --- /dev/null +++ b/Task/Strip-control-codes-and-extended-characters-from-a-string/DuckDB/strip-control-codes-and-extended-characters-from-a-string.duckdb @@ -0,0 +1,29 @@ +# Produce a list of the unicode values of a string +create or replace function explode(s) as ( + regexp_extract_all(s, '.').list_transform(c -> unicode(c)) +); + +# Produce a string from a list of unicode values +create or replace function implode(lst) as ( + list_transform(lst, c -> chr(c)) + .array_to_string('') +); + +create or replace function strip_control_codes(s) as ( + explode(s) + .list_filter(unicode -> (unicode > 31 and unicode != 127)) + .implode() +); + +create or replace function strip_extended_characters(s) as ( + explode(s) + .list_filter(unicode -> (31 < unicode) and (unicode < 127)) + .implode() +); + +## Example: +set variable string = 'string of ☺☻♥♦⌂, may include control characters such as null (' || chr(0) || ') and other ilk.\n§►↔◄\nRødgrød med fløde'; + +select getvariable('string').strip_control_codes(); + +select getvariable('string').strip_extended_characters(); diff --git a/Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB/strip-whitespace-from-a-string-top-and-tail.duckdb b/Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB/strip-whitespace-from-a-string-top-and-tail.duckdb new file mode 100644 index 0000000000..a91d7fab66 --- /dev/null +++ b/Task/Strip-whitespace-from-a-string-Top-and-tail/DuckDB/strip-whitespace-from-a-string-top-and-tail.duckdb @@ -0,0 +1,27 @@ +create or replace function lstrip(s) as ( + select regexp_replace(s, '^[\s\p{Cc}]+', '', 'g' ) +); + +# p{Cc} == "Other, control" +create or replace function rstrip(s) as ( + select regexp_replace(s, '[\s\p{Cc}]+$', '', 'g' ) +); + +create or replace function strip(s) as ( + select lstrip(s).rstrip() +); + +# Examples: + +create or replace function demo() as table ( + select s, lstrip(s), rstrip(s), strip(s), length(s), length(strip(s)) + from unnest([ + ' ' || chr(9) || ' ' || chr(13) || ' ' || chr(10) || ' String with leading spaces \t \r \n ', + chr(1) || ' <- control A', + (chr(1) || ' ' || chr(2) || ' <- ^A ^B' ) + ]) _(s) +); + +.mode line +.columns +from demo(); diff --git a/Task/Substitution-cipher/Rust/substitution-cipher.rs b/Task/Substitution-cipher/Rust/substitution-cipher.rs new file mode 100644 index 0000000000..e7dc53105a --- /dev/null +++ b/Task/Substitution-cipher/Rust/substitution-cipher.rs @@ -0,0 +1,25 @@ +fn main() { + let key = "]kYV}(!7P$n5_0i R:?jOWtF/=-pe'AD&@r6%ZXs\"v*N[#wSl9zq2^+g;LoB`aGh{3.HIu4fbK)mU8|dMET><,Qc\\C1yxJ"; + + let s = "The quick brown fox jumps over the lazy dog, who barks VERY loudly!"; + let enc = encode(s, key); + println!("Encoded: {}", enc); + println!("Decoded: {}", decode(&enc, key)); +} + +fn encode(s: &str, key: &str) -> String { + let key_bytes = key.as_bytes(); + s.bytes() + .map(|b| key_bytes[(b as usize) - 32] as char) + .collect() +} + +fn decode(s: &str, key: &str) -> String { + let key_bytes = key.as_bytes(); + s.bytes() + .map(|b| { + let index = key_bytes.iter().position(|&k| k == b).unwrap(); + (index + 32) as u8 as char + }) + .collect() +} diff --git a/Task/Substring-Top-and-tail/Maxima/substring-top-and-tail.maxima b/Task/Substring-Top-and-tail/Maxima/substring-top-and-tail.maxima new file mode 100644 index 0000000000..6f00e14a51 --- /dev/null +++ b/Task/Substring-Top-and-tail/Maxima/substring-top-and-tail.maxima @@ -0,0 +1,5 @@ +load("stringproc")$ +top(s) := substring(s, 2)$ +tail(s) := substring(s, 1, slength(s))$ +top_and_tail(s) := substring(s, 2, slength(s))$ +map(lambda([f], f("xyzzy")), [top, tail, top_and_tail]); diff --git a/Task/Substring-Top-and-tail/R/substring-top-and-tail.r b/Task/Substring-Top-and-tail/R/substring-top-and-tail.r new file mode 100644 index 0000000000..3e4673d02e --- /dev/null +++ b/Task/Substring-Top-and-tail/R/substring-top-and-tail.r @@ -0,0 +1,4 @@ +top_and_tail <- function(s, top=TRUE, tail=TRUE) substr(s, 1+top, nchar(s)-tail) +top_and_tail("xyzzy") +top_and_tail("xyzzy", top=FALSE) +top_and_tail("xyzzy", tail=FALSE) diff --git a/Task/Substring/DuckDB/substring.duckdb b/Task/Substring/DuckDB/substring.duckdb new file mode 100644 index 0000000000..f03d8182ff --- /dev/null +++ b/Task/Substring/DuckDB/substring.duckdb @@ -0,0 +1,20 @@ +# For brevity, we will use a table-valued function for defining the sample string(s): +create or replace function s() as table (select '一二三四五六七八九十' as s); + +# starting from n characters in and of m length: s[n: n+m-1] +select s[1:2] from s(); + +# starting from n characters in, up to the end of the string: s[n:] +select s[9:] from s(); + +# whole string minus the last character: .[:-2] +select s[0:-2] from s(); + +# starting from a known character within the string and of m length, say 2: +select s[ix:ix+(2-1)] from (select s, position('五' in s) as ix from s()); + +# starting from a known substring within the string and of m length, say 2: +select s[ix:ix+(2-1)] from (select s, position('五六' in s) as ix from s()); + +# For clarity we'll use DuckDB's 'list' output mode: +.mode list diff --git a/Task/Sudoku/DuckDB/sudoku.duckdb b/Task/Sudoku/DuckDB/sudoku.duckdb new file mode 100644 index 0000000000..4ea141d510 --- /dev/null +++ b/Task/Sudoku/DuckDB/sudoku.duckdb @@ -0,0 +1,40 @@ +# An example +.maxwidth 100 +set variable game='85 24 72 9 4 1 7 23 5 9 4 8 7 17 36 4 '; + +create or replace function instr3(s,t,j) as ( + select case when n = 0 then 0 + else n + j - 1 + end + from (select instr(substr(s,j), t) as n) +); + +with recursive + symbols (d) as (select level::VARCHAR from range(1,10) t(level) ) +, board (i) as (select level from range(1,82) t(level) ) +, neighbors (i, j) as ( + select b1.i, b2.i + from board b1 inner join board b2 + on b1.i != b2.i + and ( + mod(b1.i - b2.i, 9) = 0 + or ceil(b1.i / 9) = ceil(b2.i / 9) + or ceil(b1.i / 27) = ceil(b2.i / 27) and trunc(mod(b1.i - 1, 9) / 3) = trunc(mod(b2.i - 1, 9) / 3) + ) + ) +, r (str, pos) as ( + select getvariable('game'), instr(getvariable('game'), ' ') + + union all + select substr(r.str, 1, r.pos - 1) || s.d || substr(r.str, r.pos + 1), instr3(r.str, ' ', r.pos + 1) + from r inner join symbols s + on r.pos > 0 and not exists ( + select * + from neighbors n + where r.pos = n.i and s.d = substr(r.str, n.j, 1) + ) + ) +select str +from r +where pos = 0 +; diff --git a/Task/Sudoku/Zig/sudoku.zig b/Task/Sudoku/Zig/sudoku.zig new file mode 100644 index 0000000000..ece9ae2db5 --- /dev/null +++ b/Task/Sudoku/Zig/sudoku.zig @@ -0,0 +1,104 @@ +const std = @import("std"); + +const Sudoku = [81]u8; + +fn isValid(val: u8, x: usize, y: usize, sudokuAr: *Sudoku) bool { + // Check row and column + for (0..9) |i| { + if (sudokuAr[y * 9 + i] == val or sudokuAr[i * 9 + x] == val) { + return false; + } + } + + // Check 3x3 box + const startX = (x / 3) * 3; + const startY = (y / 3) * 3; + + for (startY..startY + 3) |i| { + for (startX..startX + 3) |j| { + if (sudokuAr[i * 9 + j] == val) { + return false; + } + } + } + + return true; +} + +fn placeNumber(pos: usize, sudokuAr: *Sudoku) bool { + var currentPos: usize = pos; + + // Find next empty cell + while (currentPos < 81 and sudokuAr[currentPos] != 0) { + currentPos += 1; + } + + // If no empty cells, puzzle is solved + if (currentPos >= 81) { + return true; + } + + const x = currentPos % 9; + const y = currentPos / 9; + + // Try placing digits 1-9 + for (1..10) |n| { + if (isValid(@intCast(n), x, y, sudokuAr)) { + sudokuAr[currentPos] = @intCast(n); + + if (placeNumber(currentPos + 1, sudokuAr)) { + return true; + } + + // Backtrack + sudokuAr[currentPos] = 0; + } + } + + return false; +} + +fn prettyPrint(sudokuAr: Sudoku) void { + const lineSep = "------+-------+------"; + std.debug.print("{s}\n", .{lineSep}); + + for (0..81) |i| { + std.debug.print("{d} ", .{sudokuAr[i]}); + + if ((i + 1) % 3 == 0 and (i + 1) % 9 != 0) { + std.debug.print("| ", .{}); + } + + if ((i + 1) % 9 == 0) { + std.debug.print("\n", .{}); + } + + if ((i + 1) % 27 == 0) { + std.debug.print("{s}\n", .{lineSep}); + } + } +} + +fn solve(sudokuAr: *Sudoku) bool { + return placeNumber(0, sudokuAr); +} + +pub fn main() !void { + var sudokuAr: Sudoku = [_]u8{ + 8, 5, 0, 0, 0, 2, 4, 0, 0, + 7, 2, 0, 0, 0, 0, 0, 0, 9, + 0, 0, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 7, 0, 0, 2, + 3, 0, 5, 0, 0, 0, 9, 0, 0, + 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 0, 0, 7, 0, + 0, 1, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 6, 0, 4, 0 + }; + + if (solve(&sudokuAr)) { + prettyPrint(sudokuAr); + } else { + std.debug.print("Unsolvable\n", .{}); + } +} diff --git a/Task/Sum-and-product-of-an-array/ArkScript/sum-and-product-of-an-array.ark b/Task/Sum-and-product-of-an-array/ArkScript/sum-and-product-of-an-array.ark new file mode 100644 index 0000000000..c205a3fb07 --- /dev/null +++ b/Task/Sum-and-product-of-an-array/ArkScript/sum-and-product-of-an-array.ark @@ -0,0 +1,9 @@ +(import std.List :sum :product :reduce) + +(let array [1 2 3 4]) + +(assert (= (sum array) 10) "sum of array is 10") +(assert (= (reduce array (fun (a b) (+ a b))) 10) "reduction of array with + is 10") + +(assert (= (product array) 24) "product of array is 24") +(assert (= (reduce array (fun (a b) (* a b))) 24) "reduction of array with * is 24") diff --git a/Task/Sum-and-product-of-an-array/DuckDB/sum-and-product-of-an-array.duckdb b/Task/Sum-and-product-of-an-array/DuckDB/sum-and-product-of-an-array.duckdb new file mode 100644 index 0000000000..79201c9fdb --- /dev/null +++ b/Task/Sum-and-product-of-an-array/DuckDB/sum-and-product-of-an-array.duckdb @@ -0,0 +1,4 @@ +create or replace function product(lst) as list_reduce(lst, (acc,x) -> acc*x); + +# 10! +select range(1,11).product(); diff --git a/Task/Sum-and-product-of-an-array/Haskell/sum-and-product-of-an-array-2.hs b/Task/Sum-and-product-of-an-array/Haskell/sum-and-product-of-an-array-2.hs index b69401289e..b30df6a4bf 100644 --- a/Task/Sum-and-product-of-an-array/Haskell/sum-and-product-of-an-array-2.hs +++ b/Task/Sum-and-product-of-an-array/Haskell/sum-and-product-of-an-array-2.hs @@ -1,10 +1,6 @@ main :: IO () main = - mapM_ - print - ( fmap - ($ [1 .. 10]) - [ foldr (+) 0, - foldr (*) 1 - ] - ) + mapM_ print $ + [ foldr (+) 0, + foldr (*) 1 + ] <*> [[1 .. 10]] diff --git a/Task/Sum-and-product-of-an-array/REXX/sum-and-product-of-an-array.rexx b/Task/Sum-and-product-of-an-array/REXX/sum-and-product-of-an-array.rexx index f9b04f5931..e81fef6879 100644 --- a/Task/Sum-and-product-of-an-array/REXX/sum-and-product-of-an-array.rexx +++ b/Task/Sum-and-product-of-an-array/REXX/sum-and-product-of-an-array.rexx @@ -1,17 +1,16 @@ -/*REXX program adds and multiplies N elements of a (populated) array @. */ -numeric digits 200 /*200 decimal digit #s (default is 9).*/ +/*REXX program adds and multiplies N elements of a (populated) array x. */ +numeric digits 100 /*100 decimal digit #s (default is 9).*/ parse arg N .; if N=='' then N=20 /*Not specified? Then use the default.*/ - do j=1 for N /*build array of N elements (or 20?).*/ - @.j=j /*set 1st to 1, 3rd to 3, 8th to 8 ··· */ - end /*j*/ +do j=1 for N /*build array of N elements (or 20?).*/ + x.j=j /*set 1st to 1, 3rd to 3, 8th to 8 ··· */ + end /*j*/ sum=0 /*initialize SUM (variable) to zero. */ -prod=1 /*initialize PROD (variable) to unity.*/ - do k=1 for N - sum = sum + @.k /*add the element to the running total.*/ - prod = prod * @.k /*multiply element to running product. */ - end /*k*/ /* [↑] this pgm: same as N factorial.*/ +prod=1 /*initialize PROD (variable) to one */ +do k=1 for N + sum = sum + x.k /*add the element to the running total.*/ + prod = prod * x.k /*multiply element to running product. */ + end /*k*/ /* [?] this pgm: same as N factorial.*/ -say ' sum of ' m " elements for the @ array is: " sum -say ' product of ' m " elements for the @ array is: " prod - /*stick a fork in it, we're all done. */ +say ' sum of ' N ' elements for the x array is: ' sum +say ' product of ' N ' elements for the x array is: ' prod diff --git a/Task/Sum-digits-of-an-integer/ArkScript/sum-digits-of-an-integer.ark b/Task/Sum-digits-of-an-integer/ArkScript/sum-digits-of-an-integer.ark new file mode 100644 index 0000000000..6e12836de0 --- /dev/null +++ b/Task/Sum-digits-of-an-integer/ArkScript/sum-digits-of-an-integer.ark @@ -0,0 +1,27 @@ +(import std.List) +(import std.String) + +(let to-base (fun (n base) { + (let o (string:ord n)) + + (let v + (if (and (>= o 48) (<= o 57)) + (- o 48) + (if (and (>= o 97) (<= o 122)) + (- o 87) + (if (and (>= o 65) (<= o 90)) + (- o 55) + o)))) + (mod v base) })) + +(let sum-digits (fun (n base) { + (let number + (if (not (= "String" (type n))) + (toString n) + n)) + (list:reduce (list:map number (fun (e) (to-base e base))) (fun (a b) (+ a b))) })) + +(assert (= (sum-digits 1 10) 1) "sum of digits in 10 (base 10) is 1") +(assert (= (sum-digits 1234 10) 10) "sum of digits in 1234 (base 10) is 10") +(assert (= (sum-digits "fe" 16) 29) "sum of digits in fe (base 16) is 29") +(assert (= (sum-digits "f0e" 16) 29) "sum of digits in f0e (base 16) is 29") diff --git a/Task/Sum-digits-of-an-integer/DuckDB/sum-digits-of-an-integer.duckdb b/Task/Sum-digits-of-an-integer/DuckDB/sum-digits-of-an-integer.duckdb new file mode 100644 index 0000000000..71763bc719 --- /dev/null +++ b/Task/Sum-digits-of-an-integer/DuckDB/sum-digits-of-an-integer.duckdb @@ -0,0 +1,24 @@ +create or replace function number_sum_of_digits(i) as ( + with characters as (select unnest( regexp_extract_all(i::VARCHAR, '[0-9]')) as c) + select sum(c::uint8) from characters +); + +create or replace function string_sum_of_digits(str) as ( + with characters as (select unnest( regexp_extract_all(str::VARCHAR, '[0-9a-zA-Z]')) as c), + numbers as (select ascii(c) as a from characters) + select sum( + case when a < 65 then a - 48 -- 0 => 48 + when a < 97 then a - 55 -- A => 65 + else a - 87 -- a => 97 + end ) from numbers +); + +create or replace function sum_of_digits(x) as ( + case when typeof(x) = 'VARCHAR' then string_sum_of_digits(x) + else number_sum_of_digits(x) + end +); + +select sum_of_digits('f0E') = 29; +select sum_of_digits(1234) = 10; +select sum_of_digits(1.2e-34) = 10; diff --git a/Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer.pas b/Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-1.pas similarity index 100% rename from Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer.pas rename to Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-1.pas diff --git a/Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-2.pas b/Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-2.pas new file mode 100644 index 0000000000..c3f0e5746f --- /dev/null +++ b/Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer-2.pas @@ -0,0 +1,8 @@ +//Modern way: +uses School; +begin + 1.digits.Sum.print; + 1234.digits.Sum.print; + $FE.digits(16).Sum.print; + $F0E.digits(16).Sum.print; +end. diff --git a/Task/Sum-digits-of-an-integer/Pluto/sum-digits-of-an-integer.pluto b/Task/Sum-digits-of-an-integer/Pluto/sum-digits-of-an-integer.pluto new file mode 100644 index 0000000000..4eab399a53 --- /dev/null +++ b/Task/Sum-digits-of-an-integer/Pluto/sum-digits-of-an-integer.pluto @@ -0,0 +1,10 @@ +local int = require("int") +local fmt = require("fmt") + +local tests = { {1, 10}, {1234, 10}, {0xfe, 16}, {0xf0e, 16}, {1411, 8}, {111, 3} } +print("The sum of the digits is: ") +for tests as test do + local [n, b] = test + local sum = int.digstat(n, b)[2] + fmt.print("%-5s in base %2d = %2d", fmt.itoa(n, b), b, sum) +end diff --git a/Task/Sum-multiples-of-3-and-5/DuckDB/sum-multiples-of-3-and-5.duckdb b/Task/Sum-multiples-of-3-and-5/DuckDB/sum-multiples-of-3-and-5.duckdb new file mode 100644 index 0000000000..beda2f0d20 --- /dev/null +++ b/Task/Sum-multiples-of-3-and-5/DuckDB/sum-multiples-of-3-and-5.duckdb @@ -0,0 +1,9 @@ +create or replace function sum_multiples(n, d) as ( + select sum + from (select (n // d) as a, (d * a * (a+1)) // 2 as sum) +); + +# Sum of multiples of a or b that are less than n +create or replace function task(n, a, b) as ( + (n - 1).sum_multiples(a) + (n-1).sum_multiples(b) - (n-1).sum_multiples(a*b) +); diff --git a/Task/Sum-of-a-series/ArkScript/sum-of-a-series.ark b/Task/Sum-of-a-series/ArkScript/sum-of-a-series.ark new file mode 100644 index 0000000000..f99703db88 --- /dev/null +++ b/Task/Sum-of-a-series/ArkScript/sum-of-a-series.ark @@ -0,0 +1,9 @@ +(import std.Range :range :map) +(import std.List :sum) + +(let r (range 1 1000)) +(let sol (sum (map r (fun (x) (/ 1 (* x x)))))) + +(import std.Math :abs) + +(assert (< (abs (- sol 1.64493406685)) 0.0011) "S1000(2) is near Pi^2/6") diff --git a/Task/Sum-of-a-series/DuckDB/sum-of-a-series-1.duckdb b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-1.duckdb new file mode 100644 index 0000000000..05207a4f7f --- /dev/null +++ b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-1.duckdb @@ -0,0 +1 @@ +select list_sum( list_transform(range(1,1001), i -> 1 / (i*i))); diff --git a/Task/Sum-of-a-series/DuckDB/sum-of-a-series-2.duckdb b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-2.duckdb new file mode 100644 index 0000000000..eb55ed03f0 --- /dev/null +++ b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-2.duckdb @@ -0,0 +1,4 @@ +create or replace function s(n) as ( +select list_sum( list_transform(range(1,n+1), i -> 1 / (i*i))); + +select s(1000); diff --git a/Task/Sum-of-a-series/DuckDB/sum-of-a-series-3.duckdb b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-3.duckdb new file mode 100644 index 0000000000..560b1760cd --- /dev/null +++ b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-3.duckdb @@ -0,0 +1,7 @@ +create or replace function f(i) as (1 / (i*i)); + +create or replace function s(n) as ( + list_sum( list_transform(range(1,n+1), i -> f(i))) +); + +select s(1000); diff --git a/Task/Sum-of-a-series/DuckDB/sum-of-a-series-4.duckdb b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-4.duckdb new file mode 100644 index 0000000000..f43705e60e --- /dev/null +++ b/Task/Sum-of-a-series/DuckDB/sum-of-a-series-4.duckdb @@ -0,0 +1,5 @@ +create or replace function s(n) as ( + select sum(x) from (select (1 / (i*i)) as x from range(1,1+n) _(i) ) + ); + +select s(1000); diff --git a/Task/Sum-of-a-series/FutureBasic/sum-of-a-series.basic b/Task/Sum-of-a-series/FutureBasic/sum-of-a-series.basic new file mode 100644 index 0000000000..6bb0bc0e66 --- /dev/null +++ b/Task/Sum-of-a-series/FutureBasic/sum-of-a-series.basic @@ -0,0 +1,12 @@ +double local fn SumOfSeries( n as UInt32 ) + if n == 0 then return 0 + double sum = 0 + for int i = 1 to n + sum += 1.0 / i^2 + next +end fn = sum + +printf @"Precise sum: %.15f", fn SumOfSeries( 1000 ) +printf @"Approximate: %.15f", M_PI * M_PI / 6 + +HandleEvents diff --git a/Task/Sum-of-a-series/Tcl/sum-of-a-series-1.tcl b/Task/Sum-of-a-series/Tcl/sum-of-a-series-1.tcl index 673b50e055..281ff7b1bf 100644 --- a/Task/Sum-of-a-series/Tcl/sum-of-a-series-1.tcl +++ b/Task/Sum-of-a-series/Tcl/sum-of-a-series-1.tcl @@ -1,6 +1,9 @@ package require Tcl 8.5 namespace path {::tcl::mathop ::tcl::} ;# Ease of access to mathop commands -proc lsum_series {l} {+ {*}[lmap n $l {/ [** $n 2]}]} ;# an expr would be clearer, but this is a demonstration of mathop +# an expr would be clearer, +# but this is a demonstration of mathop + +proc lsum_series {l} {+ {*}[lmap n $l {/ [** $n 2]}]} # using range function defined below lsum_series [range 1 1001] ;# ==> 1.6439345666815615 diff --git a/Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena/sum-of-elements-below-main-diagonal-of-matrix.agena b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena/sum-of-elements-below-main-diagonal-of-matrix.agena new file mode 100644 index 0000000000..dec46aabf3 --- /dev/null +++ b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Agena/sum-of-elements-below-main-diagonal-of-matrix.agena @@ -0,0 +1,28 @@ +scope # sum the elements below the main diagonal of a matrix + + # returns the sum of the elements below the main diagonal + # of m, m must be a square matrix + local procedure lowerSum( m :: sequence ) :: number + local sum := 0; + for r from 2 to size m do + if size m[ r ] <> size m then + error( "Matrix is not square" ) + else + for c to r - 1 do + sum +:= m[ r, c ] + od + fi + od; + return sum + end; + + # task test case + print( lowerSum( seq( (/ 1, 3, 7, 8, 10 \) + , (/ 2, 4, 16, 14, 4 \) + , (/ 3, 1, 9, 18, 11 \) + , (/ 12, 14, 17, 18, 20 \) + , (/ 7, 1, 3, 9, 5 \) + ) + ) + ) +end diff --git a/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fennel/sum-of-elements-below-main-diagonal-of-matrix.fennel b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fennel/sum-of-elements-below-main-diagonal-of-matrix.fennel new file mode 100644 index 0000000000..991cb8c7bb --- /dev/null +++ b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fennel/sum-of-elements-below-main-diagonal-of-matrix.fennel @@ -0,0 +1,27 @@ +(do ;;; sum the elements below the main diagonal of a matrix + + (fn lower-sum [m] ; returns the sum of the elements below the main diagonal + ; of m, m must be a square matrix + (var sum 0) + (for [r 2 (length m)] + (if (not= (length (. m r)) (length m)) + (error "Matrix is not square") + ;else + (for [c 1 (- r 1)] + (set sum (+ sum (. (. m r) c))) + ) + ) + ) + sum + ) + + ; task test case + (print (lower-sum [ [ 1 3 7 8 10 ] + [ 2 4 16 14 4 ] + [ 3 1 9 18 11 ] + [ 12 14 17 18 20 ] + [ 7 1 3 9 5 ] + ] + ) + ) +) diff --git a/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fortran/sum-of-elements-below-main-diagonal-of-matrix.f b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fortran/sum-of-elements-below-main-diagonal-of-matrix.f new file mode 100644 index 0000000000..4d70f7d2b9 --- /dev/null +++ b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Fortran/sum-of-elements-below-main-diagonal-of-matrix.f @@ -0,0 +1,27 @@ +program sum_below_diagonal + implicit none + integer, dimension(5,5) :: matrix + integer :: i, j, total_sum + + ! Initialize the matrix + matrix = reshape([1, 2, 3, 12, 7, & + 3, 4, 1, 14, 1, & + 7, 16, 9, 17, 3, & + 8, 14, 18, 18, 9, & + 10, 4, 11, 20, 5], shape(matrix), order=[1,2]) + + ! Compute the sum of elements below the main diagonal + total_sum = 0 + do i = 1, 5 + do j = 1, 5 + if (i > j) then + total_sum = total_sum + matrix(i, j) + end if + end do + end do + + ! Display the sum + print *, "The sum of elements below the main diagonal is: ", total_sum + +end program sum_below_diagonal +. diff --git a/Task/Sum-of-elements-below-main-diagonal-of-matrix/Lua/sum-of-elements-below-main-diagonal-of-matrix.lua b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Lua/sum-of-elements-below-main-diagonal-of-matrix.lua new file mode 100644 index 0000000000..eda3a62551 --- /dev/null +++ b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Lua/sum-of-elements-below-main-diagonal-of-matrix.lua @@ -0,0 +1,27 @@ +do -- sum the elements below the main diagonal of a matrix + + -- returns the sum of the elements below the main diagonal + -- of m, m must be a square matrix + local function lowerSum( m ) + local sum = 0 + for r = 2, # m do + if # m[ r ] ~= # m then + error( "Matrix is not square" ) + else + for c = 1, r - 1 do + sum = sum + m[ r ][ c ] + end + end + end + return sum + end + + -- task test case + print( lowerSum{ { 1, 3, 7, 8, 10 } + , { 2, 4, 16, 14, 4 } + , { 3, 1, 9, 18, 11 } + , { 12, 14, 17, 18, 20 } + , { 7, 1, 3, 9, 5 } + } + ) +end diff --git a/Task/Sum-of-elements-below-main-diagonal-of-matrix/Pluto/sum-of-elements-below-main-diagonal-of-matrix.pluto b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Pluto/sum-of-elements-below-main-diagonal-of-matrix.pluto new file mode 100644 index 0000000000..68aa622790 --- /dev/null +++ b/Task/Sum-of-elements-below-main-diagonal-of-matrix/Pluto/sum-of-elements-below-main-diagonal-of-matrix.pluto @@ -0,0 +1,27 @@ +do -- sum the elements below the main diagonal of a matrix + + -- returns the sum of the elements below the main diagonal + -- of m, m must be a square matrix + local function lowerSum( m : table ) : number + local sum = 0 + for r = 2, # m do + if # m[ r ] != # m then + error( "Matrix is not square" ) + else + for c = 1, r - 1 do + sum += m[ r ][ c ] + end + end + end + return sum + end + + -- task test case + print( lowerSum{ { 1, 3, 7, 8, 10 } + , { 2, 4, 16, 14, 4 } + , { 3, 1, 9, 18, 11 } + , { 12, 14, 17, 18, 20 } + , { 7, 1, 3, 9, 5 } + } + ) +end diff --git a/Task/Sum-of-squares/ArkScript/sum-of-squares.ark b/Task/Sum-of-squares/ArkScript/sum-of-squares.ark new file mode 100644 index 0000000000..747205c437 --- /dev/null +++ b/Task/Sum-of-squares/ArkScript/sum-of-squares.ark @@ -0,0 +1,16 @@ +(import std.List) + +(assert (= + (list:sum + (list:map + [1 2 3 4 5] + (fun (x) (* x x)))) + 55) + "sum of list is 55") +(assert (= + (list:sum + (list:map + [] + (fun (x) (* x x)))) + 0) + "sum of empty list is 0") diff --git a/Task/Sum-of-squares/DuckDB/sum-of-squares-1.duckdb b/Task/Sum-of-squares/DuckDB/sum-of-squares-1.duckdb new file mode 100644 index 0000000000..c3dc742e32 --- /dev/null +++ b/Task/Sum-of-squares/DuckDB/sum-of-squares-1.duckdb @@ -0,0 +1 @@ +select coalesce(sum(pow(x,2)), 0) from t; diff --git a/Task/Sum-of-squares/DuckDB/sum-of-squares-2.duckdb b/Task/Sum-of-squares/DuckDB/sum-of-squares-2.duckdb new file mode 100644 index 0000000000..fbf8860132 --- /dev/null +++ b/Task/Sum-of-squares/DuckDB/sum-of-squares-2.duckdb @@ -0,0 +1,5 @@ +create or replace function ss(columnname, tablename) as ( + coalesce( + (select sum(pow( COLUMNS(x-> x = columnname),2)) as s from query_table(tablename)), + 0) +); diff --git a/Task/Sum-of-squares/DuckDB/sum-of-squares-3.duckdb b/Task/Sum-of-squares/DuckDB/sum-of-squares-3.duckdb new file mode 100644 index 0000000000..2ed26fd794 --- /dev/null +++ b/Task/Sum-of-squares/DuckDB/sum-of-squares-3.duckdb @@ -0,0 +1,3 @@ +create or replace table t as (from values (1),(2) t(i)); + +select ss('i', 't') as "ss of t.i"; diff --git a/Task/Sum-of-squares/DuckDB/sum-of-squares-4.duckdb b/Task/Sum-of-squares/DuckDB/sum-of-squares-4.duckdb new file mode 100644 index 0000000000..3f0fcee4c6 --- /dev/null +++ b/Task/Sum-of-squares/DuckDB/sum-of-squares-4.duckdb @@ -0,0 +1,8 @@ +create or replace function ss(lst) as ( + select (case when length(lst) = 0 then 0 + else list_sum(list_transform( lst, x -> x*x)) + end) +); + +# Example +select ss([]) as 'ss of []', ss([1.0,2.0,3.0]) as "ss of list"; diff --git a/Task/Sum-to-100/EasyLang/sum-to-100.easy b/Task/Sum-to-100/EasyLang/sum-to-100.easy index 4306c8b04c..bbdf7caef6 100644 --- a/Task/Sum-to-100/EasyLang/sum-to-100.easy +++ b/Task/Sum-to-100/EasyLang/sum-to-100.easy @@ -29,7 +29,7 @@ proc init . f[i] = evaluate i . . -call init +init proc out code . a = 19683 b = 6561 diff --git a/Task/Sum-to-100/FutureBasic/sum-to-100.basic b/Task/Sum-to-100/FutureBasic/sum-to-100.basic new file mode 100644 index 0000000000..b095db7332 --- /dev/null +++ b/Task/Sum-to-100/FutureBasic/sum-to-100.basic @@ -0,0 +1,118 @@ +// +// Sum to 100 solutions +// +// Using 123456789 digits so the resulting +// mathematical expression adds up to a 100 +// using "-" and "+" operators only +// + +Int maxPerm, allDigits + +maxPerm = 13122 //2 * 3 ^ 8 max permutation +allDigits = 123456789 + +Int sum(13121) +CFStringRef equation + +// Get sum of one of the permutation +// on entry: n = permutation number +// on exit: ret = sum +// modifies global var equation + +local fn doEval( n as UInt32) as Int + + CFStringRef evalstr + boolean doAdd = _False + Int ret, cPtr, x, sw + + evalstr = @"9" + ret = 0: cPtr = 9 + doAdd = (n => (maxPerm / 2)) + + for x = 8 to 1 step -1 //do 87654321 + sw = n % 3 + if sw == 0 then cPtr += x * 10^(1 + fix(log(cPtr + 0.5) / log(10))) + if sw == 1 + ret += cPtr + cPtr = x + evalstr = concat (@" + ",evalstr) + end if + if sw == 2 + ret -= cPtr + cPtr = x + evalstr = concat (@" - ",evalstr) + end if + evalstr = concat(mid(str(x),1),evalstr) + n = fix(n/3) + next x + + if doAdd == 0 + evalstr = concat(@" - ", evalstr) + ret -= cPtr + else + ret += cPtr + end if + + evalstr = concat(str(ret),@" = ",evalstr) + equation = evalstr +end fn = ret + +window 1,@"Sum to 100" + + +Int x, y, curr + +// calculate all solutions 2 * 3 ^ 8 +// +for x = maxPerm-1 to 0 step -1 + equation = @"" + curr = fn DoEval(x) + sum(x) = curr + if curr = 100 then print equation +next x +print + +// sum with most solution + +Int i,j,sav,most,tot + +for x = 0 to maxPerm-1 + sav = 0 + for y = 0 to maxPerm-1 + if sum(y) == sum(x) then sav++ + next y + if sav > tot then tot = sav: most = sum(x) +next x +print most;" has most solutions occurring ";tot;" times." + +// lowest non negative with no solution + +boolean sk = _False +for x = 0 to allDigits-1 + for y = 0 to maxPerm-1 + if sum(y) == x then sk = _True: y = maxPerm + next y + if !sk + print "The first non negative number that has no solution is ";x + exit for + else + sk = _False + end if +next x + +// ten highest with solution + +print +print "The ten highest numbers that can be expressed:" + +most = 0 +for x = 1 to 10 + for y = 0 to maxPerm-1 + if sum(y) > sum(most) then most = y + next y + fn doEval(most) + print equation + sum(most) = 0 +next x + +HandleEvents diff --git a/Task/Superellipse/EasyLang/superellipse.easy b/Task/Superellipse/EasyLang/superellipse.easy index 0eebece6bb..f39215af3d 100644 --- a/Task/Superellipse/EasyLang/superellipse.easy +++ b/Task/Superellipse/EasyLang/superellipse.easy @@ -2,11 +2,10 @@ n = 2.5 a = 200 b = 200 glinewidth 0.2 +gpenup while t <= 360 - xp = x - yp = y x = (pow abs cos t (2 / n) * a * sign cos t) / 5 + 50 y = (pow abs sin t (2 / n) * b * sign sin t) / 5 + 50 - if t > 0 : gline xp yp x y + glineto x y t += 0.5 . diff --git a/Task/Superellipse/Maxima/superellipse.maxima b/Task/Superellipse/Maxima/superellipse.maxima new file mode 100644 index 0000000000..46e7281dde --- /dev/null +++ b/Task/Superellipse/Maxima/superellipse.maxima @@ -0,0 +1,7 @@ +wxdraw2d( + implicit( + abs(x/200)^(2.5)+abs(y/200)^2.5=1, + x,-250,250, + y,-250,250 + ) +)$ diff --git a/Task/Superellipse/Python/superellipse.py b/Task/Superellipse/Python/superellipse.py index 0033b55285..f80e004ab5 100644 --- a/Task/Superellipse/Python/superellipse.py +++ b/Task/Superellipse/Python/superellipse.py @@ -1,5 +1,4 @@ # Superellipse drawing in Python 2.7.9 -# pic can see at http://www.imgup.cz/image/712 import matplotlib.pyplot as plt from math import sin, cos, pi diff --git a/Task/Superpermutation-minimisation/JavaScript/superpermutation-minimisation.js b/Task/Superpermutation-minimisation/JavaScript/superpermutation-minimisation.js new file mode 100644 index 0000000000..b2b1728043 --- /dev/null +++ b/Task/Superpermutation-minimisation/JavaScript/superpermutation-minimisation.js @@ -0,0 +1,61 @@ +const nMax = 12; + +let superperm; +let pos; +let count = new Array(nMax); + +function factSum(n) { + let sum = 0; + for (let m = 1; m <= n; m++) { + let factorial = 1; + for (let i = 1; i <= m; i++) { + factorial *= i; + } + sum += factorial; + } + return sum; +} + +function r(n) { + if (n === 0) { + return false; + } + + const c = superperm[pos - n]; + if (--count[n] === 0) { + count[n] = n; + if (!r(n - 1)) { + return false; + } + } + superperm[pos++] = c; + return true; +} + +function superPerm(n) { + const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + pos = n; + superperm = new Array(factSum(n)); + + for (let i = 0; i < n + 1; i++) { + count[i] = i; + } + for (let i = 1; i < n + 1; i++) { + superperm[i - 1] = chars.charAt(i); + } + + while (r(n)) { + // Continue until r(n) returns false + } +} + +function main() { + for (let n = 0; n < nMax; n++) { + superPerm(n); + console.log(`superPerm(${n.toString().padStart(2, ' ')}) len = ${superperm.length}`); + } +} + +// Run the main function +main(); diff --git a/Task/Symmetric-difference/DuckDB/symmetric-difference.duckdb b/Task/Symmetric-difference/DuckDB/symmetric-difference.duckdb new file mode 100644 index 0000000000..9c50911d10 --- /dev/null +++ b/Task/Symmetric-difference/DuckDB/symmetric-difference.duckdb @@ -0,0 +1,12 @@ +create or replace function arrxor(list1, list2) as + (select array_agg(elements) from + (select min(arr) as mn, max(arr) as mx, elements from + ( (select 1, unnest(list1)) + union all + (select 2, unnest(list2)) ) as t(arr, elements) + group by elements + having mn = mx) ) ; + +# Example: + +select arrxor(['this','is','a','test'], ['also','part','of','a','test'] ) as arrxor; diff --git a/Task/Symmetric-difference/Pluto/symmetric-difference.pluto b/Task/Symmetric-difference/Pluto/symmetric-difference.pluto new file mode 100644 index 0000000000..55e6d22b54 --- /dev/null +++ b/Task/Symmetric-difference/Pluto/symmetric-difference.pluto @@ -0,0 +1,10 @@ +require "map" +local fmt = require "fmt" + +local a = set.of("John", "Bob", "Mary", "Serena") +local b = set.of("Jim", "Mary", "John", "Bob") +fmt.print("A = %s", a) +fmt.print("B = %s", b) +fmt.print("A - B = %s", a:except(b)) +fmt.print("B - A = %s", b:except(a)) +fmt.print("A △ B = %s", a:symdiff(b)) diff --git a/Task/System-time/Pluto/system-time.pluto b/Task/System-time/Pluto/system-time.pluto new file mode 100644 index 0000000000..50fb7a9b31 --- /dev/null +++ b/Task/System-time/Pluto/system-time.pluto @@ -0,0 +1 @@ +print(os.date()) diff --git a/Task/System-time/REBOL/system-time.rebol b/Task/System-time/REBOL/system-time.rebol index a6ec70b1c1..5b4a3a6e58 100644 --- a/Task/System-time/REBOL/system-time.rebol +++ b/Task/System-time/REBOL/system-time.rebol @@ -1,2 +1,3 @@ -now +print now +print now/precise print rejoin [now/year "-" now/month "-" now/day " " now/time] diff --git a/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-1.duckdb b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-1.duckdb new file mode 100644 index 0000000000..b2a37091ea --- /dev/null +++ b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-1.duckdb @@ -0,0 +1,7 @@ +CREATE TABLE address_USA ( + address_ID INTEGER PRIMARY KEY, + address_Street TEXT, + address_City TEXT, + address_State TEXT, + address_Zip INTEGER +); diff --git a/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-2.duckdb b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-2.duckdb new file mode 100644 index 0000000000..9178c8e4bc --- /dev/null +++ b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-2.duckdb @@ -0,0 +1 @@ +CREATE SEQUENCE 'addrID' START 1; diff --git a/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-3.duckdb b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-3.duckdb new file mode 100644 index 0000000000..624996ef19 --- /dev/null +++ b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-3.duckdb @@ -0,0 +1,7 @@ +CREATE TABLE Address ( + addrID Integer PRIMARY KEY DEFAULT NEXTVAL('addrID'), + addrStreet Varchar(50) not null, + addrCity Varchar(25) not null, + addrState Char(2) not null, + addrZIP Char(10) not null +); diff --git a/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-4.duckdb b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-4.duckdb new file mode 100644 index 0000000000..33a020f58a --- /dev/null +++ b/Task/Table-creation-Postal-addresses/DuckDB/table-creation-postal-addresses-4.duckdb @@ -0,0 +1 @@ +INSERT INTO Address values (DEFAULT, '1 Main St', 'Townsend', 'ZZ', 54321); diff --git a/Task/Tarjan/JavaScript/tarjan.js b/Task/Tarjan/JavaScript/tarjan.js new file mode 100644 index 0000000000..0a418f3dbc --- /dev/null +++ b/Task/Tarjan/JavaScript/tarjan.js @@ -0,0 +1,83 @@ +class Graph { + constructor(size) { + this.adjacencyLists = []; + this.vertices = []; + this.index = 0; + this.stack = []; + this.numbers = new Map(); + this.lowlinks = new Map(); + this.stronglyConnectedComponents = []; + + for (let i = 0; i < size; i++) { + this.vertices.push(i); + this.adjacencyLists.push(new Set()); + } + } + + addDirectedEdge(from, to) { + this.adjacencyLists[from].add(to); + } + + getSCC() { + for (const vertex of this.vertices) { + if (!this.numbers.has(vertex)) { + this.stronglyConnect(vertex); + } + } + + return this.stronglyConnectedComponents; + } + + stronglyConnect(vertex) { + this.numbers.set(vertex, this.index); + this.lowlinks.set(vertex, this.index); + this.index += 1; + this.stack.push(vertex); + + for (const adjacent of this.adjacencyLists[vertex]) { + if (!this.numbers.has(adjacent)) { + this.stronglyConnect(adjacent); + this.lowlinks.set(vertex, Math.min(this.lowlinks.get(vertex), this.lowlinks.get(adjacent))); + } else if (this.stack.includes(adjacent)) { + this.lowlinks.set(vertex, Math.min(this.lowlinks.get(vertex), this.numbers.get(adjacent))); + } + } + + if (this.lowlinks.get(vertex) === this.numbers.get(vertex)) { + const stronglyConnectedComponent = new Set(); + let top; + do { + top = this.stack.pop(); + stronglyConnectedComponent.add(top); + } while (top !== vertex); + + this.stronglyConnectedComponents.push(stronglyConnectedComponent); + } + } +} + +// Main function equivalent +function main() { + const graph = new Graph(8); + + graph.addDirectedEdge(0, 1); + graph.addDirectedEdge(1, 2); + graph.addDirectedEdge(1, 7); + graph.addDirectedEdge(2, 3); + graph.addDirectedEdge(2, 6); + graph.addDirectedEdge(3, 4); + graph.addDirectedEdge(4, 2); + graph.addDirectedEdge(4, 5); + graph.addDirectedEdge(6, 3); + graph.addDirectedEdge(6, 5); + graph.addDirectedEdge(7, 0); + graph.addDirectedEdge(7, 6); + + console.log("The strongly connected components are: "); + for (const component of graph.getSCC()) { + console.log(component); + } +} + +// Run the main function +main(); diff --git a/Task/Tarjan/Zig/tarjan.zig b/Task/Tarjan/Zig/tarjan.zig new file mode 100644 index 0000000000..302114c85d --- /dev/null +++ b/Task/Tarjan/Zig/tarjan.zig @@ -0,0 +1,200 @@ +const std = @import("std"); +const ArrayList = std.ArrayList; +const HashMap = std.HashMap; +const print = std.debug.print; +const Allocator = std.mem.Allocator; + +// Simple graph representation using adjacency lists +const Graph = struct { + neighbors: ArrayList(ArrayList(usize)), + allocator: Allocator, + + const Self = @This(); + + pub fn init(allocator: Allocator, size: usize) !Self { + var neighbors = ArrayList(ArrayList(usize)).init(allocator); + try neighbors.ensureTotalCapacity(size); + + for (0..size) |_| { + try neighbors.append(ArrayList(usize).init(allocator)); + } + + return Self{ + .neighbors = neighbors, + .allocator = allocator, + }; + } + + pub fn deinit(self: *Self) void { + for (self.neighbors.items) |*neighbor_list| { + neighbor_list.deinit(); + } + self.neighbors.deinit(); + } + + pub fn addEdge(self: *Self, from: usize, to: usize) !void { + std.debug.assert(to < self.len()); + try self.neighbors.items[from].append(to); + } + + pub fn addEdges(self: *Self, from: usize, to: []const usize) !void { + const limit = self.len(); + for (to) |vertex| { + std.debug.assert(vertex < limit); + try self.neighbors.items[from].append(vertex); + } + } + + pub fn getEdges(self: *const Self, vertex: usize) []const usize { + return self.neighbors.items[vertex].items; + } + + pub fn isEmpty(self: *const Self) bool { + return self.neighbors.items.len == 0; + } + + pub fn len(self: *const Self) usize { + return self.neighbors.items.len; + } +}; + +const VertexState = struct { + index: usize, + low_link: usize, + on_stack: bool, +}; + +const Tarjan = struct { + graph: *const Graph, + index: usize, + stack: ArrayList(usize), + state: ArrayList(VertexState), + components: ArrayList(ArrayList(usize)), + allocator: Allocator, + + const Self = @This(); + const INVALID_INDEX: usize = std.math.maxInt(usize); + + pub fn init(allocator: Allocator, graph: *const Graph) !Self { + var state = ArrayList(VertexState).init(allocator); + try state.ensureTotalCapacity(graph.len()); + + for (0..graph.len()) |_| { + try state.append(VertexState{ + .index = INVALID_INDEX, + .low_link = INVALID_INDEX, + .on_stack = false, + }); + } + + return Self{ + .graph = graph, + .index = 0, + .stack = ArrayList(usize).init(allocator), + .state = state, + .components = ArrayList(ArrayList(usize)).init(allocator), + .allocator = allocator, + }; + } + + pub fn deinit(self: *Self) void { + for (self.components.items) |*component| { + component.deinit(); + } + self.components.deinit(); + self.stack.deinit(); + self.state.deinit(); + } + + pub fn walk(allocator: Allocator, graph: *const Graph) !ArrayList(ArrayList(usize)) { + var tarjan = try Self.init(allocator, graph); + defer tarjan.deinit(); + + return try tarjan.visitAll(); + } + + fn visitAll(self: *Self) !ArrayList(ArrayList(usize)) { + for (0..self.graph.len()) |vertex| { + if (self.state.items[vertex].index == INVALID_INDEX) { + try self.visit(vertex); + } + } + + // Move components out to avoid double-free + var result = ArrayList(ArrayList(usize)).init(self.allocator); + try result.ensureTotalCapacity(self.components.items.len); + + for (self.components.items) |component| { + try result.append(component); + } + + // Clear the original components to avoid double-free + self.components.clearRetainingCapacity(); + + return result; + } + + fn visit(self: *Self, v: usize) !void { + self.state.items[v].index = self.index; + self.state.items[v].low_link = self.index; + self.index += 1; + try self.stack.append(v); + self.state.items[v].on_stack = true; + + for (self.graph.getEdges(v)) |w| { + if (self.state.items[w].index == INVALID_INDEX) { + try self.visit(w); + const w_low_link = self.state.items[w].low_link; + self.state.items[v].low_link = @min(self.state.items[v].low_link, w_low_link); + } else if (self.state.items[w].on_stack) { + const w_index = self.state.items[w].index; + self.state.items[v].low_link = @min(self.state.items[v].low_link, w_index); + } + } + + if (self.state.items[v].low_link == self.state.items[v].index) { + var component = ArrayList(usize).init(self.allocator); + + while (true) { + const w = self.stack.pop().?; + self.state.items[w].on_stack = false; + try component.append(w); + if (w == v) { + break; + } + } + + try self.components.append(component); + } + } +}; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + var graph = try Graph.init(allocator, 8); + defer graph.deinit(); + + try graph.addEdge(0, 1); + try graph.addEdge(2, 0); + try graph.addEdges(5, &[_]usize{ 2, 6 }); + try graph.addEdge(6, 5); + try graph.addEdge(1, 2); + try graph.addEdges(3, &[_]usize{ 1, 2, 4 }); + try graph.addEdges(4, &[_]usize{ 5, 3 }); + try graph.addEdges(7, &[_]usize{ 4, 7, 6 }); + + var components = try Tarjan.walk(allocator, &graph); + defer { + for (components.items) |*component| { + component.deinit(); + } + components.deinit(); + } + + for (components.items) |component| { + print("{any}\n", .{component.items}); + } +} diff --git a/Task/Tau-function/FutureBasic/tau-function.basic b/Task/Tau-function/FutureBasic/tau-function.basic new file mode 100644 index 0000000000..98dc1db0f1 --- /dev/null +++ b/Task/Tau-function/FutureBasic/tau-function.basic @@ -0,0 +1,39 @@ +// +// Tau Function +// +// FutureBasic 7.0.34, August 2025 R.W +// +// Given a positive integer, count the +// number of its positive divisors. +//--------------------------------------- + +// Given an integer, returns the +// Tau positive integer + +local fn Tau( n as Int) as Int + int x, result + if n < 3 + result = n + else + result = 2 + for x = 2 to fix((n + 1) / 2) + if n % x == 0 then result++ + next x + end if +end fn = result + + +Window 1,@"Tau Function" + +print +print "First 100 positive integer Tau numbers:" +print + +int x + +for x = 1 to 100 + print using "####";fn Tau(x); + if x % 10 == 0 then print +next x + +handleEvents diff --git a/Task/Tau-function/Pluto/tau-function.pluto b/Task/Tau-function/Pluto/tau-function.pluto new file mode 100644 index 0000000000..6a7ea1b896 --- /dev/null +++ b/Task/Tau-function/Pluto/tau-function.pluto @@ -0,0 +1,11 @@ +local int = require "int" +local fmt = require "fmt" + +local limit = 100 +local tau = {} +local i = 0 +print($"The tau functions for the first {limit} positive integers are:") +for i = 1, limit do + tau:insert(int.divstat(i)[1]) +end +fmt.tprint("%2d ", tau, 10) diff --git a/Task/Tau-number/FutureBasic/tau-number.basic b/Task/Tau-number/FutureBasic/tau-number.basic new file mode 100644 index 0000000000..2846e38f1b --- /dev/null +++ b/Task/Tau-number/FutureBasic/tau-number.basic @@ -0,0 +1,46 @@ +// +// Tau Numbers +// +// FutureBasic 7.0.34, August 2025 R.W +// +//------------------------------------- +// +// Given an integer, returns the +// Tau positive integer +local fn Tau( n as Int) as Int + int x, result + if n < 3 + result = n + else + result = 2 + for x = 2 to fix((n + 1) / 2) + if n % x == 0 then result++ + next x + end if +end fn = result + +// Returns True if n is a Tau number +local fn isTau(n as Int) as boolean + boolean result = _False + if n % fn Tau(n) == 0 then result = _True +end fn = result + +window 1,@"Tau numbers" + +print +print " First 100 Tau numbers:" +print + +int x, c, res +c = 1: x = 1 +while c < 100 + if fn isTau(x) + print using "######";x; + if (c % 9 == 0) then print + c++ + end if + x++ +wend + +handleEvents +// diff --git a/Task/Tau-number/Pluto/tau-number.pluto b/Task/Tau-number/Pluto/tau-number.pluto new file mode 100644 index 0000000000..517c5d4493 --- /dev/null +++ b/Task/Tau-number/Pluto/tau-number.pluto @@ -0,0 +1,13 @@ +local int = require "int" +local fmt = require "fmt" + +local limit = 100 +local tau = {} +local i = 0 +print($"The first {limit} tau numbers are:") +repeat + ++i + local dc = int.divstat(i)[1] + if i % dc == 0 then tau:insert(i) end +until #tau == limit +fmt.tprint("%4d ", tau, 10) diff --git a/Task/Terminal-control-Clear-the-screen/Pluto/terminal-control-clear-the-screen.pluto b/Task/Terminal-control-Clear-the-screen/Pluto/terminal-control-clear-the-screen.pluto new file mode 100644 index 0000000000..d1ac1c7150 --- /dev/null +++ b/Task/Terminal-control-Clear-the-screen/Pluto/terminal-control-clear-the-screen.pluto @@ -0,0 +1,3 @@ +require "ansi" + +screen.clear() diff --git a/Task/Terminal-control-Coloured-text/Pluto/terminal-control-coloured-text.pluto b/Task/Terminal-control-Coloured-text/Pluto/terminal-control-coloured-text.pluto new file mode 100644 index 0000000000..dcb6fc00dd --- /dev/null +++ b/Task/Terminal-control-Coloured-text/Pluto/terminal-control-coloured-text.pluto @@ -0,0 +1,16 @@ +require "ansi" + +local colors = {"Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"} +-- Display words using 'bright' colors +for i = 2, 8 do screen.print(colors[i], color[colors[i]]) end -- Red to White + +os.sleep(3000) -- wait for 3 seconds +screen.setBack(color.white) -- set background color to white +screen.clear() -- clear screen to background color & home the cursor + +-- display words again using 'blinking' colors +screen.setStyle("blink") -- blink on +for i = 1, 7 do screen.print(colors[i], color[colors[i]]) end -- Black to Cyan +os.sleep(3000) -- wait for 3 more seconds +screen.reset() -- reset all attributes +screen.clear() -- clear screen to background color & home the cursor diff --git a/Task/Terminal-control-Cursor-movement/Pluto/terminal-control-cursor-movement.pluto b/Task/Terminal-control-Cursor-movement/Pluto/terminal-control-cursor-movement.pluto new file mode 100644 index 0000000000..5abdc724bb --- /dev/null +++ b/Task/Terminal-control-Cursor-movement/Pluto/terminal-control-cursor-movement.pluto @@ -0,0 +1,26 @@ +require "ansi" + +screen.clear() -- clear terminal +cursor.move(12, 40) -- move to (12, 40) +os.sleep(2000) +cursor.left() -- move left +screen.fwrite("+\b") +os.sleep(2000) +cursor.right() -- move right +screen.fwrite("x\b") +os.sleep(2000) +cursor.up() -- move up +screen.fwrite("!\b") +os.sleep(2000) +cursor.down() -- move down +screen.fwrite("?\b") +os.sleep(2000) +cursor.col() -- move to beginning of line +os.sleep(2000) +cursor.col(80) -- move to end of line (assuming 80 column terminal) +os.sleep(2000) +cursor.home() -- move to top left corner +os.sleep(2000) +cursor.move(24, 80) -- move to bottom right corner (assuming 80 x 24 terminal) +os.sleep(2000) +screen.clear() -- clear screen again before quitting diff --git a/Task/Terminal-control-Cursor-positioning/Pluto/terminal-control-cursor-positioning.pluto b/Task/Terminal-control-Cursor-positioning/Pluto/terminal-control-cursor-positioning.pluto new file mode 100644 index 0000000000..fc0122df8f --- /dev/null +++ b/Task/Terminal-control-Cursor-positioning/Pluto/terminal-control-cursor-positioning.pluto @@ -0,0 +1,5 @@ +require "ansi" + +screen.clear() -- clear the terminal +cursor.move(6, 3) -- move to (6, 3) +print("Hello") -- print 'Hello' diff --git a/Task/Terminal-control-Dimensions/Pluto/terminal-control-dimensions.pluto b/Task/Terminal-control-Dimensions/Pluto/terminal-control-dimensions.pluto new file mode 100644 index 0000000000..82f518c8b5 --- /dev/null +++ b/Task/Terminal-control-Dimensions/Pluto/terminal-control-dimensions.pluto @@ -0,0 +1,6 @@ +local tmp = "_pluto_.tmp" +os.execute($"stty size > {tmp}") +local res = io.contents(tmp):strip() +io.remove(tmp) +local [h, w] = res:split(" ") +print($"Terminal width = {w} and height = {h}") diff --git a/Task/Terminal-control-Display-an-extended-character/Pluto/terminal-control-display-an-extended-character.pluto b/Task/Terminal-control-Display-an-extended-character/Pluto/terminal-control-display-an-extended-character.pluto new file mode 100644 index 0000000000..e74448fb82 --- /dev/null +++ b/Task/Terminal-control-Display-an-extended-character/Pluto/terminal-control-display-an-extended-character.pluto @@ -0,0 +1 @@ +print "£" diff --git a/Task/Terminal-control-Hiding-the-cursor/Pluto/terminal-control-hiding-the-cursor.pluto b/Task/Terminal-control-Hiding-the-cursor/Pluto/terminal-control-hiding-the-cursor.pluto new file mode 100644 index 0000000000..68ae069e17 --- /dev/null +++ b/Task/Terminal-control-Hiding-the-cursor/Pluto/terminal-control-hiding-the-cursor.pluto @@ -0,0 +1,6 @@ +require "ansi" + +cursor.hide() +os.sleep(3000) +cursor.show() +os.sleep(3000) diff --git a/Task/Terminal-control-Inverse-video/Pluto/terminal-control-inverse-video.pluto b/Task/Terminal-control-Inverse-video/Pluto/terminal-control-inverse-video.pluto new file mode 100644 index 0000000000..cffe10e500 --- /dev/null +++ b/Task/Terminal-control-Inverse-video/Pluto/terminal-control-inverse-video.pluto @@ -0,0 +1,6 @@ +require "ansi" + +screen.setStyle(style.inverse) +print("Inverse") +screen.resetStyle() +print("Normal") diff --git a/Task/Terminal-control-Preserve-screen/Pluto/terminal-control-preserve-screen.pluto b/Task/Terminal-control-Preserve-screen/Pluto/terminal-control-preserve-screen.pluto new file mode 100644 index 0000000000..44e65a7050 --- /dev/null +++ b/Task/Terminal-control-Preserve-screen/Pluto/terminal-control-preserve-screen.pluto @@ -0,0 +1,10 @@ +require "ansi" + +screen.enablebuffer() +print("Alternate screen buffer") +for i = 5, 1, -1 do + local s = (i != 1) ? "s" : "" + screen.fwrite($"\rGoing back in {i} second{s}...") + os.sleep(1000) +end +screen.disablebuffer() diff --git a/Task/Terminal-control-Ringing-the-terminal-bell/Pluto/terminal-control-ringing-the-terminal-bell.pluto b/Task/Terminal-control-Ringing-the-terminal-bell/Pluto/terminal-control-ringing-the-terminal-bell.pluto new file mode 100644 index 0000000000..3fde07b32e --- /dev/null +++ b/Task/Terminal-control-Ringing-the-terminal-bell/Pluto/terminal-control-ringing-the-terminal-bell.pluto @@ -0,0 +1 @@ +print "\a" diff --git a/Task/Terminal-control-Ringing-the-terminal-bell/YAMLScript/terminal-control-ringing-the-terminal-bell.ys b/Task/Terminal-control-Ringing-the-terminal-bell/YAMLScript/terminal-control-ringing-the-terminal-bell.ys new file mode 100644 index 0000000000..9395df93ef --- /dev/null +++ b/Task/Terminal-control-Ringing-the-terminal-bell/YAMLScript/terminal-control-ringing-the-terminal-bell.ys @@ -0,0 +1,2 @@ +!YS-v0 +print: char(7) diff --git a/Task/Terminal-control-Unicode-output/Pluto/terminal-control-unicode-output.pluto b/Task/Terminal-control-Unicode-output/Pluto/terminal-control-unicode-output.pluto new file mode 100644 index 0000000000..798a1d4085 --- /dev/null +++ b/Task/Terminal-control-Unicode-output/Pluto/terminal-control-unicode-output.pluto @@ -0,0 +1,10 @@ +local function supports_unicode() + local lang = os.getenv("LANG") + return "UTF-8" in lang or "utf-8" in lang +end + +if supports_unicode() then + print($"Unicode is supported on this terminal and U+25B3 is : {"\u{25B3}"}") +else + error("Unicode is not supported on this terminal") +end diff --git a/Task/Test-integerness/Ada/test-integerness.ada b/Task/Test-integerness/Ada/test-integerness.ada new file mode 100644 index 0000000000..dc2ec8dfb7 --- /dev/null +++ b/Task/Test-integerness/Ada/test-integerness.ada @@ -0,0 +1,49 @@ +-- Big_Numbers is an Ada 2022 unit + +with Ada.Numerics.Big_Numbers.Big_Integers, + Ada.Numerics.Big_Numbers.Big_Reals, + Ada.Numerics.Generic_Complex_Types, + Ada.Text_IO; + +use Ada.Numerics.Big_Numbers.Big_Integers, + Ada.Numerics.Big_Numbers.Big_Reals, + Ada.Text_IO; + +procedure Test_Integer is + -- These are the only numerical types defined in package + -- "Standard" which is always incuded. 'Base also covers anything + -- with the same Base types. + function Is_Integer (N : Integer'Base) return Boolean is (True); + function Is_Integer (N : Float'Base) return Boolean is (Float'Base'Floor (N) = N); + + -- Additional types defined in the standard library. + function Is_Integer (N : Big_Integer) return Boolean is (True); + + -- The type says real, but these are rational approximations of + -- real numbers. + function Is_Integer (N : Big_Real) return Boolean is (Denominator (N) = 1); + + package Complex_Float is new Ada.Numerics.Generic_Complex_Types (Float); + use Complex_Float; + + function Is_Integer (N : Complex) return Boolean + is (Im (N) = 0.0 and then Is_Integer (Re (N))); + + Int_One : Integer := 1; + Flo_One : Float := 1.0; + Flo_OneH : Float := 1.5; + BInt_One : Big_Integer := To_Big_Integer (1); + BFlo_One : Big_Real := To_Big_Real (1); + BFlo_OneH : Big_Real := From_String ("1.5"); + CInt_One : Complex := 1.0 + 0.0 * I; + CInt_OneI : Complex := 1.0 + 1.0 * I; +begin + Put_Line (Int_One'Image & " is integer? " & Is_Integer (Int_One)'Image); + Put_Line (Flo_One'Image & " is integer? " & Is_Integer (Flo_One)'Image); + Put_Line (Flo_OneH'Image & " is integer? " & Is_Integer (Flo_OneH)'Image); + Put_Line (BInt_One'Image & " is integer? " & Is_Integer (BInt_One)'Image); + Put_Line (BFlo_One'Image & " is integer? " & Is_Integer (BFlo_One)'Image); + Put_Line (BFlo_OneH'Image & " is integer? " & Is_Integer (BFlo_OneH)'Image); + Put_Line (CInt_One'Image & " is integer? " & Is_Integer (CInt_One)'Image); + Put_Line (CInt_OneI'Image & " is integer? " & Is_Integer (CInt_OneI)'Image); +end Test_Integer; diff --git a/Task/Test-integerness/DuckDB/test-integerness-1.duckdb b/Task/Test-integerness/DuckDB/test-integerness-1.duckdb new file mode 100644 index 0000000000..33341025fc --- /dev/null +++ b/Task/Test-integerness/DuckDB/test-integerness-1.duckdb @@ -0,0 +1,3 @@ +create type Complex as struct (r float, i float); + +create type Rational as struct (n integer, d integer); diff --git a/Task/Test-integerness/DuckDB/test-integerness-2.duckdb b/Task/Test-integerness/DuckDB/test-integerness-2.duckdb new file mode 100644 index 0000000000..9644451eb4 --- /dev/null +++ b/Task/Test-integerness/DuckDB/test-integerness-2.duckdb @@ -0,0 +1,16 @@ +create or replace function number_integerp(x) as ( + x = trunc(x) +); + +# Return true iff x has the type signature of a Rational +# with the denominator dividing the numerator evenly. +create or replace function rational_integerp(x) as ( + typeof(x) = 'STRUCT(n INTEGER, d INTEGER)' + and x.n % x.d = 0 +); + +# Return true if x can be cast to a Complex with +# the imaginary part equal to 0 and an integer real part. +create or replace function complex_integerp(x) as ( + (x::Complex).i = 0 and number_integerp(x.r) +); diff --git a/Task/Test-integerness/Pluto/test-integerness.pluto b/Task/Test-integerness/Pluto/test-integerness.pluto new file mode 100644 index 0000000000..0b3b0e6387 --- /dev/null +++ b/Task/Test-integerness/Pluto/test-integerness.pluto @@ -0,0 +1,37 @@ +require "complex" +require "rat" +require "table2" +local fmt = require "fmt" + +local tests1 = {25.000000, 24.999999, 25.000100} +local tests2 = {-2.1e120} +local tests3 = {-5e-2, 0/0, 1/0} +local tests4 = {complex.of(5, 0), complex.of(5, -5)} +local tests5 = {rat.of(24, 8), rat.of(-5, 1), rat.of(17, 2)} +local tests6 = tests1:joined({-5e-2}) + +print("Using exact arithmetic:\n") +for tests1 as t do + fmt.print(" %-9.6f is integer? %s", t, t % 1 == 0) +end +print() +for tests2 as t do + fmt.print(" %-9g is integer? %s", t, t % 1 == 0) +end +for tests3 as t do + fmt.print(" %-9.6f is integer? %s", t, t % 1 == 0) +end +print() +for tests4 as t do + fmt.print(" %-9s is integer? %s", t, t:getReal() % 1 == 0 and t:getImag() == 0) +end +print() +for tests5 as t do + fmt.print(" %-9s is integer? %s", t, t:isint()) +end +print("\nWithin a tolerance of 0.00001:\n") +local tol = 0.00001 +for tests6 as t do + local d = math.abs(t - math.round(t)) + fmt.print(" %9.6f is integer? %s", t, d <= tol) +end diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-1.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-1.duckdb new file mode 100644 index 0000000000..eb5e3b404e --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-1.duckdb @@ -0,0 +1,2 @@ +create or replace table t as +from read_csv_auto('readings.txt', header=false); diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-2.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-2.duckdb new file mode 100644 index 0000000000..c61c6dc483 --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-2.duckdb @@ -0,0 +1 @@ +alter table t rename column column00 to date; diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-3.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-3.duckdb new file mode 100644 index 0000000000..c578499e6b --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-3.duckdb @@ -0,0 +1,7 @@ +.mode list +.headers off +.once dynamic.tmp +select 'alter table t rename column ''column' || format('{:02d}', 2 * n) || ''' to ''flag' || format('{:02d}'';', n) from range(1,25) t(n); +.read dynamic.tmp +.mode duckdb +.headers on diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-4.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-4.duckdb new file mode 100644 index 0000000000..00993c94ac --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-4.duckdb @@ -0,0 +1,9 @@ +# The values in a struct as JSON values +create or replace function struct_values(s) as ( + with j as (select s::JSON as j) + SELECT list_transform( json_keys(j), k -> j[k]) from j +); + +# Number of nulls in an entire table: +select sum(length(list_filter(struct_values(t), x -> x = 'null'))) as "|null|" +from (select t from t); diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-5.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-5.duckdb new file mode 100644 index 0000000000..53c30a7e9a --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-5.duckdb @@ -0,0 +1,9 @@ +# j is a JSON object ; return a list of the keys for which the value is less than 1 +create or replace function report(j) as ( + list_filter(json_keys(j), k -> (j -> k) < 1 ) +); + +select count(*) from +from (select report(struct_pack(*COLUMNS('flag'))::JSON) as flags + from t + where flags = []); diff --git a/Task/Text-processing-2/DuckDB/text-processing-2-6.duckdb b/Task/Text-processing-2/DuckDB/text-processing-2-6.duckdb new file mode 100644 index 0000000000..2229dd4d81 --- /dev/null +++ b/Task/Text-processing-2/DuckDB/text-processing-2-6.duckdb @@ -0,0 +1,6 @@ +with allflags as ( + select array_agg(flags) as flags + from (select report(struct_pack(*COLUMNS('flag'))::JSON) as flags from t) + ) + select list_reduce( flags, (acc,x) -> list_intersect(acc,x) ) as "never worked" + from allflags; diff --git a/Task/The-Name-Game/R/the-name-game.r b/Task/The-Name-Game/R/the-name-game.r new file mode 100644 index 0000000000..5867fafbc6 --- /dev/null +++ b/Task/The-Name-Game/R/the-name-game.r @@ -0,0 +1,20 @@ +library(stringr) + +namegame <- function(name){ + name <- str_to_title(name) + bfm_flags <- c("b","f","m") + #Y is only considered a starting vowel if it is followed by a consonant + if(str_detect(name, "^[AEIOU]|^Y[^aeiou]")) name_trunc <- str_to_lower(name) + else name_trunc <- str_sub(name, start=2) + switch(str_sub(name, 1, 1), + "B"=eval(bfm_flags[1] <- ""), + "F"=eval(bfm_flags[2] <- ""), + "M"=eval(bfm_flags[3] <- "")) + str_glue("{name}, {name}, bo-{bfm_flags[1]}{name_trunc}", + "Banana-fana fo-{bfm_flags[2]}{name_trunc}", + "Fee-fi-mo-{bfm_flags[3]}{name_trunc}", + "{name}!", .sep="\n") +} + +test_names <- c("Gary", "Earl", "Billy", "Felix", "Mary", "Yancy", "Yvonne") +sapply(test_names, namegame) |> writeLines() diff --git a/Task/The-Twelve-Days-of-Christmas/AutoLISP/the-twelve-days-of-christmas.l b/Task/The-Twelve-Days-of-Christmas/AutoLISP/the-twelve-days-of-christmas.l new file mode 100644 index 0000000000..a2d1ec511b --- /dev/null +++ b/Task/The-Twelve-Days-of-Christmas/AutoLISP/the-twelve-days-of-christmas.l @@ -0,0 +1,30 @@ +(defun c:TDOC ( / days gifts) + (setq days + '( + ("first" "A partridge in a pear tree.") + ("second" "Two turtle doves and") + ("third" "Three french hens") + ("fourth" "Four calling birds") + ("fifth" "Five golden rings") + ("sixth" "Six geese a-laying") + ("seventh" "Seven swans a-swimming") + ("eighth" "Eight maids a-milking") + ("ninth" "Nine ladies dancing") + ("tenth" "Ten lords a-leaping") + ("eleventh" "Eleven pipers piping") + ("twelfth" "Twelve drummers drumming") + ) + ) + (setq gifts "") + (foreach day days + (prompt + (strcat + "\n-----" + "\nOn the " (car day) " day of Christmas," + "\nMy true love gave to me:" + (setq gifts (strcat "\n" (cadr day) gifts)) + ) + ) + ) + (princ) +) diff --git a/Task/Thue-Morse/DuckDB/thue-morse-1.duckdb b/Task/Thue-Morse/DuckDB/thue-morse-1.duckdb new file mode 100644 index 0000000000..4a27bd020f --- /dev/null +++ b/Task/Thue-Morse/DuckDB/thue-morse-1.duckdb @@ -0,0 +1,16 @@ +create or replace function t(n) as ( + with recursive mx as (select (ceil(log(n) / log(2))) as mx), + cte as ( + select '0' as a, + 0 as ix + union all + select replace(replace(hex(a),'30','01'),'31','10') as a, + ix+1 as ix + from cte, mx + where ix < mx + ) + select last(a[n] order by ix) from cte +); + +## Example: +select t(1), t(2), t(3), t(4), t(5), t(100); diff --git a/Task/Thue-Morse/DuckDB/thue-morse-2.duckdb b/Task/Thue-Morse/DuckDB/thue-morse-2.duckdb new file mode 100644 index 0000000000..3ecc2f8c1f --- /dev/null +++ b/Task/Thue-Morse/DuckDB/thue-morse-2.duckdb @@ -0,0 +1,16 @@ +create or replace function TM(n) as ( +create or replace function TM(n) as ( + with recursive mx as (select (ceil(log(n) / log(2))) as mx), + cte as ( + select '0' as sb0, '1' as sb1, 0 as ix + union all + select (sb0 || sb1) as sb0, + (sb1 || sb0) as sb1, + ix+1, + from cte, mx + where ix < mx + ) + select last(sb0[:n] order by ix) from cte +); +## Example: +select TM(100); diff --git a/Task/Thue-Morse/Prolog/thue-morse.pro b/Task/Thue-Morse/Prolog/thue-morse.pro new file mode 100644 index 0000000000..5b342753fb --- /dev/null +++ b/Task/Thue-Morse/Prolog/thue-morse.pro @@ -0,0 +1,15 @@ +%! thue_morse(+N, -TM) is det. +% Calculates the Nth number of the Thue-Morse sequence, indexing from 0. +thue_morse(N, TM) :- TM is popcount(N) mod 2. + +%! thue_morse_list(-List) is multi. +% Calculates progressively longer prefixes of the Thue-Morse sequence. +thue_morse_list(List) :- thue_morse_list(0, List). + +thue_morse_list(N, [TM | List]) :- + thue_morse(N, TM), + ( List = [] + ; N1 is N + 1, thue_morse_list(N1, List) + ). + +:- length(List, 20), once(thue_morse_list(List)), write(List). diff --git a/Task/Tic-tac-toe/TAV/tic-tac-toe.tav b/Task/Tic-tac-toe/TAV/tic-tac-toe.tav new file mode 100644 index 0000000000..fa73c27b8d --- /dev/null +++ b/Task/Tic-tac-toe/TAV/tic-tac-toe.tav @@ -0,0 +1,133 @@ +\( Simple (not perfect) solver for tic-tac-toe + The state is a 9-element vector, with + 0 for free, 1 for user; 4 for machine + Lanes are used to check if there is a win or near-win: + 1 2 3 + 4 5 6 + 7 8 9 + 1 4 7 + 2 5 8 + 3 6 9 + 1 5 9 + 3 5 7 + For each lane, the sum of the values is calculated + and the number of free ones determined. + After the player's move and the machine action, + the lane sums are checked for wins: + - if = 3, the player has won, stop. + - if = 12, the machine has won, stop. + - if none are free, the game ends with a draw + The machine action is: + - if = 2, the player could win; set the free place + - if = 8, the machine will win, set the free place + - if field 5 is free, set + - if any of the fields 1, 3, 7 or 9 are free, set at random + - if any of the fields 2, 4, 6 or 8 are free, set at random +\) +main (parms):+ + random set seed () + print "enter field number, or 'x' to quit:" + state =: new row size 9 init 0 + state.lanes =: ((1, 2, 3), (4, 5, 6), (7, 8, 9), (1, 4, 7), (2, 5, 8), (3, 6, 9), (1, 5, 9), (3, 5, 7)) + state.free =: 9 + ?* state.free > 0 + show state + set user state + show state + check end state + ? state.free > 0 + step move state + check end state + show state + +check end (state): + ?# t =: tuple state.lanes give values + c =: sum of places state lane t + \ print c, t + ? c = 3: + print "You win:", t + ?# i =: tuple t give values + state[i] =: '+' + state.free =: 0 + :> + ? c = 12: + print "I win:", t + ?# i =: tuple t give values + state[i] =: '*' + state.free =: 0 + :> + ? state.free = 0 + print "This is a draw." + +step move (state): + ?# t =: tuple state.lanes give values + c =: sum of places state lane t + ? c = 2 + set state at t + :> + ? c = 8 + set state at t + :> + ? set state at 5 + :> + ? set state at shuffle 1, 3, 7, 9 + :> + ? set state at shuffle 2, 4, 6, 8 + :> + +set (state) at (points): + ? ~ is points tuple + points =: points, () \ make it a tuple + ?# i =: tuple points give values + ? state[i] = 0 + state[i] =: 4 + print "my move:", i + :> ?+ + :> ?- + +shuffle (points): + n =: points.Count + r =: random tuple n + points =: tuple points select r + :> points + +sum of places (state) lane (tpl): + s =: 0 + ?# i =: tuple tpl give values + v =: state[i] + ? v ~= 0 + s =+ state[i] + :> s + +set user (state): + ?* + print "your move: " nonl + c =: file stream () get + ? c = 'q' || c = 'x' + system exit 0 + n =: string c as integer else () + ? n = () || n < 1 || n > state.Count + print "Invalid input, " nonl + ?^ + ? state[n] = 0 + state[n] =: 1 + :> + print "not free; retry " nonl + +show (state): + state.free =:0 + ?# i =: from 1 upto 9 + v =: state[i] + w =: v + ? v = 0 + w =: i + state.free =+ 1 + ? v = 1 + w =: 'X' + ? v = 4 + w =: 'O' + print ' ' _ w nonl + ? i = 3 || i = 6 + print '' + print '' + \ state.free=0 is used to terminate the central loop diff --git a/Task/Time-a-function/Agena/time-a-function.agena b/Task/Time-a-function/Agena/time-a-function.agena new file mode 100644 index 0000000000..19baf18a28 --- /dev/null +++ b/Task/Time-a-function/Agena/time-a-function.agena @@ -0,0 +1,14 @@ +scope # Time a function + + local procedure timeFunction( f :: procedure ) :: number + local startTime := os.clock(); + f(); + return os.clock() - startTime # execution time in milliseconds + end; + + local procedure toBeTimed() + os.wait( 1.234 ) # sleep 1.234 seconds + end + + print( timeFunction( toBeTimed ) / 1000, " seconds" ) +end diff --git a/Task/Time-a-function/DuckDB/time-a-function.duckdb b/Task/Time-a-function/DuckDB/time-a-function.duckdb new file mode 100644 index 0000000000..3bdea7649c --- /dev/null +++ b/Task/Time-a-function/DuckDB/time-a-function.duckdb @@ -0,0 +1,21 @@ +# A table +create or replace function countto(n) as ( + with recursive cte as ( + select 0 as ix + union all + select ix+1 + from cte + where ix < n) + select last(ix order by ix) + from cte +); + +.timer on +.print .timer is now on +.print 10^4 +select length(range(0, 10_000)); +select countto(10 ^ 4); + +.print 10^5 +select length(range(0, 100_000)); +select countto(10 ^ 5); diff --git a/Task/Time-a-function/Fennel/time-a-function.fennel b/Task/Time-a-function/Fennel/time-a-function.fennel new file mode 100644 index 0000000000..da00463f90 --- /dev/null +++ b/Task/Time-a-function/Fennel/time-a-function.fennel @@ -0,0 +1,22 @@ +(do ;;; Time a function + + (fn time-function [fn-to=be-timed] + (local start-time (os.clock)) + (fn-to=be-timed) + (- (os.clock) start-time) ;;; execution time in seconds + ) + + (fn delay [delta-t] + (local end-time (+ (os.clock) delta-t)) + (while (< (os.clock) end-time) + (var x 0) + (for [i 1 100_000] (set x (+ x 1))) + ) + ) + + (fn test-fn [] + (delay 1.234) ; sleep 1.234 seconds + ) + + (print (time-function test-fn " seconds")) +) diff --git a/Task/Time-a-function/Lua/time-a-function.lua b/Task/Time-a-function/Lua/time-a-function.lua index e7a108419b..40efbdd971 100644 --- a/Task/Time-a-function/Lua/time-a-function.lua +++ b/Task/Time-a-function/Lua/time-a-function.lua @@ -2,7 +2,7 @@ function bench(Function, ...) local t = os.time() local clock1 = os.clock() Function(...) - local c = os.clock()-clock + local c = os.clock()-clock1 return os.time()-t, c end diff --git a/Task/Time-a-function/Pluto/time-a-function.pluto b/Task/Time-a-function/Pluto/time-a-function.pluto new file mode 100644 index 0000000000..a9eecc53d1 --- /dev/null +++ b/Task/Time-a-function/Pluto/time-a-function.pluto @@ -0,0 +1,14 @@ +do -- Time a function + + local function timeFunction( f : function ) : number + local startTime = os.micros() + f() + return os.micros() - startTime + end + + local function toBeTimed() : void + os.sleep( 1234 ) -- sleep 1.234 seconds + end + + print( $"{ timeFunction( toBeTimed ) / 1_000_000 } seconds" ) +end diff --git a/Task/Time-a-function/REXX/time-a-function-2.rexx b/Task/Time-a-function/REXX/time-a-function-2.rexx index b8a590ac0f..b40b4fb45f 100644 --- a/Task/Time-a-function/REXX/time-a-function-2.rexx +++ b/Task/Time-a-function/REXX/time-a-function-2.rexx @@ -1,10 +1,17 @@ --- 22 Mar 2025 -arg count','prec +-- 7 Aug 2025 include Settings +arg count','prec +if count = '' then + count = 1e7 +if prec = '' then + prec = 9 +numeric digits prec say 'TIME A FUNCTION' say version say +say 'Part 1: REXX clauses' +say call Parameters call DoLoop call DoForLoop @@ -57,19 +64,23 @@ say call Stems say call Average +say +say 'Part 2: Profiler' +say +call Profiler 'ArcSin(X)',1/3 +call Profiler 'Exp(X)',1/4 +call Profiler 'Gamma(X)',1/5 +call Profiler 'Ln(X)',1/6 +call Profiler 'Pi()' +call Profiler 'Sin(X)',1/7 +call Profiler 'Sqrt(X)',1/8 +call Profiler 'X',1/9 +call Profiler 'X**5-5/x-1',1/10 +call Profiler 'Zeta(X)',1/11 return Parameters: start = date() time() -if count = '' then - count = 1e6 -if prec = '' then - prec = 9 -parse version version -say 'Version' version -say 'Using loop counter' count/1e6 'million and' Digits() 'digits' -say -numeric digits prec int1 = right(sqrt3(),prec%2); int2 = right(sqrt2(),prec%2) if int2 > int1 then parse value int2 int1 with int1 int2 @@ -478,6 +489,10 @@ else say Left(measure,20) 'cannot perform measure, please try a higher count' return -include Functions -include Constants -include Abend +Profiler: +arg ff,xx,yy,zz +rr=Profile(ff,xx,yy,zz) +say left(ff,10) 'takes' right(word(rr,2),4) 'microsec, x =' xx', f =' word(rr,1)/1 +return + +include Math diff --git a/Task/Tokenize-a-string-with-escaping/Icon/tokenize-a-string-with-escaping.icon b/Task/Tokenize-a-string-with-escaping/Icon/tokenize-a-string-with-escaping.icon new file mode 100644 index 0000000000..8744df9fc4 --- /dev/null +++ b/Task/Tokenize-a-string-with-escaping/Icon/tokenize-a-string-with-escaping.icon @@ -0,0 +1,21 @@ +procedure main() + str := "one^|uno||three^^^^|four^^^|^cuatro|" + every write("\"",!tokenize(str,"|","^"),"\"") +end + +procedure tokenize(str,sep,esc) + ret := [] + token := "" + cse := cset(sep||esc) + str ? + repeat{ + token ||:= tab(i := (upto(cse) | 0)) + if i = 0 then return put(ret,token) + move(1) + if str[i] == sep then{ + put(ret,token) + token := "" + }else + token ||:= move(1) + } +end diff --git a/Task/Tokenize-a-string/DuckDB/tokenize-a-string.duckdb b/Task/Tokenize-a-string/DuckDB/tokenize-a-string.duckdb new file mode 100644 index 0000000000..7d9391bc19 --- /dev/null +++ b/Task/Tokenize-a-string/DuckDB/tokenize-a-string.duckdb @@ -0,0 +1,4 @@ +create or replace function tokenize(s) as ( + regexp_split_to_array(s, ' *, *') +); +select tokenize('Hello,How,Are,You,Today') as tokens; diff --git a/Task/Tokenize-a-string/Refal/tokenize-a-string.refal b/Task/Tokenize-a-string/Refal/tokenize-a-string.refal new file mode 100644 index 0000000000..4dad638e7e --- /dev/null +++ b/Task/Tokenize-a-string/Refal/tokenize-a-string.refal @@ -0,0 +1,15 @@ +$ENTRY Go { + = >>; +}; + +Split { + (e.S) = ; + (e.S) e.1 e.S e.2 = (e.1) ; + (e.S) e.1 = (e.1); +}; + +Join { + (e.J) = ; + (e.J) (e.1) = e.1; + (e.J) (e.1) e.2 = e.1 e.J ; +}; diff --git a/Task/Tokenize-a-string/SETL/tokenize-a-string.setl b/Task/Tokenize-a-string/SETL/tokenize-a-string.setl new file mode 100644 index 0000000000..67670ca08c --- /dev/null +++ b/Task/Tokenize-a-string/SETL/tokenize-a-string.setl @@ -0,0 +1,18 @@ +program tokenize_a_string; + s := 'Hello,How,Are,You,Today'; + loop for part in tokenize(',', s) do + nprint(part + ". "); + end loop; + print; + + proc tokenize(sep, s); + loop + init parts := []; + doing parts with:= break(s, sep); + while s /= "" + do + s := s(2..); + end loop; + return parts; + end proc; +end program; diff --git a/Task/Tokenize-a-string/TAV/tokenize-a-string.tav b/Task/Tokenize-a-string/TAV/tokenize-a-string.tav new file mode 100644 index 0000000000..94127b9070 --- /dev/null +++ b/Task/Tokenize-a-string/TAV/tokenize-a-string.tav @@ -0,0 +1,8 @@ + \ clear explicit version + s =: "Hello,How,Are,You,Today" + r =: string s split by any of ',' \ single character split + print join r by '.' + \ all in one, no parenthesis required + print join string "Hello,How,Are,You,Today" split by any of ',' by '.' + \ parenthesis for clarity + print (join (string "Hello,How,Are,You,Today" split by any of ',') by '.') diff --git a/Task/Tonelli-Shanks-algorithm/Dart/tonelli-shanks-algorithm.dart b/Task/Tonelli-Shanks-algorithm/Dart/tonelli-shanks-algorithm.dart new file mode 100644 index 0000000000..c56c649e82 --- /dev/null +++ b/Task/Tonelli-Shanks-algorithm/Dart/tonelli-shanks-algorithm.dart @@ -0,0 +1,122 @@ +class Pair { + final int n; + final int p; + + Pair(this.n, this.p); +} + +class Solution { + final int root1; + final int root2; + final bool isSquare; + + Solution(this.root1, this.root2, this.isSquare); +} + +int multiplyModulus(int a, int b, int modulus) { + a %= modulus; + b %= modulus; + if (b < a) { + var temp = a; + a = b; + b = temp; + } + + int result = 0; + while (a > 0) { + if (a % 2 == 1) { + result = (result + b) % modulus; + } + b = (b << 1) % modulus; + a >>= 1; + } + return result; +} + +int powerModulus(int base, int exponent, int modulus) { + if (modulus == 1) return 0; + + base %= modulus; + int result = 1; + while (exponent > 0) { + if ((exponent & 1) == 1) { + result = multiplyModulus(result, base, modulus); + } + base = multiplyModulus(base, base, modulus); + exponent >>= 1; + } + return result; +} + +int legendre(int a, int p) { + return powerModulus(a, (p - 1) ~/ 2, p); +} + +Solution tonelliShanks(int n, int p) { + if (legendre(n, p) != 1) { + return Solution(0, 0, false); + } + + // Factor out powers of 2 from p - 1 + int q = p - 1; + int s = 0; + while (q % 2 == 0) { + q ~/= 2; + s += 1; + } + + if (s == 1) { + int result = powerModulus(n, (p + 1) ~/ 4, p); + return Solution(result, p - result, true); + } + + // Find a non-square z such that (z | p) = -1 + int z = 2; + while (legendre(z, p) != p - 1) { + z += 1; + } + + int c = powerModulus(z, q, p); + int t = powerModulus(n, q, p); + int m = s; + int result = powerModulus(n, (q + 1) ~/ 2, p); + + while (t != 1) { + int i = 1; + int zTemp = multiplyModulus(t, t, p); + while (zTemp != 1 && i < m - 1) { + i += 1; + zTemp = multiplyModulus(zTemp, zTemp, p); + } + + int b = powerModulus(c, 1 << (m - i - 1), p); + c = multiplyModulus(b, b, p); + t = multiplyModulus(t, c, p); + m = i; + result = multiplyModulus(result, b, p); + } + + return Solution(result, p - result, true); +} + +void main() { + final List tests = [ + Pair(10, 13), + Pair(56, 101), + Pair(1030, 1009), + Pair(1032, 1009), + Pair(44402, 100049), + Pair(665820697, 1000000009), + Pair(881398088036, 1000000000039), + ]; + + for (final test in tests) { + final solution = tonelliShanks(test.n, test.p); + print('n = ${test.n}, p = ${test.p}'); + if (solution.isSquare) { + print('has solutions: ${solution.root1} and ${solution.root2}\n'); + } else { + print('has no solutions because n is not a square modulo p\n'); + } + } +} diff --git a/Task/Tonelli-Shanks-algorithm/Mathematica/tonelli-shanks-algorithm.math b/Task/Tonelli-Shanks-algorithm/Mathematica/tonelli-shanks-algorithm.math new file mode 100644 index 0000000000..3166ffb7df --- /dev/null +++ b/Task/Tonelli-Shanks-algorithm/Mathematica/tonelli-shanks-algorithm.math @@ -0,0 +1,67 @@ +(* Legendre symbol *) +LegendreSymbol[a_, p_] := PowerMod[a, (p - 1)/2, p] + +(* Tonelli-Shanks Algorithm *) +Tonelli[n_, p_] := Module[ + {q, s, z, c, r, t, m, t2, i, b}, + (* Check that n is a quadratic residue mod p *) + If[LegendreSymbol[n, p] =!= 1, + Message[Tonelli::notsquare, n, p]; Abort[]]; + + (* Step 1: Factor out powers of 2 from p - 1 *) + q = p - 1; + s = 0; + While[EvenQ[q], q = q/2; s++]; + + (* Special case when s == 1 *) + If[s == 1, + Return[PowerMod[n, (p + 1)/4, p]] + ]; + + (* Find a non-residue z *) + For[z = 2, z < p, z++, + If[LegendreSymbol[z, p] == p - 1, Break[]] + ]; + + (* Initialize variables *) + c = PowerMod[z, q, p]; + r = PowerMod[n, (q + 1)/2, p]; + t = PowerMod[n, q, p]; + m = s; + + (* Main loop *) + While[Mod[t - 1, p] =!= 0, + t2 = Mod[t^2, p]; + For[i = 1, i < m, i++, + If[Mod[t2 - 1, p] === 0, Break[]]; + t2 = Mod[t2^2, p]; + ]; + b = PowerMod[c, 2^(m - i - 1), p]; + r = Mod[r*b, p]; + c = Mod[b^2, p]; + t = Mod[t*c, p]; + m = i; + ]; + r +] + +(* Test cases *) +ttest = { + {10, 13}, + {56, 101}, + {1030, 10009}, + {44402, 100049}, + {665820697, 1000000009}, + {881398088036, 1000000000039}, + {41660815127637347468140745042827704103445750172002, 10^50 + 577} +}; + +Do[ + n = ttest[[i, 1]]; + p = ttest[[i, 2]]; + r = Tonelli[n, p]; + Assert[Mod[r^2 - n, p] == 0]; + Print["n = ", n, ", p = ", p]; + Print["\troots : ", r, " ", p - r], + {i, Length[ttest]} +] diff --git a/Task/Tonelli-Shanks-algorithm/PARI-GP/tonelli-shanks-algorithm.parigp b/Task/Tonelli-Shanks-algorithm/PARI-GP/tonelli-shanks-algorithm.parigp new file mode 100644 index 0000000000..6408b9f0b7 --- /dev/null +++ b/Task/Tonelli-Shanks-algorithm/PARI-GP/tonelli-shanks-algorithm.parigp @@ -0,0 +1,123 @@ +/* Legendre symbol */ +legendresymbol(a, p) = +{ + lift(Mod(a, p)^((p-1)/2)); +} + +/* Tonelli-Shanks Algorithm */ +tonelli(n, p) = +{ + local(q, s, z, c, r, t, m, t2, i, b); + + /* Check that n is a quadratic residue mod p */ + if(legendresymbol(n, p) != 1, + error("n is not a quadratic residue mod p")); + + /* Step 1: Factor out powers of 2 from p - 1 */ + q = p - 1; + s = 0; + while(q % 2 == 0, + q = q/2; + s++ + ); + + /* Special case when s == 1 */ + if(s == 1, + return(lift(Mod(n, p)^((p+1)/4))) + ); + + /* Find a non-residue z */ + z = 2; + while(z < p, + if(legendresymbol(z, p) == p - 1, break()); + z++ + ); + + /* Initialize variables */ + c = lift(Mod(z, p)^q); + r = lift(Mod(n, p)^((q+1)/2)); + t = lift(Mod(n, p)^q); + m = s; + + /* Main loop */ + while((t - 1) % p != 0, + t2 = t^2 % p; + i = 1; + while(i < m, + if((t2 - 1) % p == 0, break()); + t2 = t2^2 % p; + i++ + ); + b = lift(Mod(c, p)^(2^(m - i - 1))); + r = (r * b) % p; + c = b^2 % p; + t = (t * c) % p; + m = i + ); + + return(r); +} + +/* Test the functions */ +print("Testing Tonelli-Shanks algorithm:"); +print(); + +/* Test case 1 */ +n = 10; p = 13; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + +/* Test case 2 */ +n = 56; p = 101; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + +/* Test case 3 */ +n = 1030; p = 10009; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + + +/* Test case 4 */ +n = 44402; p = 100049; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + + +/* Test case 5 */ +n = 665820697; p = 1000000009; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + + +/* Test case 6 */ +n = 881398088036; p = 1000000000039; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); + + +/* Test case 7 */ +n = 41660815127637347468140745042827704103445750172002; p = 100000000000000000000000000000000000000000000000577; +r = tonelli(n, p); +print("n = ", n, ", p = ", p); +print("roots: ", r, ", ", p - r); +print("verification: ", r, "^2 mod ", p, " = ", r^2 % p); +print(); diff --git a/Task/Tonelli-Shanks-algorithm/R/tonelli-shanks-algorithm.r b/Task/Tonelli-Shanks-algorithm/R/tonelli-shanks-algorithm.r new file mode 100644 index 0000000000..e8346a4564 --- /dev/null +++ b/Task/Tonelli-Shanks-algorithm/R/tonelli-shanks-algorithm.r @@ -0,0 +1,98 @@ +library(gmp) # For handling large integers and modular arithmetic + +# Legendre symbol: a^((p-1)/2) mod p +legendre <- function(a, p) { + a <- as.bigz(a) + p <- as.bigz(p) + e <- div.bigz(sub.bigz(p, 1), 2) + result <- powm(a, e, p) + return(result) +} + +# Tonelli-Shanks algorithm to find square root of n mod p +tonelli <- function(n, p) { + n <- as.bigz(n) + p <- as.bigz(p) + + # Check that n is a quadratic residue + leg <- legendre(n, p) + if (!identical(as.character(leg), "1")) { + stop("not a square (mod p)") + } + + q <- sub.bigz(p, 1) + s <- 0 + while (mod.bigz(q, 2) == 0) { + q <- div.bigz(q, 2) + s <- s + 1 + } + + if (s == 1) { + e <- div.bigz(add.bigz(p, 1), 4) + return(powm(n, e, p)) + } + + z <- as.bigz(2) + p_minus_1 <- sub.bigz(p, 1) + while (z < p) { + if (identical(as.character(legendre(z, p)), as.character(p_minus_1))) { + break + } + z <- add.bigz(z, 1) + } + + c <- powm(z, q, p) + r <- powm(n, div.bigz(add.bigz(q, 1), 2), p) + t <- powm(n, q, p) + m <- s + + one <- as.bigz(1) + two <- as.bigz(2) + + while (!identical(mod.bigz(sub.bigz(t, one), p), as.bigz(0))) { + t2 <- mod.bigz(mul.bigz(t, t), p) + i <- 1 + while (i < m) { + if (identical(mod.bigz(sub.bigz(t2, one), p), as.bigz(0))) { + break + } + t2 <- mod.bigz(mul.bigz(t2, t2), p) + i <- i + 1 + } + + b_exp <- pow.bigz(two, m - i - 1) + b <- powm(c, b_exp, p) + r <- mod.bigz(mul.bigz(r, b), p) + c <- mod.bigz(mul.bigz(b, b), p) + t <- mod.bigz(mul.bigz(t, c), p) + m <- i + } + + return(r) +} + +# Test cases +ttest <- list( + c("10", "13"), + c("56", "101"), + c("1030", "10009"), + c("44402", "100049"), + c("665820697", "1000000009"), + c("881398088036", "1000000000039"), + c("41660815127637347468140745042827704103445750172002", "100000000000000000000000000000000000000000000000577") +) + +for (case in ttest) { + n <- as.bigz(case[1]) + p <- as.bigz(case[2]) + r <- tonelli(n, p) + check <- mod.bigz(sub.bigz(mul.bigz(r, r), n), p) + + # Verify the result + if (!identical(as.character(check), "0")) { + stop("Verification failed") + } + + cat("n =", as.character(n), "p =", as.character(p), "\n") + cat("\troots :", as.character(r), as.character(sub.bigz(p, r)), "\n") +} diff --git a/Task/Tonelli-Shanks-algorithm/Scala/tonelli-shanks-algorithm.scala b/Task/Tonelli-Shanks-algorithm/Scala/tonelli-shanks-algorithm.scala new file mode 100644 index 0000000000..0d3550f865 --- /dev/null +++ b/Task/Tonelli-Shanks-algorithm/Scala/tonelli-shanks-algorithm.scala @@ -0,0 +1,106 @@ +import java.math.BigInteger +import scala.collection.immutable.List +import scala.annotation.tailrec + +object TonelliShanks { + private val ZERO = BigInteger.ZERO + private val ONE = BigInteger.ONE + private val TEN = BigInteger.TEN + private val TWO = BigInteger.valueOf(2) + private val FOUR = BigInteger.valueOf(4) + + private case class Solution(root1: BigInteger, root2: BigInteger, exists: Boolean) + + private def ts(n: Long, p: Long): Solution = ts(BigInteger.valueOf(n), BigInteger.valueOf(p)) + + private def ts(n: BigInteger, p: BigInteger): Solution = { + val powModP: (BigInteger, BigInteger) => BigInteger = (a, e) => a.modPow(e, p) + val ls: BigInteger => BigInteger = a => powModP(a, p.subtract(ONE).divide(TWO)) + + if (!ls(n).equals(ONE)) return Solution(ZERO, ZERO, false) + + var q = p.subtract(ONE) + var ss = ZERO + while (q.and(ONE).equals(ZERO)) { + ss = ss.add(ONE) + q = q.shiftRight(1) + } + + if (ss.equals(ONE)) { + val r1 = powModP(n, p.add(ONE).divide(FOUR)) + return Solution(r1, p.subtract(r1), true) + } + + var z = TWO + while (!ls(z).equals(p.subtract(ONE))) z = z.add(ONE) + var c = powModP(z, q) + var r = powModP(n, q.add(ONE).divide(TWO)) + var t = powModP(n, q) + var m = ss + + // Convert the while(true) loop to a tail-recursive function + @tailrec + def loop(r: BigInteger, c: BigInteger, t: BigInteger, m: BigInteger): Solution = { + if (t.equals(ONE)) { + Solution(r, p.subtract(r), true) + } else { + var i = ZERO + var zz = t + while (!zz.equals(BigInteger.ONE) && i.compareTo(m.subtract(ONE)) < 0) { + zz = zz.multiply(zz).mod(p) + i = i.add(ONE) + } + var b = c + var e = m.subtract(i).subtract(ONE) + while (e.compareTo(ZERO) > 0) { + b = b.multiply(b).mod(p) + e = e.subtract(ONE) + } + val newR = r.multiply(b).mod(p) + val newC = b.multiply(b).mod(p) + val newT = t.multiply(newC).mod(p) + val newM = i + loop(newR, newC, newT, newM) + } + } + + loop(r, c, t, m) + } + + def main(args: Array[String]): Unit = { + val pairs = List( + (10L, 13L), + (56L, 101L), + (1030L, 10009L), + (1032L, 10009L), + (44402L, 100049L), + (665820697L, 1000000009L), + (881398088036L, 1000000000039L) + ) + + for ((n, p) <- pairs) { + val sol = ts(n, p) + println(s"n = $n") + println(s"p = $p") + if (sol.exists) { + println(s"root1 = ${sol.root1}") + println(s"root2 = ${sol.root2}") + } else { + println("No solution exists") + } + println() + } + + val bn = new BigInteger("41660815127637347468140745042827704103445750172002") + val bp = TEN.pow(50).add(BigInteger.valueOf(577)) + val sol = ts(bn, bp) + println(s"n = $bn") + println(s"p = $bp") + if (sol.exists) { + println(s"root1 = ${sol.root1}") + println(s"root2 = ${sol.root2}") + } else { + println("No solution exists") + } + } +} diff --git a/Task/Top-rank-per-group/DuckDB/top-rank-per-group-1.duckdb b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-1.duckdb new file mode 100644 index 0000000000..74de517b71 --- /dev/null +++ b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-1.duckdb @@ -0,0 +1,14 @@ +create or replace table EMP as + from read_csv_auto('input.csv'); + +create or replace function rank_by_department(number) as table ( + with cte as ( + SELECT *, row_number() OVER (PARTITION BY Department ORDER BY salary desc) as rank + FROM EMP + ) + select * from cte + where rank <= number + order by Department, Salary DESC +); + +from rank_by_department(3); diff --git a/Task/Top-rank-per-group/DuckDB/top-rank-per-group-2.duckdb b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-2.duckdb new file mode 100644 index 0000000000..bf547de47d --- /dev/null +++ b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-2.duckdb @@ -0,0 +1,6 @@ +create or replace table EMP ( + EMP_ID varchar(6), + EMP_NAME varchar(20), + DEPT_ID varchar(4), + SALARY decimal(10,2) +); diff --git a/Task/Top-rank-per-group/DuckDB/top-rank-per-group-3.duckdb b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-3.duckdb new file mode 100644 index 0000000000..949b90bfca --- /dev/null +++ b/Task/Top-rank-per-group/DuckDB/top-rank-per-group-3.duckdb @@ -0,0 +1,3 @@ +create or replace function to_char(s,f) as ( + format('{:9.2f}', s) +); diff --git a/Task/Topic-variable/Maxima/topic-variable.maxima b/Task/Topic-variable/Maxima/topic-variable.maxima new file mode 100644 index 0000000000..74c018bb72 --- /dev/null +++ b/Task/Topic-variable/Maxima/topic-variable.maxima @@ -0,0 +1,9 @@ +3; /* % won't work if $ is used instead of ; */ +[%^2, sqrt(%)]; + +3$ /* _ works with $ or ; */ +[_^2, sqrt(_)]; + +block(x: 3, [%%^2, sqrt(%%)]); + +__+3; /* __ only evaluates itself once to avoid infinite loops */ diff --git a/Task/Topswops/Prolog/topswops.pro b/Task/Topswops/Prolog/topswops.pro new file mode 100644 index 0000000000..376a72028d --- /dev/null +++ b/Task/Topswops/Prolog/topswops.pro @@ -0,0 +1,23 @@ +topswops(N, MaximumSwaps) :- + numlist(1, N, Cards), + aggregate_all(max(Swaps), ( + permutation(Cards, Shuffled), + topswops_(Shuffled, 0, Swaps) + ), MaximumSwaps). + +topswops_([Card | Cards0], Swaps0, Swaps) :- + ( Card = 1 + -> Swaps0 = Swaps + ; succ(Swaps0, Swaps1), + length(Prefix, Card), + append(Prefix, Suffix, [Card | Cards0]), + reverse(Prefix, Reversed), + append(Reversed, Suffix, Cards), + topswops_(Cards, Swaps1, Swaps) + ). + +main :- + foreach( + ( between(1, 10, N), topswops(N, MaximumSwaps) ), + format("~w: ~w~n", [N, MaximumSwaps]) + ). diff --git a/Task/Total-circles-area/00-TASK.txt b/Task/Total-circles-area/00-TASK.txt index e81c603abd..d4e3553bd2 100644 --- a/Task/Total-circles-area/00-TASK.txt +++ b/Task/Total-circles-area/00-TASK.txt @@ -1,3 +1,4 @@ +https://rosettacode.org/wiki/Total_circles_area?action=edit Given some partially overlapping circles on the plane, compute and show the total area covered by them, with four or six (or a little more) decimal digits of precision. The area covered by two or more disks needs to be counted only once. One point of this Task is also to compare and discuss the relative merits of various solution strategies, their performance, precision and simplicity. This means keeping both slower and faster solutions for a language (like C) is welcome. diff --git a/Task/Total-circles-area/Ada/total-circles-area.ada b/Task/Total-circles-area/Ada/total-circles-area.ada new file mode 100644 index 0000000000..22175d5daf --- /dev/null +++ b/Task/Total-circles-area/Ada/total-circles-area.ada @@ -0,0 +1,109 @@ +with Ada.Text_IO; + +procedure Circles_Area is + type Point is record + X, Y : Float; + end record; + + type Circle is record + P : Point; + R : Float; + end record; + + type Box is record + P1, P2 : Point; + end record; + + type Circle_Array is array (1 .. 25) of Circle; + + Circles : constant Circle_Array := + ( + ((1.6417233788, 1.6121789534), 0.0848270516), + ((-1.4944608174, 1.2077959613), 1.1039549836), + ((0.6110294452, -0.6907087527), 0.9089162485), + ((0.3844862411, 0.2923344616), 0.2375743054), + ((-0.2495892950, -0.3832854473), 1.0845181219), + ((1.7813504266, 1.6178237031), 0.8162655711), + ((-0.1985249206, -0.8343333301), 0.0538864941), + ((-1.7011985145, -0.1263820964), 0.4776976918), + ((-0.4319462812, 1.4104420482), 0.7886291537), + ((0.2178372997, -0.9499557344), 0.0357871187), + ((-0.6294854565, -1.3078893852), 0.7653357688), + ((1.7952608455, 0.6281269104), 0.2727652452), + ((1.4168575317, 1.0683357171), 1.1016025378), + ((1.4637371396, 0.9463877418), 1.1846214562), + ((-0.5263668798, 1.7315156631), 1.4428514068), + ((-1.2197352481, 0.9144146579), 1.0727263474), + ((-0.1389358881, 0.1092805780), 0.7350208828), + ((1.5293954595, 0.0030278255), 1.2472867347), + ((-0.5258728625, 1.3782633069), 1.3495508831), + ((-0.1403562064, 0.2437382535), 1.3804956588), + ((0.8055826339, -0.0482092025), 0.3327165165), + ((-0.6311979224, 0.7184578971), 0.2491045282), + ((1.4685857879, -0.8347049536), 1.3670667538), + ((-0.6855727502, 1.6465021616), 1.0593087096), + ((0.0152957411, 0.0638919221), 0.9771215985) + ); + + function Bounding_Box return Box is + C : Circle := Circles (1); + Left : Float := C.P.X - C.R; + Right : Float := C.P.X + C.R; + Down : Float := C.P.Y - C.R; + Up : Float := C.P.Y + C.R; + begin + for I in Circles'Range loop + C := Circles (I); + Left := Float'Min (Left, C.P.X - C.R); + Right := Float'Max (Right, C.P.X + C.R); + Down := Float'Min (Down, C.P.Y - C.R); + Up := Float'Max (Up, C.P.Y + C.R); + end loop; + + return ((Left, Down), (Right, Up)); + end Bounding_Box; + + function Distance2 (P1, P2 : Point) return Float is + ((P2.X - P1.X) ** 2 + (P2.Y - P1.Y) ** 2); + + function Is_Inside (P : Point) return Boolean is + C : Circle; + begin + for I in Circles'Range loop + C := Circles (I); + if Distance2 (C.P, P) < C.R ** 2 then + return True; + end if; + end loop; + + return False; + end Is_Inside; + + -- Use grid sampling + function Area return Float is + Bounds : constant Box := Bounding_Box; + X_Span : constant Float := (Bounds.P2.X - Bounds.P1.X); + Y_Span : constant Float := (Bounds.P2.Y - Bounds.P1.Y); + Grid_Area : constant Float := X_Span * Y_Span; + Steps : constant Integer := 1000; + Points_In, Points_Out : Integer := 0; + P : Point; + begin + for I in 1 .. Steps loop + for J in 1 .. Steps loop + P.X := Bounds.P1.X + X_Span * Float (I) / Float (Steps); + P.Y := Bounds.P1.Y + Y_Span * Float (J) / Float (Steps); + if Is_Inside (P) then + Points_In := Points_In + 1; + else + Points_Out := Points_Out + 1; + end if; + end loop; + end loop; + + return Grid_Area * Float (Points_In) / Float (Points_In + Points_Out); + end Area; + +begin + Ada.Text_IO.Put ("Circles area is " & Area'Image); +end Circles_Area; diff --git a/Task/Total-circles-area/Pluto/total-circles-area-1.pluto b/Task/Total-circles-area/Pluto/total-circles-area-1.pluto new file mode 100644 index 0000000000..64c5a83a07 --- /dev/null +++ b/Task/Total-circles-area/Pluto/total-circles-area-1.pluto @@ -0,0 +1,51 @@ +local class circle + function __construct(public x, public y, public r) end +end + +local circles = { + new circle( 1.6417233788, 1.6121789534, 0.0848270516), + new circle(-1.4944608174, 1.2077959613, 1.1039549836), + new circle( 0.6110294452, -0.6907087527, 0.9089162485), + new circle( 0.3844862411, 0.2923344616, 0.2375743054), + new circle(-0.2495892950, -0.3832854473, 1.0845181219), + new circle( 1.7813504266, 1.6178237031, 0.8162655711), + new circle(-0.1985249206, -0.8343333301, 0.0538864941), + new circle(-1.7011985145, -0.1263820964, 0.4776976918), + new circle(-0.4319462812, 1.4104420482, 0.7886291537), + new circle( 0.2178372997, -0.9499557344, 0.0357871187), + new circle(-0.6294854565, -1.3078893852, 0.7653357688), + new circle( 1.7952608455, 0.6281269104, 0.2727652452), + new circle( 1.4168575317, 1.0683357171, 1.1016025378), + new circle( 1.4637371396, 0.9463877418, 1.1846214562), + new circle(-0.5263668798, 1.7315156631, 1.4428514068), + new circle(-1.2197352481, 0.9144146579, 1.0727263474), + new circle(-0.1389358881, 0.1092805780, 0.7350208828), + new circle( 1.5293954595, 0.0030278255, 1.2472867347), + new circle(-0.5258728625, 1.3782633069, 1.3495508831), + new circle(-0.1403562064, 0.2437382535, 1.3804956588), + new circle( 0.8055826339, -0.0482092025, 0.3327165165), + new circle(-0.6311979224, 0.7184578971, 0.2491045282), + new circle( 1.4685857879, -0.8347049536, 1.3670667538), + new circle(-0.6855727502, 1.6465021616, 1.0593087096), + new circle( 0.0152957411, 0.0638919221, 0.9771215985) +} + +local sq = |v| -> v * v + +local xmin = circles:mapped(|c| -> c.x - c.r):min() +local xmax = circles:mapped(|c| -> c.x + c.r):max() +local ymin = circles:mapped(|c| -> c.y - c.r):min() +local ymax = circles:mapped(|c| -> c.y + c.r):max() +local boxside = 3000 +local dx = (xmax - xmin) / boxside +local dy = (ymax - ymin) / boxside +local count = 0 +for r = 0, boxside - 1 do + local y = ymin + r * dy + for c = 0, boxside - 1 do + local x = xmin + c * dx + local b = circles:find(|cc| -> sq(x - cc.x) + sq(y - cc.y) <= sq(cc.r)) + if b then ++count end + end +end +print($"Approximate area = {count * dx * dy}") diff --git a/Task/Total-circles-area/Pluto/total-circles-area-2.pluto b/Task/Total-circles-area/Pluto/total-circles-area-2.pluto new file mode 100644 index 0000000000..73db8d290f --- /dev/null +++ b/Task/Total-circles-area/Pluto/total-circles-area-2.pluto @@ -0,0 +1,72 @@ +local class point + function __construct(public x, public y) end +end + +local class circle + function __construct(public x, public y, public r) end +end + +local circles = { + new circle( 1.6417233788, 1.6121789534, 0.0848270516), + new circle(-1.4944608174, 1.2077959613, 1.1039549836), + new circle( 0.6110294452, -0.6907087527, 0.9089162485), + new circle( 0.3844862411, 0.2923344616, 0.2375743054), + new circle(-0.2495892950, -0.3832854473, 1.0845181219), + new circle( 1.7813504266, 1.6178237031, 0.8162655711), + new circle(-0.1985249206, -0.8343333301, 0.0538864941), + new circle(-1.7011985145, -0.1263820964, 0.4776976918), + new circle(-0.4319462812, 1.4104420482, 0.7886291537), + new circle( 0.2178372997, -0.9499557344, 0.0357871187), + new circle(-0.6294854565, -1.3078893852, 0.7653357688), + new circle( 1.7952608455, 0.6281269104, 0.2727652452), + new circle( 1.4168575317, 1.0683357171, 1.1016025378), + new circle( 1.4637371396, 0.9463877418, 1.1846214562), + new circle(-0.5263668798, 1.7315156631, 1.4428514068), + new circle(-1.2197352481, 0.9144146579, 1.0727263474), + new circle(-0.1389358881, 0.1092805780, 0.7350208828), + new circle( 1.5293954595, 0.0030278255, 1.2472867347), + new circle(-0.5258728625, 1.3782633069, 1.3495508831), + new circle(-0.1403562064, 0.2437382535, 1.3804956588), + new circle( 0.8055826339, -0.0482092025, 0.3327165165), + new circle(-0.6311979224, 0.7184578971, 0.2491045282), + new circle( 1.4685857879, -0.8347049536, 1.3670667538), + new circle(-0.6855727502, 1.6465021616, 1.0593087096), + new circle( 0.0152957411, 0.0638919221, 0.9771215985) +} + +local sq = |v| -> v * v + +local function area_scan(precision) + + local function sect(c, y) + local dr = math.sqrt(sq(c.r) - sq(y - c.y)) + return new point(c.x - dr, c.x + dr) + end + + local cm1 = circles:mapped(|c| -> c.y + c.r) + local cm2 = circles:mapped(|c| -> c.y - c.r) + local ys = {} + table.move(cm1, 1, #cm1, 1, ys) + table.move(cm2, 1, #cm2, #ys + 1, ys) + local mins = math.floor(ys:min() / precision) + local maxs = math.ceil (ys:max() / precision) + local total = 0 + for x = mins, maxs do + local y = x * precision + local right = -1 / 0 + local points = circles:filtered(|c| -> math.abs(y - c.y) < c.r) + :reorder() + :map(|c| -> sect(c, y)) + :sort(|p1, p2| -> p1.x < p2.x) + for points as p do + if p.y > right then + total += p.y - math.max(p.x, right) + right = p.y + end + end + end + return total * precision +end + +local p = 1e-5 +print($"Approximate area = {area_scan(p)}") diff --git a/Task/Totient-function/Agena/totient-function.agena b/Task/Totient-function/Agena/totient-function.agena new file mode 100644 index 0000000000..2b54086ff8 --- /dev/null +++ b/Task/Totient-function/Agena/totient-function.agena @@ -0,0 +1,46 @@ +scope # Totient function + + # returns the number of integers k where 1 <= k <= n that are mutually prime to n + local procedure totient( n :: number ) :: number + if n < 3 then result := 1 + elif n = 3 then result := 2 + else + result := n; + local v, i := n, 2; + while i * i <= v do + if v mod i = 0 then + while v mod i = 0 do v \:= i od; + result -:= result \ i + fi; + if i = 2 then + i := 1 + fi; + i +:= 2 + od; + if v > 1 then result -:= result \ v fi; + fi; + return result + end; + + # show the totient function values for the first 25 integers + io.write( " n phi(n) remarks\n" ); + for n to 25 do + local constant tn := totient( n ); + printf( "%2d: %5d%s\n", n, tn, if tn = n - 1 and tn <> 0 then " n is prime" else "" fi ) + od; + + # use the totient function to count primes + local n100, n1_000, n10_000, n100_000 := 0, 0, 0, 0; + for n to 100_000 do + if totient( n ) = n - 1 then + if n <= 100 then n100 +:= 1 fi; + if n <= 1000 then n1_000 +:= 1 fi; + if n <= 10000 then n10_000 +:= 1 fi; + if n <= 100000 then n100_000 +:= 1 fi + fi + od; + printf( "There are %6d primes below 100\n", n100 ); + printf( "There are %6d primes below 1 000\n", n1_000 ); + printf( "There are %6d primes below 10 000\n", n10_000 ); + printf( "There are %6d primes below 100 000\n", n100_000 ) +end diff --git a/Task/Totient-function/Fortran/totient-function.f b/Task/Totient-function/Fortran/totient-function.f new file mode 100644 index 0000000000..9957fa9c34 --- /dev/null +++ b/Task/Totient-function/Fortran/totient-function.f @@ -0,0 +1,54 @@ +program totient_function + implicit none + integer, parameter :: M = 100000 + integer :: i, j + integer, dimension(1:M) :: phi + character(len=10) :: is_prime + integer :: count100, count1000, count10000, count100000 + + ! Initialize phi array + do i = 1, M + phi(i) = i + end do + + ! Compute totient using sieve method + do i = 2, M + if (phi(i) == i) then ! i is prime + do j = i, M, i + phi(j) = (phi(j) / i) * (i - 1) + end do + end if + end do + + ! Display for the first 25 integers + print*,'n phi prime' + print*,repeat('-',30) + do i = 1, 25 + if (phi(i) == i - 1) then + is_prime = 'prime' + else + is_prime = 'not prime' + end if + print "(i0,t10,i3,t20,a)", i, phi(i), trim(is_prime) + end do + + ! Count primes up to specified limits + count100 = 0 + count1000 = 0 + count10000 = 0 + count100000 = 0 + do i = 2, M + if (phi(i) == i - 1) then + if (i <= 100) count100 = count100 + 1 + if (i <= 1000) count1000 = count1000 + 1 + if (i <= 10000) count10000 = count10000 + 1 + count100000 = count100000 + 1 + end if + end do + + print *, 'Count of primes up to 100:', count100 + print *, 'Count of primes up to 1,000:', count1000 + print *, 'Count of primes up to 10,000:', count10000 + print *, 'Count of primes up to 100,000:', count100000 + +end program totient_function diff --git a/Task/Totient-function/Lua/totient-function-2.lua b/Task/Totient-function/Lua/totient-function-2.lua index c8689c4256..ec4e85b99f 100644 --- a/Task/Totient-function/Lua/totient-function-2.lua +++ b/Task/Totient-function/Lua/totient-function-2.lua @@ -22,23 +22,20 @@ do io.write( " n phi(n) remarks\n" ) for n = 1,25 do local tn = totient( n ) - io.write( string.format( "%2d", n ), ": ", string.format( "%5d", tn ) - , ( tn == n - 1 and tn ~= 0 and " n is prime" or "" ) - , "\n" - ) + io.write( string.format( "%2d: %5d%s\n", n, tn, ( tn == n - 1 and tn ~= 0 and " n is prime" or "" ) ) ) end -- use the totient function to count primes - local n100, n1000, n10000, n100000 = 0, 0, 0, 0 + local n100, n1_000, n10_000, n100_000 = 0, 0, 0, 0 for n = 1,100000 do if totient( n ) == n - 1 then - if n <= 100 then n100 = n100 + 1 end - if n <= 1000 then n1000 = n1000 + 1 end - if n <= 10000 then n10000 = n10000 + 1 end - if n <= 100000 then n100000 = n100000 + 1 end + if n <= 100 then n100 = n100 + 1 end + if n <= 1000 then n1_000 = n1_000 + 1 end + if n <= 10000 then n10_000 = n10_000 + 1 end + if n <= 100000 then n100_000 = n100_000 + 1 end end end - io.write( "There are ", string.format( "%6d", n100 ), " primes below 100\n" ) - io.write( "There are ", string.format( "%6d", n1000 ), " primes below 1 000\n" ) - io.write( "There are ", string.format( "%6d", n10000 ), " primes below 10 000\n" ) - io.write( "There are ", string.format( "%6d", n100000 ), " primes below 100 000\n" ) + io.write( string.format( "There are %6d primes below 100\n", n100 ) ) + io.write( string.format( "There are %6d primes below 1 000\n", n1_000 ) ) + io.write( string.format( "There are %6d primes below 10 000\n", n10_000 ) ) + io.write( string.format( "There are %6d primes below 100 000\n", n100_000 ) ) end diff --git a/Task/Totient-function/Pluto/totient-function.pluto b/Task/Totient-function/Pluto/totient-function.pluto new file mode 100644 index 0000000000..115229b457 --- /dev/null +++ b/Task/Totient-function/Pluto/totient-function.pluto @@ -0,0 +1,33 @@ +local function totient(n) + local tot = n + local i = 2 + while i * i <= n do + if n % i == 0 then + while n % i == 0 do n //= i end + tot -= tot // i + end + if i == 2 then i = 1 end + i += 2 + end + if n > 1 do tot -= tot // n end + return tot +end + +print(" n phi prime") +print("---------------") +local count = 0 +for n = 1, 25 do + local tot = totient(n) + local isPrime = (n - 1) == tot + if isPrime then ++count end + print(string.format("%2d %2d %s", n, tot, isPrime)) +end +print("\nNumber of primes up to 25 = " .. count) +for n = 26, 100_000 do + local tot = totient(n) + if tot == n - 1 then ++count end + if n == 100 or n == 1_000 or n % 10_000 == 0 then + local ns = string.format("%-6d", n) + print($"\nNumber of primes up to {ns} = {count}") + end +end diff --git a/Task/Towers-of-Hanoi/Maxima/towers-of-hanoi.maxima b/Task/Towers-of-Hanoi/Maxima/towers-of-hanoi.maxima new file mode 100644 index 0000000000..2c717a61ef --- /dev/null +++ b/Task/Towers-of-Hanoi/Maxima/towers-of-hanoi.maxima @@ -0,0 +1,8 @@ +hanoi(n, a, b, c) := block( +if(n=1) then print(sconcat("peg ", a, " to peg ", b)) +else block( + hanoi(n-1, a, c, b), + hanoi(1, a, b, c), + hanoi(n-1, c, b, a)))$ + +hanoi(4,1,2,3)$ diff --git a/Task/Towers-of-Hanoi/Pluto/towers-of-hanoi.pluto b/Task/Towers-of-Hanoi/Pluto/towers-of-hanoi.pluto new file mode 100644 index 0000000000..c84d6ebe88 --- /dev/null +++ b/Task/Towers-of-Hanoi/Pluto/towers-of-hanoi.pluto @@ -0,0 +1,20 @@ +class Hanoi + function __construct(disks) + self.moves = 0 + print($"Towers of Hanoi with {disks} disks:\n") + self:move(disks, "L", "C", "R") + print($"\nCompleted in {self.moves} moves\n") + end + + function move(n, from, to, via) + if n > 0 then + self:move(n - 1, from, via, to) + ++self.moves + print($"Move disk {n} from {from} to {to}") + self:move(n - 1, via, to, from) + end + end +end + +new Hanoi(3) +new Hanoi(4) diff --git a/Task/Towers-of-Hanoi/Red/towers-of-hanoi.red b/Task/Towers-of-Hanoi/Red/towers-of-hanoi.red new file mode 100644 index 0000000000..d5bf88399c --- /dev/null +++ b/Task/Towers-of-Hanoi/Red/towers-of-hanoi.red @@ -0,0 +1,9 @@ +Red [ "Towers of Hanoi - Hinjo, 20 July 2025" ] +hanoi: function [n src tgt aux] [ + if n > 0 [ + hanoi n - 1 src aux tgt + print ["Move from " src " to " tgt] + hanoi n - 1 aux tgt src + ] +] +hanoi 5 "A" "C" "B" diff --git a/Task/Trabb-Pardo-Knuth-algorithm/Pluto/trabb-pardo-knuth-algorithm.pluto b/Task/Trabb-Pardo-Knuth-algorithm/Pluto/trabb-pardo-knuth-algorithm.pluto new file mode 100644 index 0000000000..c42e7b1e6d --- /dev/null +++ b/Task/Trabb-Pardo-Knuth-algorithm/Pluto/trabb-pardo-knuth-algorithm.pluto @@ -0,0 +1,22 @@ +require "io2" +local fmt = require "fmt" + +local f = |x| -> math.sqrt(math.abs(x)) + 5 * x * x * x + +local s = {} +print("Please enter 11 numbers:") +local count = 0 +repeat + s[++count] = io.readNum(string.format(" Number %-2d : ", count)) +until count == 11 + +s:reverse() +print("\nResults:") +for s as item do + local fi = f(item) + if fi <= 400 then + fmt.print(" f(%6.3f) = %7.3f", item, fi) + else + fmt.print(" f(%6.3f) = overflow", item) + end +end diff --git a/Task/Trabb-Pardo-Knuth-algorithm/Prolog/trabb-pardo-knuth-algorithm.pro b/Task/Trabb-Pardo-Knuth-algorithm/Prolog/trabb-pardo-knuth-algorithm.pro new file mode 100644 index 0000000000..c493139f2b --- /dev/null +++ b/Task/Trabb-Pardo-Knuth-algorithm/Prolog/trabb-pardo-knuth-algorithm.pro @@ -0,0 +1,26 @@ +:- use_module(library(dcg/basics)). +:- use_module(library(dcg/high_order)). + +main :- + % ask for 11 numbers to be read into a sequence S + format("Enter 11 numbers for evaluation~n", []), + length(S, 11), + phrase_from_stream((sequence(integer, "\n", S), remainder(_)), user_input), + + % reverse sequence S + reverse(S, ReversedS), + + % for each item in sequence S + foreach(( + member(Item, ReversedS), + % result := call a function to do an operation + Result is sqrt(abs(Item)) + 5 * Item ^ 3 + ), + % if result overflows + ( Result > 400 + % alert user + -> format("~d: OVERFLOW~n", [Item]) + % else print result + ; format("~d: ~f~n", [Item, Result]) + ) + ). diff --git a/Task/Trabb-Pardo-Knuth-algorithm/QB64/trabb-pardo-knuth-algorithm.qb64 b/Task/Trabb-Pardo-Knuth-algorithm/QB64/trabb-pardo-knuth-algorithm.qb64 new file mode 100644 index 0000000000..ea9c82ac61 --- /dev/null +++ b/Task/Trabb-Pardo-Knuth-algorithm/QB64/trabb-pardo-knuth-algorithm.qb64 @@ -0,0 +1,26 @@ +Dim s(1 To 11) As Double +Dim x As Double +Dim i As Integer + +Print "enter 11 numbers" +For i = 1 To 11 + Print i; " => "; + Input s(i) +Next i + +Print: Print String$(20, "-") + +For i = 11 To 1 Step -1 + x = f(s(i)) + Print "f("; s(i); ") = "; + If x > 400 Then + Print "-=< overflow >=-" + Else + Print x + End If +Next i +End + +Function f (n As Double) + f = Sqr(Abs(n)) + 5 * n ^ 3 +End Function diff --git a/Task/Transliterate-English-text-using-the-Greek-alphabet/FreeBASIC/transliterate-english-text-using-the-greek-alphabet.basic b/Task/Transliterate-English-text-using-the-Greek-alphabet/FreeBASIC/transliterate-english-text-using-the-greek-alphabet.basic new file mode 100644 index 0000000000..3bcd628279 --- /dev/null +++ b/Task/Transliterate-English-text-using-the-Greek-alphabet/FreeBASIC/transliterate-english-text-using-the-greek-alphabet.basic @@ -0,0 +1,118 @@ +Dim As String texts(2) +texts(0) = "The quick brown fox jumped over the lazy dog." +texts(1) = "I was looking at some rhododendrons in my back garden," & Chr(10) & "dressed in my khaki shorts, when the telephone rang." & Chr(10) & Chr(10) & "As I answered it, I cheerfully glimpsed that the July sun" & Chr(10) & "caused a fragment of black pine wax to ooze on the velvet quilt" & Chr(10) & "laying in my patio." +texts(2) = "sphinx of black quartz, judge my vow." + +Type Replacement + oldStr As String + newStr As String +End Type + +Dim Shared As Replacement replacements(51) +replacements(0).oldStr = "ch" : replacements(0).newStr = "χ" +replacements(1).oldStr = "th" : replacements(1).newStr = "θ" +replacements(2).oldStr = "ps" : replacements(2).newStr = "ψ" +replacements(3).oldStr = "ph" : replacements(3).newStr = "f" +replacements(4).oldStr = "Ch" : replacements(4).newStr = "Χ" +replacements(5).oldStr = "Th" : replacements(5).newStr = "Θ" +replacements(6).oldStr = "Ps" : replacements(6).newStr = "Ψ" +replacements(7).oldStr = "Ph" : replacements(7).newStr = "F" +replacements(8).oldStr = "ee" : replacements(8).newStr = "h" +replacements(9).oldStr = "ck" : replacements(9).newStr = "κ" +replacements(10).oldStr = "rh" : replacements(10).newStr = "r" +replacements(11).oldStr = "kh" : replacements(11).newStr = "χ" +replacements(12).oldStr = "Kh" : replacements(12).newStr = "Χ" +replacements(13).oldStr = "oo" : replacements(13).newStr = "w" +replacements(14).oldStr = "a" : replacements(14).newStr = "α" +replacements(15).oldStr = "b" : replacements(15).newStr = "β" +replacements(16).oldStr = "c" : replacements(16).newStr = "κ" +replacements(17).oldStr = "d" : replacements(17).newStr = "δ" +replacements(18).oldStr = "e" : replacements(18).newStr = "ε" +replacements(19).oldStr = "f" : replacements(19).newStr = "φ" +replacements(20).oldStr = "g" : replacements(20).newStr = "γ" +replacements(21).oldStr = "h" : replacements(21).newStr = "η" +replacements(22).oldStr = "i" : replacements(22).newStr = "ι" +replacements(23).oldStr = "j" : replacements(23).newStr = "ι" +replacements(24).oldStr = "k" : replacements(24).newStr = "κ" +replacements(25).oldStr = "l" : replacements(25).newStr = "λ" +replacements(26).oldStr = "m" : replacements(26).newStr = "μ" +replacements(27).oldStr = "n" : replacements(27).newStr = "ν" +replacements(28).oldStr = "o" : replacements(28).newStr = "ο" +replacements(29).oldStr = "p" : replacements(29).newStr = "π" +replacements(30).oldStr = "q" : replacements(30).newStr = "κ" +replacements(31).oldStr = "r" : replacements(31).newStr = "ρ" +replacements(32).oldStr = "s" : replacements(32).newStr = "σ" +replacements(33).oldStr = "t" : replacements(33).newStr = "τ" +replacements(34).oldStr = "u" : replacements(34).newStr = "υ" +replacements(35).oldStr = "v" : replacements(35).newStr = "β" +replacements(36).oldStr = "w" : replacements(36).newStr = "ω" +replacements(37).oldStr = "x" : replacements(37).newStr = "ξ" +replacements(38).oldStr = "y" : replacements(38).newStr = "υ" +replacements(39).oldStr = "z" : replacements(39).newStr = "ζ" +replacements(40).oldStr = "D" : replacements(40).newStr = "Δ" +replacements(41).oldStr = "F" : replacements(41).newStr = "Φ" +replacements(42).oldStr = "G" : replacements(42).newStr = "Γ" +replacements(43).oldStr = "J" : replacements(43).newStr = "I" +replacements(44).oldStr = "L" : replacements(44).newStr = "Λ" +replacements(45).oldStr = "P" : replacements(45).newStr = "Π" +replacements(46).oldStr = "Q" : replacements(46).newStr = "Κ" +replacements(47).oldStr = "R" : replacements(47).newStr = "Ρ" +replacements(48).oldStr = "S" : replacements(48).newStr = "Σ" +replacements(49).oldStr = "Y" : replacements(49).newStr = "U" +replacements(50).oldStr = "W" : replacements(50).newStr = "Ω" +replacements(51).oldStr = "X" : replacements(51).newStr = "Ξ" + +' Special replacement for "s" at the end of a word or followed by a non-letter +Function replaceSigmaFinal(txt As String) As String + Dim As String res = "" + Dim As Integer i, l = Len(txt) + For i = 1 To l + If Mid(txt, i, 1) = "s" Then + If i = l Or (Mid(txt, i+1, 1) < "A" Or (Mid(txt, i+1, 1) > "Z" And Mid(txt, i+1, 1) < "a") Or Mid(txt, i+1, 1) > "z") Then + res &= "ς" + Else + res &= "s" + End If + Else + res &= Mid(txt, i, 1) + End If + Next + Return res +End Function + +Function replaceString(ByVal txt As String, ByVal buscar As String, ByVal reemplazar As String) As String + Dim As Integer posic = 1, lenBuscar = Len(buscar) + Dim As String resultado = "" + + If lenBuscar = 0 Then Return txt ' Avoid infinite loop + + Do + Dim As Integer idx = InStr(posic, txt, buscar) + If idx = 0 Then + resultado &= Mid(txt, posic) + Exit Do + End If + resultado &= Mid(txt, posic, idx - posic) & reemplazar + posic = idx + lenBuscar + Loop + + Return resultado +End Function + +Function replaceText(txt As String) As String + txt = ReplaceSigmaFinal(txt) + For i As Integer = 0 To UBound(replacements) + txt = ReplaceString(txt, replacements(i).oldStr, replacements(i).newStr) + Next + Return txt +End Function + +' Test program +For i As Integer = Lbound(texts) To Ubound(texts) + Print texts(i) + Print "=>" + Print replaceText(texts(i)) + Print String(65, "=") +Next + +Sleep diff --git a/Task/Tree-datastructures/Rust/tree-datastructures.rs b/Task/Tree-datastructures/Rust/tree-datastructures.rs new file mode 100644 index 0000000000..0583ffe856 --- /dev/null +++ b/Task/Tree-datastructures/Rust/tree-datastructures.rs @@ -0,0 +1,125 @@ +#[derive(Debug, Clone, PartialEq)] +pub struct NestTree { + name: String, + children: Vec, +} + +impl NestTree { + pub fn new(name: &str) -> Self { + NestTree { + name: name.to_string(), + children: Vec::new(), + } + } + + pub fn add_child(&mut self, name: &str) { + self.children.push(NestTree::new(name)); + } + + pub fn get_child_mut(&mut self, index: usize) -> Option<&mut NestTree> { + self.children.get_mut(index) + } + + pub fn print(&self) { + self.print_with_level(0); + } + + fn print_with_level(&self, level: usize) { + let indent = " ".repeat(level * 4); + println!("{}{}", indent, self.name); + for child in &self.children { + child.print_with_level(level + 1); + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn children(&self) -> &[NestTree] { + &self.children + } + + pub fn equals(&self, other: &NestTree) -> bool { + self == other + } +} + +pub struct IndentTree { + items: Vec<(i32, String)>, +} + +impl IndentTree { + pub fn new(nest: &NestTree) -> Self { + let mut items = Vec::new(); + items.push((0, nest.name().to_string())); + + let mut indent_tree = IndentTree { items }; + indent_tree.from_nest(nest, 0); + indent_tree + } + + fn from_nest(&mut self, nest: &NestTree, level: i32) { + for child in nest.children() { + self.items.push((level + 1, child.name().to_string())); + self.from_nest(child, level + 1); + } + } + + pub fn print(&self) { + for (level, name) in &self.items { + println!("{} {}", level, name); + } + } + + pub fn to_nest(&self) -> NestTree { + let mut nest = NestTree::new(&self.items[0].1); + self.to_nest_recursive(&mut nest, 1, 0); + nest + } + + fn to_nest_recursive(&self, nest: &mut NestTree, mut pos: usize, level: i32) -> usize { + while pos < self.items.len() && self.items[pos].0 == level + 1 { + nest.add_child(&self.items[pos].1); + let child_index = nest.children().len() - 1; + if let Some(child) = nest.get_child_mut(child_index) { + pos = self.to_nest_recursive(child, pos + 1, level + 1); + } else { + pos += 1; + } + } + pos + } +} + +fn main() { + let mut n = NestTree::new("RosettaCode"); + + // Add children + n.add_child("rocks"); + n.add_child("mocks"); + + // Access children by index to avoid borrowing issues + if let Some(child1) = n.get_child_mut(0) { + child1.add_child("code"); + child1.add_child("comparison"); + child1.add_child("wiki"); + } + + if let Some(child2) = n.get_child_mut(1) { + child2.add_child("trolling"); + } + + println!("Initial nest format:"); + n.print(); + + let i = IndentTree::new(&n); + println!("\nIndent format:"); + i.print(); + + let n2 = i.to_nest(); + println!("\nFinal nest format:"); + n2.print(); + + println!("\nAre initial and final nest formats equal? {}", n.equals(&n2)); +} diff --git a/Task/Tree-datastructures/Zig/tree-datastructures.zig b/Task/Tree-datastructures/Zig/tree-datastructures.zig new file mode 100644 index 0000000000..8591cdf2af --- /dev/null +++ b/Task/Tree-datastructures/Zig/tree-datastructures.zig @@ -0,0 +1,182 @@ +const std = @import("std"); +const ArrayList = std.ArrayList; +const Allocator = std.mem.Allocator; +const print = std.debug.print; + +pub const NestTree = struct { + name: []const u8, + children: ArrayList(NestTree), + allocator: Allocator, + + pub fn init(allocator: Allocator, name: []const u8) !NestTree { + const owned_name = try allocator.dupe(u8, name); + return NestTree{ + .name = owned_name, + .children = ArrayList(NestTree).init(allocator), + .allocator = allocator, + }; + } + + pub fn deinit(self: *NestTree) void { + for (self.children.items) |*child| { + child.deinit(); + } + self.children.deinit(); + self.allocator.free(self.name); + } + + pub fn addChild(self: *NestTree, name: []const u8) !void { + const child = try NestTree.init(self.allocator, name); + try self.children.append(child); + } + + pub fn getChildMut(self: *NestTree, index: usize) ?*NestTree { + if (index >= self.children.items.len) return null; + return &self.children.items[index]; + } + + pub fn printTree(self: *const NestTree) void { + self.printWithLevel(0); + } + + fn printWithLevel(self: *const NestTree, level: usize) void { + var i: usize = 0; + while (i < level * 4) : (i += 1) { + print(" " , .{}); + } + print("{s}\n", .{self.name}); + + for (self.children.items) |*child| { + child.printWithLevel(level + 1); + } + } + + pub fn getName(self: *const NestTree) []const u8 { + return self.name; + } + + pub fn getChildren(self: *const NestTree) []const NestTree { + return self.children.items; + } + + pub fn equals(self: *const NestTree, other: *const NestTree) bool { + if (!std.mem.eql(u8, self.name, other.name)) return false; + if (self.children.items.len != other.children.items.len) return false; + + for (self.children.items, other.children.items) |*child1, *child2| { + if (!child1.equals(child2)) return false; + } + + return true; + } +}; + +pub const IndentTree = struct { + items: ArrayList(IndentItem), + allocator: Allocator, + + const IndentItem = struct { + level: i32, + name: []const u8, + }; + + pub fn init(allocator: Allocator, nest: *const NestTree) !IndentTree { + var items = ArrayList(IndentItem).init(allocator); + const root_name = try allocator.dupe(u8, nest.getName()); + try items.append(IndentItem{ .level = 0, .name = root_name }); + + var indent_tree = IndentTree{ + .items = items, + .allocator = allocator, + }; + + try indent_tree.fromNest(nest, 0); + return indent_tree; + } + + pub fn deinit(self: *IndentTree) void { + for (self.items.items) |item| { + self.allocator.free(item.name); + } + self.items.deinit(); + } + + fn fromNest(self: *IndentTree, nest: *const NestTree, level: i32) !void { + for (nest.getChildren()) |*child| { + const child_name = try self.allocator.dupe(u8, child.getName()); + try self.items.append(IndentItem{ .level = level + 1, .name = child_name }); + try self.fromNest(child, level + 1); + } + } + + pub fn printTree(self: *const IndentTree) void { + for (self.items.items) |item| { + print("{} {s}\n", .{ item.level, item.name }); + } + } + + pub fn toNest(self: *const IndentTree) !NestTree { + if (self.items.items.len == 0) return error.EmptyIndentTree; + + var nest = try NestTree.init(self.allocator, self.items.items[0].name); + _ = try self.toNestRecursive(&nest, 1, 0); + return nest; + } + + fn toNestRecursive(self: *const IndentTree, nest: *NestTree, pos: usize, level: i32) !usize { + var current_pos = pos; + + while (current_pos < self.items.items.len and self.items.items[current_pos].level == level + 1) { + try nest.addChild(self.items.items[current_pos].name); + const child_index = nest.children.items.len - 1; + if (nest.getChildMut(child_index)) |child| { + current_pos = try self.toNestRecursive(child, current_pos + 1, level + 1); + } else { + current_pos += 1; + } + } + + return current_pos; + } +}; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + var n = try NestTree.init(allocator, "RosettaCode"); + defer n.deinit(); + + // Add children + try n.addChild("rocks"); + try n.addChild("mocks"); + + // Access children by index to avoid borrowing issues + if (n.getChildMut(0)) |child1| { + try child1.addChild("code"); + try child1.addChild("comparison"); + try child1.addChild("wiki"); + } + + if (n.getChildMut(1)) |child2| { + try child2.addChild("trolling"); + } + + print("Initial nest format:\n" , .{}); + n.printTree(); + + var i = try IndentTree.init(allocator, &n); + defer i.deinit(); + + print("\nIndent format:\n" , .{}); + i.printTree(); + + var n2 = try i.toNest(); + defer n2.deinit(); + + print("\nFinal nest format:\n" , .{} ); + n2.printTree(); + + print("\nAre initial and final nest formats equal? {}\n", .{n.equals(&n2)}); +} diff --git a/Task/Tree-from-nesting-levels/Icon/tree-from-nesting-levels.icon b/Task/Tree-from-nesting-levels/Icon/tree-from-nesting-levels.icon new file mode 100644 index 0000000000..c4f9e4b06e --- /dev/null +++ b/Task/Tree-from-nesting-levels/Icon/tree-from-nesting-levels.icon @@ -0,0 +1,46 @@ +procedure main() + tests := [ [], [1, 2, 4], [3, 1, 3, 1], [1, 2, 3, 1], [3, 2, 1, 3], + [3, 3, 3, 1, 1, 3, 3, 3], [3, 3, 3, 2, 2, 3, 4, 3], + [1, 2, 4, 2, 2, 1] ] + + every test := !tests do + if result := tfnl(test) then + write(limage2(test)," ---> ",limage2(result)) + else + write(limage2(test)," ---> FAILED") +end + +procedure tfnl(levels) + innerlist := [] + level := levels[1] | fail + put(r := [], nested(level,level-1,innerlist)) | fail + /innerlist[1] := r + every i := 2 to *levels & level := levels[i] do + if j := i-1 to 1 by -1 & level >= levels[j] then{ + put(innerlist[j], nested(level,level-levels[j],innerlist)) + /innerlist[i] := innerlist[j] + }else{ + put(r, nested(level,level-1,innerlist)) + /innerlist[i] := r + } + return r +end + +procedure nested(item,level,innerlist) + if level = 0 then{ # special case + put(innerlist,&null) + return item + } + outer := inner := [] + every 2 to level do inner := put(inner,[])[1] + put(inner,item) + put(innerlist,inner) + return outer +end + +procedure limage2(L) + if type(L) ~== "list" then return image(L) + result := "" + every result ||:= limage2(!L) || "," + return ("[" || result[1:-1] || "]") | "[]" +end diff --git a/Task/Tree-traversal/Adina/tree-traversal-1.adina b/Task/Tree-traversal/Adina/tree-traversal-1.adina new file mode 100644 index 0000000000..7c04186ab7 --- /dev/null +++ b/Task/Tree-traversal/Adina/tree-traversal-1.adina @@ -0,0 +1,63 @@ +структура узел + данные левая-ветвь правая-ветвь + #:суффикс -узла + +лист значение = + узел значение ложь ложь + +дерево = + узел 1 + узел 2 + узел 4 + лист 7 + ложь + лист 5 + узел 3 + узел 6 + лист 8 + лист 9 + ложь + +прямой дерево действие = + если дерево тогда + действие данные-узла(дерево) + прямой левая-ветвь-узла(дерево) действие + прямой правая-ветвь-узла(дерево) действие + +центрированный дерево действие = + если дерево тогда + центрированный левая-ветвь-узла(дерево) действие + действие данные-узла(дерево) + центрированный правая-ветвь-узла(дерево) действие + +обратный дерево действие = + если дерево тогда + обратный левая-ветвь-узла(дерево) действие + обратный правая-ветвь-узла(дерево) действие + действие данные-узла(дерево) + +поуровневый дерево действие = + пусть цикл + деревья список(дерево) + если не пустой?(деревья) тогда + цикл + применить добавить + цикл/список + для + дерево деревья + #:когда дерево + действие данные-узла(дерево) + список левая-ветвь-узла(дерево) правая-ветвь-узла(дерево) + +запуск имя обход = + вывести имя + обход дерево + функция (данные) + вывести « » + вывести данные + вывести/перенос «» + +запуск «preorder: » прямой +запуск «inorder: » центрированный +запуск «postorder: » обратный +запуск «level-order: » поуровневый diff --git a/Task/Tree-traversal/Adina/tree-traversal-2.adina b/Task/Tree-traversal/Adina/tree-traversal-2.adina new file mode 100644 index 0000000000..a479f360d8 --- /dev/null +++ b/Task/Tree-traversal/Adina/tree-traversal-2.adina @@ -0,0 +1,68 @@ +english() + +struct node + data left right + +leaf x = + node x #f #f + +the-tree = + node 1 + node 2 + node 4 + leaf 7 + #f + leaf 5 + node 3 + node 6 + leaf 8 + leaf 9 + #f + +preorder tree visit = + let loop + $ t tree + when t + visit node-data(t) + loop node-left(t) + loop node-right(t) + +inorder tree visit = + let loop + $ t tree + when t + loop node-left(t) + visit node-data(t) + loop node-right(t) + +postorder tree visit = + let loop + $ t tree + when t + loop node-left(t) + loop node-right(t) + visit node-data(t) + +levelorder tree visit = + let loop + $ trees + list tree + unless null?(trees) + loop + append* + for/list + (t trees) #:when t + visit node-data(t) + list node-left(t) node-right(t) + +run name order = + printf "~a" name + order the-tree + lambda (x) + printf " ~s" x + newline() + +run "preorder: " preorder +run "inorder: " inorder +run "postorder: " postorder +run "level-order: " levelorder diff --git a/Task/Trigonometric-functions/DuckDB/trigonometric-functions.duckdb b/Task/Trigonometric-functions/DuckDB/trigonometric-functions.duckdb new file mode 100644 index 0000000000..a81a0ac0e5 --- /dev/null +++ b/Task/Trigonometric-functions/DuckDB/trigonometric-functions.duckdb @@ -0,0 +1,22 @@ +# degrees to radians +create or replace function radians(degrees) as degrees * pi() / 180.0; + +# radians to degrees +create or replace function degrees(radians) as (radians * 180 / pi()); + +.mode lines +select + sin(-pi() / 6), + cos(3 * pi() / 4), + tan(pi() / 3), + asin(-1 / 2), + acos(-sqrt(2)/2), + atan(sqrt(3)), + + -- Using degrees: + sin(-radians(30)), + cos(radians(135)), + tan(radians(60)), + asin(-1 / 2).degrees(), + acos(-sqrt(2)/2).degrees(), + atan(sqrt(3)).degrees() ; diff --git a/Task/Trigonometric-functions/REXX/trigonometric-functions.rexx b/Task/Trigonometric-functions/REXX/trigonometric-functions.rexx index 1b71fa05ce..8e6a9053d6 100644 --- a/Task/Trigonometric-functions/REXX/trigonometric-functions.rexx +++ b/Task/Trigonometric-functions/REXX/trigonometric-functions.rexx @@ -1,6 +1,7 @@ +-- 28 Jul 2025 include Settings -say 'TRIGONOMETRIC FUNCTIONS - 2 Mar 2025' +say 'TRIGONOMETRIC FUNCTIONS' say version say s = Copies('-',77); w = 18 @@ -39,6 +40,4 @@ end say s return -include Functions -include Constants -include Abend +include Math diff --git a/Task/Twos-complement/Ada/twos-complement.ada b/Task/Twos-complement/Ada/twos-complement.ada new file mode 100644 index 0000000000..dd3ebbe70d --- /dev/null +++ b/Task/Twos-complement/Ada/twos-complement.ada @@ -0,0 +1,10 @@ +with Ada.Text_IO; + +procedure Twos_Complement is + type Number is mod 2 ** 32; + A : constant Number := 42; + B : constant Number := not A + 1; + Is_Negative : constant Boolean := A + B = 0; +begin + Ada.Text_IO.Put_Line ("B = -A is " & Is_Negative'Image); +end Twos_Complement; diff --git a/Task/Twos-complement/Fortran/twos-complement.f b/Task/Twos-complement/Fortran/twos-complement.f new file mode 100644 index 0000000000..160e76a191 --- /dev/null +++ b/Task/Twos-complement/Fortran/twos-complement.f @@ -0,0 +1,57 @@ +! +program twos_complement_demo + implicit none + + integer :: x, tc + integer :: nbits + character(len=:), allocatable :: bits_x, bits_not, bits_tc + + ! Prompt for input + write(*,"(a)",advance="no") "Enter a positive integer (or any integer):" + read *, x + + ! Determine bit-width and convert to bit-strings + nbits = bit_size(x) + bits_x = to_bitstring(x) + bits_not = to_bitstring(not(x)) + + ! Compute two's complement: flip all bits then add one + tc = not(x) + 1 + bits_tc = to_bitstring(tc) + + ! Display results + 10 format(a,t30,i0) + 20 format(a,i0,a,t30,a,/) + 30 format(a,t30,a) + write(*,*) + write(*,10) "Original integer:", x + write(*,20) "Bit pattern (", nbits, " bits):", trim(bits_x) + write(*,30) "After bitwise NOT: ", trim(bits_not) + write(*,30) "Then add 1 --> two’s comp:", trim(bits_tc) + write(*,*) + write(*,10) "Two’s complement (decimal):", tc + +contains + + !------------------------------------------------------------ + ! Convert an integer to a string of ‘0’ and ‘1’ + !------------------------------------------------------------ + function to_bitstring(val) result(str) + integer, intent(in) :: val + character(len=:), allocatable :: str + integer :: n, i + + ! Number of bits in this integer kind + n = bit_size(val) + allocate(character(len=n) :: str) + + do i = 1, n + if (btest(val, n - i)) then + str(i:i) = '1' + else + str(i:i) = '0' + end if + end do + end function to_bitstring + +end program twos_complement_demo diff --git a/Task/UPC/Pluto/upc.pluto b/Task/UPC/Pluto/upc.pluto new file mode 100644 index 0000000000..ac82a43fa1 --- /dev/null +++ b/Task/UPC/Pluto/upc.pluto @@ -0,0 +1,110 @@ +local fmt = require "fmt" + +local digitL = { + [" ## #"] = 0, + [" ## #"] = 1, + [" # ##"] = 2, + [" #### #"] = 3, + [" # ##"] = 4, + [" ## #"] = 5, + [" # ####"] = 6, + [" ### ##"] = 7, + [" ## ###"] = 8, + [" # ##"] = 9 +} + +local digitR = { + ["### # "] = 0, + ["## ## "] = 1, + ["## ## "] = 2, + ["# # "] = 3, + ["# ### "] = 4, + ["# ### "] = 5, + ["# # "] = 6, + ["# # "] = 7, + ["# # "] = 8, + ["### # "] = 9 +} + +local end_sentinel = "# #" -- also at start +local mid_sentinel = " # # " + +local function decode_upc(s) + local function decode_upc_impl(input) + local upc = input:strip() + if #upc != 95 then return false end + local pos = 1 + local digits = {} + local sum = 0 + local one_three = {1, 3} + + -- end sentinel + if upc:sub(pos, pos + 2) == end_sentinel then + pos += 3 + else + return false + end + + -- 6 left hand digits + for _ = 1, 6 do + local digit = digitL[upc:sub(pos, pos + 6)] + if !digit then return false end + digits:insert(digit) + sum += digit * one_three[#digits % 2 + 1] + pos += 7 + end + + -- mid sentinel + if upc:sub(pos, pos + 4) == mid_sentinel then + pos += 5 + else + return false + end + + -- 6 right hand digits + for _ = 1, 6 do + local digit = digitR[upc:sub(pos, pos + 6)] + if !digit then return false end + digits:insert(digit) + sum += digit * one_three[#digits % 2 + 1] + pos += 7 + end + + -- end sentinel + if upc:sub(pos, pos + 2) != end_sentinel then return false end + + if sum % 10 == 0 then + fmt.write("%s ", fmt.swrite(digits)) + return true + end + io.write("Failed Checksum ") + return false + end + + if decode_upc_impl(s) then + print("Rightside Up") + elseif decode_upc_impl(s:reverse()) then + print("Upside Down") + else + print("Invalid digit(s)") + end +end + +local barcodes = { + " # # # ## # ## # ## ### ## ### ## #### # # # ## ## # # ## ## ### # ## ## ### # # # ", + " # # # ## ## # #### # # ## # ## # ## # # # ### # ### ## ## ### # # ### ### # # # ", + " # # # # # ### # # # # # # # # # # ## # ## # ## # ## # # #### ### ## # # ", + " # # ## ## ## ## # # # # ### # ## ## # # # ## ## # ### ## ## # # #### ## # # # ", + " # # ### ## # ## ## ### ## # ## # # ## # # ### # ## ## # # ### # ## ## # # # ", + " # # # # ## ## # # # # ## ## # # # # # #### # ## # #### #### # # ## # #### # # ", + " # # # ## ## # # ## ## # ### ## ## # # # # # # # # ### # # ### # # # # # ", + " # # # # ## ## # # ## ## ### # # # # # ### ## ## ### ## ### ### ## # ## ### ## # # ", + " # # ### ## ## # # #### # ## # #### # #### # # # # # ### # # ### # # # ### # # # ", + " # # # #### ## # #### # # ## ## ### #### # # # # ### # ### ### # # ### # # # ### # # " +} +local n = 0 +for barcodes as barcode do + ++n + fmt.write("%2d: ", n) + decode_upc(barcode) +end diff --git a/Task/UPC/Rust/upc.rs b/Task/UPC/Rust/upc.rs new file mode 100644 index 0000000000..a7932479be --- /dev/null +++ b/Task/UPC/Rust/upc.rs @@ -0,0 +1,161 @@ +use std::collections::HashMap; + +fn trim(s: &str) -> &str { + s.trim() +} + +// Helper function to create the left digits map +fn create_left_digits() -> HashMap<&'static str, i32> { + let mut map = HashMap::new(); + map.insert(" ## #", 0); + map.insert(" ## #", 1); + map.insert(" # ##", 2); + map.insert(" #### #", 3); + map.insert(" # ##", 4); + map.insert(" ## #", 5); + map.insert(" # ####", 6); + map.insert(" ### ##", 7); + map.insert(" ## ###", 8); + map.insert(" # ##", 9); + map +} + +// Helper function to create the right digits map +fn create_right_digits() -> HashMap<&'static str, i32> { + let mut map = HashMap::new(); + map.insert("### # ", 0); + map.insert("## ## ", 1); + map.insert("## ## ", 2); + map.insert("# # ", 3); + map.insert("# ### ", 4); + map.insert("# ### ", 5); + map.insert("# # ", 6); + map.insert("# # ", 7); + map.insert("# # ", 8); + map.insert("### # ", 9); + map +} + +const END_SENTINEL: &str = "# #"; +const MID_SENTINEL: &str = " # # "; + +fn decode_upc(input: &str) { + let left_digits = create_left_digits(); + let right_digits = create_right_digits(); + + let decode = |candidate: &str| -> (bool, Vec) { + let mut output = Vec::new(); + let mut pos = 0; + + // Check start sentinel + if candidate.len() < pos + END_SENTINEL.len() { + return (false, output); + } + let part = &candidate[pos..pos + END_SENTINEL.len()]; + if part == END_SENTINEL { + pos += END_SENTINEL.len(); + } else { + return (false, output); + } + + // Decode left 6 digits + for _ in 0..6 { + if candidate.len() < pos + 7 { + return (false, output); + } + let part = &candidate[pos..pos + 7]; + pos += 7; + + if let Some(&digit) = left_digits.get(part) { + output.push(digit); + } else { + return (false, output); + } + } + + // Check middle sentinel + if candidate.len() < pos + MID_SENTINEL.len() { + return (false, output); + } + let part = &candidate[pos..pos + MID_SENTINEL.len()]; + if part == MID_SENTINEL { + pos += MID_SENTINEL.len(); + } else { + return (false, output); + } + + // Decode right 6 digits + for _ in 0..6 { + if candidate.len() < pos + 7 { + return (false, output); + } + let part = &candidate[pos..pos + 7]; + pos += 7; + + if let Some(&digit) = right_digits.get(part) { + output.push(digit); + } else { + return (false, output); + } + } + + // Check end sentinel + if candidate.len() < pos + END_SENTINEL.len() { + return (false, output); + } + let part = &candidate[pos..pos + END_SENTINEL.len()]; + if part == END_SENTINEL { + pos += END_SENTINEL.len(); + } else { + return (false, output); + } + + // Calculate checksum + let sum: i32 = output.iter().enumerate().map(|(i, &digit)| { + if i % 2 == 0 { + 3 * digit + } else { + digit + } + }).sum(); + + (sum % 10 == 0, output) + }; + + let candidate = trim(input); + + let (valid, digits) = decode(candidate); + if valid { + println!("{:?}", digits); + } else { + // Try upside down + let reversed: String = candidate.chars().rev().collect(); + let (valid_reversed, digits_reversed) = decode(&reversed); + if valid_reversed { + println!("{:?} Upside down", digits_reversed); + } else if !digits.is_empty() { + println!("Invalid checksum"); + } else { + println!("Invalid digit(s)"); + } + } +} + +fn main() { + let barcodes = vec![ + " # # # ## # ## # ## ### ## ### ## #### # # # ## ## # # ## ## ### # ## ## ### # # # ", + " # # # ## ## # #### # # ## # ## # ## # # # ### # ### ## ## ### # # ### ### # # # ", + " # # # # # ### # # # # # # # # # # ## # ## # ## # ## # # #### ### ## # # ", + " # # ## ## ## ## # # # # ### # ## ## # # # ## ## # ### ## ## # # #### ## # # # ", + " # # ### ## # ## ## ### ## # ## # # ## # # ### # ## ## # # ### # ## ## # # # ", + " # # # # ## ## # # # # ## ## # # # # # #### # ## # #### #### # # ## # #### # # ", + " # # # ## ## # # ## ## # ### ## ## # # # # # # # # ### # # ### # # # # # ", + " # # # # ## ## # # ## ## ### # # # # # ### ## ## ### ## ### ### ## # ## ### ## # # ", + " # # ### ## ## # # #### # ## # #### # #### # # # # # ### # # ### # # # ### # # # ", + " # # # #### ## # #### # # ## ## ### #### # # # # ### # ### ### # # ### # # # ### # # ", + ]; + + for barcode in &barcodes { + decode_upc(barcode); + } +} diff --git a/Task/UPC/Scala/upc.scala b/Task/UPC/Scala/upc.scala new file mode 100644 index 0000000000..c8270fdf84 --- /dev/null +++ b/Task/UPC/Scala/upc.scala @@ -0,0 +1,129 @@ +object UPC { + private val SEVEN = 7 + + private val LEFT_DIGITS = Map( + " ## #" -> 0, + " ## #" -> 1, + " # ##" -> 2, + " #### #" -> 3, + " # ##" -> 4, + " ## #" -> 5, + " # ####" -> 6, + " ### ##" -> 7, + " ## ###" -> 8, + " # ##" -> 9 + ) + + private val RIGHT_DIGITS = LEFT_DIGITS.map { case (key, value) => + key.replace(' ', 's').replace('#', ' ').replace('s', '#') -> value + } + + private val END_SENTINEL = "# #" + private val MID_SENTINEL = " # # " + + private def decode(candidate: String): (Boolean, List[Int]) = { + var pos = 0 + val output = scala.collection.mutable.ListBuffer[Int]() + + // Check start sentinel + if (candidate.length < pos + END_SENTINEL.length || + candidate.substring(pos, pos + END_SENTINEL.length) != END_SENTINEL) { + return (false, output.toList) + } + pos += END_SENTINEL.length + + // Decode left side digits + for (_ <- 1 until SEVEN) { + if (candidate.length < pos + SEVEN) { + return (false, output.toList) + } + val part = candidate.substring(pos, pos + SEVEN) + pos += SEVEN + + LEFT_DIGITS.get(part) match { + case Some(digit) => output += digit + case None => return (false, output.toList) + } + } + + // Check middle sentinel + if (candidate.length < pos + MID_SENTINEL.length || + candidate.substring(pos, pos + MID_SENTINEL.length) != MID_SENTINEL) { + return (false, output.toList) + } + pos += MID_SENTINEL.length + + // Decode right side digits + for (_ <- 1 until SEVEN) { + if (candidate.length < pos + SEVEN) { + return (false, output.toList) + } + val part = candidate.substring(pos, pos + SEVEN) + pos += SEVEN + + RIGHT_DIGITS.get(part) match { + case Some(digit) => output += digit + case None => return (false, output.toList) + } + } + + // Check end sentinel + if (candidate.length < pos + END_SENTINEL.length || + candidate.substring(pos, pos + END_SENTINEL.length) != END_SENTINEL) { + return (false, output.toList) + } + + // Calculate checksum + val sum = output.zipWithIndex.map { case (digit, index) => + if (index % 2 == 0) 3 * digit else digit + }.sum + + (sum % 10 == 0, output.toList) + } + + private def printList(list: List[Int]): Unit = { + print("[") + print(list.mkString(", ")) + print("]") + } + + private def decodeUPC(input: String): Unit = { + val candidate = input.trim + val (isValid, digits) = decode(candidate) + + if (isValid) { + printList(digits) + println() + } else { + // Try upside down + val reversed = candidate.reverse + val (isValidReversed, digitsReversed) = decode(reversed) + + if (isValidReversed) { + printList(digitsReversed) + println(" Upside down") + } else if (digitsReversed.length == 12) { + println("Invalid checksum") + } else { + println("Invalid digit(s)") + } + } + } + + def main(args: Array[String]): Unit = { + val barcodes = List( + " # # # ## # ## # ## ### ## ### ## #### # # # ## ## # # ## ## ### # ## ## ### # # # ", + " # # # ## ## # #### # # ## # ## # ## # # # ### # ### ## ## ### # # ### ### # # # ", + " # # # # # ### # # # # # # # # # # ## # ## # ## # ## # # #### ### ## # # ", + " # # ## ## ## ## # # # # ### # ## ## # # # ## ## # ### ## ## # # #### ## # # # ", + " # # ### ## # ## ## ### ## # ## # # ## # # ### # ## ## # # ### # ## ## # # # ", + " # # # # ## ## # # # # ## ## # # # # # #### # ## # #### #### # # ## # #### # # ", + " # # # ## ## # # ## ## # ### ## ## # # # # # # # # ### # # ### # # # # # ", + " # # # # ## ## # # ## ## ### # # # # # ### ## ## ### ## ### ### ## # ## ### ## # # ", + " # # ### ## ## # # #### # ## # #### # #### # # # # # ### # # ### # # # ### # # # ", + " # # # #### ## # #### # # ## ## ### #### # # # # ### # ### ### # # ### # # # ### # # " + ) + + barcodes.foreach(decodeUPC) + } +} diff --git a/Task/URL-decoding/DuckDB/url-decoding.duckdb b/Task/URL-decoding/DuckDB/url-decoding.duckdb new file mode 100644 index 0000000000..366491b3a4 --- /dev/null +++ b/Task/URL-decoding/DuckDB/url-decoding.duckdb @@ -0,0 +1,27 @@ +create or replace function hex2chr(pxx) as + replace(pxx,'%','').from_hex().decode() ; + +create or replace function urldecode(url) as ( + WITH RECURSIVE cte AS ( + -- Base case: set xx as the first sequence of %XX encodings if any + SELECT + replace(url, '+', ' ') AS decoded, + regexp_extract(replace(url, '+', ' '), '(%[0-9A-Fa-f]{2})+') AS xx + UNION ALL + -- Recursive case: replace the xx encodings with the decoded character(s) + SELECT + replace(decoded, xx, xx.hex2chr()) AS decoded, + regexp_extract(replace(decoded, xx, ' '), '(%[0-9A-Fa-f]{2})+') as xx + FROM cte + WHERE xx != '' + ) + SELECT decoded FROM cte + WHERE xx = '' +); + +SELECT s, url_decode(s), urldecode(s) +FROM unnest( [ + 'http%3A%2F%2Ffoo%20bar%2F', + 'google.com/search?q=%60Abdu%27l-Bah%C3%A1', + '%25%32%35' + ]) _(s); diff --git a/Task/UTF-8-encode-and-decode/DuckDB/utf-8-encode-and-decode.duckdb b/Task/UTF-8-encode-and-decode/DuckDB/utf-8-encode-and-decode.duckdb new file mode 100644 index 0000000000..f08b197743 --- /dev/null +++ b/Task/UTF-8-encode-and-decode/DuckDB/utf-8-encode-and-decode.duckdb @@ -0,0 +1,12 @@ +create or replace function utf8x(codepoint) as ( + select hex(encode(chr(codepoint))) +); + +# Example: +select s, + unicode(s) as codepoint, + chr(codepoint) as c, + unicode(c), + utf8x(codepoint), + decode(from_hex(utf8x(codepoint))) as "decode(from_hex())" +from values ('A'), ('ö'), ('Ж'), ('€'), ('𝄞') t(s); diff --git a/Task/Undefined-values/YAMLScript/undefined-values.ys b/Task/Undefined-values/YAMLScript/undefined-values.ys new file mode 100644 index 0000000000..970fd00f36 --- /dev/null +++ b/Task/Undefined-values/YAMLScript/undefined-values.ys @@ -0,0 +1,9 @@ +!YS-v0 + +x =: +y =: 1 + +each v qw(x y): + if v:symbol:resolve:bound?: + say: "$v is defined" + say: "$v is not defined" diff --git a/Task/Unicode-strings/00-TASK.txt b/Task/Unicode-strings/00-TASK.txt index 2b6c3dc5de..10bd3e4617 100644 --- a/Task/Unicode-strings/00-TASK.txt +++ b/Task/Unicode-strings/00-TASK.txt @@ -1,6 +1,6 @@ As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, [[Unicode]] is your best friend. -It is a very capable and [https://www.youtube.com/watch?v=MijmeoH9LT4 remarquable] tool, but also quite complex compared to older single- and double-byte character encodings. +It is a very capable and [https://www.youtube.com/watch?v=MijmeoH9LT4 remarkable] tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for Unicode? diff --git a/Task/Unicode-strings/EasyLang/unicode-strings.easy b/Task/Unicode-strings/EasyLang/unicode-strings.easy new file mode 100644 index 0000000000..8bc99ea0f5 --- /dev/null +++ b/Task/Unicode-strings/EasyLang/unicode-strings.easy @@ -0,0 +1,14 @@ +s$ = "你好 😀" +print len s$ +for c$ in strchars s$ + print c$ & " " & strcode c$ +. +print strpos s$ "好" +print strchar 128512 +print s$ +flag$ = "🇮🇹" +print flag$ +print len flag$ +for c$ in strchars flag$ + print c$ & " " & strcode c$ +. diff --git a/Task/Unicode-strings/Pluto/unicode-strings.pluto b/Task/Unicode-strings/Pluto/unicode-strings.pluto new file mode 100644 index 0000000000..756380921c --- /dev/null +++ b/Task/Unicode-strings/Pluto/unicode-strings.pluto @@ -0,0 +1,26 @@ +require "uchar" +require "gchar" +local fmt = require("fmt") + +local w = "voilà" +local u = uchar.of(w) +for i = 1, u:len() do + io.write($"{u:get(i)} ") -- prints the 5 Unicode 'characters' +end +print($"\nThe length of {w} is {u:len()}") + +print("\nIts code-points are:") +fmt.lprint(u:tocodes(), " ", "") -- prints the code-points as numbers + +print("\n\nIts bytes are: ") +fmt.lprint(u:tobytes(), " ", "") -- prints the bytes as numbers + +local zwe = "👨‍👩‍👧" +local g = gchar.of(zwe) +local codepoints = g:tocodes() +local bytes = g:tobytes() + +print($"\n\n{zwe} has:") +fmt.print(" %d bytes: %s", #bytes, fmt.swrite(bytes, " ", "")) +fmt.print(" %d code-points: %s", #codepoints, fmt.swrite(codepoints, " ", "")) +fmt.print(" %d grapheme", g:len()) diff --git a/Task/Unix-ls/DuckDB/unix-ls.duckdb b/Task/Unix-ls/DuckDB/unix-ls.duckdb new file mode 100644 index 0000000000..0426aff992 --- /dev/null +++ b/Task/Unix-ls/DuckDB/unix-ls.duckdb @@ -0,0 +1 @@ +from glob('*') order by file; diff --git a/Task/Unprimeable-numbers/Agena/unprimeable-numbers.agena b/Task/Unprimeable-numbers/Agena/unprimeable-numbers.agena new file mode 100644 index 0000000000..1071fc9ba9 --- /dev/null +++ b/Task/Unprimeable-numbers/Agena/unprimeable-numbers.agena @@ -0,0 +1,101 @@ +scope # find unprimeable numbers - numbers which can't be made into a prime by changing one digit + + local constant maxNumber := 9_999_999; # maximum number we will consider + + # sieve the primes up to maxNumber + local prime; create register prime( maxNumber ); + prime[ 1 ] := false; + for sPos from 2 to maxNumber do prime[ sPos ] := true od; + for sPos from 2 to entier( sqrt( maxNumber ) ) do + if prime[ sPos ] then + for p from sPos * sPos to maxNumber by sPos do + prime[ p ] := false + od + fi + od; + + # returns true if n is unprimeable, false otherwise + local procedure isUnprimeable( n :: number ) :: boolean + local result := false; + if n < 100 then return false + elif prime[ n ] then return false + else + # need to try changing a digit + local constant lastDigit := n mod 10; + local constant leadingDigits := n - lastDigit; + if prime[ leadingDigits + 1 ] then return false + elif prime[ leadingDigits + 3 ] then return false + elif prime[ leadingDigits + 7 ] then return false + elif prime[ leadingDigits + 9 ] then return false + elif lastDigit = 2 or lastDigit = 5 then + # the final digit is 2 or 5, changing the other digits can't make a prime + # unless there is only one other digit which we can change to 0 + local v, dc := leadingDigits \ 10, 1; + while v > 0 do + if v mod 10 <> 0 then dc +:= 1 fi; + v \:= 10 + od; + return dc <> 2 + elif not odd lastDigit then + return true # last digit is even, changing the other digits won't make a prime + else + # last digit is 1, 3, 7, 9: must try changing the other digits + local m10, r10 := 10, 100; + result := true; + while result and n > r10 do + local constant base := ( ( n \ r10 ) * r10 ) + ( n mod m10 ); + for i from 0 by m10 while result and i < r10 do + result := not prime[ base + i ] + od; + m10 *:= 10; + r10 *:= 10 + od; + if result then + # still not unprimeable, try changing the first digit + local constant base := n mod m10; + for i from 0 by m10 while result and i < r10 do + result := not prime[ base + i ] + od + fi + fi + fi; + return result + end + + # returns a string representation of n with commas, n must be an integer + local procedure commatise( n :: number ) :: string + local constant nStr := tostring( abs n ); + local constant signStr := if n < 0 then "-" else "" fi; + local constant cStr := strings.reverse( strings.gsub( strings.reverse( nStr ), "%d%d%d", "%1," ) ); + return signStr & strings.gsub( cStr, "^,", "" ) + end; + + scope # find unprimeable numbers + local uCount, dCount := 0, 0; + local firstUnprimeable := reg( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); # note: indexed from 1 + for i from 100 while i < size prime and dCount < 10 do + if isUnprimeable( i ) then + uCount +:= 1; + if uCount = 1 then + printf( "First 35 unprimeable numbers: %d", i ) + elif uCount <= 35 then + printf( " %d", i ) + elif uCount = 600 then + printf( "\n600th unprimeable number: %s", commatise( i ) ) + fi; + # need to add 1 to the final digit because firstUnprimeable is indxed from 1 + local constant finalDigitPlus1 := ( i mod 10 ) + 1; + if firstUnprimeable[ finalDigitPlus1 ] = 0 then + # first unprimeable number with this final digit + dCount +:= 1; + firstUnprimeable[ finalDigitPlus1 ] := i + fi + fi + od; + # show the first unprimeable number that ends with each digit + print(); + for i from 0 to size firstUnprimeable - 1 do + printf( "First unprimeable number ending in %d: %s\n", i, commatise( firstUnprimeable[ i + 1 ] ) ) + od + end +end diff --git a/Task/Unprimeable-numbers/Pluto/unprimeable-numbers.pluto b/Task/Unprimeable-numbers/Pluto/unprimeable-numbers.pluto new file mode 100644 index 0000000000..6f3e66f19e --- /dev/null +++ b/Task/Unprimeable-numbers/Pluto/unprimeable-numbers.pluto @@ -0,0 +1,97 @@ +do -- find unprimable numbers - numbers which can't be made into a prime by changing one digit + + local fmt = require( "fmt" ) -- RC Pluto formatting library + local int = require( "int" ) -- RC Pluto integer library - inc. some prime utilities + + local maxNumber = 9_999_999 -- maximum number we will consider + + -- sieve the primes up to maxNumber + local prime = int.arecomps( maxNumber ):map( | v | -> not v ) + + -- returns true if n is unprimeable, false otherwise + local function isUnprimeable( n : number ) : boolean + local result = false + if n < 100 then return false + elseif prime[ n ] then return false + else + -- need to try changing a digit + local lastDigit = n % 10 + local leadingDigits = n - lastDigit + if prime[ leadingDigits + 1 ] then return false + elseif prime[ leadingDigits + 3 ] then return false + elseif prime[ leadingDigits + 7 ] then return false + elseif prime[ leadingDigits + 9 ] then return false + elseif lastDigit == 2 or lastDigit == 5 then + -- the final digit is 2 or 5, changing the other digits can't make a prime + -- unless there is only one other digit which we can change to 0 + local v, dc = leadingDigits // 10, 1 + while v > 0 do + if v % 10 != 0 then dc += 1 end + v //= 10 + end + return dc != 2 + elseif lastDigit % 2 == 0 then + return true -- last digit is even, changing the other digits won't make a prime + else + -- last digit is 1, 3, 7, 9 must try changing the other digits + local m10, r10 = 10, 100 + result = true + while result and n > r10 do + local base = ( ( n // r10 ) * r10 ) + ( n % m10 ) + local i = 0 + while result and i < r10 do + result = not prime[ base + i ] + i += m10 + end + m10 *= 10 + r10 *= 10 + end + if result then + -- still not unprimeable, try changing the first digit + local base = n % m10 + local i = 0 + while result and i < r10 do + result = not prime[ base + i ] + i += m10 + end + end + end + end + return result + end + + -- returns a string representation of n with commas, n must be an integer + local function commatise( n : number ) : string + local cStr = tostring( math.abs( n ) ):reverse():gsub( "%d%d%d", "%1," ):reverse() + return if n < 0 then "-" else "" end..cStr:gsub( "^,", "" ) + end + + do -- find unprimeable numbers + local uCount, dCount = 0, 0 + local firstUnprimeable = { [0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + for i = 100, # prime do + if dCount >= 10 then break end + if isUnprimeable( i ) then + uCount += 1 + if uCount == 1 then + fmt.write( "First 35 unprimeable numbers: %d", i ) + elseif uCount <= 35 then + fmt.write( " %d", i ) + elseif uCount == 600 then + fmt.write( "\n600th unprimeable number: %s", commatise( i ) ) + end + local finalDigit = i % 10 + if firstUnprimeable[ finalDigit ] == 0 then + -- first unprimeable number with this final digit + dCount += 1 + firstUnprimeable[ finalDigit ] = i + end + end + end + -- show the first unprimeable number that ends with each digit + fmt.write( "\n" ) + for i = 0, 9 do + fmt.write( "First unprimeable number ending in %d %s\n", i, commatise( firstUnprimeable[ i ] ) ) + end + end +end diff --git a/Task/Unprimeable-numbers/REXX/unprimeable-numbers.rexx b/Task/Unprimeable-numbers/REXX/unprimeable-numbers.rexx index a6ca596e28..07ac31ba1b 100644 --- a/Task/Unprimeable-numbers/REXX/unprimeable-numbers.rexx +++ b/Task/Unprimeable-numbers/REXX/unprimeable-numbers.rexx @@ -1,4 +1,4 @@ --- 22 Mar 2025 +-- 3 Aug 2025 include Settings say 'UNPRIMEABLE NUMBERS' @@ -89,6 +89,4 @@ say '-----------' say Format(Time('e'),,3) 'seconds'; say return -include Functions -include Sequences -include Abend +include Math diff --git a/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-1.jl b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-1.jl new file mode 100644 index 0000000000..e21eeb4c16 --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-1.jl @@ -0,0 +1,21 @@ +// Save this section as main.c +#include + +extern int Query (char * Data, size_t * Length); + +int main (int argc, char * argv []) +{ + char Buffer [1024]; + size_t Size = sizeof (Buffer); + + if (0 == Query (Buffer, &Size)) + { + printf ("failed to call Query\n"); + } + else + { + char * Ptr = Buffer; + while (Size-- > 0) putchar (*Ptr++); + putchar ('\n'); + } +} diff --git a/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-2.jl b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-2.jl new file mode 100644 index 0000000000..9a7b4a3d08 --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-2.jl @@ -0,0 +1,17 @@ +# Save this section as a file called query.jl + +function Query(buffer::Ptr{UInt8}, length::Ptr{Csize_t})::Cint + """ Define the Query function to be called from C """ + + max_size = unsafe_load(length) + data = "Hello from Julia!" + bytes = codeunits(data) + max_size < length(bytes) && return 0 # Failure: buffer too small + for i in 1:length(bytes) + unsafe_store!(buffer, bytes[i], i) + end + unsafe_store!(length, length(bytes)) + return 1 +end + +Base.@export Query diff --git a/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-3.jl b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-3.jl new file mode 100644 index 0000000000..210c4ec0c2 --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-3.jl @@ -0,0 +1,33 @@ +// save this section as query_wrapper.c + +#include + +JULIA_DEFINE_FAST_TLS() + +int Query(char *Data, size_t *Length) { + jl_init(); + + jl_eval_string("include(\"query.jl\")"); // Include the Julia file containing Query function + + jl_function_t *func = jl_get_function(jl_main_module, "Query"); + if (!func) { + jl_atexit_hook(0); + return 0; + } + + jl_value_t *buffer = jl_ptr_to_array_1d(jl_uint8_type, Data, *Length, 0); + jl_value_t *length = jl_box_uint64((uint64_t)Length); + + // Call the query function within Julia + jl_value_t *result = jl_call2(func, buffer, length); + if (jl_exception_occurred()) { + jl_atexit_hook(0); + return 0; + } + + // Get return value + int ret = jl_unbox_int32(result); + + jl_atexit_hook(0); + return ret; // Return the result of the Query function from the C shared library +} diff --git a/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-4.jl b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-4.jl new file mode 100644 index 0000000000..42ffe58ace --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Julia/use-another-language-to-call-a-function-4.jl @@ -0,0 +1,19 @@ +# Save this section as compile.sh and run it in a terminal with all files in same directory +gcc -shared -fPIC -o libquery.so query_wrapper.c -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib -ljulia -Wl,-rpath,$JULIA_DIR/lib +if [ $? -ne 0 ]; then + echo "Error: Compilation of libquery.so failed." + exit 1 +fi +echo "libquery.so compiled successfully." + +gcc -o main main.c -L. -lquery +if [ $? -ne 0 ]; then + echo "Error: Compilation of main failed." + exit 1 +fi +echo "main compiled successfully." + +export LD_LIBRARY_PATH=.:$JULIA_DIR/lib:$LD_LIBRARY_PATH +./main + +echo "Script finished." diff --git a/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-1.lua b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-1.lua new file mode 100644 index 0000000000..474a9c5d9e --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-1.lua @@ -0,0 +1,24 @@ +-- Query.lua + +-- basic kv dbase +function qdb_init () + qdb = {} -- global in lua + qdb["who are you?"] = "I am Lua" + qdb["what are you?"] = "I am a Lua virtual machine" + qdb["when are you?"] = "I am live" + qdb["where are you?"] = "Here I am" + qdb["how are you?"] = "I am a fine" + qdb["default"] = "unknown query" + +end + +-- call from C with key => Data +function Query(k) + + local key = string.lower(k) + + if (qdb[key] == nil) then key = "default" end + + lua_response = qdb[key] + +end diff --git a/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-2.lua b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-2.lua new file mode 100644 index 0000000000..ea13576fb6 --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-2.lua @@ -0,0 +1,205 @@ +/* Query_lua.c */ +#include +#include +#include +#include + +#include +#include +#include + +// tell lua how many args for a function +typedef enum { NOARG, ONEARG, TWOARGS, THREEARGS } argcount; +// 0 1 2 3 + +// diagnostics when things go wrong +typedef enum { C_OK, C_FAILURE, LUA_FAILURE} exitcode; +// 0 1 2 + +/* lua vars we will create or use */ +const char* lua_Query = "Query"; +const char* lua_Data = "Data"; +const char* lua_qdb_init = "qdb_init"; +const char* lua_qdb = "qdb"; +const char* lua_response = "lua_response"; + + +int LTop; // global C index to top of lua stack + +/* function prototypes */ + +int Query(char* Data, size_t * Length); + +void fail(const char* fmsg, const char* errstr, exitcode ret); + +lua_State* C_lua_init(const char* luafile); + +bool C_push_string(lua_State* L, const char* name, + const char* str, const size_t n); + +bool C_get_string( lua_State * L, const char* src, + char* dest, size_t max); + + +// exit program with diagnostice and exitcode +void fail(const char* fmsg, const char* errstr, exitcode ret) { + + fprintf(stderr, "%s ", fmsg); + + if (errstr != NULL){ fprintf(stderr, "%s ", errstr); } + + fprintf(stderr, "\n"); + + exit(ret); +} + + +// push C string to lua +bool C_push_string(lua_State* L, const char* name, + const char* str, const size_t n){ + (void) n; + lua_pushstring(L, str); + lua_setglobal(L, name); + return true; +} + +// get C string from lua string by variable var +bool C_get_string( lua_State * L, const char* luavar, + char* dest, size_t max){ + + const char* lstring = NULL; + size_t len = 0; + + lua_getglobal(L, luavar); + + if(!lua_isstring(L, -1)) { + fail("expected a string", lua_tostring(L, -1), LUA_FAILURE); + } + + LTop = lua_gettop(L); + + lstring = lua_tolstring(L, LTop, &max ); + len = strlen(lstring); + + if (len > 0) { + strncpy(dest, lstring, len); + dest[len+1] = '\0'; + return true; + } + + return false; +} + + +/* + initialize the lua vm + load up the lua file + any commands in the global area will run +*/ + +lua_State* C_lua_init(const char* luafile) { + + exitcode status = C_OK; + + /// creates Lua machine & env + lua_State* L = luaL_newstate(); + if (L == NULL) { + fail("could not create lua state", "lua internal failure", LUA_FAILURE); + } + + // imports basic libs like string, io, os, table, utf-8, math + luaL_openlibs(L); + + // lua file to load + status = luaL_loadfile(L, luafile); + + if (status != LUA_OK){ + fail("loadfile failed", lua_tostring(L, -1), LUA_FAILURE); + } + + /* "priming run" + SEE http://www.troubleshooters.com/codecorn/lua/lua_c_calls_lua.htm + */ + if (lua_pcall(L, 0, 0, 0) != LUA_OK) { + fail("priming run failed",lua_tostring(L, -1), LUA_FAILURE); + } + + return L; +} + +/* -------------------------------------------------- + function called by main in Query.c +*/ + +int Query(char* Data, size_t * Length) { + + /* ======= SETUP LUA ====== */ + // create Lua vm with file + lua_State* L = C_lua_init("Query.lua"); + + // call db init + lua_getglobal(L, lua_qdb_init); + luaL_checktype(L, -1, LUA_TFUNCTION); // optionally check lua type + + int result = lua_pcall(L, NOARG, 0, 0); // execute lua func + if (result != LUA_OK) { + fail("failed to run qdb_init function", lua_tostring(L, -1), LUA_FAILURE); + } + + /* ======= RUN LUA CODE ========= */ + + // put Data into Lua env as a string + C_push_string(L, lua_Data, Data, *Length-1); + + /* set function to call and 1 arg(s) */ + lua_getglobal(L, lua_Query); // function + luaL_checktype(L, -1, LUA_TFUNCTION); + + lua_getglobal(L, lua_Data); // arg + luaL_checktype(L, -1, LUA_TSTRING); + + // call lua function with 1 arg* + result = lua_pcall(L, ONEARG, LUA_MULTRET, 0); + if (result != LUA_OK) { + fail("failed to run Query function", lua_tostring(L, -1), LUA_FAILURE); + } + + // lua_response should have our answer + char* response = calloc(*Length, sizeof(char)); + if (response == NULL) { + fail("calloc failed allocation", NULL, C_FAILURE); + } + + // created within lua + C_get_string(L, lua_response, response, *Length); + + + /* ======== CLEANUP LUA ====== */ + + // clean up lua vars and close vm + // (assign var = nil) + lua_pushnil(L); lua_setglobal(L, lua_response); + lua_pushnil(L); lua_setglobal(L, lua_Data); + lua_pushnil(L); lua_setglobal(L, lua_Query); + lua_pushnil(L); lua_setglobal(L, lua_qdb); + lua_close(L); // lua is done + + + /* ======= REPORT ====== */ + + size_t rlen = strlen(response); + + if (rlen > 0) { + strncpy(Data, response, *Length-1); + Data[rlen] = '\0'; + free(response); // because dynamically allocated + } else { + fail("lua", "no response", LUA_FAILURE); + } + + + return 1; +} + + +// end diff --git a/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-3.lua b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-3.lua new file mode 100644 index 0000000000..850ea4a502 --- /dev/null +++ b/Task/Use-another-language-to-call-a-function/Lua/use-another-language-to-call-a-function-3.lua @@ -0,0 +1,4 @@ +gcc -std=c2x -Wall -Wextra \ + -I/usr/include/lua5.3 -o query \ + Query.c Query_lua.c \ + -L/usr/lib/x84_64-linux-gnu/ -l lua5.3 diff --git a/Task/User-input-Graphical/FuncSug/user-input-graphical.funcsug b/Task/User-input-Graphical/FuncSug/user-input-graphical.funcsug new file mode 100644 index 0000000000..4b6c13587c --- /dev/null +++ b/Task/User-input-Graphical/FuncSug/user-input-graphical.funcsug @@ -0,0 +1,10 @@ +# input a string +displayNewMessage("Enter a string") +var text := awaitHumanText() + +# input 75000 +displayNewMessage("Enter the number 75000") +var numberInput := displayNewElementIn('', 'body', 'input', true) +while numberInput.value != 75000: + awaitDomeventBeep('change', numberInput) +displayNewMessage("You've entered 75000") diff --git a/Task/User-input-Text/ArkScript/user-input-text.ark b/Task/User-input-Text/ArkScript/user-input-text.ark new file mode 100644 index 0000000000..248c7e0921 --- /dev/null +++ b/Task/User-input-Text/ArkScript/user-input-text.ark @@ -0,0 +1,5 @@ +(let str (input "str> ")) +(let num (toNumber (input "num> "))) + +(if (nil? num) + (print "num is not a valid number")) diff --git a/Task/User-input-Text/Extended-Color-BASIC/user-input-text.basic b/Task/User-input-Text/Extended-Color-BASIC/user-input-text.basic new file mode 100644 index 0000000000..5acaca32f9 --- /dev/null +++ b/Task/User-input-Text/Extended-Color-BASIC/user-input-text.basic @@ -0,0 +1,4 @@ +10 INPUT A$ +20 INPUT B +30 IF B<>75000 THEN 20 +40 PRINT A$, B diff --git a/Task/User-input-Text/Pluto/user-input-text.pluto b/Task/User-input-Text/Pluto/user-input-text.pluto new file mode 100644 index 0000000000..dc9501c569 --- /dev/null +++ b/Task/User-input-Text/Pluto/user-input-text.pluto @@ -0,0 +1,4 @@ +io.write("Enter a number: ") +a = io.read("*l")+0 +io.write("Enter a string: ") +b = io.read("*l") diff --git a/Task/Van-Eck-sequence/Agena/van-eck-sequence.agena b/Task/Van-Eck-sequence/Agena/van-eck-sequence.agena new file mode 100644 index 0000000000..f5e8b8516e --- /dev/null +++ b/Task/Van-Eck-sequence/Agena/van-eck-sequence.agena @@ -0,0 +1,26 @@ +scope # find elements of the Van Eck Sequence - first term is 0, following + # terms are 0 if the previous was the first appearance of the element + # or how far back in the sequence the last element appeared otherwise + + local procedure VanEck( n :: number ) :: sequence # returns the first n elements of the Van Eck sequence + local constant result := seq(); for i to n do result[ i ] := 0 od; + local constant pos := seq(); for i to n + 1 do pos[ i ] := 0 od; + for i from 2 to n do + local constant j := i - 1; + local constant prev := result[ j ] + 1; # prev is indexed from 1, not 0 + if pos[ prev ] <> 0 then + # not a new element + result[ i ] := j - pos[ prev ] + fi; + pos[ prev ] := j + od; + return result + end; + + local constant veSeq := VanEck( 1000 ); # construct the first 1000 terms of the sequence + # show the first and last 10 elements + for i to 10 do printf( " %d", veSeq[ i ] ) od; + printf( "\n" ); + for i from size veSeq - 9 to size veSeq do printf( " %d", veSeq[ i ] ) od; + printf( "\n" ) +end diff --git a/Task/Van-Eck-sequence/Pluto/van-eck-sequence.pluto b/Task/Van-Eck-sequence/Pluto/van-eck-sequence.pluto new file mode 100644 index 0000000000..351a65f1db --- /dev/null +++ b/Task/Van-Eck-sequence/Pluto/van-eck-sequence.pluto @@ -0,0 +1,26 @@ +do --[[ find elements of the Van Eck Sequence - first term is 0, following + terms are 0 if the previous was the first appearance of the element + or how far back in the sequence the last element appeared otherwise + ]] + local fmt = require( "fmt" ) -- RC formatting module + + local function VanEck( n : number ) : table -- returns the first n elements of the Van Eck sequence + local result = {} for i = 1, n do result[ i ] = 0 end + local pos = {} for i = 1, n + 1 do pos[ i ] = 0 end + for i = 2, n do + local j = i - 1 + local prev = result[ j ] + 1; -- prev is indexed from 1, not 0 + if pos[ prev ] != 0 then + -- not a new element + result[ i ] = j - pos[ prev ] + end + pos[ prev ] = j + end + return result + end + + local veSeq = VanEck( 1000 ) -- construct the first 1000 terms of the sequence + -- show the first and last 10 elements + fmt.lprint( veSeq:slice( 1, 10 ) ) + fmt.lprint( veSeq:slice( # veSeq - 9, # veSeq ) ) +end diff --git a/Task/Van-der-Corput-sequence/Agena/van-der-corput-sequence.agena b/Task/Van-der-Corput-sequence/Agena/van-der-corput-sequence.agena new file mode 100644 index 0000000000..31e5e74e2f --- /dev/null +++ b/Task/Van-der-Corput-sequence/Agena/van-der-corput-sequence.agena @@ -0,0 +1,32 @@ +scope /* show members of the van der Corput sequence in various bases + translated from the C sample + */ + + # returns the numerator and denominator of the nth member of the van der Corput sequence + # in the specified base + local procedure vc( nth :: number, base :: number ) + local p, q, n := 0, 1, nth; + + while n <> 0 do + p *:= base + p +:= n mod base + q *:= base + n \:= base + od; + + # return the numerator and denominator reduced by their gcd + local num, denom := p, q; + q := numtheory.gcd( p, q ); + return num \ q, denom \ q + end + + # task + for b from 2 to 5 do + printf( "base %d:", b ); + for i from 0 to 9 do + local n, d := vc( i, b ); + if n <> 0 then printf( " %d/%d", n, d ) else printf( " 0" ) fi; + end + io.write( "\n" ) + od +end diff --git a/Task/Van-der-Corput-sequence/Pluto/van-der-corput-sequence.pluto b/Task/Van-der-Corput-sequence/Pluto/van-der-corput-sequence.pluto new file mode 100644 index 0000000000..07f57fefc6 --- /dev/null +++ b/Task/Van-der-Corput-sequence/Pluto/van-der-corput-sequence.pluto @@ -0,0 +1,35 @@ +do --[[ show members of the van der Corput sequence in various bases + translated from the C sample + ]] + + local int = require( "int" ) -- RC integer module - includes gcd + + -- returns the numerator and denominator of the nth member of the van der Corput sequence + -- in the specified base + local function vc( nth : number, base : number ) + local p, q, n = 0, 1, nth + + while n != 0 do + p *= base + p += n % base + q *= base + n //= base + end + + num, denom = p, q + + -- return the numerator and denominator reduced by their gcd + q = int.gcd( num, denom ) + return num // q, denom // q + end + + -- task + for b = 2, 5 do + io.write( $"base {b}:" ) + for i = 0, 9 do + local n, d = vc( i, b ) + io.write( if n != 0 then $" {n}/{d}" else " 0" end ) + end + io.write( "\n" ) + end +end diff --git a/Task/Van-der-Corput-sequence/YAMLScript/van-der-corput-sequence.ys b/Task/Van-der-Corput-sequence/YAMLScript/van-der-corput-sequence.ys new file mode 100644 index 0000000000..3c710205c1 --- /dev/null +++ b/Task/Van-der-Corput-sequence/YAMLScript/van-der-corput-sequence.ys @@ -0,0 +1,18 @@ +!YS-v0 + +defn main(b): + each n range(10): + say: + format '%.6f': + vdc: n b + +defn vdc(n b): + loop n n, d 1, vdc 0.0: + if n > 0: + then: + d *=: b + r =: n % b + n .=: quot(b) + vdc +=: r / d + recur: n, d, vdc + else: vdc diff --git a/Task/Variable-size-Get/DuckDB/variable-size-get.duckdb b/Task/Variable-size-Get/DuckDB/variable-size-get.duckdb new file mode 100644 index 0000000000..c65f1c2616 --- /dev/null +++ b/Task/Variable-size-Get/DuckDB/variable-size-get.duckdb @@ -0,0 +1,50 @@ +CREATE OR REPLACE FUNCTION parse_int(val) AS ( + regexp_extract('decimal(12,3)', '[0-9]+')::INTEGER +); + +# DECIMAL(p, s): +CREATE OR REPLACE FUNCTION d2w(p) AS ( + if( p <= 4, 16, + if( p <= 9, 32, + if( p <= 18, 64, + 128) )) +); + +CREATE OR REPLACE FUNCTION nominal_size_in_bits(val) AS ( + CASE typeof(val) + WHEN 'TINYINT' THEN 8 + WHEN 'SMALLINT' THEN 16 + WHEN 'INTEGER' THEN 32 + WHEN 'BIGINT' THEN 64 + WHEN 'HUGEINT' THEN 128 + + WHEN 'UTINYINT' THEN 8 + WHEN 'USMALLINT' THEN 16 + WHEN 'UINTEGER' THEN 32 + WHEN 'UBIGINT' THEN 64 + WHEN 'UHUGEINT' THEN 128 + + WHEN 'JSON' THEN 8 * length(val::JSON::VARCHAR) + WHEN 'UUID' THEN 128 + + WHEN 'FLOAT' THEN 32 + WHEN 'DOUBLE' THEN 64 + WHEN 'BOOLEAN' THEN 8 + WHEN 'BIT' THEN (CEIL(LENGTH(val::VARCHAR) / 8.0) * 8)::INTEGER + WHEN 'BLOB' THEN octet_length(val::BLOB) * 8 + ELSE CASE + WHEN typeof(val) LIKE 'DECIMAL%' + THEN d2w( regexp_extract(typeof(val), '[0-9]+')::INTEGER ) + WHEN typeof(val) LIKE 'VARCHAR%' + THEN 8 * octet_length(encode(val::VARCHAR)) + ELSE NULL + END + END +); + +# Example: + +select nominal_size_in_bits('1'::BIT) as "1::BIT", + nominal_size_in_bits(bitstring('1',7)) as "0000001", + nominal_size_in_bits(9.4) as "9.4", + nominal_size_in_bits('👨') as "glyph"; diff --git a/Task/Variable-size-Set/DuckDB/variable-size-set.duckdb b/Task/Variable-size-Set/DuckDB/variable-size-set.duckdb new file mode 100644 index 0000000000..116c73ed70 --- /dev/null +++ b/Task/Variable-size-Set/DuckDB/variable-size-set.duckdb @@ -0,0 +1,34 @@ +# DECIMAL(p, s): +CREATE OR REPLACE FUNCTION d2w(p) AS ( + if( p <= 4, 16, + if( p <= 9, 32, + if( p <= 18, 64, + 128) )) +); + +CREATE OR REPLACE FUNCTION nominal_size_in_bits(val) AS ( + CASE typeof(val) + WHEN 'TINYINT' THEN 8 + WHEN 'SMALLINT' THEN 16 + WHEN 'INTEGER' THEN 32 + WHEN 'BIGINT' THEN 64 + WHEN 'HUGEINT' THEN 128 + + WHEN 'UTINYINT' THEN 8 + WHEN 'USMALLINT' THEN 16 + WHEN 'UINTEGER' THEN 32 + WHEN 'UBIGINT' THEN 64 + WHEN 'UHUGEINT' THEN 128 + + WHEN 'BOOLEAN' THEN 8 + WHEN 'UUID' THEN 128 + + WHEN 'FLOAT' THEN 32 + WHEN 'DOUBLE' THEN 64 + ELSE CASE + WHEN typeof(val) LIKE 'DECIMAL%' + THEN d2w( regexp_extract(typeof(val), '[0-9]+')::INTEGER ) + ELSE NULL + END + END +); diff --git a/Task/Variables/Bc/variables.bc b/Task/Variables/Bc/variables.bc new file mode 100644 index 0000000000..b5d37ccefc --- /dev/null +++ b/Task/Variables/Bc/variables.bc @@ -0,0 +1,15 @@ +a = 1 /* global variables */ + +define add(a,b) { /* function parameters */ + return a+b +} + +define test(c) { /* local variables ('auto') */ + auto a + a = 2 + return c / a +} + +{ print a,"\n" +print add(1,2),"\n" +print test(120),"\n" } diff --git a/Task/Variadic-function/Pluto/variadic-function.pluto b/Task/Variadic-function/Pluto/variadic-function.pluto new file mode 100644 index 0000000000..ac5ddffda8 --- /dev/null +++ b/Task/Variadic-function/Pluto/variadic-function.pluto @@ -0,0 +1,10 @@ +local function variadic(...args) + for args as arg do print(arg) end +end + +variadic("Pip", "Squeak", "Wilfred") +local a = {} +a:insert("Faith") +a:insert("Hope") +a:insert("Charity") +variadic(a:unpack()) diff --git a/Task/Vector-products/DuckDB/vector-products.duckdb b/Task/Vector-products/DuckDB/vector-products.duckdb new file mode 100644 index 0000000000..5695b0d31c --- /dev/null +++ b/Task/Vector-products/DuckDB/vector-products.duckdb @@ -0,0 +1,17 @@ +create or replace function cross_product(a,b) as table ( + select [ a[2]*b[3] - a[3]*b[2], a[3]*b[1] - a[1]*b[3], a[1]*b[2]-a[2]*b[1] ]); + +create or replace function scalar_triple_product(a,b,c) as table ( + select list_dot_product(a, (from cross_product(b, c))) ); + +create or replace function vector_triple_product(a,b,c) as table ( + from cross_product(a, (from cross_product(b, c))) ); + +# Examples +select [3, 4, 5] as a, + [4, 3, 5] as b, + [-5, -12, -13] as c, + list_dot_product(a, b) as 'a . b', + ((from cross_product(a, b) )) as 'a x b', + ((from scalar_triple_product(a, b, c))) as 'a . (b x c)', + ((from vector_triple_product(a, b, c))) as 'a x (b x c)' ; diff --git a/Task/Vector-products/Pluto/vector-products.pluto b/Task/Vector-products/Pluto/vector-products.pluto new file mode 100644 index 0000000000..130486ab8f --- /dev/null +++ b/Task/Vector-products/Pluto/vector-products.pluto @@ -0,0 +1,19 @@ +local vector3 = require "vector3" +local fmt = require "fmt" + +local function scalar_tripleproduct(a, b, c) return a:dot(b:crossproduct(c)) end + +local function vector_tripleproduct(a, b, c) return a:crossproduct(b:crossproduct(c)) end + +local a = vector3( 3, 4, 5) +local b = vector3( 4, 3, 5) +local c = vector3(-5, -12, -13) + +fmt.print("a = %s", a) +fmt.print("b = %s", b) +fmt.print("c = %s", c) +print() +fmt.print("a . b = %s", a:dot(b)) +fmt.print("a x b = %s", a:crossproduct(b)) +fmt.print("a . b x c = %s", scalar_tripleproduct(a, b, c)) +fmt.print("a x b x c = %s", vector_tripleproduct(a, b, c)) diff --git a/Task/Vector-products/REXX/vector-products.rexx b/Task/Vector-products/REXX/vector-products.rexx index d2687f7539..eb314fe6b1 100644 --- a/Task/Vector-products/REXX/vector-products.rexx +++ b/Task/Vector-products/REXX/vector-products.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings say 'VECTOR PRODUCTS' @@ -6,23 +6,20 @@ say version say a = '3 4 5'; b = '4 3 5'; c = '-5 -12 -13'; d = '1 2 3' say 'VALUES' -say 'A =' Vlst2Form(a) -say 'B =' Vlst2Form(b) -say 'C =' Vlst2Form(c) -say 'D =' Vlst2Form(d) +say 'A =' Lst2FormV(a) +say 'B =' Lst2FormV(b) +say 'C =' Lst2FormV(c) +say 'D =' Lst2FormV(d) say say 'BASICS' -say 'A . B =' Vdot(a,b)/1 -say 'A x B =' Vlst2Form(Vcross(a,b)) +say 'A . B =' DotV(a,b)/1 '= dot product' +say 'A x B =' Lst2FormV(CrossV(a,b)) '= cross product' say say 'BONUS' -say 'A . (BxC) =' VscalTrip(a,b,c)/1 -say 'A x (BxC) =' Vlst2Form(VvectTrip(a,b,c)) -say '(AxB) . (CxD) =' VscalQuad(a,b,c,d)/1 -say '(AxB) x (CxD) =' Vlst2Form(VvectQuad(a,b,c,d)) +say 'A . (BxC) =' ScalTripV(a,b,c)/1 '= scalar triple product' +say 'A x (BxC) =' Lst2FormV(VectTripV(a,b,c)) '= vector triple product' +say '(AxB) . (CxD) =' ScalQuadV(a,b,c,d)/1 '= scalar quadruple product' +say '(AxB) x (CxD) =' Lst2FormV(VectQuadV(a,b,c,d)) '= vector quadruple product' exit -include Vector -include Functions -include Constants -include Abend +include Math diff --git a/Task/Vector/Ada/vector.ada b/Task/Vector/Ada/vector.ada new file mode 100644 index 0000000000..688292cc03 --- /dev/null +++ b/Task/Vector/Ada/vector.ada @@ -0,0 +1,31 @@ +with Ada.Text_IO; + +procedure Vector_Demo is + type Vector is record + X, Y : Float; + end record; + + function "+" (A, B : Vector) return Vector is + (A.X + B.X, A.Y + B.Y); + + function "-" (A, B : Vector) return Vector is + (A.X - B.X, A.Y - B.Y); + + function "*" (S : Float; A : Vector) return Vector is + (S * A.X, S * A.Y); + + function "/" (A : Vector; S : Float) return Vector is + (A.X / S, A.Y / S); + + procedure Print (A : Vector) is + begin + Ada.Text_IO.Put_Line ("(" & A.X'Image & "," & A.Y'Image & ")"); + end Print; + + Example : Vector := (1.0, 1.0); +begin + Print (Example + Example); + Print (Example - Example); + Print (2.0 * Example); + Print (Example / 2.0); +end Vector_Demo; diff --git a/Task/Vector/Pluto/vector.pluto b/Task/Vector/Pluto/vector.pluto new file mode 100644 index 0000000000..774d4dcce5 --- /dev/null +++ b/Task/Vector/Pluto/vector.pluto @@ -0,0 +1,31 @@ +local fmt = require "fmt" + +class vector2 + static function polar(r, theta) + return new vector2(r * math.cos(theta), r * math.sin(theta)) + end + + static function scale(s, v) return v * s end + + function __construct(public x, public y) end + + function __add(v) return new vector2(self.x + v.x, self.y + v.y) end + function __sub(v) return new vector2(self.x - v.x, self.y - v.y) end + function __mul(s) return new vector2(self.x * s, self.y * s) end + function __div(s) return new vector2(self.x / s, self.y / s) end + + function __tostring() return $"({self.x}, {self.y})" end +end + +local v1 = new vector2(5, 7) +local v2 = new vector2(2, 3) +local v3 = vector2.polar(math.sqrt(2.0), math.pi / 4) +fmt.print("v1 = %s", v1) +fmt.print("v2 = %s", v2) +fmt.print("v3 = %s", v3) +print() +fmt.print("v1 + v2 = %s", v1 + v2) +fmt.print("v1 - v2 = %s", v1 - v2) +fmt.print("v1 * 11 = %s", v1 * 11) +fmt.print("11 * v2 = %s", vector2.scale(11, v2)) +fmt.print("v1 / 2 = %s", v1 / 2) diff --git a/Task/Vector/REXX/vector.rexx b/Task/Vector/REXX/vector.rexx index 2a7854d747..3ad112f709 100644 --- a/Task/Vector/REXX/vector.rexx +++ b/Task/Vector/REXX/vector.rexx @@ -1,4 +1,4 @@ --- 19 May 2025 +-- 28 Jul 2025 include Settings say 'VECTOR' @@ -6,26 +6,23 @@ say version say a = '1 2 3'; b = '3 2 1'; c = 3; d = '4 5'; e = '2 1' say 'VALUES' -say 'A =' Vlst2Form(a) -say 'B =' Vlst2Form(b) +say 'A =' Lst2FormV(a) +say 'B =' Lst2FormV(b) say 'C =' c -say 'D =' Vlst2Form(d) -say 'E =' Vlst2Form(e) +say 'D =' Lst2FormV(d) +say 'E =' Lst2FormV(e) say say 'BASICS' -say 'A+B =' Vlst2Form(Vadd(a,b)) -say 'A-B =' Vlst2Form(Vsub(a,b)) -say 'A*C =' Vlst2Form(Vmul(a,c)) -say 'A/C =' Vlst2Form(Vdiv(a,c)) +say 'A+B =' Lst2FormV(AddV(a,b)) +say 'A-B =' Lst2FormV(SubV(a,b)) +say 'A*C =' Lst2FormV(ScaleV(a,c)) +say 'A/C =' Lst2FormV(ScaleV(a,1/c)) say say 'BONUS' -say 'Length(D) =' Vlen(d)+0 -say 'Angle(D) =' Vang(d)+0 -say 'Polar(D) =' Vlst2Form(Vrec2Pol(d)) -say 'Rect(E) =' Vlst2Form(Vpol2Rec(e)) +say 'Length(D) =' LenV(d)+0 +say 'Angle(D) =' AngV(d)+0 +say 'Polar(D) =' Lst2FormV(Rec2PolV(d)) +say 'Rect(E) =' Lst2FormV(Pol2RecV(e)) exit -include Vector -include Functions -include Constants -include Abend +include Math diff --git a/Task/Verhoeff-algorithm/Zig/verhoeff-algorithm.zig b/Task/Verhoeff-algorithm/Zig/verhoeff-algorithm.zig new file mode 100644 index 0000000000..54a2560abf --- /dev/null +++ b/Task/Verhoeff-algorithm/Zig/verhoeff-algorithm.zig @@ -0,0 +1,112 @@ +const std = @import("std"); +const print = std.debug.print; + +const MULTIPLICATION_TABLE: [10][10]i32 = [_][10]i32{ + [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + [_]i32{ 1, 2, 3, 4, 0, 6, 7, 8, 9, 5 }, + [_]i32{ 2, 3, 4, 0, 1, 7, 8, 9, 5, 6 }, + [_]i32{ 3, 4, 0, 1, 2, 8, 9, 5, 6, 7 }, + [_]i32{ 4, 0, 1, 2, 3, 9, 5, 6, 7, 8 }, + [_]i32{ 5, 9, 8, 7, 6, 0, 4, 3, 2, 1 }, + [_]i32{ 6, 5, 9, 8, 7, 1, 0, 4, 3, 2 }, + [_]i32{ 7, 6, 5, 9, 8, 2, 1, 0, 4, 3 }, + [_]i32{ 8, 7, 6, 5, 9, 3, 2, 1, 0, 4 }, + [_]i32{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, +}; + +const INVERSE: [10]i32 = [_]i32{ 0, 4, 3, 2, 1, 5, 6, 7, 8, 9 }; + +const PERMUTATION_TABLE: [8][10]i32 = [_][10]i32{ + [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + [_]i32{ 1, 5, 7, 6, 2, 8, 3, 0, 9, 4 }, + [_]i32{ 5, 8, 0, 3, 7, 9, 6, 1, 4, 2 }, + [_]i32{ 8, 9, 1, 6, 0, 4, 3, 5, 2, 7 }, + [_]i32{ 9, 4, 5, 3, 1, 2, 6, 8, 7, 0 }, + [_]i32{ 4, 2, 8, 6, 5, 7, 3, 9, 0, 1 }, + [_]i32{ 2, 7, 9, 3, 8, 0, 6, 4, 1, 5 }, + [_]i32{ 7, 0, 4, 6, 9, 1, 3, 2, 5, 8 }, +}; + +fn verhoeffChecksum(allocator: std.mem.Allocator, number: []const u8, do_validation: bool, do_display: bool) !i32 { + if (do_display) { + const calculation_type = if (do_validation) "Validation" else "Check digit"; + print("{s} calculations for {s}\n\n", .{ calculation_type, number }); + print(" i ni p[i, ni] c\n", .{}); + print("-------------------\n", .{}); + } + + var working_number = std.ArrayList(u8).init(allocator); + defer working_number.deinit(); + + try working_number.appendSlice(number); + if (!do_validation) { + try working_number.append('0'); + } + + var c: i32 = 0; + const le = working_number.items.len - 1; + + var i: usize = le + 1; + while (i > 0) { + i -= 1; + const ni = working_number.items[i] - '0'; + const pos = (le - i) % 8; + const pi = PERMUTATION_TABLE[pos][ni]; + c = MULTIPLICATION_TABLE[@intCast(c)][@as(usize, @intCast(pi))]; + + if (do_display) { + print("{:2} {:2} {:2} {:2}\n\n", .{ le - i, ni, pi, c }); + } + } + + if (do_display and !do_validation) { + print("inverse[{}] = {}\n\n", .{ c, INVERSE[@intCast(c)] }); + } + + if (do_validation) { + return if (c == 0) 1 else 0; + } else { + return INVERSE[@intCast(c)]; + } +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const Test = struct { + test_num: []const u8, + display: bool, + }; + + const tests = [_]Test{ + .{ .test_num = "123", .display = true }, + .{ .test_num = "12345", .display = true }, + .{ .test_num = "123456789012", .display = false }, + }; + + for (tests) |my_test| { + const digit = try verhoeffChecksum(allocator, my_test.test_num, false, my_test.display); + print("The check digit for {s} is {}\n\n", .{ my_test.test_num, digit }); + + // Create test numbers with check digit and with '9' + var correct_number = std.ArrayList(u8).init(allocator); + defer correct_number.deinit(); + try correct_number.appendSlice(my_test.test_num); + try correct_number.append('0' + @as(u8, @intCast(digit))); + + var incorrect_number = std.ArrayList(u8).init(allocator); + defer incorrect_number.deinit(); + try incorrect_number.appendSlice(my_test.test_num); + try incorrect_number.append('9'); + + const numbers = [_][]const u8{ correct_number.items, incorrect_number.items }; + + for (numbers) |number| { + const validation_result = try verhoeffChecksum(allocator, number, true, my_test.display); + const result = if (validation_result == 1) "correct" else "incorrect"; + print("The validation for \"{s}\" is \"{s}\". \n", .{ number, result }); + } + } +} diff --git a/Task/Verify-distribution-uniformity-Chi-squared-test/REXX/verify-distribution-uniformity-chi-squared-test.rexx b/Task/Verify-distribution-uniformity-Chi-squared-test/REXX/verify-distribution-uniformity-chi-squared-test.rexx index 5b7e3fbb9d..cb84428fc4 100644 --- a/Task/Verify-distribution-uniformity-Chi-squared-test/REXX/verify-distribution-uniformity-chi-squared-test.rexx +++ b/Task/Verify-distribution-uniformity-Chi-squared-test/REXX/verify-distribution-uniformity-chi-squared-test.rexx @@ -1,4 +1,4 @@ --- 8 May 2025 +-- 28 Jul 2025 include Settings say 'VERIFY DISTRIBUTION UNIFORMITY / CHI-SQUARED TEST' @@ -12,7 +12,7 @@ call Timer exit Check: -procedure expose stat. glob. +procedure expose stat. Memo. arg xx -- Dataset stat. = 0 @@ -60,8 +60,4 @@ say 'Is dataset uniform?' Word('Yes No',(Abs(pv)= 'A' and c <= 'Z') { + const key_char = key[key_index % key.len]; + // Fix the integer overflow by using a safer formula + const shift = @as(i32, c) - @as(i32, key_char); + const adjusted_shift = @mod(shift + 26, 26); + const decrypted = @as(u8, @intCast(adjusted_shift)) + 'A'; + try result.append(decrypted); + key_index += 1; + } + } + + return result.toOwnedSlice(); +} + +pub fn main() !void { + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena.deinit(); + const allocator = arena.allocator(); + + // Parse cryptogram - remove spaces + var enc = std.ArrayList(u8).init(allocator); + defer enc.deinit(); + + for (CRYPTOGRAM) |c| { + if (c >= 'A' and c <= 'Z') { + try enc.append(c); + } + } + + // Convert to indices + var cryptogram = std.ArrayList(u8).init(allocator); + defer cryptogram.deinit(); + + for (enc.items) |c| { + try cryptogram.append(c - 'A'); + } + + var best_fit: f32 = std.math.floatMax(f32); + var best_key = std.ArrayList(u8).init(allocator); + defer best_key.deinit(); + + var j: usize = 1; + while (j <= 26) : (j += 1) { + const key = try allocator.alloc(u8, j); + const fit = freqEveryNth(cryptogram.items, key); + + if (fit < best_fit) { + best_fit = fit; + best_key.clearAndFree(); + try best_key.appendSlice(key); + } + allocator.free(key); + } + + // Print results + const stdout = std.io.getStdOut().writer(); + try stdout.print("best key: ", .{}); + for (best_key.items) |c| { + try stdout.writeByte(c); + } + try stdout.writeByte('\n'); + + const decrypted = try decrypt(allocator, enc.items, best_key.items); + defer allocator.free(decrypted); + + try stdout.print("\nDecrypted text:\n{s}\n", .{decrypted}); +} diff --git a/Task/Vogels-approximation-method/C-sharp/vogels-approximation-method.cs b/Task/Vogels-approximation-method/C-sharp/vogels-approximation-method.cs new file mode 100644 index 0000000000..fb65be9685 --- /dev/null +++ b/Task/Vogels-approximation-method/C-sharp/vogels-approximation-method.cs @@ -0,0 +1,117 @@ +using System; +using System.Linq; +using System.Threading.Tasks; + +public class VogelsApproximationMethod +{ + private static readonly int[] demand = {30, 20, 70, 30, 60}; + private static readonly int[] supply = {50, 60, 50, 50}; + private static readonly int[,] costs = {{16, 16, 13, 22, 17}, {14, 14, 13, 19, 15}, + {19, 19, 20, 23, 50}, {50, 12, 50, 15, 11}}; + + private static readonly int nRows = supply.Length; + private static readonly int nCols = demand.Length; + + private static bool[] rowDone = new bool[nRows]; + private static bool[] colDone = new bool[nCols]; + private static int[,] result = new int[nRows, nCols]; + + public static async Task Main(string[] args) + { + int supplyLeft = supply.Sum(); + int totalCost = 0; + + while (supplyLeft > 0) + { + int[] cell = await NextCell(); + int r = cell[0]; + int c = cell[1]; + + int quantity = Math.Min(demand[c], supply[r]); + demand[c] -= quantity; + if (demand[c] == 0) + colDone[c] = true; + + supply[r] -= quantity; + if (supply[r] == 0) + rowDone[r] = true; + + result[r, c] = quantity; + supplyLeft -= quantity; + + totalCost += quantity * costs[r, c]; + } + + // Print results + for (int i = 0; i < nRows; i++) + { + Console.Write("["); + for (int j = 0; j < nCols; j++) + { + Console.Write(result[i, j]); + if (j < nCols - 1) Console.Write(", "); + } + Console.WriteLine("]"); + } + Console.WriteLine($"Total cost: {totalCost}"); + } + + private static async Task NextCell() + { + Task task1 = Task.Run(() => MaxPenalty(nRows, nCols, true)); + Task task2 = Task.Run(() => MaxPenalty(nCols, nRows, false)); + + int[] res1 = await task1; + int[] res2 = await task2; + + if (res1[3] == res2[3]) + return res1[2] < res2[2] ? res1 : res2; + + return (res1[3] > res2[3]) ? res2 : res1; + } + + private static int[] Diff(int j, int len, bool isRow) + { + int min1 = int.MaxValue, min2 = int.MaxValue; + int minP = -1; + + for (int i = 0; i < len; i++) + { + if (isRow ? colDone[i] : rowDone[i]) + continue; + + int c = isRow ? costs[j, i] : costs[i, j]; + if (c < min1) + { + min2 = min1; + min1 = c; + minP = i; + } + else if (c < min2) + min2 = c; + } + return new int[] {min2 - min1, min1, minP}; + } + + private static int[] MaxPenalty(int len1, int len2, bool isRow) + { + int md = int.MinValue; + int pc = -1, pm = -1, mc = -1; + + for (int i = 0; i < len1; i++) + { + if (isRow ? rowDone[i] : colDone[i]) + continue; + + int[] res = Diff(i, len2, isRow); + if (res[0] > md) + { + md = res[0]; // max diff + pm = i; // pos of max diff + mc = res[1]; // min cost + pc = res[2]; // pos of min cost + } + } + return isRow ? new int[] {pm, pc, mc, md} : new int[] {pc, pm, mc, md}; + } +} diff --git a/Task/Vogels-approximation-method/Mathematica/vogels-approximation-method.math b/Task/Vogels-approximation-method/Mathematica/vogels-approximation-method.math new file mode 100644 index 0000000000..56a1d5cf1e --- /dev/null +++ b/Task/Vogels-approximation-method/Mathematica/vogels-approximation-method.math @@ -0,0 +1,123 @@ +(* Transportation Problem Solver using Vogel's Approximation Method *) + +costs = <| + "W" -> <|"A" -> 16, "B" -> 16, "C" -> 13, "D" -> 22, "E" -> 17|>, + "X" -> <|"A" -> 14, "B" -> 14, "C" -> 13, "D" -> 19, "E" -> 15|>, + "Y" -> <|"A" -> 19, "B" -> 19, "C" -> 20, "D" -> 23, "E" -> 50|>, + "Z" -> <|"A" -> 50, "B" -> 12, "C" -> 50, "D" -> 15, "E" -> 11|> +|>; + +demand = <|"A" -> 30, "B" -> 20, "C" -> 70, "D" -> 30, "E" -> 60|>; +cols = Sort[Keys[demand]]; +supply = <|"W" -> 50, "X" -> 60, "Y" -> 50, "Z" -> 50|>; + +(* Initialize result matrix *) +res = AssociationMap[ + Function[k, AssociationMap[0 &, Keys[demand]]], + Keys[costs] +]; + +(* Initialize g dictionary for sorting *) +g = <||>; + +(* Sort destinations by cost for each supplier *) +Do[ + g[x] = SortBy[Keys[costs[x]], costs[x][#] &]; + , {x, Keys[supply]} +]; + +(* Sort suppliers by cost for each destination *) +Do[ + g[x] = SortBy[Keys[costs], costs[#][x] &]; + , {x, Keys[demand]} +]; + +(* Main algorithm loop *) +While[Length[g] > 0, + (* Calculate penalties for demand nodes *) + d = <||>; + Do[ + If[KeyExistsQ[demand, x] && Length[g[x]] > 0, + d[x] = If[Length[g[x]] > 1, + costs[g[x][[2]]][x] - costs[g[x][[1]]][x], + costs[g[x][[1]]][x] + ]; + ]; + , {x, Keys[demand]} + ]; + + (* Calculate penalties for supply nodes *) + s = <||>; + Do[ + If[KeyExistsQ[supply, x] && Length[g[x]] > 0, + s[x] = If[Length[g[x]] > 1, + costs[x][g[x][[2]]] - costs[x][g[x][[1]]], + costs[x][g[x][[1]]] + ]; + ]; + , {x, Keys[supply]} + ]; + + (* Find keys with maximum penalties *) + fKey = If[Length[d] > 0, + First[Keys[d] // SortBy[d[#] &] // Reverse], + "" + ]; + tKey = If[Length[s] > 0, + First[Keys[s] // SortBy[s[#] &] // Reverse], + "" + ]; + + (* Get the actual maximum values *) + maxD = If[Length[d] > 0, d[fKey], 0]; + maxS = If[Length[s] > 0, s[tKey], 0]; + + (* Choose the allocation with higher penalty *) + {t, f} = If[maxD > maxS, + {fKey, g[fKey][[1]]}, + {g[tKey][[1]], tKey} + ]; + + (* Allocate minimum of supply and demand *) + v = Min[supply[f], demand[t]]; + res[f][t] += v; + demand[t] -= v; + + (* Update demand and remove if satisfied *) + If[demand[t] == 0, + Do[ + If[KeyExistsQ[supply, k] && supply[k] != 0, + g[k] = DeleteCases[g[k], t] + ]; + , {k, Keys[supply]} + ]; + g = KeyDrop[g, t]; + demand = KeyDrop[demand, t]; + ]; + + (* Update supply and remove if exhausted *) + supply[f] -= v; + If[supply[f] == 0, + Do[ + If[KeyExistsQ[demand, k] && demand[k] != 0, + g[k] = DeleteCases[g[k], f] + ]; + , {k, Keys[demand]} + ]; + g = KeyDrop[g, f]; + supply = KeyDrop[supply, f]; + ]; +]; + +(*Display results*) +Print["Transportation Solution:"]; + +Dataset[res] + +totalCost = 0; +Do[rowData = Table[ + totalCost += res[supplier][dest]*costs[supplier][dest]; + , {dest, cols}]; + , {supplier, Sort[Keys[costs]]}]; + +Print["Total Cost = ", totalCost]; diff --git a/Task/Vogels-approximation-method/Zig/vogels-approximation-method.zig b/Task/Vogels-approximation-method/Zig/vogels-approximation-method.zig new file mode 100644 index 0000000000..872d05373b --- /dev/null +++ b/Task/Vogels-approximation-method/Zig/vogels-approximation-method.zig @@ -0,0 +1,212 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; + +const Vogel = struct { + supply: ArrayList(i32), + demand: ArrayList(i32), + costs: ArrayList(ArrayList(i32)), + n_rows: i32, + n_cols: i32, + row_done: ArrayList(bool), + col_done: ArrayList(bool), + allocator: std.mem.Allocator, + + const Self = @This(); + + pub fn init(allocator: std.mem.Allocator) Self { + return Self{ + .supply = ArrayList(i32).init(allocator), + .demand = ArrayList(i32).init(allocator), + .costs = ArrayList(ArrayList(i32)).init(allocator), + .n_rows = 0, + .n_cols = 0, + .row_done = ArrayList(bool).init(allocator), + .col_done = ArrayList(bool).init(allocator), + .allocator = allocator, + }; + } + + pub fn deinit(self: *Self) void { + self.supply.deinit(); + self.demand.deinit(); + for (self.costs.items) |*row| { + row.deinit(); + } + self.costs.deinit(); + self.row_done.deinit(); + self.col_done.deinit(); + } + + pub fn approximate(self: *Self) !void { + var results = ArrayList(ArrayList(i32)).init(self.allocator); + defer { + for (results.items) |*row| { + row.deinit(); + } + results.deinit(); + } + + // Initialize results matrix + for (0..@intCast(self.n_rows)) |_| { + var row = ArrayList(i32).init(self.allocator); + for (0..@intCast(self.n_cols)) |_| { + try row.append(0); + } + try results.append(row); + } + + var supply_remaining: i32 = 0; + for (self.supply.items) |s| { + supply_remaining += s; + } + + var total_cost: i32 = 0; + + while (supply_remaining > 0) { + const cell = try self.next_cell(); + const r = cell[0]; + const c = cell[1]; + const q = if (self.demand.items[c] < self.supply.items[r]) + self.demand.items[c] + else + self.supply.items[r]; + + self.demand.items[c] -= q; + if (self.demand.items[c] == 0) { + self.col_done.items[c] = true; + } + + self.supply.items[r] -= q; + if (self.supply.items[r] == 0) { + self.row_done.items[r] = true; + } + + results.items[r].items[c] = q; + supply_remaining -= q; + total_cost += q * self.costs.items[r].items[c]; + } + + print(" A B C D E\n", .{}); + for (results.items, 0..) |result, i| { + print("{c}", .{@as(u8, @intCast('W' + i))}); + for (result.items) |item| { + print(" {:>2}", .{item}); + } + print("\n", .{}); + } + print("\nTotal Cost = {}\n", .{total_cost}); + } + + fn next_cell(self: *Self) ![]usize { + const res1 = try self.max_penalty(self.n_rows, self.n_cols, true); + const res2 = try self.max_penalty(self.n_cols, self.n_rows, false); + + if (res1[3] == res2[3]) { + return if (res1[2] < res2[2]) res1 else res2; + } + return if (res1[3] > res2[3]) res2 else res1; + } + + fn max_penalty(self: *Self, len1: i32, len2: i32, is_row: bool) ![]usize { + var md: i32 = std.math.minInt(i32); + var pc: i32 = -1; + var pm: i32 = -1; + var mc: i32 = -1; + + for (0..@intCast(len1)) |i| { + const should_process = if (is_row) + !self.row_done.items[i] + else + !self.col_done.items[i]; + + if (should_process) { + var min1: i32 = std.math.maxInt(i32); + var min2: i32 = min1; + var min_p: i32 = -1; + + for (0..@intCast(len2)) |j| { + const should_process_inner = if (is_row) + !self.col_done.items[j] + else + !self.row_done.items[j]; + + if (should_process_inner) { + const c = if (is_row) + self.costs.items[i].items[j] + else + self.costs.items[j].items[i]; + + if (c < min1) { + min2 = min1; + min1 = c; + min_p = @intCast(j); + } else if (c < min2) { + min2 = c; + } + } + } + + const diff = min2 - min1; + if (diff > md) { + md = diff; + pm = @intCast(i); + mc = min1; + pc = min_p; + } + } + } + + var result = try self.allocator.alloc(usize, 4); + if (is_row) { + result[0] = @intCast(pm); + result[1] = @intCast(pc); + result[2] = @intCast(mc); + result[3] = @intCast(md); + } else { + result[0] = @intCast(pc); + result[1] = @intCast(pm); + result[2] = @intCast(mc); + result[3] = @intCast(md); + } + return result; + } +}; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + var my_test = Vogel.init(allocator); + defer my_test.deinit(); + + // Initialize supply + try my_test.supply.appendSlice(&[_]i32{ 50, 60, 50, 50 }); + + // Initialize demand + try my_test.demand.appendSlice(&[_]i32{ 30, 20, 70, 30, 60 }); + + // Initialize costs matrix + const cost_data = [_][]const i32{ + &[_]i32{ 16, 16, 13, 22, 17 }, + &[_]i32{ 14, 14, 13, 19, 15 }, + &[_]i32{ 19, 19, 20, 23, 50 }, + &[_]i32{ 50, 12, 50, 15, 11 }, + }; + + for (cost_data) |row_data| { + var row = ArrayList(i32).init(allocator); + try row.appendSlice(row_data); + try my_test.costs.append(row); + } + + my_test.n_rows = 4; + my_test.n_cols = 5; + + // Initialize row_done and col_done + try my_test.row_done.appendNTimes(false, 4); + try my_test.col_done.appendNTimes(false, 5); + + try my_test.approximate(); +} diff --git a/Task/Wagstaff-primes/Agena/wagstaff-primes.agena b/Task/Wagstaff-primes/Agena/wagstaff-primes.agena new file mode 100644 index 0000000000..b92fb35357 --- /dev/null +++ b/Task/Wagstaff-primes/Agena/wagstaff-primes.agena @@ -0,0 +1,36 @@ +scope # find some Wagstaff primes: primes of the form ( 2^p + 1 ) / 3 + # where p is an odd prime + local constant maxWagstaff := 10; # number of Wagstaff primes to find + local constant sieveSize := 200; # hopefully, enough primes... + create register primes( sieveSize ); # "vector" to be sieved + scope # sieve the primes up to sieveMax + primes[ 1 ] := false; + for sPos from 2 to sieveSize do primes[ sPos ] := true od; + for sPos from 2 to entier( sqrt( sieveSize ) ) do + if primes[ sPos ] then + for p from sPos * sPos to sieveSize by sPos do + primes[ p ] := false + od + fi + od + end; + scope # attempt to find the Wagstaff primes + local powerOf2 := 2; # 2^1 + local wCount := 0; # number of Wagstaff primes found so far + for p from 3 by 2 while wCount < maxWagstaff do + powerOf2 *:= 4; + if primes[ p ] then + local w, isPrime := ( powerOf2 + 1 ) \ 3, true; + # check w is prime - trial division + for n from 3 by 2 while n * n <= w and isPrime do + isPrime := w mod n <> 0; + od; + if isPrime then # have another Wagstaff prime + wCount +:= 1; + # have to use %f to print w as it could be > 2^32 + printf( "%2d: %4d: %16.0f\n", wCount, p, w ) + fi + fi + od + end +end diff --git a/Task/Wagstaff-primes/Lua/wagstaff-primes.lua b/Task/Wagstaff-primes/Lua/wagstaff-primes.lua new file mode 100644 index 0000000000..cd4b7c668f --- /dev/null +++ b/Task/Wagstaff-primes/Lua/wagstaff-primes.lua @@ -0,0 +1,38 @@ +do -- find some Wagstaff primes primes of the form ( 2^p + 1 ) / 3 + -- where p is an odd prime + + local maxWagstaff = 10 -- number of Wagstaff primes to find + local sieveSize = 200 -- hopefully, enough primes... + local primes = {} + do -- sieve the primes up to sieveMax + primes[ 1 ] = false + for sPos = 2, sieveSize do primes[ sPos ] = true end + for sPos = 2, math.floor( math.sqrt( sieveSize ) ) do + if primes[ sPos ] then + for p = sPos * sPos, sieveSize, sPos do + primes[ p ] = false + end + end + end + end + do -- attempt to find the Wagstaff primes + local powerOf2 = 2 -- 2^1 + local wCount = 0 -- number of Wagstaff primes found so far + for p = 3, sieveSize, 2 do + if wCount >= maxWagstaff then break end + powerOf2 = powerOf2 * 4 + if primes[ p ] then + local w, isPrime = ( powerOf2 + 1 ) // 3, true + -- check w is prime - trial division + for n = 3, w, 2 do + if n * n > w or not isPrime then break end + isPrime = w % n ~= 0 + end + if isPrime then -- have another Wagstaff prime + wCount = wCount + 1 + io.write( string.format( "%2d %4d: %16d\n", wCount, p, w ) ) + end + end + end + end +end diff --git a/Task/Wagstaff-primes/Pluto/wagstaff-primes.pluto b/Task/Wagstaff-primes/Pluto/wagstaff-primes.pluto new file mode 100644 index 0000000000..df8b96236d --- /dev/null +++ b/Task/Wagstaff-primes/Pluto/wagstaff-primes.pluto @@ -0,0 +1,40 @@ +do -- find some Wagstaff primes primes of the form ( 2^p + 1 ) / 3 + -- where p is an odd prime + + local fmt = require( "fmt" ) -- RC formatting library + + local maxWagstaff = 10 -- number of Wagstaff primes to find + local sieveSize = 200 -- hopefully, enough primes... + local primes = {} + do -- sieve the primes up to sieveMax + primes[ 1 ] = false + for sPos = 2, sieveSize do primes[ sPos ] = true end + for sPos = 2, math.floor( math.sqrt( sieveSize ) ) do + if primes[ sPos ] then + for p = sPos * sPos, sieveSize, sPos do + primes[ p ] = false + end + end + end + end + do -- attempt to find the Wagstaff primes + local powerOf2 = 2 -- 2^1 + local wCount = 0 -- number of Wagstaff primes found so far + for p = 3, sieveSize, 2 do + if wCount >= maxWagstaff then break end + powerOf2 *= 4 + if primes[ p ] then + local w, isPrime = ( powerOf2 + 1 ) // 3, true + -- check w is prime - trial division + for n = 3, w, 2 do + if n * n > w or not isPrime then break end + isPrime = w % n != 0 + end + if isPrime then -- have another Wagstaff prime + ++ wCount + fmt.write( "%2d %4d: %16d\n", wCount, p, w ) + end + end + end + end +end diff --git a/Task/Wagstaff-primes/Ring/wagstaff-primes.ring b/Task/Wagstaff-primes/Ring/wagstaff-primes.ring new file mode 100644 index 0000000000..d80dc80eb3 --- /dev/null +++ b/Task/Wagstaff-primes/Ring/wagstaff-primes.ring @@ -0,0 +1,12 @@ +load "stdlib.ring" + +flag = 0 +p = 3 +while flag < 10 + m=(pow(2,p)+1)/3 + if isPrime(m) and isPrime(p) and p%2=1 + see "p = " + p +", " + "m = " + m + nl + flag++ + ok + p = p + 2 +end diff --git a/Task/War-card-game/Rust/war-card-game.rs b/Task/War-card-game/Rust/war-card-game.rs new file mode 100644 index 0000000000..a128b9e6a1 --- /dev/null +++ b/Task/War-card-game/Rust/war-card-game.rs @@ -0,0 +1,110 @@ +use rand::seq::SliceRandom; +use rand::thread_rng; + +const SUITS: [&str; 4] = ["♣", "♦", "♥", "♠"]; +const FACES: [&str; 13] = ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]; + +struct Card { + display: String, + rank: usize, +} + +impl Card { + fn new(index: usize) -> Self { + let face = FACES[index % 13]; + let suit = SUITS[index / 13]; + Card { + display: format!("{}{}", face, suit), + rank: index % 13, + } + } +} + +fn war() { + // Create and shuffle deck + let mut deck: Vec = (0..52).collect(); + deck.shuffle(&mut thread_rng()); + + // Deal cards to players (reversing order to match Go implementation) + let mut hand1: Vec = Vec::with_capacity(52); + let mut hand2: Vec = Vec::with_capacity(52); + + for i in 0..26 { + hand1.push(deck[2 * i]); + hand2.push(deck[2 * i + 1]); + } + hand1.reverse(); + hand2.reverse(); + + // Create cards lookup + let cards: Vec = (0..52).map(Card::new).collect(); + + while !hand1.is_empty() && !hand2.is_empty() { + let card1 = hand1.remove(0); + let card2 = hand2.remove(0); + + let mut played1 = vec![card1]; + let mut played2 = vec![card2]; + let mut num_played = 2; + + let mut current_card1 = card1; + let mut current_card2 = card2; + + loop { + print!("{}\t{}\t", cards[current_card1].display, cards[current_card2].display); + + if cards[current_card1].rank > cards[current_card2].rank { + hand1.extend(played1); + hand1.extend(played2); + println!("Player 1 takes the {} cards. Now has {}.", num_played, hand1.len()); + break; + } else if cards[current_card1].rank < cards[current_card2].rank { + hand2.extend(played2); + hand2.extend(played1); + println!("Player 2 takes the {} cards. Now has {}.", num_played, hand2.len()); + break; + } else { + println!("War!"); + + if hand1.len() < 2 { + println!("Player 1 has insufficient cards left."); + hand2.extend(played2); + hand2.extend(played1); + hand2.extend(hand1.drain(..)); + break; + } + + if hand2.len() < 2 { + println!("Player 2 has insufficient cards left."); + hand1.extend(played1); + hand1.extend(played2); + hand1.extend(hand2.drain(..)); + break; + } + + let fd_card1 = hand1.remove(0); // face down card + current_card1 = hand1.remove(0); // face up card + played1.push(fd_card1); + played1.push(current_card1); + + let fd_card2 = hand2.remove(0); // face down card + current_card2 = hand2.remove(0); // face up card + played2.push(fd_card2); + played2.push(current_card2); + + num_played += 4; + println!("? \t? \tFace down cards."); + } + } + } + + if hand1.len() == 52 { + println!("Player 1 wins the game!"); + } else { + println!("Player 2 wins the game!"); + } +} + +fn main() { + war(); +} diff --git a/Task/War-card-game/Zig/war-card-game.zig b/Task/War-card-game/Zig/war-card-game.zig new file mode 100644 index 0000000000..a305d37eee --- /dev/null +++ b/Task/War-card-game/Zig/war-card-game.zig @@ -0,0 +1,155 @@ +const std = @import("std"); +const print = std.debug.print; +const ArrayList = std.ArrayList; +const Allocator = std.mem.Allocator; + +const SUITS = [_][]const u8{ "♣", "♦", "♥", "♠" }; +const FACES = [_][]const u8{ "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A" }; + +const Card = struct { + display: [4]u8, + rank: usize, + + fn new(index: usize) Card { + const face = FACES[index % 13]; + const suit = SUITS[index / 13]; + + var display: [4]u8 = undefined; + // Copy face (1 byte) + display[0] = face[0]; + // Copy suit (3 bytes for Unicode symbols) + @memcpy(display[1..4], suit[0..3]); + + return Card{ + .display = display, + .rank = index % 13, + }; + } + + fn getDisplaySlice(self: *const Card) []const u8 { + return self.display[0..4]; + } +}; + +fn war(allocator: Allocator) !void { + // Create and shuffle deck + var deck = ArrayList(usize).init(allocator); + defer deck.deinit(); + + for (0..52) |i| { + try deck.append(i); + } + + // Shuffle deck + var prng = std.Random.DefaultPrng.init(blk: { + var seed: u64 = undefined; + std.posix.getrandom(std.mem.asBytes(&seed)) catch @panic("Failed to get random seed"); + break :blk seed; + }); + const random = prng.random(); + random.shuffle(usize, deck.items); + + // Deal cards to players (reversing order to match original implementation) + var hand1 = ArrayList(usize).init(allocator); + defer hand1.deinit(); + var hand2 = ArrayList(usize).init(allocator); + defer hand2.deinit(); + + try hand1.ensureTotalCapacity(52); + try hand2.ensureTotalCapacity(52); + + for (0..26) |i| { + try hand1.append(deck.items[2 * i]); + try hand2.append(deck.items[2 * i + 1]); + } + + // Reverse hands + std.mem.reverse(usize, hand1.items); + std.mem.reverse(usize, hand2.items); + + // Create cards lookup + var cards: [52]Card = undefined; + for (0..52) |i| { + cards[i] = Card.new(i); + } + + while (hand1.items.len > 0 and hand2.items.len > 0) { + const card1 = hand1.orderedRemove(0); + const card2 = hand2.orderedRemove(0); + + var played1 = ArrayList(usize).init(allocator); + defer played1.deinit(); + var played2 = ArrayList(usize).init(allocator); + defer played2.deinit(); + + try played1.append(card1); + try played2.append(card2); + var num_played: usize = 2; + + var current_card1 = card1; + var current_card2 = card2; + + while (true) { + print("{s}\t{s}\t", .{cards[current_card1].getDisplaySlice(), cards[current_card2].getDisplaySlice()} ); + + if (cards[current_card1].rank > cards[current_card2].rank) { + try hand1.appendSlice(played1.items); + try hand1.appendSlice(played2.items); + print("Player 1 takes the {} cards. Now has {}.\n", .{ num_played, hand1.items.len }); + break; + } else if (cards[current_card1].rank < cards[current_card2].rank) { + try hand2.appendSlice(played2.items); + try hand2.appendSlice(played1.items); + print("Player 2 takes the {} cards. Now has {}.\n", .{ num_played, hand2.items.len }); + break; + } else { + print("War!\n", .{}); + + if (hand1.items.len < 2) { + print("Player 1 has insufficient cards left.\n", .{}); + try hand2.appendSlice(played2.items); + try hand2.appendSlice(played1.items); + try hand2.appendSlice(hand1.items); + hand1.clearRetainingCapacity(); + break; + } + + if (hand2.items.len < 2) { + print("Player 2 has insufficient cards left.\n", .{}); + try hand1.appendSlice(played1.items); + try hand1.appendSlice(played2.items); + try hand1.appendSlice(hand2.items); + hand2.clearRetainingCapacity(); + break; + } + + const fd_card1 = hand1.orderedRemove(0); // face down card + current_card1 = hand1.orderedRemove(0); // face up card + try played1.append(fd_card1); + try played1.append(current_card1); + + const fd_card2 = hand2.orderedRemove(0); // face down card + current_card2 = hand2.orderedRemove(0); // face up card + try played2.append(fd_card2); + try played2.append(current_card2); + + num_played += 4; + print("? \t? \tFace down cards.\n" , .{}); + } + } + } + + if (hand1.items.len == 52) { + print("Player 1 wins the game!\n", .{}); + } else { + print("Player 2 wins the game!\n", .{}); + } +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + try war(allocator); +} diff --git a/Task/Web-scraping/REBOL/web-scraping.rebol b/Task/Web-scraping/REBOL/web-scraping.rebol index 0ff410d319..d8290431d1 100644 --- a/Task/Web-scraping/REBOL/web-scraping.rebol +++ b/Task/Web-scraping/REBOL/web-scraping.rebol @@ -1,4 +1,4 @@ -REBOL [ +Rebol [ Title: "Web Scraping" URL: http://rosettacode.org/wiki/Web_Scraping ] diff --git a/Task/Wieferich-primes/Agena/wieferich-primes.agena b/Task/Wieferich-primes/Agena/wieferich-primes.agena new file mode 100644 index 0000000000..00675721a2 --- /dev/null +++ b/Task/Wieferich-primes/Agena/wieferich-primes.agena @@ -0,0 +1,37 @@ +scope # find some Wierferich Primes: primes p where p^2 evenly divides 2^(p-1)-1 + + import mapm; # explicit import needed for: Linux, Mac OS X, Windows and Solaris + + local constant maxNumber := 5000; # maximum number we will consider + mapm.xdigits( 1600 ); # need 1600 digits for this task + + # sieve the primes up to maxNumber + local primes; create register primes( maxNumber ); + primes[ 1 ] := false; + for sPos from 2 to maxNumber do primes[ sPos ] := true od; + for sPos from 2 to entier( sqrt( maxNumber ) ) do + if primes[ sPos ] then + for p from sPos * sPos to maxNumber by sPos do + primes[ p ] := false + od + fi + od; + + # find the first two Wierferich Primes - note 2 is not a Wierferich prime + local constant b0, constant b1 := mapm.xnumber( 0 ), mapm.xnumber( 1 ); + local pPos, twoToPMinus1, power, wCount := 1, b1, 0, 0; + for pPos from 3 to size primes by 2 while wCount < 2 do + if primes[ pPos ] then + local constant p := pPos; + while power < ( p - 1 ) do + twoToPMinus1 +:= twoToPMinus1; + power +:= 1 + od; + local constant p2 := p * p; + if ( twoToPMinus1 - b1 ) % p2 = b0 then + printf( " %d", p ) + wCount +:= 1 + fi + fi + od +end diff --git a/Task/Wieferich-primes/Common-Lisp/wieferich-primes.lisp b/Task/Wieferich-primes/Common-Lisp/wieferich-primes.lisp new file mode 100644 index 0000000000..92b26e39ca --- /dev/null +++ b/Task/Wieferich-primes/Common-Lisp/wieferich-primes.lisp @@ -0,0 +1,35 @@ +(defun modpow (base exp mod) + (cond ((= mod 1) 0) + (t (do ((base (mod base mod) (mod (* base base) mod)) + (exp exp (ash exp -1)) + (result 1 (cond ((= (logand exp 1) 1) (mod (* result base) mod)) + (t result)))) + ((zerop exp) result))))) + +(defun primes-upto (limit) + (let ((sieve (make-array limit :element-type 'boolean :initial-element t))) + (when (plusp limit) (setf (svref sieve 0) nil)) + (when (> limit 1) (setf (svref sieve 1) nil)) + (loop for i from 4 below limit by 2 + do (setf (svref sieve i) nil)) + (loop for p = 3 then (+ p 2) + for q = (expt p 2) + while (< q limit) + when (aref sieve p) + do (loop with incr = (* 2 p) + while (< q limit) + do (setf (svref sieve q) nil) + (incf q incr))) + sieve)) + +(defun wieferich-primes-upto (limit) + (loop with sieve = (primes-upto limit) + for p from 3 below limit by 2 + when (and (svref sieve p) (= (modpow 2 (1- p) (expt p 2)) 1)) + collect p)) + +(defparameter *check-upto-limit* 5000) + +(format t "Wieferich primes less than ~a:~%~{~a~%~}" + *check-upto-limit* + (wieferich-primes-upto *check-upto-limit*)) diff --git a/Task/Wieferich-primes/Lua/wieferich-primes.lua b/Task/Wieferich-primes/Lua/wieferich-primes.lua new file mode 100644 index 0000000000..dd781ad0c8 --- /dev/null +++ b/Task/Wieferich-primes/Lua/wieferich-primes.lua @@ -0,0 +1,48 @@ +function prime_sieve(limit) + local sieve = {} + for i = 2, limit do sieve[i] = true end + if limit > 1 then sieve[1] = false end + for i = 4, limit, 2 do sieve[i] = false end + local p = 3 + while true do + local q = p * p + if q > limit then break end + if sieve[p] then + local incr = 2 * p + for r = q, limit, incr do + sieve[r] = false + end + end + p = p + 2 + end + return sieve +end + +function modpow(base, exp, mod) + if mod == 1 then return 0 end + local result = 1 + base = base % mod + while exp > 0 do + if (exp & 1) == 1 then + result = (result * base) % mod + end + base = (base * base) % mod + exp = exp >> 1 + end + return result +end + +function wieferich_primes(limit) + local result = {} + local sieve = prime_sieve(limit) + for p = 2, limit do + if sieve[p] and modpow(2, p - 1, p * p) == 1 then + table.insert(result, p) + end + end + return result +end + +local limit = 5000 +print('Wieferich primes less than ' .. limit .. ':') +print(table.unpack(wieferich_primes(limit))) diff --git a/Task/Wieferich-primes/Pluto/wieferich-primes.pluto b/Task/Wieferich-primes/Pluto/wieferich-primes.pluto new file mode 100644 index 0000000000..7b587f9dbe --- /dev/null +++ b/Task/Wieferich-primes/Pluto/wieferich-primes.pluto @@ -0,0 +1,24 @@ +do -- find some Wierferich Primes: primes p where p^2 evenly divides 2^(p-1)-1 + + local bigint = require( "pluto:bigint" ) -- standard Pluto big integers + local int = require( "int" ) -- RC integer module, includes some prime utilities + local maxNumber = 5000 -- maximum number we will consider + local primeList = int.primes( maxNumber ) -- get a list of primes up to maxNumber + + -- find the first two Wierferich Primes + local b0 , b1 = new bigint( 0 ), new bigint( 1 ) + local pPos, twoToPMinus1, power, wCount = 1, b1, 0, 0 + for primeList as p do + if wCount == 2 then break end + while power < ( p - 1 ) do + twoToPMinus1 += twoToPMinus1 + power += 1 + end + local p2 = new bigint( p * p ) + if ( twoToPMinus1 - b1 ) % p2 == b0 then + io.write( " ", p ) + wCount += 1 + end + pPos += 1 + end +end diff --git a/Task/Wieferich-primes/R/wieferich-primes.r b/Task/Wieferich-primes/R/wieferich-primes.r new file mode 100644 index 0000000000..8588c0ab60 --- /dev/null +++ b/Task/Wieferich-primes/R/wieferich-primes.r @@ -0,0 +1,10 @@ +library(gmp) + +is_wieferich <- function(p){ + p_big <- as.bigz(p) + (2^(p_big-1)-1)%%(p_big^2)==0 +} + +primes <- which(isprime(1:5000)!=0) + +primes[is_wieferich(primes)] diff --git a/Task/Window-creation/TAV/window-creation.tav b/Task/Window-creation/TAV/window-creation.tav new file mode 100644 index 0000000000..1f031b2e6d --- /dev/null +++ b/Task/Window-creation/TAV/window-creation.tav @@ -0,0 +1,9 @@ +main (args):+ + GTK init args + win =: new GTK window \ currently only top-level + win::set title "Hello GTK" + win::set size 200, 100 + win::connect 'destroy' to `GTK main quit` + win::show all + GTK main win +\+ ./TAVPL_gtk.tavh diff --git a/Task/Wireworld/Prolog/wireworld.pro b/Task/Wireworld/Prolog/wireworld.pro new file mode 100644 index 0000000000..a3bfa8b5cb --- /dev/null +++ b/Task/Wireworld/Prolog/wireworld.pro @@ -0,0 +1,69 @@ +:- initialization(main, main). +:- set_prolog_flag(double_quotes, codes). +:- use_module(library(ansi_term), [ansi_format/3]). +:- use_module(library(dcg/basics), [blanks/2, eol/2, eos/2, string_without/4]). +:- use_module(library(dcg/high_order), [optional/4, sequence/4]). + +grid(Grid) --> sequence(row, Grid), blanks. +row(Row) --> string_without("\n", Row), { Row \= [] }, eol. + +:- meta_predicate maplist_with_nth0(3, +, -). +maplist_with_nth0(Goal, List0, List) :- + length(List0, Length), + succ(LastIndex, Length), + numlist(0, LastIndex, N0s), + maplist(Goal, N0s, List0, List). + +:- meta_predicate map_grid0(3, +, -). +map_grid0(Goal, Grid0, Grid) :- + maplist_with_nth0({Goal}/[Y, Row0, Row] >> ( + maplist_with_nth0({Goal, Y}/[X, T0, T] >> ( + call(Goal, yx(Y, X), T0, T) + ), Row0, Row) + ), Grid0, Grid). + +yxth0(yx(Y, X)) --> nth0(Y), nth0(X). + +moore_neighbourhood(yx(Y0, X0), yx(Y, X)) :- succ(Y0, Y), ( succ(X, X0) ; X = X0 ; succ(X0, X) ). +moore_neighbourhood(yx(Y, X0), yx(Y, X)) :- succ(X, X0) ; succ(X0, X). +moore_neighbourhood(yx(Y0, X0), yx(Y, X)) :- succ(Y, Y0), ( succ(X, X0) ; X = X0 ; succ(X0, X) ). + +transition(_, _, 0' , 0' ) :- !. +transition(_, _, 0'H, 0't) :- !. +transition(_, _, 0't, 0'.) :- !. +transition(Grid, Here, 0'., State) :- + aggregate_all(count, ( + moore_neighbourhood(Here, There), + yxth0(There, Grid, 0'H) + ), AdjacentHeads), + ( between(1, 2, AdjacentHeads) + -> State = 0'H + ; State = 0'. + ). + +char_attributes(0'., [bg(yellow)]). +char_attributes(0' , []). +char_attributes(0't, [bg(red)]). +char_attributes(0'H, [bg(blue)]). + +display(Grid) :- + maplist([Row] >> ( + maplist([Char] >> ( + char_attributes(Char, Attributes), + ansi_format(Attributes, "~c", [Char]) + ), Row), + nl + ), Grid). + +simulate(Grid0) :- + map_grid0(transition(Grid0), Grid0, Grid), + display(Grid), + sleep(0.25), + length(Grid, Height), + format("\e[~dA", [Height]), + simulate(Grid). + +main([Filename]) :- + format("Welcome to WireWorld! Press ^C to exit.~n~n", []), + once(phrase_from_file(grid(Grid), Filename)), + simulate(Grid). diff --git a/Task/Word-frequency/TAV/word-frequency.tav b/Task/Word-frequency/TAV/word-frequency.tav new file mode 100644 index 0000000000..a5bc650348 --- /dev/null +++ b/Task/Word-frequency/TAV/word-frequency.tav @@ -0,0 +1,34 @@ +main (args):+ + wm =: count words "../les_mis_135-0.txt" + wr =: map wm as row descending value key pairs + ?# i =: from 1 upto max + print format '%6d; %s;' wr[i] \ wr[i] is a pair + +\ read the file and provide a map with all words and their count +count words (fn): + wl =: new map + ?# line =: file fn give lines + ?# word =: string line give words of #ASCIIletters + word =: string word case to lower + wl{word} =+ 1 \ count for word; void is zero for addition + wl.words =+ 1 \ count number of words + :> wl + +\ create a sorted row of pairs (count, word) +map (@) as row descending value key pairs: + rvk =: new row size @.Count + ?# k =: map @ give keys + rvk[] =: @{k}, k + row rvk sort fast descending + :> rvk + +\ not (yet) in library +string (@) give words of (chars): + $ =~ 1 \ start point + ?* $ <= @.Count + word =: string @ from $ many of chars + $ =+ word.Count + 1 \ skip following character + ? word ~= '' + :> word + $ =: () + :> () diff --git a/Task/Word-wheel/ALGOL-68/word-wheel.alg b/Task/Word-wheel/ALGOL-68/word-wheel.alg new file mode 100644 index 0000000000..f55627274d --- /dev/null +++ b/Task/Word-wheel/ALGOL-68/word-wheel.alg @@ -0,0 +1,36 @@ +STRING wheel = "ndeokgelw"; + +PROC check word = (STRING word, wheel)BOOL: + IF UPB word >= 3 AND UPB word <= UPB wheel THEN + STRING wh := wheel; + FOR i TO UPB word DO + CHAR ch = word[i]; + FOR j TO UPB wh DO + IF ch = wh[j] THEN + wh[j] := REPR 0; + continue + FI + OD; + return false; + continue: SKIP + OD; + IF wh[UPB wh % 2 + 1] /= REPR 0 THEN return false FI; + TRUE EXIT + return false: FALSE + ELSE + FALSE + FI; + +BEGIN + FILE f; + BOOL eof := FALSE; + open(f, "unixdict.txt", stand in channel); + on logical file end(f, (REF FILE f)BOOL: eof := TRUE); + WHILE ~eof DO + STRING word; + get(f, (word, new line)); + IF check word(word, wheel) THEN + print((word, new line)) + FI + OD +END diff --git a/Task/Word-wrap/FutureBasic/word-wrap.basic b/Task/Word-wrap/FutureBasic/word-wrap.basic new file mode 100644 index 0000000000..4effaec67d --- /dev/null +++ b/Task/Word-wrap/FutureBasic/word-wrap.basic @@ -0,0 +1,59 @@ +CFArrayRef local fn WrapStringAtWordBoundaries( txtStr as CFStringRef, maxLineLength as NSUInteger ) + CFMutableArrayRef lines = fn MutableArrayNew + ScannerRef scanner = fn ScannerWithString( txtStr ) + CFMutableStringref currentLine = fn MutableStringNew + CFStringRef wordStr + ScannerSetCharactersToBeSkipped( scanner, NULL ) + + while ( fn ScannerIsAtEnd( scanner ) == NO ) + fn ScannerScanUpToCharactersFromSet( scanner, fn CharacterSetWhitespaceAndNewlineSet, @wordStr ) + + if ( wordStr ) + if ( ( len( currentLine ) + len( wordStr ) + 1 ) > maxLineLength ) + if ( len( currentLine ) > 0 ) + MutableArrayAddObject( lines, fn StringWithString( currentLine ) ) + MutableStringSetString( currentLine, @"" ) // Reset the line + end if + end if + if ( len( currentLine ) > 0 ) + MutableStringAppendString( currentLine, @" " ) + end if + MutableStringAppendString( currentLine, wordStr ) + end if + fn ScannerScanCharactersFromSet( scanner, fn CharacterSetWhitespaceAndNewlineSet, NULL ) // Skip over whitespace between words + wend + + if ( len( currentLine ) > 0 ) + MutableArrayAddObject( lines, fn StringWithString( currentLine ) ) + end if + + return lines +end fn = NULL + + +CFStringRef txtStr +txtStr = @"In olden times when wishing still helped one, there lived a king ¬ +whose daughters were all beautiful, but the youngest was so beautiful ¬ +that the sun itself, which has seen so much, was astonished whenever ¬ +it shone-in-her-face. Close by the king's castle lay a great dark ¬ +forest, and under an old lime-tree in the forest was a well, and when ¬ +the day was very warm, the king's child went out into the forest and ¬ +sat down by the side of the cool-fountain, and when she was bored she ¬ +took a golden ball, and threw it up on high and caught it, and this ¬ +ball was her favorite plaything." + +CFStringRef columnizedStr + +// Create wrapping lines respecting word boundaries + +print @"Wrapped at 20 characters:" +columnizedStr = fn ArrayComponentsJoinedByString( fn WrapStringAtWordBoundaries( txtStr, 20 ), @"\n" ) +print columnizedStr + +print + +print @"Wrapped at 80 characters:" +columnizedStr = fn ArrayComponentsJoinedByString( fn WrapStringAtWordBoundaries( txtStr, 80 ), @"\n" ) +print columnizedStr + +HandleEvents diff --git a/Task/Write-entire-file/ArkScript/write-entire-file.ark b/Task/Write-entire-file/ArkScript/write-entire-file.ark new file mode 100644 index 0000000000..2388fe93e8 --- /dev/null +++ b/Task/Write-entire-file/ArkScript/write-entire-file.ark @@ -0,0 +1 @@ +(io:writeFile "output.txt" "hello, world!") diff --git a/Task/Write-entire-file/Frink/write-entire-file.frink b/Task/Write-entire-file/Frink/write-entire-file.frink index 9a4b9aa562..5d2fadce34 100644 --- a/Task/Write-entire-file/Frink/write-entire-file.frink +++ b/Task/Write-entire-file/Frink/write-entire-file.frink @@ -1,3 +1 @@ -w = new Writer["test.txt"] -w.print["I am the captain now."] -w.close[] +w = new Writer["test.txt"].printAndClose["I am the captain now."] diff --git a/Task/Write-entire-file/Odin/write-entire-file.odin b/Task/Write-entire-file/Odin/write-entire-file.odin index 0b13d18a2a..e9ef5612e4 100644 --- a/Task/Write-entire-file/Odin/write-entire-file.odin +++ b/Task/Write-entire-file/Odin/write-entire-file.odin @@ -2,10 +2,19 @@ package main import "core:fmt" import "core:os" -import "core:c/libc" + main :: proc() { - dummy := "henlo" - succ:= os.write_entire_file("file",transmute([]u8)(dummy),false) + dummy := "This is a string." + write := os.write_entire_file("file",transmute([]u8)(dummy),false) + + // Returns an error + write2 := os.write_entire_file_or_err("file2",transmute([]u8)(dummy),false) + + // If error than do something + if (write2!=nil){ + fmt.println("err") + } + } diff --git a/Task/Write-entire-file/R/write-entire-file.r b/Task/Write-entire-file/R/write-entire-file.r new file mode 100644 index 0000000000..1e6d5a4378 --- /dev/null +++ b/Task/Write-entire-file/R/write-entire-file.r @@ -0,0 +1 @@ +writeLines(text="This is a string.", con="file.txt") diff --git a/Task/Xiaolin-Wus-line-algorithm/YAMLScript/xiaolin-wus-line-algorithm.ys b/Task/Xiaolin-Wus-line-algorithm/YAMLScript/xiaolin-wus-line-algorithm.ys new file mode 100644 index 0000000000..d94adce73d --- /dev/null +++ b/Task/Xiaolin-Wus-line-algorithm/YAMLScript/xiaolin-wus-line-algorithm.ys @@ -0,0 +1,52 @@ +!YS-v0 + +defn main(): + draw-line: 0 1 10 2 + +defn draw-line(x0 y0 x1 y1): + plot x0 x1 y0 y1 =: + if abs(y1 - y0) > abs(x1 - x0): + + [\(plot(y0 x0 x1)) y0 x0 y1 x1] + [plot x0 x1 y0 y1] + + x0 x1 y0 y1 =: + if x0 > x1: + + [x1 x0 y1 y0] + [x0 x1 y0 y1] + + dx =: x1 - x0 + dy =: y1 - y0 + gradient =: dy / dx + + intery xends =: + loop intery 0, xends [], [[x y] *xys] [[x0 y0] [x1 y1]]: + xend =: round(x) + yend =: y + (gradient * (xend - x)) + xgap =: rfpart(x + 0.5) + + x-pixel =: xend + y-pixel =: yend:to-int + xends =: xends.conj(x-pixel) + + plot: x-pixel y-pixel (rfpart(yend) * xgap) + plot: x-pixel y-pixel.++ (fpart(yend) * xgap) + intery |||=: yend + gradient + + if xys.?: + recur: intery, xends, xys + vector: intery, xends + + loop intery intery, [x *xs] (xends.0.++ .. xends.1.--): + plot: x intery:I rfpart(intery) + plot: x intery:I.++ fpart(intery) + when xs.?: + recur (intery + gradient): xs + +defn plot(x y c): + when c != 0.0: + say: + format 'plot %d %d %.1f': x y c:F + +defn fpart(x): x - x:to-int + +defn rfpart(x): 1 - fpart(x) diff --git a/Task/Y-combinator/Pluto/y-combinator.pluto b/Task/Y-combinator/Pluto/y-combinator.pluto new file mode 100644 index 0000000000..88cd0c6519 --- /dev/null +++ b/Task/Y-combinator/Pluto/y-combinator.pluto @@ -0,0 +1,14 @@ +local function y(f) + local g = |r| -> f(|x| -> r(r)(x)) + return g(g) +end + +local almost_fac = |f| -> (|x| -> x <= 1 ? 1 : x * f(x - 1)) + +local almost_fib = |f| -> (|x| -> x <= 2 ? 1 : f(x - 1) + f(x - 2)) + +local fac = y(almost_fac) +local fib = y(almost_fib) + +print($"fac(10) = {fac(10)}") +print($"fib(10) = {fib(10)}") diff --git a/Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena b/Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena new file mode 100644 index 0000000000..d02ca7f5e5 --- /dev/null +++ b/Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena @@ -0,0 +1,27 @@ +scope # Yellowstone sequence - translation of the Pluto sample + + local procedure yellowstone( n :: number ) :: table + local a, m := [ 1, 2, 3 ], [ true, true, true ]; + for x from 4 to n do + a[ x ], m[ x ] := 0, false + od; + local minV := 4; + for c from 4 to n do + local more := true + for i from minV while more do + if not m[ i ] and numtheory.gcd( a[ c - 1 ], i ) = 1 and numtheory.gcd( a[ c - 2 ], i ) > 1 + then + a[ c ], m[ i ] := i, true; + if i = minV then minV +:= 1 fi; + more := false + fi + od + od; + return a + end; + + local constant ySize, constant perLine := 30, 10; + local y := yellowstone( ySize ); + printf( "The first %d Yellowstone numbers are:\n", ySize ); + for yPos to ySize do printf( " %2d", y[ yPos ] ); if yPos mod perLine = 0 then print() fi od +end diff --git a/Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel b/Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel new file mode 100644 index 0000000000..88b0486ee1 --- /dev/null +++ b/Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel @@ -0,0 +1,45 @@ +(do ;;; Yellowstone sequence - translation of the Pluto sample + + (fn gcd [m n] + (var (a b) (values (math.abs m) (math.abs n))) + (while (not= b 0) + (set (b a) (values (% a b) b)) + ) + a + ) + + (fn yellowstone [n] + (var (a m) (values [1 2 3] [true true true])) + (for [x 4 n] + (tset a x 0) + (tset m x false) + ) + (var minV 4) + (for [c 4 n] + (var (more i) (values true minV)) + (while more + (when (and (not (. m i)) + (= (gcd (. a (- c 1)) i) 1) + (> (gcd (. a (- c 2)) i) 1) + ) + (tset a c i) + (tset m i true) + (when (= i minV) + (set minV (+ 1 minV)) + ) + (set more false) + ) + (set i (+ i 1)) + ) + ) + a + ) + + (local (ySize perLine) (values 30 10)) + (local y (yellowstone ySize)) + (io.write (string.format "The first %d Yellowstone numbers are:\n" ySize)) + (for [yPos 1 ySize] + (io.write (string.format " %2d" (. y yPos))) + (when (= 0 (% yPos perLine)) (print)) + ) +) diff --git a/Task/Yellowstone-sequence/FutureBasic/yellowstone-sequence.basic b/Task/Yellowstone-sequence/FutureBasic/yellowstone-sequence.basic new file mode 100644 index 0000000000..74da99ae02 --- /dev/null +++ b/Task/Yellowstone-sequence/FutureBasic/yellowstone-sequence.basic @@ -0,0 +1,33 @@ +include "NSLog.incl" + +NSInteger local fn GCD( a as NSInteger, b as NSInteger ) + if ( a == 0 ) then return b + return fn GCD( b % a, a ) +end fn = 0 + +void local fn CalcYellowstoneSequence( terms as int ) + CFMutableArrayRef sequence = fn MutableArrayWithObjects( @1, @2, @3, NULL ) + + for int n = 3 to terms - 1 + NSInteger prev1 = fn NumberIntegerValue( fn ArrayObjectAtIndex( sequence, n - 1 ) ) + NSInteger prev2 = fn NumberIntegerValue( fn ArrayObjectAtIndex( sequence, n - 2 ) ) + NSInteger candidate = 1 + + while (YES) + if ( !fn ArrayContainsObject( sequence, @(candidate) ) && fn GCD( candidate, prev1 ) == 1 && fn GCD( candidate, prev2 ) > 1 ) + MutableArrayAddObject( sequence, @(candidate) ) + break + end if + candidate++ + wend + next + + NSLog( @"Yellowstone sequence up to %d terms:", terms ) + for CFNumberRef num in sequence + NSLog( @"%@ \b", num ) + next +end fn + +fn CalcYellowstoneSequence( 30 ) + +HandleEvents diff --git a/Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto b/Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto new file mode 100644 index 0000000000..74f3cd66f5 --- /dev/null +++ b/Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto @@ -0,0 +1,32 @@ +require "table2" +local int = require "int" +local fmt = require "fmt" + +local function yellowstone(n) + local m = {} + local a = table.rep(n, 0) + for i = 1, 3 do + a[i] = i + m[i] = true + end + local min = 4 + for c = 4, n do + local i = min + while true do + if !m[i] and int.gcd(a[c - 1], i) == 1 and int.gcd(a[c - 2], i) > 1 then + a[c] = i + m[i] = true + if i == min then ++min end + break + end + ++i + end + end + return a +end + +local x = {} +for i = 1, 30 do x[i] = i end +local y = yellowstone(30) +print("The first 30 Yellowstone numbers are:") +fmt.tprint("%2d ", y, 10) diff --git a/Task/Yellowstone-sequence/REXX/yellowstone-sequence.rexx b/Task/Yellowstone-sequence/REXX/yellowstone-sequence.rexx index de391c503f..364dc133fd 100644 --- a/Task/Yellowstone-sequence/REXX/yellowstone-sequence.rexx +++ b/Task/Yellowstone-sequence/REXX/yellowstone-sequence.rexx @@ -1,4 +1,4 @@ --- 25 Apr 2025 +-- 28 Jul 2025 include Settings numeric digits 100 arg xx @@ -14,7 +14,7 @@ call Timer exit GetYellow: -procedure expose yell. work. +procedure expose yell. work. Memo. arg xx say 'Get yellowstones...' yell. = 0; work. = 0; n = 0 @@ -50,7 +50,4 @@ end say return -include Sequences -include Functions -include Helper -include Abend +include Math diff --git a/Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys b/Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys new file mode 100644 index 0000000000..313b8c66f7 --- /dev/null +++ b/Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys @@ -0,0 +1,24 @@ +!YS-v0 + +defn main(n=30): + say: yellow(n) + +defn yellow(n): + a =: +[1 2 3] + b =: (1 .. 3).zipmap([true]:cycle) + i =: 4 + loop a a, b b, i i: + if n > a.#: + ? if b.$i.! && + (i.gcd(a.$) == 1) && + (i.gcd(a:butlast.$) > 1) + : recur: + a.conj(i), b.assoc(i true), 5 + recur: a, b, i.++ + =>: a + +defn gcd(a b): + loop a a, b b: + if b.?: + recur b: a % b + else: a diff --git a/Task/Zebra-puzzle/FutureBasic/zebra-puzzle.basic b/Task/Zebra-puzzle/FutureBasic/zebra-puzzle.basic new file mode 100644 index 0000000000..9853f130be --- /dev/null +++ b/Task/Zebra-puzzle/FutureBasic/zebra-puzzle.basic @@ -0,0 +1,266 @@ +/* + + Z E B R A P U Z Z L E + Based on Phix logic + FutureBasic 7.0.34, August 2025 R.W. + +*/ + +/*-------------------------------------------------------------------- + There are five houses... +---------------------------------------------------------------------- +// The green house is immediately to the left of the white house +// The Norwegian lives in the first house +// The English man lives in the red house +// The Norwegian lives next to the blue house +// The Dane drinks tea +// They drink coffee in the green house +// In the middle house they drink milk +// In the yellow house they smoke Dunhill +// The German smokes Prince +// The man who smokes Blue Master drinks beer +// They drink water in a house next to the house where they smoke Blend +// The Swede has a dog +// The man who smokes Pall Mall has birds +// The man who smokes Blend lives in the house next to the house with cats +// In a house next to the house where they have a horse, +// they smoke Dunhill +// +// Task: Who owns the zebra? +*/ +// Enumerate based on the data given +// in the puzzle (5 variables for each group) + +Begin Enum 1 // drinks + _tea + _coffee + _milk + _beer + _water +End Enum + +Begin Enum 1 // nationalities + _English + _Swede + _Dane + _Norwegian + _German +End Enum + +Begin Enum 1 // house colors + _red + _white + _green + _yellow + _blue +End Enum + +Begin Enum 1 // smokes + _PallMall + _Dunhill + _Blend + _BlueMaster + _Prince +End Enum + +Begin Enum 1 // animals + _dog + _birds + _cats + _horse + _zebra +End Enum + +// Since we have 5 variables, the total permutation/combo +// would be 5! (5 factorial) which is 120 + +Int gPermutation(120, 5) // 120 combinations +Int gNumbers(5) // of 1 to 5 +Int gPermCount +Int factorial5 = 120 // value of 5! +Int entry, ns, ic +Int color, nationality, drink, smoke, pet // 5 groups + +// Since we used assigned numbers, we need this to +// show the equivalent description + +CFStringRef Colors(5) = {@"Houses",@"red",@"white",¬ +@"green",@"yellow",@"blue"} +CFStringRef Nationalities(5) = {@"Nationalities",@"English",@"Swede",¬ +@"Dane",@"Norwegian",@"German"} +CFStringRef Smokes(5) = {@"Smokes",@"Pall Mall",@"Dunhill",¬ +@"Blend",@"Blue Master",@"Prince"} +CFStringRef Drinks(5) = {@"Drinks",@"tea",@"coffee",¬ +@"milk",@"beer",@"water"} +CFStringRef Pets(5) = {@"Animals",@"dog",@"birds",¬ +@"cats",@"horse",@"zebra"} + +// Recursive permutation generator +local fn Permute( l as int, r as int ) + dim i as int + if l = r + for i = 1 to 5 + gPermutation(gPermCount, i) = gNumbers(i) + next + gPermCount++ + else + for i = l to r + swap gNumbers(l), gNumbers(i) + fn Permute( l + 1, r ) + swap gNumbers(l), gNumbers(i) + next + end if +end fn + +// +// Fill arrays of 5! permutations of 1 to 5 +local fn generatePermutations + int i + for i = 1 to 5: gNumbers(i) = i: next i + gPermCount = 1 + fn Permute( 1, 5 ) // Use 1-based index range +end fn + +// +// Pad spaces to width of "padTo" for output formatting +Local fn Pad(theString as CFStringRef, padTo as Int) as CFStringRef + theString = fn StringByReplacingOccurrencesOfString (theString, @"\"", @"" ) + if len(theString) < padTo then theString ¬ + = left( concat( theString, @" "), padTo ) + print theString; +end fn = theString + +// Find an entry in the permutation table +// c1 = index into gPermutation array +// v1 = the seek value +local fn find(c1 as Int, v1 as Int) as Int + Int h, i + h = 0 + for i = 1 to 5 + if gPermutation(c1,i) == v1 then h = i: i = 6: + next i +end fn = h + +// +// Left (as seen from the front) to location logic +local fn left_of(c1 as Int, v1 as Int, c2 as Int, v2 as Int) as Int + Int h, result + h = fn find(c1,v1) + result = (h <=4) && (gPermutation(c2,h + 1) == v2) +end fn = result + +// +// Is in the same house logic +local fn same_house(c1 as Int, v1 as Int, c2 as Int, v2 as Int) as Int + Int h, result + h = fn find(c1, v1) + result = (gPermutation(c2,h) == v2) +end fn = result + +// +// located next to logic +local fn next_to(c1 as Int, v1 as Int, c2 as Int, v2 as Int) as Int + Int h1, h2, result + h1 = fn find(c1, v1): h2 = fn find(c2, v2) + result = abs(h1-h2) == 1 +end fn = result + +//================================================================ +// Main + +window 1,@"Zebra puzzle" + +Int i, j +fn generatePermutations +// start the clock +CFTimeInterval t +t = fn CACurrentMediaTime +print + +for Color = 1 to factorial5 + ic++ + // The green house is immediately to the left of the white house + if fn left_of (Color, _green, Color, _white) + + for Nationality = 1 to factorial5 + ic++ + // The Norwegian lives in the first house and + // The English man lives in the red house and + // The Norwegian lives next to the blue house. + if gPermutation (Nationality,1) == _Norwegian && ¬ + fn same_house (Nationality, _English, Color, _red) && ¬ + fn next_to (Nationality, _Norwegian,Color, _blue) + + for drink = 1 to factorial5 + ic++ + // The Dane drinks tea and + // They drink coffee in the green house and + // In the middle house they drink milk + if fn same_house (Nationality, _Dane,drink, _tea) && ¬ + fn same_house (drink, _coffee, Color, _green) && ¬ + gPermutation (drink, 3) == _milk + + for smoke = 1 to factorial5 + ic++ + // In the yellow house they smoke Dunhill and + // The German smokes Prince and + // The man who smokes Blue Master drinks beer and + // They drink water in a house next to the house + // where they smoke Blend + if fn same_house (Color, _yellow, smoke, _Dunhill) && ¬ + fn same_house (Nationality, _German, smoke, _Prince) && ¬ + fn same_house (smoke, _BlueMaster, drink, _beer) && ¬ + fn next_to (drink, _water, smoke, _Blend) + + for pet = 1 to factorial5 + ic++ + // The Swede has a dog and + // The man who smokes Pall Mall has birds and + // The man who smokes Blend lives in the house next + // to the house with cats and + // In a house next to the house where they have a horse, + // they smoke Dunhill + if fn same_house (Nationality, _Swede, pet, _dog) && ¬ + fn same_house (smoke,_PallMall, pet, _birds) && ¬ + fn next_to (smoke,_Blend, pet, _cats) && ¬ + fn next_to (pet,_horse,smoke,_Dunhill) + + // stop the clock + printf @" Solved in = %.4f seconds", ¬ + (fn CACurrentMediaTime-t) + print + // Show the results + fn pad (@" HOUSE",11): fn pad (@"PERSON",11) + fn pad (@"DRINKS",8): fn pad (@"SMOKES",13) + fn pad (@"HAS",6) + print + print " ===============================================" + for i=1 to 5 + print " ";i;" "; + fn pad (Colors(gPermutation(color,i)),8) + fn pad (Nationalities(gPermutation(Nationality,i)),11) + fn pad (Drinks(gPermutation(drink,i)),8) + fn pad (Smokes(gPermutation(smoke,i)),13) + fn pad (Pets(gPermutation(pet,i)),8): print + if i == 5 then entry = i + next i + print + print " The ";Nationalities(entry);" owns the zebra." + ns += 1: print + print " ";ic;" combinations tested before finding a solution" + print " Solution found = ";ns; + if ns < 2 then print " (unique)" + end if //5 + next pet + end if //4 + next smoke + end if //3 + next drink + end if //2 + next nationality + end if //1 +next color +// +handleEvents + +// diff --git a/Task/Zebra-puzzle/J/zebra-puzzle-1.j b/Task/Zebra-puzzle/J/zebra-puzzle-1.j index b34c7f5f07..c7b7d82cdc 100644 --- a/Task/Zebra-puzzle/J/zebra-puzzle-1.j +++ b/Task/Zebra-puzzle/J/zebra-puzzle-1.j @@ -1,7 +1,7 @@ in=: {{n&{ i. m"_}} NB. index of m in row n of matrix F =: {{u"_1 # ]}} NB. filter by function of items 'Col Nat Pet Drink Cig'=: i.5 NB. refer to rows by name -'col nat pet drink cig'=: (A.~i.@!@#)&>;:'BGRWY DEGNS BCDHZ BCMTW BbDpP' NB. perm matrices +'col nat pet drink cig'=: (A.~i.@!@#)&>BGRWY`DEGNS`BCDHZ`BCMTW`BbDpP NB. perm matrices P=: ,/col,:"1/nat NB. join color and nationality matrices P=: ('W' in Col = 1+ 'G' in Col)F P NB. white right of green P=: (0 = 'N' in Nat)F P NB. Norwegian in first house diff --git a/Task/Zebra-puzzle/Pluto/zebra-puzzle.pluto b/Task/Zebra-puzzle/Pluto/zebra-puzzle.pluto new file mode 100644 index 0000000000..b4958e1aed --- /dev/null +++ b/Task/Zebra-puzzle/Pluto/zebra-puzzle.pluto @@ -0,0 +1,84 @@ +local fmt = require "fmt" +require "perm" + +local colors = {"Red", "Green", "White", "Yellow", "Blue"} +local nations = {"English", "Swede", "Danish", "Norwegian", "German"} +local animals = {"Dog", "Birds", "Cats", "Horse", "Zebra"} +local drinks = {"Tea", "Coffee", "Milk", "Beer", "Water"} +local smokes = {"Pall Mall", "Dunhill", "Blend", "Blue Master", "Prince"} + +local p = perm.list({1, 2, 3, 4, 5}) + +local function check(a1, a2, v1, v2) + for i = 1, 5 do + if p[a1][i] == v1 then return p[a2][i] == v2 end + end + return false +end + +local function check_left(a1, a2, v1, v2) + for i = 1, 4 do + if p[a1][i] == v1 then return p[a2][i + 1] == v2 end + end + return false +end + +local function check_right(a1, a2, v1, v2) + for i = 2, 5 do + if p[a1][i] == v1 then return p[a2][i - 1] == v2 end + end + return false +end + +local function check_adjacent(a1, a2, v1, v2) + return check_left(a1, a2, v1, v2) or check_right(a1, a2, v1, v2) +end + +local function print_houses(c, n, a, d, s) + local owner = "" + print("House Color Nation Animal Drink Smokes") + print("===== ====== ========= ====== ====== ===========") + for i = 1, 5 do + local f = "%3d %-6s %-9s %-6s %-6s %-11s" + local l = {i, colors[p[c][i]], nations[p[n][i]], animals[p[a][i]], drinks[p[d][i]], smokes[p[s][i]]} + fmt.print(f, l:unpack()) + if animals[p[a][i]] == "Zebra" then owner = nations[p[n][i]] end + end + print($"\nThe {owner} owns the Zebra\n") +end + +local function fill_houses() + local solutions = 0 + for c = 1, 120 do + if !check_left(c, c, 2, 3) then continue end -- C5 : Green left of white + for n = 1, 120 do + if p[n][1] != 4 then continue end -- C10: Norwegian in First + if !check(n, c, 1, 1) then continue end -- C2 : English in Red + if !check_adjacent(n, c, 4, 5) then continue end -- C15: Norwegian next to Blue + for a = 1, 120 do + if !check(a, n, 1, 2) then continue end -- C3 : Swede has Dog + for d = 1, 120 do + if p[d][3] != 3 then continue end -- C9 : Middle drinks Milk + if !check(d, n, 1, 3) then continue end -- C4 : Dane drinks Tea + if !check(d, c, 2, 2) then continue end -- C6 : Green drinks Coffee + for s = 1, 120 do + if !check(s, a, 1, 2) then continue end -- C7 : Pall Mall has Birds + if !check(s, c, 2, 4) then continue end -- C8 : Yellow smokes Dunhill + if !check(s, d, 4, 4) then continue end -- C13: Blue Master drinks Beer + if !check(s, n, 5, 5) then continue end -- C14: German smokes Prince + if !check_adjacent(s, a, 3, 3) then continue end -- C11: Blend next to Cats + if !check_adjacent(s, a, 2, 4) then continue end -- C12: Dunhill next to Horse + if !check_adjacent(s, d, 3, 5) then continue end -- C16: Blend next to Water + ++solutions + print_houses(c, n, a, d, s) + end + end + end + end + end + return solutions +end + +local solutions = fill_houses() +local plural = fmt.plural(solutions, "solution") +print($"{solutions} {plural} found") diff --git a/Task/Zero-to-the-zero-power/DuckDB/zero-to-the-zero-power.duckdb b/Task/Zero-to-the-zero-power/DuckDB/zero-to-the-zero-power.duckdb new file mode 100644 index 0000000000..f34db3edec --- /dev/null +++ b/Task/Zero-to-the-zero-power/DuckDB/zero-to-the-zero-power.duckdb @@ -0,0 +1 @@ + select power(0,0); diff --git a/Task/Zero-to-the-zero-power/Pluto/zero-to-the-zero-power.pluto b/Task/Zero-to-the-zero-power/Pluto/zero-to-the-zero-power.pluto new file mode 100644 index 0000000000..8b74d2a2b2 --- /dev/null +++ b/Task/Zero-to-the-zero-power/Pluto/zero-to-the-zero-power.pluto @@ -0,0 +1 @@ +print(0^0) diff --git a/Task/Zero-to-the-zero-power/Prolog/zero-to-the-zero-power.pro b/Task/Zero-to-the-zero-power/Prolog/zero-to-the-zero-power.pro new file mode 100644 index 0000000000..ed03ed5312 --- /dev/null +++ b/Task/Zero-to-the-zero-power/Prolog/zero-to-the-zero-power.pro @@ -0,0 +1 @@ +:- X is 0 ^ 0. diff --git a/Task/Zig-zag-matrix/DuckDB/zig-zag-matrix.duckdb b/Task/Zig-zag-matrix/DuckDB/zig-zag-matrix.duckdb new file mode 100644 index 0000000000..f14d59b037 --- /dev/null +++ b/Task/Zig-zag-matrix/DuckDB/zig-zag-matrix.duckdb @@ -0,0 +1,40 @@ +create or replace function zigzag_matrix(n) as table ( + with recursive cte as ( + select 1 as ix, 1 as i, 1 as j, 0 as ij + union all + select ix+1 as ix, + if( (i + j) % 2 = 0, + -- Even stripes + if( i < n, i + 1, i), + -- Odd stripes + if( j < n, i - (i > 1)::INT, i + 1) ) as i, + if( (i + j) % 2 == 0, + -- Even stripes + if( i < n, j - (j > 1)::INT, j + 1) , + -- Odd stripes + if( j < n, j+1, j)) as j, + ij + 1 as ij + from cte + where ix < n*n + ) + select i, j, ij as value + from cte +); + +# The i-th row as a list +create or replace function ijTable2Row(A, m) as ( + select array_agg(value order by j) + from query_table(A) + where i = m +); + +# Pretty-print the mxn matrix stored as an ij-table named A +create or replace function ijTable_pp(A,m,n) as table ( + select ijTable2Row(A,i) as row + from range(1, m+1) t(i) + order by i +); + +# Create the zig-zag matrix as a table and pretty-print it +with zz as (from zigzag_matrix(5)) +from ijTable_pp('zz', 5,5); diff --git a/Task/Zig-zag-matrix/YAMLScript/zig-zag-matrix.ys b/Task/Zig-zag-matrix/YAMLScript/zig-zag-matrix.ys new file mode 100644 index 0000000000..f1828e2882 --- /dev/null +++ b/Task/Zig-zag-matrix/YAMLScript/zig-zag-matrix.ys @@ -0,0 +1,34 @@ +!YS-v0 + +defn main(n=10): + gprint: + zig-zag: n + +defn gprint(grid): + f =: (" %$(grid.$.$.digits().#)d" * grid.#) + each line grid: + say: format(f line*) + +defn zig-zag(n): + take-from n: + map \(_1 _2) cycle([reverse a]): + partitions _ range(n:sqr): + concat (1 .. n): (n.-- .. -1) + +defn take-from(n colls): + lazy-seq: + when-let s seq(colls): + first-n rest-n =: split-at(n s) + cons map(first first-n): + take-from n: + concat _ rest-n: + filter seq: + map rest: first-n + +defn partitions(sizes coll): + lazy-seq: + when-let n sizes.0: + when-let s seq(coll): + cons take(n coll): + partitions next(sizes): + drop n: coll