From 5c1bb7bfa99af77e44d05de93f7158345d732a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Sat, 13 Jul 2024 15:19:22 -0700 Subject: [PATCH] Data update --- Lang/8080-Assembly/Square-but-not-cube | 1 + Lang/AArch64-Assembly/Pi | 1 + Lang/ABC/Look-and-say-sequence | 1 + Lang/ABC/Population-count | 1 + Lang/ABC/Square-but-not-cube | 1 + Lang/ALGOL-68/00-LANG.txt | 31 +- Lang/ALGOL-68/Draw-a-cuboid | 1 + Lang/ALGOL-68/Perlin-noise | 1 + Lang/ALGOL-68/Sleeping-Beauty-problem | 1 + Lang/ALGOL-68/Sorting-Algorithms-Circle-Sort | 1 + Lang/ALGOL-W/Eulers-constant-0.5772... | 1 + .../Find-the-intersection-of-two-lines | 1 + ...Pseudo-random-numbers-Middle-square-method | 1 + Lang/ANSI-BASIC/Damm-algorithm | 1 + Lang/ANSI-BASIC/Formatted-numeric-output | 1 + Lang/ANSI-BASIC/Function-definition | 1 + Lang/ANSI-BASIC/Monty-Hall-problem | 1 + Lang/ANSI-BASIC/Random-numbers | 1 + Lang/ANSI-BASIC/Real-constants-and-functions | 1 + Lang/ANSI-BASIC/Sorting-algorithms-Quicksort | 1 + Lang/APL/Display-a-linear-combination | 1 + Lang/APL/Pisano-period | 1 + Lang/APL/Word-ladder | 1 + Lang/ARM-Assembly/Pi | 1 + Lang/Ada/00-LANG.txt | 4 +- Lang/Ada/Abelian-sandpile-model | 1 + Lang/Ada/Achilles-numbers | 1 + .../Arithmetic-geometric-mean-Calculate-Pi | 1 + Lang/Ada/Ascending-primes | 1 + Lang/Ada/Brace-expansion | 1 + Lang/Ada/Color-wheel | 1 + Lang/Ada/Combinations-and-permutations | 1 + Lang/Ada/Eulers-constant-0.5772... | 1 + Lang/Ada/FTP | 1 + Lang/Ada/Hex-words | 1 + ...he-characters-that-can-be-used-for-symbols | 1 + .../Largest-number-divisible-by-its-digits | 1 + Lang/Ada/Magic-constant | 1 + Lang/Ada/Mind-boggling-card-trick | 1 + Lang/Ada/Musical-scale | 1 + Lang/Ada/Next-highest-int-from-digits | 1 + Lang/Ada/Penneys-game | 1 + Lang/Ada/Permutations-by-swapping | 1 + Lang/Ada/Play-recorded-sounds | 1 + Lang/Ada/Poker-hand-analyser | 1 + Lang/Ada/Record-sound | 1 + ...e-instances-of-a-character-within-a-string | 1 + Lang/Ada/Sierpinski-square-curve | 1 + Lang/Ada/Sorting-algorithms-Permutation-sort | 1 + Lang/Ada/UPC | 1 + Lang/Ada/War-card-game | 1 + Lang/Ada/Weird-numbers | 1 + Lang/Ada/Word-ladder | 1 + Lang/Ada/Word-search | 1 + Lang/Ada/Word-wheel | 1 + Lang/AmigaBASIC/00-LANG.txt | 2 + .../Display-a-linear-combination | 1 + Lang/Applesoft-BASIC/Repeat | 1 + Lang/Asymptote/Jensens-Device | 1 + Lang/Asymptote/Towers-of-Hanoi | 1 + Lang/AutoHotKey-V2/00-LANG.txt | 1 - Lang/AutoHotKey-V2/00-META.yaml | 2 - Lang/AutoHotKey-V2/Hello-world-Graphical | 1 - Lang/Autohotkey-V2/00-LANG.txt | 16 + Lang/Autohotkey-V2/00-META.yaml | 2 + Lang/Autohotkey-V2/Hello-world-Graphical | 1 + Lang/BASIC/00-LANG.txt | 32 +- Lang/BASIC/Damm-algorithm | 1 - Lang/BASIC/Function-definition | 1 - Lang/BASIC/Gray-code | 1 - Lang/BASIC/Monty-Hall-problem | 1 - Lang/BASIC/Ordered-words | 1 + Lang/BASIC/Sorting-algorithms-Quicksort | 1 - Lang/BASIC256/Kronecker-product | 1 + Lang/BASIC256/Multiple-regression | 1 + Lang/BASIC256/Nested-templated-data | 1 + .../Ramer-Douglas-Peucker-line-simplification | 1 + Lang/BASIC256/Sexy-primes | 1 + Lang/Bruijn/Harmonic-series | 1 + Lang/Bruijn/Towers-of-Hanoi | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/C++/Bitcoin-address-validation | 1 + Lang/C++/Bitcoin-public-point-to-address | 1 + Lang/C++/Catmull-Clark-subdivision-surface | 1 + Lang/C++/Compiler-virtual-machine-interpreter | 1 + ...bers-indexing-permutations-of-a-collection | 1 + .../Im-a-software-engineer-get-me-out-of-here | 1 + Lang/C++/P-Adic-square-roots | 1 + Lang/C++/Simple-database | 1 + Lang/C++/Sort-an-outline-at-every-level | 1 + Lang/C-sharp/Additive-primes | 1 + Lang/C-sharp/Cyclops-numbers | 1 + Lang/C-sharp/Summarize-primes | 1 + Lang/C-sharp/Tau-function | 1 + Lang/C-sharp/Tau-number | 1 + Lang/C-sharp/Tree-from-nesting-levels | 1 + Lang/C-sharp/Ultra-useful-primes | 1 + Lang/C-sharp/Variable-declaration-reset | 1 + Lang/C-sharp/Yellowstone-sequence | 1 + Lang/C/Hunt-the-Wumpus | 1 + Lang/C/Pig-the-dice-game-Player | 1 + Lang/COBOL/Nim-game | 1 + Lang/COBOL/Parametric-polymorphism | 1 + Lang/Chapel/Function-definition | 1 + Lang/Chapel/Maze-generation | 1 + Lang/Chapel/Repeat | 1 + .../Display-a-linear-combination | 1 + .../Fibonacci-n-step-number-sequences | 1 + Lang/Chipmunk-Basic/Jensens-Device | 1 + Lang/Chipmunk-Basic/Multiple-regression | 1 + Lang/Chipmunk-Basic/Nested-templated-data | 1 + Lang/Chipmunk-Basic/Price-fraction | 1 + Lang/Chipmunk-Basic/Proper-divisors | 1 + Lang/Chipmunk-Basic/Rate-counter | 1 + Lang/Chipmunk-Basic/Vector | 1 + Lang/Commodore-BASIC/N-queens-problem | 1 + Lang/Common-Lisp/Blum-integer | 1 + Lang/Common-Lisp/Factorial-primes | 1 + Lang/Cowgol/Display-a-linear-combination | 1 + Lang/Dart/15-puzzle-solver | 1 + Lang/Dart/Jensens-Device | 1 + Lang/Dart/Solve-a-Numbrix-puzzle | 1 + Lang/Draco/Display-a-linear-combination | 1 + Lang/EMal/Babbage-problem | 1 + Lang/EMal/Bifid-cipher | 1 + Lang/EMal/Mutual-recursion | 1 + Lang/EMal/Sorting-algorithms-Bogosort | 1 + Lang/EMal/Tree-traversal | 1 + Lang/EMal/User-input-Text | 1 + Lang/EasyLang/00-LANG.txt | 6 +- Lang/EasyLang/Abelian-sandpile-model | 1 + Lang/EasyLang/Abelian-sandpile-model-Identity | 1 + Lang/EasyLang/Approximate-equality | 1 + Lang/EasyLang/Arithmetic-Complex | 1 + Lang/EasyLang/Greatest-subsequential-sum | 1 + .../Guess-the-number-With-feedback-player- | 1 + Lang/EasyLang/Halt-and-catch-fire | 1 + Lang/EasyLang/Hamming-numbers | 1 + .../Hofstadter-Figure-Figure-sequences | 1 + Lang/EasyLang/IBAN | 1 + Lang/EasyLang/Iterated-digits-squaring | 1 + Lang/EasyLang/JortSort | 1 + Lang/EasyLang/Kronecker-product | 1 + .../EasyLang/Kronecker-product-based-fractals | 1 + .../Largest-int-from-concatenated-ints | 1 + Lang/EasyLang/Last-letter-first-letter | 1 + Lang/EasyLang/Longest-increasing-subsequence | 1 + Lang/EasyLang/Ludic-numbers | 1 + Lang/EasyLang/Map-range | 1 + Lang/EasyLang/Move-to-front-algorithm | 1 + Lang/EasyLang/Multisplit | 1 + Lang/EasyLang/Negative-base-numbers | 1 + Lang/EasyLang/Non-continuous-subsequences | 1 + Lang/EasyLang/Non-decimal-radices-Input | 1 + Lang/EasyLang/Number-reversal-game | 1 + .../Partition-an-integer-x-into-n-primes | 1 + Lang/EasyLang/Pascal-matrix-generation | 1 + .../Pathological-floating-point-problems | 1 + Lang/EasyLang/Peripheral-drift-illusion | 1 + .../Permutations-Rank-of-a-permutation | 1 + Lang/EasyLang/Phrase-reversals | 1 + Lang/EasyLang/Pierpont-primes | 1 + Lang/EasyLang/Pinstripe-Display | 1 + Lang/EasyLang/Plasma-effect | 1 + Lang/EasyLang/Pythagorean-quadruples | 1 + Lang/EasyLang/Range-expansion | 1 + Lang/EasyLang/Rock-paper-scissors | 1 + Lang/EasyLang/Ruth-Aaron-numbers | 1 + .../Sailors-coconuts-and-a-monkey-problem | 1 + Lang/EasyLang/Scope-Function-names-and-labels | 1 + ...e-instances-of-a-character-within-a-string | 1 + Lang/EasyLang/Self-numbers | 1 + Lang/EasyLang/Show-the-epoch | 1 + Lang/EasyLang/Sierpinski-triangle | 1 + .../Sort-a-list-of-object-identifiers | 1 + Lang/EasyLang/Sort-an-integer-array | 1 + Lang/EasyLang/Sort-numbers-lexicographically | 1 + Lang/EasyLang/Sorting-Algorithms-Circle-Sort | 1 + .../EasyLang/Sorting-algorithms-Cocktail-sort | 1 + Lang/EasyLang/Sorting-algorithms-Comb-sort | 1 + Lang/EasyLang/Sorting-algorithms-Pancake-sort | 1 + .../Sorting-algorithms-Permutation-sort | 1 + Lang/EasyLang/Sorting-algorithms-Shell-sort | 1 + Lang/EasyLang/Sorting-algorithms-Strand-sort | 1 + Lang/EasyLang/Stair-climbing-puzzle | 1 + Lang/EasyLang/Stem-and-leaf-plot | 1 + Lang/EasyLang/Taxicab-numbers | 1 + Lang/EasyLang/Tokenize-a-string-with-escaping | 1 + Lang/EasyLang/Top-rank-per-group | 1 + .../Verify-distribution-uniformity-Naive | 1 + Lang/EasyLang/Zig-zag-matrix | 1 + Lang/Ecstasy/00-LANG.txt | 5 +- Lang/Ecstasy/100-prisoners | 1 + Lang/Ecstasy/Assertions | 1 + Lang/Ecstasy/Pointers-and-references | 1 + Lang/Ecstasy/Program-name | 1 + Lang/Ecstasy/Reflection-List-methods | 1 + Lang/Ecstasy/Reflection-List-properties | 1 + Lang/Ecstasy/Search-a-list | 1 + Lang/Ecstasy/Send-an-unknown-method-call | 1 + Lang/Ecstasy/Singleton | 1 + Lang/Ecstasy/String-case | 1 + Lang/Ecstasy/String-comparison | 1 + Lang/Ecstasy/String-concatenation | 1 + Lang/Ecstasy/String-length | 1 + Lang/Ecstasy/Substring | 1 + Lang/Ecstasy/Substring-Top-and-tail | 1 + Lang/Ecstasy/System-time | 1 + Lang/Elixir/Parallel-brute-force | 1 + Lang/Elm/Caesar-cipher | 1 + Lang/Emacs-Lisp/Abbreviations-automatic | 1 + Lang/Emacs-Lisp/Anagrams | 1 + Lang/Emacs-Lisp/Compare-length-of-two-strings | 1 + Lang/Emacs-Lisp/Date-manipulation | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/Emacs-Lisp/Determine-sentence-type | 1 + Lang/Emacs-Lisp/Ordered-words | 1 + Lang/Emacs-Lisp/Snake | 1 + Lang/Emacs-Lisp/Substitution-cipher | 1 + Lang/Fortran/Sleeping-Beauty-problem | 1 + Lang/Free-Pascal-Lazarus/Bin-given-limits | 1 + .../Closures-Value-capture | 1 + .../Free-Pascal-Lazarus/Parallel-calculations | 1 + Lang/FreeBASIC/B-zier-curves-Intersections | 1 + Lang/FreeBASIC/Constrained-genericity | 1 + Lang/FreeBASIC/Execute-Computer-Zero | 1 + Lang/FreeBASIC/Execute-SNUSP | 1 + Lang/FreeBASIC/Execute-a-Markov-algorithm | 1 + Lang/FreeBASIC/Imaginary-base-numbers | 1 + Lang/FreeBASIC/Nested-templated-data | 1 + Lang/FreeBASIC/Padovan-sequence | 1 + Lang/FreeBASIC/Pseudo-random-numbers-PCG32 | 1 + .../Pseudo-random-numbers-Splitmix64 | 1 + .../Pseudo-random-numbers-Xorshift-star | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/FreeBASIC/Solve-the-no-connection-puzzle | 1 + Lang/FreeBASIC/Write-to-Windows-event-log | 1 + Lang/Frink/24-game | 1 + Lang/FutureBasic/24-game | 1 + Lang/FutureBasic/ASCII-art-diagram-converter | 1 + .../Arbitrary-precision-integers-included- | 1 + Lang/FutureBasic/Biorhythms | 1 + Lang/FutureBasic/Brilliant-numbers | 1 + .../Check-output-device-is-a-terminal | 1 + Lang/FutureBasic/Combinations | 1 + Lang/FutureBasic/Copy-stdin-to-stdout | 1 + Lang/FutureBasic/Determine-sentence-type | 1 + Lang/FutureBasic/Floyds-triangle | 1 + Lang/FutureBasic/Function-prototype | 1 + Lang/FutureBasic/Go-Fish | 1 + Lang/FutureBasic/Honeycombs | 1 + Lang/FutureBasic/Monty-Hall-problem | 1 + Lang/FutureBasic/Record-sound | 1 + Lang/GW-BASIC/Damm-algorithm | 1 + Lang/GW-BASIC/Display-a-linear-combination | 1 + Lang/GW-BASIC/Gray-code | 1 + Lang/GW-BASIC/Jensens-Device | 1 + Lang/GW-BASIC/Nested-templated-data | 1 + Lang/GW-BASIC/Primality-by-trial-division | 1 + Lang/GW-BASIC/Vector | 1 + Lang/Gambas/Jensens-Device | 1 + Lang/Gambas/M-bius-function | 1 + Lang/Gambas/Proper-divisors | 1 + Lang/Go/Factorial-primes | 1 + Lang/Java/Arena-storage-pool | 1 + Lang/Java/Bitcoin-public-point-to-address | 1 + Lang/Java/Catmull-Clark-subdivision-surface | 1 + .../Java/Compiler-virtual-machine-interpreter | 1 + .../Im-a-software-engineer-get-me-out-of-here | 1 + Lang/Java/P-Adic-square-roots | 1 + Lang/Java/Topic-variable | 1 + Lang/Jq/00-LANG.txt | 5 + Lang/Jq/2048 | 1 + Lang/Jq/24-game | 1 + Lang/Jq/Averages-Simple-moving-average | 1 + Lang/Jq/Bitwise-operations | 1 + Lang/Jq/CRC-32 | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + Lang/Jq/Deconvolution-1D | 1 + Lang/Jq/Display-an-outline-as-a-nested-table | 1 + Lang/Jq/Draw-a-cuboid | 1 + Lang/Jq/Entropy-Narcissist | 1 + Lang/Jq/Factors-of-a-Mersenne-number | 1 + Lang/Jq/File-size-distribution | 1 + ...Find-Chess960-starting-position-identifier | 1 + Lang/Jq/Find-duplicate-files | 1 + Lang/Jq/French-Republican-calendar | 1 + Lang/Jq/Generate-random-chess-position | 1 + Lang/Jq/Giuga-numbers | 1 + Lang/Jq/Graph-colouring | 1 + Lang/Jq/Introspection | 1 + Lang/Jq/Knights-tour | 1 + Lang/Jq/Levenshtein-distance-Alignment | 1 + Lang/Jq/Mayan-calendar | 1 + Lang/Jq/Mind-boggling-card-trick | 1 + Lang/Jq/Minimal-steps-down-to-1 | 1 + Lang/Jq/Modified-random-distribution | 1 + Lang/Jq/Multiplicative-order | 1 + Lang/Jq/Nonoblock | 1 + Lang/Jq/Nonogram-solver | 1 + Lang/Jq/P-value-correction | 1 + Lang/Jq/Palindromic-gapful-numbers | 1 + Lang/Jq/Peaceful-chess-queen-armies | 1 + Lang/Jq/Pentomino-tiling | 1 + Lang/Jq/Perlin-noise | 1 + Lang/Jq/Pisano-period | 1 + Lang/Jq/Poker-hand-analyser | 1 + Lang/Jq/Polynomial-regression | 1 + ...bers-Combined-recursive-generator-MRG32k3a | 1 + Lang/Jq/Pseudo-random-numbers-PCG32 | 1 + Lang/Jq/Pseudo-random-numbers-Xorshift-star | 1 + .../Ramer-Douglas-Peucker-line-simplification | 1 + Lang/Jq/Random-sentence-from-book | 1 + ...tta-Code-Rank-languages-by-number-of-users | 1 + Lang/Jq/Set-puzzle | 1 + Lang/Jq/Set-right-adjacent-bits | 1 + Lang/Jq/Sierpinski-pentagon | 1 + Lang/Jq/Sleeping-Beauty-problem | 1 + Lang/Jq/Solve-a-Hidato-puzzle | 1 + Lang/Jq/Solve-a-Holy-Knights-tour | 1 + Lang/Jq/Solve-a-Numbrix-puzzle | 1 + Lang/Jq/Sort-an-outline-at-every-level | 1 + Lang/Jq/Thieles-interpolation-formula | 1 + Lang/Jq/Tic-tac-toe | 1 + Lang/Jq/War-card-game | 1 + Lang/Jq/Wordiff | 1 + Lang/K/Find-common-directory-path | 1 + Lang/K/Monty-Hall-problem | 1 + Lang/Kotlin/00-LANG.txt | 2 +- Lang/Kotlin/Compare-length-of-two-strings | 1 + Lang/Kotlin/Factorial-primes | 1 + Lang/Langur/00-LANG.txt | 4 +- Lang/Langur/Babbage-problem | 1 + Lang/Langur/I-before-E-except-after-C | 1 + Lang/Langur/Safe-addition | 1 + Lang/Langur/String-interpolation-included- | 1 + Lang/Liberty-BASIC/Poker-hand-analyser | 1 + Lang/Lilypond/00-LANG.txt | 10 +- Lang/Locomotive-Basic/00-LANG.txt | 12 +- Lang/Locomotive-Basic/Abelian-sandpile-model | 1 + Lang/Locomotive-Basic/Draw-a-cuboid | 1 + Lang/MACRO-11/Square-but-not-cube | 1 + Lang/Mia/Loops-While | 1 + Lang/Minimal-BASIC/Jensens-Device | 1 + Lang/Minimal-BASIC/Monty-Hall-problem | 1 + Lang/Modula-2/Gray-code | 1 + Lang/Modula-2/Monty-Hall-problem | 1 + Lang/Modula-3/Additive-primes | 1 + Lang/Nascom-BASIC/Damm-algorithm | 1 + Lang/Oberon/100-doors | 1 - Lang/Odin/Quine | 1 + Lang/PHP/Water-collected-between-towers | 1 + Lang/PL-M/Draw-a-cuboid | 1 + Lang/PL-M/Nested-function | 1 + Lang/POV-Ray/Bitmap | 1 + Lang/POV-Ray/Maze-generation | 1 + Lang/Pascal/Count-the-coins | 1 + Lang/PascalABC.NET/00-LANG.txt | 2 +- Lang/PascalABC.NET/15-puzzle-game | 1 + Lang/PascalABC.NET/99-bottles-of-beer | 1 + Lang/PascalABC.NET/A+B | 1 + Lang/PascalABC.NET/Abstract-type | 1 + Lang/PascalABC.NET/Accumulator-factory | 1 + Lang/PascalABC.NET/Ackermann-function | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/PascalABC.NET/Address-of-a-variable | 1 + Lang/PascalABC.NET/Anagrams | 1 + Lang/PascalABC.NET/Anonymous-recursion | 1 + .../Apply-a-callback-to-an-array | 1 + Lang/PascalABC.NET/Arithmetic-Complex | 1 + Lang/PascalABC.NET/Arithmetic-Integer | 1 + Lang/PascalABC.NET/Array-concatenation | 1 + Lang/PascalABC.NET/Arrays | 1 + Lang/PascalABC.NET/Assertions | 1 + Lang/PascalABC.NET/Associative-array-Creation | 1 + .../PascalABC.NET/Associative-array-Iteration | 1 + Lang/PascalABC.NET/Balanced-brackets | 1 + Lang/PascalABC.NET/Binary-digits | 1 + Lang/PascalABC.NET/Binary-search | 1 + Lang/PascalABC.NET/Bitwise-operations | 1 + Lang/PascalABC.NET/Break-OO-privacy | 1 + Lang/PascalABC.NET/CSV-data-manipulation | 1 + Lang/PascalABC.NET/Calculating-the-value-of-e | 1 + Lang/PascalABC.NET/Call-an-object-method | 1 + Lang/PascalABC.NET/Character-codes | 1 + Lang/PascalABC.NET/Classes | 1 + Lang/PascalABC.NET/Closest-pair-problem | 1 + Lang/PascalABC.NET/Collections | 1 + Lang/PascalABC.NET/Command-line-arguments | 1 + Lang/PascalABC.NET/Comments | 1 + Lang/PascalABC.NET/Compare-a-list-of-strings | 1 + .../Compare-length-of-two-strings | 1 + Lang/PascalABC.NET/Compound-data-type | 1 + Lang/PascalABC.NET/Concurrent-computing | 1 + Lang/PascalABC.NET/Conditional-structures | 1 + Lang/PascalABC.NET/Constrained-genericity | 1 + Lang/PascalABC.NET/Copy-a-string | 1 + Lang/PascalABC.NET/Copy-stdin-to-stdout | 1 + Lang/PascalABC.NET/Count-in-factors | 1 + Lang/PascalABC.NET/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/PascalABC.NET/Date-format | 1 + Lang/PascalABC.NET/Day-of-the-week | 1 + .../Define-a-primitive-data-type | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/PascalABC.NET/Determine-sentence-type | 1 + .../Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + .../Doubly-linked-list-Traversal | 1 + Lang/PascalABC.NET/Dragon-curve | 1 + Lang/PascalABC.NET/Draw-a-pixel | 1 + Lang/PascalABC.NET/Draw-a-rotating-cube | 1 + Lang/PascalABC.NET/Empty-program | 1 + Lang/PascalABC.NET/Enumerations | 1 + Lang/PascalABC.NET/Even-or-odd | 1 + Lang/PascalABC.NET/Exceptions | 1 + .../Extreme-floating-point-values | 1 + Lang/PascalABC.NET/Factorial | 1 + Lang/PascalABC.NET/Factors-of-an-integer | 1 + Lang/PascalABC.NET/File-input-output | 1 + Lang/PascalABC.NET/File-size | 1 + Lang/PascalABC.NET/Filter | 1 + Lang/PascalABC.NET/Find-common-directory-path | 1 + Lang/PascalABC.NET/Find-limit-of-recursion | 1 + Lang/PascalABC.NET/First-class-functions | 1 + Lang/PascalABC.NET/FizzBuzz | 1 + Lang/PascalABC.NET/Flatten-a-list | 1 + Lang/PascalABC.NET/Floyds-triangle | 1 + Lang/PascalABC.NET/Formatted-numeric-output | 1 + Lang/PascalABC.NET/Function-definition | 1 + Lang/PascalABC.NET/General-FizzBuzz | 1 + .../Generate-lower-case-ASCII-alphabet | 1 + Lang/PascalABC.NET/Generic-swap | 1 + Lang/PascalABC.NET/Greatest-common-divisor | 1 + Lang/PascalABC.NET/Guess-the-number | 1 + Lang/PascalABC.NET/Hash-from-two-arrays | 1 + Lang/PascalABC.NET/Hello-world-Line-printer | 1 + .../Hello-world-Newline-omission | 1 + Lang/PascalABC.NET/Hello-world-Standard-error | 1 + Lang/PascalABC.NET/Identity-matrix | 1 + Lang/PascalABC.NET/Include-a-file | 1 + Lang/PascalABC.NET/Infinity | 1 + Lang/PascalABC.NET/Inheritance-Multiple | 1 + Lang/PascalABC.NET/Inheritance-Single | 1 + Lang/PascalABC.NET/Input-loop | 1 + Lang/PascalABC.NET/Integer-comparison | 1 + Lang/PascalABC.NET/JSON | 1 + Lang/PascalABC.NET/Jump-anywhere | 1 + Lang/PascalABC.NET/Knuth-shuffle | 1 + Lang/PascalABC.NET/Least-common-multiple | 1 + Lang/PascalABC.NET/List-comprehensions | 1 + Lang/PascalABC.NET/Literals-Floating-point | 1 + Lang/PascalABC.NET/Literals-String | 1 + Lang/PascalABC.NET/Longest-common-subsequence | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + Lang/PascalABC.NET/Loops-Break | 1 + Lang/PascalABC.NET/Loops-Continue | 1 + Lang/PascalABC.NET/Loops-Do-while | 1 + Lang/PascalABC.NET/Loops-Downward-for | 1 + Lang/PascalABC.NET/Loops-For | 1 + .../Loops-For-with-a-specified-step | 1 + Lang/PascalABC.NET/Loops-Foreach | 1 + ...oops-Increment-loop-index-within-loop-body | 1 + Lang/PascalABC.NET/Loops-N-plus-one-half | 1 + Lang/PascalABC.NET/Loops-Nested | 1 + Lang/PascalABC.NET/Loops-While | 1 + Lang/PascalABC.NET/Loops-With-multiple-ranges | 1 + Lang/PascalABC.NET/Loops-Wrong-ranges | 1 + Lang/PascalABC.NET/Man-or-boy-test | 1 + Lang/PascalABC.NET/Memory-allocation | 1 + Lang/PascalABC.NET/Mouse-position | 1 + Lang/PascalABC.NET/Nested-function | 1 + Lang/PascalABC.NET/Nth | 1 + Lang/PascalABC.NET/Null-object | 1 + Lang/PascalABC.NET/Object-serialization | 1 + Lang/PascalABC.NET/Palindrome-detection | 1 + Lang/PascalABC.NET/Parametric-polymorphism | 1 + Lang/PascalABC.NET/Pick-random-element | 1 + Lang/PascalABC.NET/Pointers-and-references | 1 + Lang/PascalABC.NET/Polymorphic-copy | 1 + Lang/PascalABC.NET/Polymorphism | 1 + Lang/PascalABC.NET/Power-set | 1 + .../PascalABC.NET/Primality-by-trial-division | 1 + Lang/PascalABC.NET/Prime-decomposition | 1 + Lang/PascalABC.NET/Program-name | 1 + Lang/PascalABC.NET/Program-termination | 1 + Lang/PascalABC.NET/Queue-Definition | 1 + Lang/PascalABC.NET/Queue-Usage | 1 + Lang/PascalABC.NET/Quine | 1 + Lang/PascalABC.NET/Quoting-constructs | 1 + Lang/PascalABC.NET/Radical-of-an-integer | 1 + .../Read-a-file-character-by-character-UTF8 | 1 + Lang/PascalABC.NET/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/PascalABC.NET/Read-entire-file | 1 + .../Real-constants-and-functions | 1 + Lang/PascalABC.NET/Reflection-List-methods | 1 + Lang/PascalABC.NET/Reflection-List-properties | 1 + Lang/PascalABC.NET/Regular-expressions | 1 + Lang/PascalABC.NET/Remove-duplicate-elements | 1 + Lang/PascalABC.NET/Remove-lines-from-a-file | 1 + Lang/PascalABC.NET/Rename-a-file | 1 + Lang/PascalABC.NET/Repeat | 1 + Lang/PascalABC.NET/Repeat-a-string | 1 + Lang/PascalABC.NET/Return-multiple-values | 1 + Lang/PascalABC.NET/Reverse-a-string | 1 + Lang/PascalABC.NET/Reverse-words-in-a-string | 1 + Lang/PascalABC.NET/Roman-numerals-Decode | 1 + Lang/PascalABC.NET/Roman-numerals-Encode | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/PascalABC.NET/Rot-13 | 1 + Lang/PascalABC.NET/Scope-modifiers | 1 + .../PascalABC.NET/Send-an-unknown-method-call | 1 + .../Sequence-of-primes-by-trial-division | 1 + Lang/PascalABC.NET/Sieve-of-Eratosthenes | 1 + .../PascalABC.NET/Simple-windowed-application | 1 + .../Singly-linked-list-Element-definition | 1 + .../Singly-linked-list-Element-insertion | 1 + Lang/PascalABC.NET/Sleep | 1 + .../Sort-an-array-of-composite-structures | 1 + Lang/PascalABC.NET/Sort-an-integer-array | 1 + Lang/PascalABC.NET/Sort-three-variables | 1 + .../Sort-using-a-custom-comparator | 1 + .../Sorting-algorithms-Quicksort | 1 + Lang/PascalABC.NET/Special-variables | 1 + Lang/PascalABC.NET/Stack | 1 + Lang/PascalABC.NET/Stack-traces | 1 + Lang/PascalABC.NET/String-append | 1 + Lang/PascalABC.NET/String-case | 1 + Lang/PascalABC.NET/String-concatenation | 1 + .../String-interpolation-included- | 1 + Lang/PascalABC.NET/String-length | 1 + Lang/PascalABC.NET/String-matching | 1 + Lang/PascalABC.NET/String-prepend | 1 + .../Strip-a-set-of-characters-from-a-string | 1 + Lang/PascalABC.NET/Strip-block-comments | 1 + .../Strip-comments-from-a-string | 1 + ...odes-and-extended-characters-from-a-string | 1 + ...trip-whitespace-from-a-string-Top-and-tail | 1 + Lang/PascalABC.NET/Substitution-cipher | 1 + Lang/PascalABC.NET/Substring | 1 + Lang/PascalABC.NET/Substring-Top-and-tail | 1 + Lang/PascalABC.NET/Sudan-function | 1 + .../PascalABC.NET/Sum-and-product-of-an-array | 1 + Lang/PascalABC.NET/Sum-digits-of-an-integer | 1 + Lang/PascalABC.NET/Sum-multiples-of-3-and-5 | 1 + Lang/PascalABC.NET/Sum-of-a-series | 1 + ...-of-elements-below-main-diagonal-of-matrix | 1 + Lang/PascalABC.NET/Sum-of-squares | 1 + Lang/PascalABC.NET/Symmetric-difference | 1 + Lang/PascalABC.NET/System-time | 1 + .../Take-notes-on-the-command-line | 1 + Lang/PascalABC.NET/Tau-function | 1 + Lang/PascalABC.NET/Tau-number | 1 + Lang/PascalABC.NET/Temperature-conversion | 1 + .../Terminal-control-Clear-the-screen | 1 + .../Terminal-control-Coloured-text | 1 + .../Terminal-control-Cursor-movement | 1 + .../Terminal-control-Cursor-positioning | 1 + .../PascalABC.NET/Terminal-control-Dimensions | 1 + ...inal-control-Display-an-extended-character | 1 + .../Terminal-control-Hiding-the-cursor | 1 + ...Terminal-control-Ringing-the-terminal-bell | 1 + Lang/PascalABC.NET/Test-a-function | 1 + Lang/PascalABC.NET/Time-a-function | 1 + Lang/PascalABC.NET/Tokenize-a-string | 1 + Lang/PascalABC.NET/Top-rank-per-group | 1 + Lang/PascalABC.NET/Towers-of-Hanoi | 1 + .../PascalABC.NET/Trabb-Pardo-Knuth-algorithm | 1 + ...rate-English-text-using-the-Greek-alphabet | 1 + Lang/PascalABC.NET/Tree-datastructures | 1 + Lang/PascalABC.NET/Tree-traversal | 1 + Lang/PascalABC.NET/Trigonometric-functions | 1 + Lang/PascalABC.NET/Truncate-a-file | 1 + Lang/PascalABC.NET/Twos-complement | 1 + Lang/PascalABC.NET/URL-decoding | 1 + Lang/PascalABC.NET/URL-encoding | 1 + Lang/PascalABC.NET/Undefined-values | 1 + Lang/PascalABC.NET/Unicode-strings | 1 + Lang/PascalABC.NET/Unicode-variable-names | 1 + Lang/PascalABC.NET/User-input-Text | 1 + Lang/PascalABC.NET/Variables | 1 + Lang/PascalABC.NET/Variadic-function | 1 + Lang/PascalABC.NET/Vector | 1 + Lang/PascalABC.NET/Vector-products | 1 + .../Walk-a-directory-Non-recursively | 1 + .../Walk-a-directory-Recursively | 1 + Lang/PascalABC.NET/Window-creation | 1 + Lang/PascalABC.NET/Word-frequency | 1 + Lang/PascalABC.NET/Word-wrap | 1 + Lang/PascalABC.NET/Write-entire-file | 1 + Lang/PascalABC.NET/Write-to-Windows-event-log | 1 + Lang/PascalABC.NET/XML-DOM-serialization | 1 + Lang/PascalABC.NET/XML-Input | 1 + Lang/PascalABC.NET/XML-Output | 1 + Lang/PascalABC.NET/Zero-to-the-zero-power | 1 + Lang/Perl/Search-in-paragraphs-text | 1 + Lang/Prog8/Quine | 1 + Lang/PureBasic/M-bius-function | 1 + Lang/Python/Rhonda-numbers | 1 + Lang/QB64/Fibonacci-n-step-number-sequences | 1 + Lang/QB64/Multiple-regression | 1 + Lang/QB64/Price-fraction | 1 + Lang/QBasic/Display-a-linear-combination | 1 + Lang/QBasic/Fibonacci-n-step-number-sequences | 1 + Lang/QBasic/Jensens-Device | 1 + Lang/QBasic/Nested-templated-data | 1 + .../Ramer-Douglas-Peucker-line-simplification | 1 + Lang/QBasic/Vector | 1 + Lang/Quackery/00-LANG.txt | 2 +- .../Dinesmans-multiple-dwelling-problem | 1 + ...stribution-of-0-digits-in-factorial-series | 1 + Lang/Quackery/Dutch-national-flag-problem | 1 + Lang/Quackery/Flipping-bits-game | 1 + ...m-multiple-of-m-where-digital-sum-equals-m | 1 + Lang/Quackery/Password-generator | 1 + Lang/Quackery/Solve-the-no-connection-puzzle | 1 + Lang/QuickBASIC/Function-definition | 1 + Lang/QuickBASIC/Monty-Hall-problem | 1 + Lang/QuickBASIC/Random-numbers | 1 + Lang/QuickBASIC/Sorting-algorithms-Quicksort | 1 + Lang/R/Arithmetic-derivative | 1 + Lang/R/Compare-length-of-two-strings | 1 + Lang/R/Conjugate-transpose | 1 + Lang/R/Golden-ratio-Convergence | 1 + Lang/REXX/00-LANG.txt | 8 +- Lang/REXX/Eulers-constant-0.5772... | 1 + Lang/Red/00-LANG.txt | 3 + Lang/Refal/Copy-stdin-to-stdout | 1 + Lang/Refal/Damm-algorithm | 1 + Lang/Refal/Determine-sentence-type | 1 + Lang/Refal/Disarium-numbers | 1 + Lang/Refal/Discordian-date | 1 + Lang/Refal/Factors-of-an-integer | 1 + Lang/Refal/Flatten-a-list | 1 + Lang/Refal/General-FizzBuzz | 1 + Lang/Refal/Letter-frequency | 1 + Lang/Refal/McNuggets-problem | 1 + Lang/Refal/Nested-templated-data | 1 + Lang/Refal/One-dimensional-cellular-automata | 1 + Lang/Refal/Palindrome-detection | 1 + Lang/Refal/Population-count | 1 + Lang/Refal/Repeat | 1 + ...racter-string-based-on-change-of-character | 1 + Lang/Refal/Square-but-not-cube | 1 + Lang/Refal/Word-ladder | 1 + Lang/Rockstar/00-LANG.txt | 6 +- Lang/Run-BASIC/Nested-templated-data | 1 + Lang/S-BASIC/Copy-a-string | 1 + Lang/S-BASIC/Factorial | 1 + Lang/S-BASIC/Loops-Break | 1 + Lang/SETL/Brilliant-numbers | 1 + Lang/SETL/Damm-algorithm | 1 + Lang/SETL/General-FizzBuzz | 1 + Lang/SETL/Levenshtein-distance | 1 + Lang/SETL/Luhn-test-of-credit-card-numbers | 1 + Lang/SETL/Monty-Hall-problem | 1 + Lang/SETL/Nested-templated-data | 1 + Lang/SETL/Ordered-words | 1 + Lang/SETL/Pisano-period | 1 + Lang/SETL/Show-ASCII-table | 1 + ...racter-string-based-on-change-of-character | 1 + Lang/SETL/Word-ladder | 1 + Lang/Sed/00-LANG.txt | 2 + ...ing-gaps-between-consecutive-Niven-numbers | 1 + Lang/Sidef/Jaro-Winkler-distance | 1 + ...rs-whose-neighboring-pairs-are-tetraprimes | 1 + Lang/Sidef/Smarandache-Wellin-primes | 1 + Lang/Sidef/Wagstaff-primes | 1 + .../Call-a-foreign-language-function | 1 + Lang/Standard-ML/Pi | 1 + Lang/SuperCollider/00-LANG.txt | 128 +++- Lang/SuperCollider/Semordnilap | 1 - Lang/Swift/Compare-length-of-two-strings | 1 + Lang/Swift/Pseudo-random-numbers-Splitmix64 | 1 + Lang/Transd/Compare-length-of-two-strings | 1 - Lang/True-BASIC/100-prisoners | 1 + Lang/True-BASIC/Multiple-regression | 1 + Lang/True-BASIC/Vector | 1 + Lang/TypeScript/Deal-cards-for-FreeCell | 1 + Lang/UNIX-Shell/Pi | 1 + Lang/UNIX-Shell/Trabb-Pardo-Knuth-algorithm | 1 + Lang/Uiua/00-LANG.txt | 16 +- Lang/Uiua/15-puzzle-solver | 1 + Lang/Uiua/ADFGVX-cipher | 1 + Lang/Uiua/ASCII-art-diagram-converter | 1 + Lang/Uiua/Abbreviations-automatic | 1 + Lang/Uiua/Abelian-sandpile-model | 1 + Lang/Uiua/Align-columns | 1 + Lang/Uiua/Anti-primes | 1 + Lang/Uiua/Arithmetic-geometric-mean | 1 + Lang/Uiua/Array-concatenation | 1 + Lang/Uiua/Array-length | 1 + Lang/Uiua/Ascending-primes | 1 + Lang/Uiua/Averages-Mean-time-of-day | 1 + Lang/Uiua/Barnsley-fern | 1 + Lang/Uiua/Benfords-law | 1 + Lang/Uiua/Bifid-cipher | 1 + Lang/Uiua/Binary-digits | 1 + Lang/Uiua/Bulls-and-cows-Player | 1 + Lang/Uiua/CSV-data-manipulation | 1 + Lang/Uiua/Calkin-Wilf-sequence | 1 + .../Cartesian-product-of-two-or-more-lists | 1 + Lang/Uiua/Combinations | 1 + .../Uiua/Convert-seconds-to-compound-duration | 1 + Lang/Uiua/Conways-Game-of-Life | 1 + .../Uiua/Determine-if-a-string-is-collapsible | 1 + Lang/Uiua/Dutch-national-flag-problem | 1 + Lang/Uiua/Factorial | 1 + Lang/Uiua/Factors-of-an-integer | 1 + Lang/Uiua/Find-the-missing-permutation | 1 + Lang/Uiua/Flatten-a-list | 1 + Lang/Uiua/Flipping-bits-game | 1 + Lang/Uiua/Forest-fire | 1 + Lang/Uiua/Greatest-common-divisor | 1 + Lang/Uiua/Identity-matrix | 1 + Lang/Uiua/Increment-a-numerical-string | 1 + Lang/Uiua/Integer-sequence | 1 + Lang/Uiua/Langtons-ant | 1 + Lang/Uiua/Largest-int-from-concatenated-ints | 1 + Lang/Uiua/Least-common-multiple | 1 + Lang/Uiua/Levenshtein-distance | 1 + Lang/Uiua/List-comprehensions | 1 + Lang/Uiua/Look-and-say-sequence | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + Lang/Uiua/Luhn-test-of-credit-card-numbers | 1 + Lang/Uiua/Mandelbrot-set | 1 + Lang/Uiua/Matrix-multiplication | 1 + Lang/Uiua/Maze-solving | 1 + Lang/Uiua/McNuggets-problem | 1 + Lang/Uiua/Middle-three-digits | 1 + Lang/Uiua/Motzkin-numbers | 1 + Lang/Uiua/N-queens-problem | 1 + ...-which-are-not-the-sum-of-distinct-squares | 1 + Lang/Uiua/One-dimensional-cellular-automata | 1 + Lang/Uiua/Ordered-words | 1 + Lang/Uiua/Permutations | 1 + Lang/Uiua/Pick-random-element | 1 + Lang/Uiua/RPG-attributes-generator | 1 + Lang/Uiua/Random-numbers | 1 + Lang/Uiua/Run-length-encoding | 1 + Lang/Uiua/Smith-numbers | 1 + Lang/Uiua/Solve-a-Hidato-puzzle | 1 + Lang/Uiua/Solve-a-Numbrix-puzzle | 1 + Lang/Uiua/Sort-disjoint-sublist | 1 + ...racter-string-based-on-change-of-character | 1 + Lang/Uiua/Square-free-integers | 1 + Lang/Uiua/Stem-and-leaf-plot | 1 + Lang/Uiua/String-case | 1 + Lang/Uiua/String-concatenation | 1 + Lang/Uiua/String-interpolation-included- | 1 + Lang/Uiua/String-matching | 1 + .../Strip-a-set-of-characters-from-a-string | 1 + Lang/Uiua/Sudoku | 1 + Lang/Uiua/Sum-multiples-of-3-and-5 | 1 + Lang/Uiua/Summarize-primes | 1 + Lang/Uiua/Test-a-function | 1 + Lang/Uiua/Truncatable-primes | 1 + ...rnational-Securities-Identification-Number | 1 + Lang/Uiua/Water-collected-between-towers | 1 + Lang/Uiua/Yellowstone-sequence | 1 + Lang/Uiua/Zebra-puzzle | 1 + Lang/Uxntal/Quine | 1 + Lang/Uxntal/Weird-numbers | 1 + Lang/Vim-Script/Hello-world-Graphical | 1 + Lang/Vim-Script/Here-document | 1 + .../Loop-over-multiple-arrays-simultaneously | 1 + Lang/Vim-Script/Loops-For | 1 + Lang/Vim-Script/XML-Input | 1 + Lang/Wren/00-LANG.txt | 2 +- Lang/XBasic/Euler-method | 1 + Lang/XBasic/M-bius-function | 1 + Lang/XBasic/Nim-game | 1 + Lang/XBasic/Sorting-algorithms-Quicksort | 1 + Lang/XPL0/Draw-a-clock | 1 + Lang/XPL0/Poker-hand-analyser | 1 + Lang/YAMLScript/00-LANG.txt | 3 +- Lang/Yabasic/Display-a-linear-combination | 1 + Lang/Yabasic/Kronecker-product | 1 + Lang/Yabasic/Multiple-regression | 1 + Lang/Yabasic/Nested-templated-data | 1 + Lang/Yabasic/Sexy-primes | 1 + Lang/Yabasic/Sorting-algorithms-Counting-sort | 1 + Lang/Yabasic/Sorting-algorithms-Stooge-sort | 1 + Lang/Zig/15-puzzle-game | 1 + Lang/Zig/9-billion-names-of-God-the-integer | 1 + Lang/Zig/A+B | 1 + Lang/Zig/Determine-if-a-string-is-numeric | 1 + Lang/Zig/Egyptian-division | 1 + Lang/Zig/Integer-sequence | 1 + Lang/Zig/Monty-Hall-problem | 1 + Lang/Zig/Solve-the-no-connection-puzzle | 1 + Task/100-doors/APL/100-doors-2.apl | 4 +- Task/100-doors/APL/100-doors-3.apl | 1 + Task/100-doors/Langur/100-doors-1.langur | 10 +- Task/100-doors/Langur/100-doors-2.langur | 2 +- Task/100-doors/Langur/100-doors-3.langur | 2 +- Task/100-doors/Oberon/100-doors.oberon | 27 - Task/100-doors/V-(Vlang)/100-doors-2.v | 9 +- Task/100-doors/V-(Vlang)/100-doors-3.v | 5 + .../Ecstasy/100-prisoners.ecstasy | 49 ++ .../True-BASIC/100-prisoners.basic | 40 ++ .../PascalABC.NET/15-puzzle-game.pas | 178 ++++++ Task/15-puzzle-game/Zig/15-puzzle-game.zig | 91 +++ .../Dart/15-puzzle-solver.dart | 78 +++ .../Uiua/15-puzzle-solver.uiua | 47 ++ Task/2048/Jq/2048.jq | 127 ++++ Task/2048/Wren/2048.wren | 7 - Task/24-game/Frink/24-game.frink | 15 + Task/24-game/FutureBasic/24-game.basic | 310 ++++++++++ Task/24-game/Jq/24-game.jq | 90 +++ ...zzle.v => 4-rings-or-4-squares-puzzle-1.v} | 0 .../V-(Vlang)/4-rings-or-4-squares-puzzle-2.v | 38 ++ .../Zig/4-rings-or-4-squares-puzzle-6.zig | 50 ++ .../9-billion-names-of-god-the-integer-1.zig | 63 ++ .../9-billion-names-of-god-the-integer-2.zig | 35 ++ .../8th/99-bottles-of-beer-1.8th | 26 + .../8th/99-bottles-of-beer-2.8th | 12 + .../8th/99-bottles-of-beer.8th | 20 - ...s-of-beer.oxy => 99-bottles-of-beer-1.oxy} | 0 .../Oxygene/99-bottles-of-beer-2.oxy | 21 + .../PascalABC.NET/99-bottles-of-beer-1.pas | 10 + .../PascalABC.NET/99-bottles-of-beer-2.pas | 10 + Task/A+B/PascalABC.NET/a+b.pas | 3 + Task/A+B/Zig/a+b.zig | 25 + Task/ADFGVX-cipher/Uiua/adfgvx-cipher.uiua | 11 + .../ascii-art-diagram-converter.basic | 93 +++ .../Uiua/ascii-art-diagram-converter.uiua | 26 + .../Emacs-Lisp/abbreviations-automatic.l | 36 ++ .../Uiua/abbreviations-automatic.uiua | 17 + .../abelian-sandpile-model-identity.easy | 60 ++ .../Ada/abelian-sandpile-model.ada | 67 +++ .../EasyLang/abelian-sandpile-model.easy | 35 ++ .../abelian-sandpile-model.basic | 27 + .../Uiua/abelian-sandpile-model.uiua | 10 + Task/Abstract-type/11l/abstract-type.11l | 4 +- .../PascalABC.NET/abstract-type-1.pas | 20 + .../PascalABC.NET/abstract-type-2.pas | 22 + .../PascalABC.NET/accumulator-factory.pas | 12 + .../Achilles-numbers/Ada/achilles-numbers.ada | 205 +++++++ .../PascalABC.NET/ackermann-function.pas | 16 + ...ariable-to-a-class-instance-at-runtime.cpp | 34 ++ ...ariable-to-a-class-instance-at-runtime.pas | 19 + .../ALGOL-68/additive-primes.alg | 3 +- .../C-sharp/additive-primes.cs | 86 +++ .../Langur/additive-primes.langur | 22 +- .../Modula-3/additive-primes.mod3 | 44 ++ .../PascalABC.NET/address-of-a-variable.pas | 6 + Task/Align-columns/Uiua/align-columns.uiua | 17 + .../00-TASK.txt | 3 + Task/Amb/Langur/amb.langur | 12 +- Task/Anagrams/Emacs-Lisp/anagrams-1.l | 87 +++ Task/Anagrams/Emacs-Lisp/anagrams-2.l | 74 +++ Task/Anagrams/PascalABC.NET/anagrams.pas | 7 + .../PascalABC.NET/anonymous-recursion-1.pas | 13 + .../PascalABC.NET/anonymous-recursion-2.pas | 13 + Task/Anti-primes/Langur/anti-primes.langur | 22 +- Task/Anti-primes/Uiua/anti-primes.uiua | 8 + .../apply-a-callback-to-an-array.langur | 2 +- .../apply-a-callback-to-an-array.pas | 5 + .../EasyLang/approximate-equality.easy | 20 + ...bitrary-precision-integers-included-.basic | 64 ++ ...itrary-precision-integers-included-.langur | 10 +- .../Java/arena-storage-pool.java | 19 + .../EasyLang/arithmetic-complex.easy | 19 + .../PascalABC.NET/arithmetic-complex.pas | 14 + .../EMal/arithmetic-integer.emal | 1 - .../PascalABC.NET/arithmetic-integer.pas | 10 + .../R/arithmetic-derivative.r | 31 + ...arithmetic-geometric-mean-calculate-pi.ada | 34 ++ .../Uiua/arithmetic-geometric-mean.uiua | 3 + .../Langur/array-concatenation.langur | 8 +- .../PascalABC.NET/array-concatenation.pas | 5 + .../Uiua/array-concatenation.uiua | 1 + .../{array-length.pas => array-length-1.pas} | 0 .../PascalABC.NET/array-length-2.pas | 4 + Task/Array-length/Uiua/array-length.uiua | 1 + Task/Arrays/Ada/arrays.ada | 11 +- Task/Arrays/Langur/arrays.langur | 28 +- Task/Arrays/PascalABC.NET/arrays.pas | 19 + .../Ascending-primes/Ada/ascending-primes.ada | 62 ++ .../Uiua/ascending-primes.uiua | 2 + Task/Assertions/Ecstasy/assertions.ecstasy | 6 + Task/Assertions/PascalABC.NET/assertions.pas | 5 + .../Langur/associative-array-creation.langur | 14 +- .../associative-array-creation.pas | 7 + .../associative-array-iteration.pas | 11 + .../Langur/averages-arithmetic-mean.langur | 4 +- .../Uiua/averages-mean-time-of-day.uiua | 24 + .../Jq/averages-simple-moving-average.jq | 30 + .../b-zier-curves-intersections-1.basic | 162 +++++ .../b-zier-curves-intersections-2.basic | 215 +++++++ .../Babbage-problem/EMal/babbage-problem.emal | 9 + .../Langur/babbage-problem.langur | 6 + .../PascalABC.NET/balanced-brackets.pas | 29 + Task/Barnsley-fern/Uiua/barnsley-fern.uiua | 11 + Task/Benfords-law/Uiua/benfords-law.uiua | 4 + Task/Bifid-cipher/EMal/bifid-cipher.emal | 82 +++ Task/Bifid-cipher/Uiua/bifid-cipher-1.uiua | 9 + Task/Bifid-cipher/Uiua/bifid-cipher-2.uiua | 9 + .../Free-Pascal-Lazarus/bin-given-limits.pas | 56 ++ .../PascalABC.NET/binary-digits.pas | 4 + Task/Binary-digits/Uiua/binary-digits.uiua | 2 + .../Binary-search/Chapel/binary-search.chapel | 10 +- .../PascalABC.NET/binary-search.pas | 61 ++ Task/Biorhythms/FutureBasic/biorhythms.basic | 110 ++++ .../C++/bitcoin-address-validation.cpp | 88 +++ ...java => bitcoin-address-validation-1.java} | 0 .../Java/bitcoin-address-validation-2.java | 71 +++ .../C++/bitcoin-public-point-to-address.cpp | 103 ++++ .../Java/bitcoin-public-point-to-address.java | 99 ++++ .../Rust/bitcoin-public-point-to-address.rust | 2 +- .../11l/bitmap-b-zier-curves-cubic.11l | 11 +- .../11l/bitmap-bresenhams-line-algorithm.11l | 11 +- .../11l/bitmap-midpoint-circle-algorithm.11l | 11 +- .../11l/bitmap-read-a-ppm-file.11l | 11 +- .../11l/bitmap-write-a-ppm-file.11l | 11 +- .../Ada/bitmap-write-a-ppm-file.ada | 3 + Task/Bitmap/11l/bitmap.11l | 11 +- Task/Bitmap/POV-Ray/bitmap.povray | 74 +++ .../Jq/bitwise-operations.jq | 32 + .../PascalABC.NET/bitwise-operations.pas | 9 + .../Common-Lisp/blum-integer.lisp | 47 ++ .../Langur/box-the-compass.langur | 10 +- Task/Brace-expansion/Ada/brace-expansion.ada | 58 ++ .../PascalABC.NET/break-oo-privacy.pas | 15 + .../FutureBasic/brilliant-numbers.basic | 70 +++ .../SETL/brilliant-numbers.setl | 65 ++ .../Ada/bulls-and-cows-player.ada | 2 +- .../Uiua/bulls-and-cows-player.uiua | 18 + Task/CRC-32/Jq/crc-32-1.jq | 2 + Task/CRC-32/Jq/crc-32-2.jq | 34 ++ .../PascalABC.NET/csv-data-manipulation.pas | 9 + .../Uiua/csv-data-manipulation.uiua | 11 + Task/CUSIP/Langur/cusip-1.langur | 26 +- Task/CUSIP/Langur/cusip-2.langur | 36 +- Task/Caesar-cipher/Elm/caesar-cipher.elm | 88 +++ .../Caesar-cipher/Langur/caesar-cipher.langur | 14 +- .../COBOL/calculating-the-value-of-e.cobol | 36 +- .../Langur/calculating-the-value-of-e.langur | 19 +- .../calculating-the-value-of-e.pas | 19 + .../Uiua/calkin-wilf-sequence.uiua | 28 + .../call-a-foreign-language-function.ml | 6 + .../Langur/call-a-function-1.langur | 3 +- .../Langur/call-a-function-2.langur | 3 +- .../Langur/call-a-function-3.langur | 3 +- .../Langur/call-a-function-4.langur | 5 +- .../Langur/call-a-function-5.langur | 4 +- .../Langur/call-a-function-6.langur | 8 +- .../Langur/call-a-function-7.langur | 4 - .../PascalABC.NET/call-an-object-method.pas | 16 + ...tesian-product-of-two-or-more-lists.langur | 16 +- ...artesian-product-of-two-or-more-lists.uiua | 9 + .../Langur/catalan-numbers.langur | 10 +- .../C++/catmull-clark-subdivision-surface.cpp | 261 ++++++++ .../catmull-clark-subdivision-surface.java | 257 ++++++++ .../Langur/character-codes.langur | 20 +- .../PascalABC.NET/character-codes.pas | 6 + .../check-output-device-is-a-terminal.basic | 17 + .../Langur/check-that-file-exists.langur | 16 +- .../11l/cheryls-birthday-1.11l | 7 +- ...les-of-given-radius-through-two-points.11l | 9 +- Task/Classes/PascalABC.NET/classes.pas | 16 + .../PascalABC.NET/closest-pair-problem.pas | 24 + .../closures-value-capture.pas | 26 + ...capture.go => closures-value-capture-1.go} | 0 .../Go/closures-value-capture-2.go | 14 + .../Collections/PascalABC.NET/collections.pas | 25 + Task/Color-wheel/Ada/color-wheel.ada | 89 +++ .../Ada/combinations-and-permutations.ada | 69 +++ Task/Combinations/EasyLang/combinations.easy | 14 +- .../FutureBasic/combinations.basic | 16 + Task/Combinations/J/combinations-10.j | 1 + Task/Combinations/J/combinations-6.j | 8 +- Task/Combinations/J/combinations-7.j | 8 +- Task/Combinations/J/combinations-8.j | 1 + Task/Combinations/J/combinations-9.j | 1 + Task/Combinations/Uiua/combinations.uiua | 10 + .../PascalABC.NET/command-line-arguments.pas | 4 + Task/Comments/FutureBasic/comments.basic | 1 - Task/Comments/PascalABC.NET/comments.pas | 7 + .../compare-a-list-of-strings.pas | 12 + .../compare-length-of-two-strings.l | 7 + .../compare-length-of-two-strings.kotlin | 16 + .../compare-length-of-two-strings.pas | 10 + .../R/compare-length-of-two-strings.r | 13 + .../Swift/compare-length-of-two-strings.swift | 4 + .../compare-length-of-two-strings.transd | 11 - Task/Compiler-AST-interpreter/00-TASK.txt | 4 +- Task/Compiler-code-generator/00-TASK.txt | 262 +++++++- Task/Compiler-lexical-analyzer/00-TASK.txt | 2 - Task/Compiler-syntax-analyzer/00-TASK.txt | 4 +- .../00-TASK.txt | 10 +- .../compiler-virtual-machine-interpreter.cpp | 190 ++++++ .../compiler-virtual-machine-interpreter.java | 173 ++++++ .../PascalABC.NET/compound-data-type.pas | 16 + .../PascalABC.NET/concurrent-computing.pas | 8 + .../Langur/conditional-structures-1.langur | 8 +- .../Langur/conditional-structures-2.langur | 2 +- .../Langur/conditional-structures-3.langur | 2 +- .../Langur/conditional-structures-4.langur | 18 +- .../Langur/conditional-structures-5.langur | 2 +- .../Langur/conditional-structures-6.langur | 4 +- .../Langur/conditional-structures-7.langur | 4 +- .../PascalABC.NET/conditional-structures.pas | 28 + .../R/conjugate-transpose.r | 69 +++ .../FreeBASIC/constrained-genericity.basic | 63 ++ .../PascalABC.NET/constrained-genericity.pas | 23 + ...ithmetic-construct-from-rational-number.jq | 57 ++ .../convert-decimal-number-to-rational.11l | 9 +- ...onvert-seconds-to-compound-duration.langur | 22 +- .../convert-seconds-to-compound-duration.uiua | 9 + .../Chapel/conways-game-of-life.chapel | 128 ++-- .../Uiua/conways-game-of-life.uiua | 4 + .../PascalABC.NET/copy-a-string.pas | 4 + .../Copy-a-string/S-BASIC/copy-a-string.basic | 23 + .../C/copy-stdin-to-stdout.c | 6 +- .../FutureBasic/copy-stdin-to-stdout.basic | 13 + ...tdout.java => copy-stdin-to-stdout-1.java} | 0 .../Java/copy-stdin-to-stdout-2.java | 5 + .../PascalABC.NET/copy-stdin-to-stdout.pas | 2 + .../Refal/copy-stdin-to-stdout.refal | 6 + .../PascalABC.NET/count-in-factors.pas | 25 + .../Langur/count-in-octal.langur | 6 +- .../PascalABC.NET/count-in-octal.pas | 3 + .../count-occurrences-of-a-substring.alg | 11 +- .../count-occurrences-of-a-substring.l | 23 +- .../count-occurrences-of-a-substring.langur | 4 +- .../count-occurrences-of-a-substring.pas | 6 + ...nt-the-coins.ada => count-the-coins-1.ada} | 0 .../Count-the-coins/Ada/count-the-coins-2.ada | 26 + .../Pascal/count-the-coins.pas | 24 + Task/Create-a-file/Seed7/create-a-file.seed7 | 4 +- ...ate-a-two-dimensional-array-at-runtime.pas | 8 + .../create-an-object-at-a-given-address.pas | 12 + .../C-sharp/cyclops-numbers.cs | 191 ++++++ .../ANSI-BASIC/damm-algorithm.basic | 28 + .../{BASIC => GW-BASIC}/damm-algorithm.basic | 0 .../Nascom-BASIC/damm-algorithm.basic | 23 + .../Damm-algorithm/Refal/damm-algorithm.refal | 38 ++ Task/Damm-algorithm/SETL/damm-algorithm.setl | 26 + Task/Date-format/Langur/date-format-1.langur | 7 +- Task/Date-format/Langur/date-format-2.langur | 5 +- Task/Date-format/Langur/date-format-3.langur | 2 - .../Date-format/PascalABC.NET/date-format.pas | 5 + .../Emacs-Lisp/date-manipulation-1.l | 40 ++ .../Emacs-Lisp/date-manipulation-2.l | 41 ++ .../Langur/date-manipulation.langur | 40 +- .../PascalABC.NET/day-of-the-week.pas | 5 + .../11l/de-bruijn-sequences.11l | 2 +- .../TypeScript/deal-cards-for-freecell.ts | 133 +++++ Task/Death-Star/11l/death-star.11l | 8 +- .../Langur/deceptive-numbers.langur | 20 +- Task/Deconvolution-1D/Jq/deconvolution-1d.jq | 22 + .../define-a-primitive-data-type.pas | 27 + .../Langur/detect-division-by-zero.langur | 8 +- .../determine-if-a-string-is-collapsible.uiua | 13 + .../determine-if-a-string-is-numeric-1.l | 12 + .../determine-if-a-string-is-numeric-2.l | 17 + .../determine-if-a-string-is-numeric.pas | 11 + ...> determine-if-a-string-is-numeric-1.rust} | 0 .../determine-if-a-string-is-numeric-2.rust | 34 ++ .../Zig/determine-if-a-string-is-numeric.zig | 32 + .../Emacs-Lisp/determine-sentence-type.l | 28 + .../FutureBasic/determine-sentence-type.basic | 16 + .../PascalABC.NET/determine-sentence-type.pas | 18 + .../Refal/determine-sentence-type.refal | 17 + .../11l/dijkstras-algorithm.11l | 10 +- ...nesmans-multiple-dwelling-problem.quackery | 38 ++ .../Refal/disarium-numbers.refal | 32 + .../Refal/discordian-date.refal | 62 ++ .../APL/display-a-linear-combination.apl | 11 + .../display-a-linear-combination.basic | 22 + .../display-a-linear-combination.basic | 38 ++ .../display-a-linear-combination.cowgol | 60 ++ .../Draco/display-a-linear-combination.draco | 44 ++ .../display-a-linear-combination.basic | 24 + .../QBasic/display-a-linear-combination.basic | 37 ++ .../display-a-linear-combination.basic | 38 ++ .../display-an-outline-as-a-nested-table.jq | 135 +++++ ...n-of-0-digits-in-factorial-series.quackery | 29 + .../doubly-linked-list-definition.pas | 75 +++ .../doubly-linked-list-element-definition.pas | 4 + .../doubly-linked-list-element-insertion.pas | 33 ++ .../doubly-linked-list-traversal.pas | 9 + .../PascalABC.NET/dragon-curve.pas | 34 ++ Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 | 48 ++ Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg | 58 ++ Task/Draw-a-cuboid/Jq/draw-a-cuboid.jq | 27 + .../Locomotive-Basic/draw-a-cuboid.basic | 6 + Task/Draw-a-cuboid/PL-M/draw-a-cuboid.plm | 81 +++ .../PascalABC.NET/draw-a-pixel.pas | 6 + .../PascalABC.NET/draw-a-rotating-cube.pas | 6 + ...w-a-sphere.basic => draw-a-sphere-1.basic} | 0 .../Locomotive-Basic/draw-a-sphere-2.basic | 32 + .../dutch-national-flag-problem.quackery | 16 + .../Uiua/dutch-national-flag-problem.uiua | 3 + Task/Eertree/11l/eertree.11l | 2 +- .../Zig/egyptian-division.zig | 52 ++ .../PascalABC.NET/empty-program.pas | 1 + .../Jq/entropy-narcissist.jq | 11 + .../PascalABC.NET/enumerations.pas | 6 + .../Langur/environment-variables-1.langur | 3 - ...-2.langur => environment-variables.langur} | 0 .../Esthetic-numbers/11l/esthetic-numbers.11l | 2 +- Task/Euler-method/XBasic/euler-method.basic | 43 ++ .../ALGOL-W/eulers-constant-0.5772....alg | 89 +++ .../Ada/eulers-constant-0.5772....ada | 47 ++ .../REXX/eulers-constant-0.5772....rexx | 272 +++++++++ .../Even-or-odd/PascalABC.NET/even-or-odd.pas | 14 + ...n-exception-thrown-in-a-nested-call.langur | 20 +- Task/Exceptions/Langur/exceptions-1.langur | 4 +- Task/Exceptions/Langur/exceptions-3.langur | 6 +- .../Exceptions/PascalABC.NET/exceptions-1.pas | 1 + .../Exceptions/PascalABC.NET/exceptions-2.pas | 1 + .../Exceptions/PascalABC.NET/exceptions-3.pas | 6 + .../FreeBASIC/execute-computer-zero.basic | 120 ++++ Task/Execute-HQ9+/11l/execute-hq9+.11l | 2 +- .../FreeBASIC/execute-snusp.basic | 77 +++ .../11l/execute-a-markov-algorithm.11l | 9 +- .../execute-a-markov-algorithm.basic | 139 +++++ .../Seed7/execute-a-system-command.seed7 | 2 +- .../Langur/extend-your-language-2.langur | 7 - ...e-1.langur => extend-your-language.langur} | 2 +- .../extreme-floating-point-values.pas | 14 + Task/FTP/Ada/ftp.ada | 57 ++ ...-indexing-permutations-of-a-collection.cpp | 138 +++++ ...indexing-permutations-of-a-collection.java | 2 +- .../Common-Lisp/factorial-primes.lisp | 27 + Task/Factorial-primes/Go/factorial-primes.go | 59 ++ .../Kotlin/factorial-primes.kotlin | 43 ++ Task/Factorial/Langur/factorial-1.langur | 4 +- Task/Factorial/Langur/factorial-2.langur | 4 +- Task/Factorial/Langur/factorial-3.langur | 12 +- Task/Factorial/Langur/factorial-4.langur | 4 +- Task/Factorial/PascalABC.NET/factorial.pas | 19 + Task/Factorial/S-BASIC/factorial-1.basic | 13 + Task/Factorial/S-BASIC/factorial-2.basic | 7 + Task/Factorial/Uiua/factorial.uiua | 1 + .../Jq/factors-of-a-mersenne-number.jq | 61 ++ .../PascalABC.NET/factors-of-an-integer.pas | 16 + .../Refal/factors-of-an-integer.refal | 13 + .../Uiua/factors-of-an-integer.uiua | 2 + .../Langur/farey-sequence.langur | 24 +- ...=> feigenbaum-constant-calculation-1.rexx} | 0 .../feigenbaum-constant-calculation-2.rexx | 63 ++ .../Langur/fermat-numbers.langur | 33 +- .../fibonacci-n-step-number-sequences.basic | 34 ++ .../fibonacci-n-step-number-sequences.qb64 | 37 ++ .../fibonacci-n-step-number-sequences.basic | 35 ++ .../Haskell/fibonacci-sequence-15.hs | 47 +- .../Haskell/fibonacci-sequence-16.hs | 67 ++- .../Haskell/fibonacci-sequence-17.hs | 37 +- .../Haskell/fibonacci-sequence-18.hs | 3 +- .../Haskell/fibonacci-sequence-19.hs | 2 +- .../Haskell/fibonacci-sequence-20.hs | 1 + .../Langur/fibonacci-sequence.langur | 4 +- .../PARI-GP/fibonacci-sequence-14.parigp | 2 +- .../PARI-GP/fibonacci-sequence-15.parigp | 2 +- .../PARI-GP/fibonacci-sequence-16.parigp | 8 +- .../PARI-GP/fibonacci-sequence-17.parigp | 10 +- .../PARI-GP/fibonacci-sequence-18.parigp | 8 +- .../PARI-GP/fibonacci-sequence-19.parigp | 1 + .../PL-0/fibonacci-sequence.pl0 | 2 +- .../FutureBasic/file-input-output.basic | 52 +- .../PascalABC.NET/file-input-output.pas | 4 + .../Jq/file-size-distribution.jq | 15 + Task/File-size/PascalABC.NET/file-size.pas | 6 + Task/Filter/Langur/filter.langur | 6 +- Task/Filter/PascalABC.NET/filter.pas | 5 + ...d-chess960-starting-position-identifier.jq | 82 +++ .../K/find-common-directory-path.k | 6 + .../find-common-directory-path.pas | 21 + .../Jq/find-duplicate-files.jq | 9 + .../find-if-a-point-is-within-a-triangle.11l | 9 +- .../PascalABC.NET/find-limit-of-recursion.pas | 9 + .../find-the-intersection-of-two-lines.alg | 33 ++ .../find-the-intersection-of-two-lines-4.py | 19 + .../Uiua/find-the-missing-permutation.uiua | 2 + .../PascalABC.NET/first-class-functions.pas | 15 + ...square-in-base-n-with-n-unique-digits.uiua | 27 +- Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp | 33 +- Task/FizzBuzz/Common-Lisp/fizzbuzz-9.lisp | 20 + Task/FizzBuzz/Langur/fizzbuzz-1.langur | 3 - Task/FizzBuzz/Langur/fizzbuzz-2.langur | 3 - Task/FizzBuzz/Langur/fizzbuzz.langur | 3 + Task/FizzBuzz/PascalABC.NET/fizzbuzz.pas | 10 + Task/FizzBuzz/Q/fizzbuzz-1.q | 2 +- Task/FizzBuzz/Q/fizzbuzz-2.q | 2 +- Task/FizzBuzz/Q/fizzbuzz-3.q | 27 +- Task/FizzBuzz/Uiua/fizzbuzz.uiua | 2 +- .../{flatten-a-list.l => flatten-a-list-1.l} | 0 .../Emacs-Lisp/flatten-a-list-2.l | 1 + .../PascalABC.NET/flatten-a-list.pas | 16 + .../Flatten-a-list/Refal/flatten-a-list.refal | 10 + Task/Flatten-a-list/Uiua/flatten-a-list.uiua | 1 + .../Quackery/flipping-bits-game.quackery | 60 ++ .../Uiua/flipping-bits-game.uiua | 19 + .../Ada/flow-control-structures-2.ada | 4 +- .../Ada/flow-control-structures-3.ada | 15 +- .../Ada/flow-control-structures-4.ada | 8 + .../Ada/flow-control-structures-5.ada | 7 + .../FutureBasic/floyds-triangle.basic | 18 + .../PascalABC.NET/floyds-triangle.pas | 19 + .../Floyds-triangle/Uiua/floyds-triangle.uiua | 26 +- Task/Forest-fire/Uiua/forest-fire.uiua | 9 + .../ANSI-BASIC/formatted-numeric-output.basic | 12 + .../formatted-numeric-output.pas | 4 + Task/Fractal-tree/11l/fractal-tree.11l | 2 +- .../Jq/french-republican-calendar.jq | 149 +++++ .../ANSI-BASIC/function-definition.basic | 13 + .../Chapel/function-definition-1.chapel | 4 + .../Chapel/function-definition-2.chapel | 4 + .../Langur/function-definition-1.langur | 3 +- .../Langur/function-definition-2.langur | 3 +- .../Langur/function-definition-3.langur | 3 +- .../Langur/function-definition-4.langur | 2 - .../Langur/function-definition-5.langur | 1 - .../PascalABC.NET/function-definition.pas | 1 + .../function-definition.basic | 0 .../FutureBasic/function-prototype.basic | 3 + .../Gamma-function/REXX/gamma-function-3.rexx | 517 ++++++++++++++++ .../PascalABC.NET/general-fizzbuzz.pas | 14 + .../Refal/general-fizzbuzz.refal | 54 ++ .../SETL/general-fizzbuzz.setl | 9 + .../generate-lower-case-ascii-alphabet.pas | 5 + .../Jq/generate-random-chess-position.jq | 94 +++ Task/Generic-swap/Langur/generic-swap.langur | 10 +- .../PascalABC.NET/generic-swap.pas | 10 + Task/Giuga-numbers/Jq/giuga-numbers.jq | 24 + Task/Go-Fish/FutureBasic/go-fish.basic | 559 ++++++++++++++++++ .../R/golden-ratio-convergence.r | 8 + Task/Graph-colouring/Jq/graph-colouring.jq | 100 ++++ Task/Gray-code/FreeBASIC/gray-code.basic | 8 - .../{BASIC => GW-BASIC}/gray-code.basic | 0 Task/Gray-code/Liberty-BASIC/gray-code.basic | 1 - Task/Gray-code/Modula-2/gray-code.mod2 | 57 ++ Task/Grayscale-image/11l/grayscale-image.11l | 11 +- .../PascalABC.NET/greatest-common-divisor.pas | 18 + .../greatest-common-divisor.uiua} | 0 .../EasyLang/greatest-subsequential-sum.easy | 23 + ...uess-the-number-with-feedback-player-.easy | 21 + .../Langur/guess-the-number.langur | 8 +- .../PascalABC.NET/guess-the-number.pas | 13 + .../EasyLang/halt-and-catch-fire.easy | 2 + .../EasyLang/hamming-numbers.easy | 27 + .../Bruijn/harmonic-series.bruijn | 16 + .../Langur/hash-from-two-arrays-1.langur | 2 +- .../Langur/hash-from-two-arrays-2.langur | 9 +- .../PascalABC.NET/hash-from-two-arrays.pas | 6 + .../hello-world-graphical.ahk | 0 .../Vim-Script/hello-world-graphical-1.vim | 1 + .../Vim-Script/hello-world-graphical-2.vim | 1 + .../hello-world-line-printer.pas | 12 + .../hello-world-newline-omission.pas | 2 + .../hello-world-standard-error.pas | 2 + ...-world-text.pas => hello-world-text-1.pas} | 0 .../PascalABC.NET/hello-world-text-2.pas | 4 + .../PascalABC.NET/hello-world-text-3.pas | 2 + .../Langur/here-document-1.langur | 2 +- .../Langur/here-document-2.langur | 2 +- .../Langur/here-document-3.langur | 2 +- .../Langur/here-document-4.langur | 2 +- .../Vim-Script/here-document-1.vim | 5 + .../Vim-Script/here-document-2.vim | 6 + Task/Hex-words/Ada/hex-words.ada | 149 +++++ .../hofstadter-figure-figure-sequences.easy | 47 ++ Task/Honeycombs/FutureBasic/honeycombs.basic | 115 ++++ Task/Huffman-coding/11l/huffman-coding.11l | 9 +- Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c | 129 ++++ .../Langur/i-before-e-except-after-c.langur | 24 + Task/IBAN/EasyLang/iban.easy | 63 ++ .../Langur/isbn13-check-digit.langur | 18 +- .../Standard-ML/isbn13-check-digit-1.ml | 22 + ...check-digit.ml => isbn13-check-digit-2.ml} | 2 +- .../Kotlin/identity-matrix.kotlin | 17 +- .../PascalABC.NET/identity-matrix.pas | 5 + .../Identity-matrix/Uiua/identity-matrix.uiua | 2 + ...haracters-that-can-be-used-for-symbols.ada | 12 + ...aracters-that-can-be-used-for-symbols.wren | 1 + ...a-software-engineer-get-me-out-of-here.cpp | 236 ++++++++ ...-software-engineer-get-me-out-of-here.java | 211 +++++++ .../FreeBASIC/imaginary-base-numbers.basic | 168 ++++++ .../PascalABC.NET/include-a-file-1.pas | 5 + .../PascalABC.NET/include-a-file-2.pas | 1 + ...ps-between-consecutive-niven-numbers.sidef | 12 + .../Uiua/increment-a-numerical-string.uiua | 2 + Task/Infinity/PascalABC.NET/infinity.pas | 2 + .../PascalABC.NET/inheritance-multiple.pas | 19 + .../PascalABC.NET/inheritance-single.pas | 6 + Task/Input-loop/PascalABC.NET/input-loop.pas | 6 + .../PascalABC.NET/integer-comparison.pas | 8 + .../Kotlin/integer-sequence.kotlin | 17 +- ...er-sequence.pas => integer-sequence-1.pas} | 0 .../PascalABC.NET/integer-sequence-2.pas | 1 + .../Uiua/integer-sequence.uiua | 1 + .../Integer-sequence/Zig/integer-sequence.zig | 9 + Task/Introspection/Jq/introspection.jq | 23 + Task/Inverted-index/Ada/inverted-index-7.ada | 4 +- .../EasyLang/iterated-digits-squaring.easy | 38 ++ Task/JSON/PascalABC.NET/json.pas | 20 + .../Sidef/jaro-winkler-distance.sidef | 26 + .../Asymptote/jensens-device.asymptote | 5 + .../BASIC256/jensens-device.basic | 6 +- .../Chipmunk-Basic/jensens-device.basic | 11 + Task/Jensens-Device/Dart/jensens-device.dart | 14 + .../GW-BASIC/jensens-device.basic | 11 + .../Gambas/jensens-device.gambas | 17 + .../Minimal-BASIC/jensens-device.basic | 12 + .../QBasic/jensens-device.basic | 12 + .../Yabasic/jensens-device.basic | 5 +- Task/JortSort/EasyLang/jortsort.easy | 16 + .../Josephus-problem/Ada/josephus-problem.ada | 16 +- .../PascalABC.NET/jump-anywhere.pas | 15 + Task/Knights-tour/Jq/knights-tour.jq | 50 ++ .../PascalABC.NET/knuth-shuffle.pas | 11 + Task/Kosaraju/11l/kosaraju.11l | 4 +- .../kronecker-product-based-fractals.easy | 38 ++ .../BASIC256/kronecker-product.basic | 42 ++ .../EasyLang/kronecker-product.easy | 15 + .../Yabasic/kronecker-product.basic | 42 ++ Task/Langtons-ant/Uiua/langtons-ant.uiua | 14 + .../largest-int-from-concatenated-ints.easy | 23 + .../largest-int-from-concatenated-ints.uiua | 2 + ...largest-number-divisible-by-its-digits.ada | 48 ++ ...gest-number-divisible-by-its-digits-1.cpp} | 0 ...rgest-number-divisible-by-its-digits-2.cpp | 44 ++ ...est-number-divisible-by-its-digits-1.java} | 0 ...gest-number-divisible-by-its-digits-2.java | 56 ++ .../EasyLang/last-letter-first-letter.easy | 43 ++ .../11l/latin-squares-in-reduced-form.11l | 4 +- .../PascalABC.NET/least-common-multiple.pas | 12 + .../Standard-ML/least-common-multiple-1.ml | 4 + ...multiple.ml => least-common-multiple-2.ml} | 0 .../Uiua/least-common-multiple.uiua | 4 + .../Emacs-Lisp/letter-frequency.l | 23 +- .../Langur/letter-frequency.langur | 10 +- .../Refal/letter-frequency.refal | 48 ++ .../Jq/levenshtein-distance-alignment.jq | 44 ++ .../JavaScript/levenshtein-distance-2.js | 162 ++--- .../SETL/levenshtein-distance.setl | 26 + .../Uiua/levenshtein-distance.uiua | 15 + .../PascalABC.NET/list-comprehensions.pas | 2 + .../Uiua/list-comprehensions.uiua | 3 + .../PascalABC.NET/literals-floating-point.pas | 3 + .../PascalABC.NET/literals-string.pas | 4 + .../Langur/logical-operations.langur | 46 +- .../EasyLang/longest-common-subsequence.easy | 2 +- .../longest-common-subsequence.pas | 30 + .../Langur/longest-common-substring.langur | 22 +- .../longest-increasing-subsequence.easy | 37 ++ .../ABC/look-and-say-sequence.abc | 19 + .../EasyLang/look-and-say-sequence.easy | 1 - .../Uiua/look-and-say-sequence.uiua | 2 + ...op-over-multiple-arrays-simultaneously.pas | 12 + ...p-over-multiple-arrays-simultaneously-5.py | 5 + ...p-over-multiple-arrays-simultaneously.uiua | 1 + ...op-over-multiple-arrays-simultaneously.vim | 6 + Task/Loops-Break/Langur/loops-break.langur | 6 +- .../Loops-Break/PascalABC.NET/loops-break.pas | 10 + Task/Loops-Break/S-BASIC/loops-break-1.basic | 13 + Task/Loops-Break/S-BASIC/loops-break-2.basic | 14 + .../Langur/loops-continue.langur | 6 +- .../PascalABC.NET/loops-continue.pas | 12 + .../PascalABC.NET/loops-do-while.pas | 7 + .../loops-do-while-2.basic | 6 - ...-do-while-1.basic => loops-do-while.basic} | 0 .../Langur/loops-downward-for-1.langur | 4 +- .../Langur/loops-downward-for-2.langur | 4 +- .../PascalABC.NET/loops-downward-for.pas | 3 + .../loops-for-with-a-specified-step.langur | 4 +- .../loops-for-with-a-specified-step.pas | 7 + Task/Loops-For/Langur/loops-for-1.langur | 4 +- Task/Loops-For/Langur/loops-for-2.langur | 4 +- Task/Loops-For/Langur/loops-for-3.langur | 4 +- Task/Loops-For/PascalABC.NET/loops-for.pas | 7 + Task/Loops-For/Vim-Script/loops-for-1.vim | 6 + Task/Loops-For/Vim-Script/loops-for-2.vim | 3 + .../Loops-Foreach/Langur/loops-foreach.langur | 18 +- .../PascalABC.NET/loops-foreach.pas | 3 + ...increment-loop-index-within-loop-body.easy | 7 +- ...-increment-loop-index-within-loop-body.pas | 17 + .../PascalABC.NET/loops-n-plus-one-half.pas | 3 + .../PascalABC.NET/loops-nested.pas | 16 + Task/Loops-While/Langur/loops-while.langur | 8 +- Task/Loops-While/Mia/loops-while.mia | 5 + .../Loops-While/PascalABC.NET/loops-while.pas | 7 + .../loops-with-multiple-ranges.pas | 20 + .../Langur/loops-wrong-ranges.langur | 21 +- .../PascalABC.NET/loops-wrong-ranges.pas | 15 + .../Langur/lucas-lehmer-test.langur | 21 +- .../Ludic-numbers/EasyLang/ludic-numbers.easy | 27 + .../luhn-test-of-credit-card-numbers.langur | 22 +- .../Lua/luhn-test-of-credit-card-numbers.lua | 49 +- .../luhn-test-of-credit-card-numbers.setl | 18 + .../luhn-test-of-credit-card-numbers.uiua | 6 + .../Gambas/m-bius-function.gambas | 27 + .../PureBasic/m-bius-function.basic | 30 + .../XBasic/m-bius-function.basic | 31 + .../Raku/md5-implementation.raku | 5 +- Task/Magic-constant/Ada/magic-constant.ada | 68 +++ .../Seed7/make-directory-path-1.seed7 | 7 - .../Seed7/make-directory-path-2.seed7 | 10 - .../Seed7/make-directory-path.seed7 | 21 + .../PascalABC.NET/man-or-boy-test.pas | 13 + Task/Mandelbrot-set/Dart/mandelbrot-set.dart | 44 +- Task/Mandelbrot-set/Uiua/mandelbrot-set.uiua | 9 + Task/Map-range/EasyLang/map-range.easy | 6 + .../EasyLang/matrix-multiplication.easy | 11 +- .../Uiua/matrix-multiplication.uiua | 8 + Task/Mayan-calendar/Jq/mayan-calendar.jq | 105 ++++ Task/Maze-generation/11l/maze-generation.11l | 2 +- .../Chapel/maze-generation.chapel | 56 ++ .../POV-Ray/maze-generation.povray | 181 ++++++ .../Maze-generation/Uiua/maze-generation.uiua | 44 +- Task/Maze-solving/Uiua/maze-solving.uiua | 26 + .../Refal/mcnuggets-problem.refal | 37 ++ .../Uiua/mcnuggets-problem.uiua | 4 + .../PascalABC.NET/memory-allocation.pas | 16 + Task/Menu/Langur/menu.langur | 24 +- .../Uiua/middle-three-digits.uiua | 9 + ...exx => miller-rabin-primality-test-1.rexx} | 0 .../REXX/miller-rabin-primality-test-2.rexx | 167 ++++++ .../Ada/mind-boggling-card-trick.ada | 100 ++++ .../Jq/mind-boggling-card-trick.jq | 105 ++++ .../Jq/minimal-steps-down-to-1.jq | 82 +++ ...e-of-m-where-digital-sum-equals-m.quackery | 14 + .../Jq/modified-random-distribution.jq | 50 ++ .../ANSI-BASIC/monty-hall-problem.basic | 41 ++ .../Euphoria/monty-hall-problem.euphoria | 4 +- .../FutureBasic/monty-hall-problem.basic | 60 ++ .../Monty-Hall-problem/K/monty-hall-problem.k | 3 + .../Liberty-BASIC/monty-hall-problem.basic | 1 - .../Minimal-BASIC/monty-hall-problem.basic | 47 ++ .../Modula-2/monty-hall-problem.mod2 | 58 ++ .../monty-hall-problem.basic | 0 .../Run-BASIC/monty-hall-problem.basic | 2 - .../SETL/monty-hall-problem.setl | 29 + .../True-BASIC/monty-hall-problem.basic | 22 +- .../XPL0/monty-hall-problem.xpl0 | 4 +- .../Zig/monty-hall-problem.zig | 29 + .../Motzkin-numbers/Uiua/motzkin-numbers.uiua | 12 + .../PascalABC.NET/mouse-position.pas | 7 + .../EasyLang/move-to-front-algorithm.easy | 39 ++ .../BASIC256/multiple-regression.basic | 70 +++ .../Chipmunk-Basic/multiple-regression.basic | 68 +++ .../QB64/multiple-regression.qb64 | 71 +++ .../True-BASIC/multiple-regression.basic | 80 +++ .../Yabasic/multiple-regression.basic | 77 +++ .../11l/multiplicative-order.11l | 7 +- .../Jq/multiplicative-order.jq | 181 ++++++ Task/Multisplit/EasyLang/multisplit.easy | 17 + .../Langur/munchausen-numbers.langur | 4 +- ...numbers.rust => munchausen-numbers-1.rust} | 0 .../Rust/munchausen-numbers-2.rust | 35 ++ Task/Musical-scale/Ada/musical-scale.ada | 74 +++ .../EMal/mutual-recursion.emal | 8 + Task/N-queens-problem/C/n-queens-problem-1.c | 96 ++- Task/N-queens-problem/C/n-queens-problem-2.c | 45 +- Task/N-queens-problem/C/n-queens-problem-3.c | 101 +--- Task/N-queens-problem/C/n-queens-problem-4.c | 138 +++-- Task/N-queens-problem/C/n-queens-problem-5.c | 69 +++ .../Commodore-BASIC/n-queens-problem.basic | 55 ++ .../Pascal/n-queens-problem-1.pas | 109 +--- .../Pascal/n-queens-problem-2.pas | 183 +++--- .../Pascal/n-queens-problem-3.pas | 112 ++++ .../Python/n-queens-problem-7.py | 30 +- .../Python/n-queens-problem-8.py | 38 +- .../Uiua/n-queens-problem.uiua | 4 + .../EasyLang/negative-base-numbers.easy | 32 + Task/Nested-function/PL-M/nested-function.plm | 74 +++ .../PascalABC.NET/nested-function.pas | 21 + .../BASIC256/nested-templated-data.basic | 31 + .../nested-templated-data.basic | 30 + .../FreeBASIC/nested-templated-data.basic | 26 + .../GW-BASIC/nested-templated-data.basic | 28 + .../QBasic/nested-templated-data.basic | 33 ++ .../Refal/nested-templated-data.refal | 17 + .../Run-BASIC/nested-templated-data.basic | 31 + .../SETL/nested-templated-data.setl | 21 + .../Yabasic/nested-templated-data.basic | 31 + Task/Next-highest-int-from-digits/00-TASK.txt | 9 +- .../Ada/next-highest-int-from-digits.ada | 125 ++++ .../Phix/next-highest-int-from-digits-1.phix | 38 +- .../Phix/next-highest-int-from-digits-2.phix | 52 +- Task/Nim-game/11l/nim-game.11l | 2 +- Task/Nim-game/COBOL/nim-game.cobol | 25 + Task/Nim-game/XBasic/nim-game.basic | 24 + .../EasyLang/non-continuous-subsequences.easy | 18 + .../EasyLang/non-decimal-radices-input.easy | 10 + Task/Nonoblock/Jq/nonoblock.jq | 23 + Task/Nonogram-solver/Jq/nonogram-solver.jq | 255 ++++++++ Task/Nth-root/Langur/nth-root.langur | 14 +- Task/Nth/PascalABC.NET/nth.pas | 9 + Task/Null-object/Chapel/null-object.chapel | 2 +- Task/Null-object/Langur/null-object.langur | 10 +- .../Null-object/PascalABC.NET/null-object.pas | 6 + .../EasyLang/number-reversal-game.easy | 36 ++ ...h-are-not-the-sum-of-distinct-squares.uiua | 7 + .../PascalABC.NET/object-serialization.pas | 32 + .../C/one-dimensional-cellular-automata-3.c | 40 ++ .../one-dimensional-cellular-automata.refal | 39 ++ .../one-dimensional-cellular-automata.uiua | 4 + Task/Ordered-words/BASIC/ordered-words.basic | 17 + Task/Ordered-words/Emacs-Lisp/ordered-words.l | 75 +++ Task/Ordered-words/SETL/ordered-words.setl | 20 + Task/Ordered-words/Uiua/ordered-words.uiua | 4 + .../EasyLang/ormiston-triples.easy | 3 +- .../Phix/ormiston-triples-1.phix | 198 +++---- .../Phix/ormiston-triples-2.phix | 82 ++- .../11l/own-digits-power-sum.11l | 2 +- .../C++/p-adic-numbers-basic.cpp | 58 +- .../Java/p-adic-numbers-basic.java | 35 +- Task/P-Adic-square-roots/00-TASK.txt | 1 + .../C++/p-adic-square-roots.cpp | 309 ++++++++++ .../Java/p-adic-square-roots.java | 336 +++++++++++ .../Jq/p-value-correction.jq | 153 +++++ .../FreeBASIC/padovan-sequence.basic | 80 +++ ...e-detection.l => palindrome-detection-1.l} | 0 .../Emacs-Lisp/palindrome-detection-2.l | 3 + .../Langur/palindrome-detection.langur | 10 +- .../PascalABC.NET/palindrome-detection.pas | 6 + .../Refal/palindrome-detection.refal | 37 ++ .../Run-BASIC/palindrome-detection.basic | 13 +- ...ction.uiua => palindrome-detection-1.uiua} | 0 .../Uiua/palindrome-detection-2.uiua | 2 + Task/Palindromic-gapful-numbers/00-TASK.txt | 20 +- .../Jq/palindromic-gapful-numbers.jq | 68 +++ .../Elixir/parallel-brute-force.elixir | 47 ++ .../parallel-calculations.pas | 82 +++ .../COBOL/parametric-polymorphism.cobol | 34 ++ .../PascalABC.NET/parametric-polymorphism.pas | 31 + .../partition-an-integer-x-into-n-primes.easy | 55 ++ .../EasyLang/pascal-matrix-generation.easy | 49 ++ .../Quackery/password-generator.quackery | 34 ++ .../pathological-floating-point-problems.easy | 51 ++ .../Jq/peaceful-chess-queen-armies.jq | 81 +++ .../Langur/pells-equation.langur | 40 +- Task/Penneys-game/Ada/penneys-game.ada | 102 ++++ Task/Pentomino-tiling/Jq/pentomino-tiling.jq | 178 ++++++ ...percentage-difference-between-images-3.ada | 2 +- .../11l/percolation-bond-percolation.11l | 9 +- .../11l/percolation-mean-cluster-density.11l | 2 +- .../11l/percolation-site-percolation.11l | 3 +- .../percolation-site-percolation.basic | 53 +- .../ALGOL-60/perfect-numbers.alg | 10 +- .../EasyLang/perfect-numbers.easy | 13 +- .../S-BASIC/perfect-numbers.basic | 6 +- .../EasyLang/peripheral-drift-illusion.easy | 27 + Task/Perlin-noise/ALGOL-68/perlin-noise.alg | 77 +++ Task/Perlin-noise/Jq/perlin-noise.jq | 99 ++++ .../permutations-rank-of-a-permutation.easy | 59 ++ .../Ada/permutations-by-swapping.ada | 28 + Task/Permutations/Langur/permutations.langur | 50 +- Task/Permutations/Uiua/permutations.uiua | 6 + .../EasyLang/phrase-reversals.easy | 18 + Task/Pi/AArch64-Assembly/pi.aarch64 | 146 +++++ Task/Pi/ARM-Assembly/pi.arm | 155 +++++ Task/Pi/Standard-ML/pi.ml | 27 + Task/Pi/UNIX-Shell/pi.sh | 48 ++ .../PascalABC.NET/pick-random-element.pas | 4 + .../Uiua/pick-random-element.uiua | 1 + .../EasyLang/pierpont-primes.easy | 47 ++ .../C/pig-the-dice-game-player.c | 179 ++++++ .../EasyLang/pinstripe-display.easy | 10 + Task/Pisano-period/APL/pisano-period.apl | 17 + Task/Pisano-period/Jq/pisano-period.jq | 114 ++++ Task/Pisano-period/SETL/pisano-period.setl | 79 +++ .../Plasma-effect/EasyLang/plasma-effect.easy | 20 + .../Ada/play-recorded-sounds.ada | 39 ++ .../EasyLang/plot-coordinate-pairs.easy | 8 +- .../Ecstasy/pointers-and-references.ecstasy | 18 + .../PascalABC.NET/pointers-and-references.pas | 29 + .../Ada/poker-hand-analyser.ada | 162 +++++ .../Jq/poker-hand-analyser.jq | 65 ++ .../Liberty-BASIC/poker-hand-analyser.basic | 371 ++++++++++++ .../XPL0/poker-hand-analyser.xpl0 | 86 +++ .../Polymorphic-copy/Ada/polymorphic-copy.ada | 8 +- .../PascalABC.NET/polymorphic-copy.pas | 33 ++ .../PascalABC.NET/polymorphism.pas | 36 ++ .../Jq/polynomial-regression.jq | 47 ++ .../Population-count/ABC/population-count.abc | 25 + .../Refal/population-count.refal | 41 ++ Task/Power-set/PascalABC.NET/power-set.pas | 16 + .../Chipmunk-Basic/price-fraction.basic | 22 + .../Langur/price-fraction-1.langur | 33 ++ .../Langur/price-fraction-2.langur | 35 ++ .../Langur/price-fraction.langur | 26 - Task/Price-fraction/QB64/price-fraction.qb64 | 19 + .../primality-by-trial-division.basic | 11 + .../primality-by-trial-division-1.langur | 8 +- .../primality-by-trial-division-2.langur | 16 +- .../primality-by-trial-division.pas | 18 + .../PascalABC.NET/prime-decomposition.pas | 19 + .../REXX/prime-decomposition-1.rexx | 82 +++ .../REXX/prime-decomposition-3.rexx | 69 +++ ...se-neighboring-pairs-are-tetraprimes.sidef | 34 ++ Task/Priority-queue/Zig/priority-queue-1.zig | 26 +- .../11l/problem-of-apollonius.11l | 9 +- .../EasyLang/problem-of-apollonius.easy | 2 +- .../Program-name/Ecstasy/program-name.ecstasy | 7 + .../PascalABC.NET/program-name.pas | 3 + .../PascalABC.NET/program-termination.pas | 5 + .../Chipmunk-Basic/proper-divisors.basic | 35 ++ .../EasyLang/proper-divisors.easy | 12 +- .../Gambas/proper-divisors.gambas | 47 ++ .../Langur/proper-divisors.langur | 34 +- ...s-combined-recursive-generator-mrg32k3a.jq | 15 + ...do-random-numbers-middle-square-method.alg | 15 + .../pseudo-random-numbers-pcg32.basic | 49 ++ .../Jq/pseudo-random-numbers-pcg32.jq | 50 ++ .../pseudo-random-numbers-splitmix64.basic | 44 ++ .../pseudo-random-numbers-splitmix64.swift | 34 ++ .../pseudo-random-numbers-xorshift-star.basic | 43 ++ .../Jq/pseudo-random-numbers-xorshift-star.jq | 38 ++ .../EasyLang/pythagorean-quadruples.easy | 28 + .../D/pythagorean-triples-1.d | 4 +- .../PascalABC.NET/queue-definition.pas | 39 ++ .../Queue-Usage/PascalABC.NET/queue-usage.pas | 7 + Task/Quine/Odin/quine.odin | 16 + Task/Quine/PascalABC.NET/quine.pas | 1 + Task/Quine/Prog8/quine.prog8 | 9 + Task/Quine/Uxntal/quine.uxnatl | 16 + .../PascalABC.NET/quoting-constructs-1.pas | 1 + .../PascalABC.NET/quoting-constructs-2.pas | 1 + .../PascalABC.NET/quoting-constructs-3.pas | 2 + .../PascalABC.NET/quoting-constructs-4.pas | 5 + Task/RIPEMD-160/Java/ripemd-160-2.java | 2 +- .../Uiua/rpg-attributes-generator.uiua | 4 + .../PascalABC.NET/radical-of-an-integer.pas | 41 ++ ...eger.rexx => radical-of-an-integer-1.rexx} | 4 + .../REXX/radical-of-an-integer-2.rexx | 361 +++++++++++ ...-douglas-peucker-line-simplification.basic | 67 +++ ...mer-douglas-peucker-line-simplification.jq | 29 + ...-douglas-peucker-line-simplification.basic | 67 +++ .../ANSI-BASIC/random-numbers.basic | 19 + .../QuickBASIC/random-numbers.basic | 7 + Task/Random-numbers/Uiua/random-numbers.uiua | 6 + .../Jq/random-sentence-from-book.jq | 107 ++++ .../EasyLang/range-expansion.easy | 20 + .../EasyLang/range-extraction.easy | 28 +- Task/Rare-numbers/Langur/rare-numbers.langur | 33 +- .../Chipmunk-Basic/rate-counter.basic | 17 + .../11l/ray-casting-algorithm.11l | 24 +- ...ead-a-file-character-by-character-utf8.pas | 6 + .../C/read-a-file-line-by-line-1.c | 45 +- .../read-a-file-line-by-line.pas | 6 + .../read-a-specific-line-from-a-file.pas | 4 + .../PascalABC.NET/read-entire-file.pas | 3 + .../real-constants-and-functions.basic | 25 + .../real-constants-and-functions.basic | 35 +- .../real-constants-and-functions.pas | 13 + .../real-constants-and-functions.basic | 2 +- .../real-constants-and-functions.ml | 21 +- .../XBasic/real-constants-and-functions.basic | 5 +- Task/Record-sound/00-TASK.txt | 1 + Task/Record-sound/Ada/record-sound.ada | 33 ++ .../FutureBasic/record-sound.basic | 138 +++++ .../Ecstasy/reflection-list-methods.ecstasy | 14 + .../PascalABC.NET/reflection-list-methods.pas | 7 + .../reflection-list-properties.ecstasy | 7 + .../reflection-list-properties.pas | 19 + .../Langur/regular-expressions-2.langur | 2 +- .../PascalABC.NET/regular-expressions.pas | 10 + .../remove-duplicate-elements.pas | 17 + .../remove-lines-from-a-file.pas | 9 + .../PascalABC.NET/rename-a-file.pas | 9 + .../PascalABC.NET/repeat-a-string.pas | 2 + Task/Repeat/Applesoft-BASIC/repeat.basic | 20 + Task/Repeat/Chapel/repeat-1.chapel | 13 + Task/Repeat/Chapel/repeat-2.chapel | 13 + Task/Repeat/Chapel/repeat-3.chapel | 13 + Task/Repeat/PascalABC.NET/repeat.pas | 7 + Task/Repeat/Refal/repeat.refal | 12 + .../PascalABC.NET/return-multiple-values.pas | 6 + .../Langur/reverse-a-string.langur | 2 +- .../PascalABC.NET/reverse-a-string.pas | 3 + .../reverse-words-in-a-string.pas | 3 + Task/Rhonda-numbers/Python/rhonda-numbers.py | 47 ++ .../EasyLang/rock-paper-scissors.easy | 24 + .../JavaScript/roman-numerals-decode-8.js | 70 +-- .../PascalABC.NET/roman-numerals-decode.pas | 39 ++ .../JavaScript/roman-numerals-encode-4.js | 47 +- .../PascalABC.NET/roman-numerals-encode.pas | 21 + .../Ada/rosetta-code-count-examples.ada | 13 +- .../rosetta-code-find-unimplemented-tasks.ada | 68 +-- ...-code-rank-languages-by-number-of-users.jq | 14 + ...etta-code-rank-languages-by-popularity.ada | 180 +++++- ...tta-code-rank-languages-by-popularity.java | 31 +- ...etta-code-rank-languages-by-popularity.pas | 13 + Task/Rot-13/PascalABC.NET/rot-13.pas | 19 + .../Uiua/run-length-encoding.uiua | 10 + ...runtime-evaluation-in-an-environment.basic | 10 + .../EasyLang/ruth-aaron-numbers.easy | 40 ++ Task/SEDOLs/Langur/sedols.langur | 34 +- Task/SHA-256/Java/sha-256.java | 2 +- Task/SHA-256/V-(Vlang)/sha-256.v | 6 +- .../Safe-addition/Langur/safe-addition.langur | 1 + ...sailors-coconuts-and-a-monkey-problem.easy | 18 + .../scope-function-names-and-labels.easy | 13 + .../Wren/scope-function-names-and-labels.wren | 13 +- .../PascalABC.NET/scope-modifiers-1.pas | 1 + .../PascalABC.NET/scope-modifiers-2.pas | 1 + .../PascalABC.NET/scope-modifiers-3.pas | 1 + .../PascalABC.NET/scope-modifiers-4.pas | 1 + .../Ecstasy/search-a-list.ecstasy | 12 + .../Perl/search-in-paragraphs-text.pl | 15 + ...stances-of-a-character-within-a-string.ada | 42 ++ ...tances-of-a-character-within-a-string.easy | 20 + Task/Self-numbers/EasyLang/self-numbers.easy | 47 ++ Task/Semiprime/REXX/semiprime-4.rexx | 59 ++ .../SuperCollider/semordnilap-1.sc | 12 - .../SuperCollider/semordnilap-2.sc | 6 - Task/Semordnilap/Uiua/semordnilap.uiua | 4 +- .../send-an-unknown-method-call.ecstasy | 21 + .../send-an-unknown-method-call.pas | 10 + .../sequence-of-primes-by-trial-division.pas | 4 + Task/Set-puzzle/Jq/set-puzzle.jq | 77 +++ .../Jq/set-right-adjacent-bits.jq | 27 + Task/Sexy-primes/BASIC256/sexy-primes.basic | 70 +++ Task/Sexy-primes/FreeBASIC/sexy-primes.basic | 12 +- Task/Sexy-primes/Yabasic/sexy-primes.basic | 66 +++ .../Langur/show-ascii-table.langur | 8 +- .../SETL/show-ascii-table.setl | 9 + .../EasyLang/show-the-epoch.easy | 2 + .../Jq/sierpinski-pentagon.jq | 59 ++ .../Ada/sierpinski-square-curve.ada | 49 ++ .../EasyLang/sierpinski-triangle.easy | 14 + .../EasyLang/sieve-of-eratosthenes.easy | 18 +- .../Erlang/sieve-of-eratosthenes-6.erl | 20 + .../Langur/sieve-of-eratosthenes.langur | 20 +- .../OCaml/sieve-of-eratosthenes-7.ocaml | 16 + .../OCaml/sieve-of-eratosthenes-8.ocaml | 3 + .../PascalABC.NET/sieve-of-eratosthenes.pas | 17 + Task/Simple-database/11l/simple-database.11l | 9 +- Task/Simple-database/C++/simple-database.cpp | 147 +++++ .../simple-windowed-application.pas | 13 + Task/Singleton/Ecstasy/singleton.ecstasy | 15 + .../singly-linked-list-element-definition.pas | 4 + .../singly-linked-list-element-insertion.pas | 33 ++ Task/Sleep/PascalABC.NET/sleep.pas | 6 + .../ALGOL-68/sleeping-beauty-problem.alg | 19 + .../Fortran/sleeping-beauty-problem.f | 43 ++ .../FutureBasic/sleeping-beauty-problem.basic | 18 +- .../Jq/sleeping-beauty-problem.jq | 25 + .../Sidef/smarandache-wellin-primes.sidef | 32 + .../Smith-numbers/EasyLang/smith-numbers.easy | 8 +- Task/Smith-numbers/Uiua/smith-numbers-1.uiua | 7 + Task/Smith-numbers/Uiua/smith-numbers-2.uiua | 3 + Task/Snake/Emacs-Lisp/snake.l | 1 + Task/Snake/Locomotive-Basic/snake.basic | 29 +- Task/Solve-a-Hidato-puzzle/00-TASK.txt | 2 +- .../Jq/solve-a-hidato-puzzle.jq | 74 +++ .../Uiua/solve-a-hidato-puzzle.uiua | 22 + .../Jq/solve-a-holy-knights-tour.jq | 83 +++ .../Dart/solve-a-numbrix-puzzle.dart | 92 +++ .../Jq/solve-a-numbrix-puzzle.jq | 80 +++ .../Uiua/solve-a-numbrix-puzzle.uiua | 22 + .../solve-the-no-connection-puzzle.basic | 51 ++ .../solve-the-no-connection-puzzle.quackery | 24 + .../Zig/solve-the-no-connection-puzzle-1.zig | 53 ++ .../Zig/solve-the-no-connection-puzzle-2.zig | 54 ++ .../sort-a-list-of-object-identifiers.easy | 28 + .../sort-an-array-of-composite-structures.pas | 10 + .../EasyLang/sort-an-integer-array.easy | 12 + .../PascalABC.NET/sort-an-integer-array.pas | 4 + .../C++/sort-an-outline-at-every-level.cpp | 258 ++++++++ .../Jq/sort-an-outline-at-every-level.jq | 169 ++++++ .../Uiua/sort-disjoint-sublist.uiua | 1 + .../sort-numbers-lexicographically.easy | 14 + .../PascalABC.NET/sort-three-variables.pas | 14 + .../sort-using-a-custom-comparator.pas | 10 + .../sorting-algorithms-circle-sort.alg | 67 +++ .../sorting-algorithms-circle-sort.easy | 31 + .../EMal/sorting-algorithms-bogosort.emal | 19 + .../sorting-algorithms-cocktail-sort.easy | 25 + .../sorting-algorithms-comb-sort.easy | 17 + .../sorting-algorithms-counting-sort.langur | 16 +- .../sorting-algorithms-counting-sort.basic | 72 +++ .../sorting-algorithms-insertion-sort-3.lisp | 24 + ...orting-algorithms-insertion-sort-1.kotlin} | 0 ...sorting-algorithms-insertion-sort-2.kotlin | 16 + .../sorting-algorithms-merge-sort.ml | 9 +- .../sorting-algorithms-pancake-sort.easy | 48 ++ .../sorting-algorithms-permutation-sort.ada | 39 ++ .../sorting-algorithms-permutation-sort.easy | 49 ++ .../11l/sorting-algorithms-quicksort.11l | 2 +- .../sorting-algorithms-quicksort.basic | 51 ++ .../sorting-algorithms-quicksort.easy | 29 +- .../sorting-algorithms-quicksort.pas | 41 ++ .../Python/sorting-algorithms-quicksort-8.py | 9 + .../sorting-algorithms-quicksort.basic | 0 .../XBasic/sorting-algorithms-quicksort.basic | 75 +++ .../sorting-algorithms-shell-sort.easy | 18 + .../11l/sorting-algorithms-stooge-sort.11l | 2 +- .../sorting-algorithms-stooge-sort.easy | 4 +- .../sorting-algorithms-stooge-sort.basic | 38 ++ .../sorting-algorithms-strand-sort.easy | 43 ++ .../PascalABC.NET/special-variables-1.pas | 4 + .../PascalABC.NET/special-variables-2.pas | 7 + .../PascalABC.NET/special-variables-3.pas | 4 + ...-string-based-on-change-of-character.refal | 16 + ...r-string-based-on-change-of-character.setl | 17 + ...r-string-based-on-change-of-character.uiua | 1 + .../8080-Assembly/square-but-not-cube.8080 | 91 +++ .../ABC/square-but-not-cube.abc | 11 + .../MACRO-11/square-but-not-cube.macro11 | 53 ++ .../Refal/square-but-not-cube.refal | 21 + .../Uiua/square-free-integers.uiua | 6 + .../PascalABC.NET/stack-traces.pas | 14 + Task/Stack/PascalABC.NET/stack.pas | 11 + .../EasyLang/stair-climbing-puzzle.easy | 15 + .../Phix/steffensens-method.phix | 108 ++-- .../EasyLang/stem-and-leaf-plot.easy | 24 + .../Uiua/stem-and-leaf-plot.uiua | 10 + .../String-append/Langur/string-append.langur | 6 +- .../PascalABC.NET/string-append.pas | 6 + Task/String-case/Ecstasy/string-case.ecstasy | 7 + .../String-case/PascalABC.NET/string-case.pas | 4 + Task/String-case/Uiua/string-case.uiua | 4 + Task/String-case/Zig/string-case.zig | 2 +- .../Ecstasy/string-comparison.ecstasy | 54 ++ ...ncatenation.c => string-concatenation-1.c} | 0 .../C/string-concatenation-2.c | 14 + .../Ecstasy/string-concatenation.ecstasy | 31 + .../PascalABC.NET/string-concatenation.pas | 4 + .../Uiua/string-concatenation.uiua | 3 + .../string-interpolation-included--1.langur | 2 + .../string-interpolation-included--2.langur | 1 + .../string-interpolation-included--3.langur | 3 + .../string-interpolation-included-.pas | 3 + .../Phix/string-interpolation-included-.phix | 8 +- .../Uiua/string-interpolation-included-.uiua | 1 + .../String-length/EasyLang/string-length.easy | 4 - .../Ecstasy/string-length.ecstasy | 10 + .../PascalABC.NET/string-length.pas | 6 + .../PascalABC.NET/string-matching.pas | 9 + .../Uiua/string-matching-1.uiua | 1 + .../Uiua/string-matching-2.uiua | 1 + .../Uiua/string-matching-3.uiua | 1 + .../Uiua/string-matching-4.uiua | 1 + .../PascalABC.NET/string-prepend.pas | 4 + ...trip-a-set-of-characters-from-a-string.pas | 6 + ...rip-a-set-of-characters-from-a-string.uiua | 3 + .../PascalABC.NET/strip-block-comments.pas | 21 + .../strip-comments-from-a-string.pas | 7 + ...d-extended-characters-from-a-string.langur | 8 +- ...-and-extended-characters-from-a-string.pas | 7 + ...-whitespace-from-a-string-top-and-tail.pas | 6 + .../Emacs-Lisp/substitution-cipher.l | 41 ++ .../PascalABC.NET/substitution-cipher.pas | 14 + .../Ecstasy/substring-top-and-tail.ecstasy | 13 + .../PascalABC.NET/substring-top-and-tail.pas | 7 + Task/Substring/Ecstasy/substring.ecstasy | 60 ++ Task/Substring/PascalABC.NET/substring.pas | 13 + .../PascalABC.NET/sudan-function.pas | 12 + Task/Sudoku/Uiua/sudoku.uiua | 26 + .../Langur/sum-and-product-of-an-array.langur | 8 +- .../sum-and-product-of-an-array.pas | 3 + .../sum-digits-of-an-integer.pas | 17 + .../sum-multiples-of-3-and-5.pas | 3 + .../Uiua/sum-multiples-of-3-and-5-1.uiua | 8 + .../Uiua/sum-multiples-of-3-and-5-2.uiua | 3 + .../Langur/sum-of-a-series-1.langur | 4 +- .../Langur/sum-of-a-series-2.langur | 4 +- .../PascalABC.NET/sum-of-a-series.pas | 2 + ...elements-below-main-diagonal-of-matrix.pas | 14 + .../PascalABC.NET/sum-of-squares.pas | 3 + .../11l/summarize-and-say-sequence.11l | 2 +- .../C-sharp/summarize-primes.cs | 61 ++ .../Uiua/summarize-primes.uiua | 4 + .../Pascal/symmetric-difference-1.pas | 2 +- .../PascalABC.NET/symmetric-difference.pas | 7 + Task/System-time/Ecstasy/system-time.ecstasy | 8 + .../System-time/PascalABC.NET/system-time.pas | 2 + .../take-notes-on-the-command-line.pas | 11 + .../take-notes-on-the-command-line-1.sh | 16 +- Task/Tarjan/11l/tarjan.11l | 2 +- Task/Tau-function/C-sharp/tau-function.cs | 51 ++ .../PascalABC.NET/tau-function.pas | 4 + Task/Tau-function/REXX/tau-function.rexx | 74 ++- Task/Tau-number/C-sharp/tau-number.cs | 59 ++ Task/Tau-number/PascalABC.NET/tau-number.pas | 12 + Task/Tau-number/REXX/tau-number.rexx | 81 +-- .../EasyLang/taxicab-numbers.easy | 34 ++ .../Teacup-rim-text/REXX/teacup-rim-text.rexx | 72 ++- .../PascalABC.NET/temperature-conversion.pas | 5 + .../terminal-control-clear-the-screen.pas | 2 + .../terminal-control-coloured-text.pas | 8 + .../terminal-control-cursor-movement.pas | 22 + .../terminal-control-cursor-positioning.pas | 6 + .../terminal-control-dimensions.pas | 5 + ...-control-display-an-extended-character.pas | 5 + .../terminal-control-hiding-the-cursor.pas | 10 + ...inal-control-ringing-the-terminal-bell.pas | 2 + .../JavaScript/ternary-logic-3.js | 3 +- .../JavaScript/ternary-logic-4.js | 14 +- .../JavaScript/ternary-logic-5.js | 26 +- .../Ternary-logic/Langur/ternary-logic.langur | 42 +- .../PascalABC.NET/test-a-function.pas | 13 + .../Test-a-function/Uiua/test-a-function.uiua | 6 + .../Jq/thieles-interpolation-formula.jq | 42 ++ Task/Tic-tac-toe/J/tic-tac-toe.j | 103 +--- Task/Tic-tac-toe/Jq/tic-tac-toe.jq | 151 +++++ .../PascalABC.NET/time-a-function.pas | 14 + .../tokenize-a-string-with-escaping.easy | 20 + .../PascalABC.NET/tokenize-a-string.pas | 5 + .../EasyLang/top-rank-per-group.easy | 58 ++ .../PascalABC.NET/top-rank-per-group.pas | 25 + Task/Topic-variable/Java/topic-variable.java | 42 ++ Task/Towers-of-Hanoi/11l/towers-of-hanoi.11l | 2 +- .../Asymptote/towers-of-hanoi.asymptote | 12 + .../Bruijn/towers-of-hanoi.bruijn | 10 + .../JavaScript/towers-of-hanoi-4.js | 18 +- .../PascalABC.NET/towers-of-hanoi.pas | 9 + .../trabb-pardo-knuth-algorithm.pas | 10 + .../UNIX-Shell/trabb-pardo-knuth-algorithm.sh | 18 + ...-english-text-using-the-greek-alphabet.pas | 37 ++ .../11l/tree-datastructures.11l | 9 +- .../PascalABC.NET/tree-datastructures.pas | 41 ++ .../C-sharp/tree-from-nesting-levels.cs | 70 +++ Task/Tree-traversal/11l/tree-traversal.11l | 8 +- Task/Tree-traversal/EMal/tree-traversal.emal | 63 ++ .../PascalABC.NET/tree-traversal.pas | 61 ++ Task/Tree-traversal/Rust/tree-traversal.rust | 39 +- .../PascalABC.NET/trigonometric-functions.pas | 20 + .../Phix/trigonometric-functions.phix | 28 +- .../REXX/truncatable-primes.rexx | 112 ++-- .../Uiua/truncatable-primes.uiua | 10 + .../PascalABC.NET/truncate-a-file.pas | 14 + .../PascalABC.NET/twos-complement.pas | 5 + Task/UPC/Ada/upc.ada | 162 +++++ Task/URL-decoding/Langur/url-decoding.langur | 8 +- .../PascalABC.NET/url-decoding.pas | 9 + Task/URL-encoding/Langur/url-encoding.langur | 12 +- .../PascalABC.NET/url-encoding.pas | 4 + .../Langur/utf-8-encode-and-decode.langur | 10 +- .../C-sharp/ultra-useful-primes.cs | 82 +++ .../PascalABC.NET/undefined-values.pas | 9 + .../PascalABC.NET/unicode-strings.pas | 6 + .../PascalABC.NET/unicode-variable-names.pas | 5 + ...chine.py => universal-turing-machine-1.py} | 0 .../Python/universal-turing-machine-2.py | 24 + .../User-input-Text/EMal/user-input-text.emal | 9 + .../PascalABC.NET/user-input-text.pas | 3 + ...al-securities-identification-number.langur | 32 +- ...onal-securities-identification-number.rexx | 70 ++- ...onal-securities-identification-number.uiua | 19 + .../REXX/van-eck-sequence-1.rexx | 34 +- .../REXX/van-eck-sequence-2.rexx | 44 +- .../C-sharp/variable-declaration-reset.cs | 37 ++ Task/Variables/PascalABC.NET/variables-1.pas | 1 + Task/Variables/PascalABC.NET/variables-2.pas | 1 + Task/Variables/PascalABC.NET/variables-3.pas | 1 + Task/Variables/PascalABC.NET/variables-4.pas | 1 + Task/Variables/PascalABC.NET/variables-5.pas | 6 + Task/Variables/PascalABC.NET/variables-6.pas | 5 + .../PascalABC.NET/variadic-function.pas | 11 + .../PascalABC.NET/vector-products.pas | 26 + .../Vector-products/REXX/vector-products.rexx | 45 +- Task/Vector/Chipmunk-Basic/vector.basic | 37 ++ Task/Vector/GW-BASIC/vector.basic | 37 ++ Task/Vector/PascalABC.NET/vector.pas | 31 + Task/Vector/QBasic/vector.basic | 39 ++ Task/Vector/True-BASIC/vector.basic | 40 ++ .../verify-distribution-uniformity-naive.easy | 47 ++ .../Sidef/wagstaff-primes.sidef | 20 + .../walk-a-directory-non-recursively.pas | 4 + .../walk-a-directory-recursively.pas | 4 + Task/War-card-game/00-TASK.txt | 1 - Task/War-card-game/Ada/war-card-game.ada | 146 +++++ Task/War-card-game/Jq/war-card-game.jq | 113 ++++ .../PHP/water-collected-between-towers.php | 60 ++ .../Uiua/water-collected-between-towers.uiua | 10 + Task/Weird-numbers/Ada/weird-numbers-1.ada | 109 ++++ Task/Weird-numbers/Ada/weird-numbers-2.ada | 105 ++++ .../{weird-numbers.py => weird-numbers-1.py} | 0 Task/Weird-numbers/Python/weird-numbers-2.py | 51 ++ .../Weird-numbers/Uxntal/weird-numbers.uxnatl | 85 +++ .../PascalABC.NET/window-creation.pas | 5 + Task/Wireworld/11l/wireworld.11l | 9 +- .../PascalABC.NET/word-frequency.pas | 3 + Task/Word-ladder/APL/word-ladder.apl | 23 + Task/Word-ladder/Ada/word-ladder.ada | 146 +++++ Task/Word-ladder/Refal/word-ladder.refal | 95 +++ Task/Word-ladder/SETL/word-ladder.setl | 45 ++ Task/Word-search/Ada/word-search.ada | 259 ++++++++ Task/Word-wheel/Ada/word-wheel.ada | 56 ++ .../Lua/{word-wheel.lua => word-wheel-1.lua} | 0 Task/Word-wheel/Lua/word-wheel-2.lua | 15 + Task/Word-wrap/PascalABC.NET/word-wrap.pas | 40 ++ Task/Wordiff/Jq/wordiff.jq | 108 ++++ .../PascalABC.NET/write-entire-file.pas | 2 + .../write-to-windows-event-log.basic | 36 ++ .../write-to-windows-event-log.pas | 7 + .../PascalABC.NET/xml-dom-serialization.pas | 19 + Task/XML-Input/PascalABC.NET/xml-input.pas | 20 + Task/XML-Input/Vim-Script/xml-input.vim | 9 + Task/XML-Output/PascalABC.NET/xml-output.pas | 20 + .../C-sharp/yellowstone-sequence.cs | 73 +++ .../Uiua/yellowstone-sequence.uiua | 6 + ...in-and-yang.basic => yin-and-yang-1.basic} | 0 .../AmigaBASIC/yin-and-yang-2.basic | 21 + Task/Zebra-puzzle/Phix/zebra-puzzle.phix | 157 ++--- Task/Zebra-puzzle/Uiua/zebra-puzzle.uiua | 32 + .../11l/zeckendorf-arithmetic.11l | 2 +- .../PascalABC.NET/zero-to-the-zero-power.pas | 2 + .../EasyLang/zig-zag-matrix.easy | 31 + 2011 files changed, 35081 insertions(+), 3229 deletions(-) create mode 120000 Lang/8080-Assembly/Square-but-not-cube create mode 120000 Lang/AArch64-Assembly/Pi create mode 120000 Lang/ABC/Look-and-say-sequence create mode 120000 Lang/ABC/Population-count create mode 120000 Lang/ABC/Square-but-not-cube create mode 120000 Lang/ALGOL-68/Draw-a-cuboid create mode 120000 Lang/ALGOL-68/Perlin-noise create mode 120000 Lang/ALGOL-68/Sleeping-Beauty-problem create mode 120000 Lang/ALGOL-68/Sorting-Algorithms-Circle-Sort create mode 120000 Lang/ALGOL-W/Eulers-constant-0.5772... create mode 120000 Lang/ALGOL-W/Find-the-intersection-of-two-lines create mode 120000 Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method create mode 120000 Lang/ANSI-BASIC/Damm-algorithm create mode 120000 Lang/ANSI-BASIC/Formatted-numeric-output create mode 120000 Lang/ANSI-BASIC/Function-definition create mode 120000 Lang/ANSI-BASIC/Monty-Hall-problem create mode 120000 Lang/ANSI-BASIC/Random-numbers create mode 120000 Lang/ANSI-BASIC/Real-constants-and-functions create mode 120000 Lang/ANSI-BASIC/Sorting-algorithms-Quicksort create mode 120000 Lang/APL/Display-a-linear-combination create mode 120000 Lang/APL/Pisano-period create mode 120000 Lang/APL/Word-ladder create mode 120000 Lang/ARM-Assembly/Pi create mode 120000 Lang/Ada/Abelian-sandpile-model create mode 120000 Lang/Ada/Achilles-numbers create mode 120000 Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi create mode 120000 Lang/Ada/Ascending-primes create mode 120000 Lang/Ada/Brace-expansion create mode 120000 Lang/Ada/Color-wheel create mode 120000 Lang/Ada/Combinations-and-permutations create mode 120000 Lang/Ada/Eulers-constant-0.5772... create mode 120000 Lang/Ada/FTP create mode 120000 Lang/Ada/Hex-words create mode 120000 Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols create mode 120000 Lang/Ada/Largest-number-divisible-by-its-digits create mode 120000 Lang/Ada/Magic-constant create mode 120000 Lang/Ada/Mind-boggling-card-trick create mode 120000 Lang/Ada/Musical-scale create mode 120000 Lang/Ada/Next-highest-int-from-digits create mode 120000 Lang/Ada/Penneys-game create mode 120000 Lang/Ada/Permutations-by-swapping create mode 120000 Lang/Ada/Play-recorded-sounds create mode 120000 Lang/Ada/Poker-hand-analyser create mode 120000 Lang/Ada/Record-sound create mode 120000 Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string create mode 120000 Lang/Ada/Sierpinski-square-curve create mode 120000 Lang/Ada/Sorting-algorithms-Permutation-sort create mode 120000 Lang/Ada/UPC create mode 120000 Lang/Ada/War-card-game create mode 120000 Lang/Ada/Weird-numbers create mode 120000 Lang/Ada/Word-ladder create mode 120000 Lang/Ada/Word-search create mode 120000 Lang/Ada/Word-wheel create mode 120000 Lang/Applesoft-BASIC/Display-a-linear-combination create mode 120000 Lang/Applesoft-BASIC/Repeat create mode 120000 Lang/Asymptote/Jensens-Device create mode 120000 Lang/Asymptote/Towers-of-Hanoi delete mode 100644 Lang/AutoHotKey-V2/00-LANG.txt delete mode 100644 Lang/AutoHotKey-V2/00-META.yaml delete mode 120000 Lang/AutoHotKey-V2/Hello-world-Graphical create mode 100644 Lang/Autohotkey-V2/00-LANG.txt create mode 100644 Lang/Autohotkey-V2/00-META.yaml create mode 120000 Lang/Autohotkey-V2/Hello-world-Graphical delete mode 120000 Lang/BASIC/Damm-algorithm delete mode 120000 Lang/BASIC/Function-definition delete mode 120000 Lang/BASIC/Gray-code delete mode 120000 Lang/BASIC/Monty-Hall-problem create mode 120000 Lang/BASIC/Ordered-words delete mode 120000 Lang/BASIC/Sorting-algorithms-Quicksort create mode 120000 Lang/BASIC256/Kronecker-product create mode 120000 Lang/BASIC256/Multiple-regression create mode 120000 Lang/BASIC256/Nested-templated-data create mode 120000 Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification create mode 120000 Lang/BASIC256/Sexy-primes create mode 120000 Lang/Bruijn/Harmonic-series create mode 120000 Lang/Bruijn/Towers-of-Hanoi create mode 120000 Lang/C++/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/C++/Bitcoin-address-validation create mode 120000 Lang/C++/Bitcoin-public-point-to-address create mode 120000 Lang/C++/Catmull-Clark-subdivision-surface create mode 120000 Lang/C++/Compiler-virtual-machine-interpreter create mode 120000 Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection create mode 120000 Lang/C++/Im-a-software-engineer-get-me-out-of-here create mode 120000 Lang/C++/P-Adic-square-roots create mode 120000 Lang/C++/Simple-database create mode 120000 Lang/C++/Sort-an-outline-at-every-level create mode 120000 Lang/C-sharp/Additive-primes create mode 120000 Lang/C-sharp/Cyclops-numbers create mode 120000 Lang/C-sharp/Summarize-primes create mode 120000 Lang/C-sharp/Tau-function create mode 120000 Lang/C-sharp/Tau-number create mode 120000 Lang/C-sharp/Tree-from-nesting-levels create mode 120000 Lang/C-sharp/Ultra-useful-primes create mode 120000 Lang/C-sharp/Variable-declaration-reset create mode 120000 Lang/C-sharp/Yellowstone-sequence create mode 120000 Lang/C/Hunt-the-Wumpus create mode 120000 Lang/C/Pig-the-dice-game-Player create mode 120000 Lang/COBOL/Nim-game create mode 120000 Lang/COBOL/Parametric-polymorphism create mode 120000 Lang/Chapel/Function-definition create mode 120000 Lang/Chapel/Maze-generation create mode 120000 Lang/Chapel/Repeat create mode 120000 Lang/Chipmunk-Basic/Display-a-linear-combination create mode 120000 Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences create mode 120000 Lang/Chipmunk-Basic/Jensens-Device create mode 120000 Lang/Chipmunk-Basic/Multiple-regression create mode 120000 Lang/Chipmunk-Basic/Nested-templated-data create mode 120000 Lang/Chipmunk-Basic/Price-fraction create mode 120000 Lang/Chipmunk-Basic/Proper-divisors create mode 120000 Lang/Chipmunk-Basic/Rate-counter create mode 120000 Lang/Chipmunk-Basic/Vector create mode 120000 Lang/Commodore-BASIC/N-queens-problem create mode 120000 Lang/Common-Lisp/Blum-integer create mode 120000 Lang/Common-Lisp/Factorial-primes create mode 120000 Lang/Cowgol/Display-a-linear-combination create mode 120000 Lang/Dart/15-puzzle-solver create mode 120000 Lang/Dart/Jensens-Device create mode 120000 Lang/Dart/Solve-a-Numbrix-puzzle create mode 120000 Lang/Draco/Display-a-linear-combination create mode 120000 Lang/EMal/Babbage-problem create mode 120000 Lang/EMal/Bifid-cipher create mode 120000 Lang/EMal/Mutual-recursion create mode 120000 Lang/EMal/Sorting-algorithms-Bogosort create mode 120000 Lang/EMal/Tree-traversal create mode 120000 Lang/EMal/User-input-Text create mode 120000 Lang/EasyLang/Abelian-sandpile-model create mode 120000 Lang/EasyLang/Abelian-sandpile-model-Identity create mode 120000 Lang/EasyLang/Approximate-equality create mode 120000 Lang/EasyLang/Arithmetic-Complex create mode 120000 Lang/EasyLang/Greatest-subsequential-sum create mode 120000 Lang/EasyLang/Guess-the-number-With-feedback-player- create mode 120000 Lang/EasyLang/Halt-and-catch-fire create mode 120000 Lang/EasyLang/Hamming-numbers create mode 120000 Lang/EasyLang/Hofstadter-Figure-Figure-sequences create mode 120000 Lang/EasyLang/IBAN create mode 120000 Lang/EasyLang/Iterated-digits-squaring create mode 120000 Lang/EasyLang/JortSort create mode 120000 Lang/EasyLang/Kronecker-product create mode 120000 Lang/EasyLang/Kronecker-product-based-fractals create mode 120000 Lang/EasyLang/Largest-int-from-concatenated-ints create mode 120000 Lang/EasyLang/Last-letter-first-letter create mode 120000 Lang/EasyLang/Longest-increasing-subsequence create mode 120000 Lang/EasyLang/Ludic-numbers create mode 120000 Lang/EasyLang/Map-range create mode 120000 Lang/EasyLang/Move-to-front-algorithm create mode 120000 Lang/EasyLang/Multisplit create mode 120000 Lang/EasyLang/Negative-base-numbers create mode 120000 Lang/EasyLang/Non-continuous-subsequences create mode 120000 Lang/EasyLang/Non-decimal-radices-Input create mode 120000 Lang/EasyLang/Number-reversal-game create mode 120000 Lang/EasyLang/Partition-an-integer-x-into-n-primes create mode 120000 Lang/EasyLang/Pascal-matrix-generation create mode 120000 Lang/EasyLang/Pathological-floating-point-problems create mode 120000 Lang/EasyLang/Peripheral-drift-illusion create mode 120000 Lang/EasyLang/Permutations-Rank-of-a-permutation create mode 120000 Lang/EasyLang/Phrase-reversals create mode 120000 Lang/EasyLang/Pierpont-primes create mode 120000 Lang/EasyLang/Pinstripe-Display create mode 120000 Lang/EasyLang/Plasma-effect create mode 120000 Lang/EasyLang/Pythagorean-quadruples create mode 120000 Lang/EasyLang/Range-expansion create mode 120000 Lang/EasyLang/Rock-paper-scissors create mode 120000 Lang/EasyLang/Ruth-Aaron-numbers create mode 120000 Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem create mode 120000 Lang/EasyLang/Scope-Function-names-and-labels create mode 120000 Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string create mode 120000 Lang/EasyLang/Self-numbers create mode 120000 Lang/EasyLang/Show-the-epoch create mode 120000 Lang/EasyLang/Sierpinski-triangle create mode 120000 Lang/EasyLang/Sort-a-list-of-object-identifiers create mode 120000 Lang/EasyLang/Sort-an-integer-array create mode 120000 Lang/EasyLang/Sort-numbers-lexicographically create mode 120000 Lang/EasyLang/Sorting-Algorithms-Circle-Sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Cocktail-sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Comb-sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Pancake-sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Permutation-sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Shell-sort create mode 120000 Lang/EasyLang/Sorting-algorithms-Strand-sort create mode 120000 Lang/EasyLang/Stair-climbing-puzzle create mode 120000 Lang/EasyLang/Stem-and-leaf-plot create mode 120000 Lang/EasyLang/Taxicab-numbers create mode 120000 Lang/EasyLang/Tokenize-a-string-with-escaping create mode 120000 Lang/EasyLang/Top-rank-per-group create mode 120000 Lang/EasyLang/Verify-distribution-uniformity-Naive create mode 120000 Lang/EasyLang/Zig-zag-matrix create mode 120000 Lang/Ecstasy/100-prisoners create mode 120000 Lang/Ecstasy/Assertions create mode 120000 Lang/Ecstasy/Pointers-and-references create mode 120000 Lang/Ecstasy/Program-name create mode 120000 Lang/Ecstasy/Reflection-List-methods create mode 120000 Lang/Ecstasy/Reflection-List-properties create mode 120000 Lang/Ecstasy/Search-a-list create mode 120000 Lang/Ecstasy/Send-an-unknown-method-call create mode 120000 Lang/Ecstasy/Singleton create mode 120000 Lang/Ecstasy/String-case create mode 120000 Lang/Ecstasy/String-comparison create mode 120000 Lang/Ecstasy/String-concatenation create mode 120000 Lang/Ecstasy/String-length create mode 120000 Lang/Ecstasy/Substring create mode 120000 Lang/Ecstasy/Substring-Top-and-tail create mode 120000 Lang/Ecstasy/System-time create mode 120000 Lang/Elixir/Parallel-brute-force create mode 120000 Lang/Elm/Caesar-cipher create mode 120000 Lang/Emacs-Lisp/Abbreviations-automatic create mode 120000 Lang/Emacs-Lisp/Anagrams create mode 120000 Lang/Emacs-Lisp/Compare-length-of-two-strings create mode 120000 Lang/Emacs-Lisp/Date-manipulation create mode 120000 Lang/Emacs-Lisp/Determine-if-a-string-is-numeric create mode 120000 Lang/Emacs-Lisp/Determine-sentence-type create mode 120000 Lang/Emacs-Lisp/Ordered-words create mode 120000 Lang/Emacs-Lisp/Snake create mode 120000 Lang/Emacs-Lisp/Substitution-cipher create mode 120000 Lang/Fortran/Sleeping-Beauty-problem create mode 120000 Lang/Free-Pascal-Lazarus/Bin-given-limits create mode 120000 Lang/Free-Pascal-Lazarus/Closures-Value-capture create mode 120000 Lang/Free-Pascal-Lazarus/Parallel-calculations create mode 120000 Lang/FreeBASIC/B-zier-curves-Intersections create mode 120000 Lang/FreeBASIC/Constrained-genericity create mode 120000 Lang/FreeBASIC/Execute-Computer-Zero create mode 120000 Lang/FreeBASIC/Execute-SNUSP create mode 120000 Lang/FreeBASIC/Execute-a-Markov-algorithm create mode 120000 Lang/FreeBASIC/Imaginary-base-numbers create mode 120000 Lang/FreeBASIC/Nested-templated-data create mode 120000 Lang/FreeBASIC/Padovan-sequence create mode 120000 Lang/FreeBASIC/Pseudo-random-numbers-PCG32 create mode 120000 Lang/FreeBASIC/Pseudo-random-numbers-Splitmix64 create mode 120000 Lang/FreeBASIC/Pseudo-random-numbers-Xorshift-star create mode 120000 Lang/FreeBASIC/Runtime-evaluation-In-an-environment create mode 120000 Lang/FreeBASIC/Solve-the-no-connection-puzzle create mode 120000 Lang/FreeBASIC/Write-to-Windows-event-log create mode 120000 Lang/Frink/24-game create mode 120000 Lang/FutureBasic/24-game create mode 120000 Lang/FutureBasic/ASCII-art-diagram-converter create mode 120000 Lang/FutureBasic/Arbitrary-precision-integers-included- create mode 120000 Lang/FutureBasic/Biorhythms create mode 120000 Lang/FutureBasic/Brilliant-numbers create mode 120000 Lang/FutureBasic/Check-output-device-is-a-terminal create mode 120000 Lang/FutureBasic/Combinations create mode 120000 Lang/FutureBasic/Copy-stdin-to-stdout create mode 120000 Lang/FutureBasic/Determine-sentence-type create mode 120000 Lang/FutureBasic/Floyds-triangle create mode 120000 Lang/FutureBasic/Function-prototype create mode 120000 Lang/FutureBasic/Go-Fish create mode 120000 Lang/FutureBasic/Honeycombs create mode 120000 Lang/FutureBasic/Monty-Hall-problem create mode 120000 Lang/FutureBasic/Record-sound create mode 120000 Lang/GW-BASIC/Damm-algorithm create mode 120000 Lang/GW-BASIC/Display-a-linear-combination create mode 120000 Lang/GW-BASIC/Gray-code create mode 120000 Lang/GW-BASIC/Jensens-Device create mode 120000 Lang/GW-BASIC/Nested-templated-data create mode 120000 Lang/GW-BASIC/Primality-by-trial-division create mode 120000 Lang/GW-BASIC/Vector create mode 120000 Lang/Gambas/Jensens-Device create mode 120000 Lang/Gambas/M-bius-function create mode 120000 Lang/Gambas/Proper-divisors create mode 120000 Lang/Go/Factorial-primes create mode 120000 Lang/Java/Arena-storage-pool create mode 120000 Lang/Java/Bitcoin-public-point-to-address create mode 120000 Lang/Java/Catmull-Clark-subdivision-surface create mode 120000 Lang/Java/Compiler-virtual-machine-interpreter create mode 120000 Lang/Java/Im-a-software-engineer-get-me-out-of-here create mode 120000 Lang/Java/P-Adic-square-roots create mode 120000 Lang/Java/Topic-variable create mode 120000 Lang/Jq/2048 create mode 120000 Lang/Jq/24-game create mode 120000 Lang/Jq/Averages-Simple-moving-average create mode 120000 Lang/Jq/Bitwise-operations create mode 120000 Lang/Jq/CRC-32 create mode 120000 Lang/Jq/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Jq/Deconvolution-1D create mode 120000 Lang/Jq/Display-an-outline-as-a-nested-table create mode 120000 Lang/Jq/Draw-a-cuboid create mode 120000 Lang/Jq/Entropy-Narcissist create mode 120000 Lang/Jq/Factors-of-a-Mersenne-number create mode 120000 Lang/Jq/File-size-distribution create mode 120000 Lang/Jq/Find-Chess960-starting-position-identifier create mode 120000 Lang/Jq/Find-duplicate-files create mode 120000 Lang/Jq/French-Republican-calendar create mode 120000 Lang/Jq/Generate-random-chess-position create mode 120000 Lang/Jq/Giuga-numbers create mode 120000 Lang/Jq/Graph-colouring create mode 120000 Lang/Jq/Introspection create mode 120000 Lang/Jq/Knights-tour create mode 120000 Lang/Jq/Levenshtein-distance-Alignment create mode 120000 Lang/Jq/Mayan-calendar create mode 120000 Lang/Jq/Mind-boggling-card-trick create mode 120000 Lang/Jq/Minimal-steps-down-to-1 create mode 120000 Lang/Jq/Modified-random-distribution create mode 120000 Lang/Jq/Multiplicative-order create mode 120000 Lang/Jq/Nonoblock create mode 120000 Lang/Jq/Nonogram-solver create mode 120000 Lang/Jq/P-value-correction create mode 120000 Lang/Jq/Palindromic-gapful-numbers create mode 120000 Lang/Jq/Peaceful-chess-queen-armies create mode 120000 Lang/Jq/Pentomino-tiling create mode 120000 Lang/Jq/Perlin-noise create mode 120000 Lang/Jq/Pisano-period create mode 120000 Lang/Jq/Poker-hand-analyser create mode 120000 Lang/Jq/Polynomial-regression create mode 120000 Lang/Jq/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a create mode 120000 Lang/Jq/Pseudo-random-numbers-PCG32 create mode 120000 Lang/Jq/Pseudo-random-numbers-Xorshift-star create mode 120000 Lang/Jq/Ramer-Douglas-Peucker-line-simplification create mode 120000 Lang/Jq/Random-sentence-from-book create mode 120000 Lang/Jq/Rosetta-Code-Rank-languages-by-number-of-users create mode 120000 Lang/Jq/Set-puzzle create mode 120000 Lang/Jq/Set-right-adjacent-bits create mode 120000 Lang/Jq/Sierpinski-pentagon create mode 120000 Lang/Jq/Sleeping-Beauty-problem create mode 120000 Lang/Jq/Solve-a-Hidato-puzzle create mode 120000 Lang/Jq/Solve-a-Holy-Knights-tour create mode 120000 Lang/Jq/Solve-a-Numbrix-puzzle create mode 120000 Lang/Jq/Sort-an-outline-at-every-level create mode 120000 Lang/Jq/Thieles-interpolation-formula create mode 120000 Lang/Jq/Tic-tac-toe create mode 120000 Lang/Jq/War-card-game create mode 120000 Lang/Jq/Wordiff create mode 120000 Lang/K/Find-common-directory-path create mode 120000 Lang/K/Monty-Hall-problem create mode 120000 Lang/Kotlin/Compare-length-of-two-strings create mode 120000 Lang/Kotlin/Factorial-primes create mode 120000 Lang/Langur/Babbage-problem create mode 120000 Lang/Langur/I-before-E-except-after-C create mode 120000 Lang/Langur/Safe-addition create mode 120000 Lang/Langur/String-interpolation-included- create mode 120000 Lang/Liberty-BASIC/Poker-hand-analyser create mode 120000 Lang/Locomotive-Basic/Abelian-sandpile-model create mode 120000 Lang/Locomotive-Basic/Draw-a-cuboid create mode 120000 Lang/MACRO-11/Square-but-not-cube create mode 120000 Lang/Mia/Loops-While create mode 120000 Lang/Minimal-BASIC/Jensens-Device create mode 120000 Lang/Minimal-BASIC/Monty-Hall-problem create mode 120000 Lang/Modula-2/Gray-code create mode 120000 Lang/Modula-2/Monty-Hall-problem create mode 120000 Lang/Modula-3/Additive-primes create mode 120000 Lang/Nascom-BASIC/Damm-algorithm delete mode 120000 Lang/Oberon/100-doors create mode 120000 Lang/Odin/Quine create mode 120000 Lang/PHP/Water-collected-between-towers create mode 120000 Lang/PL-M/Draw-a-cuboid create mode 120000 Lang/PL-M/Nested-function create mode 120000 Lang/POV-Ray/Bitmap create mode 120000 Lang/POV-Ray/Maze-generation create mode 120000 Lang/Pascal/Count-the-coins create mode 120000 Lang/PascalABC.NET/15-puzzle-game create mode 120000 Lang/PascalABC.NET/99-bottles-of-beer create mode 120000 Lang/PascalABC.NET/A+B create mode 120000 Lang/PascalABC.NET/Abstract-type create mode 120000 Lang/PascalABC.NET/Accumulator-factory create mode 120000 Lang/PascalABC.NET/Ackermann-function create mode 120000 Lang/PascalABC.NET/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/PascalABC.NET/Address-of-a-variable create mode 120000 Lang/PascalABC.NET/Anagrams create mode 120000 Lang/PascalABC.NET/Anonymous-recursion create mode 120000 Lang/PascalABC.NET/Apply-a-callback-to-an-array create mode 120000 Lang/PascalABC.NET/Arithmetic-Complex create mode 120000 Lang/PascalABC.NET/Arithmetic-Integer create mode 120000 Lang/PascalABC.NET/Array-concatenation create mode 120000 Lang/PascalABC.NET/Arrays create mode 120000 Lang/PascalABC.NET/Assertions create mode 120000 Lang/PascalABC.NET/Associative-array-Creation create mode 120000 Lang/PascalABC.NET/Associative-array-Iteration create mode 120000 Lang/PascalABC.NET/Balanced-brackets create mode 120000 Lang/PascalABC.NET/Binary-digits create mode 120000 Lang/PascalABC.NET/Binary-search create mode 120000 Lang/PascalABC.NET/Bitwise-operations create mode 120000 Lang/PascalABC.NET/Break-OO-privacy create mode 120000 Lang/PascalABC.NET/CSV-data-manipulation create mode 120000 Lang/PascalABC.NET/Calculating-the-value-of-e create mode 120000 Lang/PascalABC.NET/Call-an-object-method create mode 120000 Lang/PascalABC.NET/Character-codes create mode 120000 Lang/PascalABC.NET/Classes create mode 120000 Lang/PascalABC.NET/Closest-pair-problem create mode 120000 Lang/PascalABC.NET/Collections create mode 120000 Lang/PascalABC.NET/Command-line-arguments create mode 120000 Lang/PascalABC.NET/Comments create mode 120000 Lang/PascalABC.NET/Compare-a-list-of-strings create mode 120000 Lang/PascalABC.NET/Compare-length-of-two-strings create mode 120000 Lang/PascalABC.NET/Compound-data-type create mode 120000 Lang/PascalABC.NET/Concurrent-computing create mode 120000 Lang/PascalABC.NET/Conditional-structures create mode 120000 Lang/PascalABC.NET/Constrained-genericity create mode 120000 Lang/PascalABC.NET/Copy-a-string create mode 120000 Lang/PascalABC.NET/Copy-stdin-to-stdout create mode 120000 Lang/PascalABC.NET/Count-in-factors create mode 120000 Lang/PascalABC.NET/Count-in-octal create mode 120000 Lang/PascalABC.NET/Count-occurrences-of-a-substring create mode 120000 Lang/PascalABC.NET/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/PascalABC.NET/Create-an-object-at-a-given-address create mode 120000 Lang/PascalABC.NET/Date-format create mode 120000 Lang/PascalABC.NET/Day-of-the-week create mode 120000 Lang/PascalABC.NET/Define-a-primitive-data-type create mode 120000 Lang/PascalABC.NET/Determine-if-a-string-is-numeric create mode 120000 Lang/PascalABC.NET/Determine-sentence-type create mode 120000 Lang/PascalABC.NET/Doubly-linked-list-Definition create mode 120000 Lang/PascalABC.NET/Doubly-linked-list-Element-definition create mode 120000 Lang/PascalABC.NET/Doubly-linked-list-Element-insertion create mode 120000 Lang/PascalABC.NET/Doubly-linked-list-Traversal create mode 120000 Lang/PascalABC.NET/Dragon-curve create mode 120000 Lang/PascalABC.NET/Draw-a-pixel create mode 120000 Lang/PascalABC.NET/Draw-a-rotating-cube create mode 120000 Lang/PascalABC.NET/Empty-program create mode 120000 Lang/PascalABC.NET/Enumerations create mode 120000 Lang/PascalABC.NET/Even-or-odd create mode 120000 Lang/PascalABC.NET/Exceptions create mode 120000 Lang/PascalABC.NET/Extreme-floating-point-values create mode 120000 Lang/PascalABC.NET/Factorial create mode 120000 Lang/PascalABC.NET/Factors-of-an-integer create mode 120000 Lang/PascalABC.NET/File-input-output create mode 120000 Lang/PascalABC.NET/File-size create mode 120000 Lang/PascalABC.NET/Filter create mode 120000 Lang/PascalABC.NET/Find-common-directory-path create mode 120000 Lang/PascalABC.NET/Find-limit-of-recursion create mode 120000 Lang/PascalABC.NET/First-class-functions create mode 120000 Lang/PascalABC.NET/FizzBuzz create mode 120000 Lang/PascalABC.NET/Flatten-a-list create mode 120000 Lang/PascalABC.NET/Floyds-triangle create mode 120000 Lang/PascalABC.NET/Formatted-numeric-output create mode 120000 Lang/PascalABC.NET/Function-definition create mode 120000 Lang/PascalABC.NET/General-FizzBuzz create mode 120000 Lang/PascalABC.NET/Generate-lower-case-ASCII-alphabet create mode 120000 Lang/PascalABC.NET/Generic-swap create mode 120000 Lang/PascalABC.NET/Greatest-common-divisor create mode 120000 Lang/PascalABC.NET/Guess-the-number create mode 120000 Lang/PascalABC.NET/Hash-from-two-arrays create mode 120000 Lang/PascalABC.NET/Hello-world-Line-printer create mode 120000 Lang/PascalABC.NET/Hello-world-Newline-omission create mode 120000 Lang/PascalABC.NET/Hello-world-Standard-error create mode 120000 Lang/PascalABC.NET/Identity-matrix create mode 120000 Lang/PascalABC.NET/Include-a-file create mode 120000 Lang/PascalABC.NET/Infinity create mode 120000 Lang/PascalABC.NET/Inheritance-Multiple create mode 120000 Lang/PascalABC.NET/Inheritance-Single create mode 120000 Lang/PascalABC.NET/Input-loop create mode 120000 Lang/PascalABC.NET/Integer-comparison create mode 120000 Lang/PascalABC.NET/JSON create mode 120000 Lang/PascalABC.NET/Jump-anywhere create mode 120000 Lang/PascalABC.NET/Knuth-shuffle create mode 120000 Lang/PascalABC.NET/Least-common-multiple create mode 120000 Lang/PascalABC.NET/List-comprehensions create mode 120000 Lang/PascalABC.NET/Literals-Floating-point create mode 120000 Lang/PascalABC.NET/Literals-String create mode 120000 Lang/PascalABC.NET/Longest-common-subsequence create mode 120000 Lang/PascalABC.NET/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/PascalABC.NET/Loops-Break create mode 120000 Lang/PascalABC.NET/Loops-Continue create mode 120000 Lang/PascalABC.NET/Loops-Do-while create mode 120000 Lang/PascalABC.NET/Loops-Downward-for create mode 120000 Lang/PascalABC.NET/Loops-For create mode 120000 Lang/PascalABC.NET/Loops-For-with-a-specified-step create mode 120000 Lang/PascalABC.NET/Loops-Foreach create mode 120000 Lang/PascalABC.NET/Loops-Increment-loop-index-within-loop-body create mode 120000 Lang/PascalABC.NET/Loops-N-plus-one-half create mode 120000 Lang/PascalABC.NET/Loops-Nested create mode 120000 Lang/PascalABC.NET/Loops-While create mode 120000 Lang/PascalABC.NET/Loops-With-multiple-ranges create mode 120000 Lang/PascalABC.NET/Loops-Wrong-ranges create mode 120000 Lang/PascalABC.NET/Man-or-boy-test create mode 120000 Lang/PascalABC.NET/Memory-allocation create mode 120000 Lang/PascalABC.NET/Mouse-position create mode 120000 Lang/PascalABC.NET/Nested-function create mode 120000 Lang/PascalABC.NET/Nth create mode 120000 Lang/PascalABC.NET/Null-object create mode 120000 Lang/PascalABC.NET/Object-serialization create mode 120000 Lang/PascalABC.NET/Palindrome-detection create mode 120000 Lang/PascalABC.NET/Parametric-polymorphism create mode 120000 Lang/PascalABC.NET/Pick-random-element create mode 120000 Lang/PascalABC.NET/Pointers-and-references create mode 120000 Lang/PascalABC.NET/Polymorphic-copy create mode 120000 Lang/PascalABC.NET/Polymorphism create mode 120000 Lang/PascalABC.NET/Power-set create mode 120000 Lang/PascalABC.NET/Primality-by-trial-division create mode 120000 Lang/PascalABC.NET/Prime-decomposition create mode 120000 Lang/PascalABC.NET/Program-name create mode 120000 Lang/PascalABC.NET/Program-termination create mode 120000 Lang/PascalABC.NET/Queue-Definition create mode 120000 Lang/PascalABC.NET/Queue-Usage create mode 120000 Lang/PascalABC.NET/Quine create mode 120000 Lang/PascalABC.NET/Quoting-constructs create mode 120000 Lang/PascalABC.NET/Radical-of-an-integer create mode 120000 Lang/PascalABC.NET/Read-a-file-character-by-character-UTF8 create mode 120000 Lang/PascalABC.NET/Read-a-file-line-by-line create mode 120000 Lang/PascalABC.NET/Read-a-specific-line-from-a-file create mode 120000 Lang/PascalABC.NET/Read-entire-file create mode 120000 Lang/PascalABC.NET/Real-constants-and-functions create mode 120000 Lang/PascalABC.NET/Reflection-List-methods create mode 120000 Lang/PascalABC.NET/Reflection-List-properties create mode 120000 Lang/PascalABC.NET/Regular-expressions create mode 120000 Lang/PascalABC.NET/Remove-duplicate-elements create mode 120000 Lang/PascalABC.NET/Remove-lines-from-a-file create mode 120000 Lang/PascalABC.NET/Rename-a-file create mode 120000 Lang/PascalABC.NET/Repeat create mode 120000 Lang/PascalABC.NET/Repeat-a-string create mode 120000 Lang/PascalABC.NET/Return-multiple-values create mode 120000 Lang/PascalABC.NET/Reverse-a-string create mode 120000 Lang/PascalABC.NET/Reverse-words-in-a-string create mode 120000 Lang/PascalABC.NET/Roman-numerals-Decode create mode 120000 Lang/PascalABC.NET/Roman-numerals-Encode create mode 120000 Lang/PascalABC.NET/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/PascalABC.NET/Rot-13 create mode 120000 Lang/PascalABC.NET/Scope-modifiers create mode 120000 Lang/PascalABC.NET/Send-an-unknown-method-call create mode 120000 Lang/PascalABC.NET/Sequence-of-primes-by-trial-division create mode 120000 Lang/PascalABC.NET/Sieve-of-Eratosthenes create mode 120000 Lang/PascalABC.NET/Simple-windowed-application create mode 120000 Lang/PascalABC.NET/Singly-linked-list-Element-definition create mode 120000 Lang/PascalABC.NET/Singly-linked-list-Element-insertion create mode 120000 Lang/PascalABC.NET/Sleep create mode 120000 Lang/PascalABC.NET/Sort-an-array-of-composite-structures create mode 120000 Lang/PascalABC.NET/Sort-an-integer-array create mode 120000 Lang/PascalABC.NET/Sort-three-variables create mode 120000 Lang/PascalABC.NET/Sort-using-a-custom-comparator create mode 120000 Lang/PascalABC.NET/Sorting-algorithms-Quicksort create mode 120000 Lang/PascalABC.NET/Special-variables create mode 120000 Lang/PascalABC.NET/Stack create mode 120000 Lang/PascalABC.NET/Stack-traces create mode 120000 Lang/PascalABC.NET/String-append create mode 120000 Lang/PascalABC.NET/String-case create mode 120000 Lang/PascalABC.NET/String-concatenation create mode 120000 Lang/PascalABC.NET/String-interpolation-included- create mode 120000 Lang/PascalABC.NET/String-length create mode 120000 Lang/PascalABC.NET/String-matching create mode 120000 Lang/PascalABC.NET/String-prepend create mode 120000 Lang/PascalABC.NET/Strip-a-set-of-characters-from-a-string create mode 120000 Lang/PascalABC.NET/Strip-block-comments create mode 120000 Lang/PascalABC.NET/Strip-comments-from-a-string create mode 120000 Lang/PascalABC.NET/Strip-control-codes-and-extended-characters-from-a-string create mode 120000 Lang/PascalABC.NET/Strip-whitespace-from-a-string-Top-and-tail create mode 120000 Lang/PascalABC.NET/Substitution-cipher create mode 120000 Lang/PascalABC.NET/Substring create mode 120000 Lang/PascalABC.NET/Substring-Top-and-tail create mode 120000 Lang/PascalABC.NET/Sudan-function create mode 120000 Lang/PascalABC.NET/Sum-and-product-of-an-array create mode 120000 Lang/PascalABC.NET/Sum-digits-of-an-integer create mode 120000 Lang/PascalABC.NET/Sum-multiples-of-3-and-5 create mode 120000 Lang/PascalABC.NET/Sum-of-a-series create mode 120000 Lang/PascalABC.NET/Sum-of-elements-below-main-diagonal-of-matrix create mode 120000 Lang/PascalABC.NET/Sum-of-squares create mode 120000 Lang/PascalABC.NET/Symmetric-difference create mode 120000 Lang/PascalABC.NET/System-time create mode 120000 Lang/PascalABC.NET/Take-notes-on-the-command-line create mode 120000 Lang/PascalABC.NET/Tau-function create mode 120000 Lang/PascalABC.NET/Tau-number create mode 120000 Lang/PascalABC.NET/Temperature-conversion create mode 120000 Lang/PascalABC.NET/Terminal-control-Clear-the-screen create mode 120000 Lang/PascalABC.NET/Terminal-control-Coloured-text create mode 120000 Lang/PascalABC.NET/Terminal-control-Cursor-movement create mode 120000 Lang/PascalABC.NET/Terminal-control-Cursor-positioning create mode 120000 Lang/PascalABC.NET/Terminal-control-Dimensions create mode 120000 Lang/PascalABC.NET/Terminal-control-Display-an-extended-character create mode 120000 Lang/PascalABC.NET/Terminal-control-Hiding-the-cursor create mode 120000 Lang/PascalABC.NET/Terminal-control-Ringing-the-terminal-bell create mode 120000 Lang/PascalABC.NET/Test-a-function create mode 120000 Lang/PascalABC.NET/Time-a-function create mode 120000 Lang/PascalABC.NET/Tokenize-a-string create mode 120000 Lang/PascalABC.NET/Top-rank-per-group create mode 120000 Lang/PascalABC.NET/Towers-of-Hanoi create mode 120000 Lang/PascalABC.NET/Trabb-Pardo-Knuth-algorithm create mode 120000 Lang/PascalABC.NET/Transliterate-English-text-using-the-Greek-alphabet create mode 120000 Lang/PascalABC.NET/Tree-datastructures create mode 120000 Lang/PascalABC.NET/Tree-traversal create mode 120000 Lang/PascalABC.NET/Trigonometric-functions create mode 120000 Lang/PascalABC.NET/Truncate-a-file create mode 120000 Lang/PascalABC.NET/Twos-complement create mode 120000 Lang/PascalABC.NET/URL-decoding create mode 120000 Lang/PascalABC.NET/URL-encoding create mode 120000 Lang/PascalABC.NET/Undefined-values create mode 120000 Lang/PascalABC.NET/Unicode-strings create mode 120000 Lang/PascalABC.NET/Unicode-variable-names create mode 120000 Lang/PascalABC.NET/User-input-Text create mode 120000 Lang/PascalABC.NET/Variables create mode 120000 Lang/PascalABC.NET/Variadic-function create mode 120000 Lang/PascalABC.NET/Vector create mode 120000 Lang/PascalABC.NET/Vector-products create mode 120000 Lang/PascalABC.NET/Walk-a-directory-Non-recursively create mode 120000 Lang/PascalABC.NET/Walk-a-directory-Recursively create mode 120000 Lang/PascalABC.NET/Window-creation create mode 120000 Lang/PascalABC.NET/Word-frequency create mode 120000 Lang/PascalABC.NET/Word-wrap create mode 120000 Lang/PascalABC.NET/Write-entire-file create mode 120000 Lang/PascalABC.NET/Write-to-Windows-event-log create mode 120000 Lang/PascalABC.NET/XML-DOM-serialization create mode 120000 Lang/PascalABC.NET/XML-Input create mode 120000 Lang/PascalABC.NET/XML-Output create mode 120000 Lang/PascalABC.NET/Zero-to-the-zero-power create mode 120000 Lang/Perl/Search-in-paragraphs-text create mode 120000 Lang/Prog8/Quine create mode 120000 Lang/PureBasic/M-bius-function create mode 120000 Lang/Python/Rhonda-numbers create mode 120000 Lang/QB64/Fibonacci-n-step-number-sequences create mode 120000 Lang/QB64/Multiple-regression create mode 120000 Lang/QB64/Price-fraction create mode 120000 Lang/QBasic/Display-a-linear-combination create mode 120000 Lang/QBasic/Fibonacci-n-step-number-sequences create mode 120000 Lang/QBasic/Jensens-Device create mode 120000 Lang/QBasic/Nested-templated-data create mode 120000 Lang/QBasic/Ramer-Douglas-Peucker-line-simplification create mode 120000 Lang/QBasic/Vector create mode 120000 Lang/Quackery/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Quackery/Distribution-of-0-digits-in-factorial-series create mode 120000 Lang/Quackery/Dutch-national-flag-problem create mode 120000 Lang/Quackery/Flipping-bits-game create mode 120000 Lang/Quackery/Minimum-multiple-of-m-where-digital-sum-equals-m create mode 120000 Lang/Quackery/Password-generator create mode 120000 Lang/Quackery/Solve-the-no-connection-puzzle create mode 120000 Lang/QuickBASIC/Function-definition create mode 120000 Lang/QuickBASIC/Monty-Hall-problem create mode 120000 Lang/QuickBASIC/Random-numbers create mode 120000 Lang/QuickBASIC/Sorting-algorithms-Quicksort create mode 120000 Lang/R/Arithmetic-derivative create mode 120000 Lang/R/Compare-length-of-two-strings create mode 120000 Lang/R/Conjugate-transpose create mode 120000 Lang/R/Golden-ratio-Convergence create mode 120000 Lang/REXX/Eulers-constant-0.5772... create mode 120000 Lang/Refal/Copy-stdin-to-stdout create mode 120000 Lang/Refal/Damm-algorithm create mode 120000 Lang/Refal/Determine-sentence-type create mode 120000 Lang/Refal/Disarium-numbers create mode 120000 Lang/Refal/Discordian-date create mode 120000 Lang/Refal/Factors-of-an-integer create mode 120000 Lang/Refal/Flatten-a-list create mode 120000 Lang/Refal/General-FizzBuzz create mode 120000 Lang/Refal/Letter-frequency create mode 120000 Lang/Refal/McNuggets-problem create mode 120000 Lang/Refal/Nested-templated-data create mode 120000 Lang/Refal/One-dimensional-cellular-automata create mode 120000 Lang/Refal/Palindrome-detection create mode 120000 Lang/Refal/Population-count create mode 120000 Lang/Refal/Repeat create mode 120000 Lang/Refal/Split-a-character-string-based-on-change-of-character create mode 120000 Lang/Refal/Square-but-not-cube create mode 120000 Lang/Refal/Word-ladder create mode 120000 Lang/Run-BASIC/Nested-templated-data create mode 120000 Lang/S-BASIC/Copy-a-string create mode 120000 Lang/S-BASIC/Factorial create mode 120000 Lang/S-BASIC/Loops-Break create mode 120000 Lang/SETL/Brilliant-numbers create mode 120000 Lang/SETL/Damm-algorithm create mode 120000 Lang/SETL/General-FizzBuzz create mode 120000 Lang/SETL/Levenshtein-distance create mode 120000 Lang/SETL/Luhn-test-of-credit-card-numbers create mode 120000 Lang/SETL/Monty-Hall-problem create mode 120000 Lang/SETL/Nested-templated-data create mode 120000 Lang/SETL/Ordered-words create mode 120000 Lang/SETL/Pisano-period create mode 120000 Lang/SETL/Show-ASCII-table create mode 120000 Lang/SETL/Split-a-character-string-based-on-change-of-character create mode 120000 Lang/SETL/Word-ladder create mode 120000 Lang/Sidef/Increasing-gaps-between-consecutive-Niven-numbers create mode 120000 Lang/Sidef/Jaro-Winkler-distance create mode 120000 Lang/Sidef/Prime-numbers-whose-neighboring-pairs-are-tetraprimes create mode 120000 Lang/Sidef/Smarandache-Wellin-primes create mode 120000 Lang/Sidef/Wagstaff-primes create mode 120000 Lang/Standard-ML/Call-a-foreign-language-function create mode 120000 Lang/Standard-ML/Pi delete mode 120000 Lang/SuperCollider/Semordnilap create mode 120000 Lang/Swift/Compare-length-of-two-strings create mode 120000 Lang/Swift/Pseudo-random-numbers-Splitmix64 delete mode 120000 Lang/Transd/Compare-length-of-two-strings create mode 120000 Lang/True-BASIC/100-prisoners create mode 120000 Lang/True-BASIC/Multiple-regression create mode 120000 Lang/True-BASIC/Vector create mode 120000 Lang/TypeScript/Deal-cards-for-FreeCell create mode 120000 Lang/UNIX-Shell/Pi create mode 120000 Lang/UNIX-Shell/Trabb-Pardo-Knuth-algorithm create mode 120000 Lang/Uiua/15-puzzle-solver create mode 120000 Lang/Uiua/ADFGVX-cipher create mode 120000 Lang/Uiua/ASCII-art-diagram-converter create mode 120000 Lang/Uiua/Abbreviations-automatic create mode 120000 Lang/Uiua/Abelian-sandpile-model create mode 120000 Lang/Uiua/Align-columns create mode 120000 Lang/Uiua/Anti-primes create mode 120000 Lang/Uiua/Arithmetic-geometric-mean create mode 120000 Lang/Uiua/Array-concatenation create mode 120000 Lang/Uiua/Array-length create mode 120000 Lang/Uiua/Ascending-primes create mode 120000 Lang/Uiua/Averages-Mean-time-of-day create mode 120000 Lang/Uiua/Barnsley-fern create mode 120000 Lang/Uiua/Benfords-law create mode 120000 Lang/Uiua/Bifid-cipher create mode 120000 Lang/Uiua/Binary-digits create mode 120000 Lang/Uiua/Bulls-and-cows-Player create mode 120000 Lang/Uiua/CSV-data-manipulation create mode 120000 Lang/Uiua/Calkin-Wilf-sequence create mode 120000 Lang/Uiua/Cartesian-product-of-two-or-more-lists create mode 120000 Lang/Uiua/Combinations create mode 120000 Lang/Uiua/Convert-seconds-to-compound-duration create mode 120000 Lang/Uiua/Conways-Game-of-Life create mode 120000 Lang/Uiua/Determine-if-a-string-is-collapsible create mode 120000 Lang/Uiua/Dutch-national-flag-problem create mode 120000 Lang/Uiua/Factorial create mode 120000 Lang/Uiua/Factors-of-an-integer create mode 120000 Lang/Uiua/Find-the-missing-permutation create mode 120000 Lang/Uiua/Flatten-a-list create mode 120000 Lang/Uiua/Flipping-bits-game create mode 120000 Lang/Uiua/Forest-fire create mode 120000 Lang/Uiua/Greatest-common-divisor create mode 120000 Lang/Uiua/Identity-matrix create mode 120000 Lang/Uiua/Increment-a-numerical-string create mode 120000 Lang/Uiua/Integer-sequence create mode 120000 Lang/Uiua/Langtons-ant create mode 120000 Lang/Uiua/Largest-int-from-concatenated-ints create mode 120000 Lang/Uiua/Least-common-multiple create mode 120000 Lang/Uiua/Levenshtein-distance create mode 120000 Lang/Uiua/List-comprehensions create mode 120000 Lang/Uiua/Look-and-say-sequence create mode 120000 Lang/Uiua/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/Uiua/Luhn-test-of-credit-card-numbers create mode 120000 Lang/Uiua/Mandelbrot-set create mode 120000 Lang/Uiua/Matrix-multiplication create mode 120000 Lang/Uiua/Maze-solving create mode 120000 Lang/Uiua/McNuggets-problem create mode 120000 Lang/Uiua/Middle-three-digits create mode 120000 Lang/Uiua/Motzkin-numbers create mode 120000 Lang/Uiua/N-queens-problem create mode 120000 Lang/Uiua/Numbers-which-are-not-the-sum-of-distinct-squares create mode 120000 Lang/Uiua/One-dimensional-cellular-automata create mode 120000 Lang/Uiua/Ordered-words create mode 120000 Lang/Uiua/Permutations create mode 120000 Lang/Uiua/Pick-random-element create mode 120000 Lang/Uiua/RPG-attributes-generator create mode 120000 Lang/Uiua/Random-numbers create mode 120000 Lang/Uiua/Run-length-encoding create mode 120000 Lang/Uiua/Smith-numbers create mode 120000 Lang/Uiua/Solve-a-Hidato-puzzle create mode 120000 Lang/Uiua/Solve-a-Numbrix-puzzle create mode 120000 Lang/Uiua/Sort-disjoint-sublist create mode 120000 Lang/Uiua/Split-a-character-string-based-on-change-of-character create mode 120000 Lang/Uiua/Square-free-integers create mode 120000 Lang/Uiua/Stem-and-leaf-plot create mode 120000 Lang/Uiua/String-case create mode 120000 Lang/Uiua/String-concatenation create mode 120000 Lang/Uiua/String-interpolation-included- create mode 120000 Lang/Uiua/String-matching create mode 120000 Lang/Uiua/Strip-a-set-of-characters-from-a-string create mode 120000 Lang/Uiua/Sudoku create mode 120000 Lang/Uiua/Sum-multiples-of-3-and-5 create mode 120000 Lang/Uiua/Summarize-primes create mode 120000 Lang/Uiua/Test-a-function create mode 120000 Lang/Uiua/Truncatable-primes create mode 120000 Lang/Uiua/Validate-International-Securities-Identification-Number create mode 120000 Lang/Uiua/Water-collected-between-towers create mode 120000 Lang/Uiua/Yellowstone-sequence create mode 120000 Lang/Uiua/Zebra-puzzle create mode 120000 Lang/Uxntal/Quine create mode 120000 Lang/Uxntal/Weird-numbers create mode 120000 Lang/Vim-Script/Hello-world-Graphical create mode 120000 Lang/Vim-Script/Here-document create mode 120000 Lang/Vim-Script/Loop-over-multiple-arrays-simultaneously create mode 120000 Lang/Vim-Script/Loops-For create mode 120000 Lang/Vim-Script/XML-Input create mode 120000 Lang/XBasic/Euler-method create mode 120000 Lang/XBasic/M-bius-function create mode 120000 Lang/XBasic/Nim-game create mode 120000 Lang/XBasic/Sorting-algorithms-Quicksort create mode 120000 Lang/XPL0/Draw-a-clock create mode 120000 Lang/XPL0/Poker-hand-analyser create mode 120000 Lang/Yabasic/Display-a-linear-combination create mode 120000 Lang/Yabasic/Kronecker-product create mode 120000 Lang/Yabasic/Multiple-regression create mode 120000 Lang/Yabasic/Nested-templated-data create mode 120000 Lang/Yabasic/Sexy-primes create mode 120000 Lang/Yabasic/Sorting-algorithms-Counting-sort create mode 120000 Lang/Yabasic/Sorting-algorithms-Stooge-sort create mode 120000 Lang/Zig/15-puzzle-game create mode 120000 Lang/Zig/9-billion-names-of-God-the-integer create mode 120000 Lang/Zig/A+B create mode 120000 Lang/Zig/Determine-if-a-string-is-numeric create mode 120000 Lang/Zig/Egyptian-division create mode 120000 Lang/Zig/Integer-sequence create mode 120000 Lang/Zig/Monty-Hall-problem create mode 120000 Lang/Zig/Solve-the-no-connection-puzzle create mode 100644 Task/100-doors/APL/100-doors-3.apl delete mode 100644 Task/100-doors/Oberon/100-doors.oberon create mode 100644 Task/100-doors/V-(Vlang)/100-doors-3.v create mode 100644 Task/100-prisoners/Ecstasy/100-prisoners.ecstasy create mode 100644 Task/100-prisoners/True-BASIC/100-prisoners.basic create mode 100644 Task/15-puzzle-game/PascalABC.NET/15-puzzle-game.pas create mode 100644 Task/15-puzzle-game/Zig/15-puzzle-game.zig create mode 100644 Task/15-puzzle-solver/Dart/15-puzzle-solver.dart create mode 100644 Task/15-puzzle-solver/Uiua/15-puzzle-solver.uiua create mode 100644 Task/2048/Jq/2048.jq create mode 100644 Task/24-game/Frink/24-game.frink create mode 100644 Task/24-game/FutureBasic/24-game.basic create mode 100644 Task/24-game/Jq/24-game.jq rename Task/4-rings-or-4-squares-puzzle/V-(Vlang)/{4-rings-or-4-squares-puzzle.v => 4-rings-or-4-squares-puzzle-1.v} (100%) create mode 100644 Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-2.v create mode 100644 Task/4-rings-or-4-squares-puzzle/Zig/4-rings-or-4-squares-puzzle-6.zig create mode 100644 Task/9-billion-names-of-God-the-integer/Zig/9-billion-names-of-god-the-integer-1.zig create mode 100644 Task/9-billion-names-of-God-the-integer/Zig/9-billion-names-of-god-the-integer-2.zig create mode 100644 Task/99-bottles-of-beer/8th/99-bottles-of-beer-1.8th create mode 100644 Task/99-bottles-of-beer/8th/99-bottles-of-beer-2.8th delete mode 100644 Task/99-bottles-of-beer/8th/99-bottles-of-beer.8th rename Task/99-bottles-of-beer/Oxygene/{99-bottles-of-beer.oxy => 99-bottles-of-beer-1.oxy} (100%) create mode 100644 Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-2.oxy create mode 100644 Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-1.pas create mode 100644 Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-2.pas create mode 100644 Task/A+B/PascalABC.NET/a+b.pas create mode 100644 Task/A+B/Zig/a+b.zig create mode 100644 Task/ADFGVX-cipher/Uiua/adfgvx-cipher.uiua create mode 100644 Task/ASCII-art-diagram-converter/FutureBasic/ascii-art-diagram-converter.basic create mode 100644 Task/ASCII-art-diagram-converter/Uiua/ascii-art-diagram-converter.uiua create mode 100644 Task/Abbreviations-automatic/Emacs-Lisp/abbreviations-automatic.l create mode 100644 Task/Abbreviations-automatic/Uiua/abbreviations-automatic.uiua create mode 100644 Task/Abelian-sandpile-model-Identity/EasyLang/abelian-sandpile-model-identity.easy create mode 100644 Task/Abelian-sandpile-model/Ada/abelian-sandpile-model.ada create mode 100644 Task/Abelian-sandpile-model/EasyLang/abelian-sandpile-model.easy create mode 100644 Task/Abelian-sandpile-model/Locomotive-Basic/abelian-sandpile-model.basic create mode 100644 Task/Abelian-sandpile-model/Uiua/abelian-sandpile-model.uiua create mode 100644 Task/Abstract-type/PascalABC.NET/abstract-type-1.pas create mode 100644 Task/Abstract-type/PascalABC.NET/abstract-type-2.pas create mode 100644 Task/Accumulator-factory/PascalABC.NET/accumulator-factory.pas create mode 100644 Task/Achilles-numbers/Ada/achilles-numbers.ada create mode 100644 Task/Ackermann-function/PascalABC.NET/ackermann-function.pas create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/C++/add-a-variable-to-a-class-instance-at-runtime.cpp create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/PascalABC.NET/add-a-variable-to-a-class-instance-at-runtime.pas create mode 100644 Task/Additive-primes/C-sharp/additive-primes.cs create mode 100644 Task/Additive-primes/Modula-3/additive-primes.mod3 create mode 100644 Task/Address-of-a-variable/PascalABC.NET/address-of-a-variable.pas create mode 100644 Task/Align-columns/Uiua/align-columns.uiua create mode 100644 Task/Anagrams/Emacs-Lisp/anagrams-1.l create mode 100644 Task/Anagrams/Emacs-Lisp/anagrams-2.l create mode 100644 Task/Anagrams/PascalABC.NET/anagrams.pas create mode 100644 Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-1.pas create mode 100644 Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-2.pas create mode 100644 Task/Anti-primes/Uiua/anti-primes.uiua create mode 100644 Task/Apply-a-callback-to-an-array/PascalABC.NET/apply-a-callback-to-an-array.pas create mode 100644 Task/Approximate-equality/EasyLang/approximate-equality.easy create mode 100644 Task/Arbitrary-precision-integers-included-/FutureBasic/arbitrary-precision-integers-included-.basic create mode 100644 Task/Arena-storage-pool/Java/arena-storage-pool.java create mode 100644 Task/Arithmetic-Complex/EasyLang/arithmetic-complex.easy create mode 100644 Task/Arithmetic-Complex/PascalABC.NET/arithmetic-complex.pas create mode 100644 Task/Arithmetic-Integer/PascalABC.NET/arithmetic-integer.pas create mode 100644 Task/Arithmetic-derivative/R/arithmetic-derivative.r create mode 100644 Task/Arithmetic-geometric-mean-Calculate-Pi/Ada/arithmetic-geometric-mean-calculate-pi.ada create mode 100644 Task/Arithmetic-geometric-mean/Uiua/arithmetic-geometric-mean.uiua create mode 100644 Task/Array-concatenation/PascalABC.NET/array-concatenation.pas create mode 100644 Task/Array-concatenation/Uiua/array-concatenation.uiua rename Task/Array-length/PascalABC.NET/{array-length.pas => array-length-1.pas} (100%) create mode 100644 Task/Array-length/PascalABC.NET/array-length-2.pas create mode 100644 Task/Array-length/Uiua/array-length.uiua create mode 100644 Task/Arrays/PascalABC.NET/arrays.pas create mode 100644 Task/Ascending-primes/Ada/ascending-primes.ada create mode 100644 Task/Ascending-primes/Uiua/ascending-primes.uiua create mode 100644 Task/Assertions/Ecstasy/assertions.ecstasy create mode 100644 Task/Assertions/PascalABC.NET/assertions.pas create mode 100644 Task/Associative-array-Creation/PascalABC.NET/associative-array-creation.pas create mode 100644 Task/Associative-array-Iteration/PascalABC.NET/associative-array-iteration.pas create mode 100644 Task/Averages-Mean-time-of-day/Uiua/averages-mean-time-of-day.uiua create mode 100644 Task/Averages-Simple-moving-average/Jq/averages-simple-moving-average.jq create mode 100644 Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-1.basic create mode 100644 Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-2.basic create mode 100644 Task/Babbage-problem/EMal/babbage-problem.emal create mode 100644 Task/Babbage-problem/Langur/babbage-problem.langur create mode 100644 Task/Balanced-brackets/PascalABC.NET/balanced-brackets.pas create mode 100644 Task/Barnsley-fern/Uiua/barnsley-fern.uiua create mode 100644 Task/Benfords-law/Uiua/benfords-law.uiua create mode 100644 Task/Bifid-cipher/EMal/bifid-cipher.emal create mode 100644 Task/Bifid-cipher/Uiua/bifid-cipher-1.uiua create mode 100644 Task/Bifid-cipher/Uiua/bifid-cipher-2.uiua create mode 100644 Task/Bin-given-limits/Free-Pascal-Lazarus/bin-given-limits.pas create mode 100644 Task/Binary-digits/PascalABC.NET/binary-digits.pas create mode 100644 Task/Binary-digits/Uiua/binary-digits.uiua create mode 100644 Task/Binary-search/PascalABC.NET/binary-search.pas create mode 100644 Task/Biorhythms/FutureBasic/biorhythms.basic create mode 100644 Task/Bitcoin-address-validation/C++/bitcoin-address-validation.cpp rename Task/Bitcoin-address-validation/Java/{bitcoin-address-validation.java => bitcoin-address-validation-1.java} (100%) create mode 100644 Task/Bitcoin-address-validation/Java/bitcoin-address-validation-2.java create mode 100644 Task/Bitcoin-public-point-to-address/C++/bitcoin-public-point-to-address.cpp create mode 100644 Task/Bitcoin-public-point-to-address/Java/bitcoin-public-point-to-address.java create mode 100644 Task/Bitmap/POV-Ray/bitmap.povray create mode 100644 Task/Bitwise-operations/Jq/bitwise-operations.jq create mode 100644 Task/Bitwise-operations/PascalABC.NET/bitwise-operations.pas create mode 100644 Task/Blum-integer/Common-Lisp/blum-integer.lisp create mode 100644 Task/Brace-expansion/Ada/brace-expansion.ada create mode 100644 Task/Break-OO-privacy/PascalABC.NET/break-oo-privacy.pas create mode 100644 Task/Brilliant-numbers/FutureBasic/brilliant-numbers.basic create mode 100644 Task/Brilliant-numbers/SETL/brilliant-numbers.setl create mode 100644 Task/Bulls-and-cows-Player/Uiua/bulls-and-cows-player.uiua create mode 100644 Task/CRC-32/Jq/crc-32-1.jq create mode 100644 Task/CRC-32/Jq/crc-32-2.jq create mode 100644 Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas create mode 100644 Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua create mode 100644 Task/Caesar-cipher/Elm/caesar-cipher.elm create mode 100644 Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas create mode 100644 Task/Calkin-Wilf-sequence/Uiua/calkin-wilf-sequence.uiua create mode 100644 Task/Call-a-foreign-language-function/Standard-ML/call-a-foreign-language-function.ml delete mode 100644 Task/Call-a-function/Langur/call-a-function-7.langur create mode 100644 Task/Call-an-object-method/PascalABC.NET/call-an-object-method.pas create mode 100644 Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua create mode 100644 Task/Catmull-Clark-subdivision-surface/C++/catmull-clark-subdivision-surface.cpp create mode 100644 Task/Catmull-Clark-subdivision-surface/Java/catmull-clark-subdivision-surface.java create mode 100644 Task/Character-codes/PascalABC.NET/character-codes.pas create mode 100644 Task/Check-output-device-is-a-terminal/FutureBasic/check-output-device-is-a-terminal.basic create mode 100644 Task/Classes/PascalABC.NET/classes.pas create mode 100644 Task/Closest-pair-problem/PascalABC.NET/closest-pair-problem.pas create mode 100644 Task/Closures-Value-capture/Free-Pascal-Lazarus/closures-value-capture.pas rename Task/Closures-Value-capture/Go/{closures-value-capture.go => closures-value-capture-1.go} (100%) create mode 100644 Task/Closures-Value-capture/Go/closures-value-capture-2.go create mode 100644 Task/Collections/PascalABC.NET/collections.pas create mode 100644 Task/Color-wheel/Ada/color-wheel.ada create mode 100644 Task/Combinations-and-permutations/Ada/combinations-and-permutations.ada create mode 100644 Task/Combinations/FutureBasic/combinations.basic create mode 100644 Task/Combinations/J/combinations-10.j create mode 100644 Task/Combinations/J/combinations-8.j create mode 100644 Task/Combinations/J/combinations-9.j create mode 100644 Task/Combinations/Uiua/combinations.uiua create mode 100644 Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas create mode 100644 Task/Comments/PascalABC.NET/comments.pas create mode 100644 Task/Compare-a-list-of-strings/PascalABC.NET/compare-a-list-of-strings.pas create mode 100644 Task/Compare-length-of-two-strings/Emacs-Lisp/compare-length-of-two-strings.l create mode 100644 Task/Compare-length-of-two-strings/Kotlin/compare-length-of-two-strings.kotlin create mode 100644 Task/Compare-length-of-two-strings/PascalABC.NET/compare-length-of-two-strings.pas create mode 100644 Task/Compare-length-of-two-strings/R/compare-length-of-two-strings.r create mode 100644 Task/Compare-length-of-two-strings/Swift/compare-length-of-two-strings.swift delete mode 100644 Task/Compare-length-of-two-strings/Transd/compare-length-of-two-strings.transd create mode 100644 Task/Compiler-virtual-machine-interpreter/C++/compiler-virtual-machine-interpreter.cpp create mode 100644 Task/Compiler-virtual-machine-interpreter/Java/compiler-virtual-machine-interpreter.java create mode 100644 Task/Compound-data-type/PascalABC.NET/compound-data-type.pas create mode 100644 Task/Concurrent-computing/PascalABC.NET/concurrent-computing.pas create mode 100644 Task/Conditional-structures/PascalABC.NET/conditional-structures.pas create mode 100644 Task/Conjugate-transpose/R/conjugate-transpose.r create mode 100644 Task/Constrained-genericity/FreeBASIC/constrained-genericity.basic create mode 100644 Task/Constrained-genericity/PascalABC.NET/constrained-genericity.pas create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Jq/continued-fraction-arithmetic-construct-from-rational-number.jq create mode 100644 Task/Convert-seconds-to-compound-duration/Uiua/convert-seconds-to-compound-duration.uiua create mode 100644 Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua create mode 100644 Task/Copy-a-string/PascalABC.NET/copy-a-string.pas create mode 100644 Task/Copy-a-string/S-BASIC/copy-a-string.basic create mode 100644 Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic rename Task/Copy-stdin-to-stdout/Java/{copy-stdin-to-stdout.java => copy-stdin-to-stdout-1.java} (100%) create mode 100644 Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java create mode 100644 Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas create mode 100644 Task/Copy-stdin-to-stdout/Refal/copy-stdin-to-stdout.refal create mode 100644 Task/Count-in-factors/PascalABC.NET/count-in-factors.pas create mode 100644 Task/Count-in-octal/PascalABC.NET/count-in-octal.pas create mode 100644 Task/Count-occurrences-of-a-substring/PascalABC.NET/count-occurrences-of-a-substring.pas rename Task/Count-the-coins/Ada/{count-the-coins.ada => count-the-coins-1.ada} (100%) create mode 100644 Task/Count-the-coins/Ada/count-the-coins-2.ada create mode 100644 Task/Count-the-coins/Pascal/count-the-coins.pas create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/PascalABC.NET/create-a-two-dimensional-array-at-runtime.pas create mode 100644 Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas create mode 100644 Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs create mode 100644 Task/Damm-algorithm/ANSI-BASIC/damm-algorithm.basic rename Task/Damm-algorithm/{BASIC => GW-BASIC}/damm-algorithm.basic (100%) create mode 100644 Task/Damm-algorithm/Nascom-BASIC/damm-algorithm.basic create mode 100644 Task/Damm-algorithm/Refal/damm-algorithm.refal create mode 100644 Task/Damm-algorithm/SETL/damm-algorithm.setl delete mode 100644 Task/Date-format/Langur/date-format-3.langur create mode 100644 Task/Date-format/PascalABC.NET/date-format.pas create mode 100644 Task/Date-manipulation/Emacs-Lisp/date-manipulation-1.l create mode 100644 Task/Date-manipulation/Emacs-Lisp/date-manipulation-2.l create mode 100644 Task/Day-of-the-week/PascalABC.NET/day-of-the-week.pas create mode 100644 Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts create mode 100644 Task/Deconvolution-1D/Jq/deconvolution-1d.jq create mode 100644 Task/Define-a-primitive-data-type/PascalABC.NET/define-a-primitive-data-type.pas create mode 100644 Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua create mode 100644 Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.l create mode 100644 Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.l create mode 100644 Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas rename Task/Determine-if-a-string-is-numeric/Rust/{determine-if-a-string-is-numeric.rust => determine-if-a-string-is-numeric-1.rust} (100%) create mode 100644 Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-2.rust create mode 100644 Task/Determine-if-a-string-is-numeric/Zig/determine-if-a-string-is-numeric.zig create mode 100644 Task/Determine-sentence-type/Emacs-Lisp/determine-sentence-type.l create mode 100644 Task/Determine-sentence-type/FutureBasic/determine-sentence-type.basic create mode 100644 Task/Determine-sentence-type/PascalABC.NET/determine-sentence-type.pas create mode 100644 Task/Determine-sentence-type/Refal/determine-sentence-type.refal create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Quackery/dinesmans-multiple-dwelling-problem.quackery create mode 100644 Task/Disarium-numbers/Refal/disarium-numbers.refal create mode 100644 Task/Discordian-date/Refal/discordian-date.refal create mode 100644 Task/Display-a-linear-combination/APL/display-a-linear-combination.apl create mode 100644 Task/Display-a-linear-combination/Applesoft-BASIC/display-a-linear-combination.basic create mode 100644 Task/Display-a-linear-combination/Chipmunk-Basic/display-a-linear-combination.basic create mode 100644 Task/Display-a-linear-combination/Cowgol/display-a-linear-combination.cowgol create mode 100644 Task/Display-a-linear-combination/Draco/display-a-linear-combination.draco create mode 100644 Task/Display-a-linear-combination/GW-BASIC/display-a-linear-combination.basic create mode 100644 Task/Display-a-linear-combination/QBasic/display-a-linear-combination.basic create mode 100644 Task/Display-a-linear-combination/Yabasic/display-a-linear-combination.basic create mode 100644 Task/Display-an-outline-as-a-nested-table/Jq/display-an-outline-as-a-nested-table.jq create mode 100644 Task/Distribution-of-0-digits-in-factorial-series/Quackery/distribution-of-0-digits-in-factorial-series.quackery create mode 100644 Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas create mode 100644 Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas create mode 100644 Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas create mode 100644 Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas create mode 100644 Task/Dragon-curve/PascalABC.NET/dragon-curve.pas create mode 100644 Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 create mode 100644 Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg create mode 100644 Task/Draw-a-cuboid/Jq/draw-a-cuboid.jq create mode 100644 Task/Draw-a-cuboid/Locomotive-Basic/draw-a-cuboid.basic create mode 100644 Task/Draw-a-cuboid/PL-M/draw-a-cuboid.plm create mode 100644 Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas create mode 100644 Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas rename Task/Draw-a-sphere/Locomotive-Basic/{draw-a-sphere.basic => draw-a-sphere-1.basic} (100%) create mode 100644 Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic create mode 100644 Task/Dutch-national-flag-problem/Quackery/dutch-national-flag-problem.quackery create mode 100644 Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua create mode 100644 Task/Egyptian-division/Zig/egyptian-division.zig create mode 100644 Task/Empty-program/PascalABC.NET/empty-program.pas create mode 100644 Task/Entropy-Narcissist/Jq/entropy-narcissist.jq create mode 100644 Task/Enumerations/PascalABC.NET/enumerations.pas delete mode 100644 Task/Environment-variables/Langur/environment-variables-1.langur rename Task/Environment-variables/Langur/{environment-variables-2.langur => environment-variables.langur} (100%) create mode 100644 Task/Euler-method/XBasic/euler-method.basic create mode 100644 Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg create mode 100644 Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....ada create mode 100644 Task/Eulers-constant-0.5772.../REXX/eulers-constant-0.5772....rexx create mode 100644 Task/Even-or-odd/PascalABC.NET/even-or-odd.pas create mode 100644 Task/Exceptions/PascalABC.NET/exceptions-1.pas create mode 100644 Task/Exceptions/PascalABC.NET/exceptions-2.pas create mode 100644 Task/Exceptions/PascalABC.NET/exceptions-3.pas create mode 100644 Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic create mode 100644 Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic create mode 100644 Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic delete mode 100644 Task/Extend-your-language/Langur/extend-your-language-2.langur rename Task/Extend-your-language/Langur/{extend-your-language-1.langur => extend-your-language.langur} (86%) create mode 100644 Task/Extreme-floating-point-values/PascalABC.NET/extreme-floating-point-values.pas create mode 100644 Task/FTP/Ada/ftp.ada create mode 100644 Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++/factorial-base-numbers-indexing-permutations-of-a-collection.cpp create mode 100644 Task/Factorial-primes/Common-Lisp/factorial-primes.lisp create mode 100644 Task/Factorial-primes/Go/factorial-primes.go create mode 100644 Task/Factorial-primes/Kotlin/factorial-primes.kotlin create mode 100644 Task/Factorial/PascalABC.NET/factorial.pas create mode 100644 Task/Factorial/S-BASIC/factorial-1.basic create mode 100644 Task/Factorial/S-BASIC/factorial-2.basic create mode 100644 Task/Factorial/Uiua/factorial.uiua create mode 100644 Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq create mode 100644 Task/Factors-of-an-integer/PascalABC.NET/factors-of-an-integer.pas create mode 100644 Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal create mode 100644 Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua rename Task/Feigenbaum-constant-calculation/REXX/{feigenbaum-constant-calculation.rexx => feigenbaum-constant-calculation-1.rexx} (100%) create mode 100644 Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-2.rexx create mode 100644 Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic/fibonacci-n-step-number-sequences.basic create mode 100644 Task/Fibonacci-n-step-number-sequences/QB64/fibonacci-n-step-number-sequences.qb64 create mode 100644 Task/Fibonacci-n-step-number-sequences/QBasic/fibonacci-n-step-number-sequences.basic create mode 100644 Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs create mode 100644 Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-19.parigp create mode 100644 Task/File-input-output/PascalABC.NET/file-input-output.pas create mode 100644 Task/File-size-distribution/Jq/file-size-distribution.jq create mode 100644 Task/File-size/PascalABC.NET/file-size.pas create mode 100644 Task/Filter/PascalABC.NET/filter.pas create mode 100644 Task/Find-Chess960-starting-position-identifier/Jq/find-chess960-starting-position-identifier.jq create mode 100644 Task/Find-common-directory-path/K/find-common-directory-path.k create mode 100644 Task/Find-common-directory-path/PascalABC.NET/find-common-directory-path.pas create mode 100644 Task/Find-duplicate-files/Jq/find-duplicate-files.jq create mode 100644 Task/Find-limit-of-recursion/PascalABC.NET/find-limit-of-recursion.pas create mode 100644 Task/Find-the-intersection-of-two-lines/ALGOL-W/find-the-intersection-of-two-lines.alg create mode 100644 Task/Find-the-intersection-of-two-lines/Python/find-the-intersection-of-two-lines-4.py create mode 100644 Task/Find-the-missing-permutation/Uiua/find-the-missing-permutation.uiua create mode 100644 Task/First-class-functions/PascalABC.NET/first-class-functions.pas create mode 100644 Task/FizzBuzz/Common-Lisp/fizzbuzz-9.lisp delete mode 100644 Task/FizzBuzz/Langur/fizzbuzz-1.langur delete mode 100644 Task/FizzBuzz/Langur/fizzbuzz-2.langur create mode 100644 Task/FizzBuzz/Langur/fizzbuzz.langur create mode 100644 Task/FizzBuzz/PascalABC.NET/fizzbuzz.pas rename Task/Flatten-a-list/Emacs-Lisp/{flatten-a-list.l => flatten-a-list-1.l} (100%) create mode 100644 Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.l create mode 100644 Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas create mode 100644 Task/Flatten-a-list/Refal/flatten-a-list.refal create mode 100644 Task/Flatten-a-list/Uiua/flatten-a-list.uiua create mode 100644 Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery create mode 100644 Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua create mode 100644 Task/Flow-control-structures/Ada/flow-control-structures-4.ada create mode 100644 Task/Flow-control-structures/Ada/flow-control-structures-5.ada create mode 100644 Task/Floyds-triangle/FutureBasic/floyds-triangle.basic create mode 100644 Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas create mode 100644 Task/Forest-fire/Uiua/forest-fire.uiua create mode 100644 Task/Formatted-numeric-output/ANSI-BASIC/formatted-numeric-output.basic create mode 100644 Task/Formatted-numeric-output/PascalABC.NET/formatted-numeric-output.pas create mode 100644 Task/French-Republican-calendar/Jq/french-republican-calendar.jq create mode 100644 Task/Function-definition/ANSI-BASIC/function-definition.basic create mode 100644 Task/Function-definition/Chapel/function-definition-1.chapel create mode 100644 Task/Function-definition/Chapel/function-definition-2.chapel delete mode 100644 Task/Function-definition/Langur/function-definition-4.langur delete mode 100644 Task/Function-definition/Langur/function-definition-5.langur create mode 100644 Task/Function-definition/PascalABC.NET/function-definition.pas rename Task/Function-definition/{BASIC => QuickBASIC}/function-definition.basic (100%) create mode 100644 Task/Function-prototype/FutureBasic/function-prototype.basic create mode 100644 Task/Gamma-function/REXX/gamma-function-3.rexx create mode 100644 Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas create mode 100644 Task/General-FizzBuzz/Refal/general-fizzbuzz.refal create mode 100644 Task/General-FizzBuzz/SETL/general-fizzbuzz.setl create mode 100644 Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas create mode 100644 Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq create mode 100644 Task/Generic-swap/PascalABC.NET/generic-swap.pas create mode 100644 Task/Giuga-numbers/Jq/giuga-numbers.jq create mode 100644 Task/Go-Fish/FutureBasic/go-fish.basic create mode 100644 Task/Golden-ratio-Convergence/R/golden-ratio-convergence.r create mode 100644 Task/Graph-colouring/Jq/graph-colouring.jq rename Task/Gray-code/{BASIC => GW-BASIC}/gray-code.basic (100%) create mode 100644 Task/Gray-code/Modula-2/gray-code.mod2 create mode 100644 Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas rename Task/Greatest-common-divisor/{TypeScript/greatest-common-divisor-3.ts => Uiua/greatest-common-divisor.uiua} (100%) create mode 100644 Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy create mode 100644 Task/Guess-the-number-With-feedback-player-/EasyLang/guess-the-number-with-feedback-player-.easy create mode 100644 Task/Guess-the-number/PascalABC.NET/guess-the-number.pas create mode 100644 Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy create mode 100644 Task/Hamming-numbers/EasyLang/hamming-numbers.easy create mode 100644 Task/Harmonic-series/Bruijn/harmonic-series.bruijn create mode 100644 Task/Hash-from-two-arrays/PascalABC.NET/hash-from-two-arrays.pas rename Task/Hello-world-Graphical/{AutoHotKey-V2 => Autohotkey-V2}/hello-world-graphical.ahk (100%) create mode 100644 Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-1.vim create mode 100644 Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-2.vim create mode 100644 Task/Hello-world-Line-printer/PascalABC.NET/hello-world-line-printer.pas create mode 100644 Task/Hello-world-Newline-omission/PascalABC.NET/hello-world-newline-omission.pas create mode 100644 Task/Hello-world-Standard-error/PascalABC.NET/hello-world-standard-error.pas rename Task/Hello-world-Text/PascalABC.NET/{hello-world-text.pas => hello-world-text-1.pas} (100%) create mode 100644 Task/Hello-world-Text/PascalABC.NET/hello-world-text-2.pas create mode 100644 Task/Hello-world-Text/PascalABC.NET/hello-world-text-3.pas create mode 100644 Task/Here-document/Vim-Script/here-document-1.vim create mode 100644 Task/Here-document/Vim-Script/here-document-2.vim create mode 100644 Task/Hex-words/Ada/hex-words.ada create mode 100644 Task/Hofstadter-Figure-Figure-sequences/EasyLang/hofstadter-figure-figure-sequences.easy create mode 100644 Task/Honeycombs/FutureBasic/honeycombs.basic create mode 100644 Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c create mode 100644 Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur create mode 100644 Task/IBAN/EasyLang/iban.easy create mode 100644 Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml rename Task/ISBN13-check-digit/Standard-ML/{isbn13-check-digit.ml => isbn13-check-digit-2.ml} (98%) create mode 100644 Task/Identity-matrix/PascalABC.NET/identity-matrix.pas create mode 100644 Task/Identity-matrix/Uiua/identity-matrix.uiua create mode 100644 Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.ada create mode 100644 Task/Im-a-software-engineer-get-me-out-of-here/C++/im-a-software-engineer-get-me-out-of-here.cpp create mode 100644 Task/Im-a-software-engineer-get-me-out-of-here/Java/im-a-software-engineer-get-me-out-of-here.java create mode 100644 Task/Imaginary-base-numbers/FreeBASIC/imaginary-base-numbers.basic create mode 100644 Task/Include-a-file/PascalABC.NET/include-a-file-1.pas create mode 100644 Task/Include-a-file/PascalABC.NET/include-a-file-2.pas create mode 100644 Task/Increasing-gaps-between-consecutive-Niven-numbers/Sidef/increasing-gaps-between-consecutive-niven-numbers.sidef create mode 100644 Task/Increment-a-numerical-string/Uiua/increment-a-numerical-string.uiua create mode 100644 Task/Infinity/PascalABC.NET/infinity.pas create mode 100644 Task/Inheritance-Multiple/PascalABC.NET/inheritance-multiple.pas create mode 100644 Task/Inheritance-Single/PascalABC.NET/inheritance-single.pas create mode 100644 Task/Input-loop/PascalABC.NET/input-loop.pas create mode 100644 Task/Integer-comparison/PascalABC.NET/integer-comparison.pas rename Task/Integer-sequence/PascalABC.NET/{integer-sequence.pas => integer-sequence-1.pas} (100%) create mode 100644 Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas create mode 100644 Task/Integer-sequence/Uiua/integer-sequence.uiua create mode 100644 Task/Integer-sequence/Zig/integer-sequence.zig create mode 100644 Task/Introspection/Jq/introspection.jq create mode 100644 Task/Iterated-digits-squaring/EasyLang/iterated-digits-squaring.easy create mode 100644 Task/JSON/PascalABC.NET/json.pas create mode 100644 Task/Jaro-Winkler-distance/Sidef/jaro-winkler-distance.sidef create mode 100644 Task/Jensens-Device/Asymptote/jensens-device.asymptote create mode 100644 Task/Jensens-Device/Chipmunk-Basic/jensens-device.basic create mode 100644 Task/Jensens-Device/Dart/jensens-device.dart create mode 100644 Task/Jensens-Device/GW-BASIC/jensens-device.basic create mode 100644 Task/Jensens-Device/Gambas/jensens-device.gambas create mode 100644 Task/Jensens-Device/Minimal-BASIC/jensens-device.basic create mode 100644 Task/Jensens-Device/QBasic/jensens-device.basic create mode 100644 Task/JortSort/EasyLang/jortsort.easy create mode 100644 Task/Jump-anywhere/PascalABC.NET/jump-anywhere.pas create mode 100644 Task/Knights-tour/Jq/knights-tour.jq create mode 100644 Task/Knuth-shuffle/PascalABC.NET/knuth-shuffle.pas create mode 100644 Task/Kronecker-product-based-fractals/EasyLang/kronecker-product-based-fractals.easy create mode 100644 Task/Kronecker-product/BASIC256/kronecker-product.basic create mode 100644 Task/Kronecker-product/EasyLang/kronecker-product.easy create mode 100644 Task/Kronecker-product/Yabasic/kronecker-product.basic create mode 100644 Task/Langtons-ant/Uiua/langtons-ant.uiua create mode 100644 Task/Largest-int-from-concatenated-ints/EasyLang/largest-int-from-concatenated-ints.easy create mode 100644 Task/Largest-int-from-concatenated-ints/Uiua/largest-int-from-concatenated-ints.uiua create mode 100644 Task/Largest-number-divisible-by-its-digits/Ada/largest-number-divisible-by-its-digits.ada rename Task/Largest-number-divisible-by-its-digits/C++/{largest-number-divisible-by-its-digits.cpp => largest-number-divisible-by-its-digits-1.cpp} (100%) create mode 100644 Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-2.cpp rename Task/Largest-number-divisible-by-its-digits/Java/{largest-number-divisible-by-its-digits.java => largest-number-divisible-by-its-digits-1.java} (100%) create mode 100644 Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-2.java create mode 100644 Task/Last-letter-first-letter/EasyLang/last-letter-first-letter.easy create mode 100644 Task/Least-common-multiple/PascalABC.NET/least-common-multiple.pas create mode 100644 Task/Least-common-multiple/Standard-ML/least-common-multiple-1.ml rename Task/Least-common-multiple/Standard-ML/{least-common-multiple.ml => least-common-multiple-2.ml} (100%) create mode 100644 Task/Least-common-multiple/Uiua/least-common-multiple.uiua create mode 100644 Task/Letter-frequency/Refal/letter-frequency.refal create mode 100644 Task/Levenshtein-distance-Alignment/Jq/levenshtein-distance-alignment.jq create mode 100644 Task/Levenshtein-distance/SETL/levenshtein-distance.setl create mode 100644 Task/Levenshtein-distance/Uiua/levenshtein-distance.uiua create mode 100644 Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas create mode 100644 Task/List-comprehensions/Uiua/list-comprehensions.uiua create mode 100644 Task/Literals-Floating-point/PascalABC.NET/literals-floating-point.pas create mode 100644 Task/Literals-String/PascalABC.NET/literals-string.pas create mode 100644 Task/Longest-common-subsequence/PascalABC.NET/longest-common-subsequence.pas create mode 100644 Task/Longest-increasing-subsequence/EasyLang/longest-increasing-subsequence.easy create mode 100644 Task/Look-and-say-sequence/ABC/look-and-say-sequence.abc create mode 100644 Task/Look-and-say-sequence/Uiua/look-and-say-sequence.uiua create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/PascalABC.NET/loop-over-multiple-arrays-simultaneously.pas create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/Python/loop-over-multiple-arrays-simultaneously-5.py create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/Uiua/loop-over-multiple-arrays-simultaneously.uiua create mode 100644 Task/Loop-over-multiple-arrays-simultaneously/Vim-Script/loop-over-multiple-arrays-simultaneously.vim create mode 100644 Task/Loops-Break/PascalABC.NET/loops-break.pas create mode 100644 Task/Loops-Break/S-BASIC/loops-break-1.basic create mode 100644 Task/Loops-Break/S-BASIC/loops-break-2.basic create mode 100644 Task/Loops-Continue/PascalABC.NET/loops-continue.pas create mode 100644 Task/Loops-Do-while/PascalABC.NET/loops-do-while.pas delete mode 100644 Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-2.basic rename Task/Loops-Do-while/Sinclair-ZX81-BASIC/{loops-do-while-1.basic => loops-do-while.basic} (100%) create mode 100644 Task/Loops-Downward-for/PascalABC.NET/loops-downward-for.pas create mode 100644 Task/Loops-For-with-a-specified-step/PascalABC.NET/loops-for-with-a-specified-step.pas create mode 100644 Task/Loops-For/PascalABC.NET/loops-for.pas create mode 100644 Task/Loops-For/Vim-Script/loops-for-1.vim create mode 100644 Task/Loops-For/Vim-Script/loops-for-2.vim create mode 100644 Task/Loops-Foreach/PascalABC.NET/loops-foreach.pas create mode 100644 Task/Loops-Increment-loop-index-within-loop-body/PascalABC.NET/loops-increment-loop-index-within-loop-body.pas create mode 100644 Task/Loops-N-plus-one-half/PascalABC.NET/loops-n-plus-one-half.pas create mode 100644 Task/Loops-Nested/PascalABC.NET/loops-nested.pas create mode 100644 Task/Loops-While/Mia/loops-while.mia create mode 100644 Task/Loops-While/PascalABC.NET/loops-while.pas create mode 100644 Task/Loops-With-multiple-ranges/PascalABC.NET/loops-with-multiple-ranges.pas create mode 100644 Task/Loops-Wrong-ranges/PascalABC.NET/loops-wrong-ranges.pas create mode 100644 Task/Ludic-numbers/EasyLang/ludic-numbers.easy create mode 100644 Task/Luhn-test-of-credit-card-numbers/SETL/luhn-test-of-credit-card-numbers.setl create mode 100644 Task/Luhn-test-of-credit-card-numbers/Uiua/luhn-test-of-credit-card-numbers.uiua create mode 100644 Task/M-bius-function/Gambas/m-bius-function.gambas create mode 100644 Task/M-bius-function/PureBasic/m-bius-function.basic create mode 100644 Task/M-bius-function/XBasic/m-bius-function.basic create mode 100644 Task/Magic-constant/Ada/magic-constant.ada delete mode 100644 Task/Make-directory-path/Seed7/make-directory-path-1.seed7 delete mode 100644 Task/Make-directory-path/Seed7/make-directory-path-2.seed7 create mode 100644 Task/Make-directory-path/Seed7/make-directory-path.seed7 create mode 100644 Task/Man-or-boy-test/PascalABC.NET/man-or-boy-test.pas create mode 100644 Task/Mandelbrot-set/Uiua/mandelbrot-set.uiua create mode 100644 Task/Map-range/EasyLang/map-range.easy create mode 100644 Task/Matrix-multiplication/Uiua/matrix-multiplication.uiua create mode 100644 Task/Mayan-calendar/Jq/mayan-calendar.jq create mode 100644 Task/Maze-generation/Chapel/maze-generation.chapel create mode 100644 Task/Maze-generation/POV-Ray/maze-generation.povray create mode 100644 Task/Maze-solving/Uiua/maze-solving.uiua create mode 100644 Task/McNuggets-problem/Refal/mcnuggets-problem.refal create mode 100644 Task/McNuggets-problem/Uiua/mcnuggets-problem.uiua create mode 100644 Task/Memory-allocation/PascalABC.NET/memory-allocation.pas create mode 100644 Task/Middle-three-digits/Uiua/middle-three-digits.uiua rename Task/Miller-Rabin-primality-test/REXX/{miller-rabin-primality-test.rexx => miller-rabin-primality-test-1.rexx} (100%) create mode 100644 Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-2.rexx create mode 100644 Task/Mind-boggling-card-trick/Ada/mind-boggling-card-trick.ada create mode 100644 Task/Mind-boggling-card-trick/Jq/mind-boggling-card-trick.jq create mode 100644 Task/Minimal-steps-down-to-1/Jq/minimal-steps-down-to-1.jq create mode 100644 Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Quackery/minimum-multiple-of-m-where-digital-sum-equals-m.quackery create mode 100644 Task/Modified-random-distribution/Jq/modified-random-distribution.jq create mode 100644 Task/Monty-Hall-problem/ANSI-BASIC/monty-hall-problem.basic create mode 100644 Task/Monty-Hall-problem/FutureBasic/monty-hall-problem.basic create mode 100644 Task/Monty-Hall-problem/K/monty-hall-problem.k create mode 100644 Task/Monty-Hall-problem/Minimal-BASIC/monty-hall-problem.basic create mode 100644 Task/Monty-Hall-problem/Modula-2/monty-hall-problem.mod2 rename Task/Monty-Hall-problem/{BASIC => QuickBASIC}/monty-hall-problem.basic (100%) create mode 100644 Task/Monty-Hall-problem/SETL/monty-hall-problem.setl create mode 100644 Task/Monty-Hall-problem/Zig/monty-hall-problem.zig create mode 100644 Task/Motzkin-numbers/Uiua/motzkin-numbers.uiua create mode 100644 Task/Mouse-position/PascalABC.NET/mouse-position.pas create mode 100644 Task/Move-to-front-algorithm/EasyLang/move-to-front-algorithm.easy create mode 100644 Task/Multiple-regression/BASIC256/multiple-regression.basic create mode 100644 Task/Multiple-regression/Chipmunk-Basic/multiple-regression.basic create mode 100644 Task/Multiple-regression/QB64/multiple-regression.qb64 create mode 100644 Task/Multiple-regression/True-BASIC/multiple-regression.basic create mode 100644 Task/Multiple-regression/Yabasic/multiple-regression.basic create mode 100644 Task/Multiplicative-order/Jq/multiplicative-order.jq create mode 100644 Task/Multisplit/EasyLang/multisplit.easy rename Task/Munchausen-numbers/Rust/{munchausen-numbers.rust => munchausen-numbers-1.rust} (100%) create mode 100644 Task/Munchausen-numbers/Rust/munchausen-numbers-2.rust create mode 100644 Task/Musical-scale/Ada/musical-scale.ada create mode 100644 Task/Mutual-recursion/EMal/mutual-recursion.emal create mode 100644 Task/N-queens-problem/C/n-queens-problem-5.c create mode 100644 Task/N-queens-problem/Commodore-BASIC/n-queens-problem.basic create mode 100644 Task/N-queens-problem/Pascal/n-queens-problem-3.pas create mode 100644 Task/N-queens-problem/Uiua/n-queens-problem.uiua create mode 100644 Task/Negative-base-numbers/EasyLang/negative-base-numbers.easy create mode 100644 Task/Nested-function/PL-M/nested-function.plm create mode 100644 Task/Nested-function/PascalABC.NET/nested-function.pas create mode 100644 Task/Nested-templated-data/BASIC256/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/Chipmunk-Basic/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/FreeBASIC/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/GW-BASIC/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/QBasic/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/Refal/nested-templated-data.refal create mode 100644 Task/Nested-templated-data/Run-BASIC/nested-templated-data.basic create mode 100644 Task/Nested-templated-data/SETL/nested-templated-data.setl create mode 100644 Task/Nested-templated-data/Yabasic/nested-templated-data.basic create mode 100644 Task/Next-highest-int-from-digits/Ada/next-highest-int-from-digits.ada create mode 100644 Task/Nim-game/COBOL/nim-game.cobol create mode 100644 Task/Nim-game/XBasic/nim-game.basic create mode 100644 Task/Non-continuous-subsequences/EasyLang/non-continuous-subsequences.easy create mode 100644 Task/Non-decimal-radices-Input/EasyLang/non-decimal-radices-input.easy create mode 100644 Task/Nonoblock/Jq/nonoblock.jq create mode 100644 Task/Nonogram-solver/Jq/nonogram-solver.jq create mode 100644 Task/Nth/PascalABC.NET/nth.pas create mode 100644 Task/Null-object/PascalABC.NET/null-object.pas create mode 100644 Task/Number-reversal-game/EasyLang/number-reversal-game.easy create mode 100644 Task/Numbers-which-are-not-the-sum-of-distinct-squares/Uiua/numbers-which-are-not-the-sum-of-distinct-squares.uiua create mode 100644 Task/Object-serialization/PascalABC.NET/object-serialization.pas create mode 100644 Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-3.c create mode 100644 Task/One-dimensional-cellular-automata/Refal/one-dimensional-cellular-automata.refal create mode 100644 Task/One-dimensional-cellular-automata/Uiua/one-dimensional-cellular-automata.uiua create mode 100644 Task/Ordered-words/BASIC/ordered-words.basic create mode 100644 Task/Ordered-words/Emacs-Lisp/ordered-words.l create mode 100644 Task/Ordered-words/SETL/ordered-words.setl create mode 100644 Task/Ordered-words/Uiua/ordered-words.uiua create mode 100644 Task/P-Adic-square-roots/C++/p-adic-square-roots.cpp create mode 100644 Task/P-Adic-square-roots/Java/p-adic-square-roots.java create mode 100644 Task/P-value-correction/Jq/p-value-correction.jq create mode 100644 Task/Padovan-sequence/FreeBASIC/padovan-sequence.basic rename Task/Palindrome-detection/Emacs-Lisp/{palindrome-detection.l => palindrome-detection-1.l} (100%) create mode 100644 Task/Palindrome-detection/Emacs-Lisp/palindrome-detection-2.l create mode 100644 Task/Palindrome-detection/PascalABC.NET/palindrome-detection.pas create mode 100644 Task/Palindrome-detection/Refal/palindrome-detection.refal rename Task/Palindrome-detection/Uiua/{palindrome-detection.uiua => palindrome-detection-1.uiua} (100%) create mode 100644 Task/Palindrome-detection/Uiua/palindrome-detection-2.uiua create mode 100644 Task/Palindromic-gapful-numbers/Jq/palindromic-gapful-numbers.jq create mode 100644 Task/Parallel-brute-force/Elixir/parallel-brute-force.elixir create mode 100644 Task/Parallel-calculations/Free-Pascal-Lazarus/parallel-calculations.pas create mode 100644 Task/Parametric-polymorphism/COBOL/parametric-polymorphism.cobol create mode 100644 Task/Parametric-polymorphism/PascalABC.NET/parametric-polymorphism.pas create mode 100644 Task/Partition-an-integer-x-into-n-primes/EasyLang/partition-an-integer-x-into-n-primes.easy create mode 100644 Task/Pascal-matrix-generation/EasyLang/pascal-matrix-generation.easy create mode 100644 Task/Password-generator/Quackery/password-generator.quackery create mode 100644 Task/Pathological-floating-point-problems/EasyLang/pathological-floating-point-problems.easy create mode 100644 Task/Peaceful-chess-queen-armies/Jq/peaceful-chess-queen-armies.jq create mode 100644 Task/Penneys-game/Ada/penneys-game.ada create mode 100644 Task/Pentomino-tiling/Jq/pentomino-tiling.jq create mode 100644 Task/Peripheral-drift-illusion/EasyLang/peripheral-drift-illusion.easy create mode 100644 Task/Perlin-noise/ALGOL-68/perlin-noise.alg create mode 100644 Task/Perlin-noise/Jq/perlin-noise.jq create mode 100644 Task/Permutations-Rank-of-a-permutation/EasyLang/permutations-rank-of-a-permutation.easy create mode 100644 Task/Permutations-by-swapping/Ada/permutations-by-swapping.ada create mode 100644 Task/Permutations/Uiua/permutations.uiua create mode 100644 Task/Phrase-reversals/EasyLang/phrase-reversals.easy create mode 100644 Task/Pi/AArch64-Assembly/pi.aarch64 create mode 100644 Task/Pi/ARM-Assembly/pi.arm create mode 100644 Task/Pi/Standard-ML/pi.ml create mode 100644 Task/Pi/UNIX-Shell/pi.sh create mode 100644 Task/Pick-random-element/PascalABC.NET/pick-random-element.pas create mode 100644 Task/Pick-random-element/Uiua/pick-random-element.uiua create mode 100644 Task/Pierpont-primes/EasyLang/pierpont-primes.easy create mode 100644 Task/Pig-the-dice-game-Player/C/pig-the-dice-game-player.c create mode 100644 Task/Pinstripe-Display/EasyLang/pinstripe-display.easy create mode 100644 Task/Pisano-period/APL/pisano-period.apl create mode 100644 Task/Pisano-period/Jq/pisano-period.jq create mode 100644 Task/Pisano-period/SETL/pisano-period.setl create mode 100644 Task/Plasma-effect/EasyLang/plasma-effect.easy create mode 100644 Task/Play-recorded-sounds/Ada/play-recorded-sounds.ada create mode 100644 Task/Pointers-and-references/Ecstasy/pointers-and-references.ecstasy create mode 100644 Task/Pointers-and-references/PascalABC.NET/pointers-and-references.pas create mode 100644 Task/Poker-hand-analyser/Ada/poker-hand-analyser.ada create mode 100644 Task/Poker-hand-analyser/Jq/poker-hand-analyser.jq create mode 100644 Task/Poker-hand-analyser/Liberty-BASIC/poker-hand-analyser.basic create mode 100644 Task/Poker-hand-analyser/XPL0/poker-hand-analyser.xpl0 create mode 100644 Task/Polymorphic-copy/PascalABC.NET/polymorphic-copy.pas create mode 100644 Task/Polymorphism/PascalABC.NET/polymorphism.pas create mode 100644 Task/Polynomial-regression/Jq/polynomial-regression.jq create mode 100644 Task/Population-count/ABC/population-count.abc create mode 100644 Task/Population-count/Refal/population-count.refal create mode 100644 Task/Power-set/PascalABC.NET/power-set.pas create mode 100644 Task/Price-fraction/Chipmunk-Basic/price-fraction.basic create mode 100644 Task/Price-fraction/Langur/price-fraction-1.langur create mode 100644 Task/Price-fraction/Langur/price-fraction-2.langur delete mode 100644 Task/Price-fraction/Langur/price-fraction.langur create mode 100644 Task/Price-fraction/QB64/price-fraction.qb64 create mode 100644 Task/Primality-by-trial-division/GW-BASIC/primality-by-trial-division.basic create mode 100644 Task/Primality-by-trial-division/PascalABC.NET/primality-by-trial-division.pas create mode 100644 Task/Prime-decomposition/PascalABC.NET/prime-decomposition.pas create mode 100644 Task/Prime-decomposition/REXX/prime-decomposition-3.rexx create mode 100644 Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/Sidef/prime-numbers-whose-neighboring-pairs-are-tetraprimes.sidef create mode 100644 Task/Program-name/Ecstasy/program-name.ecstasy create mode 100644 Task/Program-name/PascalABC.NET/program-name.pas create mode 100644 Task/Program-termination/PascalABC.NET/program-termination.pas create mode 100644 Task/Proper-divisors/Chipmunk-Basic/proper-divisors.basic create mode 100644 Task/Proper-divisors/Gambas/proper-divisors.gambas create mode 100644 Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/Jq/pseudo-random-numbers-combined-recursive-generator-mrg32k3a.jq create mode 100644 Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W/pseudo-random-numbers-middle-square-method.alg create mode 100644 Task/Pseudo-random-numbers-PCG32/FreeBASIC/pseudo-random-numbers-pcg32.basic create mode 100644 Task/Pseudo-random-numbers-PCG32/Jq/pseudo-random-numbers-pcg32.jq create mode 100644 Task/Pseudo-random-numbers-Splitmix64/FreeBASIC/pseudo-random-numbers-splitmix64.basic create mode 100644 Task/Pseudo-random-numbers-Splitmix64/Swift/pseudo-random-numbers-splitmix64.swift create mode 100644 Task/Pseudo-random-numbers-Xorshift-star/FreeBASIC/pseudo-random-numbers-xorshift-star.basic create mode 100644 Task/Pseudo-random-numbers-Xorshift-star/Jq/pseudo-random-numbers-xorshift-star.jq create mode 100644 Task/Pythagorean-quadruples/EasyLang/pythagorean-quadruples.easy create mode 100644 Task/Queue-Definition/PascalABC.NET/queue-definition.pas create mode 100644 Task/Queue-Usage/PascalABC.NET/queue-usage.pas create mode 100644 Task/Quine/Odin/quine.odin create mode 100644 Task/Quine/PascalABC.NET/quine.pas create mode 100644 Task/Quine/Prog8/quine.prog8 create mode 100644 Task/Quine/Uxntal/quine.uxnatl create mode 100644 Task/Quoting-constructs/PascalABC.NET/quoting-constructs-1.pas create mode 100644 Task/Quoting-constructs/PascalABC.NET/quoting-constructs-2.pas create mode 100644 Task/Quoting-constructs/PascalABC.NET/quoting-constructs-3.pas create mode 100644 Task/Quoting-constructs/PascalABC.NET/quoting-constructs-4.pas create mode 100644 Task/RPG-attributes-generator/Uiua/rpg-attributes-generator.uiua create mode 100644 Task/Radical-of-an-integer/PascalABC.NET/radical-of-an-integer.pas rename Task/Radical-of-an-integer/REXX/{radical-of-an-integer.rexx => radical-of-an-integer-1.rexx} (93%) create mode 100644 Task/Radical-of-an-integer/REXX/radical-of-an-integer-2.rexx create mode 100644 Task/Ramer-Douglas-Peucker-line-simplification/BASIC256/ramer-douglas-peucker-line-simplification.basic create mode 100644 Task/Ramer-Douglas-Peucker-line-simplification/Jq/ramer-douglas-peucker-line-simplification.jq create mode 100644 Task/Ramer-Douglas-Peucker-line-simplification/QBasic/ramer-douglas-peucker-line-simplification.basic create mode 100644 Task/Random-numbers/ANSI-BASIC/random-numbers.basic create mode 100644 Task/Random-numbers/QuickBASIC/random-numbers.basic create mode 100644 Task/Random-numbers/Uiua/random-numbers.uiua create mode 100644 Task/Random-sentence-from-book/Jq/random-sentence-from-book.jq create mode 100644 Task/Range-expansion/EasyLang/range-expansion.easy create mode 100644 Task/Rate-counter/Chipmunk-Basic/rate-counter.basic create mode 100644 Task/Read-a-file-character-by-character-UTF8/PascalABC.NET/read-a-file-character-by-character-utf8.pas create mode 100644 Task/Read-a-file-line-by-line/PascalABC.NET/read-a-file-line-by-line.pas create mode 100644 Task/Read-a-specific-line-from-a-file/PascalABC.NET/read-a-specific-line-from-a-file.pas create mode 100644 Task/Read-entire-file/PascalABC.NET/read-entire-file.pas create mode 100644 Task/Real-constants-and-functions/ANSI-BASIC/real-constants-and-functions.basic create mode 100644 Task/Real-constants-and-functions/PascalABC.NET/real-constants-and-functions.pas create mode 100644 Task/Record-sound/Ada/record-sound.ada create mode 100644 Task/Record-sound/FutureBasic/record-sound.basic create mode 100644 Task/Reflection-List-methods/Ecstasy/reflection-list-methods.ecstasy create mode 100644 Task/Reflection-List-methods/PascalABC.NET/reflection-list-methods.pas create mode 100644 Task/Reflection-List-properties/Ecstasy/reflection-list-properties.ecstasy create mode 100644 Task/Reflection-List-properties/PascalABC.NET/reflection-list-properties.pas create mode 100644 Task/Regular-expressions/PascalABC.NET/regular-expressions.pas create mode 100644 Task/Remove-duplicate-elements/PascalABC.NET/remove-duplicate-elements.pas create mode 100644 Task/Remove-lines-from-a-file/PascalABC.NET/remove-lines-from-a-file.pas create mode 100644 Task/Rename-a-file/PascalABC.NET/rename-a-file.pas create mode 100644 Task/Repeat-a-string/PascalABC.NET/repeat-a-string.pas create mode 100644 Task/Repeat/Applesoft-BASIC/repeat.basic create mode 100644 Task/Repeat/Chapel/repeat-1.chapel create mode 100644 Task/Repeat/Chapel/repeat-2.chapel create mode 100644 Task/Repeat/Chapel/repeat-3.chapel create mode 100644 Task/Repeat/PascalABC.NET/repeat.pas create mode 100644 Task/Repeat/Refal/repeat.refal create mode 100644 Task/Return-multiple-values/PascalABC.NET/return-multiple-values.pas create mode 100644 Task/Reverse-a-string/PascalABC.NET/reverse-a-string.pas create mode 100644 Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas create mode 100644 Task/Rhonda-numbers/Python/rhonda-numbers.py create mode 100644 Task/Rock-paper-scissors/EasyLang/rock-paper-scissors.easy create mode 100644 Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode.pas create mode 100644 Task/Roman-numerals-Encode/PascalABC.NET/roman-numerals-encode.pas create mode 100644 Task/Rosetta-Code-Rank-languages-by-number-of-users/Jq/rosetta-code-rank-languages-by-number-of-users.jq create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/PascalABC.NET/rosetta-code-rank-languages-by-popularity.pas create mode 100644 Task/Rot-13/PascalABC.NET/rot-13.pas create mode 100644 Task/Run-length-encoding/Uiua/run-length-encoding.uiua create mode 100644 Task/Runtime-evaluation-In-an-environment/FreeBASIC/runtime-evaluation-in-an-environment.basic create mode 100644 Task/Ruth-Aaron-numbers/EasyLang/ruth-aaron-numbers.easy create mode 100644 Task/Safe-addition/Langur/safe-addition.langur create mode 100644 Task/Sailors-coconuts-and-a-monkey-problem/EasyLang/sailors-coconuts-and-a-monkey-problem.easy create mode 100644 Task/Scope-Function-names-and-labels/EasyLang/scope-function-names-and-labels.easy create mode 100644 Task/Scope-modifiers/PascalABC.NET/scope-modifiers-1.pas create mode 100644 Task/Scope-modifiers/PascalABC.NET/scope-modifiers-2.pas create mode 100644 Task/Scope-modifiers/PascalABC.NET/scope-modifiers-3.pas create mode 100644 Task/Scope-modifiers/PascalABC.NET/scope-modifiers-4.pas create mode 100644 Task/Search-a-list/Ecstasy/search-a-list.ecstasy create mode 100644 Task/Search-in-paragraphs-text/Perl/search-in-paragraphs-text.pl create mode 100644 Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada/selectively-replace-multiple-instances-of-a-character-within-a-string.ada create mode 100644 Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang/selectively-replace-multiple-instances-of-a-character-within-a-string.easy create mode 100644 Task/Self-numbers/EasyLang/self-numbers.easy create mode 100644 Task/Semiprime/REXX/semiprime-4.rexx delete mode 100644 Task/Semordnilap/SuperCollider/semordnilap-1.sc delete mode 100644 Task/Semordnilap/SuperCollider/semordnilap-2.sc create mode 100644 Task/Send-an-unknown-method-call/Ecstasy/send-an-unknown-method-call.ecstasy create mode 100644 Task/Send-an-unknown-method-call/PascalABC.NET/send-an-unknown-method-call.pas create mode 100644 Task/Sequence-of-primes-by-trial-division/PascalABC.NET/sequence-of-primes-by-trial-division.pas create mode 100644 Task/Set-puzzle/Jq/set-puzzle.jq create mode 100644 Task/Set-right-adjacent-bits/Jq/set-right-adjacent-bits.jq create mode 100644 Task/Sexy-primes/BASIC256/sexy-primes.basic create mode 100644 Task/Sexy-primes/Yabasic/sexy-primes.basic create mode 100644 Task/Show-ASCII-table/SETL/show-ascii-table.setl create mode 100644 Task/Show-the-epoch/EasyLang/show-the-epoch.easy create mode 100644 Task/Sierpinski-pentagon/Jq/sierpinski-pentagon.jq create mode 100644 Task/Sierpinski-square-curve/Ada/sierpinski-square-curve.ada create mode 100644 Task/Sierpinski-triangle/EasyLang/sierpinski-triangle.easy create mode 100644 Task/Sieve-of-Eratosthenes/Erlang/sieve-of-eratosthenes-6.erl create mode 100644 Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-7.ocaml create mode 100644 Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-8.ocaml create mode 100644 Task/Sieve-of-Eratosthenes/PascalABC.NET/sieve-of-eratosthenes.pas create mode 100644 Task/Simple-database/C++/simple-database.cpp create mode 100644 Task/Simple-windowed-application/PascalABC.NET/simple-windowed-application.pas create mode 100644 Task/Singleton/Ecstasy/singleton.ecstasy create mode 100644 Task/Singly-linked-list-Element-definition/PascalABC.NET/singly-linked-list-element-definition.pas create mode 100644 Task/Singly-linked-list-Element-insertion/PascalABC.NET/singly-linked-list-element-insertion.pas create mode 100644 Task/Sleep/PascalABC.NET/sleep.pas create mode 100644 Task/Sleeping-Beauty-problem/ALGOL-68/sleeping-beauty-problem.alg create mode 100644 Task/Sleeping-Beauty-problem/Fortran/sleeping-beauty-problem.f create mode 100644 Task/Sleeping-Beauty-problem/Jq/sleeping-beauty-problem.jq create mode 100644 Task/Smarandache-Wellin-primes/Sidef/smarandache-wellin-primes.sidef create mode 100644 Task/Smith-numbers/Uiua/smith-numbers-1.uiua create mode 100644 Task/Smith-numbers/Uiua/smith-numbers-2.uiua create mode 100644 Task/Snake/Emacs-Lisp/snake.l create mode 100644 Task/Solve-a-Hidato-puzzle/Jq/solve-a-hidato-puzzle.jq create mode 100644 Task/Solve-a-Hidato-puzzle/Uiua/solve-a-hidato-puzzle.uiua create mode 100644 Task/Solve-a-Holy-Knights-tour/Jq/solve-a-holy-knights-tour.jq create mode 100644 Task/Solve-a-Numbrix-puzzle/Dart/solve-a-numbrix-puzzle.dart create mode 100644 Task/Solve-a-Numbrix-puzzle/Jq/solve-a-numbrix-puzzle.jq create mode 100644 Task/Solve-a-Numbrix-puzzle/Uiua/solve-a-numbrix-puzzle.uiua create mode 100644 Task/Solve-the-no-connection-puzzle/FreeBASIC/solve-the-no-connection-puzzle.basic create mode 100644 Task/Solve-the-no-connection-puzzle/Quackery/solve-the-no-connection-puzzle.quackery create mode 100644 Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-1.zig create mode 100644 Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-2.zig create mode 100644 Task/Sort-a-list-of-object-identifiers/EasyLang/sort-a-list-of-object-identifiers.easy create mode 100644 Task/Sort-an-array-of-composite-structures/PascalABC.NET/sort-an-array-of-composite-structures.pas create mode 100644 Task/Sort-an-integer-array/EasyLang/sort-an-integer-array.easy create mode 100644 Task/Sort-an-integer-array/PascalABC.NET/sort-an-integer-array.pas create mode 100644 Task/Sort-an-outline-at-every-level/C++/sort-an-outline-at-every-level.cpp create mode 100644 Task/Sort-an-outline-at-every-level/Jq/sort-an-outline-at-every-level.jq create mode 100644 Task/Sort-disjoint-sublist/Uiua/sort-disjoint-sublist.uiua create mode 100644 Task/Sort-numbers-lexicographically/EasyLang/sort-numbers-lexicographically.easy create mode 100644 Task/Sort-three-variables/PascalABC.NET/sort-three-variables.pas create mode 100644 Task/Sort-using-a-custom-comparator/PascalABC.NET/sort-using-a-custom-comparator.pas create mode 100644 Task/Sorting-Algorithms-Circle-Sort/ALGOL-68/sorting-algorithms-circle-sort.alg create mode 100644 Task/Sorting-Algorithms-Circle-Sort/EasyLang/sorting-algorithms-circle-sort.easy create mode 100644 Task/Sorting-algorithms-Bogosort/EMal/sorting-algorithms-bogosort.emal create mode 100644 Task/Sorting-algorithms-Cocktail-sort/EasyLang/sorting-algorithms-cocktail-sort.easy create mode 100644 Task/Sorting-algorithms-Comb-sort/EasyLang/sorting-algorithms-comb-sort.easy create mode 100644 Task/Sorting-algorithms-Counting-sort/Yabasic/sorting-algorithms-counting-sort.basic create mode 100644 Task/Sorting-algorithms-Insertion-sort/Common-Lisp/sorting-algorithms-insertion-sort-3.lisp rename Task/Sorting-algorithms-Insertion-sort/Kotlin/{sorting-algorithms-insertion-sort.kotlin => sorting-algorithms-insertion-sort-1.kotlin} (100%) create mode 100644 Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-2.kotlin create mode 100644 Task/Sorting-algorithms-Pancake-sort/EasyLang/sorting-algorithms-pancake-sort.easy create mode 100644 Task/Sorting-algorithms-Permutation-sort/Ada/sorting-algorithms-permutation-sort.ada create mode 100644 Task/Sorting-algorithms-Permutation-sort/EasyLang/sorting-algorithms-permutation-sort.easy create mode 100644 Task/Sorting-algorithms-Quicksort/ANSI-BASIC/sorting-algorithms-quicksort.basic create mode 100644 Task/Sorting-algorithms-Quicksort/PascalABC.NET/sorting-algorithms-quicksort.pas create mode 100644 Task/Sorting-algorithms-Quicksort/Python/sorting-algorithms-quicksort-8.py rename Task/Sorting-algorithms-Quicksort/{BASIC => QuickBASIC}/sorting-algorithms-quicksort.basic (100%) create mode 100644 Task/Sorting-algorithms-Quicksort/XBasic/sorting-algorithms-quicksort.basic create mode 100644 Task/Sorting-algorithms-Shell-sort/EasyLang/sorting-algorithms-shell-sort.easy create mode 100644 Task/Sorting-algorithms-Stooge-sort/Yabasic/sorting-algorithms-stooge-sort.basic create mode 100644 Task/Sorting-algorithms-Strand-sort/EasyLang/sorting-algorithms-strand-sort.easy create mode 100644 Task/Special-variables/PascalABC.NET/special-variables-1.pas create mode 100644 Task/Special-variables/PascalABC.NET/special-variables-2.pas create mode 100644 Task/Special-variables/PascalABC.NET/special-variables-3.pas create mode 100644 Task/Split-a-character-string-based-on-change-of-character/Refal/split-a-character-string-based-on-change-of-character.refal create mode 100644 Task/Split-a-character-string-based-on-change-of-character/SETL/split-a-character-string-based-on-change-of-character.setl create mode 100644 Task/Split-a-character-string-based-on-change-of-character/Uiua/split-a-character-string-based-on-change-of-character.uiua create mode 100644 Task/Square-but-not-cube/8080-Assembly/square-but-not-cube.8080 create mode 100644 Task/Square-but-not-cube/ABC/square-but-not-cube.abc create mode 100644 Task/Square-but-not-cube/MACRO-11/square-but-not-cube.macro11 create mode 100644 Task/Square-but-not-cube/Refal/square-but-not-cube.refal create mode 100644 Task/Square-free-integers/Uiua/square-free-integers.uiua create mode 100644 Task/Stack-traces/PascalABC.NET/stack-traces.pas create mode 100644 Task/Stack/PascalABC.NET/stack.pas create mode 100644 Task/Stair-climbing-puzzle/EasyLang/stair-climbing-puzzle.easy create mode 100644 Task/Stem-and-leaf-plot/EasyLang/stem-and-leaf-plot.easy create mode 100644 Task/Stem-and-leaf-plot/Uiua/stem-and-leaf-plot.uiua create mode 100644 Task/String-append/PascalABC.NET/string-append.pas create mode 100644 Task/String-case/Ecstasy/string-case.ecstasy create mode 100644 Task/String-case/PascalABC.NET/string-case.pas create mode 100644 Task/String-case/Uiua/string-case.uiua create mode 100644 Task/String-comparison/Ecstasy/string-comparison.ecstasy rename Task/String-concatenation/C/{string-concatenation.c => string-concatenation-1.c} (100%) create mode 100644 Task/String-concatenation/C/string-concatenation-2.c create mode 100644 Task/String-concatenation/Ecstasy/string-concatenation.ecstasy create mode 100644 Task/String-concatenation/PascalABC.NET/string-concatenation.pas create mode 100644 Task/String-concatenation/Uiua/string-concatenation.uiua create mode 100644 Task/String-interpolation-included-/Langur/string-interpolation-included--1.langur create mode 100644 Task/String-interpolation-included-/Langur/string-interpolation-included--2.langur create mode 100644 Task/String-interpolation-included-/Langur/string-interpolation-included--3.langur create mode 100644 Task/String-interpolation-included-/PascalABC.NET/string-interpolation-included-.pas create mode 100644 Task/String-interpolation-included-/Uiua/string-interpolation-included-.uiua create mode 100644 Task/String-length/Ecstasy/string-length.ecstasy create mode 100644 Task/String-length/PascalABC.NET/string-length.pas create mode 100644 Task/String-matching/PascalABC.NET/string-matching.pas create mode 100644 Task/String-matching/Uiua/string-matching-1.uiua create mode 100644 Task/String-matching/Uiua/string-matching-2.uiua create mode 100644 Task/String-matching/Uiua/string-matching-3.uiua create mode 100644 Task/String-matching/Uiua/string-matching-4.uiua create mode 100644 Task/String-prepend/PascalABC.NET/string-prepend.pas create mode 100644 Task/Strip-a-set-of-characters-from-a-string/PascalABC.NET/strip-a-set-of-characters-from-a-string.pas create mode 100644 Task/Strip-a-set-of-characters-from-a-string/Uiua/strip-a-set-of-characters-from-a-string.uiua create mode 100644 Task/Strip-block-comments/PascalABC.NET/strip-block-comments.pas create mode 100644 Task/Strip-comments-from-a-string/PascalABC.NET/strip-comments-from-a-string.pas create mode 100644 Task/Strip-control-codes-and-extended-characters-from-a-string/PascalABC.NET/strip-control-codes-and-extended-characters-from-a-string.pas create mode 100644 Task/Strip-whitespace-from-a-string-Top-and-tail/PascalABC.NET/strip-whitespace-from-a-string-top-and-tail.pas create mode 100644 Task/Substitution-cipher/Emacs-Lisp/substitution-cipher.l create mode 100644 Task/Substitution-cipher/PascalABC.NET/substitution-cipher.pas create mode 100644 Task/Substring-Top-and-tail/Ecstasy/substring-top-and-tail.ecstasy create mode 100644 Task/Substring-Top-and-tail/PascalABC.NET/substring-top-and-tail.pas create mode 100644 Task/Substring/Ecstasy/substring.ecstasy create mode 100644 Task/Substring/PascalABC.NET/substring.pas create mode 100644 Task/Sudan-function/PascalABC.NET/sudan-function.pas create mode 100644 Task/Sudoku/Uiua/sudoku.uiua create mode 100644 Task/Sum-and-product-of-an-array/PascalABC.NET/sum-and-product-of-an-array.pas create mode 100644 Task/Sum-digits-of-an-integer/PascalABC.NET/sum-digits-of-an-integer.pas create mode 100644 Task/Sum-multiples-of-3-and-5/PascalABC.NET/sum-multiples-of-3-and-5.pas create mode 100644 Task/Sum-multiples-of-3-and-5/Uiua/sum-multiples-of-3-and-5-1.uiua create mode 100644 Task/Sum-multiples-of-3-and-5/Uiua/sum-multiples-of-3-and-5-2.uiua create mode 100644 Task/Sum-of-a-series/PascalABC.NET/sum-of-a-series.pas create mode 100644 Task/Sum-of-elements-below-main-diagonal-of-matrix/PascalABC.NET/sum-of-elements-below-main-diagonal-of-matrix.pas create mode 100644 Task/Sum-of-squares/PascalABC.NET/sum-of-squares.pas create mode 100644 Task/Summarize-primes/C-sharp/summarize-primes.cs create mode 100644 Task/Summarize-primes/Uiua/summarize-primes.uiua create mode 100644 Task/Symmetric-difference/PascalABC.NET/symmetric-difference.pas create mode 100644 Task/System-time/Ecstasy/system-time.ecstasy create mode 100644 Task/System-time/PascalABC.NET/system-time.pas create mode 100644 Task/Take-notes-on-the-command-line/PascalABC.NET/take-notes-on-the-command-line.pas create mode 100644 Task/Tau-function/C-sharp/tau-function.cs create mode 100644 Task/Tau-function/PascalABC.NET/tau-function.pas create mode 100644 Task/Tau-number/C-sharp/tau-number.cs create mode 100644 Task/Tau-number/PascalABC.NET/tau-number.pas create mode 100644 Task/Taxicab-numbers/EasyLang/taxicab-numbers.easy create mode 100644 Task/Temperature-conversion/PascalABC.NET/temperature-conversion.pas create mode 100644 Task/Terminal-control-Clear-the-screen/PascalABC.NET/terminal-control-clear-the-screen.pas create mode 100644 Task/Terminal-control-Coloured-text/PascalABC.NET/terminal-control-coloured-text.pas create mode 100644 Task/Terminal-control-Cursor-movement/PascalABC.NET/terminal-control-cursor-movement.pas create mode 100644 Task/Terminal-control-Cursor-positioning/PascalABC.NET/terminal-control-cursor-positioning.pas create mode 100644 Task/Terminal-control-Dimensions/PascalABC.NET/terminal-control-dimensions.pas create mode 100644 Task/Terminal-control-Display-an-extended-character/PascalABC.NET/terminal-control-display-an-extended-character.pas create mode 100644 Task/Terminal-control-Hiding-the-cursor/PascalABC.NET/terminal-control-hiding-the-cursor.pas create mode 100644 Task/Terminal-control-Ringing-the-terminal-bell/PascalABC.NET/terminal-control-ringing-the-terminal-bell.pas create mode 100644 Task/Test-a-function/PascalABC.NET/test-a-function.pas create mode 100644 Task/Test-a-function/Uiua/test-a-function.uiua create mode 100644 Task/Thieles-interpolation-formula/Jq/thieles-interpolation-formula.jq create mode 100644 Task/Tic-tac-toe/Jq/tic-tac-toe.jq create mode 100644 Task/Time-a-function/PascalABC.NET/time-a-function.pas create mode 100644 Task/Tokenize-a-string-with-escaping/EasyLang/tokenize-a-string-with-escaping.easy create mode 100644 Task/Tokenize-a-string/PascalABC.NET/tokenize-a-string.pas create mode 100644 Task/Top-rank-per-group/EasyLang/top-rank-per-group.easy create mode 100644 Task/Top-rank-per-group/PascalABC.NET/top-rank-per-group.pas create mode 100644 Task/Topic-variable/Java/topic-variable.java create mode 100644 Task/Towers-of-Hanoi/Asymptote/towers-of-hanoi.asymptote create mode 100644 Task/Towers-of-Hanoi/Bruijn/towers-of-hanoi.bruijn create mode 100644 Task/Towers-of-Hanoi/PascalABC.NET/towers-of-hanoi.pas create mode 100644 Task/Trabb-Pardo-Knuth-algorithm/PascalABC.NET/trabb-pardo-knuth-algorithm.pas create mode 100644 Task/Trabb-Pardo-Knuth-algorithm/UNIX-Shell/trabb-pardo-knuth-algorithm.sh create mode 100644 Task/Transliterate-English-text-using-the-Greek-alphabet/PascalABC.NET/transliterate-english-text-using-the-greek-alphabet.pas create mode 100644 Task/Tree-datastructures/PascalABC.NET/tree-datastructures.pas create mode 100644 Task/Tree-from-nesting-levels/C-sharp/tree-from-nesting-levels.cs create mode 100644 Task/Tree-traversal/EMal/tree-traversal.emal create mode 100644 Task/Tree-traversal/PascalABC.NET/tree-traversal.pas create mode 100644 Task/Trigonometric-functions/PascalABC.NET/trigonometric-functions.pas create mode 100644 Task/Truncatable-primes/Uiua/truncatable-primes.uiua create mode 100644 Task/Truncate-a-file/PascalABC.NET/truncate-a-file.pas create mode 100644 Task/Twos-complement/PascalABC.NET/twos-complement.pas create mode 100644 Task/UPC/Ada/upc.ada create mode 100644 Task/URL-decoding/PascalABC.NET/url-decoding.pas create mode 100644 Task/URL-encoding/PascalABC.NET/url-encoding.pas create mode 100644 Task/Ultra-useful-primes/C-sharp/ultra-useful-primes.cs create mode 100644 Task/Undefined-values/PascalABC.NET/undefined-values.pas create mode 100644 Task/Unicode-strings/PascalABC.NET/unicode-strings.pas create mode 100644 Task/Unicode-variable-names/PascalABC.NET/unicode-variable-names.pas rename Task/Universal-Turing-machine/Python/{universal-turing-machine.py => universal-turing-machine-1.py} (100%) create mode 100644 Task/Universal-Turing-machine/Python/universal-turing-machine-2.py create mode 100644 Task/User-input-Text/EMal/user-input-text.emal create mode 100644 Task/User-input-Text/PascalABC.NET/user-input-text.pas create mode 100644 Task/Validate-International-Securities-Identification-Number/Uiua/validate-international-securities-identification-number.uiua create mode 100644 Task/Variable-declaration-reset/C-sharp/variable-declaration-reset.cs create mode 100644 Task/Variables/PascalABC.NET/variables-1.pas create mode 100644 Task/Variables/PascalABC.NET/variables-2.pas create mode 100644 Task/Variables/PascalABC.NET/variables-3.pas create mode 100644 Task/Variables/PascalABC.NET/variables-4.pas create mode 100644 Task/Variables/PascalABC.NET/variables-5.pas create mode 100644 Task/Variables/PascalABC.NET/variables-6.pas create mode 100644 Task/Variadic-function/PascalABC.NET/variadic-function.pas create mode 100644 Task/Vector-products/PascalABC.NET/vector-products.pas create mode 100644 Task/Vector/Chipmunk-Basic/vector.basic create mode 100644 Task/Vector/GW-BASIC/vector.basic create mode 100644 Task/Vector/PascalABC.NET/vector.pas create mode 100644 Task/Vector/QBasic/vector.basic create mode 100644 Task/Vector/True-BASIC/vector.basic create mode 100644 Task/Verify-distribution-uniformity-Naive/EasyLang/verify-distribution-uniformity-naive.easy create mode 100644 Task/Wagstaff-primes/Sidef/wagstaff-primes.sidef create mode 100644 Task/Walk-a-directory-Non-recursively/PascalABC.NET/walk-a-directory-non-recursively.pas create mode 100644 Task/Walk-a-directory-Recursively/PascalABC.NET/walk-a-directory-recursively.pas create mode 100644 Task/War-card-game/Ada/war-card-game.ada create mode 100644 Task/War-card-game/Jq/war-card-game.jq create mode 100644 Task/Water-collected-between-towers/PHP/water-collected-between-towers.php create mode 100644 Task/Water-collected-between-towers/Uiua/water-collected-between-towers.uiua create mode 100644 Task/Weird-numbers/Ada/weird-numbers-1.ada create mode 100644 Task/Weird-numbers/Ada/weird-numbers-2.ada rename Task/Weird-numbers/Python/{weird-numbers.py => weird-numbers-1.py} (100%) create mode 100644 Task/Weird-numbers/Python/weird-numbers-2.py create mode 100644 Task/Weird-numbers/Uxntal/weird-numbers.uxnatl create mode 100644 Task/Window-creation/PascalABC.NET/window-creation.pas create mode 100644 Task/Word-frequency/PascalABC.NET/word-frequency.pas create mode 100644 Task/Word-ladder/APL/word-ladder.apl create mode 100644 Task/Word-ladder/Ada/word-ladder.ada create mode 100644 Task/Word-ladder/Refal/word-ladder.refal create mode 100644 Task/Word-ladder/SETL/word-ladder.setl create mode 100644 Task/Word-search/Ada/word-search.ada create mode 100644 Task/Word-wheel/Ada/word-wheel.ada rename Task/Word-wheel/Lua/{word-wheel.lua => word-wheel-1.lua} (100%) create mode 100644 Task/Word-wheel/Lua/word-wheel-2.lua create mode 100644 Task/Word-wrap/PascalABC.NET/word-wrap.pas create mode 100644 Task/Wordiff/Jq/wordiff.jq create mode 100644 Task/Write-entire-file/PascalABC.NET/write-entire-file.pas create mode 100644 Task/Write-to-Windows-event-log/FreeBASIC/write-to-windows-event-log.basic create mode 100644 Task/Write-to-Windows-event-log/PascalABC.NET/write-to-windows-event-log.pas create mode 100644 Task/XML-DOM-serialization/PascalABC.NET/xml-dom-serialization.pas create mode 100644 Task/XML-Input/PascalABC.NET/xml-input.pas create mode 100644 Task/XML-Input/Vim-Script/xml-input.vim create mode 100644 Task/XML-Output/PascalABC.NET/xml-output.pas create mode 100644 Task/Yellowstone-sequence/C-sharp/yellowstone-sequence.cs create mode 100644 Task/Yellowstone-sequence/Uiua/yellowstone-sequence.uiua rename Task/Yin-and-yang/AmigaBASIC/{yin-and-yang.basic => yin-and-yang-1.basic} (100%) create mode 100644 Task/Yin-and-yang/AmigaBASIC/yin-and-yang-2.basic create mode 100644 Task/Zebra-puzzle/Uiua/zebra-puzzle.uiua create mode 100644 Task/Zero-to-the-zero-power/PascalABC.NET/zero-to-the-zero-power.pas create mode 100644 Task/Zig-zag-matrix/EasyLang/zig-zag-matrix.easy diff --git a/Lang/8080-Assembly/Square-but-not-cube b/Lang/8080-Assembly/Square-but-not-cube new file mode 120000 index 0000000000..e8de867485 --- /dev/null +++ b/Lang/8080-Assembly/Square-but-not-cube @@ -0,0 +1 @@ +../../Task/Square-but-not-cube/8080-Assembly \ No newline at end of file diff --git a/Lang/AArch64-Assembly/Pi b/Lang/AArch64-Assembly/Pi new file mode 120000 index 0000000000..34be149f2d --- /dev/null +++ b/Lang/AArch64-Assembly/Pi @@ -0,0 +1 @@ +../../Task/Pi/AArch64-Assembly \ No newline at end of file diff --git a/Lang/ABC/Look-and-say-sequence b/Lang/ABC/Look-and-say-sequence new file mode 120000 index 0000000000..68b9661932 --- /dev/null +++ b/Lang/ABC/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/ABC \ No newline at end of file diff --git a/Lang/ABC/Population-count b/Lang/ABC/Population-count new file mode 120000 index 0000000000..6bd44c7e1e --- /dev/null +++ b/Lang/ABC/Population-count @@ -0,0 +1 @@ +../../Task/Population-count/ABC \ No newline at end of file diff --git a/Lang/ABC/Square-but-not-cube b/Lang/ABC/Square-but-not-cube new file mode 120000 index 0000000000..23a046e711 --- /dev/null +++ b/Lang/ABC/Square-but-not-cube @@ -0,0 +1 @@ +../../Task/Square-but-not-cube/ABC \ No newline at end of file diff --git a/Lang/ALGOL-68/00-LANG.txt b/Lang/ALGOL-68/00-LANG.txt index c77464279f..4aa1cbcf81 100644 --- a/Lang/ALGOL-68/00-LANG.txt +++ b/Lang/ALGOL-68/00-LANG.txt @@ -67,7 +67,7 @@ A syntax chart is available [http://www.softwarepreservation.org/projects/ALGOL/ *Oct. 1968: Penultimate Draft Report on the Algorithmic Language ALGOL 68 - Chapters 1-9 - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster. *Dec. 1968: Report on the Algorithmic Language ALGOL 68 - Offprint from Numerische Mathematik, 14, 79-218 (1969); Springer-Verlag. - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster. *Sep 1973: Revised Report on the Algorithmic Language Algol 68 - Springer-Verlag 1976 - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker. -==Coding style of samples== +==Coding style of samples, alphabets and stropping== Click "Expand" for more details.
@@ -96,23 +96,30 @@ not too much else is required. Examples: END FINISH |} +

'''Alphabets''' +

+Notionally, Algol 68 source is written in two alphabets. The reserved words, mode indicants (type names) and operators that are non-symbolic (.e.g. '''and''', '''or''', ...) are generally referred to as "bold words" and usually shown in a bold font in literature. Words that are identifiers (used for "variable" names, procedure names, structure member names, ...) are in a separate, non-bold font.
+The [https://www.softwarepreservation.org/projects/ALGOL/manual/a68s.txt/view Manual for CMU ALGOL 68S (on softwarepreservation.org)] refers to the non-bold words as being in timid face.

'''Examples of different program representations'''

At the time when ALGOL 68 was defined some predominant computers had 24 or 36 bit words, with 6 bit character sets. Hence it was desirable that -ALGOL 68 should be able to run on machines with only uppercase. +ALGOL 68 should be able to run on machines with only uppercase. +As multiple fonts were generally unavailable, a method of identifying the bold words was required.
The official spec provided for different representations of the same -program. Quote stropping (enclosing the bold words in single quotes) +program. +Quote stropping (enclosing the bold words in single quotes) and Point stropping (preceeding the bold words with a dot) -were used. A variant of Point stropping called RES stropping was also defined. -In RES stropping some language-defined bold words are not preceded by a dot. +were used.
+A variant of Point stropping called RES stropping was also defined. +In RES stropping some language-defined bold words are not preceded by a dot.
A pragmatic comment may have been required to indicate which -stropping convention was to be used, as in some of the examples below. +stropping convention was to be used, as in some of the examples below.
Upper stropping (representing the bold words by upper case and -non-bold words in lower case) was introduced by Algol 68R. Upper stropping -is used by Algol 68RS and is one of the options for Algol 68G. -Rutgers ALGOL 68 uses quote stropping. Most of the samples -on Rosetta Code use Upper stropping. +non-bold words in lower case) was introduced by Algol 68R.
+Upper stropping is used by Algol 68RS and is one of the options for Algol 68G.
+Rutgers ALGOL 68 uses quote stropping.
+Most of the samples on Rosetta Code use Upper stropping.

Examples (pragmatic comments to set the stropping regime not shown): {|border="1" style="border-collapse: collapse; border: 2px double grey;" align="left" || Algol68 as typically published @@ -281,5 +288,9 @@ For more details about Primaries and Secondaries refer to [[Operator_precedence# [https://rosettacode.org/wiki/Category:ALGOL_68-rows Row (array) related]
[https://rosettacode.org/wiki/Category:ALGOL_68-l-system L-System related] +== Tools == +[[Syntax_highlighting_using_Mediawiki_formatting#ALGOL 68|Format an upper-stropped Algol 68 source with Mediawiki markup]]
+[[Compiler/Simple_file_inclusion_pre_processor#ALGOL 68|Implement ''read'' and ''include'' pragmatic-comments for compilers that don't support file inclusion]] + {{language programming paradigm|Concurrent}} {{language programming paradigm|Imperative}} \ No newline at end of file diff --git a/Lang/ALGOL-68/Draw-a-cuboid b/Lang/ALGOL-68/Draw-a-cuboid new file mode 120000 index 0000000000..3102af7fc7 --- /dev/null +++ b/Lang/ALGOL-68/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Perlin-noise b/Lang/ALGOL-68/Perlin-noise new file mode 120000 index 0000000000..8bd6981103 --- /dev/null +++ b/Lang/ALGOL-68/Perlin-noise @@ -0,0 +1 @@ +../../Task/Perlin-noise/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sleeping-Beauty-problem b/Lang/ALGOL-68/Sleeping-Beauty-problem new file mode 120000 index 0000000000..b5873d4f8d --- /dev/null +++ b/Lang/ALGOL-68/Sleeping-Beauty-problem @@ -0,0 +1 @@ +../../Task/Sleeping-Beauty-problem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sorting-Algorithms-Circle-Sort b/Lang/ALGOL-68/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..de6d7c8e6a --- /dev/null +++ b/Lang/ALGOL-68/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-W/Eulers-constant-0.5772... b/Lang/ALGOL-W/Eulers-constant-0.5772... new file mode 120000 index 0000000000..809de9e1fd --- /dev/null +++ b/Lang/ALGOL-W/Eulers-constant-0.5772... @@ -0,0 +1 @@ +../../Task/Eulers-constant-0.5772.../ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Find-the-intersection-of-two-lines b/Lang/ALGOL-W/Find-the-intersection-of-two-lines new file mode 120000 index 0000000000..0514984ef6 --- /dev/null +++ b/Lang/ALGOL-W/Find-the-intersection-of-two-lines @@ -0,0 +1 @@ +../../Task/Find-the-intersection-of-two-lines/ALGOL-W \ No newline at end of file diff --git a/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method b/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method new file mode 120000 index 0000000000..e6f0e36a5b --- /dev/null +++ b/Lang/ALGOL-W/Pseudo-random-numbers-Middle-square-method @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Damm-algorithm b/Lang/ANSI-BASIC/Damm-algorithm new file mode 120000 index 0000000000..e4b39fdaa1 --- /dev/null +++ b/Lang/ANSI-BASIC/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Formatted-numeric-output b/Lang/ANSI-BASIC/Formatted-numeric-output new file mode 120000 index 0000000000..e876b7e939 --- /dev/null +++ b/Lang/ANSI-BASIC/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Function-definition b/Lang/ANSI-BASIC/Function-definition new file mode 120000 index 0000000000..c45352eba7 --- /dev/null +++ b/Lang/ANSI-BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Monty-Hall-problem b/Lang/ANSI-BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..8f9a29cbcc --- /dev/null +++ b/Lang/ANSI-BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Random-numbers b/Lang/ANSI-BASIC/Random-numbers new file mode 120000 index 0000000000..1de5221db0 --- /dev/null +++ b/Lang/ANSI-BASIC/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Real-constants-and-functions b/Lang/ANSI-BASIC/Real-constants-and-functions new file mode 120000 index 0000000000..02cced5726 --- /dev/null +++ b/Lang/ANSI-BASIC/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/ANSI-BASIC \ No newline at end of file diff --git a/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort b/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..acf4c89afe --- /dev/null +++ b/Lang/ANSI-BASIC/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/ANSI-BASIC \ No newline at end of file diff --git a/Lang/APL/Display-a-linear-combination b/Lang/APL/Display-a-linear-combination new file mode 120000 index 0000000000..0e1867473a --- /dev/null +++ b/Lang/APL/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/APL \ No newline at end of file diff --git a/Lang/APL/Pisano-period b/Lang/APL/Pisano-period new file mode 120000 index 0000000000..d81ff37307 --- /dev/null +++ b/Lang/APL/Pisano-period @@ -0,0 +1 @@ +../../Task/Pisano-period/APL \ No newline at end of file diff --git a/Lang/APL/Word-ladder b/Lang/APL/Word-ladder new file mode 120000 index 0000000000..6de9f38d51 --- /dev/null +++ b/Lang/APL/Word-ladder @@ -0,0 +1 @@ +../../Task/Word-ladder/APL \ No newline at end of file diff --git a/Lang/ARM-Assembly/Pi b/Lang/ARM-Assembly/Pi new file mode 120000 index 0000000000..97b44cbcc1 --- /dev/null +++ b/Lang/ARM-Assembly/Pi @@ -0,0 +1 @@ +../../Task/Pi/ARM-Assembly \ No newline at end of file diff --git a/Lang/Ada/00-LANG.txt b/Lang/Ada/00-LANG.txt index 85a16e96c0..f17f9738ab 100644 --- a/Lang/Ada/00-LANG.txt +++ b/Lang/Ada/00-LANG.txt @@ -17,4 +17,6 @@ The language is named after [[wp:Ada_Lovelace|Augusta Ada King, Countess of Love {{Language programming paradigm|Distributed}} {{Language programming paradigm|Generic}} {{Language programming paradigm|Imperative}} -{{Language programming paradigm|Object-oriented}} \ No newline at end of file +{{Language programming paradigm|Object-oriented}} +==Todo== +* [[Tasks not implemented in Ada]] \ No newline at end of file diff --git a/Lang/Ada/Abelian-sandpile-model b/Lang/Ada/Abelian-sandpile-model new file mode 120000 index 0000000000..adfb5aa625 --- /dev/null +++ b/Lang/Ada/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/Ada \ No newline at end of file diff --git a/Lang/Ada/Achilles-numbers b/Lang/Ada/Achilles-numbers new file mode 120000 index 0000000000..8a02102d36 --- /dev/null +++ b/Lang/Ada/Achilles-numbers @@ -0,0 +1 @@ +../../Task/Achilles-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi b/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi new file mode 120000 index 0000000000..14bdbe4c3d --- /dev/null +++ b/Lang/Ada/Arithmetic-geometric-mean-Calculate-Pi @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean-Calculate-Pi/Ada \ No newline at end of file diff --git a/Lang/Ada/Ascending-primes b/Lang/Ada/Ascending-primes new file mode 120000 index 0000000000..cee2b86585 --- /dev/null +++ b/Lang/Ada/Ascending-primes @@ -0,0 +1 @@ +../../Task/Ascending-primes/Ada \ No newline at end of file diff --git a/Lang/Ada/Brace-expansion b/Lang/Ada/Brace-expansion new file mode 120000 index 0000000000..b881365fa7 --- /dev/null +++ b/Lang/Ada/Brace-expansion @@ -0,0 +1 @@ +../../Task/Brace-expansion/Ada \ No newline at end of file diff --git a/Lang/Ada/Color-wheel b/Lang/Ada/Color-wheel new file mode 120000 index 0000000000..3d78384078 --- /dev/null +++ b/Lang/Ada/Color-wheel @@ -0,0 +1 @@ +../../Task/Color-wheel/Ada \ No newline at end of file diff --git a/Lang/Ada/Combinations-and-permutations b/Lang/Ada/Combinations-and-permutations new file mode 120000 index 0000000000..3f163f203e --- /dev/null +++ b/Lang/Ada/Combinations-and-permutations @@ -0,0 +1 @@ +../../Task/Combinations-and-permutations/Ada \ No newline at end of file diff --git a/Lang/Ada/Eulers-constant-0.5772... b/Lang/Ada/Eulers-constant-0.5772... new file mode 120000 index 0000000000..b0e75cb33e --- /dev/null +++ b/Lang/Ada/Eulers-constant-0.5772... @@ -0,0 +1 @@ +../../Task/Eulers-constant-0.5772.../Ada \ No newline at end of file diff --git a/Lang/Ada/FTP b/Lang/Ada/FTP new file mode 120000 index 0000000000..1d406ce7cd --- /dev/null +++ b/Lang/Ada/FTP @@ -0,0 +1 @@ +../../Task/FTP/Ada \ No newline at end of file diff --git a/Lang/Ada/Hex-words b/Lang/Ada/Hex-words new file mode 120000 index 0000000000..da49cf2b4d --- /dev/null +++ b/Lang/Ada/Hex-words @@ -0,0 +1 @@ +../../Task/Hex-words/Ada \ No newline at end of file diff --git a/Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols b/Lang/Ada/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols new file mode 120000 index 0000000000..29e378f3f1 --- /dev/null +++ b/Lang/Ada/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/Ada \ No newline at end of file diff --git a/Lang/Ada/Largest-number-divisible-by-its-digits b/Lang/Ada/Largest-number-divisible-by-its-digits new file mode 120000 index 0000000000..d61b3cb8be --- /dev/null +++ b/Lang/Ada/Largest-number-divisible-by-its-digits @@ -0,0 +1 @@ +../../Task/Largest-number-divisible-by-its-digits/Ada \ No newline at end of file diff --git a/Lang/Ada/Magic-constant b/Lang/Ada/Magic-constant new file mode 120000 index 0000000000..bd59423b8e --- /dev/null +++ b/Lang/Ada/Magic-constant @@ -0,0 +1 @@ +../../Task/Magic-constant/Ada \ No newline at end of file diff --git a/Lang/Ada/Mind-boggling-card-trick b/Lang/Ada/Mind-boggling-card-trick new file mode 120000 index 0000000000..11ae4366fc --- /dev/null +++ b/Lang/Ada/Mind-boggling-card-trick @@ -0,0 +1 @@ +../../Task/Mind-boggling-card-trick/Ada \ No newline at end of file diff --git a/Lang/Ada/Musical-scale b/Lang/Ada/Musical-scale new file mode 120000 index 0000000000..a792f4144a --- /dev/null +++ b/Lang/Ada/Musical-scale @@ -0,0 +1 @@ +../../Task/Musical-scale/Ada \ No newline at end of file diff --git a/Lang/Ada/Next-highest-int-from-digits b/Lang/Ada/Next-highest-int-from-digits new file mode 120000 index 0000000000..e996a777e6 --- /dev/null +++ b/Lang/Ada/Next-highest-int-from-digits @@ -0,0 +1 @@ +../../Task/Next-highest-int-from-digits/Ada \ No newline at end of file diff --git a/Lang/Ada/Penneys-game b/Lang/Ada/Penneys-game new file mode 120000 index 0000000000..00a5e1d496 --- /dev/null +++ b/Lang/Ada/Penneys-game @@ -0,0 +1 @@ +../../Task/Penneys-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Permutations-by-swapping b/Lang/Ada/Permutations-by-swapping new file mode 120000 index 0000000000..9140cf7f43 --- /dev/null +++ b/Lang/Ada/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Ada \ No newline at end of file diff --git a/Lang/Ada/Play-recorded-sounds b/Lang/Ada/Play-recorded-sounds new file mode 120000 index 0000000000..2365ca211b --- /dev/null +++ b/Lang/Ada/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Ada \ No newline at end of file diff --git a/Lang/Ada/Poker-hand-analyser b/Lang/Ada/Poker-hand-analyser new file mode 120000 index 0000000000..fc5a66b995 --- /dev/null +++ b/Lang/Ada/Poker-hand-analyser @@ -0,0 +1 @@ +../../Task/Poker-hand-analyser/Ada \ No newline at end of file diff --git a/Lang/Ada/Record-sound b/Lang/Ada/Record-sound new file mode 120000 index 0000000000..af45b7783f --- /dev/null +++ b/Lang/Ada/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/Ada \ No newline at end of file diff --git a/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string new file mode 120000 index 0000000000..5077dd9033 --- /dev/null +++ b/Lang/Ada/Selectively-replace-multiple-instances-of-a-character-within-a-string @@ -0,0 +1 @@ +../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Sierpinski-square-curve b/Lang/Ada/Sierpinski-square-curve new file mode 120000 index 0000000000..32cee5f712 --- /dev/null +++ b/Lang/Ada/Sierpinski-square-curve @@ -0,0 +1 @@ +../../Task/Sierpinski-square-curve/Ada \ No newline at end of file diff --git a/Lang/Ada/Sorting-algorithms-Permutation-sort b/Lang/Ada/Sorting-algorithms-Permutation-sort new file mode 120000 index 0000000000..0f333c5ec8 --- /dev/null +++ b/Lang/Ada/Sorting-algorithms-Permutation-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Permutation-sort/Ada \ No newline at end of file diff --git a/Lang/Ada/UPC b/Lang/Ada/UPC new file mode 120000 index 0000000000..374da7b0aa --- /dev/null +++ b/Lang/Ada/UPC @@ -0,0 +1 @@ +../../Task/UPC/Ada \ No newline at end of file diff --git a/Lang/Ada/War-card-game b/Lang/Ada/War-card-game new file mode 120000 index 0000000000..dd4f92afee --- /dev/null +++ b/Lang/Ada/War-card-game @@ -0,0 +1 @@ +../../Task/War-card-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Weird-numbers b/Lang/Ada/Weird-numbers new file mode 120000 index 0000000000..98491ade1a --- /dev/null +++ b/Lang/Ada/Weird-numbers @@ -0,0 +1 @@ +../../Task/Weird-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-ladder b/Lang/Ada/Word-ladder new file mode 120000 index 0000000000..495c24dbcd --- /dev/null +++ b/Lang/Ada/Word-ladder @@ -0,0 +1 @@ +../../Task/Word-ladder/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-search b/Lang/Ada/Word-search new file mode 120000 index 0000000000..32f00f4762 --- /dev/null +++ b/Lang/Ada/Word-search @@ -0,0 +1 @@ +../../Task/Word-search/Ada \ No newline at end of file diff --git a/Lang/Ada/Word-wheel b/Lang/Ada/Word-wheel new file mode 120000 index 0000000000..47f67698e0 --- /dev/null +++ b/Lang/Ada/Word-wheel @@ -0,0 +1 @@ +../../Task/Word-wheel/Ada \ No newline at end of file diff --git a/Lang/AmigaBASIC/00-LANG.txt b/Lang/AmigaBASIC/00-LANG.txt index 94b3e71ee7..c2e6f48854 100644 --- a/Lang/AmigaBASIC/00-LANG.txt +++ b/Lang/AmigaBASIC/00-LANG.txt @@ -11,5 +11,7 @@ Execution speed however was not a particular strength of AmigaBASIC. Some 8-bit AmigaBASIC was superseded by [[wp:ARexx|ARexx]], a REXX-style scripting language, from AmigaOS version 2.0 onwards. The 1.x AmigaBASIC binary also works on AmigaOS 2, but not on AmigaOS 3. +Microsoft [[QuickBASIC]] (1985) and QBasic (1991) look very similar to AmigaBASIC, so their syntax highlighting rules mostly also work for AmigaBASIC code. + ==See Also== *[https://archive.org/search.php?query=amiga%20basic Scanned AmigaBASIC books at archive.org] \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Display-a-linear-combination b/Lang/Applesoft-BASIC/Display-a-linear-combination new file mode 120000 index 0000000000..d72f6d3a78 --- /dev/null +++ b/Lang/Applesoft-BASIC/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Repeat b/Lang/Applesoft-BASIC/Repeat new file mode 120000 index 0000000000..eb0c08d923 --- /dev/null +++ b/Lang/Applesoft-BASIC/Repeat @@ -0,0 +1 @@ +../../Task/Repeat/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Asymptote/Jensens-Device b/Lang/Asymptote/Jensens-Device new file mode 120000 index 0000000000..621c474cd7 --- /dev/null +++ b/Lang/Asymptote/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Asymptote \ No newline at end of file diff --git a/Lang/Asymptote/Towers-of-Hanoi b/Lang/Asymptote/Towers-of-Hanoi new file mode 120000 index 0000000000..62a6e4d923 --- /dev/null +++ b/Lang/Asymptote/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/Asymptote \ No newline at end of file diff --git a/Lang/AutoHotKey-V2/00-LANG.txt b/Lang/AutoHotKey-V2/00-LANG.txt deleted file mode 100644 index a333f928af..0000000000 --- a/Lang/AutoHotKey-V2/00-LANG.txt +++ /dev/null @@ -1 +0,0 @@ -{{stub}}{{language|AutoHotKey V2}} \ No newline at end of file diff --git a/Lang/AutoHotKey-V2/00-META.yaml b/Lang/AutoHotKey-V2/00-META.yaml deleted file mode 100644 index 316ebe0ccb..0000000000 --- a/Lang/AutoHotKey-V2/00-META.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -from: http://rosettacode.org/wiki/Category:AutoHotKey_V2 diff --git a/Lang/AutoHotKey-V2/Hello-world-Graphical b/Lang/AutoHotKey-V2/Hello-world-Graphical deleted file mode 120000 index 89783bc714..0000000000 --- a/Lang/AutoHotKey-V2/Hello-world-Graphical +++ /dev/null @@ -1 +0,0 @@ -../../Task/Hello-world-Graphical/AutoHotKey-V2 \ No newline at end of file diff --git a/Lang/Autohotkey-V2/00-LANG.txt b/Lang/Autohotkey-V2/00-LANG.txt new file mode 100644 index 0000000000..b3e33b65ab --- /dev/null +++ b/Lang/Autohotkey-V2/00-LANG.txt @@ -0,0 +1,16 @@ +{{stub}}AutoHotkey V2 is an [[open source]] programming language for Microsoft [[Windows]]. + +AutoHotkey v2 is a major update to the AutoHotkey language, which includes numerous new features and improvements. + +== Citations == + +* [https://www.autohotkey.com/docs/v2/ Documentation] +* [http://autohotkey.com/download Downloads] +* [http://autohotkey.com/docs/scripts/ Script Showcase] +* [http://autohotkey.com/boards/ New Community forum] +* [http://www.autohotkey.com/forum/ Archived Community forum] +* [http://ahkscript.org/foundation AutoHotkey Foundation LLC] +* [[wp:AutoHotkey|AutoHotkey on Wikipedia]] +* #ahk on [http://webchat.freenode.net/?channels=%23ahk Freenode Web interface] +* [[:Category:AutoHotkey_Originated]] +{{language|Ayrch}} \ No newline at end of file diff --git a/Lang/Autohotkey-V2/00-META.yaml b/Lang/Autohotkey-V2/00-META.yaml new file mode 100644 index 0000000000..651d1bc21b --- /dev/null +++ b/Lang/Autohotkey-V2/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Autohotkey_V2 diff --git a/Lang/Autohotkey-V2/Hello-world-Graphical b/Lang/Autohotkey-V2/Hello-world-Graphical new file mode 120000 index 0000000000..0375a8eeb7 --- /dev/null +++ b/Lang/Autohotkey-V2/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Autohotkey-V2 \ No newline at end of file diff --git a/Lang/BASIC/00-LANG.txt b/Lang/BASIC/00-LANG.txt index 8f4f969193..745f847ac8 100644 --- a/Lang/BASIC/00-LANG.txt +++ b/Lang/BASIC/00-LANG.txt @@ -12,11 +12,25 @@ BASIC became popular, with many different implementations for various computers. ==Links== *[[wp:BASIC|Wikipedia:BASIC]] +**[[wp:ASIC]] +**[[wp:Atari BASIC]] **[[wp:BASIC-PLUS]] +**[[wp:Basic-256]] +**[[wp:Batari BASIC]] +**[[wp:BBC BASIC]] **[[wp:Benton Harbor BASIC]] +**[[wp:Beta BASIC]] **[[wp:CBASIC]] **[[wp:Chipmunk Basic]] +**[[wp:DarkBASIC]] **[[wp:Dartmouth BASIC]] +**[[wp:FreeBASIC]] +**[[wp:FutureBASIC]] +**[[wp:GFA BASIC]] +**[[wp:GLBasic]] +**[[wp:Integer BASIC]] +**[[wp:Liberty BASIC]] +**[[wp:Locomotive BASIC]] **[[wp:Microsoft BASIC]] ***[[wp:Altair BASIC]] ***[[wp:Amiga BASIC]] @@ -24,13 +38,29 @@ BASIC became popular, with many different implementations for various computers. ***[[wp:Atari Microsoft BASIC]] ***[[wp:Commodore BASIC]] ***[[wp:IBM BASIC]] -***[[wp:TRS-80 Level II BASIC ]] +***[[wp:MS BASIC for Macintosh]] +***[[wp:MSX BASIC]] +***[[wp:Small Basic]] +***[[wp:QBasic]] +***[[wp:QuickBASIC]]‎ +***[[wp:TRS-80 Level II BASIC]] +***[[wp:Visual Basic‎]] **[[wp:PowerBASIC]] **[[wp:PureBasic]] +**[[wp:QB64‎]] +**[[wp:Quite BASIC]]‎ +**[[wp:RapidQ]] +**[[wp:Realbasic]] **[[wp:Rocky Mountain BASIC]] +**[[wp:Run BASIC]] **[[wp:S-BASIC]] +**[[wp:ScriptBasic]] **[[wp:Sinclair BASIC]] +**[[wp:SmileBASIC‎]] **[[wp:SuperBASIC]] **[[wp:TI BASIC (TI 99/4A)]] +**[[wp:Tiny BASIC‎]] **[[wp:True BASIC]] +**[[wp:UBASIC]] +**[[wp:Yabasic]] {{language programming paradigm|Procedural}} \ No newline at end of file diff --git a/Lang/BASIC/Damm-algorithm b/Lang/BASIC/Damm-algorithm deleted file mode 120000 index 41ee6d1c36..0000000000 --- a/Lang/BASIC/Damm-algorithm +++ /dev/null @@ -1 +0,0 @@ -../../Task/Damm-algorithm/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Function-definition b/Lang/BASIC/Function-definition deleted file mode 120000 index a052c63292..0000000000 --- a/Lang/BASIC/Function-definition +++ /dev/null @@ -1 +0,0 @@ -../../Task/Function-definition/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Gray-code b/Lang/BASIC/Gray-code deleted file mode 120000 index f0bc6f352f..0000000000 --- a/Lang/BASIC/Gray-code +++ /dev/null @@ -1 +0,0 @@ -../../Task/Gray-code/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Monty-Hall-problem b/Lang/BASIC/Monty-Hall-problem deleted file mode 120000 index ba5a5a279d..0000000000 --- a/Lang/BASIC/Monty-Hall-problem +++ /dev/null @@ -1 +0,0 @@ -../../Task/Monty-Hall-problem/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Ordered-words b/Lang/BASIC/Ordered-words new file mode 120000 index 0000000000..dd2f98d4e6 --- /dev/null +++ b/Lang/BASIC/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Sorting-algorithms-Quicksort b/Lang/BASIC/Sorting-algorithms-Quicksort deleted file mode 120000 index f7976ecb9f..0000000000 --- a/Lang/BASIC/Sorting-algorithms-Quicksort +++ /dev/null @@ -1 +0,0 @@ -../../Task/Sorting-algorithms-Quicksort/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/Kronecker-product b/Lang/BASIC256/Kronecker-product new file mode 120000 index 0000000000..dd258524fe --- /dev/null +++ b/Lang/BASIC256/Kronecker-product @@ -0,0 +1 @@ +../../Task/Kronecker-product/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Multiple-regression b/Lang/BASIC256/Multiple-regression new file mode 120000 index 0000000000..4d8b79e98b --- /dev/null +++ b/Lang/BASIC256/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Nested-templated-data b/Lang/BASIC256/Nested-templated-data new file mode 120000 index 0000000000..f5ddb43f39 --- /dev/null +++ b/Lang/BASIC256/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification b/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification new file mode 120000 index 0000000000..9a890661d4 --- /dev/null +++ b/Lang/BASIC256/Ramer-Douglas-Peucker-line-simplification @@ -0,0 +1 @@ +../../Task/Ramer-Douglas-Peucker-line-simplification/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Sexy-primes b/Lang/BASIC256/Sexy-primes new file mode 120000 index 0000000000..86fc0a12b9 --- /dev/null +++ b/Lang/BASIC256/Sexy-primes @@ -0,0 +1 @@ +../../Task/Sexy-primes/BASIC256 \ No newline at end of file diff --git a/Lang/Bruijn/Harmonic-series b/Lang/Bruijn/Harmonic-series new file mode 120000 index 0000000000..b39ae4ae88 --- /dev/null +++ b/Lang/Bruijn/Harmonic-series @@ -0,0 +1 @@ +../../Task/Harmonic-series/Bruijn \ No newline at end of file diff --git a/Lang/Bruijn/Towers-of-Hanoi b/Lang/Bruijn/Towers-of-Hanoi new file mode 120000 index 0000000000..96dafe6af8 --- /dev/null +++ b/Lang/Bruijn/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/Bruijn \ No newline at end of file diff --git a/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime b/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..61888079c6 --- /dev/null +++ b/Lang/C++/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/C++ \ No newline at end of file diff --git a/Lang/C++/Bitcoin-address-validation b/Lang/C++/Bitcoin-address-validation new file mode 120000 index 0000000000..fdb6fa9bf8 --- /dev/null +++ b/Lang/C++/Bitcoin-address-validation @@ -0,0 +1 @@ +../../Task/Bitcoin-address-validation/C++ \ No newline at end of file diff --git a/Lang/C++/Bitcoin-public-point-to-address b/Lang/C++/Bitcoin-public-point-to-address new file mode 120000 index 0000000000..1229c8b30f --- /dev/null +++ b/Lang/C++/Bitcoin-public-point-to-address @@ -0,0 +1 @@ +../../Task/Bitcoin-public-point-to-address/C++ \ No newline at end of file diff --git a/Lang/C++/Catmull-Clark-subdivision-surface b/Lang/C++/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..dbaa0ac83b --- /dev/null +++ b/Lang/C++/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/C++ \ No newline at end of file diff --git a/Lang/C++/Compiler-virtual-machine-interpreter b/Lang/C++/Compiler-virtual-machine-interpreter new file mode 120000 index 0000000000..94f3cd637b --- /dev/null +++ b/Lang/C++/Compiler-virtual-machine-interpreter @@ -0,0 +1 @@ +../../Task/Compiler-virtual-machine-interpreter/C++ \ No newline at end of file diff --git a/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection b/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection new file mode 120000 index 0000000000..9b984d5ea4 --- /dev/null +++ b/Lang/C++/Factorial-base-numbers-indexing-permutations-of-a-collection @@ -0,0 +1 @@ +../../Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++ \ No newline at end of file diff --git a/Lang/C++/Im-a-software-engineer-get-me-out-of-here b/Lang/C++/Im-a-software-engineer-get-me-out-of-here new file mode 120000 index 0000000000..7c9de1375f --- /dev/null +++ b/Lang/C++/Im-a-software-engineer-get-me-out-of-here @@ -0,0 +1 @@ +../../Task/Im-a-software-engineer-get-me-out-of-here/C++ \ No newline at end of file diff --git a/Lang/C++/P-Adic-square-roots b/Lang/C++/P-Adic-square-roots new file mode 120000 index 0000000000..a25d0f7d5c --- /dev/null +++ b/Lang/C++/P-Adic-square-roots @@ -0,0 +1 @@ +../../Task/P-Adic-square-roots/C++ \ No newline at end of file diff --git a/Lang/C++/Simple-database b/Lang/C++/Simple-database new file mode 120000 index 0000000000..60394bf013 --- /dev/null +++ b/Lang/C++/Simple-database @@ -0,0 +1 @@ +../../Task/Simple-database/C++ \ No newline at end of file diff --git a/Lang/C++/Sort-an-outline-at-every-level b/Lang/C++/Sort-an-outline-at-every-level new file mode 120000 index 0000000000..5467a50bff --- /dev/null +++ b/Lang/C++/Sort-an-outline-at-every-level @@ -0,0 +1 @@ +../../Task/Sort-an-outline-at-every-level/C++ \ No newline at end of file diff --git a/Lang/C-sharp/Additive-primes b/Lang/C-sharp/Additive-primes new file mode 120000 index 0000000000..d958846baf --- /dev/null +++ b/Lang/C-sharp/Additive-primes @@ -0,0 +1 @@ +../../Task/Additive-primes/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Cyclops-numbers b/Lang/C-sharp/Cyclops-numbers new file mode 120000 index 0000000000..c4380e8ccd --- /dev/null +++ b/Lang/C-sharp/Cyclops-numbers @@ -0,0 +1 @@ +../../Task/Cyclops-numbers/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Summarize-primes b/Lang/C-sharp/Summarize-primes new file mode 120000 index 0000000000..de1b22714d --- /dev/null +++ b/Lang/C-sharp/Summarize-primes @@ -0,0 +1 @@ +../../Task/Summarize-primes/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Tau-function b/Lang/C-sharp/Tau-function new file mode 120000 index 0000000000..aa9069413d --- /dev/null +++ b/Lang/C-sharp/Tau-function @@ -0,0 +1 @@ +../../Task/Tau-function/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Tau-number b/Lang/C-sharp/Tau-number new file mode 120000 index 0000000000..0980d5ce28 --- /dev/null +++ b/Lang/C-sharp/Tau-number @@ -0,0 +1 @@ +../../Task/Tau-number/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Tree-from-nesting-levels b/Lang/C-sharp/Tree-from-nesting-levels new file mode 120000 index 0000000000..e46b1553ea --- /dev/null +++ b/Lang/C-sharp/Tree-from-nesting-levels @@ -0,0 +1 @@ +../../Task/Tree-from-nesting-levels/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Ultra-useful-primes b/Lang/C-sharp/Ultra-useful-primes new file mode 120000 index 0000000000..2258e0373a --- /dev/null +++ b/Lang/C-sharp/Ultra-useful-primes @@ -0,0 +1 @@ +../../Task/Ultra-useful-primes/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Variable-declaration-reset b/Lang/C-sharp/Variable-declaration-reset new file mode 120000 index 0000000000..ec0809da88 --- /dev/null +++ b/Lang/C-sharp/Variable-declaration-reset @@ -0,0 +1 @@ +../../Task/Variable-declaration-reset/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Yellowstone-sequence b/Lang/C-sharp/Yellowstone-sequence new file mode 120000 index 0000000000..793ce587ba --- /dev/null +++ b/Lang/C-sharp/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/C-sharp \ No newline at end of file diff --git a/Lang/C/Hunt-the-Wumpus b/Lang/C/Hunt-the-Wumpus new file mode 120000 index 0000000000..e7186ced48 --- /dev/null +++ b/Lang/C/Hunt-the-Wumpus @@ -0,0 +1 @@ +../../Task/Hunt-the-Wumpus/C \ No newline at end of file diff --git a/Lang/C/Pig-the-dice-game-Player b/Lang/C/Pig-the-dice-game-Player new file mode 120000 index 0000000000..28ecb509a8 --- /dev/null +++ b/Lang/C/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/C \ No newline at end of file diff --git a/Lang/COBOL/Nim-game b/Lang/COBOL/Nim-game new file mode 120000 index 0000000000..9a7c582b48 --- /dev/null +++ b/Lang/COBOL/Nim-game @@ -0,0 +1 @@ +../../Task/Nim-game/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Parametric-polymorphism b/Lang/COBOL/Parametric-polymorphism new file mode 120000 index 0000000000..44f214df50 --- /dev/null +++ b/Lang/COBOL/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/COBOL \ No newline at end of file diff --git a/Lang/Chapel/Function-definition b/Lang/Chapel/Function-definition new file mode 120000 index 0000000000..589b4afa2c --- /dev/null +++ b/Lang/Chapel/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Chapel \ No newline at end of file diff --git a/Lang/Chapel/Maze-generation b/Lang/Chapel/Maze-generation new file mode 120000 index 0000000000..b4c55cfddb --- /dev/null +++ b/Lang/Chapel/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Chapel \ No newline at end of file diff --git a/Lang/Chapel/Repeat b/Lang/Chapel/Repeat new file mode 120000 index 0000000000..3c555a4885 --- /dev/null +++ b/Lang/Chapel/Repeat @@ -0,0 +1 @@ +../../Task/Repeat/Chapel \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Display-a-linear-combination b/Lang/Chipmunk-Basic/Display-a-linear-combination new file mode 120000 index 0000000000..76f3965566 --- /dev/null +++ b/Lang/Chipmunk-Basic/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences b/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..24e6f1fb75 --- /dev/null +++ b/Lang/Chipmunk-Basic/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Jensens-Device b/Lang/Chipmunk-Basic/Jensens-Device new file mode 120000 index 0000000000..927dca2f6f --- /dev/null +++ b/Lang/Chipmunk-Basic/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Multiple-regression b/Lang/Chipmunk-Basic/Multiple-regression new file mode 120000 index 0000000000..82844a944e --- /dev/null +++ b/Lang/Chipmunk-Basic/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Nested-templated-data b/Lang/Chipmunk-Basic/Nested-templated-data new file mode 120000 index 0000000000..a7e95ed6f1 --- /dev/null +++ b/Lang/Chipmunk-Basic/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Price-fraction b/Lang/Chipmunk-Basic/Price-fraction new file mode 120000 index 0000000000..895d56d4cf --- /dev/null +++ b/Lang/Chipmunk-Basic/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Proper-divisors b/Lang/Chipmunk-Basic/Proper-divisors new file mode 120000 index 0000000000..e83b2b6ef0 --- /dev/null +++ b/Lang/Chipmunk-Basic/Proper-divisors @@ -0,0 +1 @@ +../../Task/Proper-divisors/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Rate-counter b/Lang/Chipmunk-Basic/Rate-counter new file mode 120000 index 0000000000..214d671194 --- /dev/null +++ b/Lang/Chipmunk-Basic/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Chipmunk-Basic/Vector b/Lang/Chipmunk-Basic/Vector new file mode 120000 index 0000000000..68aa51b11b --- /dev/null +++ b/Lang/Chipmunk-Basic/Vector @@ -0,0 +1 @@ +../../Task/Vector/Chipmunk-Basic \ No newline at end of file diff --git a/Lang/Commodore-BASIC/N-queens-problem b/Lang/Commodore-BASIC/N-queens-problem new file mode 120000 index 0000000000..d5a4ff5b7a --- /dev/null +++ b/Lang/Commodore-BASIC/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Commodore-BASIC \ No newline at end of file diff --git a/Lang/Common-Lisp/Blum-integer b/Lang/Common-Lisp/Blum-integer new file mode 120000 index 0000000000..854dbaeee7 --- /dev/null +++ b/Lang/Common-Lisp/Blum-integer @@ -0,0 +1 @@ +../../Task/Blum-integer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Factorial-primes b/Lang/Common-Lisp/Factorial-primes new file mode 120000 index 0000000000..cc0d935af1 --- /dev/null +++ b/Lang/Common-Lisp/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Common-Lisp \ No newline at end of file diff --git a/Lang/Cowgol/Display-a-linear-combination b/Lang/Cowgol/Display-a-linear-combination new file mode 120000 index 0000000000..7e169cd6fe --- /dev/null +++ b/Lang/Cowgol/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Cowgol \ No newline at end of file diff --git a/Lang/Dart/15-puzzle-solver b/Lang/Dart/15-puzzle-solver new file mode 120000 index 0000000000..9e8e216a39 --- /dev/null +++ b/Lang/Dart/15-puzzle-solver @@ -0,0 +1 @@ +../../Task/15-puzzle-solver/Dart \ No newline at end of file diff --git a/Lang/Dart/Jensens-Device b/Lang/Dart/Jensens-Device new file mode 120000 index 0000000000..973fbf791f --- /dev/null +++ b/Lang/Dart/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Dart \ No newline at end of file diff --git a/Lang/Dart/Solve-a-Numbrix-puzzle b/Lang/Dart/Solve-a-Numbrix-puzzle new file mode 120000 index 0000000000..38339de00c --- /dev/null +++ b/Lang/Dart/Solve-a-Numbrix-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Numbrix-puzzle/Dart \ No newline at end of file diff --git a/Lang/Draco/Display-a-linear-combination b/Lang/Draco/Display-a-linear-combination new file mode 120000 index 0000000000..bbaeb41c31 --- /dev/null +++ b/Lang/Draco/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Draco \ No newline at end of file diff --git a/Lang/EMal/Babbage-problem b/Lang/EMal/Babbage-problem new file mode 120000 index 0000000000..8a7db13311 --- /dev/null +++ b/Lang/EMal/Babbage-problem @@ -0,0 +1 @@ +../../Task/Babbage-problem/EMal \ No newline at end of file diff --git a/Lang/EMal/Bifid-cipher b/Lang/EMal/Bifid-cipher new file mode 120000 index 0000000000..1dbee9fec8 --- /dev/null +++ b/Lang/EMal/Bifid-cipher @@ -0,0 +1 @@ +../../Task/Bifid-cipher/EMal \ No newline at end of file diff --git a/Lang/EMal/Mutual-recursion b/Lang/EMal/Mutual-recursion new file mode 120000 index 0000000000..cb3ebc8ca5 --- /dev/null +++ b/Lang/EMal/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/EMal \ No newline at end of file diff --git a/Lang/EMal/Sorting-algorithms-Bogosort b/Lang/EMal/Sorting-algorithms-Bogosort new file mode 120000 index 0000000000..8dc8cc02d3 --- /dev/null +++ b/Lang/EMal/Sorting-algorithms-Bogosort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Bogosort/EMal \ No newline at end of file diff --git a/Lang/EMal/Tree-traversal b/Lang/EMal/Tree-traversal new file mode 120000 index 0000000000..b693d069a6 --- /dev/null +++ b/Lang/EMal/Tree-traversal @@ -0,0 +1 @@ +../../Task/Tree-traversal/EMal \ No newline at end of file diff --git a/Lang/EMal/User-input-Text b/Lang/EMal/User-input-Text new file mode 120000 index 0000000000..3c00cf11ba --- /dev/null +++ b/Lang/EMal/User-input-Text @@ -0,0 +1 @@ +../../Task/User-input-Text/EMal \ No newline at end of file diff --git a/Lang/EasyLang/00-LANG.txt b/Lang/EasyLang/00-LANG.txt index aa156f93c8..ba3b92e229 100644 --- a/Lang/EasyLang/00-LANG.txt +++ b/Lang/EasyLang/00-LANG.txt @@ -1,19 +1,19 @@ {{language |exec=interpreted -|site=https://easylang.dev/ +|site=https://easylang.online/ |parampass=value, reference |safety=safe |express=explicit |checking=static |tags=learning, web canvas}} -[https://easylang.dev/ide/ '''Browser IDE'''] +[https://easylang.online/ide/ '''Browser IDE'''] ''Easylang'' is a (beginners) programming language with built-in commands for graphics output. The statically typed language has a reduced syntax and semantics. Variables do not have to be declared, the data type is encoded in the variable name - as was usual in the earlier home computer BASIC. The data types are strings and numbers (floating point), arrays of strings and numbers, and arrays of arrays. Arrays are 1-based and can grow. Programs compiled into an AST tree run in the browser or in the browser IDE. [https://easylang.dev/ide/ A browser IDE] with different tutorials, one for beginners, makes programming and learning to program as easy as possible. -The finished programs can be easily integrated into a [https://easylang.dev/apps/ website]. +The finished programs can be easily integrated into a [https://easylang.online/apps/ website]. ==Todo== [[Tasks not implemented in EasyLang]] \ No newline at end of file diff --git a/Lang/EasyLang/Abelian-sandpile-model b/Lang/EasyLang/Abelian-sandpile-model new file mode 120000 index 0000000000..c97f3c3aa6 --- /dev/null +++ b/Lang/EasyLang/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Abelian-sandpile-model-Identity b/Lang/EasyLang/Abelian-sandpile-model-Identity new file mode 120000 index 0000000000..c44f8cb53d --- /dev/null +++ b/Lang/EasyLang/Abelian-sandpile-model-Identity @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model-Identity/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Approximate-equality b/Lang/EasyLang/Approximate-equality new file mode 120000 index 0000000000..916cbf0873 --- /dev/null +++ b/Lang/EasyLang/Approximate-equality @@ -0,0 +1 @@ +../../Task/Approximate-equality/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Arithmetic-Complex b/Lang/EasyLang/Arithmetic-Complex new file mode 120000 index 0000000000..547a37cd78 --- /dev/null +++ b/Lang/EasyLang/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Greatest-subsequential-sum b/Lang/EasyLang/Greatest-subsequential-sum new file mode 120000 index 0000000000..679d3c6deb --- /dev/null +++ b/Lang/EasyLang/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Guess-the-number-With-feedback-player- b/Lang/EasyLang/Guess-the-number-With-feedback-player- new file mode 120000 index 0000000000..56ad8fd02a --- /dev/null +++ b/Lang/EasyLang/Guess-the-number-With-feedback-player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player-/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Halt-and-catch-fire b/Lang/EasyLang/Halt-and-catch-fire new file mode 120000 index 0000000000..fe61f64c40 --- /dev/null +++ b/Lang/EasyLang/Halt-and-catch-fire @@ -0,0 +1 @@ +../../Task/Halt-and-catch-fire/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hamming-numbers b/Lang/EasyLang/Hamming-numbers new file mode 120000 index 0000000000..6f52ef2c78 --- /dev/null +++ b/Lang/EasyLang/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Hofstadter-Figure-Figure-sequences b/Lang/EasyLang/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..d5a34b275d --- /dev/null +++ b/Lang/EasyLang/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/IBAN b/Lang/EasyLang/IBAN new file mode 120000 index 0000000000..961014b963 --- /dev/null +++ b/Lang/EasyLang/IBAN @@ -0,0 +1 @@ +../../Task/IBAN/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Iterated-digits-squaring b/Lang/EasyLang/Iterated-digits-squaring new file mode 120000 index 0000000000..193be9fcba --- /dev/null +++ b/Lang/EasyLang/Iterated-digits-squaring @@ -0,0 +1 @@ +../../Task/Iterated-digits-squaring/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/JortSort b/Lang/EasyLang/JortSort new file mode 120000 index 0000000000..69c9d425de --- /dev/null +++ b/Lang/EasyLang/JortSort @@ -0,0 +1 @@ +../../Task/JortSort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kronecker-product b/Lang/EasyLang/Kronecker-product new file mode 120000 index 0000000000..1246c0ce28 --- /dev/null +++ b/Lang/EasyLang/Kronecker-product @@ -0,0 +1 @@ +../../Task/Kronecker-product/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Kronecker-product-based-fractals b/Lang/EasyLang/Kronecker-product-based-fractals new file mode 120000 index 0000000000..563af0ba71 --- /dev/null +++ b/Lang/EasyLang/Kronecker-product-based-fractals @@ -0,0 +1 @@ +../../Task/Kronecker-product-based-fractals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Largest-int-from-concatenated-ints b/Lang/EasyLang/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..10e1335e8a --- /dev/null +++ b/Lang/EasyLang/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Last-letter-first-letter b/Lang/EasyLang/Last-letter-first-letter new file mode 120000 index 0000000000..0b195a1260 --- /dev/null +++ b/Lang/EasyLang/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Longest-increasing-subsequence b/Lang/EasyLang/Longest-increasing-subsequence new file mode 120000 index 0000000000..eabf95f750 --- /dev/null +++ b/Lang/EasyLang/Longest-increasing-subsequence @@ -0,0 +1 @@ +../../Task/Longest-increasing-subsequence/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ludic-numbers b/Lang/EasyLang/Ludic-numbers new file mode 120000 index 0000000000..1d6fc2e015 --- /dev/null +++ b/Lang/EasyLang/Ludic-numbers @@ -0,0 +1 @@ +../../Task/Ludic-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Map-range b/Lang/EasyLang/Map-range new file mode 120000 index 0000000000..7f2fe886c3 --- /dev/null +++ b/Lang/EasyLang/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Move-to-front-algorithm b/Lang/EasyLang/Move-to-front-algorithm new file mode 120000 index 0000000000..8c3f8fe7f9 --- /dev/null +++ b/Lang/EasyLang/Move-to-front-algorithm @@ -0,0 +1 @@ +../../Task/Move-to-front-algorithm/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Multisplit b/Lang/EasyLang/Multisplit new file mode 120000 index 0000000000..3f480eaeea --- /dev/null +++ b/Lang/EasyLang/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Negative-base-numbers b/Lang/EasyLang/Negative-base-numbers new file mode 120000 index 0000000000..750b2fa4de --- /dev/null +++ b/Lang/EasyLang/Negative-base-numbers @@ -0,0 +1 @@ +../../Task/Negative-base-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Non-continuous-subsequences b/Lang/EasyLang/Non-continuous-subsequences new file mode 120000 index 0000000000..1ddebfbef7 --- /dev/null +++ b/Lang/EasyLang/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Non-decimal-radices-Input b/Lang/EasyLang/Non-decimal-radices-Input new file mode 120000 index 0000000000..15845b7041 --- /dev/null +++ b/Lang/EasyLang/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Number-reversal-game b/Lang/EasyLang/Number-reversal-game new file mode 120000 index 0000000000..a55399f2e0 --- /dev/null +++ b/Lang/EasyLang/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Partition-an-integer-x-into-n-primes b/Lang/EasyLang/Partition-an-integer-x-into-n-primes new file mode 120000 index 0000000000..21cc93eeed --- /dev/null +++ b/Lang/EasyLang/Partition-an-integer-x-into-n-primes @@ -0,0 +1 @@ +../../Task/Partition-an-integer-x-into-n-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pascal-matrix-generation b/Lang/EasyLang/Pascal-matrix-generation new file mode 120000 index 0000000000..2a45a12baf --- /dev/null +++ b/Lang/EasyLang/Pascal-matrix-generation @@ -0,0 +1 @@ +../../Task/Pascal-matrix-generation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pathological-floating-point-problems b/Lang/EasyLang/Pathological-floating-point-problems new file mode 120000 index 0000000000..feb17cf372 --- /dev/null +++ b/Lang/EasyLang/Pathological-floating-point-problems @@ -0,0 +1 @@ +../../Task/Pathological-floating-point-problems/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Peripheral-drift-illusion b/Lang/EasyLang/Peripheral-drift-illusion new file mode 120000 index 0000000000..6922becd71 --- /dev/null +++ b/Lang/EasyLang/Peripheral-drift-illusion @@ -0,0 +1 @@ +../../Task/Peripheral-drift-illusion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Permutations-Rank-of-a-permutation b/Lang/EasyLang/Permutations-Rank-of-a-permutation new file mode 120000 index 0000000000..0512aed3af --- /dev/null +++ b/Lang/EasyLang/Permutations-Rank-of-a-permutation @@ -0,0 +1 @@ +../../Task/Permutations-Rank-of-a-permutation/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Phrase-reversals b/Lang/EasyLang/Phrase-reversals new file mode 120000 index 0000000000..3631697399 --- /dev/null +++ b/Lang/EasyLang/Phrase-reversals @@ -0,0 +1 @@ +../../Task/Phrase-reversals/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pierpont-primes b/Lang/EasyLang/Pierpont-primes new file mode 120000 index 0000000000..6e3e44c04c --- /dev/null +++ b/Lang/EasyLang/Pierpont-primes @@ -0,0 +1 @@ +../../Task/Pierpont-primes/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pinstripe-Display b/Lang/EasyLang/Pinstripe-Display new file mode 120000 index 0000000000..db25917458 --- /dev/null +++ b/Lang/EasyLang/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Plasma-effect b/Lang/EasyLang/Plasma-effect new file mode 120000 index 0000000000..5f845f7e61 --- /dev/null +++ b/Lang/EasyLang/Plasma-effect @@ -0,0 +1 @@ +../../Task/Plasma-effect/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Pythagorean-quadruples b/Lang/EasyLang/Pythagorean-quadruples new file mode 120000 index 0000000000..63bc250851 --- /dev/null +++ b/Lang/EasyLang/Pythagorean-quadruples @@ -0,0 +1 @@ +../../Task/Pythagorean-quadruples/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Range-expansion b/Lang/EasyLang/Range-expansion new file mode 120000 index 0000000000..b1e04fdc47 --- /dev/null +++ b/Lang/EasyLang/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Rock-paper-scissors b/Lang/EasyLang/Rock-paper-scissors new file mode 120000 index 0000000000..f5bc56ac98 --- /dev/null +++ b/Lang/EasyLang/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Ruth-Aaron-numbers b/Lang/EasyLang/Ruth-Aaron-numbers new file mode 120000 index 0000000000..8c50b35963 --- /dev/null +++ b/Lang/EasyLang/Ruth-Aaron-numbers @@ -0,0 +1 @@ +../../Task/Ruth-Aaron-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem b/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem new file mode 120000 index 0000000000..13c2416787 --- /dev/null +++ b/Lang/EasyLang/Sailors-coconuts-and-a-monkey-problem @@ -0,0 +1 @@ +../../Task/Sailors-coconuts-and-a-monkey-problem/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Scope-Function-names-and-labels b/Lang/EasyLang/Scope-Function-names-and-labels new file mode 120000 index 0000000000..159b6679bd --- /dev/null +++ b/Lang/EasyLang/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string b/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string new file mode 120000 index 0000000000..c9738f521a --- /dev/null +++ b/Lang/EasyLang/Selectively-replace-multiple-instances-of-a-character-within-a-string @@ -0,0 +1 @@ +../../Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Self-numbers b/Lang/EasyLang/Self-numbers new file mode 120000 index 0000000000..219b2abf44 --- /dev/null +++ b/Lang/EasyLang/Self-numbers @@ -0,0 +1 @@ +../../Task/Self-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Show-the-epoch b/Lang/EasyLang/Show-the-epoch new file mode 120000 index 0000000000..67a6b1a9c5 --- /dev/null +++ b/Lang/EasyLang/Show-the-epoch @@ -0,0 +1 @@ +../../Task/Show-the-epoch/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sierpinski-triangle b/Lang/EasyLang/Sierpinski-triangle new file mode 120000 index 0000000000..36520550cb --- /dev/null +++ b/Lang/EasyLang/Sierpinski-triangle @@ -0,0 +1 @@ +../../Task/Sierpinski-triangle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-a-list-of-object-identifiers b/Lang/EasyLang/Sort-a-list-of-object-identifiers new file mode 120000 index 0000000000..6767e4212b --- /dev/null +++ b/Lang/EasyLang/Sort-a-list-of-object-identifiers @@ -0,0 +1 @@ +../../Task/Sort-a-list-of-object-identifiers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-an-integer-array b/Lang/EasyLang/Sort-an-integer-array new file mode 120000 index 0000000000..b6e22e35fd --- /dev/null +++ b/Lang/EasyLang/Sort-an-integer-array @@ -0,0 +1 @@ +../../Task/Sort-an-integer-array/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sort-numbers-lexicographically b/Lang/EasyLang/Sort-numbers-lexicographically new file mode 120000 index 0000000000..096e63b030 --- /dev/null +++ b/Lang/EasyLang/Sort-numbers-lexicographically @@ -0,0 +1 @@ +../../Task/Sort-numbers-lexicographically/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-Algorithms-Circle-Sort b/Lang/EasyLang/Sorting-Algorithms-Circle-Sort new file mode 120000 index 0000000000..575205820f --- /dev/null +++ b/Lang/EasyLang/Sorting-Algorithms-Circle-Sort @@ -0,0 +1 @@ +../../Task/Sorting-Algorithms-Circle-Sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Cocktail-sort b/Lang/EasyLang/Sorting-algorithms-Cocktail-sort new file mode 120000 index 0000000000..6ea90a8bea --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Cocktail-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Cocktail-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Comb-sort b/Lang/EasyLang/Sorting-algorithms-Comb-sort new file mode 120000 index 0000000000..105d051508 --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Comb-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Comb-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Pancake-sort b/Lang/EasyLang/Sorting-algorithms-Pancake-sort new file mode 120000 index 0000000000..7f8da5bd54 --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Pancake-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Pancake-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Permutation-sort b/Lang/EasyLang/Sorting-algorithms-Permutation-sort new file mode 120000 index 0000000000..858ffd0315 --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Permutation-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Permutation-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Shell-sort b/Lang/EasyLang/Sorting-algorithms-Shell-sort new file mode 120000 index 0000000000..f5b30c5803 --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Shell-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Shell-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Sorting-algorithms-Strand-sort b/Lang/EasyLang/Sorting-algorithms-Strand-sort new file mode 120000 index 0000000000..005353ca66 --- /dev/null +++ b/Lang/EasyLang/Sorting-algorithms-Strand-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Strand-sort/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stair-climbing-puzzle b/Lang/EasyLang/Stair-climbing-puzzle new file mode 120000 index 0000000000..e0c07f706d --- /dev/null +++ b/Lang/EasyLang/Stair-climbing-puzzle @@ -0,0 +1 @@ +../../Task/Stair-climbing-puzzle/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Stem-and-leaf-plot b/Lang/EasyLang/Stem-and-leaf-plot new file mode 120000 index 0000000000..cf4dace06c --- /dev/null +++ b/Lang/EasyLang/Stem-and-leaf-plot @@ -0,0 +1 @@ +../../Task/Stem-and-leaf-plot/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Taxicab-numbers b/Lang/EasyLang/Taxicab-numbers new file mode 120000 index 0000000000..7035ad16c4 --- /dev/null +++ b/Lang/EasyLang/Taxicab-numbers @@ -0,0 +1 @@ +../../Task/Taxicab-numbers/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Tokenize-a-string-with-escaping b/Lang/EasyLang/Tokenize-a-string-with-escaping new file mode 120000 index 0000000000..1059b903ad --- /dev/null +++ b/Lang/EasyLang/Tokenize-a-string-with-escaping @@ -0,0 +1 @@ +../../Task/Tokenize-a-string-with-escaping/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Top-rank-per-group b/Lang/EasyLang/Top-rank-per-group new file mode 120000 index 0000000000..861db59645 --- /dev/null +++ b/Lang/EasyLang/Top-rank-per-group @@ -0,0 +1 @@ +../../Task/Top-rank-per-group/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Verify-distribution-uniformity-Naive b/Lang/EasyLang/Verify-distribution-uniformity-Naive new file mode 120000 index 0000000000..bc6d548e1b --- /dev/null +++ b/Lang/EasyLang/Verify-distribution-uniformity-Naive @@ -0,0 +1 @@ +../../Task/Verify-distribution-uniformity-Naive/EasyLang \ No newline at end of file diff --git a/Lang/EasyLang/Zig-zag-matrix b/Lang/EasyLang/Zig-zag-matrix new file mode 120000 index 0000000000..59c91477d5 --- /dev/null +++ b/Lang/EasyLang/Zig-zag-matrix @@ -0,0 +1 @@ +../../Task/Zig-zag-matrix/EasyLang \ No newline at end of file diff --git a/Lang/Ecstasy/00-LANG.txt b/Lang/Ecstasy/00-LANG.txt index 7358e7f1ea..9c977a310d 100644 --- a/Lang/Ecstasy/00-LANG.txt +++ b/Lang/Ecstasy/00-LANG.txt @@ -25,4 +25,7 @@ The primary benefits of Ecstasy are: * A security model designed for the serverless cloud, using lightweight software containers and dependency injection (IOC/DI) * A reified generic type system with support for unions, intersection, and difference types, first-class tuples and functions, type inference, and type-safe mixins * Built-in concurrency support, with first-class support for object immutability, and the elimination of shared-mutable data -* All of the modern capabilities that developers have grown to depend on, such as: [[garbage collection|Automatic memory management]], an integrated module system, first-class lambdas and functions, partial binding and currying, cross-platform portability, and an open source development model \ No newline at end of file +* All of the modern capabilities that developers have grown to depend on, such as: [[garbage collection|Automatic memory management]], an integrated module system, first-class lambdas and functions, partial binding and currying, cross-platform portability, and an open source development model + +==TODO== +* [[Tasks not implemented in Ecstasy]] \ No newline at end of file diff --git a/Lang/Ecstasy/100-prisoners b/Lang/Ecstasy/100-prisoners new file mode 120000 index 0000000000..e9fb2d2f70 --- /dev/null +++ b/Lang/Ecstasy/100-prisoners @@ -0,0 +1 @@ +../../Task/100-prisoners/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Assertions b/Lang/Ecstasy/Assertions new file mode 120000 index 0000000000..0802d10c0c --- /dev/null +++ b/Lang/Ecstasy/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Pointers-and-references b/Lang/Ecstasy/Pointers-and-references new file mode 120000 index 0000000000..9b85919b2d --- /dev/null +++ b/Lang/Ecstasy/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Program-name b/Lang/Ecstasy/Program-name new file mode 120000 index 0000000000..6411623f47 --- /dev/null +++ b/Lang/Ecstasy/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Reflection-List-methods b/Lang/Ecstasy/Reflection-List-methods new file mode 120000 index 0000000000..f4010fce77 --- /dev/null +++ b/Lang/Ecstasy/Reflection-List-methods @@ -0,0 +1 @@ +../../Task/Reflection-List-methods/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Reflection-List-properties b/Lang/Ecstasy/Reflection-List-properties new file mode 120000 index 0000000000..40ec86fd95 --- /dev/null +++ b/Lang/Ecstasy/Reflection-List-properties @@ -0,0 +1 @@ +../../Task/Reflection-List-properties/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Search-a-list b/Lang/Ecstasy/Search-a-list new file mode 120000 index 0000000000..f6044e825c --- /dev/null +++ b/Lang/Ecstasy/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Send-an-unknown-method-call b/Lang/Ecstasy/Send-an-unknown-method-call new file mode 120000 index 0000000000..5d1a4cbed5 --- /dev/null +++ b/Lang/Ecstasy/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Singleton b/Lang/Ecstasy/Singleton new file mode 120000 index 0000000000..8c9a0eb1b2 --- /dev/null +++ b/Lang/Ecstasy/Singleton @@ -0,0 +1 @@ +../../Task/Singleton/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-case b/Lang/Ecstasy/String-case new file mode 120000 index 0000000000..75c8cc65c2 --- /dev/null +++ b/Lang/Ecstasy/String-case @@ -0,0 +1 @@ +../../Task/String-case/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-comparison b/Lang/Ecstasy/String-comparison new file mode 120000 index 0000000000..2a690e7c01 --- /dev/null +++ b/Lang/Ecstasy/String-comparison @@ -0,0 +1 @@ +../../Task/String-comparison/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-concatenation b/Lang/Ecstasy/String-concatenation new file mode 120000 index 0000000000..a8fc37bb41 --- /dev/null +++ b/Lang/Ecstasy/String-concatenation @@ -0,0 +1 @@ +../../Task/String-concatenation/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/String-length b/Lang/Ecstasy/String-length new file mode 120000 index 0000000000..e3f6d6a12a --- /dev/null +++ b/Lang/Ecstasy/String-length @@ -0,0 +1 @@ +../../Task/String-length/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Substring b/Lang/Ecstasy/Substring new file mode 120000 index 0000000000..59160f9d22 --- /dev/null +++ b/Lang/Ecstasy/Substring @@ -0,0 +1 @@ +../../Task/Substring/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/Substring-Top-and-tail b/Lang/Ecstasy/Substring-Top-and-tail new file mode 120000 index 0000000000..cf035aa347 --- /dev/null +++ b/Lang/Ecstasy/Substring-Top-and-tail @@ -0,0 +1 @@ +../../Task/Substring-Top-and-tail/Ecstasy \ No newline at end of file diff --git a/Lang/Ecstasy/System-time b/Lang/Ecstasy/System-time new file mode 120000 index 0000000000..4b0a593cce --- /dev/null +++ b/Lang/Ecstasy/System-time @@ -0,0 +1 @@ +../../Task/System-time/Ecstasy \ No newline at end of file diff --git a/Lang/Elixir/Parallel-brute-force b/Lang/Elixir/Parallel-brute-force new file mode 120000 index 0000000000..154ccc9bb9 --- /dev/null +++ b/Lang/Elixir/Parallel-brute-force @@ -0,0 +1 @@ +../../Task/Parallel-brute-force/Elixir \ No newline at end of file diff --git a/Lang/Elm/Caesar-cipher b/Lang/Elm/Caesar-cipher new file mode 120000 index 0000000000..e2f4604523 --- /dev/null +++ b/Lang/Elm/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Elm \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Abbreviations-automatic b/Lang/Emacs-Lisp/Abbreviations-automatic new file mode 120000 index 0000000000..917fbde092 --- /dev/null +++ b/Lang/Emacs-Lisp/Abbreviations-automatic @@ -0,0 +1 @@ +../../Task/Abbreviations-automatic/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Anagrams b/Lang/Emacs-Lisp/Anagrams new file mode 120000 index 0000000000..0bf987f884 --- /dev/null +++ b/Lang/Emacs-Lisp/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Compare-length-of-two-strings b/Lang/Emacs-Lisp/Compare-length-of-two-strings new file mode 120000 index 0000000000..2aa87a97f8 --- /dev/null +++ b/Lang/Emacs-Lisp/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Date-manipulation b/Lang/Emacs-Lisp/Date-manipulation new file mode 120000 index 0000000000..d88e6a9576 --- /dev/null +++ b/Lang/Emacs-Lisp/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric b/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..2314291eaa --- /dev/null +++ b/Lang/Emacs-Lisp/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Determine-sentence-type b/Lang/Emacs-Lisp/Determine-sentence-type new file mode 120000 index 0000000000..633b068253 --- /dev/null +++ b/Lang/Emacs-Lisp/Determine-sentence-type @@ -0,0 +1 @@ +../../Task/Determine-sentence-type/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Ordered-words b/Lang/Emacs-Lisp/Ordered-words new file mode 120000 index 0000000000..444b596fcd --- /dev/null +++ b/Lang/Emacs-Lisp/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Snake b/Lang/Emacs-Lisp/Snake new file mode 120000 index 0000000000..b334d7a373 --- /dev/null +++ b/Lang/Emacs-Lisp/Snake @@ -0,0 +1 @@ +../../Task/Snake/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Substitution-cipher b/Lang/Emacs-Lisp/Substitution-cipher new file mode 120000 index 0000000000..93f7ee4d63 --- /dev/null +++ b/Lang/Emacs-Lisp/Substitution-cipher @@ -0,0 +1 @@ +../../Task/Substitution-cipher/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Fortran/Sleeping-Beauty-problem b/Lang/Fortran/Sleeping-Beauty-problem new file mode 120000 index 0000000000..35b7547112 --- /dev/null +++ b/Lang/Fortran/Sleeping-Beauty-problem @@ -0,0 +1 @@ +../../Task/Sleeping-Beauty-problem/Fortran \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Bin-given-limits b/Lang/Free-Pascal-Lazarus/Bin-given-limits new file mode 120000 index 0000000000..090d25165e --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Bin-given-limits @@ -0,0 +1 @@ +../../Task/Bin-given-limits/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Closures-Value-capture b/Lang/Free-Pascal-Lazarus/Closures-Value-capture new file mode 120000 index 0000000000..4b2493493f --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Closures-Value-capture @@ -0,0 +1 @@ +../../Task/Closures-Value-capture/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/Parallel-calculations b/Lang/Free-Pascal-Lazarus/Parallel-calculations new file mode 120000 index 0000000000..191ed1dae7 --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Free-Pascal-Lazarus \ No newline at end of file diff --git a/Lang/FreeBASIC/B-zier-curves-Intersections b/Lang/FreeBASIC/B-zier-curves-Intersections new file mode 120000 index 0000000000..e1718d7dc9 --- /dev/null +++ b/Lang/FreeBASIC/B-zier-curves-Intersections @@ -0,0 +1 @@ +../../Task/B-zier-curves-Intersections/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Constrained-genericity b/Lang/FreeBASIC/Constrained-genericity new file mode 120000 index 0000000000..1fc68e6907 --- /dev/null +++ b/Lang/FreeBASIC/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Execute-Computer-Zero b/Lang/FreeBASIC/Execute-Computer-Zero new file mode 120000 index 0000000000..018dffe9b4 --- /dev/null +++ b/Lang/FreeBASIC/Execute-Computer-Zero @@ -0,0 +1 @@ +../../Task/Execute-Computer-Zero/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Execute-SNUSP b/Lang/FreeBASIC/Execute-SNUSP new file mode 120000 index 0000000000..7b179aedb8 --- /dev/null +++ b/Lang/FreeBASIC/Execute-SNUSP @@ -0,0 +1 @@ +../../Task/Execute-SNUSP/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Execute-a-Markov-algorithm b/Lang/FreeBASIC/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..7f61263c19 --- /dev/null +++ b/Lang/FreeBASIC/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Imaginary-base-numbers b/Lang/FreeBASIC/Imaginary-base-numbers new file mode 120000 index 0000000000..00ee9d8fe6 --- /dev/null +++ b/Lang/FreeBASIC/Imaginary-base-numbers @@ -0,0 +1 @@ +../../Task/Imaginary-base-numbers/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Nested-templated-data b/Lang/FreeBASIC/Nested-templated-data new file mode 120000 index 0000000000..064256a2d8 --- /dev/null +++ b/Lang/FreeBASIC/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Padovan-sequence b/Lang/FreeBASIC/Padovan-sequence new file mode 120000 index 0000000000..efb5ea56df --- /dev/null +++ b/Lang/FreeBASIC/Padovan-sequence @@ -0,0 +1 @@ +../../Task/Padovan-sequence/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Pseudo-random-numbers-PCG32 b/Lang/FreeBASIC/Pseudo-random-numbers-PCG32 new file mode 120000 index 0000000000..8a007fed91 --- /dev/null +++ b/Lang/FreeBASIC/Pseudo-random-numbers-PCG32 @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-PCG32/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Pseudo-random-numbers-Splitmix64 b/Lang/FreeBASIC/Pseudo-random-numbers-Splitmix64 new file mode 120000 index 0000000000..233c73713f --- /dev/null +++ b/Lang/FreeBASIC/Pseudo-random-numbers-Splitmix64 @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Splitmix64/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Pseudo-random-numbers-Xorshift-star b/Lang/FreeBASIC/Pseudo-random-numbers-Xorshift-star new file mode 120000 index 0000000000..a40446f6c8 --- /dev/null +++ b/Lang/FreeBASIC/Pseudo-random-numbers-Xorshift-star @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Xorshift-star/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Runtime-evaluation-In-an-environment b/Lang/FreeBASIC/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..80c5a69b35 --- /dev/null +++ b/Lang/FreeBASIC/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Solve-the-no-connection-puzzle b/Lang/FreeBASIC/Solve-the-no-connection-puzzle new file mode 120000 index 0000000000..b14a0d6097 --- /dev/null +++ b/Lang/FreeBASIC/Solve-the-no-connection-puzzle @@ -0,0 +1 @@ +../../Task/Solve-the-no-connection-puzzle/FreeBASIC \ No newline at end of file diff --git a/Lang/FreeBASIC/Write-to-Windows-event-log b/Lang/FreeBASIC/Write-to-Windows-event-log new file mode 120000 index 0000000000..8993ae4828 --- /dev/null +++ b/Lang/FreeBASIC/Write-to-Windows-event-log @@ -0,0 +1 @@ +../../Task/Write-to-Windows-event-log/FreeBASIC \ No newline at end of file diff --git a/Lang/Frink/24-game b/Lang/Frink/24-game new file mode 120000 index 0000000000..843d6f51e2 --- /dev/null +++ b/Lang/Frink/24-game @@ -0,0 +1 @@ +../../Task/24-game/Frink \ No newline at end of file diff --git a/Lang/FutureBasic/24-game b/Lang/FutureBasic/24-game new file mode 120000 index 0000000000..f1ea3d0684 --- /dev/null +++ b/Lang/FutureBasic/24-game @@ -0,0 +1 @@ +../../Task/24-game/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/ASCII-art-diagram-converter b/Lang/FutureBasic/ASCII-art-diagram-converter new file mode 120000 index 0000000000..cb5711ff54 --- /dev/null +++ b/Lang/FutureBasic/ASCII-art-diagram-converter @@ -0,0 +1 @@ +../../Task/ASCII-art-diagram-converter/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Arbitrary-precision-integers-included- b/Lang/FutureBasic/Arbitrary-precision-integers-included- new file mode 120000 index 0000000000..ca9deb04e2 --- /dev/null +++ b/Lang/FutureBasic/Arbitrary-precision-integers-included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included-/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Biorhythms b/Lang/FutureBasic/Biorhythms new file mode 120000 index 0000000000..db55b5c43b --- /dev/null +++ b/Lang/FutureBasic/Biorhythms @@ -0,0 +1 @@ +../../Task/Biorhythms/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Brilliant-numbers b/Lang/FutureBasic/Brilliant-numbers new file mode 120000 index 0000000000..0ee49e027a --- /dev/null +++ b/Lang/FutureBasic/Brilliant-numbers @@ -0,0 +1 @@ +../../Task/Brilliant-numbers/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Check-output-device-is-a-terminal b/Lang/FutureBasic/Check-output-device-is-a-terminal new file mode 120000 index 0000000000..e2e8c9c4eb --- /dev/null +++ b/Lang/FutureBasic/Check-output-device-is-a-terminal @@ -0,0 +1 @@ +../../Task/Check-output-device-is-a-terminal/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Combinations b/Lang/FutureBasic/Combinations new file mode 120000 index 0000000000..d7395ea4d1 --- /dev/null +++ b/Lang/FutureBasic/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Copy-stdin-to-stdout b/Lang/FutureBasic/Copy-stdin-to-stdout new file mode 120000 index 0000000000..9a5df43082 --- /dev/null +++ b/Lang/FutureBasic/Copy-stdin-to-stdout @@ -0,0 +1 @@ +../../Task/Copy-stdin-to-stdout/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Determine-sentence-type b/Lang/FutureBasic/Determine-sentence-type new file mode 120000 index 0000000000..fce2322962 --- /dev/null +++ b/Lang/FutureBasic/Determine-sentence-type @@ -0,0 +1 @@ +../../Task/Determine-sentence-type/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Floyds-triangle b/Lang/FutureBasic/Floyds-triangle new file mode 120000 index 0000000000..134b2be232 --- /dev/null +++ b/Lang/FutureBasic/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Function-prototype b/Lang/FutureBasic/Function-prototype new file mode 120000 index 0000000000..00a31e111b --- /dev/null +++ b/Lang/FutureBasic/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Go-Fish b/Lang/FutureBasic/Go-Fish new file mode 120000 index 0000000000..cc2210d25a --- /dev/null +++ b/Lang/FutureBasic/Go-Fish @@ -0,0 +1 @@ +../../Task/Go-Fish/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Honeycombs b/Lang/FutureBasic/Honeycombs new file mode 120000 index 0000000000..306c30d982 --- /dev/null +++ b/Lang/FutureBasic/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Monty-Hall-problem b/Lang/FutureBasic/Monty-Hall-problem new file mode 120000 index 0000000000..0d9da7e7cc --- /dev/null +++ b/Lang/FutureBasic/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/FutureBasic \ No newline at end of file diff --git a/Lang/FutureBasic/Record-sound b/Lang/FutureBasic/Record-sound new file mode 120000 index 0000000000..7ce89c688d --- /dev/null +++ b/Lang/FutureBasic/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/FutureBasic \ No newline at end of file diff --git a/Lang/GW-BASIC/Damm-algorithm b/Lang/GW-BASIC/Damm-algorithm new file mode 120000 index 0000000000..b0cc19e6df --- /dev/null +++ b/Lang/GW-BASIC/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Display-a-linear-combination b/Lang/GW-BASIC/Display-a-linear-combination new file mode 120000 index 0000000000..8162367d7b --- /dev/null +++ b/Lang/GW-BASIC/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Gray-code b/Lang/GW-BASIC/Gray-code new file mode 120000 index 0000000000..a45f2031ed --- /dev/null +++ b/Lang/GW-BASIC/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Jensens-Device b/Lang/GW-BASIC/Jensens-Device new file mode 120000 index 0000000000..0236b00319 --- /dev/null +++ b/Lang/GW-BASIC/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Nested-templated-data b/Lang/GW-BASIC/Nested-templated-data new file mode 120000 index 0000000000..bb39849801 --- /dev/null +++ b/Lang/GW-BASIC/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Primality-by-trial-division b/Lang/GW-BASIC/Primality-by-trial-division new file mode 120000 index 0000000000..2b782a101b --- /dev/null +++ b/Lang/GW-BASIC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Vector b/Lang/GW-BASIC/Vector new file mode 120000 index 0000000000..6d1d7a6796 --- /dev/null +++ b/Lang/GW-BASIC/Vector @@ -0,0 +1 @@ +../../Task/Vector/GW-BASIC \ No newline at end of file diff --git a/Lang/Gambas/Jensens-Device b/Lang/Gambas/Jensens-Device new file mode 120000 index 0000000000..cf682dd548 --- /dev/null +++ b/Lang/Gambas/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Gambas \ No newline at end of file diff --git a/Lang/Gambas/M-bius-function b/Lang/Gambas/M-bius-function new file mode 120000 index 0000000000..4846367944 --- /dev/null +++ b/Lang/Gambas/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Proper-divisors b/Lang/Gambas/Proper-divisors new file mode 120000 index 0000000000..c95a4aae71 --- /dev/null +++ b/Lang/Gambas/Proper-divisors @@ -0,0 +1 @@ +../../Task/Proper-divisors/Gambas \ No newline at end of file diff --git a/Lang/Go/Factorial-primes b/Lang/Go/Factorial-primes new file mode 120000 index 0000000000..5b25426fd0 --- /dev/null +++ b/Lang/Go/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Go \ No newline at end of file diff --git a/Lang/Java/Arena-storage-pool b/Lang/Java/Arena-storage-pool new file mode 120000 index 0000000000..11592b83c1 --- /dev/null +++ b/Lang/Java/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/Java \ No newline at end of file diff --git a/Lang/Java/Bitcoin-public-point-to-address b/Lang/Java/Bitcoin-public-point-to-address new file mode 120000 index 0000000000..cbdcab404f --- /dev/null +++ b/Lang/Java/Bitcoin-public-point-to-address @@ -0,0 +1 @@ +../../Task/Bitcoin-public-point-to-address/Java \ No newline at end of file diff --git a/Lang/Java/Catmull-Clark-subdivision-surface b/Lang/Java/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..cc0173bf86 --- /dev/null +++ b/Lang/Java/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/Java \ No newline at end of file diff --git a/Lang/Java/Compiler-virtual-machine-interpreter b/Lang/Java/Compiler-virtual-machine-interpreter new file mode 120000 index 0000000000..8a6c333099 --- /dev/null +++ b/Lang/Java/Compiler-virtual-machine-interpreter @@ -0,0 +1 @@ +../../Task/Compiler-virtual-machine-interpreter/Java \ No newline at end of file diff --git a/Lang/Java/Im-a-software-engineer-get-me-out-of-here b/Lang/Java/Im-a-software-engineer-get-me-out-of-here new file mode 120000 index 0000000000..5e4c7fd308 --- /dev/null +++ b/Lang/Java/Im-a-software-engineer-get-me-out-of-here @@ -0,0 +1 @@ +../../Task/Im-a-software-engineer-get-me-out-of-here/Java \ No newline at end of file diff --git a/Lang/Java/P-Adic-square-roots b/Lang/Java/P-Adic-square-roots new file mode 120000 index 0000000000..768922bdbb --- /dev/null +++ b/Lang/Java/P-Adic-square-roots @@ -0,0 +1 @@ +../../Task/P-Adic-square-roots/Java \ No newline at end of file diff --git a/Lang/Java/Topic-variable b/Lang/Java/Topic-variable new file mode 120000 index 0000000000..25c03be6d5 --- /dev/null +++ b/Lang/Java/Topic-variable @@ -0,0 +1 @@ +../../Task/Topic-variable/Java \ No newline at end of file diff --git a/Lang/Jq/00-LANG.txt b/Lang/Jq/00-LANG.txt index 3eba7f05c0..a2d6626be7 100644 --- a/Lang/Jq/00-LANG.txt +++ b/Lang/Jq/00-LANG.txt @@ -7,9 +7,14 @@ jq was originally designed and developed by Stephen Dolan. ==jq Modules at rosettacode.org== * [[:Category:Jq/assert.jq|assert.jq]] - module to support assertions +* [[:Category:Jq/bitwise.jq|bitwise.jq]] - bit streams, bit arrays, and integers * [[:Category:Jq/fibonacci.jq|fibonacci.jq]] - Fibonacci sequence and Fibonacci coding * [[:Category:Jq/peg.jq|peg.jq]] - Parsing Expression Grammar foundations * [[:Category:Jq/polynomials.jq|polynomials.jq]] - polynomials as JSON arrays +* [[:Category:Jq/rational.jq|rational.jq]] - rational numbers + +* [[:Category:Jq/Date.jq|Date.jq]] - Gregorian calendar from the year 1 +* [[:Category:Jq/MRG32k3a.jq|MRG32k3a.jq]] - MRG32k3a Combined Recursive Pseudo-Random Number Generator * [[:Category:Jq/RealSet.jq|RealSet.jq]] - Union of finite real intervals ==Todo== diff --git a/Lang/Jq/2048 b/Lang/Jq/2048 new file mode 120000 index 0000000000..e78d154a28 --- /dev/null +++ b/Lang/Jq/2048 @@ -0,0 +1 @@ +../../Task/2048/Jq \ No newline at end of file diff --git a/Lang/Jq/24-game b/Lang/Jq/24-game new file mode 120000 index 0000000000..1db8a29eb4 --- /dev/null +++ b/Lang/Jq/24-game @@ -0,0 +1 @@ +../../Task/24-game/Jq \ No newline at end of file diff --git a/Lang/Jq/Averages-Simple-moving-average b/Lang/Jq/Averages-Simple-moving-average new file mode 120000 index 0000000000..7c27d5bee2 --- /dev/null +++ b/Lang/Jq/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Jq \ No newline at end of file diff --git a/Lang/Jq/Bitwise-operations b/Lang/Jq/Bitwise-operations new file mode 120000 index 0000000000..eff5a2f904 --- /dev/null +++ b/Lang/Jq/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Jq \ No newline at end of file diff --git a/Lang/Jq/CRC-32 b/Lang/Jq/CRC-32 new file mode 120000 index 0000000000..800ab8f0ad --- /dev/null +++ b/Lang/Jq/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Jq \ No newline at end of file diff --git a/Lang/Jq/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Jq/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..90c56c3b3a --- /dev/null +++ b/Lang/Jq/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Jq \ No newline at end of file diff --git a/Lang/Jq/Deconvolution-1D b/Lang/Jq/Deconvolution-1D new file mode 120000 index 0000000000..4f872c1005 --- /dev/null +++ b/Lang/Jq/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Jq \ No newline at end of file diff --git a/Lang/Jq/Display-an-outline-as-a-nested-table b/Lang/Jq/Display-an-outline-as-a-nested-table new file mode 120000 index 0000000000..37137659b6 --- /dev/null +++ b/Lang/Jq/Display-an-outline-as-a-nested-table @@ -0,0 +1 @@ +../../Task/Display-an-outline-as-a-nested-table/Jq \ No newline at end of file diff --git a/Lang/Jq/Draw-a-cuboid b/Lang/Jq/Draw-a-cuboid new file mode 120000 index 0000000000..2af657c230 --- /dev/null +++ b/Lang/Jq/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Jq \ No newline at end of file diff --git a/Lang/Jq/Entropy-Narcissist b/Lang/Jq/Entropy-Narcissist new file mode 120000 index 0000000000..f142d7e681 --- /dev/null +++ b/Lang/Jq/Entropy-Narcissist @@ -0,0 +1 @@ +../../Task/Entropy-Narcissist/Jq \ No newline at end of file diff --git a/Lang/Jq/Factors-of-a-Mersenne-number b/Lang/Jq/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..e34af6567d --- /dev/null +++ b/Lang/Jq/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Jq \ No newline at end of file diff --git a/Lang/Jq/File-size-distribution b/Lang/Jq/File-size-distribution new file mode 120000 index 0000000000..d42e94402e --- /dev/null +++ b/Lang/Jq/File-size-distribution @@ -0,0 +1 @@ +../../Task/File-size-distribution/Jq \ No newline at end of file diff --git a/Lang/Jq/Find-Chess960-starting-position-identifier b/Lang/Jq/Find-Chess960-starting-position-identifier new file mode 120000 index 0000000000..ea292cff65 --- /dev/null +++ b/Lang/Jq/Find-Chess960-starting-position-identifier @@ -0,0 +1 @@ +../../Task/Find-Chess960-starting-position-identifier/Jq \ No newline at end of file diff --git a/Lang/Jq/Find-duplicate-files b/Lang/Jq/Find-duplicate-files new file mode 120000 index 0000000000..289f08d02f --- /dev/null +++ b/Lang/Jq/Find-duplicate-files @@ -0,0 +1 @@ +../../Task/Find-duplicate-files/Jq \ No newline at end of file diff --git a/Lang/Jq/French-Republican-calendar b/Lang/Jq/French-Republican-calendar new file mode 120000 index 0000000000..d495d14d71 --- /dev/null +++ b/Lang/Jq/French-Republican-calendar @@ -0,0 +1 @@ +../../Task/French-Republican-calendar/Jq \ No newline at end of file diff --git a/Lang/Jq/Generate-random-chess-position b/Lang/Jq/Generate-random-chess-position new file mode 120000 index 0000000000..a6ff2b1df0 --- /dev/null +++ b/Lang/Jq/Generate-random-chess-position @@ -0,0 +1 @@ +../../Task/Generate-random-chess-position/Jq \ No newline at end of file diff --git a/Lang/Jq/Giuga-numbers b/Lang/Jq/Giuga-numbers new file mode 120000 index 0000000000..b5850902a3 --- /dev/null +++ b/Lang/Jq/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/Jq \ No newline at end of file diff --git a/Lang/Jq/Graph-colouring b/Lang/Jq/Graph-colouring new file mode 120000 index 0000000000..07b418f3a3 --- /dev/null +++ b/Lang/Jq/Graph-colouring @@ -0,0 +1 @@ +../../Task/Graph-colouring/Jq \ No newline at end of file diff --git a/Lang/Jq/Introspection b/Lang/Jq/Introspection new file mode 120000 index 0000000000..cdb6f22cc1 --- /dev/null +++ b/Lang/Jq/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Jq \ No newline at end of file diff --git a/Lang/Jq/Knights-tour b/Lang/Jq/Knights-tour new file mode 120000 index 0000000000..ca47275558 --- /dev/null +++ b/Lang/Jq/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Jq \ No newline at end of file diff --git a/Lang/Jq/Levenshtein-distance-Alignment b/Lang/Jq/Levenshtein-distance-Alignment new file mode 120000 index 0000000000..b331da38ff --- /dev/null +++ b/Lang/Jq/Levenshtein-distance-Alignment @@ -0,0 +1 @@ +../../Task/Levenshtein-distance-Alignment/Jq \ No newline at end of file diff --git a/Lang/Jq/Mayan-calendar b/Lang/Jq/Mayan-calendar new file mode 120000 index 0000000000..aa0964c1d8 --- /dev/null +++ b/Lang/Jq/Mayan-calendar @@ -0,0 +1 @@ +../../Task/Mayan-calendar/Jq \ No newline at end of file diff --git a/Lang/Jq/Mind-boggling-card-trick b/Lang/Jq/Mind-boggling-card-trick new file mode 120000 index 0000000000..11a1e6dd3d --- /dev/null +++ b/Lang/Jq/Mind-boggling-card-trick @@ -0,0 +1 @@ +../../Task/Mind-boggling-card-trick/Jq \ No newline at end of file diff --git a/Lang/Jq/Minimal-steps-down-to-1 b/Lang/Jq/Minimal-steps-down-to-1 new file mode 120000 index 0000000000..d05488db25 --- /dev/null +++ b/Lang/Jq/Minimal-steps-down-to-1 @@ -0,0 +1 @@ +../../Task/Minimal-steps-down-to-1/Jq \ No newline at end of file diff --git a/Lang/Jq/Modified-random-distribution b/Lang/Jq/Modified-random-distribution new file mode 120000 index 0000000000..5585f4b8dd --- /dev/null +++ b/Lang/Jq/Modified-random-distribution @@ -0,0 +1 @@ +../../Task/Modified-random-distribution/Jq \ No newline at end of file diff --git a/Lang/Jq/Multiplicative-order b/Lang/Jq/Multiplicative-order new file mode 120000 index 0000000000..72c4d667a9 --- /dev/null +++ b/Lang/Jq/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Jq \ No newline at end of file diff --git a/Lang/Jq/Nonoblock b/Lang/Jq/Nonoblock new file mode 120000 index 0000000000..f2323057e5 --- /dev/null +++ b/Lang/Jq/Nonoblock @@ -0,0 +1 @@ +../../Task/Nonoblock/Jq \ No newline at end of file diff --git a/Lang/Jq/Nonogram-solver b/Lang/Jq/Nonogram-solver new file mode 120000 index 0000000000..2ae5949d16 --- /dev/null +++ b/Lang/Jq/Nonogram-solver @@ -0,0 +1 @@ +../../Task/Nonogram-solver/Jq \ No newline at end of file diff --git a/Lang/Jq/P-value-correction b/Lang/Jq/P-value-correction new file mode 120000 index 0000000000..4685fd057d --- /dev/null +++ b/Lang/Jq/P-value-correction @@ -0,0 +1 @@ +../../Task/P-value-correction/Jq \ No newline at end of file diff --git a/Lang/Jq/Palindromic-gapful-numbers b/Lang/Jq/Palindromic-gapful-numbers new file mode 120000 index 0000000000..3f1d4b0a65 --- /dev/null +++ b/Lang/Jq/Palindromic-gapful-numbers @@ -0,0 +1 @@ +../../Task/Palindromic-gapful-numbers/Jq \ No newline at end of file diff --git a/Lang/Jq/Peaceful-chess-queen-armies b/Lang/Jq/Peaceful-chess-queen-armies new file mode 120000 index 0000000000..7c675a3306 --- /dev/null +++ b/Lang/Jq/Peaceful-chess-queen-armies @@ -0,0 +1 @@ +../../Task/Peaceful-chess-queen-armies/Jq \ No newline at end of file diff --git a/Lang/Jq/Pentomino-tiling b/Lang/Jq/Pentomino-tiling new file mode 120000 index 0000000000..cce133df04 --- /dev/null +++ b/Lang/Jq/Pentomino-tiling @@ -0,0 +1 @@ +../../Task/Pentomino-tiling/Jq \ No newline at end of file diff --git a/Lang/Jq/Perlin-noise b/Lang/Jq/Perlin-noise new file mode 120000 index 0000000000..eb52c317a2 --- /dev/null +++ b/Lang/Jq/Perlin-noise @@ -0,0 +1 @@ +../../Task/Perlin-noise/Jq \ No newline at end of file diff --git a/Lang/Jq/Pisano-period b/Lang/Jq/Pisano-period new file mode 120000 index 0000000000..223468a26a --- /dev/null +++ b/Lang/Jq/Pisano-period @@ -0,0 +1 @@ +../../Task/Pisano-period/Jq \ No newline at end of file diff --git a/Lang/Jq/Poker-hand-analyser b/Lang/Jq/Poker-hand-analyser new file mode 120000 index 0000000000..fd9738ce61 --- /dev/null +++ b/Lang/Jq/Poker-hand-analyser @@ -0,0 +1 @@ +../../Task/Poker-hand-analyser/Jq \ No newline at end of file diff --git a/Lang/Jq/Polynomial-regression b/Lang/Jq/Polynomial-regression new file mode 120000 index 0000000000..56985e2ba4 --- /dev/null +++ b/Lang/Jq/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Jq \ No newline at end of file diff --git a/Lang/Jq/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a b/Lang/Jq/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a new file mode 120000 index 0000000000..8a1fa69d52 --- /dev/null +++ b/Lang/Jq/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/Jq \ No newline at end of file diff --git a/Lang/Jq/Pseudo-random-numbers-PCG32 b/Lang/Jq/Pseudo-random-numbers-PCG32 new file mode 120000 index 0000000000..c80dea5d5d --- /dev/null +++ b/Lang/Jq/Pseudo-random-numbers-PCG32 @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-PCG32/Jq \ No newline at end of file diff --git a/Lang/Jq/Pseudo-random-numbers-Xorshift-star b/Lang/Jq/Pseudo-random-numbers-Xorshift-star new file mode 120000 index 0000000000..54ff010417 --- /dev/null +++ b/Lang/Jq/Pseudo-random-numbers-Xorshift-star @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Xorshift-star/Jq \ No newline at end of file diff --git a/Lang/Jq/Ramer-Douglas-Peucker-line-simplification b/Lang/Jq/Ramer-Douglas-Peucker-line-simplification new file mode 120000 index 0000000000..2692c011c6 --- /dev/null +++ b/Lang/Jq/Ramer-Douglas-Peucker-line-simplification @@ -0,0 +1 @@ +../../Task/Ramer-Douglas-Peucker-line-simplification/Jq \ No newline at end of file diff --git a/Lang/Jq/Random-sentence-from-book b/Lang/Jq/Random-sentence-from-book new file mode 120000 index 0000000000..677f7ffdcc --- /dev/null +++ b/Lang/Jq/Random-sentence-from-book @@ -0,0 +1 @@ +../../Task/Random-sentence-from-book/Jq \ No newline at end of file diff --git a/Lang/Jq/Rosetta-Code-Rank-languages-by-number-of-users b/Lang/Jq/Rosetta-Code-Rank-languages-by-number-of-users new file mode 120000 index 0000000000..41c301e751 --- /dev/null +++ b/Lang/Jq/Rosetta-Code-Rank-languages-by-number-of-users @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-number-of-users/Jq \ No newline at end of file diff --git a/Lang/Jq/Set-puzzle b/Lang/Jq/Set-puzzle new file mode 120000 index 0000000000..4d4860ff33 --- /dev/null +++ b/Lang/Jq/Set-puzzle @@ -0,0 +1 @@ +../../Task/Set-puzzle/Jq \ No newline at end of file diff --git a/Lang/Jq/Set-right-adjacent-bits b/Lang/Jq/Set-right-adjacent-bits new file mode 120000 index 0000000000..74d85af7c9 --- /dev/null +++ b/Lang/Jq/Set-right-adjacent-bits @@ -0,0 +1 @@ +../../Task/Set-right-adjacent-bits/Jq \ No newline at end of file diff --git a/Lang/Jq/Sierpinski-pentagon b/Lang/Jq/Sierpinski-pentagon new file mode 120000 index 0000000000..25b52521df --- /dev/null +++ b/Lang/Jq/Sierpinski-pentagon @@ -0,0 +1 @@ +../../Task/Sierpinski-pentagon/Jq \ No newline at end of file diff --git a/Lang/Jq/Sleeping-Beauty-problem b/Lang/Jq/Sleeping-Beauty-problem new file mode 120000 index 0000000000..56204d6c76 --- /dev/null +++ b/Lang/Jq/Sleeping-Beauty-problem @@ -0,0 +1 @@ +../../Task/Sleeping-Beauty-problem/Jq \ No newline at end of file diff --git a/Lang/Jq/Solve-a-Hidato-puzzle b/Lang/Jq/Solve-a-Hidato-puzzle new file mode 120000 index 0000000000..e3f6b38721 --- /dev/null +++ b/Lang/Jq/Solve-a-Hidato-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Hidato-puzzle/Jq \ No newline at end of file diff --git a/Lang/Jq/Solve-a-Holy-Knights-tour b/Lang/Jq/Solve-a-Holy-Knights-tour new file mode 120000 index 0000000000..d69331eff1 --- /dev/null +++ b/Lang/Jq/Solve-a-Holy-Knights-tour @@ -0,0 +1 @@ +../../Task/Solve-a-Holy-Knights-tour/Jq \ No newline at end of file diff --git a/Lang/Jq/Solve-a-Numbrix-puzzle b/Lang/Jq/Solve-a-Numbrix-puzzle new file mode 120000 index 0000000000..29721632e1 --- /dev/null +++ b/Lang/Jq/Solve-a-Numbrix-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Numbrix-puzzle/Jq \ No newline at end of file diff --git a/Lang/Jq/Sort-an-outline-at-every-level b/Lang/Jq/Sort-an-outline-at-every-level new file mode 120000 index 0000000000..bce371340d --- /dev/null +++ b/Lang/Jq/Sort-an-outline-at-every-level @@ -0,0 +1 @@ +../../Task/Sort-an-outline-at-every-level/Jq \ No newline at end of file diff --git a/Lang/Jq/Thieles-interpolation-formula b/Lang/Jq/Thieles-interpolation-formula new file mode 120000 index 0000000000..25d4327e8c --- /dev/null +++ b/Lang/Jq/Thieles-interpolation-formula @@ -0,0 +1 @@ +../../Task/Thieles-interpolation-formula/Jq \ No newline at end of file diff --git a/Lang/Jq/Tic-tac-toe b/Lang/Jq/Tic-tac-toe new file mode 120000 index 0000000000..29e18a13ef --- /dev/null +++ b/Lang/Jq/Tic-tac-toe @@ -0,0 +1 @@ +../../Task/Tic-tac-toe/Jq \ No newline at end of file diff --git a/Lang/Jq/War-card-game b/Lang/Jq/War-card-game new file mode 120000 index 0000000000..428c4a1307 --- /dev/null +++ b/Lang/Jq/War-card-game @@ -0,0 +1 @@ +../../Task/War-card-game/Jq \ No newline at end of file diff --git a/Lang/Jq/Wordiff b/Lang/Jq/Wordiff new file mode 120000 index 0000000000..61aa15852c --- /dev/null +++ b/Lang/Jq/Wordiff @@ -0,0 +1 @@ +../../Task/Wordiff/Jq \ No newline at end of file diff --git a/Lang/K/Find-common-directory-path b/Lang/K/Find-common-directory-path new file mode 120000 index 0000000000..21e1ffcdd3 --- /dev/null +++ b/Lang/K/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/K \ No newline at end of file diff --git a/Lang/K/Monty-Hall-problem b/Lang/K/Monty-Hall-problem new file mode 120000 index 0000000000..8fb0f9e98b --- /dev/null +++ b/Lang/K/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/K \ No newline at end of file diff --git a/Lang/Kotlin/00-LANG.txt b/Lang/Kotlin/00-LANG.txt index 5f33d4bd2a..95d9b59867 100644 --- a/Lang/Kotlin/00-LANG.txt +++ b/Lang/Kotlin/00-LANG.txt @@ -4,7 +4,7 @@ |site=http://kotlinlang.org |hopl=no }} -Kotlin is a statically-typed programming language that runs on the [[JVM]] and can also be compiled to JavaScript. It is being developed by JetBrains with assistance from open source contributors and is intended for industrial use. +Kotlin is a statically-typed programming language that runs on the [[runs on vm::Java Virtual Machine]] (JVM) and can also be compiled to JavaScript. It is being developed by JetBrains with assistance from open source contributors and is intended for industrial use. In addition, a separate team at JetBrains is developing a version of Kotlin which compiles (via LLVM) directly to machine code for various platforms. The first Technology Preview for this version was rolled out in April 2017. diff --git a/Lang/Kotlin/Compare-length-of-two-strings b/Lang/Kotlin/Compare-length-of-two-strings new file mode 120000 index 0000000000..a8c0b8d6cf --- /dev/null +++ b/Lang/Kotlin/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/Kotlin \ No newline at end of file diff --git a/Lang/Kotlin/Factorial-primes b/Lang/Kotlin/Factorial-primes new file mode 120000 index 0000000000..36b19250f9 --- /dev/null +++ b/Lang/Kotlin/Factorial-primes @@ -0,0 +1 @@ +../../Task/Factorial-primes/Kotlin \ No newline at end of file diff --git a/Lang/Langur/00-LANG.txt b/Lang/Langur/00-LANG.txt index c2da20439a..0c64770672 100644 --- a/Lang/Langur/00-LANG.txt +++ b/Lang/Langur/00-LANG.txt @@ -3,9 +3,9 @@ |hopl=no }} -Langur is an open-source imperative/functional programming language. The name langur begins with a lowercase letter when it does not start a sentence. +Langur is an open-source programming language that natively uses decimal floating point, and deals with extremely large and small numbers. Its principles of design are accuracy in calculation and a concise, expressive syntax. The name langur begins with a lowercase letter when it does not start a sentence. -Langur code can be run with script files or with its REPL. The recommended file name extension is .langur. +Langur code can be run from executable files, or you can use the REPL. The recommended file name extension is .langur. Langur uses a hash mark for single line comments. Therefore, script files may begin with a shebang to tell a Linux shell where to find the interpreter. diff --git a/Lang/Langur/Babbage-problem b/Lang/Langur/Babbage-problem new file mode 120000 index 0000000000..662297217a --- /dev/null +++ b/Lang/Langur/Babbage-problem @@ -0,0 +1 @@ +../../Task/Babbage-problem/Langur \ No newline at end of file diff --git a/Lang/Langur/I-before-E-except-after-C b/Lang/Langur/I-before-E-except-after-C new file mode 120000 index 0000000000..a4c67c55c7 --- /dev/null +++ b/Lang/Langur/I-before-E-except-after-C @@ -0,0 +1 @@ +../../Task/I-before-E-except-after-C/Langur \ No newline at end of file diff --git a/Lang/Langur/Safe-addition b/Lang/Langur/Safe-addition new file mode 120000 index 0000000000..9cd478ca7f --- /dev/null +++ b/Lang/Langur/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Langur \ No newline at end of file diff --git a/Lang/Langur/String-interpolation-included- b/Lang/Langur/String-interpolation-included- new file mode 120000 index 0000000000..e0b5bfaf9c --- /dev/null +++ b/Lang/Langur/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/Langur \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Poker-hand-analyser b/Lang/Liberty-BASIC/Poker-hand-analyser new file mode 120000 index 0000000000..3ed8c3b507 --- /dev/null +++ b/Lang/Liberty-BASIC/Poker-hand-analyser @@ -0,0 +1 @@ +../../Task/Poker-hand-analyser/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Lilypond/00-LANG.txt b/Lang/Lilypond/00-LANG.txt index 5c24c70c93..9afe2b1bd9 100644 --- a/Lang/Lilypond/00-LANG.txt +++ b/Lang/Lilypond/00-LANG.txt @@ -1,9 +1 @@ -{{stub}} -{{language|lilypond -|site=http://www.lilypond.org/ -|hopl=no -}} - -The lilypond language is used by the lilypond score production software for describing the layout of musical score sheets. - -[[Category:Musical Notation]] \ No newline at end of file +#REDIRECT [[:Category:LilyPond]] \ No newline at end of file diff --git a/Lang/Locomotive-Basic/00-LANG.txt b/Lang/Locomotive-Basic/00-LANG.txt index 04db5b5ea8..5045a1b047 100644 --- a/Lang/Locomotive-Basic/00-LANG.txt +++ b/Lang/Locomotive-Basic/00-LANG.txt @@ -7,9 +7,9 @@ '''Locomotive BASIC''' is a variant of BASIC that is built into the ROM of the [[wp:Amstrad CPC|Amstrad CPC]] series of home computers introduced in 1984. In the 1980s, the CPC was a popular, slightly more expensive alternative to the Commodore C64/C128. It was not just suited for games but also office work because of its high resolution display and [[wp:CP/M|CP/M]] support. -The easiest way to use Locomotive BASIC today is [https://benchmarko.github.io/CPCBasic/cpcbasic.html CPCBasic], a very fast implementation in JavaScript which also allows easy pasting of code from Rosetta Code. Note that programs will run much faster in CPCBasic than on a real CPC. To slow down a program, add an extra delay loop to the main loop, e.g.:for delay=1 to 5:frame:nextwhich will pause for five frames or 0.1 seconds. +The easiest way to use Locomotive BASIC today is [https://benchmarko.github.io/CPCBasic/cpcbasic.html CPCBasic], a very fast implementation in JavaScript which also allows easy pasting of code from Rosetta Code. Note that programs will run much faster in CPCBasic than on a real CPC. To slow down a program, add an extra delay loop to the main loop, e.g. for delay=1 to 5:frame:nextwhich will pause for five frames or 0.1 seconds. -[https://www.retrovm.com/ CPCBox] is another option for the web browser, a whole-machine JavaScript CPC emulator mainly for games which has good compatibility but which lacks copy and paste support. +[https://retroshowcase.gr/cpcbox-master/ CPCBox] is another option for the web browser, a whole-machine JavaScript CPC emulator mainly for games which has good compatibility but which lacks copy and paste support. Locomotive BASIC can also be used via native CPC emulators such as [http://www.winape.net/ WinAPE] (Windows) or [http://sourceforge.net/projects/javacpc/ JavaCPC] (Windows/macOS/Linux). All these CPC emulators are also perfectly legal because Amstrad has given their permission for distributing CPC ROM images with emulators. @@ -19,14 +19,14 @@ Either use the CPCBasic browser-based Locomotive Basic emulator (https://benchma In CPCBasic, enter your program, e.g. -10 print "Hello World!" +10 print "Hello World!" into the "CPC Basic" text box at the top and then press the Run button below it. Output goes to the blue CPC screen below. You can also interact with the CPC screen directly if you first click on it with the mouse. The Reset button stops a running program and returns you to the Ready prompt. In a native emulator, just type -10 print "Hello World!" -run +10 print "Hello World!" +run to run your first Locomotive BASIC program. @@ -56,7 +56,7 @@ As on many other 8-bit machines of the era, BASIC programs are often extended wi Memory on the CPC 464 and 664 is subdivided into four 16 kB blocks (0 to 3), with block 3 at &c000 normally reserved for the screen. The CPC 6128 features a second 64 kB bank (blocks 4 to 7) which can be accessed from BASIC with [[wp:Bank switching|bank switching]] in block 1 (&4000 and &7fff), e.g. -out &7fff,&x11000100 +out &7fff,&x11000100 would make block 4 accessible in the address space of block 1.http://k1.dyndns.org/Vintage/Schneider%20CPC/Das%20Schneider%20CPC%20Systembuch/z87.htm This way, the entire 128 kB of memory can be used by BASIC. Alternatively, RSX commands for bank switching and copying between banks are included on the system discs and discussed in chapter 8 of the CPC user manual.http://www.cpcwiki.eu/index.php/User_Manual Even on the 64 kB models, it is possible to do [[wp:Multiple buffering|double buffering]] in BASIC by reserving another RAM block for the screen, drawing into the hidden screen, and then setting the CRTC screen address to the currently hidden screen with the BASIC [[wp:I/o port|port I/O]] command OUT. diff --git a/Lang/Locomotive-Basic/Abelian-sandpile-model b/Lang/Locomotive-Basic/Abelian-sandpile-model new file mode 120000 index 0000000000..e00a530896 --- /dev/null +++ b/Lang/Locomotive-Basic/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Draw-a-cuboid b/Lang/Locomotive-Basic/Draw-a-cuboid new file mode 120000 index 0000000000..cbfb396b7f --- /dev/null +++ b/Lang/Locomotive-Basic/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Locomotive-Basic \ No newline at end of file diff --git a/Lang/MACRO-11/Square-but-not-cube b/Lang/MACRO-11/Square-but-not-cube new file mode 120000 index 0000000000..7130b2c620 --- /dev/null +++ b/Lang/MACRO-11/Square-but-not-cube @@ -0,0 +1 @@ +../../Task/Square-but-not-cube/MACRO-11 \ No newline at end of file diff --git a/Lang/Mia/Loops-While b/Lang/Mia/Loops-While new file mode 120000 index 0000000000..acad4e8591 --- /dev/null +++ b/Lang/Mia/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Mia \ No newline at end of file diff --git a/Lang/Minimal-BASIC/Jensens-Device b/Lang/Minimal-BASIC/Jensens-Device new file mode 120000 index 0000000000..f729ff931e --- /dev/null +++ b/Lang/Minimal-BASIC/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Minimal-BASIC \ No newline at end of file diff --git a/Lang/Minimal-BASIC/Monty-Hall-problem b/Lang/Minimal-BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..e997b4d558 --- /dev/null +++ b/Lang/Minimal-BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Minimal-BASIC \ No newline at end of file diff --git a/Lang/Modula-2/Gray-code b/Lang/Modula-2/Gray-code new file mode 120000 index 0000000000..8cb45ff695 --- /dev/null +++ b/Lang/Modula-2/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Monty-Hall-problem b/Lang/Modula-2/Monty-Hall-problem new file mode 120000 index 0000000000..9ad6c8767a --- /dev/null +++ b/Lang/Modula-2/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-3/Additive-primes b/Lang/Modula-3/Additive-primes new file mode 120000 index 0000000000..b81b571c35 --- /dev/null +++ b/Lang/Modula-3/Additive-primes @@ -0,0 +1 @@ +../../Task/Additive-primes/Modula-3 \ No newline at end of file diff --git a/Lang/Nascom-BASIC/Damm-algorithm b/Lang/Nascom-BASIC/Damm-algorithm new file mode 120000 index 0000000000..5a6439a18c --- /dev/null +++ b/Lang/Nascom-BASIC/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/Nascom-BASIC \ No newline at end of file diff --git a/Lang/Oberon/100-doors b/Lang/Oberon/100-doors deleted file mode 120000 index 9d190b3c16..0000000000 --- a/Lang/Oberon/100-doors +++ /dev/null @@ -1 +0,0 @@ -../../Task/100-doors/Oberon \ No newline at end of file diff --git a/Lang/Odin/Quine b/Lang/Odin/Quine new file mode 120000 index 0000000000..53e4cf3687 --- /dev/null +++ b/Lang/Odin/Quine @@ -0,0 +1 @@ +../../Task/Quine/Odin \ No newline at end of file diff --git a/Lang/PHP/Water-collected-between-towers b/Lang/PHP/Water-collected-between-towers new file mode 120000 index 0000000000..524c5ae99b --- /dev/null +++ b/Lang/PHP/Water-collected-between-towers @@ -0,0 +1 @@ +../../Task/Water-collected-between-towers/PHP \ No newline at end of file diff --git a/Lang/PL-M/Draw-a-cuboid b/Lang/PL-M/Draw-a-cuboid new file mode 120000 index 0000000000..c6084a0c66 --- /dev/null +++ b/Lang/PL-M/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/PL-M \ No newline at end of file diff --git a/Lang/PL-M/Nested-function b/Lang/PL-M/Nested-function new file mode 120000 index 0000000000..2fbc4399dd --- /dev/null +++ b/Lang/PL-M/Nested-function @@ -0,0 +1 @@ +../../Task/Nested-function/PL-M \ No newline at end of file diff --git a/Lang/POV-Ray/Bitmap b/Lang/POV-Ray/Bitmap new file mode 120000 index 0000000000..90fece7e75 --- /dev/null +++ b/Lang/POV-Ray/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/POV-Ray \ No newline at end of file diff --git a/Lang/POV-Ray/Maze-generation b/Lang/POV-Ray/Maze-generation new file mode 120000 index 0000000000..724f710098 --- /dev/null +++ b/Lang/POV-Ray/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/POV-Ray \ No newline at end of file diff --git a/Lang/Pascal/Count-the-coins b/Lang/Pascal/Count-the-coins new file mode 120000 index 0000000000..8d7999b667 --- /dev/null +++ b/Lang/Pascal/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Pascal \ No newline at end of file diff --git a/Lang/PascalABC.NET/00-LANG.txt b/Lang/PascalABC.NET/00-LANG.txt index d9efe4d43e..48e9f6ce41 100644 --- a/Lang/PascalABC.NET/00-LANG.txt +++ b/Lang/PascalABC.NET/00-LANG.txt @@ -16,4 +16,4 @@ begin end. -{{unimpl_Page|PacalABC.NET}} \ No newline at end of file +{{unimpl_Page|PascalABC.NET}} \ No newline at end of file diff --git a/Lang/PascalABC.NET/15-puzzle-game b/Lang/PascalABC.NET/15-puzzle-game new file mode 120000 index 0000000000..caf890e56b --- /dev/null +++ b/Lang/PascalABC.NET/15-puzzle-game @@ -0,0 +1 @@ +../../Task/15-puzzle-game/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/99-bottles-of-beer b/Lang/PascalABC.NET/99-bottles-of-beer new file mode 120000 index 0000000000..bc29442ab5 --- /dev/null +++ b/Lang/PascalABC.NET/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/A+B b/Lang/PascalABC.NET/A+B new file mode 120000 index 0000000000..7a5a9db498 --- /dev/null +++ b/Lang/PascalABC.NET/A+B @@ -0,0 +1 @@ +../../Task/A+B/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Abstract-type b/Lang/PascalABC.NET/Abstract-type new file mode 120000 index 0000000000..305270825e --- /dev/null +++ b/Lang/PascalABC.NET/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Accumulator-factory b/Lang/PascalABC.NET/Accumulator-factory new file mode 120000 index 0000000000..dd94a031d6 --- /dev/null +++ b/Lang/PascalABC.NET/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Ackermann-function b/Lang/PascalABC.NET/Ackermann-function new file mode 120000 index 0000000000..c2fa2dd278 --- /dev/null +++ b/Lang/PascalABC.NET/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Add-a-variable-to-a-class-instance-at-runtime b/Lang/PascalABC.NET/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..ec0970f459 --- /dev/null +++ b/Lang/PascalABC.NET/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Address-of-a-variable b/Lang/PascalABC.NET/Address-of-a-variable new file mode 120000 index 0000000000..8477592c7b --- /dev/null +++ b/Lang/PascalABC.NET/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Anagrams b/Lang/PascalABC.NET/Anagrams new file mode 120000 index 0000000000..2bec53abb4 --- /dev/null +++ b/Lang/PascalABC.NET/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Anonymous-recursion b/Lang/PascalABC.NET/Anonymous-recursion new file mode 120000 index 0000000000..7a2a34d4d5 --- /dev/null +++ b/Lang/PascalABC.NET/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Apply-a-callback-to-an-array b/Lang/PascalABC.NET/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..88f34b5a9e --- /dev/null +++ b/Lang/PascalABC.NET/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Arithmetic-Complex b/Lang/PascalABC.NET/Arithmetic-Complex new file mode 120000 index 0000000000..bccd03a873 --- /dev/null +++ b/Lang/PascalABC.NET/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Arithmetic-Integer b/Lang/PascalABC.NET/Arithmetic-Integer new file mode 120000 index 0000000000..30d5138cbd --- /dev/null +++ b/Lang/PascalABC.NET/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Array-concatenation b/Lang/PascalABC.NET/Array-concatenation new file mode 120000 index 0000000000..bfe26798bc --- /dev/null +++ b/Lang/PascalABC.NET/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Arrays b/Lang/PascalABC.NET/Arrays new file mode 120000 index 0000000000..62dfb07030 --- /dev/null +++ b/Lang/PascalABC.NET/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Assertions b/Lang/PascalABC.NET/Assertions new file mode 120000 index 0000000000..bdc3ed57c2 --- /dev/null +++ b/Lang/PascalABC.NET/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Associative-array-Creation b/Lang/PascalABC.NET/Associative-array-Creation new file mode 120000 index 0000000000..fc1bef5cdb --- /dev/null +++ b/Lang/PascalABC.NET/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Associative-array-Iteration b/Lang/PascalABC.NET/Associative-array-Iteration new file mode 120000 index 0000000000..2f1ab21d84 --- /dev/null +++ b/Lang/PascalABC.NET/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Balanced-brackets b/Lang/PascalABC.NET/Balanced-brackets new file mode 120000 index 0000000000..4b5678c4d8 --- /dev/null +++ b/Lang/PascalABC.NET/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Binary-digits b/Lang/PascalABC.NET/Binary-digits new file mode 120000 index 0000000000..e0597a5dc1 --- /dev/null +++ b/Lang/PascalABC.NET/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Binary-search b/Lang/PascalABC.NET/Binary-search new file mode 120000 index 0000000000..aa5ba91c87 --- /dev/null +++ b/Lang/PascalABC.NET/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Bitwise-operations b/Lang/PascalABC.NET/Bitwise-operations new file mode 120000 index 0000000000..acc6123f1c --- /dev/null +++ b/Lang/PascalABC.NET/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Break-OO-privacy b/Lang/PascalABC.NET/Break-OO-privacy new file mode 120000 index 0000000000..29ee336925 --- /dev/null +++ b/Lang/PascalABC.NET/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/CSV-data-manipulation b/Lang/PascalABC.NET/CSV-data-manipulation new file mode 120000 index 0000000000..ab9f191d41 --- /dev/null +++ b/Lang/PascalABC.NET/CSV-data-manipulation @@ -0,0 +1 @@ +../../Task/CSV-data-manipulation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Calculating-the-value-of-e b/Lang/PascalABC.NET/Calculating-the-value-of-e new file mode 120000 index 0000000000..c544f3c00f --- /dev/null +++ b/Lang/PascalABC.NET/Calculating-the-value-of-e @@ -0,0 +1 @@ +../../Task/Calculating-the-value-of-e/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Call-an-object-method b/Lang/PascalABC.NET/Call-an-object-method new file mode 120000 index 0000000000..0c1cf230d7 --- /dev/null +++ b/Lang/PascalABC.NET/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Character-codes b/Lang/PascalABC.NET/Character-codes new file mode 120000 index 0000000000..1888f78c06 --- /dev/null +++ b/Lang/PascalABC.NET/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Classes b/Lang/PascalABC.NET/Classes new file mode 120000 index 0000000000..08756ef03a --- /dev/null +++ b/Lang/PascalABC.NET/Classes @@ -0,0 +1 @@ +../../Task/Classes/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Closest-pair-problem b/Lang/PascalABC.NET/Closest-pair-problem new file mode 120000 index 0000000000..4b7bc32806 --- /dev/null +++ b/Lang/PascalABC.NET/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Collections b/Lang/PascalABC.NET/Collections new file mode 120000 index 0000000000..c3fa3dc417 --- /dev/null +++ b/Lang/PascalABC.NET/Collections @@ -0,0 +1 @@ +../../Task/Collections/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Command-line-arguments b/Lang/PascalABC.NET/Command-line-arguments new file mode 120000 index 0000000000..f229191025 --- /dev/null +++ b/Lang/PascalABC.NET/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Comments b/Lang/PascalABC.NET/Comments new file mode 120000 index 0000000000..5e528e6991 --- /dev/null +++ b/Lang/PascalABC.NET/Comments @@ -0,0 +1 @@ +../../Task/Comments/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Compare-a-list-of-strings b/Lang/PascalABC.NET/Compare-a-list-of-strings new file mode 120000 index 0000000000..b8b040023f --- /dev/null +++ b/Lang/PascalABC.NET/Compare-a-list-of-strings @@ -0,0 +1 @@ +../../Task/Compare-a-list-of-strings/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Compare-length-of-two-strings b/Lang/PascalABC.NET/Compare-length-of-two-strings new file mode 120000 index 0000000000..92be62a3df --- /dev/null +++ b/Lang/PascalABC.NET/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Compound-data-type b/Lang/PascalABC.NET/Compound-data-type new file mode 120000 index 0000000000..89ad664595 --- /dev/null +++ b/Lang/PascalABC.NET/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Concurrent-computing b/Lang/PascalABC.NET/Concurrent-computing new file mode 120000 index 0000000000..ced9fcccc5 --- /dev/null +++ b/Lang/PascalABC.NET/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Conditional-structures b/Lang/PascalABC.NET/Conditional-structures new file mode 120000 index 0000000000..6186fdd1f8 --- /dev/null +++ b/Lang/PascalABC.NET/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Constrained-genericity b/Lang/PascalABC.NET/Constrained-genericity new file mode 120000 index 0000000000..4d89cf348d --- /dev/null +++ b/Lang/PascalABC.NET/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Copy-a-string b/Lang/PascalABC.NET/Copy-a-string new file mode 120000 index 0000000000..d102da9b43 --- /dev/null +++ b/Lang/PascalABC.NET/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Copy-stdin-to-stdout b/Lang/PascalABC.NET/Copy-stdin-to-stdout new file mode 120000 index 0000000000..08f7b00296 --- /dev/null +++ b/Lang/PascalABC.NET/Copy-stdin-to-stdout @@ -0,0 +1 @@ +../../Task/Copy-stdin-to-stdout/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Count-in-factors b/Lang/PascalABC.NET/Count-in-factors new file mode 120000 index 0000000000..42811aa9aa --- /dev/null +++ b/Lang/PascalABC.NET/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Count-in-octal b/Lang/PascalABC.NET/Count-in-octal new file mode 120000 index 0000000000..8965e8c25f --- /dev/null +++ b/Lang/PascalABC.NET/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Count-occurrences-of-a-substring b/Lang/PascalABC.NET/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..d67adab506 --- /dev/null +++ b/Lang/PascalABC.NET/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Create-a-two-dimensional-array-at-runtime b/Lang/PascalABC.NET/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..2c7befc65f --- /dev/null +++ b/Lang/PascalABC.NET/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Create-an-object-at-a-given-address b/Lang/PascalABC.NET/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..aa2e5f2ab2 --- /dev/null +++ b/Lang/PascalABC.NET/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Date-format b/Lang/PascalABC.NET/Date-format new file mode 120000 index 0000000000..176b256586 --- /dev/null +++ b/Lang/PascalABC.NET/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Day-of-the-week b/Lang/PascalABC.NET/Day-of-the-week new file mode 120000 index 0000000000..3300b037b4 --- /dev/null +++ b/Lang/PascalABC.NET/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Define-a-primitive-data-type b/Lang/PascalABC.NET/Define-a-primitive-data-type new file mode 120000 index 0000000000..684571f697 --- /dev/null +++ b/Lang/PascalABC.NET/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Determine-if-a-string-is-numeric b/Lang/PascalABC.NET/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..3ddeb93c61 --- /dev/null +++ b/Lang/PascalABC.NET/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Determine-sentence-type b/Lang/PascalABC.NET/Determine-sentence-type new file mode 120000 index 0000000000..dc0284a0e0 --- /dev/null +++ b/Lang/PascalABC.NET/Determine-sentence-type @@ -0,0 +1 @@ +../../Task/Determine-sentence-type/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Doubly-linked-list-Definition b/Lang/PascalABC.NET/Doubly-linked-list-Definition new file mode 120000 index 0000000000..f2561705cf --- /dev/null +++ b/Lang/PascalABC.NET/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Doubly-linked-list-Element-definition b/Lang/PascalABC.NET/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..50c9d03e8c --- /dev/null +++ b/Lang/PascalABC.NET/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Doubly-linked-list-Element-insertion b/Lang/PascalABC.NET/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..28af162224 --- /dev/null +++ b/Lang/PascalABC.NET/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Doubly-linked-list-Traversal b/Lang/PascalABC.NET/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..9cc3d51b16 --- /dev/null +++ b/Lang/PascalABC.NET/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Dragon-curve b/Lang/PascalABC.NET/Dragon-curve new file mode 120000 index 0000000000..1a8a6239bd --- /dev/null +++ b/Lang/PascalABC.NET/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Draw-a-pixel b/Lang/PascalABC.NET/Draw-a-pixel new file mode 120000 index 0000000000..cdcb7e2918 --- /dev/null +++ b/Lang/PascalABC.NET/Draw-a-pixel @@ -0,0 +1 @@ +../../Task/Draw-a-pixel/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Draw-a-rotating-cube b/Lang/PascalABC.NET/Draw-a-rotating-cube new file mode 120000 index 0000000000..9092790488 --- /dev/null +++ b/Lang/PascalABC.NET/Draw-a-rotating-cube @@ -0,0 +1 @@ +../../Task/Draw-a-rotating-cube/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Empty-program b/Lang/PascalABC.NET/Empty-program new file mode 120000 index 0000000000..9a2aa557cd --- /dev/null +++ b/Lang/PascalABC.NET/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Enumerations b/Lang/PascalABC.NET/Enumerations new file mode 120000 index 0000000000..3fbeab7aac --- /dev/null +++ b/Lang/PascalABC.NET/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Even-or-odd b/Lang/PascalABC.NET/Even-or-odd new file mode 120000 index 0000000000..4191597943 --- /dev/null +++ b/Lang/PascalABC.NET/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Exceptions b/Lang/PascalABC.NET/Exceptions new file mode 120000 index 0000000000..b4b7999bea --- /dev/null +++ b/Lang/PascalABC.NET/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Extreme-floating-point-values b/Lang/PascalABC.NET/Extreme-floating-point-values new file mode 120000 index 0000000000..438be3c964 --- /dev/null +++ b/Lang/PascalABC.NET/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Factorial b/Lang/PascalABC.NET/Factorial new file mode 120000 index 0000000000..64716300fa --- /dev/null +++ b/Lang/PascalABC.NET/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Factors-of-an-integer b/Lang/PascalABC.NET/Factors-of-an-integer new file mode 120000 index 0000000000..b2f675ad56 --- /dev/null +++ b/Lang/PascalABC.NET/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/File-input-output b/Lang/PascalABC.NET/File-input-output new file mode 120000 index 0000000000..aa29aa165d --- /dev/null +++ b/Lang/PascalABC.NET/File-input-output @@ -0,0 +1 @@ +../../Task/File-input-output/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/File-size b/Lang/PascalABC.NET/File-size new file mode 120000 index 0000000000..cb4f56c334 --- /dev/null +++ b/Lang/PascalABC.NET/File-size @@ -0,0 +1 @@ +../../Task/File-size/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Filter b/Lang/PascalABC.NET/Filter new file mode 120000 index 0000000000..b6b1f56f68 --- /dev/null +++ b/Lang/PascalABC.NET/Filter @@ -0,0 +1 @@ +../../Task/Filter/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Find-common-directory-path b/Lang/PascalABC.NET/Find-common-directory-path new file mode 120000 index 0000000000..48495d80e3 --- /dev/null +++ b/Lang/PascalABC.NET/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Find-limit-of-recursion b/Lang/PascalABC.NET/Find-limit-of-recursion new file mode 120000 index 0000000000..8e738ede74 --- /dev/null +++ b/Lang/PascalABC.NET/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/First-class-functions b/Lang/PascalABC.NET/First-class-functions new file mode 120000 index 0000000000..d4c191f6d3 --- /dev/null +++ b/Lang/PascalABC.NET/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/FizzBuzz b/Lang/PascalABC.NET/FizzBuzz new file mode 120000 index 0000000000..9af47ffeb0 --- /dev/null +++ b/Lang/PascalABC.NET/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Flatten-a-list b/Lang/PascalABC.NET/Flatten-a-list new file mode 120000 index 0000000000..951e9e626d --- /dev/null +++ b/Lang/PascalABC.NET/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Floyds-triangle b/Lang/PascalABC.NET/Floyds-triangle new file mode 120000 index 0000000000..741db9a754 --- /dev/null +++ b/Lang/PascalABC.NET/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Formatted-numeric-output b/Lang/PascalABC.NET/Formatted-numeric-output new file mode 120000 index 0000000000..d5385037bc --- /dev/null +++ b/Lang/PascalABC.NET/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Function-definition b/Lang/PascalABC.NET/Function-definition new file mode 120000 index 0000000000..cc1ff414b4 --- /dev/null +++ b/Lang/PascalABC.NET/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/General-FizzBuzz b/Lang/PascalABC.NET/General-FizzBuzz new file mode 120000 index 0000000000..655ae97e52 --- /dev/null +++ b/Lang/PascalABC.NET/General-FizzBuzz @@ -0,0 +1 @@ +../../Task/General-FizzBuzz/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Generate-lower-case-ASCII-alphabet b/Lang/PascalABC.NET/Generate-lower-case-ASCII-alphabet new file mode 120000 index 0000000000..8ef0c3c6f0 --- /dev/null +++ b/Lang/PascalABC.NET/Generate-lower-case-ASCII-alphabet @@ -0,0 +1 @@ +../../Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Generic-swap b/Lang/PascalABC.NET/Generic-swap new file mode 120000 index 0000000000..35fd1c3542 --- /dev/null +++ b/Lang/PascalABC.NET/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Greatest-common-divisor b/Lang/PascalABC.NET/Greatest-common-divisor new file mode 120000 index 0000000000..27dc1c21f9 --- /dev/null +++ b/Lang/PascalABC.NET/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Guess-the-number b/Lang/PascalABC.NET/Guess-the-number new file mode 120000 index 0000000000..7fff26f7e2 --- /dev/null +++ b/Lang/PascalABC.NET/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Hash-from-two-arrays b/Lang/PascalABC.NET/Hash-from-two-arrays new file mode 120000 index 0000000000..06b09f8bf9 --- /dev/null +++ b/Lang/PascalABC.NET/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Hello-world-Line-printer b/Lang/PascalABC.NET/Hello-world-Line-printer new file mode 120000 index 0000000000..87d7f6b37c --- /dev/null +++ b/Lang/PascalABC.NET/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Hello-world-Newline-omission b/Lang/PascalABC.NET/Hello-world-Newline-omission new file mode 120000 index 0000000000..2c094828d8 --- /dev/null +++ b/Lang/PascalABC.NET/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Hello-world-Standard-error b/Lang/PascalABC.NET/Hello-world-Standard-error new file mode 120000 index 0000000000..4b2452f23e --- /dev/null +++ b/Lang/PascalABC.NET/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Identity-matrix b/Lang/PascalABC.NET/Identity-matrix new file mode 120000 index 0000000000..e498197ea6 --- /dev/null +++ b/Lang/PascalABC.NET/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Include-a-file b/Lang/PascalABC.NET/Include-a-file new file mode 120000 index 0000000000..5762928418 --- /dev/null +++ b/Lang/PascalABC.NET/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Infinity b/Lang/PascalABC.NET/Infinity new file mode 120000 index 0000000000..e5b6807ad7 --- /dev/null +++ b/Lang/PascalABC.NET/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Inheritance-Multiple b/Lang/PascalABC.NET/Inheritance-Multiple new file mode 120000 index 0000000000..f3f065b097 --- /dev/null +++ b/Lang/PascalABC.NET/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Inheritance-Single b/Lang/PascalABC.NET/Inheritance-Single new file mode 120000 index 0000000000..2843b9d512 --- /dev/null +++ b/Lang/PascalABC.NET/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Input-loop b/Lang/PascalABC.NET/Input-loop new file mode 120000 index 0000000000..8086164ab5 --- /dev/null +++ b/Lang/PascalABC.NET/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Integer-comparison b/Lang/PascalABC.NET/Integer-comparison new file mode 120000 index 0000000000..b60ac826c4 --- /dev/null +++ b/Lang/PascalABC.NET/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/JSON b/Lang/PascalABC.NET/JSON new file mode 120000 index 0000000000..e24e87ebee --- /dev/null +++ b/Lang/PascalABC.NET/JSON @@ -0,0 +1 @@ +../../Task/JSON/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Jump-anywhere b/Lang/PascalABC.NET/Jump-anywhere new file mode 120000 index 0000000000..cb395144b9 --- /dev/null +++ b/Lang/PascalABC.NET/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Knuth-shuffle b/Lang/PascalABC.NET/Knuth-shuffle new file mode 120000 index 0000000000..a80c329b34 --- /dev/null +++ b/Lang/PascalABC.NET/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Least-common-multiple b/Lang/PascalABC.NET/Least-common-multiple new file mode 120000 index 0000000000..446b96ac48 --- /dev/null +++ b/Lang/PascalABC.NET/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/List-comprehensions b/Lang/PascalABC.NET/List-comprehensions new file mode 120000 index 0000000000..e9fa93e9e6 --- /dev/null +++ b/Lang/PascalABC.NET/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Literals-Floating-point b/Lang/PascalABC.NET/Literals-Floating-point new file mode 120000 index 0000000000..e11300a194 --- /dev/null +++ b/Lang/PascalABC.NET/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Literals-String b/Lang/PascalABC.NET/Literals-String new file mode 120000 index 0000000000..2f02c8af92 --- /dev/null +++ b/Lang/PascalABC.NET/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Longest-common-subsequence b/Lang/PascalABC.NET/Longest-common-subsequence new file mode 120000 index 0000000000..1dfbd5ef9d --- /dev/null +++ b/Lang/PascalABC.NET/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loop-over-multiple-arrays-simultaneously b/Lang/PascalABC.NET/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..52655fded4 --- /dev/null +++ b/Lang/PascalABC.NET/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Break b/Lang/PascalABC.NET/Loops-Break new file mode 120000 index 0000000000..75f285786e --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Continue b/Lang/PascalABC.NET/Loops-Continue new file mode 120000 index 0000000000..75da2856ce --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Do-while b/Lang/PascalABC.NET/Loops-Do-while new file mode 120000 index 0000000000..a15c938618 --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Downward-for b/Lang/PascalABC.NET/Loops-Downward-for new file mode 120000 index 0000000000..c2c6306f3a --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-For b/Lang/PascalABC.NET/Loops-For new file mode 120000 index 0000000000..bf236f094e --- /dev/null +++ b/Lang/PascalABC.NET/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-For-with-a-specified-step b/Lang/PascalABC.NET/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..5244453d5c --- /dev/null +++ b/Lang/PascalABC.NET/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Foreach b/Lang/PascalABC.NET/Loops-Foreach new file mode 120000 index 0000000000..68b06931af --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Increment-loop-index-within-loop-body b/Lang/PascalABC.NET/Loops-Increment-loop-index-within-loop-body new file mode 120000 index 0000000000..f5d20bce59 --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Increment-loop-index-within-loop-body @@ -0,0 +1 @@ +../../Task/Loops-Increment-loop-index-within-loop-body/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-N-plus-one-half b/Lang/PascalABC.NET/Loops-N-plus-one-half new file mode 120000 index 0000000000..95fe8496ec --- /dev/null +++ b/Lang/PascalABC.NET/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Nested b/Lang/PascalABC.NET/Loops-Nested new file mode 120000 index 0000000000..d1a88ee15f --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-While b/Lang/PascalABC.NET/Loops-While new file mode 120000 index 0000000000..19d817b9f2 --- /dev/null +++ b/Lang/PascalABC.NET/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-With-multiple-ranges b/Lang/PascalABC.NET/Loops-With-multiple-ranges new file mode 120000 index 0000000000..1b3c0e8a85 --- /dev/null +++ b/Lang/PascalABC.NET/Loops-With-multiple-ranges @@ -0,0 +1 @@ +../../Task/Loops-With-multiple-ranges/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Loops-Wrong-ranges b/Lang/PascalABC.NET/Loops-Wrong-ranges new file mode 120000 index 0000000000..cd717ae408 --- /dev/null +++ b/Lang/PascalABC.NET/Loops-Wrong-ranges @@ -0,0 +1 @@ +../../Task/Loops-Wrong-ranges/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Man-or-boy-test b/Lang/PascalABC.NET/Man-or-boy-test new file mode 120000 index 0000000000..f9b9ccb7a0 --- /dev/null +++ b/Lang/PascalABC.NET/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Memory-allocation b/Lang/PascalABC.NET/Memory-allocation new file mode 120000 index 0000000000..b7e94af0dd --- /dev/null +++ b/Lang/PascalABC.NET/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Mouse-position b/Lang/PascalABC.NET/Mouse-position new file mode 120000 index 0000000000..207ee7b935 --- /dev/null +++ b/Lang/PascalABC.NET/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Nested-function b/Lang/PascalABC.NET/Nested-function new file mode 120000 index 0000000000..406d1380f0 --- /dev/null +++ b/Lang/PascalABC.NET/Nested-function @@ -0,0 +1 @@ +../../Task/Nested-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Nth b/Lang/PascalABC.NET/Nth new file mode 120000 index 0000000000..2151e00c8d --- /dev/null +++ b/Lang/PascalABC.NET/Nth @@ -0,0 +1 @@ +../../Task/Nth/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Null-object b/Lang/PascalABC.NET/Null-object new file mode 120000 index 0000000000..39b6da0acb --- /dev/null +++ b/Lang/PascalABC.NET/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Object-serialization b/Lang/PascalABC.NET/Object-serialization new file mode 120000 index 0000000000..07426b45b7 --- /dev/null +++ b/Lang/PascalABC.NET/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Palindrome-detection b/Lang/PascalABC.NET/Palindrome-detection new file mode 120000 index 0000000000..cc92721e9f --- /dev/null +++ b/Lang/PascalABC.NET/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Parametric-polymorphism b/Lang/PascalABC.NET/Parametric-polymorphism new file mode 120000 index 0000000000..7c242be133 --- /dev/null +++ b/Lang/PascalABC.NET/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Pick-random-element b/Lang/PascalABC.NET/Pick-random-element new file mode 120000 index 0000000000..9dd6351bad --- /dev/null +++ b/Lang/PascalABC.NET/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Pointers-and-references b/Lang/PascalABC.NET/Pointers-and-references new file mode 120000 index 0000000000..6985ca1666 --- /dev/null +++ b/Lang/PascalABC.NET/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Polymorphic-copy b/Lang/PascalABC.NET/Polymorphic-copy new file mode 120000 index 0000000000..7ed8b814ad --- /dev/null +++ b/Lang/PascalABC.NET/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Polymorphism b/Lang/PascalABC.NET/Polymorphism new file mode 120000 index 0000000000..4996bdacfd --- /dev/null +++ b/Lang/PascalABC.NET/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Power-set b/Lang/PascalABC.NET/Power-set new file mode 120000 index 0000000000..042d839f30 --- /dev/null +++ b/Lang/PascalABC.NET/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Primality-by-trial-division b/Lang/PascalABC.NET/Primality-by-trial-division new file mode 120000 index 0000000000..62ca027b6e --- /dev/null +++ b/Lang/PascalABC.NET/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Prime-decomposition b/Lang/PascalABC.NET/Prime-decomposition new file mode 120000 index 0000000000..ea96188341 --- /dev/null +++ b/Lang/PascalABC.NET/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Program-name b/Lang/PascalABC.NET/Program-name new file mode 120000 index 0000000000..6bdce5a90a --- /dev/null +++ b/Lang/PascalABC.NET/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Program-termination b/Lang/PascalABC.NET/Program-termination new file mode 120000 index 0000000000..63645717ea --- /dev/null +++ b/Lang/PascalABC.NET/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Queue-Definition b/Lang/PascalABC.NET/Queue-Definition new file mode 120000 index 0000000000..efb10e6df2 --- /dev/null +++ b/Lang/PascalABC.NET/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Queue-Usage b/Lang/PascalABC.NET/Queue-Usage new file mode 120000 index 0000000000..eab42cf449 --- /dev/null +++ b/Lang/PascalABC.NET/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Quine b/Lang/PascalABC.NET/Quine new file mode 120000 index 0000000000..98ce8f9f2f --- /dev/null +++ b/Lang/PascalABC.NET/Quine @@ -0,0 +1 @@ +../../Task/Quine/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Quoting-constructs b/Lang/PascalABC.NET/Quoting-constructs new file mode 120000 index 0000000000..971db935d4 --- /dev/null +++ b/Lang/PascalABC.NET/Quoting-constructs @@ -0,0 +1 @@ +../../Task/Quoting-constructs/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Radical-of-an-integer b/Lang/PascalABC.NET/Radical-of-an-integer new file mode 120000 index 0000000000..430a252ecf --- /dev/null +++ b/Lang/PascalABC.NET/Radical-of-an-integer @@ -0,0 +1 @@ +../../Task/Radical-of-an-integer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Read-a-file-character-by-character-UTF8 b/Lang/PascalABC.NET/Read-a-file-character-by-character-UTF8 new file mode 120000 index 0000000000..a425a12499 --- /dev/null +++ b/Lang/PascalABC.NET/Read-a-file-character-by-character-UTF8 @@ -0,0 +1 @@ +../../Task/Read-a-file-character-by-character-UTF8/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Read-a-file-line-by-line b/Lang/PascalABC.NET/Read-a-file-line-by-line new file mode 120000 index 0000000000..bd96f90ae1 --- /dev/null +++ b/Lang/PascalABC.NET/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Read-a-specific-line-from-a-file b/Lang/PascalABC.NET/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..28703147aa --- /dev/null +++ b/Lang/PascalABC.NET/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Read-entire-file b/Lang/PascalABC.NET/Read-entire-file new file mode 120000 index 0000000000..20a95b9d77 --- /dev/null +++ b/Lang/PascalABC.NET/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Real-constants-and-functions b/Lang/PascalABC.NET/Real-constants-and-functions new file mode 120000 index 0000000000..a6e7dce16d --- /dev/null +++ b/Lang/PascalABC.NET/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Reflection-List-methods b/Lang/PascalABC.NET/Reflection-List-methods new file mode 120000 index 0000000000..7e40bca2fa --- /dev/null +++ b/Lang/PascalABC.NET/Reflection-List-methods @@ -0,0 +1 @@ +../../Task/Reflection-List-methods/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Reflection-List-properties b/Lang/PascalABC.NET/Reflection-List-properties new file mode 120000 index 0000000000..ed60f425f0 --- /dev/null +++ b/Lang/PascalABC.NET/Reflection-List-properties @@ -0,0 +1 @@ +../../Task/Reflection-List-properties/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Regular-expressions b/Lang/PascalABC.NET/Regular-expressions new file mode 120000 index 0000000000..a3ccbe1574 --- /dev/null +++ b/Lang/PascalABC.NET/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Remove-duplicate-elements b/Lang/PascalABC.NET/Remove-duplicate-elements new file mode 120000 index 0000000000..6f37a5852e --- /dev/null +++ b/Lang/PascalABC.NET/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Remove-lines-from-a-file b/Lang/PascalABC.NET/Remove-lines-from-a-file new file mode 120000 index 0000000000..6e76bee372 --- /dev/null +++ b/Lang/PascalABC.NET/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Rename-a-file b/Lang/PascalABC.NET/Rename-a-file new file mode 120000 index 0000000000..e7599165d6 --- /dev/null +++ b/Lang/PascalABC.NET/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Repeat b/Lang/PascalABC.NET/Repeat new file mode 120000 index 0000000000..e16283f972 --- /dev/null +++ b/Lang/PascalABC.NET/Repeat @@ -0,0 +1 @@ +../../Task/Repeat/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Repeat-a-string b/Lang/PascalABC.NET/Repeat-a-string new file mode 120000 index 0000000000..c21e0bfde3 --- /dev/null +++ b/Lang/PascalABC.NET/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Return-multiple-values b/Lang/PascalABC.NET/Return-multiple-values new file mode 120000 index 0000000000..5178c8dd1d --- /dev/null +++ b/Lang/PascalABC.NET/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Reverse-a-string b/Lang/PascalABC.NET/Reverse-a-string new file mode 120000 index 0000000000..8e67838296 --- /dev/null +++ b/Lang/PascalABC.NET/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Reverse-words-in-a-string b/Lang/PascalABC.NET/Reverse-words-in-a-string new file mode 120000 index 0000000000..aa82b64f3b --- /dev/null +++ b/Lang/PascalABC.NET/Reverse-words-in-a-string @@ -0,0 +1 @@ +../../Task/Reverse-words-in-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Roman-numerals-Decode b/Lang/PascalABC.NET/Roman-numerals-Decode new file mode 120000 index 0000000000..990d667ad0 --- /dev/null +++ b/Lang/PascalABC.NET/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Roman-numerals-Encode b/Lang/PascalABC.NET/Roman-numerals-Encode new file mode 120000 index 0000000000..c8f15e15fa --- /dev/null +++ b/Lang/PascalABC.NET/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Rosetta-Code-Rank-languages-by-popularity b/Lang/PascalABC.NET/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..55aa7d4f0c --- /dev/null +++ b/Lang/PascalABC.NET/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Rot-13 b/Lang/PascalABC.NET/Rot-13 new file mode 120000 index 0000000000..f7c9e778c9 --- /dev/null +++ b/Lang/PascalABC.NET/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Scope-modifiers b/Lang/PascalABC.NET/Scope-modifiers new file mode 120000 index 0000000000..eb11f44070 --- /dev/null +++ b/Lang/PascalABC.NET/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Send-an-unknown-method-call b/Lang/PascalABC.NET/Send-an-unknown-method-call new file mode 120000 index 0000000000..2e049c05b3 --- /dev/null +++ b/Lang/PascalABC.NET/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sequence-of-primes-by-trial-division b/Lang/PascalABC.NET/Sequence-of-primes-by-trial-division new file mode 120000 index 0000000000..4182c218d4 --- /dev/null +++ b/Lang/PascalABC.NET/Sequence-of-primes-by-trial-division @@ -0,0 +1 @@ +../../Task/Sequence-of-primes-by-trial-division/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sieve-of-Eratosthenes b/Lang/PascalABC.NET/Sieve-of-Eratosthenes new file mode 120000 index 0000000000..c9a2623742 --- /dev/null +++ b/Lang/PascalABC.NET/Sieve-of-Eratosthenes @@ -0,0 +1 @@ +../../Task/Sieve-of-Eratosthenes/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Simple-windowed-application b/Lang/PascalABC.NET/Simple-windowed-application new file mode 120000 index 0000000000..a619cd32f7 --- /dev/null +++ b/Lang/PascalABC.NET/Simple-windowed-application @@ -0,0 +1 @@ +../../Task/Simple-windowed-application/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Singly-linked-list-Element-definition b/Lang/PascalABC.NET/Singly-linked-list-Element-definition new file mode 120000 index 0000000000..71d3f5d628 --- /dev/null +++ b/Lang/PascalABC.NET/Singly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-definition/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Singly-linked-list-Element-insertion b/Lang/PascalABC.NET/Singly-linked-list-Element-insertion new file mode 120000 index 0000000000..f60548d528 --- /dev/null +++ b/Lang/PascalABC.NET/Singly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Singly-linked-list-Element-insertion/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sleep b/Lang/PascalABC.NET/Sleep new file mode 120000 index 0000000000..d8f830cd4f --- /dev/null +++ b/Lang/PascalABC.NET/Sleep @@ -0,0 +1 @@ +../../Task/Sleep/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sort-an-array-of-composite-structures b/Lang/PascalABC.NET/Sort-an-array-of-composite-structures new file mode 120000 index 0000000000..e0459e8577 --- /dev/null +++ b/Lang/PascalABC.NET/Sort-an-array-of-composite-structures @@ -0,0 +1 @@ +../../Task/Sort-an-array-of-composite-structures/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sort-an-integer-array b/Lang/PascalABC.NET/Sort-an-integer-array new file mode 120000 index 0000000000..e2137f1191 --- /dev/null +++ b/Lang/PascalABC.NET/Sort-an-integer-array @@ -0,0 +1 @@ +../../Task/Sort-an-integer-array/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sort-three-variables b/Lang/PascalABC.NET/Sort-three-variables new file mode 120000 index 0000000000..2143247222 --- /dev/null +++ b/Lang/PascalABC.NET/Sort-three-variables @@ -0,0 +1 @@ +../../Task/Sort-three-variables/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sort-using-a-custom-comparator b/Lang/PascalABC.NET/Sort-using-a-custom-comparator new file mode 120000 index 0000000000..a2ade4323b --- /dev/null +++ b/Lang/PascalABC.NET/Sort-using-a-custom-comparator @@ -0,0 +1 @@ +../../Task/Sort-using-a-custom-comparator/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sorting-algorithms-Quicksort b/Lang/PascalABC.NET/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..d84582d974 --- /dev/null +++ b/Lang/PascalABC.NET/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Special-variables b/Lang/PascalABC.NET/Special-variables new file mode 120000 index 0000000000..00db4953ba --- /dev/null +++ b/Lang/PascalABC.NET/Special-variables @@ -0,0 +1 @@ +../../Task/Special-variables/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Stack b/Lang/PascalABC.NET/Stack new file mode 120000 index 0000000000..71f695fe1b --- /dev/null +++ b/Lang/PascalABC.NET/Stack @@ -0,0 +1 @@ +../../Task/Stack/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Stack-traces b/Lang/PascalABC.NET/Stack-traces new file mode 120000 index 0000000000..b6976dc3e0 --- /dev/null +++ b/Lang/PascalABC.NET/Stack-traces @@ -0,0 +1 @@ +../../Task/Stack-traces/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-append b/Lang/PascalABC.NET/String-append new file mode 120000 index 0000000000..78fd361243 --- /dev/null +++ b/Lang/PascalABC.NET/String-append @@ -0,0 +1 @@ +../../Task/String-append/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-case b/Lang/PascalABC.NET/String-case new file mode 120000 index 0000000000..980e55192e --- /dev/null +++ b/Lang/PascalABC.NET/String-case @@ -0,0 +1 @@ +../../Task/String-case/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-concatenation b/Lang/PascalABC.NET/String-concatenation new file mode 120000 index 0000000000..d7b52bf492 --- /dev/null +++ b/Lang/PascalABC.NET/String-concatenation @@ -0,0 +1 @@ +../../Task/String-concatenation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-interpolation-included- b/Lang/PascalABC.NET/String-interpolation-included- new file mode 120000 index 0000000000..6a1179d384 --- /dev/null +++ b/Lang/PascalABC.NET/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-length b/Lang/PascalABC.NET/String-length new file mode 120000 index 0000000000..1bc629e3ec --- /dev/null +++ b/Lang/PascalABC.NET/String-length @@ -0,0 +1 @@ +../../Task/String-length/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-matching b/Lang/PascalABC.NET/String-matching new file mode 120000 index 0000000000..f031375ab5 --- /dev/null +++ b/Lang/PascalABC.NET/String-matching @@ -0,0 +1 @@ +../../Task/String-matching/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/String-prepend b/Lang/PascalABC.NET/String-prepend new file mode 120000 index 0000000000..205b3e4638 --- /dev/null +++ b/Lang/PascalABC.NET/String-prepend @@ -0,0 +1 @@ +../../Task/String-prepend/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Strip-a-set-of-characters-from-a-string b/Lang/PascalABC.NET/Strip-a-set-of-characters-from-a-string new file mode 120000 index 0000000000..5548033cde --- /dev/null +++ b/Lang/PascalABC.NET/Strip-a-set-of-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-a-set-of-characters-from-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Strip-block-comments b/Lang/PascalABC.NET/Strip-block-comments new file mode 120000 index 0000000000..7a95085577 --- /dev/null +++ b/Lang/PascalABC.NET/Strip-block-comments @@ -0,0 +1 @@ +../../Task/Strip-block-comments/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Strip-comments-from-a-string b/Lang/PascalABC.NET/Strip-comments-from-a-string new file mode 120000 index 0000000000..c415553cce --- /dev/null +++ b/Lang/PascalABC.NET/Strip-comments-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-comments-from-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Strip-control-codes-and-extended-characters-from-a-string b/Lang/PascalABC.NET/Strip-control-codes-and-extended-characters-from-a-string new file mode 120000 index 0000000000..3175c3c416 --- /dev/null +++ b/Lang/PascalABC.NET/Strip-control-codes-and-extended-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-control-codes-and-extended-characters-from-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Strip-whitespace-from-a-string-Top-and-tail b/Lang/PascalABC.NET/Strip-whitespace-from-a-string-Top-and-tail new file mode 120000 index 0000000000..075fc6a71b --- /dev/null +++ b/Lang/PascalABC.NET/Strip-whitespace-from-a-string-Top-and-tail @@ -0,0 +1 @@ +../../Task/Strip-whitespace-from-a-string-Top-and-tail/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Substitution-cipher b/Lang/PascalABC.NET/Substitution-cipher new file mode 120000 index 0000000000..5c9f1bb54c --- /dev/null +++ b/Lang/PascalABC.NET/Substitution-cipher @@ -0,0 +1 @@ +../../Task/Substitution-cipher/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Substring b/Lang/PascalABC.NET/Substring new file mode 120000 index 0000000000..f2a607112d --- /dev/null +++ b/Lang/PascalABC.NET/Substring @@ -0,0 +1 @@ +../../Task/Substring/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Substring-Top-and-tail b/Lang/PascalABC.NET/Substring-Top-and-tail new file mode 120000 index 0000000000..b64b9c4948 --- /dev/null +++ b/Lang/PascalABC.NET/Substring-Top-and-tail @@ -0,0 +1 @@ +../../Task/Substring-Top-and-tail/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sudan-function b/Lang/PascalABC.NET/Sudan-function new file mode 120000 index 0000000000..2a6cccd8a5 --- /dev/null +++ b/Lang/PascalABC.NET/Sudan-function @@ -0,0 +1 @@ +../../Task/Sudan-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-and-product-of-an-array b/Lang/PascalABC.NET/Sum-and-product-of-an-array new file mode 120000 index 0000000000..5bf49387d6 --- /dev/null +++ b/Lang/PascalABC.NET/Sum-and-product-of-an-array @@ -0,0 +1 @@ +../../Task/Sum-and-product-of-an-array/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-digits-of-an-integer b/Lang/PascalABC.NET/Sum-digits-of-an-integer new file mode 120000 index 0000000000..84d553224a --- /dev/null +++ b/Lang/PascalABC.NET/Sum-digits-of-an-integer @@ -0,0 +1 @@ +../../Task/Sum-digits-of-an-integer/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-multiples-of-3-and-5 b/Lang/PascalABC.NET/Sum-multiples-of-3-and-5 new file mode 120000 index 0000000000..3792b87fe0 --- /dev/null +++ b/Lang/PascalABC.NET/Sum-multiples-of-3-and-5 @@ -0,0 +1 @@ +../../Task/Sum-multiples-of-3-and-5/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-of-a-series b/Lang/PascalABC.NET/Sum-of-a-series new file mode 120000 index 0000000000..1c91b8532b --- /dev/null +++ b/Lang/PascalABC.NET/Sum-of-a-series @@ -0,0 +1 @@ +../../Task/Sum-of-a-series/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-of-elements-below-main-diagonal-of-matrix b/Lang/PascalABC.NET/Sum-of-elements-below-main-diagonal-of-matrix new file mode 120000 index 0000000000..055fd11a3e --- /dev/null +++ b/Lang/PascalABC.NET/Sum-of-elements-below-main-diagonal-of-matrix @@ -0,0 +1 @@ +../../Task/Sum-of-elements-below-main-diagonal-of-matrix/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Sum-of-squares b/Lang/PascalABC.NET/Sum-of-squares new file mode 120000 index 0000000000..0d6573d1ec --- /dev/null +++ b/Lang/PascalABC.NET/Sum-of-squares @@ -0,0 +1 @@ +../../Task/Sum-of-squares/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Symmetric-difference b/Lang/PascalABC.NET/Symmetric-difference new file mode 120000 index 0000000000..6a0af3805f --- /dev/null +++ b/Lang/PascalABC.NET/Symmetric-difference @@ -0,0 +1 @@ +../../Task/Symmetric-difference/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/System-time b/Lang/PascalABC.NET/System-time new file mode 120000 index 0000000000..b4cf3d92cb --- /dev/null +++ b/Lang/PascalABC.NET/System-time @@ -0,0 +1 @@ +../../Task/System-time/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Take-notes-on-the-command-line b/Lang/PascalABC.NET/Take-notes-on-the-command-line new file mode 120000 index 0000000000..ce2c9c51c4 --- /dev/null +++ b/Lang/PascalABC.NET/Take-notes-on-the-command-line @@ -0,0 +1 @@ +../../Task/Take-notes-on-the-command-line/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Tau-function b/Lang/PascalABC.NET/Tau-function new file mode 120000 index 0000000000..fcb633b959 --- /dev/null +++ b/Lang/PascalABC.NET/Tau-function @@ -0,0 +1 @@ +../../Task/Tau-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Tau-number b/Lang/PascalABC.NET/Tau-number new file mode 120000 index 0000000000..4be8374dc0 --- /dev/null +++ b/Lang/PascalABC.NET/Tau-number @@ -0,0 +1 @@ +../../Task/Tau-number/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Temperature-conversion b/Lang/PascalABC.NET/Temperature-conversion new file mode 120000 index 0000000000..607c5a8aa1 --- /dev/null +++ b/Lang/PascalABC.NET/Temperature-conversion @@ -0,0 +1 @@ +../../Task/Temperature-conversion/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Clear-the-screen b/Lang/PascalABC.NET/Terminal-control-Clear-the-screen new file mode 120000 index 0000000000..ba3f668e83 --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Clear-the-screen @@ -0,0 +1 @@ +../../Task/Terminal-control-Clear-the-screen/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Coloured-text b/Lang/PascalABC.NET/Terminal-control-Coloured-text new file mode 120000 index 0000000000..26edde266f --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Coloured-text @@ -0,0 +1 @@ +../../Task/Terminal-control-Coloured-text/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Cursor-movement b/Lang/PascalABC.NET/Terminal-control-Cursor-movement new file mode 120000 index 0000000000..75b038bfd2 --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Cursor-movement @@ -0,0 +1 @@ +../../Task/Terminal-control-Cursor-movement/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Cursor-positioning b/Lang/PascalABC.NET/Terminal-control-Cursor-positioning new file mode 120000 index 0000000000..440e989070 --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Cursor-positioning @@ -0,0 +1 @@ +../../Task/Terminal-control-Cursor-positioning/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Dimensions b/Lang/PascalABC.NET/Terminal-control-Dimensions new file mode 120000 index 0000000000..294b1506e4 --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Dimensions @@ -0,0 +1 @@ +../../Task/Terminal-control-Dimensions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Display-an-extended-character b/Lang/PascalABC.NET/Terminal-control-Display-an-extended-character new file mode 120000 index 0000000000..51ff55a04f --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Display-an-extended-character @@ -0,0 +1 @@ +../../Task/Terminal-control-Display-an-extended-character/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Hiding-the-cursor b/Lang/PascalABC.NET/Terminal-control-Hiding-the-cursor new file mode 120000 index 0000000000..0f79ee5b6d --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Hiding-the-cursor @@ -0,0 +1 @@ +../../Task/Terminal-control-Hiding-the-cursor/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Terminal-control-Ringing-the-terminal-bell b/Lang/PascalABC.NET/Terminal-control-Ringing-the-terminal-bell new file mode 120000 index 0000000000..dbea7c8c1b --- /dev/null +++ b/Lang/PascalABC.NET/Terminal-control-Ringing-the-terminal-bell @@ -0,0 +1 @@ +../../Task/Terminal-control-Ringing-the-terminal-bell/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Test-a-function b/Lang/PascalABC.NET/Test-a-function new file mode 120000 index 0000000000..561aaeccdd --- /dev/null +++ b/Lang/PascalABC.NET/Test-a-function @@ -0,0 +1 @@ +../../Task/Test-a-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Time-a-function b/Lang/PascalABC.NET/Time-a-function new file mode 120000 index 0000000000..2c161d3642 --- /dev/null +++ b/Lang/PascalABC.NET/Time-a-function @@ -0,0 +1 @@ +../../Task/Time-a-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Tokenize-a-string b/Lang/PascalABC.NET/Tokenize-a-string new file mode 120000 index 0000000000..790ef58cc8 --- /dev/null +++ b/Lang/PascalABC.NET/Tokenize-a-string @@ -0,0 +1 @@ +../../Task/Tokenize-a-string/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Top-rank-per-group b/Lang/PascalABC.NET/Top-rank-per-group new file mode 120000 index 0000000000..09da721479 --- /dev/null +++ b/Lang/PascalABC.NET/Top-rank-per-group @@ -0,0 +1 @@ +../../Task/Top-rank-per-group/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Towers-of-Hanoi b/Lang/PascalABC.NET/Towers-of-Hanoi new file mode 120000 index 0000000000..2c8ecfee74 --- /dev/null +++ b/Lang/PascalABC.NET/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Trabb-Pardo-Knuth-algorithm b/Lang/PascalABC.NET/Trabb-Pardo-Knuth-algorithm new file mode 120000 index 0000000000..c211c9d9e3 --- /dev/null +++ b/Lang/PascalABC.NET/Trabb-Pardo-Knuth-algorithm @@ -0,0 +1 @@ +../../Task/Trabb-Pardo-Knuth-algorithm/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Transliterate-English-text-using-the-Greek-alphabet b/Lang/PascalABC.NET/Transliterate-English-text-using-the-Greek-alphabet new file mode 120000 index 0000000000..d24a02b5a0 --- /dev/null +++ b/Lang/PascalABC.NET/Transliterate-English-text-using-the-Greek-alphabet @@ -0,0 +1 @@ +../../Task/Transliterate-English-text-using-the-Greek-alphabet/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Tree-datastructures b/Lang/PascalABC.NET/Tree-datastructures new file mode 120000 index 0000000000..2b711cc827 --- /dev/null +++ b/Lang/PascalABC.NET/Tree-datastructures @@ -0,0 +1 @@ +../../Task/Tree-datastructures/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Tree-traversal b/Lang/PascalABC.NET/Tree-traversal new file mode 120000 index 0000000000..7b8540d436 --- /dev/null +++ b/Lang/PascalABC.NET/Tree-traversal @@ -0,0 +1 @@ +../../Task/Tree-traversal/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Trigonometric-functions b/Lang/PascalABC.NET/Trigonometric-functions new file mode 120000 index 0000000000..90b97e3cc1 --- /dev/null +++ b/Lang/PascalABC.NET/Trigonometric-functions @@ -0,0 +1 @@ +../../Task/Trigonometric-functions/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Truncate-a-file b/Lang/PascalABC.NET/Truncate-a-file new file mode 120000 index 0000000000..e41951adf8 --- /dev/null +++ b/Lang/PascalABC.NET/Truncate-a-file @@ -0,0 +1 @@ +../../Task/Truncate-a-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Twos-complement b/Lang/PascalABC.NET/Twos-complement new file mode 120000 index 0000000000..b0daea87d5 --- /dev/null +++ b/Lang/PascalABC.NET/Twos-complement @@ -0,0 +1 @@ +../../Task/Twos-complement/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/URL-decoding b/Lang/PascalABC.NET/URL-decoding new file mode 120000 index 0000000000..bb79d3d611 --- /dev/null +++ b/Lang/PascalABC.NET/URL-decoding @@ -0,0 +1 @@ +../../Task/URL-decoding/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/URL-encoding b/Lang/PascalABC.NET/URL-encoding new file mode 120000 index 0000000000..4e193b1e1d --- /dev/null +++ b/Lang/PascalABC.NET/URL-encoding @@ -0,0 +1 @@ +../../Task/URL-encoding/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Undefined-values b/Lang/PascalABC.NET/Undefined-values new file mode 120000 index 0000000000..799f03aa4e --- /dev/null +++ b/Lang/PascalABC.NET/Undefined-values @@ -0,0 +1 @@ +../../Task/Undefined-values/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Unicode-strings b/Lang/PascalABC.NET/Unicode-strings new file mode 120000 index 0000000000..1596fd402d --- /dev/null +++ b/Lang/PascalABC.NET/Unicode-strings @@ -0,0 +1 @@ +../../Task/Unicode-strings/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Unicode-variable-names b/Lang/PascalABC.NET/Unicode-variable-names new file mode 120000 index 0000000000..356bcbe63e --- /dev/null +++ b/Lang/PascalABC.NET/Unicode-variable-names @@ -0,0 +1 @@ +../../Task/Unicode-variable-names/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/User-input-Text b/Lang/PascalABC.NET/User-input-Text new file mode 120000 index 0000000000..c49d403c30 --- /dev/null +++ b/Lang/PascalABC.NET/User-input-Text @@ -0,0 +1 @@ +../../Task/User-input-Text/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Variables b/Lang/PascalABC.NET/Variables new file mode 120000 index 0000000000..fb0f3cb656 --- /dev/null +++ b/Lang/PascalABC.NET/Variables @@ -0,0 +1 @@ +../../Task/Variables/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Variadic-function b/Lang/PascalABC.NET/Variadic-function new file mode 120000 index 0000000000..c1bc454958 --- /dev/null +++ b/Lang/PascalABC.NET/Variadic-function @@ -0,0 +1 @@ +../../Task/Variadic-function/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Vector b/Lang/PascalABC.NET/Vector new file mode 120000 index 0000000000..d45a06a593 --- /dev/null +++ b/Lang/PascalABC.NET/Vector @@ -0,0 +1 @@ +../../Task/Vector/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Vector-products b/Lang/PascalABC.NET/Vector-products new file mode 120000 index 0000000000..8bc6e1a1f1 --- /dev/null +++ b/Lang/PascalABC.NET/Vector-products @@ -0,0 +1 @@ +../../Task/Vector-products/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Walk-a-directory-Non-recursively b/Lang/PascalABC.NET/Walk-a-directory-Non-recursively new file mode 120000 index 0000000000..117d045320 --- /dev/null +++ b/Lang/PascalABC.NET/Walk-a-directory-Non-recursively @@ -0,0 +1 @@ +../../Task/Walk-a-directory-Non-recursively/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Walk-a-directory-Recursively b/Lang/PascalABC.NET/Walk-a-directory-Recursively new file mode 120000 index 0000000000..6fba185f99 --- /dev/null +++ b/Lang/PascalABC.NET/Walk-a-directory-Recursively @@ -0,0 +1 @@ +../../Task/Walk-a-directory-Recursively/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Window-creation b/Lang/PascalABC.NET/Window-creation new file mode 120000 index 0000000000..c656ea2a7f --- /dev/null +++ b/Lang/PascalABC.NET/Window-creation @@ -0,0 +1 @@ +../../Task/Window-creation/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Word-frequency b/Lang/PascalABC.NET/Word-frequency new file mode 120000 index 0000000000..eed444f9fc --- /dev/null +++ b/Lang/PascalABC.NET/Word-frequency @@ -0,0 +1 @@ +../../Task/Word-frequency/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Word-wrap b/Lang/PascalABC.NET/Word-wrap new file mode 120000 index 0000000000..b2cbb831f8 --- /dev/null +++ b/Lang/PascalABC.NET/Word-wrap @@ -0,0 +1 @@ +../../Task/Word-wrap/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Write-entire-file b/Lang/PascalABC.NET/Write-entire-file new file mode 120000 index 0000000000..fb24fa3029 --- /dev/null +++ b/Lang/PascalABC.NET/Write-entire-file @@ -0,0 +1 @@ +../../Task/Write-entire-file/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Write-to-Windows-event-log b/Lang/PascalABC.NET/Write-to-Windows-event-log new file mode 120000 index 0000000000..556c794eaf --- /dev/null +++ b/Lang/PascalABC.NET/Write-to-Windows-event-log @@ -0,0 +1 @@ +../../Task/Write-to-Windows-event-log/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/XML-DOM-serialization b/Lang/PascalABC.NET/XML-DOM-serialization new file mode 120000 index 0000000000..ac8822f809 --- /dev/null +++ b/Lang/PascalABC.NET/XML-DOM-serialization @@ -0,0 +1 @@ +../../Task/XML-DOM-serialization/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/XML-Input b/Lang/PascalABC.NET/XML-Input new file mode 120000 index 0000000000..6c693b433f --- /dev/null +++ b/Lang/PascalABC.NET/XML-Input @@ -0,0 +1 @@ +../../Task/XML-Input/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/XML-Output b/Lang/PascalABC.NET/XML-Output new file mode 120000 index 0000000000..c33649037e --- /dev/null +++ b/Lang/PascalABC.NET/XML-Output @@ -0,0 +1 @@ +../../Task/XML-Output/PascalABC.NET \ No newline at end of file diff --git a/Lang/PascalABC.NET/Zero-to-the-zero-power b/Lang/PascalABC.NET/Zero-to-the-zero-power new file mode 120000 index 0000000000..315543b2a3 --- /dev/null +++ b/Lang/PascalABC.NET/Zero-to-the-zero-power @@ -0,0 +1 @@ +../../Task/Zero-to-the-zero-power/PascalABC.NET \ No newline at end of file diff --git a/Lang/Perl/Search-in-paragraphs-text b/Lang/Perl/Search-in-paragraphs-text new file mode 120000 index 0000000000..3327049060 --- /dev/null +++ b/Lang/Perl/Search-in-paragraphs-text @@ -0,0 +1 @@ +../../Task/Search-in-paragraphs-text/Perl \ No newline at end of file diff --git a/Lang/Prog8/Quine b/Lang/Prog8/Quine new file mode 120000 index 0000000000..d19dfe3196 --- /dev/null +++ b/Lang/Prog8/Quine @@ -0,0 +1 @@ +../../Task/Quine/Prog8 \ No newline at end of file diff --git a/Lang/PureBasic/M-bius-function b/Lang/PureBasic/M-bius-function new file mode 120000 index 0000000000..86603635cf --- /dev/null +++ b/Lang/PureBasic/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/PureBasic \ No newline at end of file diff --git a/Lang/Python/Rhonda-numbers b/Lang/Python/Rhonda-numbers new file mode 120000 index 0000000000..26cc73526d --- /dev/null +++ b/Lang/Python/Rhonda-numbers @@ -0,0 +1 @@ +../../Task/Rhonda-numbers/Python \ No newline at end of file diff --git a/Lang/QB64/Fibonacci-n-step-number-sequences b/Lang/QB64/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..dbe9d19cad --- /dev/null +++ b/Lang/QB64/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/QB64 \ No newline at end of file diff --git a/Lang/QB64/Multiple-regression b/Lang/QB64/Multiple-regression new file mode 120000 index 0000000000..f5a655fb07 --- /dev/null +++ b/Lang/QB64/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/QB64 \ No newline at end of file diff --git a/Lang/QB64/Price-fraction b/Lang/QB64/Price-fraction new file mode 120000 index 0000000000..b2a7164220 --- /dev/null +++ b/Lang/QB64/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/QB64 \ No newline at end of file diff --git a/Lang/QBasic/Display-a-linear-combination b/Lang/QBasic/Display-a-linear-combination new file mode 120000 index 0000000000..e9d158c960 --- /dev/null +++ b/Lang/QBasic/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/QBasic \ No newline at end of file diff --git a/Lang/QBasic/Fibonacci-n-step-number-sequences b/Lang/QBasic/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..77136c7137 --- /dev/null +++ b/Lang/QBasic/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/QBasic \ No newline at end of file diff --git a/Lang/QBasic/Jensens-Device b/Lang/QBasic/Jensens-Device new file mode 120000 index 0000000000..199e4d7809 --- /dev/null +++ b/Lang/QBasic/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/QBasic \ No newline at end of file diff --git a/Lang/QBasic/Nested-templated-data b/Lang/QBasic/Nested-templated-data new file mode 120000 index 0000000000..ddf5a87c1b --- /dev/null +++ b/Lang/QBasic/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/QBasic \ No newline at end of file diff --git a/Lang/QBasic/Ramer-Douglas-Peucker-line-simplification b/Lang/QBasic/Ramer-Douglas-Peucker-line-simplification new file mode 120000 index 0000000000..574b7acaf0 --- /dev/null +++ b/Lang/QBasic/Ramer-Douglas-Peucker-line-simplification @@ -0,0 +1 @@ +../../Task/Ramer-Douglas-Peucker-line-simplification/QBasic \ No newline at end of file diff --git a/Lang/QBasic/Vector b/Lang/QBasic/Vector new file mode 120000 index 0000000000..7bbf551f69 --- /dev/null +++ b/Lang/QBasic/Vector @@ -0,0 +1 @@ +../../Task/Vector/QBasic \ No newline at end of file diff --git a/Lang/Quackery/00-LANG.txt b/Lang/Quackery/00-LANG.txt index 498188387d..e36ac3a936 100644 --- a/Lang/Quackery/00-LANG.txt +++ b/Lang/Quackery/00-LANG.txt @@ -19,7 +19,7 @@ To compile this definition of quackery, build takes a The words is, [, and ] are builders; they can be found in the builders dictionary, which extends the functionality of build beyond building a flat nest for do to evaluate. is takes the item that do most recently added to its output nest, and adds it to the names dictionary, along with the string that follows it, "quackery" as its name. The syntax of Quackery is; words and numbers are sequences of printable characters, separated by spaces and carriage returns unless a builder treats the text that follows it otherwise. The builder builds is equivalent to is for adding new words and behaviours to the builders dictionary. -Evaluation of a nest proceeds from left to right unless a control flow operator redirects it. done causes doto stop evaluating a nest and return to the nest that pointed to it immediately, rather than at the end of the nest. again restarts the evaluation of that nest, non-recursively. The word recurse does it recursively. if and iff conditionally (depending on the item on the top of the Quackery stack) skip over the next one and two items in the nest respectively. else skips over one item, unconditionally. As with the other provided control flow operators, these words are nests, not operators, that make use of the "meta-control flow" operators, which grant the behaviours described above to words that use them. (They modify items on the return stack, rather than acting on the Quackery engine's various pointers registers directly, so their changes are enacted upon exiting the nest that called them.) +Evaluation of a nest proceeds from left to right unless a control flow operator redirects it. done causes doto stop evaluating a nest and return to the nest that pointed to it immediately, rather than at the end of the nest. again restarts the evaluation of that nest, non-recursively. The word recurse does it recursively. if and iff conditionally (depending on the item on the top of the Quackery stack) skip over the next one and two items in the nest respectively. else skips over one item, unconditionally. As with the other provided control flow operators, these words are nests, not operators, that make use of the "meta-control flow" operators, which grant the behaviours described above to words that use them. (They modify items on the return stack, rather than acting on the Quackery engine's various registers directly, so their changes are enacted upon exiting the nest that called them.) There are no variables in Quackery. Instead, there are stack management words to rearrange the uppermost items on the Quackery stack as required, and nameable ancillary stacks that fulfil the roles of variables. diff --git a/Lang/Quackery/Dinesmans-multiple-dwelling-problem b/Lang/Quackery/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..2061e87b20 --- /dev/null +++ b/Lang/Quackery/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Distribution-of-0-digits-in-factorial-series b/Lang/Quackery/Distribution-of-0-digits-in-factorial-series new file mode 120000 index 0000000000..8627f3195b --- /dev/null +++ b/Lang/Quackery/Distribution-of-0-digits-in-factorial-series @@ -0,0 +1 @@ +../../Task/Distribution-of-0-digits-in-factorial-series/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Dutch-national-flag-problem b/Lang/Quackery/Dutch-national-flag-problem new file mode 120000 index 0000000000..133393cf2e --- /dev/null +++ b/Lang/Quackery/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Flipping-bits-game b/Lang/Quackery/Flipping-bits-game new file mode 120000 index 0000000000..fd3aa38458 --- /dev/null +++ b/Lang/Quackery/Flipping-bits-game @@ -0,0 +1 @@ +../../Task/Flipping-bits-game/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/Quackery/Minimum-multiple-of-m-where-digital-sum-equals-m new file mode 120000 index 0000000000..ddb9ece049 --- /dev/null +++ b/Lang/Quackery/Minimum-multiple-of-m-where-digital-sum-equals-m @@ -0,0 +1 @@ +../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Password-generator b/Lang/Quackery/Password-generator new file mode 120000 index 0000000000..8d0efee13f --- /dev/null +++ b/Lang/Quackery/Password-generator @@ -0,0 +1 @@ +../../Task/Password-generator/Quackery \ No newline at end of file diff --git a/Lang/Quackery/Solve-the-no-connection-puzzle b/Lang/Quackery/Solve-the-no-connection-puzzle new file mode 120000 index 0000000000..d37f201a93 --- /dev/null +++ b/Lang/Quackery/Solve-the-no-connection-puzzle @@ -0,0 +1 @@ +../../Task/Solve-the-no-connection-puzzle/Quackery \ No newline at end of file diff --git a/Lang/QuickBASIC/Function-definition b/Lang/QuickBASIC/Function-definition new file mode 120000 index 0000000000..0251617973 --- /dev/null +++ b/Lang/QuickBASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/QuickBASIC \ No newline at end of file diff --git a/Lang/QuickBASIC/Monty-Hall-problem b/Lang/QuickBASIC/Monty-Hall-problem new file mode 120000 index 0000000000..5a322fee75 --- /dev/null +++ b/Lang/QuickBASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/QuickBASIC \ No newline at end of file diff --git a/Lang/QuickBASIC/Random-numbers b/Lang/QuickBASIC/Random-numbers new file mode 120000 index 0000000000..8332f543fa --- /dev/null +++ b/Lang/QuickBASIC/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/QuickBASIC \ No newline at end of file diff --git a/Lang/QuickBASIC/Sorting-algorithms-Quicksort b/Lang/QuickBASIC/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..573bd236b2 --- /dev/null +++ b/Lang/QuickBASIC/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/QuickBASIC \ No newline at end of file diff --git a/Lang/R/Arithmetic-derivative b/Lang/R/Arithmetic-derivative new file mode 120000 index 0000000000..b37750c7e7 --- /dev/null +++ b/Lang/R/Arithmetic-derivative @@ -0,0 +1 @@ +../../Task/Arithmetic-derivative/R \ No newline at end of file diff --git a/Lang/R/Compare-length-of-two-strings b/Lang/R/Compare-length-of-two-strings new file mode 120000 index 0000000000..834feb9f20 --- /dev/null +++ b/Lang/R/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/R \ No newline at end of file diff --git a/Lang/R/Conjugate-transpose b/Lang/R/Conjugate-transpose new file mode 120000 index 0000000000..573e26fb04 --- /dev/null +++ b/Lang/R/Conjugate-transpose @@ -0,0 +1 @@ +../../Task/Conjugate-transpose/R \ No newline at end of file diff --git a/Lang/R/Golden-ratio-Convergence b/Lang/R/Golden-ratio-Convergence new file mode 120000 index 0000000000..c3444860a4 --- /dev/null +++ b/Lang/R/Golden-ratio-Convergence @@ -0,0 +1 @@ +../../Task/Golden-ratio-Convergence/R \ No newline at end of file diff --git a/Lang/REXX/00-LANG.txt b/Lang/REXX/00-LANG.txt index 26a483d9aa..e8f90b2e8c 100644 --- a/Lang/REXX/00-LANG.txt +++ b/Lang/REXX/00-LANG.txt @@ -36,7 +36,7 @@ The '''REXX''' language was influenced by the computer programming languages: &n * '''[[CRX REXX]]'''   (Compact REXX) is a classic REXX first written by Dr. Brian Marks. -* '''[[CTC REXX]]'''   is a classic REXX that is bundled with PC/SPF and written by Command Technology Corporation,   a license is required to use this product.   This version of REXX can only be used under PC/SPF and it's panels.   PC/SPF resembles the IBM program product SPF (which has other names and versions). +* '''[[CTC REXX]]'''   is a classic REXX that is bundled with PC/SPF and written by Command Technology Corporation,   a license is required to use this product.   This version of REXX can only be used under PC/SPF and it's panels.   PC/SPF resembles the IBM program product SPF (which has other names and versions). The last version was published in 1996. CTC doesn't exist anymore. * '''[[KEXX]]'''   is a subset of REXX that is bundled with KEDIT and written by Keven J. Kearney of Mansfield Software Group, Inc., a license is required to use this product.   KEXX only executes under the KEDIT licensed product.   KEDIT is an XEDIT clone (an editor from IBM for VM/CMS program products). @@ -75,7 +75,7 @@ The '''REXX''' language was influenced by the computer programming languages: &n * '''[[Regina REXX]]'''   is an implementation first created by Anders Christensen (in 1992) and is now maintained by others, notably Mark Hessling.   Regina REXX runs on more different platforms than any other REXX,   too many to name here.   It can be downloaded freely. -* '''[[Reginald REXX]]'''   is a REXX developed by Jeff Glatt.   It can be downloaded freely. +* '''[[Reginald REXX]]'''   is a REXX developed by Jeff Glatt.   It can be downloaded freely. According to Rexxinfo.org, Reginald is out of maintenance. * '''[[REXX/imc]]'''   a classic REXX developed by Ian M. Collier (imc) for Linux/Unix. @@ -84,10 +84,10 @@ The '''REXX''' language was influenced by the computer programming languages: &n * '''REXX/Personal'''   is another name for   '''Personal REXX'''     (see above). -* '''[[ROO oo-REXX]]'''   an object-oriented REXX developed by Keith Watts of Kilowatt Software, Inc.     It can be downloaded freely.   '''ROO'''   is also known as   '''ROO!'''. +* '''[[ROO oo-REXX]]'''   an object-oriented REXX developed by Keith Watts of Kilowatt Software, Inc.     It can be downloaded freely.   '''ROO'''   is also known as   '''ROO!'''. According to Rexxinfo.org, Roo! is out of maintenance. -* '''[[R4 REXX]]'''   a classic REXX developed by Keith Watts of Kilowatt Software, Inc.     It was also known as '''Portable REXX'''.   It can be downloaded freely. +* '''[[R4 REXX]]'''   a classic REXX developed by Keith Watts of Kilowatt Software, Inc.     It was also known as '''Portable REXX'''.   It can be downloaded freely. According to Rexxinfo.org, R4 is out of maintenance. * '''[[T/REXX, a REXX compiler for CMS]]'''   is an implementation of classic REXX written by Leigh Lundin and Mark Woodruff   (according to Wikipedia). diff --git a/Lang/REXX/Eulers-constant-0.5772... b/Lang/REXX/Eulers-constant-0.5772... new file mode 120000 index 0000000000..4dd79a59f3 --- /dev/null +++ b/Lang/REXX/Eulers-constant-0.5772... @@ -0,0 +1 @@ +../../Task/Eulers-constant-0.5772.../REXX \ No newline at end of file diff --git a/Lang/Red/00-LANG.txt b/Lang/Red/00-LANG.txt index 1cb6089084..bde0f4b81e 100644 --- a/Lang/Red/00-LANG.txt +++ b/Lang/Red/00-LANG.txt @@ -8,6 +8,9 @@ Like Rebol, Red has a low memory footprint, is garbage collected, and has a [htt Red embeds several DSLs, among which Red/System (C semantics meet Red syntax), dedicated to low-level and system programming. It is also used as an intermediate language (IL) when Red is compiled. The Red executable is able to build Red/System files directly (`*.reds`) as well as Red files (`*.red`), and Red/System code may be embedded freely in Red code. +==Todo== +[https://rosettacode.org/wiki/Tasks_not_implemented_in_Red Tasks not implemented in Red] + ==Useful links== * [http://www.red-lang.org Red Language Website] * [https://twitter.com/red_lang @red_lang] on Twitter. diff --git a/Lang/Refal/Copy-stdin-to-stdout b/Lang/Refal/Copy-stdin-to-stdout new file mode 120000 index 0000000000..974e13964c --- /dev/null +++ b/Lang/Refal/Copy-stdin-to-stdout @@ -0,0 +1 @@ +../../Task/Copy-stdin-to-stdout/Refal \ No newline at end of file diff --git a/Lang/Refal/Damm-algorithm b/Lang/Refal/Damm-algorithm new file mode 120000 index 0000000000..9b99056b8a --- /dev/null +++ b/Lang/Refal/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/Refal \ No newline at end of file diff --git a/Lang/Refal/Determine-sentence-type b/Lang/Refal/Determine-sentence-type new file mode 120000 index 0000000000..13809ebd86 --- /dev/null +++ b/Lang/Refal/Determine-sentence-type @@ -0,0 +1 @@ +../../Task/Determine-sentence-type/Refal \ No newline at end of file diff --git a/Lang/Refal/Disarium-numbers b/Lang/Refal/Disarium-numbers new file mode 120000 index 0000000000..7389ead892 --- /dev/null +++ b/Lang/Refal/Disarium-numbers @@ -0,0 +1 @@ +../../Task/Disarium-numbers/Refal \ No newline at end of file diff --git a/Lang/Refal/Discordian-date b/Lang/Refal/Discordian-date new file mode 120000 index 0000000000..e18bd824ca --- /dev/null +++ b/Lang/Refal/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Refal \ No newline at end of file diff --git a/Lang/Refal/Factors-of-an-integer b/Lang/Refal/Factors-of-an-integer new file mode 120000 index 0000000000..b8b431c369 --- /dev/null +++ b/Lang/Refal/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Refal \ No newline at end of file diff --git a/Lang/Refal/Flatten-a-list b/Lang/Refal/Flatten-a-list new file mode 120000 index 0000000000..b2445ac726 --- /dev/null +++ b/Lang/Refal/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Refal \ No newline at end of file diff --git a/Lang/Refal/General-FizzBuzz b/Lang/Refal/General-FizzBuzz new file mode 120000 index 0000000000..019727fd06 --- /dev/null +++ b/Lang/Refal/General-FizzBuzz @@ -0,0 +1 @@ +../../Task/General-FizzBuzz/Refal \ No newline at end of file diff --git a/Lang/Refal/Letter-frequency b/Lang/Refal/Letter-frequency new file mode 120000 index 0000000000..e9c48e99dd --- /dev/null +++ b/Lang/Refal/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Refal \ No newline at end of file diff --git a/Lang/Refal/McNuggets-problem b/Lang/Refal/McNuggets-problem new file mode 120000 index 0000000000..90628a4989 --- /dev/null +++ b/Lang/Refal/McNuggets-problem @@ -0,0 +1 @@ +../../Task/McNuggets-problem/Refal \ No newline at end of file diff --git a/Lang/Refal/Nested-templated-data b/Lang/Refal/Nested-templated-data new file mode 120000 index 0000000000..ceaf039a10 --- /dev/null +++ b/Lang/Refal/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/Refal \ No newline at end of file diff --git a/Lang/Refal/One-dimensional-cellular-automata b/Lang/Refal/One-dimensional-cellular-automata new file mode 120000 index 0000000000..89b9ba280e --- /dev/null +++ b/Lang/Refal/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Refal \ No newline at end of file diff --git a/Lang/Refal/Palindrome-detection b/Lang/Refal/Palindrome-detection new file mode 120000 index 0000000000..87f1ace89c --- /dev/null +++ b/Lang/Refal/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Refal \ No newline at end of file diff --git a/Lang/Refal/Population-count b/Lang/Refal/Population-count new file mode 120000 index 0000000000..3cdd939b69 --- /dev/null +++ b/Lang/Refal/Population-count @@ -0,0 +1 @@ +../../Task/Population-count/Refal \ No newline at end of file diff --git a/Lang/Refal/Repeat b/Lang/Refal/Repeat new file mode 120000 index 0000000000..1cdb36e096 --- /dev/null +++ b/Lang/Refal/Repeat @@ -0,0 +1 @@ +../../Task/Repeat/Refal \ No newline at end of file diff --git a/Lang/Refal/Split-a-character-string-based-on-change-of-character b/Lang/Refal/Split-a-character-string-based-on-change-of-character new file mode 120000 index 0000000000..8a3aec8866 --- /dev/null +++ b/Lang/Refal/Split-a-character-string-based-on-change-of-character @@ -0,0 +1 @@ +../../Task/Split-a-character-string-based-on-change-of-character/Refal \ No newline at end of file diff --git a/Lang/Refal/Square-but-not-cube b/Lang/Refal/Square-but-not-cube new file mode 120000 index 0000000000..a50417a708 --- /dev/null +++ b/Lang/Refal/Square-but-not-cube @@ -0,0 +1 @@ +../../Task/Square-but-not-cube/Refal \ No newline at end of file diff --git a/Lang/Refal/Word-ladder b/Lang/Refal/Word-ladder new file mode 120000 index 0000000000..b43f6deb31 --- /dev/null +++ b/Lang/Refal/Word-ladder @@ -0,0 +1 @@ +../../Task/Word-ladder/Refal \ No newline at end of file diff --git a/Lang/Rockstar/00-LANG.txt b/Lang/Rockstar/00-LANG.txt index 9dc3cbc2f7..c22e2c3636 100644 --- a/Lang/Rockstar/00-LANG.txt +++ b/Lang/Rockstar/00-LANG.txt @@ -1,4 +1,8 @@ -{{stub}}{{language|Rockstar}} +{{stub}} +{{language|Rockstar +|site=https://codewithrockstar.com/ +|hopl=no +}} Rockstar was created by a rockin' dude named Dylan Beattie. diff --git a/Lang/Run-BASIC/Nested-templated-data b/Lang/Run-BASIC/Nested-templated-data new file mode 120000 index 0000000000..e2c607e939 --- /dev/null +++ b/Lang/Run-BASIC/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/Run-BASIC \ No newline at end of file diff --git a/Lang/S-BASIC/Copy-a-string b/Lang/S-BASIC/Copy-a-string new file mode 120000 index 0000000000..cf54fdae2e --- /dev/null +++ b/Lang/S-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/S-BASIC \ No newline at end of file diff --git a/Lang/S-BASIC/Factorial b/Lang/S-BASIC/Factorial new file mode 120000 index 0000000000..3c6e9121ba --- /dev/null +++ b/Lang/S-BASIC/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/S-BASIC \ No newline at end of file diff --git a/Lang/S-BASIC/Loops-Break b/Lang/S-BASIC/Loops-Break new file mode 120000 index 0000000000..4109f93543 --- /dev/null +++ b/Lang/S-BASIC/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/S-BASIC \ No newline at end of file diff --git a/Lang/SETL/Brilliant-numbers b/Lang/SETL/Brilliant-numbers new file mode 120000 index 0000000000..8c8cbe8558 --- /dev/null +++ b/Lang/SETL/Brilliant-numbers @@ -0,0 +1 @@ +../../Task/Brilliant-numbers/SETL \ No newline at end of file diff --git a/Lang/SETL/Damm-algorithm b/Lang/SETL/Damm-algorithm new file mode 120000 index 0000000000..8e8b8d193a --- /dev/null +++ b/Lang/SETL/Damm-algorithm @@ -0,0 +1 @@ +../../Task/Damm-algorithm/SETL \ No newline at end of file diff --git a/Lang/SETL/General-FizzBuzz b/Lang/SETL/General-FizzBuzz new file mode 120000 index 0000000000..c26977365f --- /dev/null +++ b/Lang/SETL/General-FizzBuzz @@ -0,0 +1 @@ +../../Task/General-FizzBuzz/SETL \ No newline at end of file diff --git a/Lang/SETL/Levenshtein-distance b/Lang/SETL/Levenshtein-distance new file mode 120000 index 0000000000..5a234fcd60 --- /dev/null +++ b/Lang/SETL/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/SETL \ No newline at end of file diff --git a/Lang/SETL/Luhn-test-of-credit-card-numbers b/Lang/SETL/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..d5c47a10ed --- /dev/null +++ b/Lang/SETL/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/SETL \ No newline at end of file diff --git a/Lang/SETL/Monty-Hall-problem b/Lang/SETL/Monty-Hall-problem new file mode 120000 index 0000000000..0740052c5e --- /dev/null +++ b/Lang/SETL/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/SETL \ No newline at end of file diff --git a/Lang/SETL/Nested-templated-data b/Lang/SETL/Nested-templated-data new file mode 120000 index 0000000000..58fd3f508a --- /dev/null +++ b/Lang/SETL/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/SETL \ No newline at end of file diff --git a/Lang/SETL/Ordered-words b/Lang/SETL/Ordered-words new file mode 120000 index 0000000000..efd35b209e --- /dev/null +++ b/Lang/SETL/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/SETL \ No newline at end of file diff --git a/Lang/SETL/Pisano-period b/Lang/SETL/Pisano-period new file mode 120000 index 0000000000..735d169166 --- /dev/null +++ b/Lang/SETL/Pisano-period @@ -0,0 +1 @@ +../../Task/Pisano-period/SETL \ No newline at end of file diff --git a/Lang/SETL/Show-ASCII-table b/Lang/SETL/Show-ASCII-table new file mode 120000 index 0000000000..5c4e8348ce --- /dev/null +++ b/Lang/SETL/Show-ASCII-table @@ -0,0 +1 @@ +../../Task/Show-ASCII-table/SETL \ No newline at end of file diff --git a/Lang/SETL/Split-a-character-string-based-on-change-of-character b/Lang/SETL/Split-a-character-string-based-on-change-of-character new file mode 120000 index 0000000000..ff9aa0b4dd --- /dev/null +++ b/Lang/SETL/Split-a-character-string-based-on-change-of-character @@ -0,0 +1 @@ +../../Task/Split-a-character-string-based-on-change-of-character/SETL \ No newline at end of file diff --git a/Lang/SETL/Word-ladder b/Lang/SETL/Word-ladder new file mode 120000 index 0000000000..c8dccafa85 --- /dev/null +++ b/Lang/SETL/Word-ladder @@ -0,0 +1 @@ +../../Task/Word-ladder/SETL \ No newline at end of file diff --git a/Lang/Sed/00-LANG.txt b/Lang/Sed/00-LANG.txt index 23390cea6c..5d2641e2db 100644 --- a/Lang/Sed/00-LANG.txt +++ b/Lang/Sed/00-LANG.txt @@ -6,5 +6,7 @@ a non interactive tool for text manipulation and filtering. One implementation is [[GNU Sed]] +See [[Tasks not implemented in sed]] + [[Category:Editor]] [[Category:Utility]] \ No newline at end of file diff --git a/Lang/Sidef/Increasing-gaps-between-consecutive-Niven-numbers b/Lang/Sidef/Increasing-gaps-between-consecutive-Niven-numbers new file mode 120000 index 0000000000..b80a20c4f5 --- /dev/null +++ b/Lang/Sidef/Increasing-gaps-between-consecutive-Niven-numbers @@ -0,0 +1 @@ +../../Task/Increasing-gaps-between-consecutive-Niven-numbers/Sidef \ No newline at end of file diff --git a/Lang/Sidef/Jaro-Winkler-distance b/Lang/Sidef/Jaro-Winkler-distance new file mode 120000 index 0000000000..48f92f7ccd --- /dev/null +++ b/Lang/Sidef/Jaro-Winkler-distance @@ -0,0 +1 @@ +../../Task/Jaro-Winkler-distance/Sidef \ No newline at end of file diff --git a/Lang/Sidef/Prime-numbers-whose-neighboring-pairs-are-tetraprimes b/Lang/Sidef/Prime-numbers-whose-neighboring-pairs-are-tetraprimes new file mode 120000 index 0000000000..1f840ef9e4 --- /dev/null +++ b/Lang/Sidef/Prime-numbers-whose-neighboring-pairs-are-tetraprimes @@ -0,0 +1 @@ +../../Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/Sidef \ No newline at end of file diff --git a/Lang/Sidef/Smarandache-Wellin-primes b/Lang/Sidef/Smarandache-Wellin-primes new file mode 120000 index 0000000000..056e5bc295 --- /dev/null +++ b/Lang/Sidef/Smarandache-Wellin-primes @@ -0,0 +1 @@ +../../Task/Smarandache-Wellin-primes/Sidef \ No newline at end of file diff --git a/Lang/Sidef/Wagstaff-primes b/Lang/Sidef/Wagstaff-primes new file mode 120000 index 0000000000..d0053cfbed --- /dev/null +++ b/Lang/Sidef/Wagstaff-primes @@ -0,0 +1 @@ +../../Task/Wagstaff-primes/Sidef \ No newline at end of file diff --git a/Lang/Standard-ML/Call-a-foreign-language-function b/Lang/Standard-ML/Call-a-foreign-language-function new file mode 120000 index 0000000000..1f398efa97 --- /dev/null +++ b/Lang/Standard-ML/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Pi b/Lang/Standard-ML/Pi new file mode 120000 index 0000000000..f806ddbcae --- /dev/null +++ b/Lang/Standard-ML/Pi @@ -0,0 +1 @@ +../../Task/Pi/Standard-ML \ No newline at end of file diff --git a/Lang/SuperCollider/00-LANG.txt b/Lang/SuperCollider/00-LANG.txt index f804a4a144..d6b538fcd2 100644 --- a/Lang/SuperCollider/00-LANG.txt +++ b/Lang/SuperCollider/00-LANG.txt @@ -9,4 +9,130 @@ The programming language was originally devised by James McCartney and has been [https://github.com/supercollider/supercollider SuperCollider at GitHub] -[http://supercollider.github.io/ SuperCollider Homepage] \ No newline at end of file +[http://supercollider.github.io/ SuperCollider Homepage] + + +

+Some additional notes on SuperCollider 2024-06-21 + +From the SuperCollider GitHub website: https://supercollider.github.io/ :
+Quote:
+A PLATFORM FOR AUDIO SYNTHESIS AND ALGORITHMIC COMPOSITION,
+      USED BY MUSICIANS, ARTISTS AND RESEARCHERS WORKING WITH SOUND. +

+FREE AND OPEN SOURCE SOFTWARE FOR WINDOWS, MACOS AND LINUX. +

+SuperCollider features three major components:
+scsynth – A real-time audio server
+sclang – An interpreted programming language
+scide – An editor for sclang with an integrated help system
+End-Quote.
+
+Some people try to squeeze a musical composition into 140 characters: (but just for the challenge):
+Don't judge SuperCollider or the language by these examples, they are just for fun.
+ +f={|t|Pbind(\note,Pseq([-1,1,6,8,9,1,-1,8,6,1,9,8]+5,319),\dur,t)};Ptpar([0,f.(1/6),12,f.(0.1672)],1).play + +Listen to the results here: https://supercollider.github.io/assets/audio/sc-140/06_batuhanbozkurt_celesteh.mp3
+You can see/hear more at: https://supercollider.github.io/sc-140.html
+
+
+As of today (2024-06-21) the current version of SuperCollider for all supported platforms is: 3.13.0 +

+While SClang (SuperCollider language) and its companion components are designed for the creation of sounds and music, the language is a full featured programming language. +

+The language is OO, to the extent that everything is an object, even numbers.
+In this snippet: 123 + 456 the 123 is an object, + is a method on the class of that object, and 456 is a parameter to that method.
+Even though + is a method the syntax of the addition is what you would typically expect. +

+The print function in SClang is a method called postln, which first appears in the root of the class tree: Object.
+
+Some examples, showing two possible call formats: + +postln("Hello World"); // prints: Hello World +"Hello World".postln; // prints: Hello World +postln(1001); // prints: 1001 +1001.postln; // prints: 1001 +postln(123 + 456); // prints: 579 +(123 + 456).postln; // prints: 579 + + +The method postln, adds a new-line after printing the text, if you don't want the new-line, use: post. +

+ +SuperCollider from the command line (not used much) + +SuperCollider scripts are stored in files with an extension of .scd. +These are typically referred to as supercollider documents, hence .scd. +

+99.99% of the time, you will execute code from within the IDE (scide).
+
+It is possible but not typical, to run a script from the command line, for example:
+ > sclang.exe ABC_problem.scd
+This will output the expected results. +See code at: https://rosettacode.org/wiki/ABC_problem#SuperCollider

+However, before executing your code, sclang will compile its class library, and you will see all of the messages about the compilation, before you see the output from your code. +

+Also, once your code is finished, you will be stuck as sclang is still waiting for more input from a file, not the keyboard. The second problem can be solved by adding exit(0); to the end of your script (.scd file); +

+SuperCollider comes packaged with QT, and has classes that represent GUI objects, for example:
+ > sclang.exe Barnsley_fern.scd
+Will open a window and draw the Barnsley Fern.
+See code at: https://rosettacode.org/wiki/Barnsley_fern#SuperCollider
+You will have to use Ctrl-c to kill the sclang process, you cannot add exit(0) to you script as the exit would happen before the GUI was fully created. +

+It is theoretically possible to create a thread within your script which waits until all work is done and then for it to execute exit(0); but you are just giving yourself extra work. +

+You can also run sclang without giving it a file, then it will accept input from the keyboard. + > sclang.exe
+You will get this prompt sc3> now you can type in ONE LINE OF CODE. +For example, the following line of code has three statements, the end result is printing the sum of the two numbers:
+sc3> var v1=123; var v2=456; postf("v1+v2=%\n", v1+v2);
+v1+v2=579
+-> v1+v2=579
+
+The line with the arrow: -> v1+v2=579, is sclang printing the value of the last expression executed +

+Summary: You can start sclang from the command line and type in some code, or you could give sclang a script to run, both will work, but it is much more productive to use scide. +Using sclang from the command line is like playing your guitar with winter gloves on, you could do it, but why make life difficult? +

+If you have composed (written code for) a long piece of music, and now you want to execute the code from the command line, yes, you can do it, but it isn't going to sound any different than it would if you execute the code from within scide.

+Also, scide offers the ability to 'live code', i.e. execute some code to make some music, and change the code as the music is playing, so the music evolves as you change the code. +

+ +SuperCollider from the IDE
+Start scide, or 'open' a SuperCollider Document (*.scd), if scide is 'associated' with that file type.
+See: https://doc.sccode.org/Guides/SCIde.html
+After you start scide, it starts sclang, which compiles the SuperCollider classes.
+Now you can start coding.
+
+How to execute code (borrowed from the page at the URL above)
+
+To evaluate code, use one of the following keyboard commands:
+Ctrl+Return
+Most used, "smart" code evaluation:
+Normally, the current line will be evaluated (where the cursor is).
+If the cursor is within a region, the entire region will be evaluated. See below for explanation of regions.
+If some code is selected, the selection will be evaluated.
+
+Shift+Return +

+Evaluates either the current line, or the selection (if any). Use this to evaluate a single line within a region without the need to select it.
+Regions make it quick and easy to evaluate larger portions of code. A region is surrounded by parentheses; to be interpreted as a region, the parenthesis must each be the only character on a line.
+ +( +Pbind( + \degree, Pseries(0, 1, 8), + \dur, 0.25 +).play; +) + +If the cursor is anywhere between the outermost parentheses, pressing Ctrl+Return will automatically evaluate the entire contents within the parentheses, starting with Pbind and ending with play;.
+

+To quickly evaluate a portion of code, you can also double-click on any bracket (round, squared, or curly), which will select everything between this and the other matching bracket, so you can quickly evaluate it. +

+To stop any running code, use the Ctrl+. shortcut (Ctrl+Period).
+This will stop all the code scheduled on the clocks, as well as all the sound processes on the audio server. +

+ +... more coming soon ... \ No newline at end of file diff --git a/Lang/SuperCollider/Semordnilap b/Lang/SuperCollider/Semordnilap deleted file mode 120000 index ace051dba8..0000000000 --- a/Lang/SuperCollider/Semordnilap +++ /dev/null @@ -1 +0,0 @@ -../../Task/Semordnilap/SuperCollider \ No newline at end of file diff --git a/Lang/Swift/Compare-length-of-two-strings b/Lang/Swift/Compare-length-of-two-strings new file mode 120000 index 0000000000..d53f307b7e --- /dev/null +++ b/Lang/Swift/Compare-length-of-two-strings @@ -0,0 +1 @@ +../../Task/Compare-length-of-two-strings/Swift \ No newline at end of file diff --git a/Lang/Swift/Pseudo-random-numbers-Splitmix64 b/Lang/Swift/Pseudo-random-numbers-Splitmix64 new file mode 120000 index 0000000000..7f3d66c35a --- /dev/null +++ b/Lang/Swift/Pseudo-random-numbers-Splitmix64 @@ -0,0 +1 @@ +../../Task/Pseudo-random-numbers-Splitmix64/Swift \ No newline at end of file diff --git a/Lang/Transd/Compare-length-of-two-strings b/Lang/Transd/Compare-length-of-two-strings deleted file mode 120000 index 28f3956c3e..0000000000 --- a/Lang/Transd/Compare-length-of-two-strings +++ /dev/null @@ -1 +0,0 @@ -../../Task/Compare-length-of-two-strings/Transd \ No newline at end of file diff --git a/Lang/True-BASIC/100-prisoners b/Lang/True-BASIC/100-prisoners new file mode 120000 index 0000000000..b793e357f7 --- /dev/null +++ b/Lang/True-BASIC/100-prisoners @@ -0,0 +1 @@ +../../Task/100-prisoners/True-BASIC \ No newline at end of file diff --git a/Lang/True-BASIC/Multiple-regression b/Lang/True-BASIC/Multiple-regression new file mode 120000 index 0000000000..ca0e5c404e --- /dev/null +++ b/Lang/True-BASIC/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/True-BASIC \ No newline at end of file diff --git a/Lang/True-BASIC/Vector b/Lang/True-BASIC/Vector new file mode 120000 index 0000000000..4da227d0fe --- /dev/null +++ b/Lang/True-BASIC/Vector @@ -0,0 +1 @@ +../../Task/Vector/True-BASIC \ No newline at end of file diff --git a/Lang/TypeScript/Deal-cards-for-FreeCell b/Lang/TypeScript/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..04eefe17ef --- /dev/null +++ b/Lang/TypeScript/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/TypeScript \ No newline at end of file diff --git a/Lang/UNIX-Shell/Pi b/Lang/UNIX-Shell/Pi new file mode 120000 index 0000000000..854a52d02a --- /dev/null +++ b/Lang/UNIX-Shell/Pi @@ -0,0 +1 @@ +../../Task/Pi/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Trabb-Pardo-Knuth-algorithm b/Lang/UNIX-Shell/Trabb-Pardo-Knuth-algorithm new file mode 120000 index 0000000000..d9c18fe35b --- /dev/null +++ b/Lang/UNIX-Shell/Trabb-Pardo-Knuth-algorithm @@ -0,0 +1 @@ +../../Task/Trabb-Pardo-Knuth-algorithm/UNIX-Shell \ No newline at end of file diff --git a/Lang/Uiua/00-LANG.txt b/Lang/Uiua/00-LANG.txt index 2a4f3f689f..820e780454 100644 --- a/Lang/Uiua/00-LANG.txt +++ b/Lang/Uiua/00-LANG.txt @@ -1,6 +1,13 @@ {{language -|site=https://www.uiua.org/}} -{{language programming paradigm|functional}} +|exec=bytecode +|site=https://www.uiua.org/ +|checking=dynamic +|gc=yes +|express=implicit +|LCT=yes}} +{{language programming paradigm|array}} +{{language programming paradigm|functional|array}} + Uiua (''wee-wuh'') is a general purpose, stack-based, array-oriented programming language with a focus on simplicity, beauty, and tacit code. Uiua has a simple, context-free, LL(3) grammar. Code runs from right to left, top to bottom, with only one precedence rule. As operators are to the left of their operands, Uiua code reads a little bit like a Lisp, but with fewer parentheses. @@ -11,4 +18,7 @@ Uiua's one and only composite data type, the array, is based on those of APL, J, Unlike other array languages, Uiua does not have monadic and dyadic versions of each glyph. Every glyph does only one thing, so you don't need to parse an entire expression to know which version it is. -Find out more, and run code in your browser at https://www.uiua.org \ No newline at end of file +Find out more, and run code in your browser at https://www.uiua.org + +==Todo== +[https://rosettacode.org/wiki/Tasks_not_implemented_in_Uiua Tasks not implemented in Uiua] \ No newline at end of file diff --git a/Lang/Uiua/15-puzzle-solver b/Lang/Uiua/15-puzzle-solver new file mode 120000 index 0000000000..d2c4541287 --- /dev/null +++ b/Lang/Uiua/15-puzzle-solver @@ -0,0 +1 @@ +../../Task/15-puzzle-solver/Uiua \ No newline at end of file diff --git a/Lang/Uiua/ADFGVX-cipher b/Lang/Uiua/ADFGVX-cipher new file mode 120000 index 0000000000..3b808ce65e --- /dev/null +++ b/Lang/Uiua/ADFGVX-cipher @@ -0,0 +1 @@ +../../Task/ADFGVX-cipher/Uiua \ No newline at end of file diff --git a/Lang/Uiua/ASCII-art-diagram-converter b/Lang/Uiua/ASCII-art-diagram-converter new file mode 120000 index 0000000000..7868ebc205 --- /dev/null +++ b/Lang/Uiua/ASCII-art-diagram-converter @@ -0,0 +1 @@ +../../Task/ASCII-art-diagram-converter/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Abbreviations-automatic b/Lang/Uiua/Abbreviations-automatic new file mode 120000 index 0000000000..4ed38ebb71 --- /dev/null +++ b/Lang/Uiua/Abbreviations-automatic @@ -0,0 +1 @@ +../../Task/Abbreviations-automatic/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Abelian-sandpile-model b/Lang/Uiua/Abelian-sandpile-model new file mode 120000 index 0000000000..511d6d21ce --- /dev/null +++ b/Lang/Uiua/Abelian-sandpile-model @@ -0,0 +1 @@ +../../Task/Abelian-sandpile-model/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Align-columns b/Lang/Uiua/Align-columns new file mode 120000 index 0000000000..90d8156011 --- /dev/null +++ b/Lang/Uiua/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Anti-primes b/Lang/Uiua/Anti-primes new file mode 120000 index 0000000000..caaf04d665 --- /dev/null +++ b/Lang/Uiua/Anti-primes @@ -0,0 +1 @@ +../../Task/Anti-primes/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Arithmetic-geometric-mean b/Lang/Uiua/Arithmetic-geometric-mean new file mode 120000 index 0000000000..6adeb66a11 --- /dev/null +++ b/Lang/Uiua/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Array-concatenation b/Lang/Uiua/Array-concatenation new file mode 120000 index 0000000000..48fabf1a40 --- /dev/null +++ b/Lang/Uiua/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Array-length b/Lang/Uiua/Array-length new file mode 120000 index 0000000000..7c3be21b34 --- /dev/null +++ b/Lang/Uiua/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Ascending-primes b/Lang/Uiua/Ascending-primes new file mode 120000 index 0000000000..83b9f7be7a --- /dev/null +++ b/Lang/Uiua/Ascending-primes @@ -0,0 +1 @@ +../../Task/Ascending-primes/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Averages-Mean-time-of-day b/Lang/Uiua/Averages-Mean-time-of-day new file mode 120000 index 0000000000..970582690e --- /dev/null +++ b/Lang/Uiua/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Barnsley-fern b/Lang/Uiua/Barnsley-fern new file mode 120000 index 0000000000..39f57d2d79 --- /dev/null +++ b/Lang/Uiua/Barnsley-fern @@ -0,0 +1 @@ +../../Task/Barnsley-fern/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Benfords-law b/Lang/Uiua/Benfords-law new file mode 120000 index 0000000000..c9f7d29ef6 --- /dev/null +++ b/Lang/Uiua/Benfords-law @@ -0,0 +1 @@ +../../Task/Benfords-law/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Bifid-cipher b/Lang/Uiua/Bifid-cipher new file mode 120000 index 0000000000..7118fdadf7 --- /dev/null +++ b/Lang/Uiua/Bifid-cipher @@ -0,0 +1 @@ +../../Task/Bifid-cipher/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Binary-digits b/Lang/Uiua/Binary-digits new file mode 120000 index 0000000000..126c2d6665 --- /dev/null +++ b/Lang/Uiua/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Bulls-and-cows-Player b/Lang/Uiua/Bulls-and-cows-Player new file mode 120000 index 0000000000..b45c91dd88 --- /dev/null +++ b/Lang/Uiua/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Uiua \ No newline at end of file diff --git a/Lang/Uiua/CSV-data-manipulation b/Lang/Uiua/CSV-data-manipulation new file mode 120000 index 0000000000..78747e6f49 --- /dev/null +++ b/Lang/Uiua/CSV-data-manipulation @@ -0,0 +1 @@ +../../Task/CSV-data-manipulation/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Calkin-Wilf-sequence b/Lang/Uiua/Calkin-Wilf-sequence new file mode 120000 index 0000000000..23330ada15 --- /dev/null +++ b/Lang/Uiua/Calkin-Wilf-sequence @@ -0,0 +1 @@ +../../Task/Calkin-Wilf-sequence/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Cartesian-product-of-two-or-more-lists b/Lang/Uiua/Cartesian-product-of-two-or-more-lists new file mode 120000 index 0000000000..bff2250b36 --- /dev/null +++ b/Lang/Uiua/Cartesian-product-of-two-or-more-lists @@ -0,0 +1 @@ +../../Task/Cartesian-product-of-two-or-more-lists/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Combinations b/Lang/Uiua/Combinations new file mode 120000 index 0000000000..1300366dbb --- /dev/null +++ b/Lang/Uiua/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Convert-seconds-to-compound-duration b/Lang/Uiua/Convert-seconds-to-compound-duration new file mode 120000 index 0000000000..7c892696f2 --- /dev/null +++ b/Lang/Uiua/Convert-seconds-to-compound-duration @@ -0,0 +1 @@ +../../Task/Convert-seconds-to-compound-duration/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Conways-Game-of-Life b/Lang/Uiua/Conways-Game-of-Life new file mode 120000 index 0000000000..577dcf20b1 --- /dev/null +++ b/Lang/Uiua/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Determine-if-a-string-is-collapsible b/Lang/Uiua/Determine-if-a-string-is-collapsible new file mode 120000 index 0000000000..9891000cca --- /dev/null +++ b/Lang/Uiua/Determine-if-a-string-is-collapsible @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-collapsible/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Dutch-national-flag-problem b/Lang/Uiua/Dutch-national-flag-problem new file mode 120000 index 0000000000..198949a01a --- /dev/null +++ b/Lang/Uiua/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Factorial b/Lang/Uiua/Factorial new file mode 120000 index 0000000000..5664c30904 --- /dev/null +++ b/Lang/Uiua/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Factors-of-an-integer b/Lang/Uiua/Factors-of-an-integer new file mode 120000 index 0000000000..c83bd4a95a --- /dev/null +++ b/Lang/Uiua/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Find-the-missing-permutation b/Lang/Uiua/Find-the-missing-permutation new file mode 120000 index 0000000000..e1361833f3 --- /dev/null +++ b/Lang/Uiua/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Flatten-a-list b/Lang/Uiua/Flatten-a-list new file mode 120000 index 0000000000..8d22eb4f6e --- /dev/null +++ b/Lang/Uiua/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Flipping-bits-game b/Lang/Uiua/Flipping-bits-game new file mode 120000 index 0000000000..4647df0617 --- /dev/null +++ b/Lang/Uiua/Flipping-bits-game @@ -0,0 +1 @@ +../../Task/Flipping-bits-game/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Forest-fire b/Lang/Uiua/Forest-fire new file mode 120000 index 0000000000..1c1ded9f8f --- /dev/null +++ b/Lang/Uiua/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Greatest-common-divisor b/Lang/Uiua/Greatest-common-divisor new file mode 120000 index 0000000000..ed42b8017f --- /dev/null +++ b/Lang/Uiua/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Identity-matrix b/Lang/Uiua/Identity-matrix new file mode 120000 index 0000000000..73bc76c89c --- /dev/null +++ b/Lang/Uiua/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Increment-a-numerical-string b/Lang/Uiua/Increment-a-numerical-string new file mode 120000 index 0000000000..5102531751 --- /dev/null +++ b/Lang/Uiua/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Integer-sequence b/Lang/Uiua/Integer-sequence new file mode 120000 index 0000000000..71a2ec5539 --- /dev/null +++ b/Lang/Uiua/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Langtons-ant b/Lang/Uiua/Langtons-ant new file mode 120000 index 0000000000..ea25fbedff --- /dev/null +++ b/Lang/Uiua/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Largest-int-from-concatenated-ints b/Lang/Uiua/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..1440573f32 --- /dev/null +++ b/Lang/Uiua/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Least-common-multiple b/Lang/Uiua/Least-common-multiple new file mode 120000 index 0000000000..83973eef06 --- /dev/null +++ b/Lang/Uiua/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Levenshtein-distance b/Lang/Uiua/Levenshtein-distance new file mode 120000 index 0000000000..2d4dd26520 --- /dev/null +++ b/Lang/Uiua/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Uiua \ No newline at end of file diff --git a/Lang/Uiua/List-comprehensions b/Lang/Uiua/List-comprehensions new file mode 120000 index 0000000000..bf7b708e56 --- /dev/null +++ b/Lang/Uiua/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Look-and-say-sequence b/Lang/Uiua/Look-and-say-sequence new file mode 120000 index 0000000000..f3d748e2f9 --- /dev/null +++ b/Lang/Uiua/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Loop-over-multiple-arrays-simultaneously b/Lang/Uiua/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..59937c5207 --- /dev/null +++ b/Lang/Uiua/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Luhn-test-of-credit-card-numbers b/Lang/Uiua/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..6eae093c92 --- /dev/null +++ b/Lang/Uiua/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Mandelbrot-set b/Lang/Uiua/Mandelbrot-set new file mode 120000 index 0000000000..da1b6d50fa --- /dev/null +++ b/Lang/Uiua/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Matrix-multiplication b/Lang/Uiua/Matrix-multiplication new file mode 120000 index 0000000000..8ecd583efc --- /dev/null +++ b/Lang/Uiua/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Maze-solving b/Lang/Uiua/Maze-solving new file mode 120000 index 0000000000..02af57731f --- /dev/null +++ b/Lang/Uiua/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Uiua \ No newline at end of file diff --git a/Lang/Uiua/McNuggets-problem b/Lang/Uiua/McNuggets-problem new file mode 120000 index 0000000000..93b54a1053 --- /dev/null +++ b/Lang/Uiua/McNuggets-problem @@ -0,0 +1 @@ +../../Task/McNuggets-problem/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Middle-three-digits b/Lang/Uiua/Middle-three-digits new file mode 120000 index 0000000000..5c8f171c17 --- /dev/null +++ b/Lang/Uiua/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Motzkin-numbers b/Lang/Uiua/Motzkin-numbers new file mode 120000 index 0000000000..bef04d5aa9 --- /dev/null +++ b/Lang/Uiua/Motzkin-numbers @@ -0,0 +1 @@ +../../Task/Motzkin-numbers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/N-queens-problem b/Lang/Uiua/N-queens-problem new file mode 120000 index 0000000000..d8b56e5e2a --- /dev/null +++ b/Lang/Uiua/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/Uiua/Numbers-which-are-not-the-sum-of-distinct-squares new file mode 120000 index 0000000000..fd1772b308 --- /dev/null +++ b/Lang/Uiua/Numbers-which-are-not-the-sum-of-distinct-squares @@ -0,0 +1 @@ +../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/Uiua \ No newline at end of file diff --git a/Lang/Uiua/One-dimensional-cellular-automata b/Lang/Uiua/One-dimensional-cellular-automata new file mode 120000 index 0000000000..5df7e9b84a --- /dev/null +++ b/Lang/Uiua/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Ordered-words b/Lang/Uiua/Ordered-words new file mode 120000 index 0000000000..7046edd964 --- /dev/null +++ b/Lang/Uiua/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Permutations b/Lang/Uiua/Permutations new file mode 120000 index 0000000000..850f4f7144 --- /dev/null +++ b/Lang/Uiua/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Pick-random-element b/Lang/Uiua/Pick-random-element new file mode 120000 index 0000000000..e85c1a21e1 --- /dev/null +++ b/Lang/Uiua/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Uiua \ No newline at end of file diff --git a/Lang/Uiua/RPG-attributes-generator b/Lang/Uiua/RPG-attributes-generator new file mode 120000 index 0000000000..96e8262b6d --- /dev/null +++ b/Lang/Uiua/RPG-attributes-generator @@ -0,0 +1 @@ +../../Task/RPG-attributes-generator/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Random-numbers b/Lang/Uiua/Random-numbers new file mode 120000 index 0000000000..bc115ba91a --- /dev/null +++ b/Lang/Uiua/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Run-length-encoding b/Lang/Uiua/Run-length-encoding new file mode 120000 index 0000000000..b6eee5ca86 --- /dev/null +++ b/Lang/Uiua/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Smith-numbers b/Lang/Uiua/Smith-numbers new file mode 120000 index 0000000000..3e4afb53bf --- /dev/null +++ b/Lang/Uiua/Smith-numbers @@ -0,0 +1 @@ +../../Task/Smith-numbers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Solve-a-Hidato-puzzle b/Lang/Uiua/Solve-a-Hidato-puzzle new file mode 120000 index 0000000000..961a795fe0 --- /dev/null +++ b/Lang/Uiua/Solve-a-Hidato-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Hidato-puzzle/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Solve-a-Numbrix-puzzle b/Lang/Uiua/Solve-a-Numbrix-puzzle new file mode 120000 index 0000000000..d5e755e9d5 --- /dev/null +++ b/Lang/Uiua/Solve-a-Numbrix-puzzle @@ -0,0 +1 @@ +../../Task/Solve-a-Numbrix-puzzle/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Sort-disjoint-sublist b/Lang/Uiua/Sort-disjoint-sublist new file mode 120000 index 0000000000..247b8fbb37 --- /dev/null +++ b/Lang/Uiua/Sort-disjoint-sublist @@ -0,0 +1 @@ +../../Task/Sort-disjoint-sublist/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Split-a-character-string-based-on-change-of-character b/Lang/Uiua/Split-a-character-string-based-on-change-of-character new file mode 120000 index 0000000000..61d4dd8555 --- /dev/null +++ b/Lang/Uiua/Split-a-character-string-based-on-change-of-character @@ -0,0 +1 @@ +../../Task/Split-a-character-string-based-on-change-of-character/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Square-free-integers b/Lang/Uiua/Square-free-integers new file mode 120000 index 0000000000..7a649e9779 --- /dev/null +++ b/Lang/Uiua/Square-free-integers @@ -0,0 +1 @@ +../../Task/Square-free-integers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Stem-and-leaf-plot b/Lang/Uiua/Stem-and-leaf-plot new file mode 120000 index 0000000000..cfafe7201a --- /dev/null +++ b/Lang/Uiua/Stem-and-leaf-plot @@ -0,0 +1 @@ +../../Task/Stem-and-leaf-plot/Uiua \ No newline at end of file diff --git a/Lang/Uiua/String-case b/Lang/Uiua/String-case new file mode 120000 index 0000000000..4362c13413 --- /dev/null +++ b/Lang/Uiua/String-case @@ -0,0 +1 @@ +../../Task/String-case/Uiua \ No newline at end of file diff --git a/Lang/Uiua/String-concatenation b/Lang/Uiua/String-concatenation new file mode 120000 index 0000000000..cd5c2325bd --- /dev/null +++ b/Lang/Uiua/String-concatenation @@ -0,0 +1 @@ +../../Task/String-concatenation/Uiua \ No newline at end of file diff --git a/Lang/Uiua/String-interpolation-included- b/Lang/Uiua/String-interpolation-included- new file mode 120000 index 0000000000..e880f170b4 --- /dev/null +++ b/Lang/Uiua/String-interpolation-included- @@ -0,0 +1 @@ +../../Task/String-interpolation-included-/Uiua \ No newline at end of file diff --git a/Lang/Uiua/String-matching b/Lang/Uiua/String-matching new file mode 120000 index 0000000000..d45ce27782 --- /dev/null +++ b/Lang/Uiua/String-matching @@ -0,0 +1 @@ +../../Task/String-matching/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Strip-a-set-of-characters-from-a-string b/Lang/Uiua/Strip-a-set-of-characters-from-a-string new file mode 120000 index 0000000000..951d176969 --- /dev/null +++ b/Lang/Uiua/Strip-a-set-of-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-a-set-of-characters-from-a-string/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Sudoku b/Lang/Uiua/Sudoku new file mode 120000 index 0000000000..be7e18a94a --- /dev/null +++ b/Lang/Uiua/Sudoku @@ -0,0 +1 @@ +../../Task/Sudoku/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Sum-multiples-of-3-and-5 b/Lang/Uiua/Sum-multiples-of-3-and-5 new file mode 120000 index 0000000000..1949126562 --- /dev/null +++ b/Lang/Uiua/Sum-multiples-of-3-and-5 @@ -0,0 +1 @@ +../../Task/Sum-multiples-of-3-and-5/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Summarize-primes b/Lang/Uiua/Summarize-primes new file mode 120000 index 0000000000..4ad940883d --- /dev/null +++ b/Lang/Uiua/Summarize-primes @@ -0,0 +1 @@ +../../Task/Summarize-primes/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Test-a-function b/Lang/Uiua/Test-a-function new file mode 120000 index 0000000000..4e61b05504 --- /dev/null +++ b/Lang/Uiua/Test-a-function @@ -0,0 +1 @@ +../../Task/Test-a-function/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Truncatable-primes b/Lang/Uiua/Truncatable-primes new file mode 120000 index 0000000000..b02bf04462 --- /dev/null +++ b/Lang/Uiua/Truncatable-primes @@ -0,0 +1 @@ +../../Task/Truncatable-primes/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Validate-International-Securities-Identification-Number b/Lang/Uiua/Validate-International-Securities-Identification-Number new file mode 120000 index 0000000000..6d28391590 --- /dev/null +++ b/Lang/Uiua/Validate-International-Securities-Identification-Number @@ -0,0 +1 @@ +../../Task/Validate-International-Securities-Identification-Number/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Water-collected-between-towers b/Lang/Uiua/Water-collected-between-towers new file mode 120000 index 0000000000..cfd5fa722a --- /dev/null +++ b/Lang/Uiua/Water-collected-between-towers @@ -0,0 +1 @@ +../../Task/Water-collected-between-towers/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Yellowstone-sequence b/Lang/Uiua/Yellowstone-sequence new file mode 120000 index 0000000000..0bae4da70f --- /dev/null +++ b/Lang/Uiua/Yellowstone-sequence @@ -0,0 +1 @@ +../../Task/Yellowstone-sequence/Uiua \ No newline at end of file diff --git a/Lang/Uiua/Zebra-puzzle b/Lang/Uiua/Zebra-puzzle new file mode 120000 index 0000000000..cd343323b4 --- /dev/null +++ b/Lang/Uiua/Zebra-puzzle @@ -0,0 +1 @@ +../../Task/Zebra-puzzle/Uiua \ No newline at end of file diff --git a/Lang/Uxntal/Quine b/Lang/Uxntal/Quine new file mode 120000 index 0000000000..9f3a4ca4d4 --- /dev/null +++ b/Lang/Uxntal/Quine @@ -0,0 +1 @@ +../../Task/Quine/Uxntal \ No newline at end of file diff --git a/Lang/Uxntal/Weird-numbers b/Lang/Uxntal/Weird-numbers new file mode 120000 index 0000000000..1bddac81d2 --- /dev/null +++ b/Lang/Uxntal/Weird-numbers @@ -0,0 +1 @@ +../../Task/Weird-numbers/Uxntal \ No newline at end of file diff --git a/Lang/Vim-Script/Hello-world-Graphical b/Lang/Vim-Script/Hello-world-Graphical new file mode 120000 index 0000000000..799696cc16 --- /dev/null +++ b/Lang/Vim-Script/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Vim-Script \ No newline at end of file diff --git a/Lang/Vim-Script/Here-document b/Lang/Vim-Script/Here-document new file mode 120000 index 0000000000..4f2967d090 --- /dev/null +++ b/Lang/Vim-Script/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Vim-Script \ No newline at end of file diff --git a/Lang/Vim-Script/Loop-over-multiple-arrays-simultaneously b/Lang/Vim-Script/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..3e8729e53b --- /dev/null +++ b/Lang/Vim-Script/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Vim-Script \ No newline at end of file diff --git a/Lang/Vim-Script/Loops-For b/Lang/Vim-Script/Loops-For new file mode 120000 index 0000000000..427dcdb8bf --- /dev/null +++ b/Lang/Vim-Script/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Vim-Script \ No newline at end of file diff --git a/Lang/Vim-Script/XML-Input b/Lang/Vim-Script/XML-Input new file mode 120000 index 0000000000..57be30dc70 --- /dev/null +++ b/Lang/Vim-Script/XML-Input @@ -0,0 +1 @@ +../../Task/XML-Input/Vim-Script \ No newline at end of file diff --git a/Lang/Wren/00-LANG.txt b/Lang/Wren/00-LANG.txt index 1dbc2e611b..ea9fd010ee 100644 --- a/Lang/Wren/00-LANG.txt +++ b/Lang/Wren/00-LANG.txt @@ -15,7 +15,7 @@ It is under development on [https://github.com/wren-lang/wren GitHub] and is ful The CLI tool (Wren CLI) has its own repository and is the main focus of examples written for RC. The latest version 0.4.0 is available as a pre-built standalone executable for 64-bit Linux, MacOS and Windows and can be downloaded from [https://github.com/wren-lang/wren-cli/releases here]. -As a language mainly designed for embedding, Wren's standard library is (of necessity) quite small and I have therefore decided to create some additional modules to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily. The ones written so far are listed below: +As a language mainly designed for embedding, Wren's standard library is (of necessity) quite small and I ([[User:PureFox|PureFox]]) have therefore decided to create some additional modules to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily. The ones written so far are listed below: {| class="wikitable" ! No. !! Module name !! !! No. !! Module name diff --git a/Lang/XBasic/Euler-method b/Lang/XBasic/Euler-method new file mode 120000 index 0000000000..546ca521e8 --- /dev/null +++ b/Lang/XBasic/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/XBasic \ No newline at end of file diff --git a/Lang/XBasic/M-bius-function b/Lang/XBasic/M-bius-function new file mode 120000 index 0000000000..09886c7873 --- /dev/null +++ b/Lang/XBasic/M-bius-function @@ -0,0 +1 @@ +../../Task/M-bius-function/XBasic \ No newline at end of file diff --git a/Lang/XBasic/Nim-game b/Lang/XBasic/Nim-game new file mode 120000 index 0000000000..49a494ab0c --- /dev/null +++ b/Lang/XBasic/Nim-game @@ -0,0 +1 @@ +../../Task/Nim-game/XBasic \ No newline at end of file diff --git a/Lang/XBasic/Sorting-algorithms-Quicksort b/Lang/XBasic/Sorting-algorithms-Quicksort new file mode 120000 index 0000000000..baefc61c90 --- /dev/null +++ b/Lang/XBasic/Sorting-algorithms-Quicksort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Quicksort/XBasic \ No newline at end of file diff --git a/Lang/XPL0/Draw-a-clock b/Lang/XPL0/Draw-a-clock new file mode 120000 index 0000000000..7d1040eda3 --- /dev/null +++ b/Lang/XPL0/Draw-a-clock @@ -0,0 +1 @@ +../../Task/Draw-a-clock/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Poker-hand-analyser b/Lang/XPL0/Poker-hand-analyser new file mode 120000 index 0000000000..5fc0329088 --- /dev/null +++ b/Lang/XPL0/Poker-hand-analyser @@ -0,0 +1 @@ +../../Task/Poker-hand-analyser/XPL0 \ No newline at end of file diff --git a/Lang/YAMLScript/00-LANG.txt b/Lang/YAMLScript/00-LANG.txt index 1ead096361..eae1577f6a 100644 --- a/Lang/YAMLScript/00-LANG.txt +++ b/Lang/YAMLScript/00-LANG.txt @@ -7,6 +7,7 @@ '''[https://yamlscript.org 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 YAMLScript programs. YAMLScript 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: * [https://clojars.org/org.yamlscript/clj-yamlscript Clojure] +* [https://github.com/yaml/yamlscript-go Go] * [https://clojars.org/org.yamlscript/yamlscript Java] * [https://www.npmjs.com/package/@yaml/yamlscript NodeJS] * [https://metacpan.org/pod/YAMLScript Perl] @@ -19,7 +20,7 @@ Run this command to install the ys command line YAMLScript runner/loader/compiler program. - curl -sSL yamlscript.org/install | bash + curl -s https://yamlscript.org/install | bash That will install $HOME/.local/bin/ys. If $HOME/.local/bin is not in your PATH, run: diff --git a/Lang/Yabasic/Display-a-linear-combination b/Lang/Yabasic/Display-a-linear-combination new file mode 120000 index 0000000000..3089327b6e --- /dev/null +++ b/Lang/Yabasic/Display-a-linear-combination @@ -0,0 +1 @@ +../../Task/Display-a-linear-combination/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Kronecker-product b/Lang/Yabasic/Kronecker-product new file mode 120000 index 0000000000..64e2f55421 --- /dev/null +++ b/Lang/Yabasic/Kronecker-product @@ -0,0 +1 @@ +../../Task/Kronecker-product/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Multiple-regression b/Lang/Yabasic/Multiple-regression new file mode 120000 index 0000000000..047c89f1aa --- /dev/null +++ b/Lang/Yabasic/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Nested-templated-data b/Lang/Yabasic/Nested-templated-data new file mode 120000 index 0000000000..026a122d79 --- /dev/null +++ b/Lang/Yabasic/Nested-templated-data @@ -0,0 +1 @@ +../../Task/Nested-templated-data/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Sexy-primes b/Lang/Yabasic/Sexy-primes new file mode 120000 index 0000000000..a3fa026246 --- /dev/null +++ b/Lang/Yabasic/Sexy-primes @@ -0,0 +1 @@ +../../Task/Sexy-primes/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Sorting-algorithms-Counting-sort b/Lang/Yabasic/Sorting-algorithms-Counting-sort new file mode 120000 index 0000000000..c5fee45d6b --- /dev/null +++ b/Lang/Yabasic/Sorting-algorithms-Counting-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Counting-sort/Yabasic \ No newline at end of file diff --git a/Lang/Yabasic/Sorting-algorithms-Stooge-sort b/Lang/Yabasic/Sorting-algorithms-Stooge-sort new file mode 120000 index 0000000000..920cab2b30 --- /dev/null +++ b/Lang/Yabasic/Sorting-algorithms-Stooge-sort @@ -0,0 +1 @@ +../../Task/Sorting-algorithms-Stooge-sort/Yabasic \ No newline at end of file diff --git a/Lang/Zig/15-puzzle-game b/Lang/Zig/15-puzzle-game new file mode 120000 index 0000000000..67842297fa --- /dev/null +++ b/Lang/Zig/15-puzzle-game @@ -0,0 +1 @@ +../../Task/15-puzzle-game/Zig \ No newline at end of file diff --git a/Lang/Zig/9-billion-names-of-God-the-integer b/Lang/Zig/9-billion-names-of-God-the-integer new file mode 120000 index 0000000000..891e6336a6 --- /dev/null +++ b/Lang/Zig/9-billion-names-of-God-the-integer @@ -0,0 +1 @@ +../../Task/9-billion-names-of-God-the-integer/Zig \ No newline at end of file diff --git a/Lang/Zig/A+B b/Lang/Zig/A+B new file mode 120000 index 0000000000..99c5298cb2 --- /dev/null +++ b/Lang/Zig/A+B @@ -0,0 +1 @@ +../../Task/A+B/Zig \ No newline at end of file diff --git a/Lang/Zig/Determine-if-a-string-is-numeric b/Lang/Zig/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..1317ba1b29 --- /dev/null +++ b/Lang/Zig/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Zig \ No newline at end of file diff --git a/Lang/Zig/Egyptian-division b/Lang/Zig/Egyptian-division new file mode 120000 index 0000000000..fbc8453acb --- /dev/null +++ b/Lang/Zig/Egyptian-division @@ -0,0 +1 @@ +../../Task/Egyptian-division/Zig \ No newline at end of file diff --git a/Lang/Zig/Integer-sequence b/Lang/Zig/Integer-sequence new file mode 120000 index 0000000000..43f4f97f8b --- /dev/null +++ b/Lang/Zig/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Zig \ No newline at end of file diff --git a/Lang/Zig/Monty-Hall-problem b/Lang/Zig/Monty-Hall-problem new file mode 120000 index 0000000000..5c32ef8986 --- /dev/null +++ b/Lang/Zig/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Zig \ No newline at end of file diff --git a/Lang/Zig/Solve-the-no-connection-puzzle b/Lang/Zig/Solve-the-no-connection-puzzle new file mode 120000 index 0000000000..4b3367c677 --- /dev/null +++ b/Lang/Zig/Solve-the-no-connection-puzzle @@ -0,0 +1 @@ +../../Task/Solve-the-no-connection-puzzle/Zig \ No newline at end of file diff --git a/Task/100-doors/APL/100-doors-2.apl b/Task/100-doors/APL/100-doors-2.apl index ba6d739dae..bff8982b24 100644 --- a/Task/100-doors/APL/100-doors-2.apl +++ b/Task/100-doors/APL/100-doors-2.apl @@ -1,3 +1 @@ -⍝⍝ Also works with GNU APL after introduction of -⍝⍝ the ⍸ function with SVN r1368, Dec 03 2020 -⍸≠⌿0=(⍳100)∘.|⍳100 +≠⌿0=(⍳100)∘.|⍳100 diff --git a/Task/100-doors/APL/100-doors-3.apl b/Task/100-doors/APL/100-doors-3.apl new file mode 100644 index 0000000000..5fcad5e104 --- /dev/null +++ b/Task/100-doors/APL/100-doors-3.apl @@ -0,0 +1 @@ +⍸≠⌿0=(⍳100)∘.|⍳100 diff --git a/Task/100-doors/Langur/100-doors-1.langur b/Task/100-doors/Langur/100-doors-1.langur index 48e130366a..caac5fccf7 100644 --- a/Task/100-doors/Langur/100-doors-1.langur +++ b/Task/100-doors/Langur/100-doors-1.langur @@ -1,9 +1,9 @@ -var .doors = [false] * 100 +var doors = [false] * 100 -for .i of .doors { - for .j = .i; .j <= len(.doors); .j += .i { - .doors[.j] = not .doors[.j] +for i of doors { + for j = i; j <= len(doors); j += i { + doors[j] = not doors[j] } } -writeln for[=[]] .i of .doors { if(.doors[.i]: _for ~= [.i]) } +writeln for[=[]] i of doors { if doors[i]: _for = more(_for, i) } diff --git a/Task/100-doors/Langur/100-doors-2.langur b/Task/100-doors/Langur/100-doors-2.langur index f120dd60c3..f0f96dadfb 100644 --- a/Task/100-doors/Langur/100-doors-2.langur +++ b/Task/100-doors/Langur/100-doors-2.langur @@ -1 +1 @@ -writeln foldfrom(fn(.a, .b, .c) if(.b: .a~[.c]; .a), [], .doors, series 1..len .doors) +writeln foldfrom(fn a, b, c: if(b: a~[c]; a), [], doors, series(1..len(doors))) diff --git a/Task/100-doors/Langur/100-doors-3.langur b/Task/100-doors/Langur/100-doors-3.langur index d1c575957b..67108b6065 100644 --- a/Task/100-doors/Langur/100-doors-3.langur +++ b/Task/100-doors/Langur/100-doors-3.langur @@ -1 +1 @@ -writeln map fn{^2}, 1..10 +writeln map(fn{^2}, 1..10) diff --git a/Task/100-doors/Oberon/100-doors.oberon b/Task/100-doors/Oberon/100-doors.oberon deleted file mode 100644 index ddec2b2de8..0000000000 --- a/Task/100-doors/Oberon/100-doors.oberon +++ /dev/null @@ -1,27 +0,0 @@ -MODULE Doors; - IMPORT Out; - - PROCEDURE Do*; (* In Oberon an asterisk after an identifier is an export mark *) - CONST N = 100; len = N + 1; - VAR i, j: INTEGER; - closed: ARRAY len OF BOOLEAN; (* Arrays in Oberon always start with index 0; closed[0] is not used *) - BEGIN - FOR i := 1 TO N DO closed[i] := TRUE END; - FOR i := 1 TO N DO - j := 1; - WHILE j < len DO - IF j MOD i = 0 THEN closed[j] := ~closed[j] END; INC(j) (* ~ = NOT *) - END - END; - (* Print a state diagram of all doors *) - FOR i := 1 TO N DO - IF (i - 1) MOD 10 = 0 THEN Out.Ln END; - IF closed[i] THEN Out.String("- ") ELSE Out.String("+ ") END - END; Out.Ln; - (* Print the numbers of the open doors *) - FOR i := 1 TO N DO - IF ~closed[i] THEN Out.Int(i, 0); Out.Char(" ") END - END; Out.Ln - END Do; - -END Doors. diff --git a/Task/100-doors/V-(Vlang)/100-doors-2.v b/Task/100-doors/V-(Vlang)/100-doors-2.v index 6ec392d9a6..35ff929ac5 100644 --- a/Task/100-doors/V-(Vlang)/100-doors-2.v +++ b/Task/100-doors/V-(Vlang)/100-doors-2.v @@ -11,11 +11,10 @@ fn main(){ doors[current - 1] = true increment++ door_nbr += 2 * increment + 1 - } + print('O') + } else { + print('=') + } } - doors.map( fn( it bool) bool { // graphically represent opened doors - print( if it {( 'O')} else {('=')} ) - return it - }) println('') } diff --git a/Task/100-doors/V-(Vlang)/100-doors-3.v b/Task/100-doors/V-(Vlang)/100-doors-3.v new file mode 100644 index 0000000000..bce04b6c59 --- /dev/null +++ b/Task/100-doors/V-(Vlang)/100-doors-3.v @@ -0,0 +1,5 @@ +fn main() { + for i in 1..11 { + print ( " Door ${i*i} is open.\n" ) + } +} diff --git a/Task/100-prisoners/Ecstasy/100-prisoners.ecstasy b/Task/100-prisoners/Ecstasy/100-prisoners.ecstasy new file mode 100644 index 0000000000..9f66539ddd --- /dev/null +++ b/Task/100-prisoners/Ecstasy/100-prisoners.ecstasy @@ -0,0 +1,49 @@ +module OneHundredPrisoners { + @Inject Console console; + + void run() { + console.print($"# of executions: {attempts}"); + console.print($"Optimal play success rate: {simulate(tryOpt)}%"); + console.print($" Random play success rate: {simulate(tryRnd)}%"); + } + + Int attempts = 10000; + + Dec simulate(function Boolean(Int[]) allFoundNumber) { + Int[] drawers = new Int[100](i->i); + Int pardoned = 0; + for (Int i : 1..attempts) { + if (allFoundNumber(drawers.shuffled())) { + ++pardoned; + } + } + return (pardoned * 1000000 / attempts).toDec() / 10000; + } + + Boolean tryRnd(Int[] drawers) { + Inmates: for (Int inmate : 0..<100) { + Int[] choices = drawers.shuffled(); + for (Int attempt : 0..<50) { + if (drawers[choices[attempt]] == inmate) { + continue Inmates; + } + } + return False; + } + return True; + } + + Boolean tryOpt(Int[] drawers) { + Inmates: for (Int inmate : 0..<100) { + Int choice = inmate; + for (Int attempt : 0..<50) { + if (drawers[choice] == inmate) { + continue Inmates; + } + choice = drawers[choice]; + } + return False; + } + return True; + } +} diff --git a/Task/100-prisoners/True-BASIC/100-prisoners.basic b/Task/100-prisoners/True-BASIC/100-prisoners.basic new file mode 100644 index 0000000000..eacc0cac4a --- /dev/null +++ b/Task/100-prisoners/True-BASIC/100-prisoners.basic @@ -0,0 +1,40 @@ +FUNCTION trials(prisoners, iterations, optimal) + DIM drawers(100) + FOR i = 1 TO prisoners + LET drawers(i) = i + NEXT i + FOR i = 1 TO iterations + FOR k = 1 TO prisoners + LET x = RND+1 + LET p = drawers(x) + LET drawers(x) = drawers(k) + LET drawers(k) = p + NEXT k + FOR prisoner = 1 TO prisoners + LET found = false + IF optimal<>0 THEN LET drawer = prisoner ELSE LET drawer = RND+1 + FOR j = 1 TO prisoners/2 + LET drawer = drawers(drawer) + IF drawer = prisoner THEN + LET found = true + EXIT FOR + END IF + IF (NOT optimal<>0) THEN LET drawer = RND+1 + NEXT j + IF (NOT found<>0) THEN EXIT FOR + NEXT prisoner + LET pardoned = pardoned+found + NEXT i + LET trials = (100*pardoned/iterations) +END FUNCTION + +LET false = 0 +LET true = 1 +LET iterations = 10000 +PRINT "Simulation count: "; iterations +FOR prisoners = 10 TO 100 STEP 90 + LET randon = trials(prisoners,iterations,false) + LET optimal = trials(prisoners,iterations,true) + PRINT "Prisoners: "; prisoners; ", random: "; randon; ", optimal: "; optimal +NEXT prisoners +END diff --git a/Task/15-puzzle-game/PascalABC.NET/15-puzzle-game.pas b/Task/15-puzzle-game/PascalABC.NET/15-puzzle-game.pas new file mode 100644 index 0000000000..2d5275fb8f --- /dev/null +++ b/Task/15-puzzle-game/PascalABC.NET/15-puzzle-game.pas @@ -0,0 +1,178 @@ +// Игра в 15 PABCWork.NET\Samples\Games\15.pas +uses GraphABC,ABCObjects,ABCButtons; + +const +/// размер поля + n = 4; +/// размер фишки + sz = 100; +/// зазор между фишками + zz = 10; +/// отступ от левого и правого краев + x0 = 20; +/// отступ от верхнего и нижнего краев + y0 = 20; + +var + p: array [1..n,1..n] of SquareABC; + digits: array [1..n*n-1] of integer; + + MeshButton: ButtonABC; + StatusRect: RectangleABC; + + EmptyCellX,EmptyCellY: integer; + MovesCount: integer; + EndOfGame: boolean; // True если все фишки стоят на своих местах + +// Поменять местами две фишки +procedure Swap(var p,p1: SquareABC); +begin + PABCSystem.Swap(p,p1); + var i := p.Left; + p.Left := p1.Left; + p1.Left := i; + i := p.Top; + p.Top := p1.Top; + p1.Top := i; +end; + +// Определить, являются ли клетки соседями +function Neighbours(x1,y1,x2,y2: integer): boolean; +begin + Result := (Abs(x1-x2)=1) and (y1=y2) or (Abs(y1-y2)=1) and (x1=x2) +end; + +// Заполнить вспомогательный массив цифр +procedure FillDigitsArr; +begin + for var i:=1 to n*n-1 do + digits[i] := i; +end; + +// Перемешать вспомогательный массив цифр. Количество обменов должно быть четным +procedure MixDigitsArr; +var x: integer; +begin + for var i:=1 to n*n-1 do + begin + repeat + x := Random(15)+1; + until x<>i; + Swap(digits[i],digits[x]); + end; + if n mod 2=0 then + Swap(digits[1],digits[2]); // количество обменов должно быть четным +end; + +// Заполнить двумерный массив фишек. Вместо пустой ячейки - белая фишка с числом 0 +procedure Fill15ByDigitsArr; +begin + Swap(p[EmptyCellY,EmptyCellX],p[n,n]); // Переместить пустую фишку в правый нижний угол + EmptyCellX := n; + EmptyCellY := n; + var i := 1; + for var y:=1 to n do + for var x:=1 to n do + begin + if x*y=n*n then exit; + p[y,x].Number := digits[i]; + i += 1; + end; +end; + +// Перемешать массив фишек +procedure Mix15; +begin + MixDigitsArr; + Fill15ByDigitsArr; + MovesCount := 0; + EndOfGame := False; + StatusRect.Text := 'Количество ходов: '+IntToStr(MovesCount); + StatusRect.Color := RGB(200,200,255); +end; + +// Создать массив фишек +procedure Create15; +begin + EmptyCellX := n; + EmptyCellY := n; + for var x:=1 to n do + for var y:=1 to n do + begin + p[y,x] := new SquareABC(x0+(x-1)*(sz+zz),y0+(y-1)*(sz+zz),sz,clMoneyGreen); + p[y,x].BorderColor := clGreen; + p[y,x].BorderWidth := 2; + p[y,x].TextScale := 0.7; + end; + p[EmptyCellY,EmptyCellX].Color := clWhite; + p[EmptyCellY,EmptyCellX].BorderColor := clWhite; + FillDigitsArr; + MixDigitsArr; + Fill15ByDigitsArr; +end; + +// Проверить, все ли фишки стоят на своих местах +function IsSolution: boolean; +begin + Result:=True; + var i:=1; + for var y:=1 to n do + for var x:=1 to n do + begin + if p[y,x].Number<>i then + begin + Result:=False; + break; + end; + i += 1; + if i=n*n then i:=0; + end; +end; + +procedure MouseDown(x,y,mb: integer); +begin + if EndOfGame then // Если все фишки на своих местах, то не реагировать на мышь и ждать нажатия кнопки "Перемешать" + exit; + if ObjectUnderPoint(x,y)=nil then // Eсли мы щелкнули не на объекте, то не реагировать на мышь + exit; + var fx := (x-x0) div (sz+zz) + 1; // Вычислить координаты на доске для ячейки, на которой мы щелкнули мышью + var fy := (y-y0) div (sz+zz) + 1; + if (fx>n) or (fy>n) then + exit; + if Neighbours(fx,fy,EmptyCellX,EmptyCellY) then // Если ячейка соседствует с пустой, то поменять их местами + begin + Swap(p[EmptyCellY,EmptyCellX],p[fy,fx]); + EmptyCellX := fx; + EmptyCellY := fy; + Inc(MovesCount); + StatusRect.Text := 'Количество ходов: ' + MovesCount; + if IsSolution then + begin + StatusRect.Text := 'Победа! Сделано ходов: ' + MovesCount; + StatusRect.Color := RGB(255,200,200); + EndOfGame := True; + end + end; +end; + +begin + SetSmoothingOff; + Window.Title := 'Игра в 15'; + Window.IsFixedSize := True; + SetWindowSize(2*x0+(sz+zz)*n-zz,2*y0+(sz+zz)*n-zz+90); + + EndOfGame := False; + Create15; + + MeshButton := ButtonABC.Create((WindowWidth-200) div 2,2*y0+(sz+zz)*n-zz,200,'Перемешать',clLightGray); + MeshButton.OnClick := Mix15; + StatusRect := new RectangleABC(0,WindowHeight-40,WindowWidth,40,RGB(200,200,255)); + StatusRect.TextVisible := True; + StatusRect.Text := 'Количество ходов: '+IntToStr(MovesCount); + StatusRect.BorderWidth := 2; + StatusRect.BorderColor := RGB(80,80,255); + + MovesCount := 0; + + OnMouseDown := MouseDown; +end. diff --git a/Task/15-puzzle-game/Zig/15-puzzle-game.zig b/Task/15-puzzle-game/Zig/15-puzzle-game.zig new file mode 100644 index 0000000000..11d3ca114f --- /dev/null +++ b/Task/15-puzzle-game/Zig/15-puzzle-game.zig @@ -0,0 +1,91 @@ +const std = @import("std"); +const stdout = std.io.getStdOut().writer(); + +const tokens = [16][]const u8{ " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "13", "14", "15", " " }; + +const empty_token = 15; +var empty: u8 = empty_token; +var cells: [16]u8 = undefined; +var invalid: bool = false; + +const Move = enum { no, up, down, left, right }; + +fn showBoard() !void { + try stdout.writeAll("\n"); + + var solved = true; + var i: u8 = 0; + while (i < 16) : (i += 1) { + try stdout.print(" {s} ", .{tokens[cells[i]]}); + if ((i + 1) % 4 == 0) try stdout.writeAll("\n"); + if (i != cells[i]) solved = false; + } + + try stdout.writeAll("\n"); + + if (solved) { + try stdout.writeAll("\n\n** You did it! **\n\n"); + std.posix.exit(0); + } +} + +fn updateToken(move: Move) !void { + const newEmpty = switch (move) { + Move.up => if (empty / 4 < 3) empty + 4 else empty, + Move.down => if (empty / 4 > 0) empty - 4 else empty, + Move.left => if (empty % 4 < 3) empty + 1 else empty, + Move.right => if (empty % 4 > 0) empty - 1 else empty, + else => empty, + }; + + if (empty == newEmpty) { + invalid = true; + } else { + invalid = false; + cells[empty] = cells[newEmpty]; + cells[newEmpty] = empty_token; + empty = newEmpty; + } +} + +fn waitForMove() !Move { + const reader = std.io.getStdIn().reader(); + if (invalid) try stdout.writeAll("(invalid) "); + try stdout.writeAll("enter u/d/l/r or q: "); + const input = try reader.readBytesNoEof(2); + switch (std.ascii.toLower(input[0])) { + 'q' => std.posix.exit(0), + 'u' => return Move.up, + 'd' => return Move.down, + 'l' => return Move.left, + 'r' => return Move.right, + else => return Move.no, + } +} + +fn shuffle(moves: u8) !void { + var random = std.rand.DefaultPrng.init(@intCast(std.time.microTimestamp())); + const rand = random.random(); + var n: u8 = 0; + while (n < moves) { + const move: Move = rand.enumValue(Move); + try updateToken(move); + if (!invalid) n += 1; + } + invalid = false; +} + +pub fn main() !void { + var n: u8 = 0; + while (n < 16) : (n += 1) { + cells[n] = n; + } + + try shuffle(50); + try showBoard(); + + while (true) { + try updateToken(try waitForMove()); + try showBoard(); + } +} diff --git a/Task/15-puzzle-solver/Dart/15-puzzle-solver.dart b/Task/15-puzzle-solver/Dart/15-puzzle-solver.dart new file mode 100644 index 0000000000..27546c8101 --- /dev/null +++ b/Task/15-puzzle-solver/Dart/15-puzzle-solver.dart @@ -0,0 +1,78 @@ +import 'package:collection/collection.dart'; + +typedef OffsetFunction = int Function(int a, int b); +Function eq = const ListEquality().equals; + +/// Solve Random 15 Puzzles +class FifteenSolver { + static const target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]; + static const trN = [3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3]; + static const tcN = [3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2]; + var pos0 = List.filled(100, 0); + var moves = List.filled(100, 0); + var dirs = List.filled(100, ''); + int step = 0, best = 0; + var board = List.generate(100, (int i) => List.filled(16, 0)); + + bool isFinished() { + if (moves[step] < best) return nextMove(); + if (eq(board[step], target)) { + print("Solution found in $step moves :${dirs.join('')}"); + return true; + } + return (moves[step] == best) ? nextMove() : false; + } + + var passNumber = 0; + + /// Try all valid moves from here, but don't retrace your steps. + /// Return true if a solution is found. + bool nextMove() { + // if (passNumber++ ~/ 100000 == 0) print("${dirs.join('')}"); + return (dirs[step] != 'u' && pos0[step] ~/ 4 < 3 && down()) || + (dirs[step] != 'd' && pos0[step] ~/ 4 > 0 && up()) || + (dirs[step] != 'l' && pos0[step] % 4 < 3 && right()) || + (dirs[step] != 'r' && pos0[step] % 4 > 0 && left()) || + false; + } + + bool move(int offset, String dir, List rcArray, OffsetFunction rcFunc) { + final int ix = pos0[step] + offset; + final n = board[step][ix]; + pos0[step + 1] = pos0[step] + offset; + board[step + 1] = board[step].toList() + ..[pos0[step]] = n + ..[ix] = 0; + dirs[step + 1] = dir; + moves[step + 1] = moves[step] + rcFunc(rcArray[n], pos0[step]); + step++; + if (isFinished()) return true; + step--; + return false; + } + + bool right() => move(1, 'r', tcN, (a, b) => (a <= b % 4 ? 0 : 1)); + bool left() => move(-1, 'l', tcN, (a, b) => (a >= b % 4 ? 0 : 1)); + bool down() => move(4, 'd', trN, (a, b) => (a <= b ~/ 4 ? 0 : 1)); + bool up() => move(-4, 'u', trN, (a, b) => (a >= b ~/ 4 ? 0 : 1)); + + void solve(List initBoard) { + pos0[0] = initBoard.indexOf(0); + board[0] = initBoard; + while (!isFinished()) best++; + } +} + +void main(List args) { + print("running"); + // test values + // final start = [5, 1, 2, 3, 6, 10, 7, 4, 13, 9, 11, 8, 14, 0, 15, 12]; + // final start = [9, 1, 2, 4, 13, 6, 5, 7, 3, 11, 14, 15, 10, 0, 8, 12]; + // final start = [10, 3, 1, 4, 13, 5, 8, 7, 9, 6, 0, 11, 14, 15, 12, 2]; + // required solution + final start = [15, 14, 1, 6, 9, 11, 4, 12, 0, 10, 7, 3, 13, 8, 5, 2]; + // Extra credit + // final start = [0, 12, 9, 13, 15, 11, 10, 14, 3, 7, 2, 5, 4, 8, 6, 1]; + print(start); + FifteenSolver().solve(start); +} diff --git a/Task/15-puzzle-solver/Uiua/15-puzzle-solver.uiua b/Task/15-puzzle-solver/Uiua/15-puzzle-solver.uiua new file mode 100644 index 0000000000..b557fe56b6 --- /dev/null +++ b/Task/15-puzzle-solver/Uiua/15-puzzle-solver.uiua @@ -0,0 +1,47 @@ +# Solve a 15 puzzle https://rosettacode.org/wiki/15_puzzle_solver#Uiua +# Experimental! +T ← ↯4_4 ↻1⇡16 +# Return shuffled copy of the input. +Shuffle ← ⊏⊸(⍏[⍥⚂]⧻) +# Positions of the numbers (not 0) +Pos ← ≡(⊢⊚⌕)↘1⇡16¤ + +# Applying a very gentle weighting to certain cells massively +# speeds up the algorithm +Weights ← [[2 1 1 2] [2 1 1 2] [2 1 1 2] [2 1 1 1]] +Distance ← /+×⊡:Weights:≡/+⌵-⊙.∩Pos +Heuristic ← Distance T + +# Four possible neighbours +Nfour ← [[1 0] [¯1 0] [0 1] [0 ¯1]] +# Actual neighbours at a point. +ValidN ← ≡(⊂)⊙¤:⟜(▽⊸(≥0≡/↧)▽⊸(<4≡/↥)+Nfour)¤ +# Precalculate them. +ValidNs ← ⊞(□ ValidN⊟)⇡4 ⇡4 + +# Get the valid (from to) moves from this cell. +Moves ← °□⊡:ValidNs⊢⊚⌕0 +# Swap the values at the indexes [0 1] [a b 2 3] -> [b a 2 3] +Swap ← ⍜(⊡|∘◌) ⊃(⇌⊙∘|⊡) +# List the possible next positions for a position +Next ← ⊙◌≡(Swap ⊙.)⊙¤⊸Moves +Solve ← ( + &p"Running..."&p. + ⍜nowastar(Next|Heuristic|≍T) + &p$"_ seconds" + # Track the movement of the 0 between adjacent steps. + ≡(/-)◫2◇≡(⊢⊚⌕0)⇌⊢ + # Map each to a direction string and join. + /⊂⇌≡⍣("d" °¯1_0|"u" °1_0|"r" °0_¯1|"l" °0_1|∘) +) + +# Uncomment one of the following lines to try random grids +# ⍥(Swap⊡⊸(⌊×⚂⧻)⊸Moves)90 T +# [[2 14 6 4] [5 1 3 8] [9 10 7 11] [13 0 15 12]] # Simple 40 shuffles +# [[5 1 2 3] [6 10 7 4] [13 9 11 8] [14 0 15 12]] # Simple 12 steps +# [[9 1 2 4] [13 6 5 7] [3 11 14 15] [10 0 8 12]] # 34 steps +# [[10 3 1 4] [13 5 8 7] [9 6 0 11] [14 15 12 2]] # 38 steps (a few seconds) +[[15 14 1 6] [9 11 4 12] [0 10 7 3] [13 8 5 2]] # Main Challenge +# [[0 12 9 13] [15 11 10 14] [3 7 2 5] [4 8 6 1]] # Extra Credit + +Solve diff --git a/Task/2048/Jq/2048.jq b/Task/2048/Jq/2048.jq new file mode 100644 index 0000000000..367500faf2 --- /dev/null +++ b/Task/2048/Jq/2048.jq @@ -0,0 +1,127 @@ +include "MRG32k3a" {search: "."}; # see comment above + +### Generic functions + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +# Create an m x n matrix with initial values specified by . +def matrix($m; $n): + if $m == 0 then [] + else . as $init + | if $m == 1 then [range(0;$n) | $init] + elif $m > 0 then + matrix(1; $n) as $row + | [range(0; $m) | $row ] + else error("matrix\($m);\($n)) invalid") + end + end; + + +### The 2048 Game +# Left-squish the input array in accordance with the game requirements for a single row +def squish: + def squish($n): + def s: + if length == 0 then [range(0;$n)|null] + elif .[0] == null then .[1:] | s + elif length == 1 then . + [range(0; $n - 1)|null] + elif .[0] == .[1] then [.[0] + .[1]] + (.[2:]|squish($n-1)) + else .[0:1] + (.[1:]|squish($n-1)) + end; + s; + squish(length); + +# Input: a matrix of rows +def squish_left: + [.[] | squish]; + +def squish_right: + [.[] | reverse | squish | reverse]; + +def squish_up: + transpose + | [.[] | squish] + | transpose; + +def squish_down: + transpose + | [.[] | reverse | squish | reverse] + | transpose; + +# Gather the [i,j] co-ordinates of all the null values in the input matrix +def gather: + if length == 0 then error end + | (.[0] | length) as $cols + | [range(0;length) as $i + | range(0; $cols) as $j + | select(.[$i][$j] == null) | [$i,$j]] + | if length == 0 then error end ; + +# Input: {matrix} +# Add a random 2 or 4 if possible, else error +# Output: includes .prng for the PRN generator +def add_random: + (.matrix | gather) as $gather + | ($gather | length) as $n + | if $n == 0 then error end + | if .prng == null then .prng = seed(now | tostring | sub("^.*[.]";"") | tonumber) end + | .prng |= nextFloat + | $gather[.prng.nextFloat * $n | trunc] as [$i,$j] + | .prng |= nextFloat + | (if (.prng.nextFloat) < 0.1 then 4 else 2 end) as $exmachina + | .matrix[$i][$j] = $exmachina ; + +def prompt: "[ijkl] or [wasd] or q to quit or n to restart:"; + +def direction: + {"i": "up", "j": "left", "k": "down", "l": "right", + "w": "up", "a": "left", "s": "down", "d": "right", + "q": "quit", + "n": "restart" + }; + +# Recognize $goal as the goal +def play($goal): + + # Pretty print + def pp: + .matrix[] | map(. // "." | lpad(4)) | join(" "); + + def won: + any(.matrix[][]; . == $goal); + + def lost: + .matrix + | (squish_left == .) and (squish_right == .) and + (squish_up == .) and (squish_down == .); + + def round: + pp, + if lost then "Sorry! Better luck next time.", play($goal) + else prompt, + ( (try input catch halt) as $in + | .matrix as $matrix # for checking if a move is legal + | .emit = null + | direction[$in | ascii_downcase] as $direction + | if $direction == "up" then .matrix |= squish_up + elif $direction == "down" then .matrix |= squish_down + elif $direction == "left" then .matrix |= squish_left + elif $direction == "right" then .matrix |= squish_right + elif $direction == "quit" then .emit = "bye" + elif $direction == "restart" then .emit = "restart" + else .emit = "unknown direction \($direction) ... please try again." + end + | if .emit == "bye" then .emit, halt + elif .emit == "restart" then "Restarting...", play($goal) + elif .emit != null then .emit, round + elif .matrix == $matrix then "Disallowed direction! Please try again.", round + elif won then pp, "Congratulations!", play($goal) + else add_random | round + end) + end; + + { matrix: (null | matrix(4;4))} + | .matrix[2] = [null,2,2,2] + | round; + +play(2048) diff --git a/Task/2048/Wren/2048.wren b/Task/2048/Wren/2048.wren index ddff0c113d..b92bc4948d 100644 --- a/Task/2048/Wren/2048.wren +++ b/Task/2048/Wren/2048.wren @@ -20,13 +20,6 @@ class G2048 { for (j in 0..3) _board[i][j] = Tile.new(0, false) } _rand = Random.new() - initializeBoard() - } - - initializeBoard() { - for (y in 0..3) { - for (x in 0..3) _board[x][y] = Tile.new(0, false) - } } loop() { diff --git a/Task/24-game/Frink/24-game.frink b/Task/24-game/Frink/24-game.frink new file mode 100644 index 0000000000..a7a123bc86 --- /dev/null +++ b/Task/24-game/Frink/24-game.frink @@ -0,0 +1,15 @@ +ops = ["+", "-", "*", "/"] + +chosen = new array[[4], {|x| random[1,9]}] +println[chosen] + +for d = chosen.lexicographicPermute[] + multifor o = [ops, ops, ops] + { + str = "((" + d@0 + o@0 + d@1 + ")" + o@1 + d@2 + ")" + o@2 + d@3 + if eval[str] == 24 + println[str] + str = "(" + d@0 + o@0 + d@1 + ")" + o@1 + "(" + d@2 + + o@2 + d@3 + ")" + if eval[str] == 24 + println[str] + } diff --git a/Task/24-game/FutureBasic/24-game.basic b/Task/24-game/FutureBasic/24-game.basic new file mode 100644 index 0000000000..68da1c6faa --- /dev/null +++ b/Task/24-game/FutureBasic/24-game.basic @@ -0,0 +1,310 @@ +include resources "24 Game Icon.icns" + +#build CompilerOptions @"-Wno-unused-variable" + +_mEdit = 2 +editmenu _mEdit + +begin globals +long gPosition +end globals + +void local fn EraseErrorText + + CGRect r + r = fn CGRectMake(10, 200, 400, 15) + rect fill r,fn ColorBlack + +end fn + +local fn ArcRandom( a as long, b as long ) as long + long i + cln i = (arc4random()%(b-a+1))+a; +end fn = fn floor(i) + +local fn GetRandomNumbers as CFStringRef + + // 96 number groups + + CFArrayRef combos = @[¬ + + // The first 32 are easy + @"1 2 3 4", @"2 4 6 8", @"1 2 4 8", @"1 3 4 6", @"1 2 6 8", + @"2 3 4 8", @"1 3 6 9", @"1 2 7 8", @"2 3 6 8", @"1 4 6 8", + @"2 2 3 9", @"3 4 6 6", @"2 3 3 8", @"1 5 6 6", @"2 4 4 6", + @"1 3 8 8", @"2 2 6 9", @"3 3 6 9", @"1 2 5 9", @"2 4 5 5", + @"1 3 5 9", @"2 2 4 9", @"1 2 3 6", @"1 2 2 9", @"1 2 3 9", + @"1 2 4 6", @"1 2 4 4", @"1 2 2 6", @"1 3 3 6", @"1 1 4 6", + @"1 1 2 8", @"1 1 3 8", + // The middle 32 are medium + @"1 5 5 9", @"4 4 6 9", @"2 3 7 9",@"3 5 8 8", @"1 6 6 8", + @"3 3 5 6", @"1 4 5 8", @"3 3 6 7",@"2 5 5 8", @"4 4 7 9", + @"1 5 6 9", @"3 3 8 9", @"2 6 6 7",@"4 5 7 8", @"2 2 5 9", + @"2 4 6 7", @"1 5 6 8", @"3 4 7 7",@"2 5 6 6", @"3 4 5 9", + @"1 6 7 9", @"2 3 7 8", @"1 4 6 9",@"2 3 5 9", @"3 4 4 8", + @"2 5 8 9", @"1 4 8 9", @"3 3 4 9",@"2 6 7 9", @"1 3 5 7", + @"1 3 6 6", @"2 2 5 7", + // The last 32 are hard + @"1 5 7 9",@"3 4 7 9", @"2 5 7 8", @"3 4 8 9", @"3 4 5 8", + @"2 6 6 9",@"4 4 5 7", @"2 4 6 9", @"1 4 7 7", @"2 3 8 9", + @"2 3 4 7",@"3 3 4 8", @"1 3 7 9", @"2 4 5 9", @"1 3 6 8", + @"2 4 4 9",@"1 5 8 9", @"3 3 5 9", @"2 6 8 9", @"1 4 4 7", + @"2 3 6 7",@"1 3 5 8", @"2 4 7 8", @"1 3 4 7", @"2 3 5 6", + @"1 4 5 6",@"3 3 5 7", @"2 2 3 6", @"3 3 7 7", @"3 3 7 9", + @"4 4 8 9",@"2 4 8 9"] + + long i = fn ArcRandom( 0, len(combos) - 1 ) + gPosition = i + +end fn = combos[i] + + +local fn EvaluateMath( equation as CFStringRef ) as CFStringRef + equation = fn StringByReplacingOccurrencesOfString( lcase(equation), @"x", @"*" ) + + CFStringRef result = NULL + RegularExpressionRef regex = fn RegularExpressionWithPattern( @"[0-9.]+", NSRegularExpressionCaseInsensitive, NULL ) + CFArrayRef matches = fn RegularExpressionMatches( regex, equation, 0, fn CFRangeMake( 0, len(equation) ) ) + NSInteger intConversions = 0 + TextCheckingResultRef match + CFRange originalRange + CFRange adjustedRange + CFStringRef value + + for match in matches + originalRange = fn TextCheckingResultRange( match ) + adjustedRange = fn CFRangeMake( ( originalRange.location + ( intConversions * len( @".0") ) ), originalRange.length ) + value = fn StringSubstringWithRange( equation, adjustedRange ) + if fn StringContainsString( value, @"." ) + continue + else + equation = fn StringByReplacingCharactersInRange( equation, adjustedRange, fn StringWithFormat( @"%@.0", value ) ) + intConversions++ + end if + next + ExceptionRef e + try + ExpressionRef expression = fn ExpressionWithFormat( equation ) + CFNumberRef number = fn ExpressionValueWithObject( expression, NULL, NULL ) + result = fn StringWithFormat( @"%.3f", dblval( number ) ) + end try + + catch (e) + result = fn StringWithFormat( @"%@", e ) : exit fn + end catch + // Test if result is an integer and, if so, return result as an integer + if( fn StringDoubleValue( result ) == fn floorf( fn StringDoubleValue( result ) ) ) + result = fn ArrayFirstObject( fn StringComponentsSeparatedByString( result, @"." ) ) + end if +end fn = result + + +local fn QuitOrPlayAlert(GameResult as CFStringRef) + alert -2,,GameResult,@"You won!",@"Quit;Play Again" + AlertButtonSetKeyEquivalent( 2, 2, @"\e" ) + short result + result = alert 2 + if ( result != NSAlertSecondButtonReturn ) then appterminate +end fn + + +local fn BuildWindow + CGRect r = fn CGRectMake( 0, 0, 580, 250) + window 1, @"24 Game", r + windowcenter(1) + WindowSetBackgroundColor(1,fn ColorBlack) + +end fn + +///////// Start ////////// + +fn BuildWindow + + +short d(4), i +CFStringRef CheckForDuplicates(97) +for i = 1 to 96 + CheckForDuplicates(i) = @"" +next i + +short DuplicatesCounter +DuplicatesCounter = 0 + + +"Main" + +cls +text ,,fn colorWhite + +print +print %(10,15),"Given four numbers and using just the +, -, *, and / operators; and the" +print %(10,30),"possible use of parenthesis (), enter an expression that equates to 24." +print %(10,45),"You must use all your numbers and only those numbers." +print %(10,60),"Examples: 9618 Solution 9 + 6 + 1 + 8 or 3173 Solution (3 * 7) - (1 - 4)" +print +print %(10,85),"Enter Q to quit or S to skip to the next number." + +"GetFourNumbers" + +CFArrayRef randomNumbers : randomNumbers= fn StringComponentsSeparatedByString( fn GetRandomNumbers, @" " ) +CFStringRef RandomNumberblock : RandomNumberblock = @"" +CFStringRef RandomNumberblockAdd : RandomNumberblockAdd = @"" + +for i = 0 to 3 + // create a string from the 4 numbers + RandomNumberblockAdd = randomNumbers[i] + RandomNumberblock = fn StringByAppendingString(RandomNumberblock,RandomNumberblockAdd) + RandomNumberblock = fn StringByAppendingString(RandomNumberblock,@" ") +next i + + +if DuplicatesCounter = > 96 + // reset counter when last number is retrieved and start from the first number block + DuplicatesCounter = 0 + for i = 1 to 96 + CheckForDuplicates(i) = @"" + next i +end if + +for i = 1 to 96 + // check the current numbers with the numbers already used + if fn StringIsEqual(RandomNumberblock,CheckForDuplicates(i)) + RandomNumberblock = fn StringWithString(CheckForDuplicates(DuplicatesCounter)) + goto "GetFourNumbers" + end if +next i + +DuplicatesCounter ++ +CheckForDuplicates(DuplicatesCounter) = fn StringWithString(RandomNumberblock) + +d(1) = fn StringIntegerValue( randomNumbers[0] ) +d(2) = fn StringIntegerValue( randomNumbers[1] ) +d(3) = fn StringIntegerValue( randomNumbers[2] ) +d(4) = fn StringIntegerValue( randomNumbers[3] ) + +short dots = 0 + +//d(1) = 9:d(2) = 6:d(3) = 1:d(4) = 8 // Uncomment to test with 9618 numbers. Solution 9 + 6 + 1 + 8 +//d(1) = 6:d(2) = 5:d(3) = 3:d(4) = 8 // Uncomment to test with 6538 numbers. Solution 6 / ( 5 - 3 ) * 8 +//d(1) = 3:d(2) = 1:d(3) = 7:d(4) = 3 // Uncomment to test with 3773 numbers. Solution ((3 * 1) * 7) + 3 +//d(1) = 4:d(2) = 2:d(3) = 7:d(4) = 1 // Uncomment to test with 4271 numbers. Solution (4 * ( 7 - 2 + 1 ) +// NOTE: When using these test numbers, also uncomment dots = 0 below here to prevent misleading dot displays + + +if gPosition <= 32 then dots = 1 +if gPosition > 32 and gPosition < 65 then dots = 2 +if gPosition > 64 then dots = 3 + +//dots = 0 uncomment when testing the numbers above to prevent misleading dot displays + +print +text ,,fn colorGreen +print %(15,110),"These are your numbers, difficulty level "; +// @"\U000026AA" is white unicode dot - Easy difficulty (One-Dot) +// @"\U0001F534" is red unicode dot - Medium difficulty (Two-Dots) +// @"\U0001F7E1" is yellow unicode dot - Hard difficulty (Three-Dots) + +if dots = 1 then print @"\U000026AA Easy" +if dots = 2 then print @"\U0001F534 \U0001F534 Medium" +if dots = 3 then print @"\U0001F7E1 \U0001F7E1 \U0001F7E1 Hard" + +print %(55,125) +text ,18,fn colorGreen +for i = 1 to 4 + print d(i); " "; +next + +print + +text ,12,fn colorWhite +printf @"\n\n\n" + +CFStringRef expr +bool TryAgain : TryAgain = _false +CFStringRef MessageText +CFStringRef UserInput = NULL + +"InputExpression" + +if TryAgain + MessageText = fn StringWithFormat( @"Enter math expression: [ '%@' was incorrect ]", expr ) + UserInput = input %(10, 190), MessageText, @"123456789+-*/()qs", YES,, 0 +else + UserInput = input %(10, 190), @"Enter math expression:", @"123456789+-*/()qs", YES,, 0 +end if + +if ( UserInput == NULL ) then "InputExpression" +expr = UserInput +if expr = @"" then "InputExpression" +if fn StringIsEqual(ucase(expr) , @"Q") then appterminate +if fn StringIsEqual(ucase(expr) , @"S") then "Main" + + +//check expr for validity + +short j +bool GotAllNumbers : GotAllNumbers = _false +short ThisNumberPosition : ThisNumberPosition = 0 +short GotaNumber : GotaNumber = 0 +short TotalNumbers : TotalNumbers = 0 + +short ExtraNumbers:ExtraNumbers = 0 + +for i = 1 to len$(fn stringpascalstring(expr)) + if asc(mid$(fn stringpascalstring(expr),i,1)) > 48 && asc(mid$(fn stringpascalstring(expr),i,1)) < 58 + ExtraNumbers ++ + end if +next i + +if ExtraNumbers > 4 + fn EraseErrorText + text ,,fn colorRed + TryAgain = _true + print %(10,200);"Error! Extra numbers not allowed": goto "InputExpression" + text ,,fn colorWhite +end if + + +for i = 1 to 4 + GotaNumber = 0 + for j = 0 to len(expr) -1 + ThisNumberPosition = instr( j, expr, right(str( d(i)),1 )) + ThisNumberPosition ++ + if ThisNumberPosition then GotaNumber = _true + next j + if GotaNumber then TotalNumbers ++ +next i + +if TotalNumbers => 4 then GotAllNumbers = _true + +if GotAllNumbers = _false + fn EraseErrorText + text ,,fn colorRed + TryAgain = _true + print %(10,200);"ERROR! Must use all your numbers and only those numbers." : goto "InputExpression" + text ,,fn colorWhite +end if + +fn EraseErrorText + + +if fn EvaluateMath( expr ) = _false + text ,,fn colorRed + TryAgain = _true + Print %(10,200);"Error! Incorrect math sequence." + goto "InputExpression" + text ,,fn colorWhite +end if + +CFStringRef GameResult +if fn StringIntegerValue( fn EvaluateMath( expr ) ) == 24 then GameResult = @"Correct" else GameResult = @"Incorrect" + +if GameResult = @"Incorrect" + TryAgain = _true + goto "InputExpression" +end if + +fn QuitOrPlayAlert(GameResult) +goto "Main" + +handleevents diff --git a/Task/24-game/Jq/24-game.jq b/Task/24-game/Jq/24-game.jq new file mode 100644 index 0000000000..09ce6dfc30 --- /dev/null +++ b/Task/24-game/Jq/24-game.jq @@ -0,0 +1,90 @@ +### The MRG32k3a combined recursive PRNG - see above +import "MRG32k3a" as MRG {search: "."}; + +### Generic utilities +def sum(stream): reduce stream as $x (0; .+$x); + +# like while/2 but emit the final term rather than the first one +def whilst(cond; update): + def _whilst: + if cond then update | (., _whilst) else empty end; + _whilst; + +### Reverse Polish Notation +# An array of the allowed operators +def operators: "+-*/" | split(""); + +# If $a and $b are numbers and $c an operator, then "$a $b $c" is evaluated as an RPN expression. +# Output: {emit, result} with .emit == null if there is a valid result. +def applyOperator($a; $b; $c): + if ([$a,$b] | map(type) | unique) == ["number"] + then + if $c == "+" then {result: ($a + $b)} + elif $c == "-" then {result: ($a - $b)} + elif $c == "*" then {result: ($a * $b)} + elif ($c == "/") then {result: ($b / $a)} + else {emit: "unrecognized operator: \($c)"} + end + else {emit: "invalid number"} + end; + +# Input: an array representing an RPN expression. +# Output: {emit, result} as per applyOperator/3 +# Example: [1,2,3,"+","+"] | evaluate #=> 6 +def evaluate: + if length == 1 + then if .[0]|type == "number" then {result: .[0]} + else {emit: "invalid RPN expression"} + end + elif length < 3 then {emit: "invalid RPN expression: \(. | join(" "))"} + else . as $in + | (first( range(0; length) as $i | select(any( operators[]; . == $in[$i]) ) | $i) // null) as $ix + | if $ix == null then {emit: "invalid RPN expression"} + else applyOperator(.[$ix-2]; .[$ix-1]; .[$ix]) as $result + | if $result.result then .[:$ix-2] + [$result.result] + .[$ix+1:] | evaluate + else $result + end + end + end; + +### The "24 Game" + +# . is the putative RPN string to be checked. +# $four is the string of the four expected digits, in order. +# Output: {emit, result} with .emit set to "Correct!" if .result == 24 +def check($four): + if (gsub("[^1-9]";"") | explode | sort | implode) != $four + then {emit: "You must use each of the four digits \($four | split("") | join(" ")) exactly once:"} + else . as $in + | {s: [], emit: null} + | [$in | split("")[] | select(. != " ") + | . as $in | explode[0] | if . >= 48 and . <= 57 then . - 48 else $in end] + | evaluate + | if .result + then if .result|round == 24 then .emit = "Correct!" + else .emit = "Value \(.result) is not 24." + end + else .emit += "\nTry again, or enter . to start again, or q to quit." + end + end ; + +def run: + # Populate .digits with four non-negative digits selected at random, with replacement: + {digits: (9 | MRG::prn(4) | map(. + 1))} + | (.digits | sort | join("")) as $four + | "At the prompt, enter an RPN string (e.g. 64*1+1-), or . for a new set of four digits, or q to quit.", + "Make 24 using these digits, once each, in any order: \(.digits):", + ( whilst( .stop | not; + .emit = null + | . as $state + | try input catch halt + | if IN( "q", "quit") then halt + elif . == "." then $state | .stop = true + else check($four) + | if .result then .stop = true end + end ) + | select(.emit).emit ), + # rerun + run; + +run diff --git a/Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle.v b/Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-1.v similarity index 100% rename from Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle.v rename to Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-1.v diff --git a/Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-2.v b/Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-2.v new file mode 100644 index 0000000000..f44447a8e6 --- /dev/null +++ b/Task/4-rings-or-4-squares-puzzle/V-(Vlang)/4-rings-or-4-squares-puzzle-2.v @@ -0,0 +1,38 @@ +import math.bits + +fn main ( ) { + mut n := 0 + mut t := []u8{len:7} + + n = solve ( 0, mut t, 1, 7, true ) + println ( "$n unique solutions in 1 to 7" ) + n = solve ( 0, mut t, 3, 9, true ) + println("$n unique solutions in 3 to 9") + n = solve ( 0, mut t, 0, 9, false ) + println("$n non-unique solutions in 0 to 9") +} + +fn solve ( lvl u8, mut t []u8, low u8, high u8,unique bool ) int { + if lvl==7 { + return int(suma(t) && (!unique || isunique( t ))) + } + mut cnt:=0 + for v := low; v <= high; v++ { + t[lvl] = v + cnt += solve ( lvl + 1, mut t, low, high, unique ) + } + return cnt +} + +@[inline] +fn isunique ( t []u8 ) bool { + return bits.ones_count_32(u32(1)<4} {d}\n", .{ num, r.getLast() }); + } +} diff --git a/Task/9-billion-names-of-God-the-integer/Zig/9-billion-names-of-god-the-integer-2.zig b/Task/9-billion-names-of-God-the-integer/Zig/9-billion-names-of-god-the-integer-2.zig new file mode 100644 index 0000000000..3b8f04f057 --- /dev/null +++ b/Task/9-billion-names-of-God-the-integer/Zig/9-billion-names-of-god-the-integer-2.zig @@ -0,0 +1,35 @@ +const std = @import("std"); +const print = std.debug.print; +const bigint = std.math.big.int.Managed; +const eql = std.mem.eql; +const Array = std.ArrayList; +const Array1 = Array(bigint); +var gpa = std.heap.GeneralPurposeAllocator(.{}){}; +const allocator = gpa.allocator(); + +fn calc ( n:usize, p:*Array1) !void { + for ( 1..n+1 ) |k| { + var d:i64 = @intCast(n); + d -= @intCast(k*(3*k - 1)/2); + inline for ( 0..2 ) |_| { + if ( d < 0 ) return; + if (k&1>0) try p.items[n].add ( &p.items[n], &p.items[@intCast(d)] ) + else try p.items[n].sub ( &p.items[n], &p.items[@intCast(d)] ); + d -= @intCast(k); + } + } +} + +fn main() !void { + const s = [_]usize{ 23, 123, 1234, 12345, 123456 }; + var p = Array1.init ( allocator ); + try p.append ( try bigint.initSet ( allocator, 1 ) ); + var i:usize=1; + for ( s )|m|{ + while (i<=m):(i+=1){ + try p.append( try bigint.init(allocator) ); + try calc( i, &p ); + } + print("P({d}) = {d}\n", .{m,p.items[m]} ); + } +} diff --git a/Task/99-bottles-of-beer/8th/99-bottles-of-beer-1.8th b/Task/99-bottles-of-beer/8th/99-bottles-of-beer-1.8th new file mode 100644 index 0000000000..f07c88a955 --- /dev/null +++ b/Task/99-bottles-of-beer/8th/99-bottles-of-beer-1.8th @@ -0,0 +1,26 @@ +\ 99 bottles of beer on the wall: +[ + "no more bottles" , + "one bottle" , + ( dup . " bottles" ) +] var, bottles + +: .bottles + dup 2 n:min bottles @ caseof ; + +: .beer + .bottles . " of beer" . ; + +: .wall + .beer " on the wall" . ; + +: .take + " Take one down and pass it around" . ; + +: beers + .wall ", " . .beer '; putc cr + n:1- 0 max .take ", " . + .wall '. putc cr drop ; + +' beers 1 99 loop- +bye diff --git a/Task/99-bottles-of-beer/8th/99-bottles-of-beer-2.8th b/Task/99-bottles-of-beer/8th/99-bottles-of-beer-2.8th new file mode 100644 index 0000000000..f736dda979 --- /dev/null +++ b/Task/99-bottles-of-beer/8th/99-bottles-of-beer-2.8th @@ -0,0 +1,12 @@ +[ + ( "Just one more bottle of beer on the wall, one bottle of beer.\n" . ) , + ( I dup "%d bottles of beer on the wall, %d bottles of beer.\n" s:strfmt . ) +] constant lyrics + +: app:main + ( + dup lyrics [2,99] rot ' n:cmp a:pigeon w:exec + n:1- "Take one down, pass it around, %d bottles of beer on the wall.\n\n" s:strfmt . + ) 1 99 loop- + + "No more bottles of beer on the wall, no more bottles of beer.\n" . ; diff --git a/Task/99-bottles-of-beer/8th/99-bottles-of-beer.8th b/Task/99-bottles-of-beer/8th/99-bottles-of-beer.8th deleted file mode 100644 index fa816e4a36..0000000000 --- a/Task/99-bottles-of-beer/8th/99-bottles-of-beer.8th +++ /dev/null @@ -1,20 +0,0 @@ -\ 99 bottles of beer on the wall: -: allout "no more bottles" ; -: just-one "1 bottle" ; -: yeah! dup . " bottles" ; - -[ - ' allout , - ' just-one , - ' yeah! , -] var, bottles - -: .bottles dup 2 n:min bottles @ swap caseof ; -: .beer .bottles . " of beer" . ; -: .wall .beer " on the wall" . ; -: .take " Take one down and pass it around" . ; -: beers .wall ", " . .beer '; putc cr - n:1- 0 max .take ", " . - .wall '. putc cr drop ; - -' beers 1 99 loop- bye diff --git a/Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer.oxy b/Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-1.oxy similarity index 100% rename from Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer.oxy rename to Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-1.oxy diff --git a/Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-2.oxy b/Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-2.oxy new file mode 100644 index 0000000000..5fc3a8fccb --- /dev/null +++ b/Task/99-bottles-of-beer/Oxygene/99-bottles-of-beer-2.oxy @@ -0,0 +1,21 @@ +namespace _99_beers; + +method bottles(number: Integer): String; +begin +if (number = 1) then + Result := "bottle" + else + Result := "bottles"; +end; + +begin + for n: Integer := 99 downto 1 do + begin + writeLn($"{n} {bottles(n)} of beer on the wall,"); + writeLn($"{n} {bottles(n)} of beer,"); + writeLn($"Take one down, and pass it around,"); + writeLn($"{n-1} {bottles(n-1)} of beer on the wall."); + writeLn(); + end; + readLn; +end. diff --git a/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-1.pas b/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-1.pas new file mode 100644 index 0000000000..f455395d06 --- /dev/null +++ b/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-1.pas @@ -0,0 +1,10 @@ +begin + for var i:=99 to 1 step -1 do + begin + Println(i,'bottles of beer on the wall'); + Println(i,'bottles of beer'); + Println('Take one down, pass it around'); + Println(i-1,'bottles of beer on the wall'); + Println + end; +end. diff --git a/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-2.pas b/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-2.pas new file mode 100644 index 0000000000..3ce09c9fc9 --- /dev/null +++ b/Task/99-bottles-of-beer/PascalABC.NET/99-bottles-of-beer-2.pas @@ -0,0 +1,10 @@ +begin + for var i:=99 to 1 step -1 do + begin + writeLn($'{i} bottles of beer on the wall'); + writeLn($'{i} bottles of beer'); + writeLn($'Take one down, pass it around'); + writeLn($'{i-1}bottles of beer on the wall'); + writeLn + end; +end. diff --git a/Task/A+B/PascalABC.NET/a+b.pas b/Task/A+B/PascalABC.NET/a+b.pas new file mode 100644 index 0000000000..ac390aa674 --- /dev/null +++ b/Task/A+B/PascalABC.NET/a+b.pas @@ -0,0 +1,3 @@ +## +var (a,b) := ReadInteger2; +Writeln(a + b); diff --git a/Task/A+B/Zig/a+b.zig b/Task/A+B/Zig/a+b.zig new file mode 100644 index 0000000000..fc0d17b9f6 --- /dev/null +++ b/Task/A+B/Zig/a+b.zig @@ -0,0 +1,25 @@ +const std = @import("std"); +const stdout = std.io.getStdOut().writer(); + +const Input = enum { a, b }; + +pub fn main() !void { + var buf: [1024]u8 = undefined; + const reader = std.io.getStdIn().reader(); + const input = try reader.readUntilDelimiter(&buf, '\n'); + const values = std.mem.trim(u8, input, "\x20"); + + var count: usize = 0; + var split: usize = 0; + for (values, 0..) |c, i| { + if (!std.ascii.isDigit(c)) { + count += 1; + if (count == 1) split = i; + } + } + + const a = try std.fmt.parseInt(u64, values[0..split], 10); + const b = try std.fmt.parseInt(u64, values[split + count ..], 10); + + try stdout.print("{d}\n", .{a + b}); +} diff --git a/Task/ADFGVX-cipher/Uiua/adfgvx-cipher.uiua b/Task/ADFGVX-cipher/Uiua/adfgvx-cipher.uiua new file mode 100644 index 0000000000..d163a20723 --- /dev/null +++ b/Task/ADFGVX-cipher/Uiua/adfgvx-cipher.uiua @@ -0,0 +1,11 @@ +A ← ↯∞_2⊞⊟."ADFGVX" +P ← ⊏⍏[⍥⚂]⧻."ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" +K ← "PACKHORSE" +Sw ← ⊜□≠" ". +Polybius ← setinv(/⊂⊡≡(⊚⌕):⊙:¤P A|⊏:P≡(⊢⊚⌕)⊙¤∩≡□↯∞_2:A) +SortByK ← setinv(⊏⍏⟜(⍉⬚" "↯⊟∞⧻)K|▽≠" "./⊂⍉⊏⍏⍏K) +Str ← setinv(/$"_ _"Sw/⊂≡(⊂:" ")|≡(⊢°□◇⬚" "↯⊟∞)/↥≡◇⧻.Sw) +Pt ← "ATTACKAT1200AM" +&p $"Key = _\nPolybius:\n_\nPlaintext = _"K↯⊟.√⧻.P Pt +&p$"Crypttext = _". Str SortByK Polybius Pt +&p$"Plaintext = _" °Polybius °SortByK °Str diff --git a/Task/ASCII-art-diagram-converter/FutureBasic/ascii-art-diagram-converter.basic b/Task/ASCII-art-diagram-converter/FutureBasic/ascii-art-diagram-converter.basic new file mode 100644 index 0000000000..53358adc2d --- /dev/null +++ b/Task/ASCII-art-diagram-converter/FutureBasic/ascii-art-diagram-converter.basic @@ -0,0 +1,93 @@ +// RosettaCode Editing ASCII Art Diagram Converter + +include "NSLog.incl" + +local fn HexToBinary( hexString as CFStringRef ) as CFStringRef + NSUInteger i + CFMutableStringRef binaryString = fn MutableStringNew + CFDictionaryRef hexToBinaryMap = @{ + @"0": @"0000", @"1": @"0001", @"2": @"0010", @"3": @"0011", + @"4": @"0100", @"5": @"0101", @"6": @"0110", @"7": @"0111", + @"8": @"1000", @"9": @"1001", @"A": @"1010", @"B": @"1011", + @"C": @"1100", @"D": @"1101", @"E": @"1110", @"F": @"1111"} + + for i = 0 to len(hexString) - 1 + CFStringRef hexDigit = ucase( fn StringSubstringWithRange( hexString, fn CFRangeMake( i, 1 ) ) ) + CFStringRef binaryDigit = ucase( hexToBinaryMap[hexDigit] ) + if ( binaryDigit ) + MutableStringAppendString( binaryString, binaryDigit ) + end if + next +end fn = binaryString + +local fn ParseASCIIArt + CFStringRef header = @"¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + | ID |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + |QR| Opcode |AA|TC|RD|RA| Z | RCODE |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + | QDCOUNT |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + | ANCOUNT |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + | NSCOUNT |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+\n¬ + | ARCOUNT |\n¬ + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + + NSInteger i = 0, tempBits + CFMutableArrayRef table = fn MutableArrayNew + RegularExpressionRef regex = fn RegularExpressionWithPattern( @"\\| *\\w+ *", 0, NULL ) + CFArrayRef matches = fn RegularExpressionMatches( regex, header, 0, fn CFRangeMake( 0, len(header) ) ) + TextCheckingResultRef match + CFDictionaryRef dict + CFStringRef tempName, binaryStr + CFRange tempRange + + for match in matches + CFRange range = fn TextCheckingResultRange( match ) + CFCharacterSetRef charSet = fn CharacterSetWithCharactersInString( @"| " ) + CFStringRef name = fn StringByTrimmingCharactersInSet( fn StringSubstringWithRange( header, range ), charSet ) + NSInteger bits = range.length / 3 + ValueRef rangeVal = fn ValueWithRange( fn CFRangeMake( i, bits ) ) + CFDictionaryRef item = @{@"name":name, @"bits":fn NumberWithInteger( bits ), @"range":rangeVal} + MutableArrayAddObject( table, item ) + i += bits + next + + NSLog( @"\nRFC 1035 message diagram header:\n%@\n", header ) + + CFStringRef hexStr = @"78477bbf5496e12e1bf169a4" + CFStringRef binStr = fn HexToBinary( @"78477bbf5496e12e1bf169a4" ) + + NSLog( @" Decoded:" ) + NSLog( @" Name Bits Start End" ) + NSLog( @" ======= ==== ===== ===" ) + + for dict in table + tempName = dict[@"name"] + tempBits = fn NumberIntegerValue( dict[@"bits"] ) + tempRange = fn ValueRange( dict[@"range"] ) + NSLog( @"%8s %5ld %6ld %4ld", fn StringUTF8String( tempName ), tempBits, tempRange.location, tempRange.location + tempRange.length - 1 ) + next + + NSLog( @"\n Test string in hex:\n %@\n", hexStr ) + NSLog( @" Test string in binary:\n %@\n", binStr ) + + NSLog( @" Unpacked:" ) + NSLog( @" Name Size Bit Pattern" ) + NSLog( @" ======= ==== ================" ) + + for dict in table + tempName = dict[@"name"] + tempBits = fn NumberIntegerValue( dict[@"bits"] ) + tempRange = fn ValueRange( dict[@"range"] ) + binaryStr = fn StringSubstringWithRange( binStr, fn CFRangeMake( tempRange.location, tempBits ) ) + NSLog( @"%8s %5ld %-7s", fn StringUTF8String( tempName ), tempBits, fn StringUTF8String( binaryStr ) ) + next +end fn + +fn ParseASCIIArt + +HandleEvents diff --git a/Task/ASCII-art-diagram-converter/Uiua/ascii-art-diagram-converter.uiua b/Task/ASCII-art-diagram-converter/Uiua/ascii-art-diagram-converter.uiua new file mode 100644 index 0000000000..ab69945cb9 --- /dev/null +++ b/Task/ASCII-art-diagram-converter/Uiua/ascii-art-diagram-converter.uiua @@ -0,0 +1,26 @@ +HtoB ← /⊂⋯⊗:"0123456789abcdef" +Fields ← ( + ⊜□≠@|./⊂▽⊸≡(¬∊@+)⊜∘≠@\n. + ⊃(≡(÷3+1◇⧻)|≡(□(◇▽⊸⍚≥@A))) +) +T ← $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ | ID | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ |QR| Opcode |AA|TC|RD|RA| Z | RCODE | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ | QDCOUNT | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ | ANCOUNT | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ | NSCOUNT | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + $ | ARCOUNT | + $ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +◫2⊂0\+Fields T # Get field starts and ends. +HtoB "78477bbf5496e12e1bf169a4" +⍚⊏⊙¤≡(□↘⊙⇡°⊟), # Split the bits. +≡⊂:≡⊂:⊙(≡(⊂:⊟⊙(-1)°⊟⟜/-)) # Arrange the table. +&p$"Field\tBits\tStart\tEnd\tValue" +&p$"-----\t----\t-----\t---\t-----" +≡(&p$"_\t_\t_\t_\t_"⊃(⊡0|⊡1|⊡2|⊡3|⊡4)) diff --git a/Task/Abbreviations-automatic/Emacs-Lisp/abbreviations-automatic.l b/Task/Abbreviations-automatic/Emacs-Lisp/abbreviations-automatic.l new file mode 100644 index 0000000000..8877dc684b --- /dev/null +++ b/Task/Abbreviations-automatic/Emacs-Lisp/abbreviations-automatic.l @@ -0,0 +1,36 @@ +(defun abbreviate-list (list-of-days abbreviation-length) + "Take each element of LIST-OF-DAYS and abbreviate to ABBREVIATION-LENGTH." + (let ((abbrev-list) + (abbrev-element)) + (dolist (one-element list-of-days) ; loop through each day of week +;; if the day of week is at least as long as the abbreviation + (if (>= (length one-element) abbreviation-length) ; if day >= abbreviation length + (setq abbrev-element (substring one-element 0 abbreviation-length)) ; abbreviate the day of the week + (setq abbrev-element one-element)) ; otherwise don't abbreviate + (push abbrev-element abbrev-list)) ; put the abbreviated/non-abbreviated day on our list + abbrev-list)) ; return the list of abbreviated days + +(defun cycle-days (list-of-days) + "Find shortest unique abbreviation in LIST-OF-DAYS list." + (let ((abbrev-list) + (abbrev-length 1) + (current-abbrev) + (looking-for-shortest-list t)) + (if (= (length list-of-days) 0) ; if list-of-days is empty (i.e., blank line) + (setq looking-for-shortest-list nil)) ; then don't look for the shortest unique abbreviations + (while looking-for-shortest-list ; as long as we are looking for the shortest unique abbreviations + (setq abbrev-list (abbreviate-list list-of-days abbrev-length)) ; get a list of abbreviated day names + (if (= (length list-of-days) (length (seq-uniq abbrev-list))) ; if abbreviated list has no duplicates + (progn + (message (format "%d %s" abbrev-length list-of-days)) ; then in echo buffer show length and days + (setq looking-for-shortest-list nil)) ; also, then don't look for the shortest unique abbreviations + (setq abbrev-length (+ abbrev-length 1)))))) ; else increase the length of the abbreviation; loop to while + +(defun days-of-week () + "Find minimum abbreviation length of days of week." + (let ((current-line-list)) + (find-file "Days_of_week.txt") ; open file or switch to buffer + (beginning-of-buffer) ; go to the top of the buffer + (dolist (current-line (split-string (buffer-string) "\n")) ; go line by line through buffer + (setq current-line-list (split-string current-line " ")) ; change each line into list of days of week + (cycle-days current-line-list)))) diff --git a/Task/Abbreviations-automatic/Uiua/abbreviations-automatic.uiua b/Task/Abbreviations-automatic/Uiua/abbreviations-automatic.uiua new file mode 100644 index 0000000000..983c4fa405 --- /dev/null +++ b/Task/Abbreviations-automatic/Uiua/abbreviations-automatic.uiua @@ -0,0 +1,17 @@ +# Experimental! +# Find shortest distinct abbreviation length per line + +Lines ← {"Sunday Monday Tuesday Wednesday Thursday Friday Saturday" + "sing_kei_yaht sing_kei_yat sing_kei_yee sing_kei_saam sing_kei_sie sing_kei_ng sing_kei_luk" + "" + "Diu_prima Diu_sequima Diu_tritima Diu_quartima Diu_quintima Diu_sextima Diu_sabbata" + "sunnudagur mánadagur tÿsdaguy mikudagur hósdagur friggjadagur leygardagur" + "Yek_Sham'beh Do_Sham'beh Seh_Sham'beh Cha'har_Sham'beh Panj_Sham'beh Jom'eh Sham'beh"} + +# Return 1+max_common_prefix +AbbrevLen ← +1/↥◹(/↥↘1)⊞(/+\↧⬚@ =∩°□). +Split ← ⊜□⊸(≠@ ) +RemoveEmpty ← ▽⊸(≡(≠0◇⧻)) +Line ← ⊂⊂:": " °⋕:⊸(/(⊂⊂) " "≡(⬚@ ↙:°□)⊙¤)⟜AbbrevLen ◇Split +≡⍚Line RemoveEmpty Lines +≡&p diff --git a/Task/Abelian-sandpile-model-Identity/EasyLang/abelian-sandpile-model-identity.easy b/Task/Abelian-sandpile-model-Identity/EasyLang/abelian-sandpile-model-identity.easy new file mode 100644 index 0000000000..3e0c4d008f --- /dev/null +++ b/Task/Abelian-sandpile-model-Identity/EasyLang/abelian-sandpile-model-identity.easy @@ -0,0 +1,60 @@ +proc out s[] . . + for r = 0 to 2 + for c to 3 + write s[c + 3 * r] & " " + . + print "" + . + print "" +. +proc stab . m[] . + n = sqrt len m[] + repeat + stable = 1 + for p to len m[] + if m[p] >= 4 + stable = 0 + m[p] -= 4 + if p > n + m[p - n] += 1 + . + if p mod n <> 0 + m[p + 1] += 1 + . + if p <= len m[] - n + m[p + n] += 1 + . + if p mod n <> 1 + m[p - 1] += 1 + . + . + . + until stable = 1 + . +. +func[] add s1[] s2[] . + for i to len s1[] + r[] &= s1[i] + s2[i] + . + stab r[] + return r[] +. +print "avalanche:" +s4[] = [ 4 3 3 3 1 2 0 2 3 ] +stab s4[] +out s4[] +# +s1[] = [ 1 2 0 2 1 1 0 1 3 ] +s2[] = [ 2 1 3 1 0 1 0 1 0 ] +if add s1[] s2[] = add s2[] s1[] + print "s1 + s2 = s2 + s1" +. +# +s3[] = [ 3 3 3 3 3 3 3 3 3 ] +s3_id[] = [ 2 1 2 1 0 1 2 1 2 ] +if add s3[] s3_id[] = s3[] + print "s3 + s3_id = s3" +. +if add s3_id[] s3_id[] = s3_id[] + print "s3_id + s3_id = s3_id" +. diff --git a/Task/Abelian-sandpile-model/Ada/abelian-sandpile-model.ada b/Task/Abelian-sandpile-model/Ada/abelian-sandpile-model.ada new file mode 100644 index 0000000000..10aa915326 --- /dev/null +++ b/Task/Abelian-sandpile-model/Ada/abelian-sandpile-model.ada @@ -0,0 +1,67 @@ +pragma Ada_2022; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Text_IO; use Ada.Text_IO; +procedure Abelian_Sandpile is + type Grid_2D is array (Positive range <>, Positive range <>) of Natural; + + procedure Write_PPM (Grid : Grid_2D; Filename : String) is + PPM_File : File_Type; + begin + Create (PPM_File, Out_File, Filename); + Put_Line (PPM_File, "P3"); + Put_Line (PPM_File, Grid'Length (1)'Image & Grid'Length (2)'Image); + Put_Line (PPM_File, "7"); + for Y in 1 .. Grid'Length (2) loop + for X in 1 .. Grid'Length (1) loop + case Grid (X, Y) is + when 0 => Put_Line (PPM_File, "0 0 0"); -- black + when 1 => Put_Line (PPM_File, "0 7 0"); -- green + when 2 => Put_Line (PPM_File, "7 0 7"); -- lilac + when 3 => Put_Line (PPM_File, "7 7 0"); -- yellow + when others => Put_Line (PPM_File, "0 0 7"); -- blue, shouldn't happen + end case; + end loop; + end loop; + Close (PPM_File); + end Write_PPM; +begin + if Argument_Count /= 2 then + Put_Line ("Error: Must specify "); + else + declare + Initial_Height : constant Positive := Positive'Value (Argument (1)); + Grid_Size : constant Positive := Positive'Value (Argument (2)); + Sandpile : Grid_2D (1 .. Grid_Size, 1 .. Grid_Size) := [others => [others => 0]]; + More_To_Do : Boolean := True; + Overspill : Natural; + begin + Sandpile (Grid_Size / 2, Grid_Size / 2) := Initial_Height; + while More_To_Do loop + More_To_Do := False; + for X in 1 .. Grid_Size loop + for Y in 1 .. Grid_Size loop + if Sandpile (X, Y) >= 4 then + Overspill := Sandpile (X, Y) / 4; + Sandpile (X, Y) := @ mod 4; + More_To_Do := True; + if X > 1 then + Sandpile (X - 1, Y) := @ + Overspill; + end if; + if Y > 1 then + Sandpile (X, Y - 1) := @ + Overspill; + end if; + if X < Grid_Size then + Sandpile (X + 1, Y) := @ + Overspill; + end if; + if Y < Grid_Size then + Sandpile (X, Y + 1) := @ + Overspill; + end if; + end if; + end loop; + end loop; + end loop; + if Grid_Size < 16 then Put_Line (Sandpile'Image); end if; + Write_PPM (Sandpile, "sandpile.ppm"); + end; + end if; +end Abelian_Sandpile; diff --git a/Task/Abelian-sandpile-model/EasyLang/abelian-sandpile-model.easy b/Task/Abelian-sandpile-model/EasyLang/abelian-sandpile-model.easy new file mode 100644 index 0000000000..c77b7a2530 --- /dev/null +++ b/Task/Abelian-sandpile-model/EasyLang/abelian-sandpile-model.easy @@ -0,0 +1,35 @@ +n = 77 +len m[] n * n +m[n * n div 2 + 1] = 10000 +# +proc show . . + sc = 100 / n + for r range0 n + for c range0 n + move c * sc r * sc + p = r * n + c + 1 + color 222 * m[p] + rect sc sc + . + . + sleep 0 +. +proc run . . + repeat + mp[] = m[] + stable = 1 + for p to len mp[] + if mp[p] >= 4 + stable = 0 + m[p] -= 4 + m[p - n] += 1 + m[p + 1] += 1 + m[p + n] += 1 + m[p - 1] += 1 + . + . + show + until stable = 1 + . +. +run diff --git a/Task/Abelian-sandpile-model/Locomotive-Basic/abelian-sandpile-model.basic b/Task/Abelian-sandpile-model/Locomotive-Basic/abelian-sandpile-model.basic new file mode 100644 index 0000000000..6406a507ab --- /dev/null +++ b/Task/Abelian-sandpile-model/Locomotive-Basic/abelian-sandpile-model.basic @@ -0,0 +1,27 @@ +10 mode 1:defint a-z +20 height=15000:size=100 +30 ink 0,0:ink 1,18:ink 2,8:ink 3,24 +40 dim grid(size+1,size+1) +50 grid(size/2,size/2)=height +60 moretodo=1 +70 while moretodo +80 moretodo=0 +90 for x=1 to size +100 for y=1 to size +110 if grid(x,y)<4 then 190 +120 overspill=int(grid(x,y)/4) +130 grid(x,y)=grid(x,y) mod 4 +140 moretodo=1 +150 if x>1 then grid(x-1,y)=grid(x-1,y)+overspill +160 if y>1 then grid(x,y-1)=grid(x,y-1)+overspill +170 if x= 4 -- slightly faster +⟜Scale&p⍜now⍥Abelian₄ 100G 0 +⟜Scale&p⍜now⍥Abelian₄ 900⊙, +Scale⍥Abelian₄∞⊙, # Run to completion diff --git a/Task/Abstract-type/11l/abstract-type.11l b/Task/Abstract-type/11l/abstract-type.11l index ed88d4b041..2374f37287 100644 --- a/Task/Abstract-type/11l/abstract-type.11l +++ b/Task/Abstract-type/11l/abstract-type.11l @@ -1,6 +1,6 @@ T AbstractQueue - F.virtual.abstract enqueue(Int item) -> N + F.virtual.abstract enqueue(Int item) -> Void T PrintQueue(AbstractQueue) - F.virtual.assign enqueue(Int item) -> N + F.virtual.assign enqueue(Int item) -> Void print(item) diff --git a/Task/Abstract-type/PascalABC.NET/abstract-type-1.pas b/Task/Abstract-type/PascalABC.NET/abstract-type-1.pas new file mode 100644 index 0000000000..4ea14e8f5f --- /dev/null +++ b/Task/Abstract-type/PascalABC.NET/abstract-type-1.pas @@ -0,0 +1,20 @@ +type + MyAbstract = abstract class + public + procedure Proc1; abstract; + procedure Proc2; + begin + end; + end; + MyClass = class(MyAbstract) + public + procedure Proc1; override; + begin + end; + end; + + +begin + var a := new MyClass; + a.Proc1; +end. diff --git a/Task/Abstract-type/PascalABC.NET/abstract-type-2.pas b/Task/Abstract-type/PascalABC.NET/abstract-type-2.pas new file mode 100644 index 0000000000..aaa3e079db --- /dev/null +++ b/Task/Abstract-type/PascalABC.NET/abstract-type-2.pas @@ -0,0 +1,22 @@ +type + IMyInterface = interface + procedure Proc1; + procedure Proc2; + end; + MyClass = class(IMyInterface) + public + procedure Proc1; + begin + Print(1); + end; + procedure Proc2; + begin + Print(2); + end; + end; + +begin + var a: IMyInterface := new MyClass; + a.Proc1; + a.Proc2; +end. diff --git a/Task/Accumulator-factory/PascalABC.NET/accumulator-factory.pas b/Task/Accumulator-factory/PascalABC.NET/accumulator-factory.pas new file mode 100644 index 0000000000..86c0cbcc7d --- /dev/null +++ b/Task/Accumulator-factory/PascalABC.NET/accumulator-factory.pas @@ -0,0 +1,12 @@ +function foo(n: real): real -> real := + i -> begin + n += i; + Result := n; + end; + +begin + var x := foo(1); + x(5); + foo(3); + print(x(2.3)); +end. diff --git a/Task/Achilles-numbers/Ada/achilles-numbers.ada b/Task/Achilles-numbers/Ada/achilles-numbers.ada new file mode 100644 index 0000000000..054f448da3 --- /dev/null +++ b/Task/Achilles-numbers/Ada/achilles-numbers.ada @@ -0,0 +1,205 @@ +pragma Ada_2022; + +with Ada.Text_IO; +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Long_Elementary_Functions; +use Ada.Numerics.Long_Elementary_Functions; +with Ada.Strings; use Ada.Strings; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; +with Prime_Numbers; + +procedure Achilles_Numbers is + + package Long_Integer_Prime_Numbers is new Prime_Numbers + (Integer, 0, 1, 2); + use Long_Integer_Prime_Numbers; + + -- A powerful number N is such that for every primer factor P of it + -- P^2 also divides N + -- Is_Powerful function decomposes the given number N in its prime factors + -- and then it checks if each factor squared is a divisor of N + function Is_Powerful (Number : Natural) return Boolean is + List : constant Number_List := Decompose (Integer (Number)); + begin + for Index in List'Range loop + declare + N : constant Long_Long_Integer := Long_Long_Integer (Number); + F : constant Long_Long_Integer := Long_Long_Integer (List (Index)); + begin + if N mod (F * F) /= 0 then + return False; + end if; + end; + end loop; + + return True; + end Is_Powerful; + + -- The Is_Power function checks if a given number N can be written + -- as a power of two integers that are > 1 + -- It makes use of the mathematical expression N = A^B + -- taking Log(N) = Log (A^B) equals to B = Log (N) / Log (A) + -- where the solutions are when B is an integer > 1 + function Is_Power (N : Integer) return Boolean is + + function Is_Almost_Equal (A : Long_Float; + B : Long_Float) return Boolean is + Epsilon : constant := 0.000_000_000_000_001; + begin + if abs (A - B) < Epsilon then + return True; + else + return False; + end if; + end Is_Almost_Equal; + + A : Integer := 2; + B : Long_Float; + Log_Of_N : constant Long_Float := Log (Long_Float (N), 2.0); + begin + if N = 1 then + return True; + end if; + + while True loop + B := Log_Of_N / Log (Long_Float (A), 2.0); + + if Is_Almost_Equal (B, Long_Float (Integer (B))) + and then Integer (B) > 1 + then + return True; + end if; + + exit when A * A > N; + A := @ + 1; + end loop; + + return False; + + end Is_Power; + + -- An Achilles number is a powerful number that can't be expressed + -- as a power + function Is_Achilles (N : Integer) return Boolean is + begin + if Is_Powerful (N) then + if Is_Power (N) = False then + return True; + end if; + end if; + + return False; + end Is_Achilles; + + -- Calculates the Euler totient of a number + function Totient (N : Integer) return Integer is + Tot : Integer := N; + I : Integer; + N2 : Integer := N; + begin + I := 2; + while I * I <= N2 loop + if N2 mod I = 0 then + while N2 mod I = 0 loop + N2 := N2 / I; + end loop; + Tot := Tot - Tot / I; + end if; + + if I = 2 then + I := 1; + end if; + I := I + 2; + end loop; + + if N2 > 1 then + Tot := Tot - Tot / N2; + end if; + + return Tot; + end Totient; + + -- A Strong Achilles number is an Achilles number whose Euler Totient + -- is also an Achilles number + function Is_Strong_Achilles (N : Integer) return Boolean is + begin + if Is_Achilles (N) then + if Is_Achilles (Totient (N)) then + return True; + end if; + end if; + + return False; + end Is_Strong_Achilles; + + -- Counts the digits in a number by taking the string from + -- its 'Image attribute, trimming it and counting the characters + function Count_Digits (N : Integer) return Natural is + Integer_Str : constant String := Trim (N'Image, Both); + begin + return Integer_Str'Length; + end Count_Digits; + +begin + -- Find the first 50 Achilles numbers + declare + N : Integer := 1; + Count : Integer := 1; + begin + Ada.Text_IO.Put_Line ("First 50 Achilles numbers:"); + + while Count <= 50 loop + + if Is_Achilles (N) then + Count := @ + 1; + Ada.Text_IO.Put (N'Image & " "); + end if; + + N := @ + 1; + end loop; + + Ada.Text_IO.New_Line; + end; + + -- Find the first 20 Strong Achilles numbers + declare + N : Integer := 1; + Count : Integer := 1; + begin + Ada.Text_IO.Put_Line ("First 20 Strong Achilles numbers:"); + + while Count <= 20 loop + + if Is_Strong_Achilles (N) then + Count := @ + 1; + Ada.Text_IO.Put (N'Image & " "); + end if; + + N := @ + 1; + end loop; + + Ada.Text_IO.New_Line; + end; + + -- Count numbers with digits + declare + Counts : array (2 .. 6) of Natural := [others => 0]; + N : Integer := 1; + begin + Ada.Text_IO.Put_Line ("Number of Achilles numbers with:"); + + while Count_Digits (N) <= Counts'Last loop + + -- Ada.Text_IO.Put_Line ("Testing: " & N'Image); + + if Is_Achilles (N) then + Counts (Count_Digits (N)) := @ + 1; + end if; + N := @ + 1; + end loop; + + for I in Counts'Range loop + Ada.Text_IO.Put_Line (I'Image & " digits: " & Counts (I)'Image); + end loop; + end; +end Achilles_Numbers; diff --git a/Task/Ackermann-function/PascalABC.NET/ackermann-function.pas b/Task/Ackermann-function/PascalABC.NET/ackermann-function.pas new file mode 100644 index 0000000000..1343534204 --- /dev/null +++ b/Task/Ackermann-function/PascalABC.NET/ackermann-function.pas @@ -0,0 +1,16 @@ +function Ackermann(m,n: integer): integer; +begin + if (m < 0) or (n < 0) then + raise new System.ArgumentOutOfRangeException(); + if m = 0 then + Result := n + 1 + else if n = 0 then + Result := Ackermann(m - 1, 1) + else Result := Ackermann(m - 1, Ackermann(m, n - 1)) +end; + +begin + for var m := 0 to 3 do + for var n := 0 to 4 do + Println($'Ackermann({m}, {n}) = {Ackermann(m,n)}'); +end. diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/C++/add-a-variable-to-a-class-instance-at-runtime.cpp b/Task/Add-a-variable-to-a-class-instance-at-runtime/C++/add-a-variable-to-a-class-instance-at-runtime.cpp new file mode 100644 index 0000000000..1f83768ae0 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/C++/add-a-variable-to-a-class-instance-at-runtime.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +class Demonstration { +public: + Demonstration() { + variables = { }; + } + + std::map variables; +}; + +int main() { + Demonstration demo; + std::cout << "Create two variables at runtime:" << std::endl; + for ( uint32_t i = 1; i <= 2; ++i ) { + std::cout << " Variable number " << i << ":" << std::endl; + std::cout << " Enter name: " << std::endl; + std::string name; + std::cin >> name; + std::cout << " Enter value: " << std::endl; + double value; + std::cin >> value; + demo.variables[name] = value; + } + + std::cout << std::endl; + std::cout << "Two new runtime variables appear to have been created." << std::endl; + for ( const auto &[key, value] : demo.variables ) { + std::cout << "Variable " << key << " = " << value << std::endl; + } +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/PascalABC.NET/add-a-variable-to-a-class-instance-at-runtime.pas b/Task/Add-a-variable-to-a-class-instance-at-runtime/PascalABC.NET/add-a-variable-to-a-class-instance-at-runtime.pas new file mode 100644 index 0000000000..3a8fa42045 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/PascalABC.NET/add-a-variable-to-a-class-instance-at-runtime.pas @@ -0,0 +1,19 @@ +type + MyClass = class + private + dict := new Dictionary; + public + procedure Add(name: string; value: object) := dict[name] := value; + property Items[name: string]: object read dict[name]; default; + end; + +begin + var obj := new MyClass; + obj.Add('Name','PascalABC.NET'); + obj.Add('Age',16); + Println(obj['Name'],obj['Age']); + var obj1 := new MyClass; + obj1.Add('X',2.3); + obj1.Add('Y',3.8); + Println(obj1['X'],obj1['Y']); +end. diff --git a/Task/Additive-primes/ALGOL-68/additive-primes.alg b/Task/Additive-primes/ALGOL-68/additive-primes.alg index 0c87382bc0..134ae5080f 100644 --- a/Task/Additive-primes/ALGOL-68/additive-primes.alg +++ b/Task/Additive-primes/ALGOL-68/additive-primes.alg @@ -20,5 +20,6 @@ BEGIN # find additive primes - primes whose digit sum is also prime # FI FI OD; - print( ( newline, "Found ", whole( additive count, 0 ), " additive primes below ", whole( UPB prime + 1, 0 ), newline ) ) + print( ( newline, "Found ", whole( additive count, 0 ) ) ); + print( ( " additive primes below ", whole( UPB prime + 1, 0 ), newline ) ) END diff --git a/Task/Additive-primes/C-sharp/additive-primes.cs b/Task/Additive-primes/C-sharp/additive-primes.cs new file mode 100644 index 0000000000..d076d0709c --- /dev/null +++ b/Task/Additive-primes/C-sharp/additive-primes.cs @@ -0,0 +1,86 @@ +internal class Program +{ + private static void Main(string[] args) + { + long primeCandidate = 1; + long additivePrimeCount = 0; + Console.WriteLine("Additive Primes"); + + while (primeCandidate < 500) + { + if (IsAdditivePrime(primeCandidate)) + { + additivePrimeCount++; + + Console.Write($"{primeCandidate,-3} "); + + if (additivePrimeCount % 10 == 0) + { + Console.WriteLine(); + } + } + + primeCandidate++; + } + + Console.WriteLine(); + Console.WriteLine($"Found {additivePrimeCount} additive primes less than 500"); + } + + private static bool IsAdditivePrime(long number) + { + if (IsPrime(number) && IsPrime(DigitSum(number))) + { + return true; + } + + return false; + } + + private static bool IsPrime(long number) + { + if (number < 2) + { + return false; + } + + if (number % 2 == 0) + { + return number == 2; + } + + if (number % 3 == 0) + { + return number == 3; + } + + int delta = 2; + long k = 5; + + while (k * k <= number) + { + if (number % k == 0) + { + return false; + } + + k += delta; + delta = 6 - delta; + } + + return true; + } + + private static long DigitSum(long n) + { + long sum = 0; + + while (n > 0) + { + sum += n % 10; + n /= 10; + } + + return sum; + } +} diff --git a/Task/Additive-primes/Langur/additive-primes.langur b/Task/Additive-primes/Langur/additive-primes.langur index cc42b1cb23..19042c8a58 100644 --- a/Task/Additive-primes/Langur/additive-primes.langur +++ b/Task/Additive-primes/Langur/additive-primes.langur @@ -1,18 +1,20 @@ -val .isPrime = fn(.i) .i == 2 or .i > 2 and - not any fn(.x) .i div .x, pseries 2 .. .i ^/ 2 +val isPrime = fn(i) { + i == 2 or i > 2 and + not any(fn x: i div x, pseries(2 .. i ^/ 2)) +} -val .sumDigits = fn(.i) fold fn{+}, s2n string .i +val sumDigits = fn i: fold(fn{+}, s2n(string(i))) writeln "Additive primes less than 500:" -var .count = 0 +var cnt = 0 -for .i in [2] ~ series(3..500, 2) { - if .isPrime(.i) and .isPrime(.sumDigits(.i)) { - write $"\{.i:3} " - .count += 1 - if .count div 10: writeln() +for i in [2] ~ series(3..500, 2) { + if isPrime(i) and isPrime(sumDigits(i)) { + write "{{i:3}} " + cnt += 1 + if cnt div 10: writeln() } } -writeln $"\n\n\{.count} additive primes found.\n" +writeln "\n\n{{cnt}} additive primes found.\n" diff --git a/Task/Additive-primes/Modula-3/additive-primes.mod3 b/Task/Additive-primes/Modula-3/additive-primes.mod3 new file mode 100644 index 0000000000..7c2695e0cb --- /dev/null +++ b/Task/Additive-primes/Modula-3/additive-primes.mod3 @@ -0,0 +1,44 @@ +MODULE AdditivePrimes EXPORTS Main; + +IMPORT SIO,Fmt; + +CONST + Max = 500; + +VAR + Count:CARDINAL := 0; + Prime:ARRAY[2..Max] OF BOOLEAN; + +PROCEDURE DigitSum(N:CARDINAL):CARDINAL = + BEGIN + IF N < 10 THEN RETURN N + ELSE RETURN (N MOD 10) + DigitSum(N DIV 10) END; + END DigitSum; + +PROCEDURE Sieve() = + VAR J:CARDINAL; + BEGIN + FOR I := 2 TO Max DO Prime[I] := TRUE END; + FOR I := 2 TO Max DIV 2 DO + IF Prime[I] THEN + J := I*2; + WHILE J <= Max DO + Prime[J] := FALSE; + INC(J,I) + END + END + END; + END Sieve; + +BEGIN + Sieve(); + FOR N := 2 TO Max DO + IF Prime[N] AND Prime[DigitSum(N)] THEN + SIO.PutText(Fmt.F("%4s",Fmt.Int(N))); + INC(Count); + IF Count MOD 10 = 0 THEN SIO.Nl() END + END + END; + SIO.PutText(Fmt.F("\nThere are %s additive primes less than %s.\n", + Fmt.Int(Count),Fmt.Int(Max))); +END AdditivePrimes. diff --git a/Task/Address-of-a-variable/PascalABC.NET/address-of-a-variable.pas b/Task/Address-of-a-variable/PascalABC.NET/address-of-a-variable.pas new file mode 100644 index 0000000000..dae77114a9 --- /dev/null +++ b/Task/Address-of-a-variable/PascalABC.NET/address-of-a-variable.pas @@ -0,0 +1,6 @@ +begin + var i: integer := 3; + var p: ^integer := @i; + p^ += 2; + Print(p^,i); +end. diff --git a/Task/Align-columns/Uiua/align-columns.uiua b/Task/Align-columns/Uiua/align-columns.uiua new file mode 100644 index 0000000000..147119d5cb --- /dev/null +++ b/Task/Align-columns/Uiua/align-columns.uiua @@ -0,0 +1,17 @@ +# Split the text at $ and then justify each word 3 ways +N ← {"Given$a$text$file$of$many$lines,$where$fields$within$a$line$" + "are$delineated$by$a$single$'dollar'$character,$write$a$program" + "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" + "column$are$separated$by$at$least$one$space." + "Further,$allow$for$each$word$in$a$column$to$be$either$left$" + "justified,$right$justified,$or$center$justified$within$its$column."} +Ls ← ≡⍚(⊜□≠@$.)N # Get the word arrays +P ← +1/↥≡◇⧻/◇⊂Ls # Padding = Max length + 1 +PadL ← /↥⬚@ ⊟↯P@ +PadR ← ⍜⇌PadL +PadC ← PadL⊂↯:@ ⌊÷2-:P⧻. +Format! ← ≡&p≡(□/⊂≡◇^!°□) +# Demonstration of use of an array macro, which actually just resolves to +# ⊃(Format!PadC|Format!PadR|Format!PadL)Ls +Fall‼! ←^ $"⊃(_)"/⊂≡($"Format!_ |"°□)⇌ +Fall‼!PadL PadR PadC Ls diff --git a/Task/Aliquot-sequence-classifications/00-TASK.txt b/Task/Aliquot-sequence-classifications/00-TASK.txt index 0d3ab821b5..31c44d6d5f 100644 --- a/Task/Aliquot-sequence-classifications/00-TASK.txt +++ b/Task/Aliquot-sequence-classifications/00-TASK.txt @@ -30,3 +30,6 @@ Show all output on this page. *   [[Amicable pairs]]

+;External links: +* [https://www.youtube.com/watch?v=OtYKDzXwDEE An amazing thing about 276], Numberphile + diff --git a/Task/Amb/Langur/amb.langur b/Task/Amb/Langur/amb.langur index 99fb78c1fc..3adeaad38f 100644 --- a/Task/Amb/Langur/amb.langur +++ b/Task/Amb/Langur/amb.langur @@ -1,15 +1,15 @@ -val .wordsets = [ +val wordsets = [ fw/the that a/, fw/frog elephant thing/, fw/walked treaded grows/, fw/slowly quickly/, ] -val .alljoin = fn(.words) for[=true] .i of len(.words)-1 { - if last(.words[.i]) != first(.words[.i+1]): break = false +val alljoin = fn words: for[=true] i of len(words)-1 { + if words[i][-1] != words[i+1][1]: break = false } -# .amb expects 2 or more arguments -val .amb = fn(...[2 .. -1] .words) if(.alljoin(.words): join " ", .words) +# amb expects 2 or more arguments +val amb = fn ...[2..] words: if alljoin(words) { join " ", words } -writeln join "\n", filter mapX .amb, .wordsets... +writeln join("\n", filter(mapX(amb, wordsets...))) diff --git a/Task/Anagrams/Emacs-Lisp/anagrams-1.l b/Task/Anagrams/Emacs-Lisp/anagrams-1.l new file mode 100644 index 0000000000..9920fae43d --- /dev/null +++ b/Task/Anagrams/Emacs-Lisp/anagrams-1.l @@ -0,0 +1,87 @@ +(defun code-letters (str) + "Sort STR into alphabetized list of individual letters." + (sort (split-string str "" t) #'string<)) + +(defun code-letters-to-string (str) + "Sort STR alphabetically and combine into one string." + (apply #'concat (code-letters str))) + +(defun remove-periods (str) + "Remove periods (full stops) from STR." + (string-replace "." "" str)) + +(defun list-pair (str) + "Create paired list from STR, STR (unchanged) and alphabetized order of STR." + ;; Remove periods from alphabetized order to make regex matching easier + (let ((letter-list (remove-periods (code-letters-to-string str)))) + (list letter-list str))) + +(defun pair-up (words) + "Make list of lists of paired words, one alphabetized one original." + (let ((paired-list) + (temp-pair)) + (dolist (word words) + (setq temp-pair (list-pair word)) + (push temp-pair paired-list)) + paired-list)) + +(defun create-list-of-numbers (my-list) + "Create list of numbers from MY-LIST." + (let ((list-of-numbers)) + (dolist (one-pair my-list) + (push (car one-pair) list-of-numbers)) + list-of-numbers)) + +(defun get-largest-number (my-list) + "Find largest number in MY-LIST." + (let ((list-of-numbers)) + (setq list-of-numbers (create-list-of-numbers my-list)) + (apply #'max list-of-numbers))) + +(defun make-list-matching-words (coded-word-and-original number-and-code-pair) + "List original words whose code matches code in NUMBER-AND-CODE-PAIR." + (dolist (word-pair coded-word-and-original) + ;; test if coded word in CODED-WORD-AND-ORIGINAL matches + ;; coded word in NUMBER-AND-CODE-PAIR + (when (string= (nth 0 word-pair) (nth 1 number-and-code-pair)) + ;; insert the original word + (insert (format "%s " (nth 1 word-pair))))) + (insert "\n")) + +(defun count-anagrams () + "Count the number of anagrams in file wordlist.txt" + (let ((coded-word-and-original) + (just-coded-words) + (unique-coded-words) + (count-and-code) + (number-of-anagrams) + (largest-number)) + ;; Path below needs to be adapted to individual case + (find-file "~/Documents/Elisp/wordlist.txt") + (beginning-of-buffer) + ;; create list of lists of coded words and originals + (setq coded-word-and-original (pair-up (split-string (buffer-string) "\n"))) + (find-file "temp-all-coded") + (erase-buffer) + (dolist (number-and-code-pair coded-word-and-original) + ;; make list of just the coded words + (push (nth 0 number-and-code-pair) just-coded-words)) + (dolist (one-word just-coded-words) + ;; write list of coded words to buffer for later processing + (insert (format "%s\n" one-word))) + ;; create a list of coded words with no repetitions + (setq unique-coded-words (seq-uniq just-coded-words)) + (dolist (one-code unique-coded-words) + (find-file "temp-all-coded") + (beginning-of-buffer) + ;; count the number of times ONE-CODE appears in buffer + (setq number-of-anagrams (how-many (format "^%s$" one-code))) + (if (>= number-of-anagrams 1) ; eliminate "words" of zero length + (push (list number-of-anagrams one-code) count-and-code))) + (find-file "anagram-listing") + (erase-buffer) + (setq largest-number (get-largest-number count-and-code)) + (dolist (number-and-code-pair count-and-code) + ;; when the number in NUMBER-AND-CODE-PAIR = largest number of anagrams + (when (= (nth 0 number-and-code-pair) largest-number) + (make-list-matching-words coded-word-and-original number-and-code-pair))))) diff --git a/Task/Anagrams/Emacs-Lisp/anagrams-2.l b/Task/Anagrams/Emacs-Lisp/anagrams-2.l new file mode 100644 index 0000000000..4a6a2b9b3d --- /dev/null +++ b/Task/Anagrams/Emacs-Lisp/anagrams-2.l @@ -0,0 +1,74 @@ +(defun code-letters (str) + "Sort STR into alphabetized list of individual letters." + (sort (split-string str "" t) #'string<)) + +(defun code-letters-to-string (str) + "Sort STR alphabetically and combine into one string." + (apply #'concat (code-letters str))) + +(defun add-to-hash (key value table) + "If KEY exists, add VALUE to list of values. +If KEY does not exist, associate value with KEY." + (let ((current-values)) + (if (gethash key table) + (progn + (setq current-values (gethash key table)) + (setq current-values (push value current-values)) + (puthash key current-values table)) + (puthash key (list value) table)))) + +(defun create-list-of-numbers (hash-table) + "Create a list of numbers from HASH-TABLE." + (let ((current-number) + (list-of-numbers)) + (setq list-of-numbers (list)) ; omit? + (maphash (lambda (key value) + (setq current-number (car (gethash key hash-table))) + (push current-number list-of-numbers)) + hash-table) + list-of-numbers)) + +(defun find-largest-number-in-hash (hash-table) + "Find largest number in HASH-TABLE." + (let ((list-of-numbers)) + (setq list-of-numbers (create-list-of-numbers hash-table)) + (apply #'max list-of-numbers))) + +(defun find-longest-lists-of-anagrams (&optional file) + "Find the set(s) of largest number of anagrams in file wordlist.txt" + (let ((largest-number) + (hash-key) + (dictionary-table (make-hash-table :test 'equal))) + ;; Path and filename below needs to be adapted to individual case if + ;; FILE is *not* passed to this function + (with-temp-buffer + (insert-file-contents (or file "~/Documents/Elisp/wordlist.txt")) + (beginning-of-buffer) + ;; set up hash table with key and word(s) + ;; key = letters of word, but with letters in + ;; alphabetical order. Create list word(s) associated + ;; with key. + (dolist (current-word (split-string (buffer-string) "\n")) + (setq hash-key (code-letters-to-string current-word)) + (add-to-hash hash-key current-word dictionary-table)) + ;; Count number of anagram words + (maphash (lambda (key value) + "Add number of anagram words to VALUE." + (add-to-hash key (length (gethash key dictionary-table)) dictionary-table)) + dictionary-table) + ;; find the size of the largest list(s) of anagrams + (setq largest-number (find-largest-number-in-hash dictionary-table))) + ;; set up empty buffer to show results + (with-current-buffer (pop-to-buffer "anagram-listing") + (erase-buffer) + ;; show results + (maphash (lambda (key value) + "Display longest lists of anagrams." + (when (= largest-number (car (gethash key dictionary-table))) + (mapc + (lambda (element) + "Insert ELEMENT followed by one space in buffer." + (insert (format "%s " element))) + (cdr (gethash key dictionary-table))) + (insert "\n"))) + dictionary-table)))) diff --git a/Task/Anagrams/PascalABC.NET/anagrams.pas b/Task/Anagrams/PascalABC.NET/anagrams.pas new file mode 100644 index 0000000000..937517fc8e --- /dev/null +++ b/Task/Anagrams/PascalABC.NET/anagrams.pas @@ -0,0 +1,7 @@ +begin + var s := System.Net.WebClient.Create.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'); + var words := s.Split; + var groups := words.GroupBy(word -> word.Order.JoinToString); + var maxCount := groups.Max(gr -> gr.Count); + groups.Where(gr -> gr.Count = maxCount).PrintLines; +end. diff --git a/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-1.pas b/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-1.pas new file mode 100644 index 0000000000..6b5e0f0b76 --- /dev/null +++ b/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-1.pas @@ -0,0 +1,13 @@ +function Fib(n: integer): integer; +begin + if n <= 0 then + raise new System.ArgumentOutOfRangeException('Must be > 0','n'); + var fibHelper: (integer,integer,integer) -> integer; + fibHelper := (n,a,b) -> n = 1 ? a : fibHelper(n-1, b, a + b); + Result := fibHelper(n,1,1); +end; + +begin + for var i:=1 to 10 do + Fib(i).Print; +end. diff --git a/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-2.pas b/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-2.pas new file mode 100644 index 0000000000..70ab8a191f --- /dev/null +++ b/Task/Anonymous-recursion/PascalABC.NET/anonymous-recursion-2.pas @@ -0,0 +1,13 @@ +function Fib(n: integer): integer; + function fibHelper(n,a,b: integer): integer := + n = 1 ? a : fibHelper(n-1, b, a + b); +begin + if n <= 0 then + raise new System.ArgumentOutOfRangeException('Must be > 0','n'); + Result := fibHelper(n,1,1); +end; + +begin + for var i:=1 to 10 do + Fib(i).Print; +end. diff --git a/Task/Anti-primes/Langur/anti-primes.langur b/Task/Anti-primes/Langur/anti-primes.langur index 1bd79d0c33..42efda2dc6 100644 --- a/Task/Anti-primes/Langur/anti-primes.langur +++ b/Task/Anti-primes/Langur/anti-primes.langur @@ -1,18 +1,18 @@ -val .countDivisors = fn(.n) { - if .n < 2: return 1 - for[=2] .i = 2; .i <= .n\2; .i += 1 { - if .n div .i : _for += 1 +val countDivisors = fn(n) { + if n < 2: return 1 + for[=2] i = 2; i <= n\2; i += 1 { + if n div i: _for += 1 } } writeln "The first 20 anti-primes are:" -var .maxDiv, .count = 0, 0 -for .n = 1; .count < 20; .n += 1 { - val .d = .countDivisors(.n) - if .d > .maxDiv { - write .n, " " - .maxDiv = .d - .count += 1 +var maxDiv, cnt = 0, 0 +for n = 1; cnt < 20; n += 1 { + val d = countDivisors(n) + if d > maxDiv { + write n, " " + maxDiv = d + cnt += 1 } } writeln() diff --git a/Task/Anti-primes/Uiua/anti-primes.uiua b/Task/Anti-primes/Uiua/anti-primes.uiua new file mode 100644 index 0000000000..167480c2c1 --- /dev/null +++ b/Task/Anti-primes/Uiua/anti-primes.uiua @@ -0,0 +1,8 @@ +# slightly faster than the simplistic /+=0◿+1⇡. +NDivs ← ⟨+2/+=0◿(↘1+1⇡⌊÷2).|1⟩<2. +⇌⊙◌◌⍢( + # Inc n, get NDiv: if >m, join n to accum, store new m. + ⟨◌|⟜(⊂⊢)⍜(⊡1|◌):⟩:⟜ x * x).ToArray; + a.ForEach(x -> Print(x)); +end. diff --git a/Task/Approximate-equality/EasyLang/approximate-equality.easy b/Task/Approximate-equality/EasyLang/approximate-equality.easy new file mode 100644 index 0000000000..910f89b4d4 --- /dev/null +++ b/Task/Approximate-equality/EasyLang/approximate-equality.easy @@ -0,0 +1,20 @@ +func aeq a b . + return if abs (a - b) <= abs a * 1e-14 +. +proc test a b . . + write a & " " & b & " -> " + if aeq a b = 1 + print "true" + else + print "false" + . +. +numfmt 10 0 +test 100000000000000.01 100000000000000.011 +test 100.01 100.011 +test 10000000000000.001 / 10000 1000000000.0000001 +test 0.001 0.0010000001 +test 1.01e-22 0 +test sqrt 2 * sqrt 2 2 +test -sqrt 2 * sqrt 2 -2 +test 3.14159265358979323846 3.14159265358979324 diff --git a/Task/Arbitrary-precision-integers-included-/FutureBasic/arbitrary-precision-integers-included-.basic b/Task/Arbitrary-precision-integers-included-/FutureBasic/arbitrary-precision-integers-included-.basic new file mode 100644 index 0000000000..60598c768c --- /dev/null +++ b/Task/Arbitrary-precision-integers-included-/FutureBasic/arbitrary-precision-integers-included-.basic @@ -0,0 +1,64 @@ +/* + +Uses GMP for Multiple Precision Arithmetic +Install GMP using terminal and Homebrew command, "brew install gmp" +before running this app in FutureBasic. + +Homebrew available here, https://brew.sh + +*/ + + +include "NSLog.incl" + +void local fn GMPoutput + CFStringRef sourcePath = fn StringByAppendingPathComponent( @"/tmp/", @"temp.m" ) + CFStringRef executablePath = fn StringByAppendingPathComponent( @"/tmp/", @"temp" ) + CFStringRef gmpStr = @"#import \n#import \n¬ + int main(int argc, const char * argv[]) {\n¬ + @autoreleasepool {\n¬ + mpz_t a;\n¬ + mpz_init_set_ui(a, 5);\n¬ + mpz_pow_ui(a, a, 1 << 18);\n¬ + size_t len = mpz_sizeinbase(a, 10);\n¬ + printf(\"GMP says size is: %zu\\n\", len);\n¬ + char *s = mpz_get_str(0, 10, a);\n¬ + size_t trueLen = strlen(s);\n¬ + printf(\" Actual size is: %zu\\n\", trueLen);\n¬ + printf(\"First & Last 20 digits: %.20s…%s\\n\", s, s + trueLen - 20);\n¬ + }\n¬ + return 0;\n¬ + }" + fn StringWriteToURL( gmpStr, fn URLFileURLWithPath( sourcePath ), YES, NSUTF8StringEncoding, NULL ) + + TaskRef task = fn TaskInit + TaskSetExecutableURL( task, fn URLFileURLWithPath( @"usr/bin/clang" ) ) + CFArrayRef arguments = @[@"-o", executablePath, sourcePath, @"-lgmp", @"-fobjc-arc"] + TaskSetArguments( task, arguments ) + PipeRef pipe = fn PipeInit + TaskSetStandardInput( task, pipe ) + fn TaskLaunch( task, NULL ) + TaskWaitUntilExit( task ) + + if ( fn TaskTerminationStatus( task ) == 0 ) + TaskRef executionTask = fn TaskInit + TaskSetExecutableURL( executionTask, fn URLFileURLWithPath( executablePath ) ) + PipeRef executionPipe = fn PipeInit + TaskSetStandardOutput( executionTask, executionPipe ) + FileHandleRef executionFileHandle = fn PipeFileHandleForReading( executionPipe ) + fn TaskLaunch( executionTask, NULL ) + TaskWaitUntilExit( executionTask ) + CFDataRef outputData = fn FileHandleReadDataToEndOfFile( executionFileHandle, NULL ) + CFStringRef outputStr = fn StringWithData( outputData, NSUTF8StringEncoding ) + NSLog( @"%@", outputStr ) + else + alert 1,, @"GMP required but not installed" + end if + + fn FileManagerRemoveItemAtURL( fn URLFileURLWithPath( sourcePath ) ) + fn FileManagerRemoveItemAtURL( fn URLFileURLWithPath( executablePath ) ) +end fn + +fn GMPoutput + +HandleEvents diff --git a/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur b/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur index 94c3c2d9ff..ac88ad929c 100644 --- a/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur +++ b/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur @@ -1,9 +1,9 @@ -val .xs = string 5 ^ 4 ^ 3 ^ 2 +val xs = string(5 ^ 4 ^ 3 ^ 2) -val .len = len .xs -writeln .len, " digits" +writeln len(xs), " digits" + +if len(xs) > 39 and s2s(xs, 1..20) == "62060698786608744707" and + s2s(xs, -20 .. -1) == "92256259918212890625" { -if .len > 39 and s2s(.xs, 1..20) == "62060698786608744707" and - s2s(.xs, .len-19 .. .len) == "92256259918212890625" { writeln "SUCCESS" } diff --git a/Task/Arena-storage-pool/Java/arena-storage-pool.java b/Task/Arena-storage-pool/Java/arena-storage-pool.java new file mode 100644 index 0000000000..2bfb0bc428 --- /dev/null +++ b/Task/Arena-storage-pool/Java/arena-storage-pool.java @@ -0,0 +1,19 @@ +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +public final class ArenaStoragePool { + + public static void main(String[] args) { + List storagePool = new ArrayList(); + storagePool.addLast(42); + storagePool.addLast("Hello World"); + storagePool.addFirst(BigInteger.ZERO); + + System.out.println(storagePool); + + storagePool = null; + System.gc(); + } + +} diff --git a/Task/Arithmetic-Complex/EasyLang/arithmetic-complex.easy b/Task/Arithmetic-Complex/EasyLang/arithmetic-complex.easy new file mode 100644 index 0000000000..2e8ba7e31a --- /dev/null +++ b/Task/Arithmetic-Complex/EasyLang/arithmetic-complex.easy @@ -0,0 +1,19 @@ +func[] add a[] b[] . + return [ a[1] + b[1] a[2] + b[2] ] +. +func[] mult a[] b[] . + return [ a[1] * b[1] - a[2] * b[2] a[1] * b[2] + a[2] * b[1] ] +. +func[] inv a[] . + denom = a[1] * a[1] + a[2] * a[2] + return [ a[1] / denom (-a[2] / denom) ] +. +func[] neg a[] . + return [ -a[1] (-a[2]) ] +. +a[] = [ 1 1 ] +b[] = [ pi 1.2 ] +print add a[] b[] +print mult a[] b[] +print neg a[] +print inv a[] diff --git a/Task/Arithmetic-Complex/PascalABC.NET/arithmetic-complex.pas b/Task/Arithmetic-Complex/PascalABC.NET/arithmetic-complex.pas new file mode 100644 index 0000000000..7a815bfcc7 --- /dev/null +++ b/Task/Arithmetic-Complex/PascalABC.NET/arithmetic-complex.pas @@ -0,0 +1,14 @@ +begin + var a := Cplx(1,2); + var b := Cplx(3,4); + Println(a + b); + Println(a - b); + Println(a * b); + Println(a / b); + Println(-a); + Println(1/a); + Println(a.Real,a.Imaginary); + Println(a.Conjugate); + Println(Abs(a)); + Println(a ** b); +end. diff --git a/Task/Arithmetic-Integer/EMal/arithmetic-integer.emal b/Task/Arithmetic-Integer/EMal/arithmetic-integer.emal index 88c6e2ec31..ace44f0c7e 100644 --- a/Task/Arithmetic-Integer/EMal/arithmetic-integer.emal +++ b/Task/Arithmetic-Integer/EMal/arithmetic-integer.emal @@ -23,7 +23,6 @@ fun main = int by List args writeLine("integer quotient: " + (a / b)) # truncates towards 0 writeLine("remainder: " + (a % b)) # matches sign of first operand writeLine("exponentiation: " + (a ** b)) - writeLine("logarithm: " + (a // b)) writeLine("divmod: " + divmod(a, b)) return 0 end diff --git a/Task/Arithmetic-Integer/PascalABC.NET/arithmetic-integer.pas b/Task/Arithmetic-Integer/PascalABC.NET/arithmetic-integer.pas new file mode 100644 index 0000000000..e67c8a33bb --- /dev/null +++ b/Task/Arithmetic-Integer/PascalABC.NET/arithmetic-integer.pas @@ -0,0 +1,10 @@ +begin + var (a,b) := ReadInteger2; + Println($'{a} + {b} = {a + b}'); + Println($'{a} - {b} = {a - b}'); + Println($'{a} * {b} = {a * b}'); + Println($'{a} / {b} = {a / b}'); + Println($'{a} div {b} = {a div b}'); + Println($'{a} mod {b} = {a mod b}'); + Println($'{a} ** {b} = {a ** b}'); +end. diff --git a/Task/Arithmetic-derivative/R/arithmetic-derivative.r b/Task/Arithmetic-derivative/R/arithmetic-derivative.r new file mode 100644 index 0000000000..e86c844300 --- /dev/null +++ b/Task/Arithmetic-derivative/R/arithmetic-derivative.r @@ -0,0 +1,31 @@ +library(gmp) #for big number factorization + +arithmetic_derivative<-function(x){ + if (x==0|x==1|x==-1){ + D=0 + } + else{ + n=ifelse(x<0,-x,x) + prime_decomposition <-as.numeric(factorize(n)) + if (length(prime_decomposition)==1){ + D<- 1 + } + else{ + D<-sum(prime_decomposition[c(1,2)]) + if (length(prime_decomposition)>2){ + cumulative_prod <-cumprod(prime_decomposition) + for (i in 3:length(prime_decomposition)){ + D<- D * prime_decomposition[i] + cumulative_prod[i-1] + } + } + } + + } + sign(x)*D +} + +print(t(matrix(sapply(-99:100,arithmetic_derivative),nrow=10))) + +for (k in 1:20){ + x <- 10**k + cat(paste0("D(",x,")/7 = ",arithmetic_derivative(x)/7,"\n"),sep = "")} diff --git a/Task/Arithmetic-geometric-mean-Calculate-Pi/Ada/arithmetic-geometric-mean-calculate-pi.ada b/Task/Arithmetic-geometric-mean-Calculate-Pi/Ada/arithmetic-geometric-mean-calculate-pi.ada new file mode 100644 index 0000000000..92bbf6746a --- /dev/null +++ b/Task/Arithmetic-geometric-mean-Calculate-Pi/Ada/arithmetic-geometric-mean-calculate-pi.ada @@ -0,0 +1,34 @@ +-- Use the Arithmetic-geometric mean to calculate Pi +-- J. Carter 2024 May + +with Ada.Numerics.Generic_Elementary_Functions; +with Ada.Text_IO; +with System; + +procedure AGM_Pi is + type Real is digits System.Max_Digits; + + package Math is new Ada.Numerics.Generic_Elementary_Functions (Float_Type => Real); + + A : Real := 1.0; + B : Real := Math.Sqrt (0.5); + T : Real := 0.25; + N : Real := 1.0; + Prev_A : Real; + Pi : Real; + Prev_Pi : Real := 0.0; +begin -- AGM_Pi + Calculate : loop + Prev_A := A; + A := (A + B) / 2.0; + B := Math.Sqrt (Prev_A * B); + T := T - N * (A - Prev_A) ** 2; + N := N + N; + Pi := (A + B) ** 2 / (4.0 * T); + Ada.Text_IO.Put_Line (Item => Pi'Image); + + exit Calculate when abs (Prev_Pi - Pi) < 10.0 ** (-(Real'Digits - 1) ); + + Prev_Pi := Pi; + end loop Calculate; +end AGM_Pi; diff --git a/Task/Arithmetic-geometric-mean/Uiua/arithmetic-geometric-mean.uiua b/Task/Arithmetic-geometric-mean/Uiua/arithmetic-geometric-mean.uiua new file mode 100644 index 0000000000..6a89ccb923 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Uiua/arithmetic-geometric-mean.uiua @@ -0,0 +1,3 @@ +# Calculate the arithmetic-geometric mean +Agm ← ⊙◌◌⍢(⊃(√×|÷2+)|<⌵-) +Agm 1 ÷:1√2 0.0000001 diff --git a/Task/Array-concatenation/Langur/array-concatenation.langur b/Task/Array-concatenation/Langur/array-concatenation.langur index 1ac9ef60b4..a94a31915b 100644 --- a/Task/Array-concatenation/Langur/array-concatenation.langur +++ b/Task/Array-concatenation/Langur/array-concatenation.langur @@ -1,4 +1,4 @@ -val .a = [1, 2, 3] -val .b = [7, 8, 9] -val .c = .a ~ .b -writeln .c +val a = [1, 2, 3] +val b = [7, 8, 9] +val c = a ~ b +writeln c diff --git a/Task/Array-concatenation/PascalABC.NET/array-concatenation.pas b/Task/Array-concatenation/PascalABC.NET/array-concatenation.pas new file mode 100644 index 0000000000..45499f1327 --- /dev/null +++ b/Task/Array-concatenation/PascalABC.NET/array-concatenation.pas @@ -0,0 +1,5 @@ +## +var a := |1,2,3,4|; +var b := Arr(5..8); +var c := a + b; +c.Println; diff --git a/Task/Array-concatenation/Uiua/array-concatenation.uiua b/Task/Array-concatenation/Uiua/array-concatenation.uiua new file mode 100644 index 0000000000..54cb6c7141 --- /dev/null +++ b/Task/Array-concatenation/Uiua/array-concatenation.uiua @@ -0,0 +1 @@ +⊂[1 2 3] [4 5 6] diff --git a/Task/Array-length/PascalABC.NET/array-length.pas b/Task/Array-length/PascalABC.NET/array-length-1.pas similarity index 100% rename from Task/Array-length/PascalABC.NET/array-length.pas rename to Task/Array-length/PascalABC.NET/array-length-1.pas diff --git a/Task/Array-length/PascalABC.NET/array-length-2.pas b/Task/Array-length/PascalABC.NET/array-length-2.pas new file mode 100644 index 0000000000..a804662be2 --- /dev/null +++ b/Task/Array-length/PascalABC.NET/array-length-2.pas @@ -0,0 +1,4 @@ +// Array length. Mikhalkovich Stanislav: May 16, 2024 +## +var a := |'apple','orange'|; +a.Length.Print; diff --git a/Task/Array-length/Uiua/array-length.uiua b/Task/Array-length/Uiua/array-length.uiua new file mode 100644 index 0000000000..cc0a198a7f --- /dev/null +++ b/Task/Array-length/Uiua/array-length.uiua @@ -0,0 +1 @@ +⧻{"apple" "orange"} diff --git a/Task/Arrays/Ada/arrays.ada b/Task/Arrays/Ada/arrays.ada index b713c838f7..b9a90bba0b 100644 --- a/Task/Arrays/Ada/arrays.ada +++ b/Task/Arrays/Ada/arrays.ada @@ -1,9 +1,10 @@ procedure Array_Test is - A, B : array (1..20) of Integer; + type Example_Array_Type is array (1..20) of Integer; + A, B : Example_Array_Type; -- Ada array indices may begin at any value, not just 0 or 1 - C : array (-37..20) of integer + C : array (-37..20) of Integer; -- Ada arrays may be indexed by enumerated types, which are -- discrete non-numeric types @@ -26,7 +27,7 @@ procedure Array_Test is Const : constant Arr := (1 .. 10 => 1, 11 .. 20 => 2, 21 | 22 => 3); Centered : Arr (-50..50) := (0 => 1, Others => 0); - Result : Integer + Result : Integer; begin A := (others => 0); -- Assign whole array @@ -37,7 +38,7 @@ begin A (3..5) := (2, 4, -1); -- Assign a constant slice A (3..5) := A (4..6); -- It is OK to overlap slices when assigned - Fingers_Extended'First := False; -- Set first element of array - Fingers_Extended'Last := False; -- Set last element of array + Fingers_Extended(Fingers'First) := False; -- Set first element of array + Fingers_Extended(Fingers'Last) := False; -- Set last element of array end Array_Test; diff --git a/Task/Arrays/Langur/arrays.langur b/Task/Arrays/Langur/arrays.langur index 3013d73448..5b0916e890 100644 --- a/Task/Arrays/Langur/arrays.langur +++ b/Task/Arrays/Langur/arrays.langur @@ -1,24 +1,24 @@ -var .a1 = [1, 2, 3, "abc"] -val .a2 = series 4..10 -val .a3 = .a1 ~ .a2 +var a1 = [1, 2, 3, "abc"] +val a2 = series(4..10) +val a3 = a1 ~ a2 writeln "initial values ..." -writeln ".a1: ", .a1 -writeln ".a2: ", .a2 -writeln ".a3: ", .a3 +writeln "a1: ", a1 +writeln "a2: ", a2 +writeln "a3: ", a3 writeln() -.a1[4] = .a2[4] -writeln "after setting .a1[4] = .a2[4] ..." -writeln ".a1: ", .a1 -writeln ".a2: ", .a2 -writeln ".a3: ", .a3 +a1[4] = a2[4] +writeln "after setting a1[4] = a2[4] ..." +writeln "a1: ", a1 +writeln "a2: ", a2 +writeln "a3: ", a3 writeln() -writeln ".a2[1]: ", .a2[1] +writeln "a2[1]: ", a2[1] writeln() writeln "using index alternate ..." -writeln ".a2[5; 0]: ", .a2[5; 0] -writeln ".a2[10; 0]: ", .a2[10; 0] +writeln "a2[5; 0]: ", a2[5; 0] +writeln "a2[10; 0]: ", a2[10; 0] writeln() diff --git a/Task/Arrays/PascalABC.NET/arrays.pas b/Task/Arrays/PascalABC.NET/arrays.pas new file mode 100644 index 0000000000..f62890edc5 --- /dev/null +++ b/Task/Arrays/PascalABC.NET/arrays.pas @@ -0,0 +1,19 @@ +begin + // Static old-style arrays + var a: array [1..3] of integer := (1,2,3); + Println(a[1]); + + // dynamic arrays - zero based indices + var a1: array of integer := new integer[3](1,3,5); + Println(a1[0]); + + // dynamic arrays + var a2 := |1,3,5|; // literal array + SetLength(a2,4); + a2[^1] := 7; // "push" new value; ^1 - the first element from the end + + // Lists are dynamically resizing arrays + var lst := new List(a1); + lst.Add(7); + Println(lst[^1]); +end. diff --git a/Task/Ascending-primes/Ada/ascending-primes.ada b/Task/Ascending-primes/Ada/ascending-primes.ada new file mode 100644 index 0000000000..f3cbb7f3fa --- /dev/null +++ b/Task/Ascending-primes/Ada/ascending-primes.ada @@ -0,0 +1,62 @@ +pragma Ada_2022; + +with Ada.Text_IO; +with Ada.Containers.Vectors; +with Fifo; + +procedure Ascending_Primes is + + subtype Prime is Positive range 2 .. Positive'Last with + Dynamic_Predicate => + (for all I in 2 .. (Prime / 2) => (Prime mod I) /= 0); + + package Prime_Vectors is new + Ada.Containers.Vectors + (Index_Type => Natural, + Element_Type => Prime); + + package Positive_Fifo is new Fifo (Positive); + use Positive_Fifo; + + -- Helper queue and vector for primes found + Queue : Fifo_Type; + Primes : Prime_Vectors.Vector; + +begin + -- Initialise the queue with the first nine numbers + for Index in 1 .. 9 loop + Queue.Push (Index); + end loop; + + -- Read the canditate numbers from the queue + -- check if they are prime and generate + -- the next possible candidates from them + while not Queue.Is_Empty loop + declare + Candidate : Positive; + Next_Digit : Positive; + begin + Queue.Pop (Candidate); + + if Candidate in Prime then + Primes.Append (Candidate); + end if; + + -- Generate the next possible candidates + -- from the current one + Next_Digit := Candidate mod 10 + 1; + while Next_Digit <= 9 loop + Queue.Push (Candidate * 10 + Next_Digit); + Next_Digit := @ + 1; + end loop; + + end; + end loop; + + -- Print the final list of prime numbers + for P of Primes loop + Ada.Text_IO.Put (P'Image); + end loop; + Ada.Text_IO.New_Line; + +end Ascending_Primes; diff --git a/Task/Ascending-primes/Uiua/ascending-primes.uiua b/Task/Ascending-primes/Uiua/ascending-primes.uiua new file mode 100644 index 0000000000..a92ef59960 --- /dev/null +++ b/Task/Ascending-primes/Uiua/ascending-primes.uiua @@ -0,0 +1,2 @@ +/◇⊂{⍥(/◇⊂≡(□+×10:↘+1◿10,⇡10).)8 +1⇡9} # Build ascending numbers. +⊏⊸⍏▽⊸≡(=1⧻°/×) # Find primes and sort. diff --git a/Task/Assertions/Ecstasy/assertions.ecstasy b/Task/Assertions/Ecstasy/assertions.ecstasy new file mode 100644 index 0000000000..12b6825568 --- /dev/null +++ b/Task/Assertions/Ecstasy/assertions.ecstasy @@ -0,0 +1,6 @@ +module test { + void run() { + Int x = 7; + assert x == 42; + } +} diff --git a/Task/Assertions/PascalABC.NET/assertions.pas b/Task/Assertions/PascalABC.NET/assertions.pas new file mode 100644 index 0000000000..ee22dd0991 --- /dev/null +++ b/Task/Assertions/PascalABC.NET/assertions.pas @@ -0,0 +1,5 @@ +begin + var a := 3; + Assert(a = 3); + Assert(a = 4, 'Bad assert!'); +end. diff --git a/Task/Associative-array-Creation/Langur/associative-array-creation.langur b/Task/Associative-array-Creation/Langur/associative-array-creation.langur index 86b466f1a4..0ae1824628 100644 --- a/Task/Associative-array-Creation/Langur/associative-array-creation.langur +++ b/Task/Associative-array-Creation/Langur/associative-array-creation.langur @@ -1,12 +1,12 @@ -var .hash = h{1: "abc", "1": 789} +var h = {1: "abc", "1": 789} # may assign with existing or non-existing hash key (if hash is mutable) -.hash[7] = 49 +h[7] = 49 -writeln .hash[1] -writeln .hash[7] -writeln .hash["1"] +writeln h[1] +writeln h[7] +writeln h["1"] # using an alternate value in case of invalid index; prevents exception -writeln .hash[1; 42] -writeln .hash[2; 42] +writeln h[1; 42] +writeln h[2; 42] diff --git a/Task/Associative-array-Creation/PascalABC.NET/associative-array-creation.pas b/Task/Associative-array-Creation/PascalABC.NET/associative-array-creation.pas new file mode 100644 index 0000000000..3c5b9e0348 --- /dev/null +++ b/Task/Associative-array-Creation/PascalABC.NET/associative-array-creation.pas @@ -0,0 +1,7 @@ +begin + var zoo := new Dictionary; + zoo['crocodile'] := 2; + zoo['jiraffe'] := 3; + zoo['behemoth'] := 1; + zoo.Println; +end. diff --git a/Task/Associative-array-Iteration/PascalABC.NET/associative-array-iteration.pas b/Task/Associative-array-Iteration/PascalABC.NET/associative-array-iteration.pas new file mode 100644 index 0000000000..0d9d5f7fa5 --- /dev/null +++ b/Task/Associative-array-Iteration/PascalABC.NET/associative-array-iteration.pas @@ -0,0 +1,11 @@ +begin + var zoo := new Dictionary; + zoo['crocodile'] := 2; + zoo['jiraffe'] := 3; + zoo['behemoth'] := 1; + foreach var kv in zoo do + Println(kv.Key, kv.Value); + Println; + foreach var key in zoo.Keys do + Println(key,zoo[key]); +end. diff --git a/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur b/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur index 6c700294e7..f313eb66b4 100644 --- a/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur +++ b/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur @@ -1,4 +1,4 @@ -val .mean = fn(.x) fold(fn{+}, .x) / len(.x) +val umean = fn x:fold(fn{+}, x) / len(x) -writeln " custom: ", .mean([7, 3, 12]) +writeln " custom: ", umean([7, 3, 12]) writeln "built-in: ", mean([7, 3, 12]) diff --git a/Task/Averages-Mean-time-of-day/Uiua/averages-mean-time-of-day.uiua b/Task/Averages-Mean-time-of-day/Uiua/averages-mean-time-of-day.uiua new file mode 100644 index 0000000000..291cc80510 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/Uiua/averages-mean-time-of-day.uiua @@ -0,0 +1,24 @@ +# Find mean time of day using 'mean angle' + +ParseTS ← setinv(/(+×60)⊜⋕≠@:.|/(◇⊂◇⊂)@:≡(□↙¯2⊂"00"°⋕)⌊[⍥(⊃÷◿60)2]) +RpS ← ×π÷180÷240 1 # Radians per second +SpD ← ×× 24 60 60 # Seconds per day +Cos ← setinv(∿+η|-:η°∿) +# Polar to (complex) cartesian, and inverse. +PtoC ← setinv( + ℂ⍜⊟×⊃∿Cos:°⊟ +| √+∩(×.),⟜:°ℂ + ⍤("undefined for r=0")≠0. + ⊟⟜(⍥¯<0:°Cos÷) +) + +Ts ← "23:00:17, 23:40:20, 00:12:45, 00:17:19" +⊜(PtoC ⊟1 ×RpS ParseTS)¬⦷", ".Ts # Get TSs as unit complex numbers. +⁅÷RpS⊡1°PtoC÷⊃(⧻|/+) # Average them and convert back to seconds. +°ParseTS+×SpD<0. # Ensure its >0, format as TS. + + +{{out}} +
+"23:47:43"
+
diff --git a/Task/Averages-Simple-moving-average/Jq/averages-simple-moving-average.jq b/Task/Averages-Simple-moving-average/Jq/averages-simple-moving-average.jq new file mode 100644 index 0000000000..f71cc8455e --- /dev/null +++ b/Task/Averages-Simple-moving-average/Jq/averages-simple-moving-average.jq @@ -0,0 +1,30 @@ +# The input should be a JSON object with a key named "period". +# The output is a JSON object with a key named "average" giving the SMA. +def sma($x): + def average: + .n as $n + | if $n == null or $n == 0 then . + {n: 1, average: $x} + else .average |= (. * $n + $x) / ($n + 1) + | .n += 1 + end; + + if . == null or (.period and .period < 1) + then "The initial call to sma/1 must specify the period properly" | error + elif .n and .n < 0 then "Invalid value of .n" | error + elif (.period | isinfinite) then average + elif .n == null or .n == 0 then . + {n: 1, average: $x, array: [$x]} + else .n as $n + | if $n < .period + then .array += [$x] + | .n += 1 + else .array |= .[1:] + [$x] + end + | .average = (.array | (add/length)) + end; + +# Call sma($x) for the 11 numbers 0, 1, ... 10. +def example($period): + reduce range(0;11) as $x({period: $period}; sma($x)) + | .average ; + +example(11), example(infinite) diff --git a/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-1.basic b/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-1.basic new file mode 100644 index 0000000000..f872c7192b --- /dev/null +++ b/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-1.basic @@ -0,0 +1,162 @@ +' The control points of a planar quadratic Bézier curve form a +' triangle--called the "control polygon"--that completely contains +' the curve. Furthermore, the rectangle formed by the minimum and +' maximum x and y values of the control polygon completely contain +' the polygon, and therefore also the curve. +' +' Thus a simple method for narrowing down where intersections might +' be is: subdivide both curves until you find "small enough" regions +' where these rectangles overlap. + +#define Min(a, b) iif((a) < (b), (a), (b)) +#define Max(a, b) iif((a) > (b), (a), (b)) + +' Note that these are all mutable as we need to pass by reference. +Type Punto + x As Double + y As Double +End Type + +Type QuadSpline + c0 As Double + c1 As Double + c2 As Double ' Non-parametric spline +End Type + +Type QuadCurve + x As QuadSpline + y As QuadSpline ' Planar parametric spline +End Type + +' Subdivision by de Casteljau's algorithm +Sub subdivideQuadSpline(q As QuadSpline, t As Double, u As QuadSpline, v As QuadSpline) + Dim As Double s = 1.0 - t + Dim As Double c0 = q.c0 + Dim As Double c1 = q.c1 + Dim As Double 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 +End Sub + +Sub subdivideQuadCurve(q As QuadCurve, t As Double, u As QuadCurve, v As QuadCurve) + subdivideQuadSpline(q.x, t, u.x, v.x) + subdivideQuadSpline(q.y, t, u.y, v.y) +End Sub + +' It is assumed that xa0 <= xa1, ya0 <= ya1, xb0 <= xb1, and yb0 <= yb1. +Function rectsOverlap(xa0 As Double, ya0 As Double, xa1 As Double, ya1 As Double, _ + xb0 As Double, yb0 As Double, xb1 As Double, yb1 As Double) As Boolean + Return (xb0 <= xa1 And xa0 <= xb1 And yb0 <= ya1 And ya0 <= yb1) +End Function + +Function max3(x As Double, y As Double, z As Double) As Double + Return Max(Max(x, y), z) +End Function + +Function min3(x As Double, y As Double, z As Double) As Double + Return Min(Min(x, y), z) +End Function + +' This accepts the point as an intersection if the boxes are small enough. +Sub testIntersect(p As QuadCurve, q As QuadCurve, tol As Double, _ + Byref exclude As Boolean, Byref accept As Boolean, Byref intersect As Punto) + Dim As Double pxmin = min3(p.x.c0, p.x.c1, p.x.c2) + Dim As Double pymin = min3(p.y.c0, p.y.c1, p.y.c2) + Dim As Double pxmax = max3(p.x.c0, p.x.c1, p.x.c2) + Dim As Double pymax = max3(p.y.c0, p.y.c1, p.y.c2) + + Dim As Double qxmin = min3(q.x.c0, q.x.c1, q.x.c2) + Dim As Double qymin = min3(q.y.c0, q.y.c1, q.y.c2) + Dim As Double qxmax = max3(q.x.c0, q.x.c1, q.x.c2) + Dim As Double qymax = max3(q.y.c0, q.y.c1, q.y.c2) + exclude = True + accept = False + If rectsOverlap(pxmin, pymin, pxmax, pymax, qxmin, qymin, qxmax, qymax) Then + exclude = False + Dim As Double xmin = Max(pxmin, qxmin) + Dim As Double xmax = Min(pxmax, qxmax) + Assert(xmax >= xmin) + If xmax - xmin <= tol Then + Dim As Double ymin = Max(pymin, qymin) + Dim As Double ymax = Min(pymax, qymax) + Assert(ymax >= ymin) + If ymax - ymin <= tol Then + accept = True + intersect.x = 0.5 * xmin + 0.5 * xmax + intersect.y = 0.5 * ymin + 0.5 * ymax + End If + End If + End If +End Sub + +Function seemsToBeDuplicate(intersects() As Punto, icount As Integer, _ + xy As Punto, spacing As Double) As Boolean + Dim As Boolean seemsToBeDup = False + Dim As Integer i = 0 + While Not seemsToBeDup And i <> icount + Dim As Punto pt = intersects(i) + seemsToBeDup = Abs(pt.x - xy.x) < spacing And Abs(pt.y - xy.y) < spacing + i += 1 + Wend + Return seemsToBeDup +End Function + +Sub findIntersects(p As QuadCurve, q As QuadCurve, tol As Double, _ + spacing As Double, intersects() As Punto) + Dim As Integer numIntersects = 0 + Type workset + p As QuadCurve + q As QuadCurve + End Type + Dim As workset workload(64) + Dim As Integer numWorksets = 1 + workload(0) = Type(p, q) + + ' Quit looking after having emptied the workload. + While numWorksets <> 0 + Dim As workset work = workload(numWorksets-1) + numWorksets -= 1 + Dim As Boolean exclude, accept + Dim As Punto intersect + testIntersect(work.p, work.q, tol, exclude, accept, intersect) + If accept Then + ' To avoid detecting the same intersection twice, require some + ' space between intersections. + If Not seemsToBeDuplicate(intersects(), numIntersects, intersect, spacing) Then + intersects(numIntersects) = intersect + numIntersects += 1 + End If + Elseif Not exclude Then + Dim As QuadCurve p0, p1, q0, q1 + subdivideQuadCurve(work.p, 0.5, p0, p1) + subdivideQuadCurve(work.q, 0.5, q0, q1) + workload(numWorksets) = Type(p0, q0) + numWorksets += 1 + workload(numWorksets) = Type(p0, q1) + numWorksets += 1 + workload(numWorksets) = Type(p1, q0) + numWorksets += 1 + workload(numWorksets) = Type(p1, q1) + numWorksets += 1 + End If + Wend +End Sub + +Dim As QuadCurve p, q +p.x = Type(-1.0, 0.0, 1.0) +p.y = Type( 0.0, 10.0, 0.0) +q.x = Type( 2.0, -8.0, 2.0) +q.y = Type( 1.0, 2.0, 3.0) +Dim As Double tol = 0.0000001 +Dim As Double spacing = tol * 10.0 +Dim As Punto intersects(4) +findIntersects(p, q, tol, spacing, intersects()) +For i As Integer = 0 To 3 + Print "("; intersects(i).x; ", "; intersects(i).y; ")" +Next i + +Sleep diff --git a/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-2.basic b/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-2.basic new file mode 100644 index 0000000000..41eedb795f --- /dev/null +++ b/Task/B-zier-curves-Intersections/FreeBASIC/b-zier-curves-intersections-2.basic @@ -0,0 +1,215 @@ +' In this program, both of the curves are adaptively "flattened": +' that is, converted to a piecewise linear approximation. Then the +' problem is reduced to finding intersections of line segments. +' +' How efficient or inefficient the method is I will not try to answer. +' (And I do sometimes compute things "too often", although a really good +' optimizer might fix that.) +' +' I will use the symmetric power basis that was introduced by J. Sánchez-Reyes: +' +' J. Sánchez-Reyes, ‘The symmetric analogue of the polynomial power +' basis’, ACM Transactions on Graphics, vol 16 no 3, July 1997, page 319. +' +' J. Sánchez-Reyes, ‘Applications of the polynomial s-power basis +' in geometry processing’, ACM Transactions on Graphics, vol 19 +' no 1, January 2000, page 35. +' +' Flattening a quadratic that is represented in this basis has a few +' advantages, which I will not go into here. */ + +Type bernstein_spline + b0 As Double + b1 As Double + b2 As Double +End Type + +Type spower_spline + c0 As Double + c1 As Double + c2 As Double +End Type + +Type spower_curve + x As spower_spline + y As spower_spline +End Type + +' Convert a non-parametric spline from Bernstein basis to s-power. +Function bernstein_spline_to_spower(S As bernstein_spline) As spower_spline + Dim As spower_spline T + T.c0 = S.b0 + T.c1 = (2 * S.b1) - S.b0 - S.b2 + T.c2 = S.b2 + Return T +End Function + +' Compose (c0, c1, c2) with (t0, t1). This will map the portion [t0,t1] onto +' [0,1]. (To get these expressions, I did not use the general-degree methods +' described by Sánchez-Reyes, but instead used Maxima, some while ago.) +' +' This method is an alternative to de Casteljau subdivision, and can be done +' with the coefficients in any basis. Instead of breaking the spline into two +' pieces at a parameter value t, it gives you the portion lying between two +' parameter values. In general that requires two applications of de Casteljau +' subdivision. On the other hand, subdivision requires two applications of the +' following. +Function spower_spline_portion(S As spower_spline, t0 As Double, t1 As Double) As spower_spline + Dim As Double t0_t0 = t0 * t0 + Dim As Double t0_t1 = t0 * t1 + Dim As Double t1_t1 = t1 * t1 + Dim As Double c2p1m0 = S.c2 + S.c1 - S.c0 + + Dim As spower_spline T + T.c0 = S.c0 + (c2p1m0 * t0) - (S.c1 * t0_t0) + T.c1 = (S.c1 * t1_t1) - (2 * S.c1 * t0_t1) + (S.c1 * t0_t0) + T.c2 = S.c0 + (c2p1m0 * t1) - (S.c1 * t1_t1) + Return T +End Function + +Function spower_curve_portion(C As spower_curve, t0 As Double, t1 As Double) As spower_curve + Dim As spower_curve D + D.x = spower_spline_portion(C.x, t0, t1) + D.y = spower_spline_portion(C.y, t0, t1) + Return D +End Function + +' Given a parametric curve, is it "flat enough" to have its quadratic +' terms removed? +Function flat_enough(C As spower_curve, tol As Double) As Boolean + ' The degree-2 s-power polynomials are 1-t, t(1-t), t. We want to + ' remove the terms in t(1-t). The maximum of t(1-t) is 1/4, reached + ' at t=1/2. That accounts for the 1/8=0.125 in the following: + Dim As Double cx0 = C.x.c0 + Dim As Double cx1 = C.x.c1 + Dim As Double cx2 = C.x.c2 + Dim As Double cy0 = C.y.c0 + Dim As Double cy1 = C.y.c1 + Dim As Double cy2 = C.y.c2 + Dim As Double dx = cx2 - cx0 + Dim As Double dy = cy2 - cy0 + Dim As Double error_squared = 0.125 * ((cx1 * cx1) + (cy1 * cy1)) + Dim As Double length_squared = (dx * dx) + (dy * dy) + Return (error_squared <= length_squared * tol * tol) +End Function + +' Given two line segments, do they intersect? One solution to this problem is +' to use the implicitization method employed in the Maxima example, except to +' do it with linear instead of quadratic curves. That is what I do here, with +' the the roles of who gets implicitized alternated. If both ways you get as +' answer a parameter in [0,1], then the segments intersect. +Sub test_line_segment_intersection(ax0 As Double, ax1 As Double, _ + ay0 As Double, ay1 As Double, bx0 As Double, bx1 As Double, _ + by0 As Double, by1 As Double, Byref they_intersect As Boolean, _ + Byref x As Double, Byref y As Double) + Dim As Double anumer = ((bx1 - bx0) * ay0 - (by1 - by0) * ax0 _ + + bx0 * by1 - bx1 * by0) + Dim As Double bnumer = -((ax1 - ax0) * by0 - (ay1 - ay0) * bx0 _ + + ax0 * ay1 - ax1 * ay0) + Dim As Double denom = ((ax1 - ax0) * (by1 - by0) _ + - (ay1 - ay0) * (bx1 - bx0)) + Dim As Double ta = anumer / denom ' Parameter of segment a. + Dim As Double tb = bnumer / denom ' Parameter of segment b. + they_intersect = (0 <= ta And ta <= 1 And 0 <= tb And tb <= 1) + If they_intersect Then + x = ((1 - ta) * ax0) + (ta * ax1) + y = ((1 - ta) * ay0) + (ta * ay1) + End If +End Sub + +Function too_close(x As Double, y As Double, xs() As Double, ys() As Double, _ + num_points As Integer, spacing As Double) As Boolean + Dim As Boolean tooclose = False + Dim As Integer i = 0 + While Not tooclose And i <> num_points + tooclose = (Abs(x - xs(i)) < spacing And Abs(y - ys(i)) < spacing) + i += 1 + Wend + Return tooclose +End Function + +Sub recursion(tp0 As Double, tp1 As Double, tq0 As Double, tq1 As Double, _ + P As spower_curve, Q As spower_curve, tol As Double, spacing As Double, _ + max_points As Integer, xs() As Double, ys() As Double, Byref num_points As Integer) + If num_points = max_points Then + ' do nothing + Elseif Not flat_enough(spower_curve_portion(P, tp0, tp1), tol) Then + Dim As Double tp_half = (0.5 * tp0) + (0.5 * tp1) + If Not flat_enough(spower_curve_portion(Q, tq0, tq1), tol) Then + Dim As Double tq_half = (0.5 * tq0) + (0.5 * tq1) + recursion(tp0, tp_half, tq0, tq_half, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + recursion(tp0, tp_half, tq_half, tq1, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + recursion(tp_half, tp1, tq0, tq_half, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + recursion(tp_half, tp1, tq_half, tq1, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + Else + recursion(tp0, tp_half, tq0, tq1, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + recursion(tp_half, tp1, tq0, tq1, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + End If + Elseif Not flat_enough(spower_curve_portion(Q, tq0, tq1), tol) Then + Dim As Double tq_half = (0.5 * tq0) + (0.5 * tq1) + recursion(tp0, tp1, tq0, tq_half, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + recursion(tp0, tp1, tq_half, tq1, P, Q, tol, _ + spacing, max_points, xs(), ys(), num_points) + Else + Dim As spower_curve P1 = spower_curve_portion(P, tp0, tp1) + Dim As spower_curve Q1 = spower_curve_portion(Q, tq0, tq1) + Dim As Boolean they_intersect + Dim As Double x, y + test_line_segment_intersection(P1.x.c0, P1.x.c2, _ + P1.y.c0, P1.y.c2, _ + Q1.x.c0, Q1.x.c2, _ + Q1.y.c0, Q1.y.c2, _ + they_intersect, x, y) + If they_intersect And Not too_close(x, y, xs(), ys(), num_points, spacing) Then + xs(num_points) = x + ys(num_points) = y + num_points += 1 + End If +End If +End Sub + +Sub find_intersections(P As spower_curve, Q As spower_curve, _ + flatness_tolerance As Double, point_spacing As Double, _ + max_points As Integer, xs() As Double, ys() As Double, _ + Byref num_points As Integer) + num_points = 0 + recursion(0, 1, 0, 1, P, Q, flatness_tolerance, point_spacing, _ + max_points, xs(), ys(), num_points) +End Sub + +Dim As bernstein_spline bPx = Type(-1, 0, 1) +Dim As bernstein_spline bPy = Type(0, 10, 0) +Dim As bernstein_spline bQx = Type(2, -8, 2) +Dim As bernstein_spline bQy = Type(1, 2, 3) + +Dim As spower_spline Px = bernstein_spline_to_spower(bPx) +Dim As spower_spline Py = bernstein_spline_to_spower(bPy) +Dim As spower_spline Qx = bernstein_spline_to_spower(bQx) +Dim As spower_spline Qy = bernstein_spline_to_spower(bQy) + +Dim As spower_curve P = Type(Px, Py) +Dim As spower_curve Q = Type(Qx, Qy) + +Dim As Double flatness_tolerance = 0.001 +Dim As Double point_spacing = 0.000001 ' Max norm minimum spacing. + +Const max_points As Integer = 10 +Dim As Double xs(max_points) +Dim As Double ys(max_points) +Dim As Integer num_points + +find_intersections(P, Q, flatness_tolerance, point_spacing, _ +max_points, xs(), ys(), num_points) + +For i As Integer = 0 To num_points - 1 + Print "("; xs(i); ", "; ys(i); ")" +Next i + +Sleep diff --git a/Task/Babbage-problem/EMal/babbage-problem.emal b/Task/Babbage-problem/EMal/babbage-problem.emal new file mode 100644 index 0000000000..8b22bbe9f6 --- /dev/null +++ b/Task/Babbage-problem/EMal/babbage-problem.emal @@ -0,0 +1,9 @@ +^| + | Since the number must end with 269696 we can safely start counting from its square root; + | we are only interested in its integer part. + | We assign a value to a variable with "←". + | The modulo symbol for getting the remainder of a division is "%". + |^ +int i ← int!√269696 +while i² % 1000000 ≠ 269696 do ++i end +writeLine(i) diff --git a/Task/Babbage-problem/Langur/babbage-problem.langur b/Task/Babbage-problem/Langur/babbage-problem.langur new file mode 100644 index 0000000000..688d15f17d --- /dev/null +++ b/Task/Babbage-problem/Langur/babbage-problem.langur @@ -0,0 +1,6 @@ +for i = 2; i < 100000 ; i += 2 { + if i*i rem 1000000 == 269696 { + writeln "{{i}} ^ 2 == {{i^2}}" + break + } +} diff --git a/Task/Balanced-brackets/PascalABC.NET/balanced-brackets.pas b/Task/Balanced-brackets/PascalABC.NET/balanced-brackets.pas new file mode 100644 index 0000000000..f40f52b72a --- /dev/null +++ b/Task/Balanced-brackets/PascalABC.NET/balanced-brackets.pas @@ -0,0 +1,29 @@ +function GenBracketExpr(n: integer): string; +begin + var a := Arr('[',']')*n; + Shuffle(a); + Result := a.JoinToString +end; + +function IsBalanced(s: string): boolean; +begin + Result := True; + var st := new Stack; + foreach var c in s do + if c = '[' then + st.Push(c) + else if (st.Count > 0) and (st.Peek = '[') then + st.Pop + else begin + Result := False; + exit + end; +end; + +begin + loop 10 do + begin + var s := GenBracketExpr(Random(2,5)); + Println(s, IsBalanced(s)); + end; +end. diff --git a/Task/Barnsley-fern/Uiua/barnsley-fern.uiua b/Task/Barnsley-fern/Uiua/barnsley-fern.uiua new file mode 100644 index 0000000000..a2d94aeac6 --- /dev/null +++ b/Task/Barnsley-fern/Uiua/barnsley-fern.uiua @@ -0,0 +1,11 @@ +Fs ← [[[0 0 0] [0 0.16 0]] + [[0.85 0.04 0] [¯0.04 0.85 1.6]] + [[0.2 ¯0.26 0] [0.23 0.22 1.6]] + [[¯0.15 0.28 0] [0.26 0.24 0.44]]] +Ps ← [1 86 93 100] +PickF ← (⊡:Fs⊢⊚ x).named("y", "x") + x++ + if x æ side + x ← 0 + y++ + end + end + end + fun asText = text by block + text result = "" + for int y ← 0; y < me.grid.length; y++ + for int x ← 0; x < me.grid[y].length; x++ + result.append(" " + me.grid[y][x]) + end + result.appendLine() + end + return result + end +end +type BifidCipher +model + PolybiusSquare square + new by PolybiusSquare ←square do end + fun encrypt ← text by text value + List row ← int[].with(value.length * 2) + int y ← 0 + int x ← value.length + for each text char in value + Pair p ← me.square.map[char] + row[y++] ← p.y + row[x++] ← p.x + end + text encrypted + for int i ← 0; i < row.length; i += 2 + encrypted.append(me.square.grid[row[i]][row[i + 1]]) + end + return encrypted + end + fun decrypt ← text by text value + List row ← int[] + for each text char in value + Pair p ← me.square.map[char] + row.append(p.y) + row.append(p.x) + end + int y ← 0 + int x ← value.length + text decrypted + for int i ← 0; i < value.length; i++ + decrypted.append(me.square.grid[row[y++]][row[x++]]) + end + return decrypted + end +end +type Main +List pairs ← Pair[ + text%PolybiusSquare("ATTACKATDAWN" => PolybiusSquare(5, "ABCDEFGHIKLMNOPQRSTUVWXYZ")).named("sample", "square"), + text%PolybiusSquare("FLEEATONCE" => PolybiusSquare(5, "BGWKZQPNDSIOAXEFCLUMTHYVR")).named("sample", "square"), + text%PolybiusSquare("ATTACKATDAWN" => PolybiusSquare(5, "BGWKZQPNDSIOAXEFCLUMTHYVR")).named("sample", "square"), + text%PolybiusSquare("The invasion will start on the first of January".upper().replace(" ", "") => + PolybiusSquare(6, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")).named("sample", "square")] +for each Pair pair in pairs + writeLine("Using Polybius square:") + write(pair.square) + BifidCipher cipher ← BifidCipher(pair.square) + write("Encrypting '" + pair.sample + "'") + text encrypted ← cipher.encrypt(pair.sample) + write(" => '" + encrypted + "'") + text decrypted ← cipher.decrypt(encrypted) + writeLine(" => '" + decrypted + "'") + writeLine() +end diff --git a/Task/Bifid-cipher/Uiua/bifid-cipher-1.uiua b/Task/Bifid-cipher/Uiua/bifid-cipher-1.uiua new file mode 100644 index 0000000000..7a2d0a35ce --- /dev/null +++ b/Task/Bifid-cipher/Uiua/bifid-cipher-1.uiua @@ -0,0 +1,9 @@ +S ← "ABCDEFGHIKLMNOPQRSTUVWXYZ" +P ← ↯⊟.√⧻.S +Prep ← ▽∊:S.∧⍜⊡⋅@I⊚⌕@J.⌵ +Bifid ← setinv( + ⊡:⟜(↯∞_2/⊂⇌⍉≡(⊢⊚⌕)Prep:¤)P +| ⊡:⟜(⍉⇌↯2_∞/⊂≡(⊢⊚⌕):¤)P +) +°Bifid.Bifid. "This is it" +°Bifid.Bifid. "The invasion will start on the first of January" diff --git a/Task/Bifid-cipher/Uiua/bifid-cipher-2.uiua b/Task/Bifid-cipher/Uiua/bifid-cipher-2.uiua new file mode 100644 index 0000000000..c9ef4c623e --- /dev/null +++ b/Task/Bifid-cipher/Uiua/bifid-cipher-2.uiua @@ -0,0 +1,9 @@ +S ← "GLYPHABCDEFIJKMNOQRSTUVWXZ0123456789" +P ← ↯⊟.√⧻.S +Prep ← ▽∊:S.⌵ +Bifid ← setinv( + ⊡:⟜(↯∞_2/⊂⇌⍉≡(⊢⊚⌕)Prep:¤)P +| ⊡:⟜(⍉⇌↯2_∞/⊂≡(⊢⊚⌕):¤)P +) +°Bifid.Bifid. "This is it" +°Bifid.Bifid. "The invasion will start at 0600 on the 1st of January" diff --git a/Task/Bin-given-limits/Free-Pascal-Lazarus/bin-given-limits.pas b/Task/Bin-given-limits/Free-Pascal-Lazarus/bin-given-limits.pas new file mode 100644 index 0000000000..393a72a5e5 --- /dev/null +++ b/Task/Bin-given-limits/Free-Pascal-Lazarus/bin-given-limits.pas @@ -0,0 +1,56 @@ +Program bin_given_limits; + +const + limits1: array of integer = (23, 37, 43, 53, 67, 83); + data1: array of integer = (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); + limits2: array of integer = (14, 18, 249, 312, 389, 392, 513, 591, 634, 720); + data2: array of integer = (445, 814, 519, 697, 700, 130, 255, 889, 481, 122, + 932, 77, 323, 525, 570, 219, 367, 523, 442, 933, 416, 589, 930, 373, 202, + 253, 775, 47, 731, 685, 293, 126, 133, 450, 545, 100, 741, 583, 763, 306, + 655, 267, 248, 477, 549, 238, 62, 678, 98, 534, 622, 907, 406, 714, 184, + 391, 913, 42, 560, 247, 346, 860, 56, 138, 546, 38,985, 948, 58, 213, 799, + 319, 390, 634, 458, 945, 733, 507, 916, 123, 345, 110, 720, 917, 313, 845, + 426, 9, 457, 628, 410, 723, 354, 895, 881, 953, 677, 137, 397, 97, 854, 740, + 83, 216, 421, 94, 517, 479, 292, 963, 376, 981, 480, 39, 257, 272, 157, 5, + 316, 395, 787, 942, 456, 242, 759, 898, 576, 67, 298, 425, 894, 435, 831, + 241, 989, 614, 987, 770, 384, 692, 698, 765, 331, 487, 251, 600, 879, 342, + 982, 527, 736, 795, 585, 40, 54, 901, 408, 359, 577, 237, 605, 847, 353, + 968, 832, 205, 838, 427, 876, 959, 686, 646, 835, 127, 621, 892, 443, 198, + 988, 791, 466, 23, 707, 467, 33, 670, 921, 180, 991, 396, 160, 436, 717, + 918, 8, 374, 101, 684, 727, 749); + + procedure print_bins(bins, limits: array of integer); + var + i: integer; + begin + writeln(' < ', limits[0]: 3, ' := ', bins[0]: 2); + for i := 0 to high(bins) - 2 do + writeln('>= ', limits[i]: 3, ' .. < ', limits[i + 1]: 3, ' := ', bins[i + 1]: 2); + writeln('>= ', limits[high(limits)]: 3, ' := ', bins[high(bins)]: 2); + end; + + procedure do_bins(limits, Data: array of integer); + var + bins: array of integer; + i, b: integer; + begin + setlength(bins, high(limits) + 2); + for i in Data do + if i < limits[0] then Inc(bins[0]) + else + begin + for b := 1 to high(limits) do + if ((i >= limits[b - 1]) and (i < limits[b])) then Inc(bins[b]); + if i >= limits[high(limits)] then + Inc(bins[high(bins)]); + end; + print_bins(bins, limits); + end; + +begin + do_bins(limits1, data1); + writeln; + do_bins(limits2, data2); +end. diff --git a/Task/Binary-digits/PascalABC.NET/binary-digits.pas b/Task/Binary-digits/PascalABC.NET/binary-digits.pas new file mode 100644 index 0000000000..b64947cea0 --- /dev/null +++ b/Task/Binary-digits/PascalABC.NET/binary-digits.pas @@ -0,0 +1,4 @@ +begin + foreach var number in |5, 50, 9000| do + Writeln($'{number,4} - {Convert.ToString(number,2)}'); +end. diff --git a/Task/Binary-digits/Uiua/binary-digits.uiua b/Task/Binary-digits/Uiua/binary-digits.uiua new file mode 100644 index 0000000000..046c62302b --- /dev/null +++ b/Task/Binary-digits/Uiua/binary-digits.uiua @@ -0,0 +1,2 @@ +GetBits ← &pf@\n≡&pf ⇌⋯ +≡GetBits 5_50_9000 diff --git a/Task/Binary-search/Chapel/binary-search.chapel b/Task/Binary-search/Chapel/binary-search.chapel index c03efcb729..e5ab05d298 100644 --- a/Task/Binary-search/Chapel/binary-search.chapel +++ b/Task/Binary-search/Chapel/binary-search.chapel @@ -1,7 +1,9 @@ -proc binsearch(A:[], value) { - var low = A.domain.dim(1).low; - var high = A.domain.dim(1).high; - while (low <= high) { +proc binsearch(A : [], value) +{ + var low = A.domain.dim(0).low; + var high = A.domain.dim(0).high; + while (low <= high) + { var mid = (low + high) / 2; if A(mid) > value then diff --git a/Task/Binary-search/PascalABC.NET/binary-search.pas b/Task/Binary-search/PascalABC.NET/binary-search.pas new file mode 100644 index 0000000000..40e56953b1 --- /dev/null +++ b/Task/Binary-search/PascalABC.NET/binary-search.pas @@ -0,0 +1,61 @@ +function BinarySearch(a: array of integer; x: integer): integer; +begin + var (l,r) := (0, a.Length-1); + repeat + var mid := (l + r) div 2; + if x = a[mid] then + begin + Result := mid; + exit + end; + if x > a[mid] then + l := mid + 1 + else r := mid - 1; + until l > r; + Result := -1; +end; + +function BinarySearchRecursive(a: array of integer; x: integer): integer; + function BinarySearchHelper(a: array of integer; x: integer; l,r: integer): integer; + begin + if l > r then + Result := -1 + else begin + var mid := (l + r) div 2; + if x = a[mid] then + Result := mid + else if x < a[mid] then + Result := BinarySearchHelper(a, x, l, mid - 1) + else Result := BinarySearchHelper(a, x, mid + 1, r) + end; + end; +begin + Result := BinarySearchHelper(a,x,0,a.Length-1); +end; + +begin + var a := ArrRandomInteger(10,1,20); + a.Sort; + a.Println; + var x := 10; + var ind := BinarySearch(a,x); + if ind >= 0 then + Println($'{x} found at index {ind}') + else Println($'{x} not found'); + + ind := BinarySearchRecursive(a,x); + if ind >= 0 then + Println($'{x} found at index {ind}') + else Println($'{x} not found'); + + x := a.RandomElement; + ind := BinarySearch(a,x); + if ind >= 0 then + Println($'{x} found at index {ind}') + else Println($'{x} not found'); + + ind := BinarySearchRecursive(a,x); + if ind >= 0 then + Println($'{x} found at index {ind}') + else Println($'{x} not found'); +end. diff --git a/Task/Biorhythms/FutureBasic/biorhythms.basic b/Task/Biorhythms/FutureBasic/biorhythms.basic new file mode 100644 index 0000000000..2d27b3e9b9 --- /dev/null +++ b/Task/Biorhythms/FutureBasic/biorhythms.basic @@ -0,0 +1,110 @@ +/* +Biorhythms task for Rosetta Code +https://rosettacode.org/wiki/Biorhythms + +Translated from FreeBasic to FutureBasic +Rich Love May 24, 2024 + +*/ + + + +local fn Gregorian(db As str255) As short + short M, Y, D + Y = val(Left$(db,4)) : M = Val(Mid$(db,6,2)) : D = Val(Right$(db,2)) + short N = (M+9) - Int((M+9)/12) * 12 + short W = Y - Int(N/10) + short G = 365 * W + Int(W/4) - Int(W/100) + Int(W/400) + G += Int((N*306+5)/10)+(D-1) +end fn = G + + +void local fn Biorhythm(Birthdate As str255, Targetdate As str255) + + str255 TextArray(4,2) + TextArray(0,0) = "up and rising" + TextArray(1,0) = "up but falling" + TextArray(2,0) = "down and falling" + TextArray(3,0) = "down but rising" + TextArray(0,1) = "peak" + TextArray(1,1) = "transition" + TextArray(2,1) = "valley" + TextArray(3,1) = "transition" + + + short DaysBetween = fn Gregorian(Targetdate) - fn Gregorian(Birthdate) + 1 + short positionP = DaysBetween Mod 23 + short positionE = DaysBetween Mod 28 + short positionM = DaysBetween Mod 33 + short quadrantP = Int(4 * positionP / 23) + short quadrantE = Int(4 * positionE / 28) + short quadrantM = Int(4 * positionM / 33) + short percentageP = Fix(100 * Sin(2 * (pi * positionP) / 23)) + short percentageE = Fix(100 * Sin(2 * (pi * positionE) / 28)) + short percentageM = Fix(100 * Sin(2 * (pi * positionM) / 33)) + + str255 textP, textE, textM, Header1Text, Header2Text + + + Select Case percentageP + Case > 95 + textP = "Physical day " + str$(positionP) + " : " + "peak" + Case < -95 + textP = "Physical day " + str$(positionP) + " : " + "valley" + Case -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 + textP = "Physical day " + str$(positionP) + " : " + "critical transition" + Case Else + textP = "Physical day " + str$(positionP) + " : " + str$(percentageP) + "% (" + TextArray(quadrantP,0) + ")" + End Select + + Select Case percentageE + Case > 95 + textE = "Emotional day " + STR$(positionE) + " : " + "peak" + Case < -95 + textE = "Emotional day " + STR$(positionE) + " : " + "valley" + Case -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 + textE = "Emotional day " + STR$(positionE) + " : " + "critical transition" + Case Else + textE = "Emotional day " + STR$(positionE) + " : " + str$(percentageE) + "% (" + TextArray(quadrantE,0) + ")" + End Select + + Select Case percentageM + Case > 95 + textM = "Mental day " + str$(positionM)+ " : " + "peak" + Case < - 95 + textM = "Mental day " + str$(positionM) + " : " + "valley" + Case -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 + textM = "Mental day " + str$(positionM) + " : " + "critical transition" + Case Else + textM = "Mental day " + str$(positionM) + " : " + str$(percentageM) + "% (" + TextArray(quadrantM,0) + ")" + End Select + + Header1Text = "Born " + Birthdate + ", Target " + Targetdate + Header2Text = "Day " + str$(DaysBetween) + + Print Header1Text + Print Header2Text + Print textP + Print textE + Print textM + Print +end fn + +window 1, @"Biorhythms" +windowcenter(1) +WindowSetBackgroundColor(1,fn ColorBlack) + +print + +// Lets do four different birthdates and target dates +text ,,fn colorCyan +fn Biorhythm("1943-03-09", "1972-07-11") +text ,,fn colorGreen +fn Biorhythm("1809-02-12", "1863-11-19") // DOB for Abraham Lincoln +text ,,fn colorYellow +fn Biorhythm("1809-01-12", "1863-11-19") +text ,,fn colorWhite +fn Biorhythm("1943-03-09", "1972-07-11") // Bobby Fisher Chess Tournament + + +handleevents diff --git a/Task/Bitcoin-address-validation/C++/bitcoin-address-validation.cpp b/Task/Bitcoin-address-validation/C++/bitcoin-address-validation.cpp new file mode 100644 index 0000000000..654b6e7721 --- /dev/null +++ b/Task/Bitcoin-address-validation/C++/bitcoin-address-validation.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "SHA256.cpp" +SHA256 sha256{ }; + +const std::string ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + +std::map base_map = + { { '0', 0 }, { '1', 1 }, { '2', 2 }, { '3', 3 }, { '4', 4 }, { '5', 5 }, { '6', 6 }, { '7', 7 }, + { '8', 8 }, { '9', 9 }, { 'a', 10 }, { 'b', 11 }, { 'c', 12 }, { 'd', 13 }, { 'e', 14 }, { 'f', 15 }, + { 'A', 10 }, { 'B', 11 }, { 'C', 12 }, { 'D', 13 }, { 'E', 14 }, { 'F', 15 } }; + +std::vector hex_to_bytes(const std::string& text) { + std::vector bytes(text.size() / 2, 0); + for ( uint64_t i = 0; i < text.size(); i += 2 ) { + const uint32_t first_digit = base_map[text[i]]; + const uint32_t second_digit = base_map[text[i + 1]]; + bytes[i / 2] = ( first_digit << 4 ) + second_digit; + } + return bytes; +} + +std::string vector_to_ascii_string(const std::vector& bytes) { + std::string result = ""; + for ( uint32_t i = 0; i < bytes.size(); ++i ) { + result += static_cast(bytes[i]); + } + return result; +} + +std::vector decode_base_58(const std::string& text) { + std::vector result(25, 0); + for ( const char& ch : text ) { + std::string::size_type index = ALPHABET.find(ch); + if ( index == static_cast(-1) ) { + throw std::invalid_argument("Invalid character found in bitcoin address"); + } + for ( uint64_t i = result.size() - 1; i > 0; i-- ) { + index += 58 * result[i]; + result[i] = index & 0xFF; + index >>= 8; + } + if ( index != 0 ) { + throw std::invalid_argument("Bitcoin address is too long"); + } + } + return result; +} + +bool is_valid(const std::string& address) { + if ( address.size() < 26 || address.size() > 35 ) { + throw std::invalid_argument("Invalid length of bitcoin address"); + } + + std::vector decoded = decode_base_58(address); + std::vector first21(decoded.begin(), decoded.begin() + 21); + + // Convert the 'first21' into a suitable ASCII string for the first SHA256 hash + std::string text = vector_to_ascii_string(first21); + std::string hash_1 = sha256.message_digest(text); + // Convert 'hashOne' into a suitable ASCII string for the second SHA256 hash + std::vector bytes_1 = hex_to_bytes(hash_1); + std::string ascii_1 = vector_to_ascii_string(bytes_1); + std::string hash_2 = sha256.message_digest(ascii_1); + + std::vector bytes_2 = hex_to_bytes(hash_2); + std::vector checksum(bytes_2.begin(), bytes_2.begin() + 4); + std::vector last4(decoded.begin() + 21, decoded.begin() + 25); + return checksum == last4; +} + +int main() { + const std::vector addresses = { "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62j", + "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62X", + "1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i" }; + + for ( const std::string& address : addresses ) { + std::cout << address << " : " << std::boolalpha << is_valid(address) << std::endl; + } +} diff --git a/Task/Bitcoin-address-validation/Java/bitcoin-address-validation.java b/Task/Bitcoin-address-validation/Java/bitcoin-address-validation-1.java similarity index 100% rename from Task/Bitcoin-address-validation/Java/bitcoin-address-validation.java rename to Task/Bitcoin-address-validation/Java/bitcoin-address-validation-1.java diff --git a/Task/Bitcoin-address-validation/Java/bitcoin-address-validation-2.java b/Task/Bitcoin-address-validation/Java/bitcoin-address-validation-2.java new file mode 100644 index 0000000000..ab07ecd8b0 --- /dev/null +++ b/Task/Bitcoin-address-validation/Java/bitcoin-address-validation-2.java @@ -0,0 +1,71 @@ +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; + +public final class BitcoinAddressValidation { + + public static void main(String[] args) { + List addresses = List.of ( "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62j", + "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62X", + "1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i" ); + + for ( String address : addresses ) { + System.out.println(address + " : " + isValid(address)); + } + } + + private static boolean isValid(String address) { + if ( address.length() < 26 || address.length() > 35 ) { + throw new AssertionError("Invalid length of bitcoin address"); + } + + byte[] decoded = decodeBase58(address); + byte[] first21 = Arrays.copyOfRange(decoded, 0, 21); + // Convert 'first21' into an ASCII string for the first SHA256 hash + String text = new String(first21, StandardCharsets.ISO_8859_1); + String hashOne = SHA256.messageDigest(text); + // Convert 'hashOne' into an ASCII string for the second SHA256 hash + byte[] bytesOne = hexToBytes(hashOne); + String asciiOne = new String(bytesOne, StandardCharsets.ISO_8859_1); + String hashTwo = SHA256.messageDigest(asciiOne); + + byte[] bytesTwo = hexToBytes(hashTwo); + byte[] checksum = Arrays.copyOfRange(bytesTwo, 0, 4); + byte[] last4 = Arrays.copyOfRange(decoded, 21, 25); + return Arrays.equals(last4, checksum); + } + + private static byte[] decodeBase58(String text) { + byte[] result = new byte[25]; + for ( char ch : text.toCharArray() ) { + int index = ALPHABET.indexOf(ch); + if ( index == -1 ) { + throw new AssertionError("Invalid character found in bitcoin address: " + ch); + } + for ( int i = result.length - 1; i > 0; i-- ) { + index += 58 * (int) ( result[i] & 0xFF ); + result[i] = (byte) ( index & 0xFF ); + index >>= 8; + } + if ( index != 0 ) { + throw new AssertionError("Bitcoin address is too long"); + } + } + return result; + } + + private static byte[] hexToBytes(String text) { + byte[] bytes = new byte[text.length() / 2]; + for ( int i = 0; i < text.length(); i += 2 ) { + final int firstDigit = Character.digit(text.charAt(i), 16); + final int secondDigit = Character.digit(text.charAt(i + 1), 16); + bytes[i / 2] = (byte) ( ( firstDigit << 4 ) + secondDigit ); + } + return bytes; + } + + private static final String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + +} diff --git a/Task/Bitcoin-public-point-to-address/C++/bitcoin-public-point-to-address.cpp b/Task/Bitcoin-public-point-to-address/C++/bitcoin-public-point-to-address.cpp new file mode 100644 index 0000000000..3a5ee44ffc --- /dev/null +++ b/Task/Bitcoin-public-point-to-address/C++/bitcoin-public-point-to-address.cpp @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include + +#include "SHA256.cpp" +#include "RIPEMD160.cpp" +SHA256 sha256{ }; +RIPEMD160 ripemd160{ }; + +const std::string BITCOIN_SPECIAL_VALUE = "04"; +const std::string BITCOIN_VERSION_NUMBER = "00"; + +std::map base_map = + { { '0', 0 }, { '1', 1 }, { '2', 2 }, { '3', 3 }, { '4', 4 }, { '5', 5 }, { '6', 6 }, { '7', 7 }, + { '8', 8 }, { '9', 9 }, { 'a', 10 }, { 'b', 11 }, { 'c', 12 }, { 'd', 13 }, { 'e', 14 }, { 'f', 15 }, + { 'A', 10 }, { 'B', 11 }, { 'C', 12 }, { 'D', 13 }, { 'E', 14 }, { 'F', 15 } }; + +std::vector hex_to_bytes(const std::string& text) { + std::vector bytes(text.size() / 2, 0); + for ( uint64_t i = 0; i < text.size(); i += 2 ) { + const uint32_t first_digit = base_map[text[i]]; + const uint32_t second_digit = base_map[text[i + 1]]; + bytes[i / 2] = ( first_digit << 4 ) + second_digit; + } + return bytes; +} + +std::string vector_to_ascii_string(const std::vector& bytes) { + std::string result = ""; + for ( uint64_t i = 0; i < bytes.size(); ++i ) { + result += static_cast(bytes[i]); + } + return result; +} + +std::vector compute_message_bytes(const std::string& text) { + // Convert the hexadecimal string 'text' into a suitable ASCII string for the SHA256 hash + std::vector bytes_1 = hex_to_bytes(text); + std::string ascii_1 = vector_to_ascii_string(bytes_1); + std::string hexSHA256 = sha256.message_digest(ascii_1); + // Convert the hexadecimal string 'hexSHA256' into a suitable ASCII string for the RIPEMD160 hash + std::vector bytes_2 = hex_to_bytes(hexSHA256); + std::string ascii_2 = vector_to_ascii_string(bytes_2); + std::string hexRIPEMD160 = BITCOIN_VERSION_NUMBER + ripemd160.message_digest(ascii_2); + return hex_to_bytes(hexRIPEMD160); +} + +std::vector compute_checksum(const std::vector& bytes) { + // Convert the given byte array into a suitable ASCII string for the first SHA256 hash + std::string ascii_1 = vector_to_ascii_string(bytes); + std::string hex_1 = sha256.message_digest(ascii_1); + // Convert the hexadecimal string 'hex1' into a suitable ASCII string for the second SHA256 hash + std::vector bytes_1 = hex_to_bytes(hex_1); + std::string ascii_2 = vector_to_ascii_string(bytes_1); + std::string hex_2 = sha256.message_digest(ascii_2); + std::vector bytes_2 = hex_to_bytes(hex_2); + std::vector result(bytes_2.begin(), bytes_2.begin() + 4); + return result; +} + +// Return the given byte array encoded into a base58 starting with most one '1' +std::string encode_base_58(std::vector bytes) { + const std::string ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + const uint32_t ALPHABET_SIZE = ALPHABET.size(); + + std::string result(34, ' '); + for ( int64_t n = result.size() - 1; n >= 0; --n ) { + uint32_t c = 0; + for ( uint64_t i = 0; i < bytes.size(); ++i ) { + c = c * 256 + bytes[i]; + bytes[i] = c / ALPHABET_SIZE; + c %= ALPHABET_SIZE; + } + result[n] = ALPHABET[c]; + } + + while ( result.starts_with("11") ) { + result = result.substr(1); + } + return result; +} + +// Return the encoded address of the given coordinates. +std::string encode_address(const std::string& x, const std::string& y) { + std::string public_point = BITCOIN_SPECIAL_VALUE + x + y; + if ( public_point.size() != 130 ) { + throw std::invalid_argument("Invalid public point string"); + } + + std::vector message_bytes = compute_message_bytes(public_point); + std::vector checksum = compute_checksum(message_bytes); + message_bytes.insert(message_bytes.end(), checksum.begin(), checksum.end()); + return encode_base_58(message_bytes); +} + +int main() { + std::string x = "50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352"; + std::string y = "2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6"; + + std::cout << encode_address(x, y) << std::endl; +} diff --git a/Task/Bitcoin-public-point-to-address/Java/bitcoin-public-point-to-address.java b/Task/Bitcoin-public-point-to-address/Java/bitcoin-public-point-to-address.java new file mode 100644 index 0000000000..6f28ff3d99 --- /dev/null +++ b/Task/Bitcoin-public-point-to-address/Java/bitcoin-public-point-to-address.java @@ -0,0 +1,99 @@ +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.stream.Collectors; + +public final class BitcoinPublicPointToAddess { + + public static void main(String[] args) { + String x = "50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352"; + String y = "2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6"; + + if ( areValidCoordinates(x, y) ) { + System.out.println(encodeAddress(x, y)); + } else { + System.out.println("Invalid Bitcoin public point coordinates"); + } + } + + // Return the encoded address of the given coordinates. + private static String encodeAddress(String x, String y) { + String publicPoint = BITCOIN_SPECIAL_VALUE + x + y; + if ( publicPoint.length() != 130 ) { + throw new AssertionError("Invalid public point string: " + publicPoint); + } + + byte[] messageBytes = computeMessageBytes(publicPoint); + byte[] checksum = computeChecksum(messageBytes); + messageBytes = Arrays.copyOf(messageBytes, messageBytes.length + 4); + System.arraycopy(checksum, 0, messageBytes, 21, checksum.length); + return encodeBase58(messageBytes); + } + + // Return the given byte array encoded into a base58 starting with most one '1' + private static String encodeBase58(byte[] bytes) { + final String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + final int ALPHABET_SIZE = ALPHABET.length(); + + String[] temp = new String[34]; + for ( int n = temp.length - 1; n >= 0; n-- ) { + int c = 0; + for ( int i = 0; i < bytes.length; i++ ) { + c = c * 256 + (int) ( bytes[i] & 0xFF ); + bytes[i] = (byte) ( c / ALPHABET_SIZE ); + c %= ALPHABET_SIZE; + } + temp[n] = ALPHABET.substring(c, c + 1); + } + + String result = Arrays.stream(temp).collect(Collectors.joining("")); + while ( result.startsWith("11") ) { + result = result.substring(1); + } + return result; + } + + // Return whether the given coordinates are those of a point on the secp256k1 elliptic curve + private static boolean areValidCoordinates(String x, String y) { + BigInteger modulus = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16); + BigInteger X = new BigInteger(x, 16); + BigInteger Y = new BigInteger(y, 16); + return Y.multiply(Y).mod(modulus).equals(X.multiply(X).multiply(X).add(BigInteger.valueOf(7)).mod(modulus)); + } + + private static byte[] computeMessageBytes(String text) { + // Convert the hexadecimal string 'text' into a suitable ASCII string for the SHA256 hash + byte[] bytesOne = hexToBytes(text); + String asciiOne = new String(bytesOne, StandardCharsets.ISO_8859_1); + String hexSHA256 = SHA256.messageDigest(asciiOne); + // Convert the hexadecimal string 'hexSHA256' into a suitable ASCII string for the RIPEMD160 hash + byte[] bytesTwo = hexToBytes(hexSHA256); + String asciiTwo = new String(bytesTwo, StandardCharsets.ISO_8859_1); + String hexRIPEMD160 = BITCOIN_VERSION_NUMBER + RIPEMD160.messageDigest(asciiTwo); + return hexToBytes(hexRIPEMD160); + } + + private static byte[] computeChecksum(byte[] bytes) { + // Convert the given byte array into a suitable ASCII string for the first SHA256 hash + String asciiOne = new String(bytes, StandardCharsets.ISO_8859_1); + String hexOne = SHA256.messageDigest(asciiOne); + // Convert the hexadecimal string 'hex1' into a suitable ASCII string for the second SHA256 hash + byte[] bytesOne = hexToBytes(hexOne); + String asciiTwo = new String(bytesOne, StandardCharsets.ISO_8859_1); + String hexTwo = SHA256.messageDigest(asciiTwo); + return Arrays.copyOfRange(hexToBytes(hexTwo), 0, 4); + } + + private static byte[] hexToBytes(String text) { + byte[] bytes = new byte[text.length() / 2]; + for ( int i = 0; i < text.length(); i += 2 ) { + final int firstDigit = Character.digit(text.charAt(i), 16); + final int secondDigit = Character.digit(text.charAt(i + 1), 16); + bytes[i / 2] = (byte) ( ( firstDigit << 4 ) + secondDigit );; + } + return bytes; + } + + private static final String BITCOIN_SPECIAL_VALUE = "04"; + private static final String BITCOIN_VERSION_NUMBER = "00"; +} diff --git a/Task/Bitcoin-public-point-to-address/Rust/bitcoin-public-point-to-address.rust b/Task/Bitcoin-public-point-to-address/Rust/bitcoin-public-point-to-address.rust index e9c6c90584..57c7e6ba02 100644 --- a/Task/Bitcoin-public-point-to-address/Rust/bitcoin-public-point-to-address.rust +++ b/Task/Bitcoin-public-point-to-address/Rust/bitcoin-public-point-to-address.rust @@ -1,5 +1,5 @@ use ring::digest::{digest, SHA256}; -use ripemd160::{Digest, Ripemd160}; +use ripemd::{Digest, Ripemd160}; use hex::FromHex; diff --git a/Task/Bitmap-B-zier-curves-Cubic/11l/bitmap-b-zier-curves-cubic.11l b/Task/Bitmap-B-zier-curves-Cubic/11l/bitmap-b-zier-curves-cubic.11l index 7d538ce4eb..4d73742931 100644 --- a/Task/Bitmap-B-zier-curves-Cubic/11l/bitmap-b-zier-curves-cubic.11l +++ b/Task/Bitmap-B-zier-curves-Cubic/11l/bitmap-b-zier-curves-cubic.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b - - F (r, g, b) - .r = r - .g = g - .b = b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/11l/bitmap-bresenhams-line-algorithm.11l b/Task/Bitmap-Bresenhams-line-algorithm/11l/bitmap-bresenhams-line-algorithm.11l index 3c00cb16f4..928f45dde9 100644 --- a/Task/Bitmap-Bresenhams-line-algorithm/11l/bitmap-bresenhams-line-algorithm.11l +++ b/Task/Bitmap-Bresenhams-line-algorithm/11l/bitmap-bresenhams-line-algorithm.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/11l/bitmap-midpoint-circle-algorithm.11l b/Task/Bitmap-Midpoint-circle-algorithm/11l/bitmap-midpoint-circle-algorithm.11l index 0759dfdcb4..299883e44c 100644 --- a/Task/Bitmap-Midpoint-circle-algorithm/11l/bitmap-midpoint-circle-algorithm.11l +++ b/Task/Bitmap-Midpoint-circle-algorithm/11l/bitmap-midpoint-circle-algorithm.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap-Read-a-PPM-file/11l/bitmap-read-a-ppm-file.11l b/Task/Bitmap-Read-a-PPM-file/11l/bitmap-read-a-ppm-file.11l index eb8c2c11c4..93aeb15ba7 100644 --- a/Task/Bitmap-Read-a-PPM-file/11l/bitmap-read-a-ppm-file.11l +++ b/Task/Bitmap-Read-a-PPM-file/11l/bitmap-read-a-ppm-file.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap-Write-a-PPM-file/11l/bitmap-write-a-ppm-file.11l b/Task/Bitmap-Write-a-PPM-file/11l/bitmap-write-a-ppm-file.11l index 31e28a4f57..ab83896090 100644 --- a/Task/Bitmap-Write-a-PPM-file/11l/bitmap-write-a-ppm-file.11l +++ b/Task/Bitmap-Write-a-PPM-file/11l/bitmap-write-a-ppm-file.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada b/Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada index 8eb4b7a790..c3611189b3 100644 --- a/Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada +++ b/Task/Bitmap-Write-a-PPM-file/Ada/bitmap-write-a-ppm-file.ada @@ -1,6 +1,9 @@ with Ada.Characters.Latin_1; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; +with Bitmap_Store; use Bitmap_Store; +-- This package is defined in the Bitmap task. + procedure Put_PPM (File : File_Type; Picture : Image) is use Ada.Characters.Latin_1; Size : constant String := Integer'Image (Picture'Length (2)) & Integer'Image (Picture'Length (1)); diff --git a/Task/Bitmap/11l/bitmap.11l b/Task/Bitmap/11l/bitmap.11l index 1c27ab573c..6939493b36 100644 --- a/Task/Bitmap/11l/bitmap.11l +++ b/Task/Bitmap/11l/bitmap.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Bitmap/POV-Ray/bitmap.povray b/Task/Bitmap/POV-Ray/bitmap.povray new file mode 100644 index 0000000000..2578b0aa32 --- /dev/null +++ b/Task/Bitmap/POV-Ray/bitmap.povray @@ -0,0 +1,74 @@ +//cmd: +w300 +h300 +am2 +a0.01 + +#version 3.7; + +#global_settings {assumed_gamma 1} +#default{ finish{ ambient 0.1 diffuse 0.9 }} +background {rgb 0} + + +#macro mapInit(DimX, DimY) + #local Map = array[DimX][DimY]; + mapFillSolid(Map, rgb<0,0,0>) + Map +#end + + +#macro mapFillSolid(Map, Colour) + mapFillRect(Map,<0,0>,, Colour) +#end + + +#macro mapFillRect(Map, RectLowerLeft, RectUpperRight, Colour) + #for (X, RectLowerLeft.x, RectUpperRight.x - 1) + #for (Y, RectLowerLeft.y, RectUpperRight.y - 1) + #local Map[X][Y] = Colour; + #end + #end +#end + + +#macro mapSetPixel(Map, Pixel, Colour) + #local Map[Pixel.x][Pixel.y] = Colour; +#end + + +#macro mapGetPixel(Map, Pixel) + Map[Pixel.x][Pixel.y] +#end + + +#macro mapObject(Map) + // to visualize the map, each pixel is rendered as a sphere + #for (X,0,dimension_size(Map,1)-1) + #for (Y,0,dimension_size(Map,2)-1) + sphere{ + , 0.5 + pigment{colour Map[X][Y]} + } + #end + #end +#end + +//== Scene + +#declare DimX = 100; +#declare DimY = 100; +#declare ImgMap = mapInit(DimX, DimY); +mapFillSolid(ImgMap, rgb<1, 0, 0>) +mapSetPixel(ImgMap, <25,25>, rgb<1,1,1>) +mapFillRect(ImgMap, <50,50>, <75,75>, rgb<0,0,1>) + +#debug concat("Colour at: <", vstr(2,<25,25>,", ",0,0),"> is: <", vstr(3, mapGetPixel(ImgMap, <25,25>),", ",0,0),">\n") + +mapObject(ImgMap) + +camera{ + location + look_at + right x*image_width/image_height +} +light_source{ + + rgb 1 +} diff --git a/Task/Bitwise-operations/Jq/bitwise-operations.jq b/Task/Bitwise-operations/Jq/bitwise-operations.jq new file mode 100644 index 0000000000..4724c12f65 --- /dev/null +++ b/Task/Bitwise-operations/Jq/bitwise-operations.jq @@ -0,0 +1,32 @@ +include "bitwise" {search: "."}; # adjust as required + +def leftshift($n; $width): + [(range(0,$n)| 0), limit($width - $n; bitwise)][:$width] | to_int; + +# Using a width of $width bits: x << n | x >> ($width-n) +def rotateLeft($x; $n; $width): + $x | bitwise_or(leftshift($n; $width); rightshift($width-$n)); + +# Using a width of $width bits: x << n | x >> ($width-n) +def rotateRight($x; $n; $width): + $x | bitwise_or(rightshift($n); leftshift($width-$n; $width) ); + +def task($x; $y): + def isInteger: type == "number" and . == round; + if ($x|isInteger|not) or ($y|isInteger|not) or + $x < 0 or $y < 0 or $x > 4294967295 or $y > 4294967295 + then "Operands must be in the range of a 32-bit unsigned integer" | error + else + " x = \($x)", + " y = \($y)", + " x & y = \(bitwise_and($x; $y))", + " x | y = \(bitwise_or($x; $y))", + " x ^ y = \(null | xor(x; $y))", + "~x = \(32 | flip($x))", + " x << y = \($x | leftshift($y))", + " x >> y = \($x | rightshift($y))", + " x rl y = \(rotateLeft($x; $y; 32))", + " x rr y = \(rotateRight($x; $y; 32))" + end; + +task(10; 2) diff --git a/Task/Bitwise-operations/PascalABC.NET/bitwise-operations.pas b/Task/Bitwise-operations/PascalABC.NET/bitwise-operations.pas new file mode 100644 index 0000000000..b1805c5213 --- /dev/null +++ b/Task/Bitwise-operations/PascalABC.NET/bitwise-operations.pas @@ -0,0 +1,9 @@ +begin + var (a,b) := ReadInteger2; + Println($'not {a} = {not a}'); + Println($'{a} and {b} = {a and b}'); + Println($'{a} or {b} = {a or b}'); + Println($'{a} xor {b} = {a xor b}'); + Println($'{a} shl {b} = {a shl b}'); + Println($'{a} shr {b} = {a shr b}'); +end. diff --git a/Task/Blum-integer/Common-Lisp/blum-integer.lisp b/Task/Blum-integer/Common-Lisp/blum-integer.lisp new file mode 100644 index 0000000000..6f3c559ebb --- /dev/null +++ b/Task/Blum-integer/Common-Lisp/blum-integer.lisp @@ -0,0 +1,47 @@ +(defun is-factor (x y) + (zerop (mod x y))) + +(defun is-congruent (num a n) + (= (mod num n) a)) + +(defun is-prime (n) + (cond ((< n 4) (or (= n 2) (= n 3))) + ((or (zerop (mod n 2)) (zerop (mod n 3))) nil) + (t (loop for i from 5 to (floor (sqrt n)) by 6 + never (or (is-factor n i) + (is-factor n (+ i 2))))))) + +(defun first-factor (n) + (loop for i from 2 to (floor (sqrt n)) + thereis (if (is-factor n i) i nil))) + +(defun is-blum (n) + (let ((factor (first-factor n))) + (and factor + (is-congruent factor 3 4) + (/= factor (/ n factor)) + (is-congruent (/ n factor) 3 4) + (is-prime factor) + (is-prime (/ n factor))))) + +(defun main () + (let ((n 0) + (i 1) + (blums '()) + (counts '())) + (dotimes (i 10) (push (cons i 0) counts)) + (loop while (<= n 400000) + do (setf i (+ i 2)) + (when (is-blum i) + (incf n) + (incf (cdr (assoc (mod i 10) counts))) + (when (<= n 50) + (push i blums) + (when (= n 50) + (format t "First 50 Blum integers:~%") + (format t "~{~5d~5d~5d~5d~5d~5d~5d~5d~5d~5d~%~}~%" (reverse blums)))) + (if (find n '(26828 100000 200000 300000 400000)) + (format t "The ~7:dth Blum integer is: ~9:d~%" n i)))) + (format t "~%% distribution of the first 400,000 Blum integers:~%") + (dolist (x '(1 3 7 9)) + (format t "~3$% end in ~a~%" (/ (cdr (assoc x counts)) 4000) x)))) diff --git a/Task/Box-the-compass/Langur/box-the-compass.langur b/Task/Box-the-compass/Langur/box-the-compass.langur index d0f6962819..997f98881a 100644 --- a/Task/Box-the-compass/Langur/box-the-compass.langur +++ b/Task/Box-the-compass/Langur/box-the-compass.langur @@ -1,4 +1,4 @@ -val .box = ["North", "North by east", "North-northeast", "Northeast by north", +val box = ["North", "North by east", "North-northeast", "Northeast by north", "Northeast", "Northeast by east", "East-northeast", "East by north", "East", "East by south", "East-southeast", "Southeast by east", "Southeast", "Southeast by south", "South-southeast", "South by east", @@ -7,7 +7,7 @@ val .box = ["North", "North by east", "North-northeast", "Northeast by north", "West", "West by north", "West-northwest", "Northwest by west", "Northwest", "Northwest by north", "North-northwest", "North by west"] -val .angles = [ +val angles = [ 0.0, 16.87, 16.88, 33.75, 50.62, 50.63, 67.5, 84.37, 84.38, 101.25, 118.12, 118.13, 135.0, 151.87, 151.88, 168.75, 185.62, 185.63, 202.5, 219.37, 219.38, 236.25, 253.12, 253.13, 270.0, @@ -16,7 +16,7 @@ val .angles = [ writeln "index degrees compass point" writeln "----- ------- -------------" -for .phi in .angles { - val .i = trunc(.phi * 32 / 360 + 0.5) rem 32 + 1 - writeln $"\{.i:5} \{.phi:r2:6} \{.box[.i]}" +for phi in angles { + val i = trunc(phi * 32 / 360 + 0.5) rem 32 + 1 + writeln "{{i:5}} {{phi:r2:6}} {{box[i]}}" } diff --git a/Task/Brace-expansion/Ada/brace-expansion.ada b/Task/Brace-expansion/Ada/brace-expansion.ada new file mode 100644 index 0000000000..93ddba1ca7 --- /dev/null +++ b/Task/Brace-expansion/Ada/brace-expansion.ada @@ -0,0 +1,58 @@ +pragma Ada_2022; +with Ada.Containers; use Ada.Containers; +with Ada.Containers.Vectors; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +procedure Brace_Expansion is + procedure Expand_Braces (Str : Unbounded_String) is + package Position_Vectors is new Ada.Containers.Vectors (Natural, Natural); + Escaped : Boolean := False; + Depth : Integer := 0; + Brace_Points : Position_Vectors.Vector; + Braces_To_Parse : Position_Vectors.Vector; + Prefix, Suffix, Option : Unbounded_String := Null_Unbounded_String; + begin + for Idx in 1 .. Length (Str) loop + case Element (Str, Idx) is + when '\' => Escaped := not Escaped; + when '{' => + Depth := Depth + 1; + if not Escaped and then Depth = 1 then + Brace_Points.Clear; + Brace_Points.Append (Idx); + end if; + when ',' => + if not Escaped and then Depth = 1 then + Brace_Points.Append (Idx); + end if; + when '}' => + if not Escaped and then Depth = 1 and then Brace_Points.Length > 1 then + Braces_To_Parse.Clear; + Braces_To_Parse.Append_Vector (Brace_Points); + Braces_To_Parse.Append (Idx); + end if; + Depth := Depth - 1; + when others => null; + end case; + if Element (Str, Idx) /= '\' then + Escaped := False; + end if; + end loop; + if Braces_To_Parse.Length > 0 then + Prefix := Unbounded_Slice (Str, 1, Braces_To_Parse (0) - 1); + Suffix := Unbounded_Slice (Str, Braces_To_Parse.Last_Element + 1, Length (Str)); + for Idx in 1 .. Braces_To_Parse.Length - 1 loop + Option := Unbounded_Slice (Str, Braces_To_Parse (Natural (Idx - 1)) + 1, Braces_To_Parse (Natural (Idx)) - 1); + Expand_Braces (Prefix & Option & Suffix); + end loop; + else + Put_Line (Str'Image); + end if; + end Expand_Braces; + function "+"(S : String) return Unbounded_String renames To_Unbounded_String; +begin + Expand_Braces (+"~/{Downloads,Pictures}/*.{jpg,gif,png}"); + Expand_Braces (+"It{{em,alic}iz,erat}e{d,}, please."); + Expand_Braces (+"{,{,gotta have{ ,\, again\, }}more }cowbell!"); + Expand_Braces (+"{}} some }{,{\\{ edge, edge} \,}{ cases, {here} \\\\\}"); +end Brace_Expansion; diff --git a/Task/Break-OO-privacy/PascalABC.NET/break-oo-privacy.pas b/Task/Break-OO-privacy/PascalABC.NET/break-oo-privacy.pas new file mode 100644 index 0000000000..a54bbcb2d0 --- /dev/null +++ b/Task/Break-OO-privacy/PascalABC.NET/break-oo-privacy.pas @@ -0,0 +1,15 @@ +uses System.Reflection; + +type MyClass = class +private + x: integer := 5; +public + procedure PrintFields := Print(x); +end; + +begin + var a := new MyClass; + var fi := a.GetType.GetField('x', BindingFlags.Instance or BindingFlags.NonPublic); + fi.SetValue(a,777); + a.PrintFields; +end. diff --git a/Task/Brilliant-numbers/FutureBasic/brilliant-numbers.basic b/Task/Brilliant-numbers/FutureBasic/brilliant-numbers.basic new file mode 100644 index 0000000000..0cfbf2b186 --- /dev/null +++ b/Task/Brilliant-numbers/FutureBasic/brilliant-numbers.basic @@ -0,0 +1,70 @@ +#build Optimization 3 +#build Architecture "Apple Silicon" +// #build Architecture "Intel" +// #build Architecture "Universal" + +local fn isPrime( v as Uint64 ) as bool + if v < 2 then exit fn = NO + select 0 + if ( ( v - 2 ) == 0 || ( v - 3 ) == 0 ) then exit fn = YES + if ( ( v % 2 ) == 0 || ( v % 3 ) == 0 ) then exit fn = NO + end select + + Uint64 f = 5 + while f*f <= v + if v mod f == 0 then exit fn = no + f += 2 + if v mod f == 0 then exit fn = no + f += 4 + wend +end fn = yes + +local fn FirstPrimeFactor( n as UInt64 ) as UInt64 + UInt64 i + if n mod 2 == 0 then exit fn = 2 + if n mod 3 == 0 then exit fn = 3 + i = 5 + while i*i <= n + if n mod i == 0 then exit fn = i + i += 2 + if n mod i == 0 then exit fn = i + i += 4 + wend +end fn = n + +local fn DoBrilliants( expoLimit as UInt64 ) as CFMutableStringRef + UInt64 count = 0, n = 0, ff, sf, expo = 0 + CFMutableStringRef mutStr = fn MutableStringWithString( @"\nFirst 100 brilliant numbers:\n" ) + + do + ff = fn FirstPrimeFactor( n ) + sf = n/ff + if fn IsPrime( sf ) && len( str(ff) ) == len( str(sf) ) + MutableStringAppendFormat( mutStr, @"%7u\b", n ) + count++ + if count mod 10 == 0 then MutableStringAppendFormat( mutStr, @"\n" ) + end if + n++ + until count == 100 + + MutableStringAppendFormat( mutStr, @"\n" ) : count = 0 : n = 0 + + while ( expo != expoLimit ) + ff = fn FirstPrimeFactor( n ) + sf = n/ff + if fn IsPrime( sf ) && len( str(ff) ) = len( str(sf) ) + count++ + if ( n >= 10^expo ) + MutableStringAppendFormat( mutStr, @"%10u (%6d * %-6d) => 10^%d is brilliant at Position No. %d\n", n, ff, sf, expo, count ) + expo++ + end if + end if + n++ + wend +end fn = mutStr + +CFTimeInterval t : t = fn CACurrentMediaTime +CFStringRef brilliants : brilliants = fn DoBrilliants( 7 ) +printf @"%@\n\t\tTime = %.f milliseconds", brilliants, (fn CACurrentMediaTime - t) * 1000 + +HandleEvents diff --git a/Task/Brilliant-numbers/SETL/brilliant-numbers.setl b/Task/Brilliant-numbers/SETL/brilliant-numbers.setl new file mode 100644 index 0000000000..91c2fbfb10 --- /dev/null +++ b/Task/Brilliant-numbers/SETL/brilliant-numbers.setl @@ -0,0 +1,65 @@ +program brilliant_numbers; + init bs := brilliant(4); + + print('First 100 brilliant numbers:'); + loop for n in bs(1..100) do + nprint(lpad(str n, 6)); + if (c +:= 1) mod 10 = 0 then + print; + end if; + end loop; + + loop doing o +:= 1; while exists n = bs(i) | n >= 10**o do + print('First brilliant number >= ' + lpad(str(10**o), 10) + + ': ' + lpad(str n, 10) + ' at position ' + lpad(str i,6)); + end loop; + + proc brilliant(orders); + primes := sieve(10**orders); + groups := group_by_digit_count(primes); + + b := []; + loop for group in groups do + loop for i in [1..#group] do + loop for j in [1..i] do + b with:= group(i) * group(j); + end loop; + end loop; + end loop; + return [x : x in {x : x in b}]; + end proc; + + proc group_by_digit_count(nums); + magn := 10; + groups := []; + group := []; + loop for n in nums do + if n>=magn then + magn *:= 10; + groups with:= group; + group := []; + end if; + group with:= n; + end loop; + if group /= [] then + groups with:= group; + end if; + return groups; + end proc; + + proc sieve(n); + ps := [True] * n; + p := 2; + loop while p*p <= n do + if ps(p) then + c := p*p; + loop while c<=n do + ps(c) := False; + c +:= p; + end loop; + end if; + p +:= 1; + end loop; + return [i : i in [2..n] | ps(i)]; + end proc; +end program; diff --git a/Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada b/Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada index 4034dfea1c..584bad4836 100644 --- a/Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada +++ b/Task/Bulls-and-cows-Player/Ada/bulls-and-cows-player.ada @@ -127,7 +127,7 @@ procedure Bulls_Player is function Has_To_Be_Removed (Position : Positive) return Boolean is Testant : constant Sequence := V.Element (Position); Bull_Score : Natural := 0; - Cows_Score : Natural := 0; + Cow_Score : Natural := 0; begin for I in Testant'Range loop for J in S'Range loop diff --git a/Task/Bulls-and-cows-Player/Uiua/bulls-and-cows-player.uiua b/Task/Bulls-and-cows-Player/Uiua/bulls-and-cows-player.uiua new file mode 100644 index 0000000000..afd3791852 --- /dev/null +++ b/Task/Bulls-and-cows-Player/Uiua/bulls-and-cows-player.uiua @@ -0,0 +1,18 @@ +# Sets and plays a game of Bulls and Cows (Mastermind) + +T ← [⍥(+1⌊×⚂9)4] # Random target +# Score a guess against a target, or vice versa :-). +Score ← ( + :⟜/+=,, # Find bulls. + ⊟⊙(/+↧∩(≡/+⊞=+1⇡9)∩▽⊙:.¬) # Find cows. +) +&p $"_ <- Target\n" T +⍥(☇1⊞⊂.)2+1⇡9 # Proposed targets [1-9 1-9 1-9 1-9] +⍢( + + ⟜(&p$"_\t_",,⟜(Score T)⊡⊸(⌊×⚂⧻)) # Pick from Ps, and play it against T + ▽:⟜(≡≍⊙¤≡Score⊙¤) # Only keep Ps that match that score +| >1⧻ +) +&p↯21@- +&p $"_\t_" :⊸(⟨"UHOH"|"good"⟩≍T)⊢ diff --git a/Task/CRC-32/Jq/crc-32-1.jq b/Task/CRC-32/Jq/crc-32-1.jq new file mode 100644 index 0000000000..38abfc0ed9 --- /dev/null +++ b/Task/CRC-32/Jq/crc-32-1.jq @@ -0,0 +1,2 @@ +def div($j): + ((. - (. % $j)) / $j) | round; diff --git a/Task/CRC-32/Jq/crc-32-2.jq b/Task/CRC-32/Jq/crc-32-2.jq new file mode 100644 index 0000000000..20a741ca65 --- /dev/null +++ b/Task/CRC-32/Jq/crc-32-2.jq @@ -0,0 +1,34 @@ +include "bitwise" {search: "."}; # see above + +# non-negative decimal integer to hex string +def hex: + def stream: + recurse(if . >= 16 then ./16|floor else empty end) | . % 16 ; + [stream] | reverse + | map(if . < 10 then 48 + . else . + 87 end) | implode ; + +### CRC-32 + +def crc32Table: + reduce range(0; 256) as $i ([]; + . + [reduce range(0; 8) as $j ($i; + if bitwise_and(.;1) == 1 + then bitwise_xor(rightshift(1); 3988292384) # 0xedb88320 + else rightshift( 1 ) + end) ] ); + +# Input: an ASCII string +# Output: its CRC-32 +def crc32: + explode as $s + | crc32Table as $table + | reduce range(0; $s|length) as $i (4294967295 ; # ~0 + # 0xff is 255 + bitwise_and(.; 255 ) as $crb + | bitwise_xor( $table[bitwise_xor($crb; $s[$i])] ; rightshift(8)) ) + | flip(32) ; + +def task: + crc32 | hex; + +"The quick brown fox jumps over the lazy dog" | task diff --git a/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas b/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas new file mode 100644 index 0000000000..c2a30c8cee --- /dev/null +++ b/Task/CSV-data-manipulation/PascalABC.NET/csv-data-manipulation.pas @@ -0,0 +1,9 @@ +begin + var lines := ReadLines('data.csv').Select((line,i) -> begin + if i = 0 then + Result := line + ',SUM' + else Result := line + ',' + line.Split(',').Sum(x -> x.ToInteger); + end); + WriteLines('outdata.csv',lines); + lines.PrintLines; +end. diff --git a/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua b/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua new file mode 100644 index 0000000000..9e4022ca99 --- /dev/null +++ b/Task/CSV-data-manipulation/Uiua/csv-data-manipulation.uiua @@ -0,0 +1,11 @@ +# Simple CSV manipulation + +# Effect of running `&fras "example.csv"` +$ C1,C2,C3,C4,C5 +$ 1,5,9,13,17 +$ 2,6,10,14,18 +$ 3,7,11,15,19 +$ 4,8,12,16,20 + +&p⍜°csv(⍜⍉⊂:⊂□"SUM"≡(□⍜⋕/+)↘1.) +# Save using `&fwa "example.csv"` diff --git a/Task/CUSIP/Langur/cusip-1.langur b/Task/CUSIP/Langur/cusip-1.langur index 7153ac3e7b..544bb91265 100644 --- a/Task/CUSIP/Langur/cusip-1.langur +++ b/Task/CUSIP/Langur/cusip-1.langur @@ -1,23 +1,23 @@ -val .isCusip = fn(.s) { - if .s is not string or len(.s) != 9 { +val isCusip = fn(s) { + if s is not string or len(s) != 9 { return false } - val .basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#" + val basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#" - val .sum = for[=0] .i of 8 { - var .v = index(s2s(.s, .i), .basechars) - if not .v: return false - .v = .v[1]-1 - if .i div 2: .v *= 2 - _for += .v \ 10 + .v rem 10 + val sum = for[=0] i of 8 { + var v = index(s2s(s, i), basechars) + if not v: return false + v = v[1]-1 + if i div 2: v *= 2 + _for += v \ 10 + v rem 10 } - .s[9]-'0' == (10-(.sum rem 10)) rem 10 + s[9]-'0' == (10-(sum rem 10)) rem 10 } -val .candidates = fw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ +val candidates = fw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ -for .c in .candidates { - writeln .c, ": ", if(.isCusip(.c): "good" ; "bad") +for c in candidates { + writeln c, ": ", if(isCusip(c): "good" ; "bad") } diff --git a/Task/CUSIP/Langur/cusip-2.langur b/Task/CUSIP/Langur/cusip-2.langur index 792cec79d2..ce7d178e29 100644 --- a/Task/CUSIP/Langur/cusip-2.langur +++ b/Task/CUSIP/Langur/cusip-2.langur @@ -1,35 +1,37 @@ -val .isCusip = fn(.s) { - if .s is not string or len(.s) != 9 { +val isCusip = fn(s) { + if s is not string or len(s) != 9 { return false } - val .sum = for[=0] .i of 8 { - val .c = .s[.i] - var .v = 0 + val basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#" - switch[and] .c { + val sum = for[=0] i of 8 { + val c = s[i] + var v = 0 + + switch[and] c { case >= '0', <= '9': - .v = .c-'0' + v = c-'0' case >= 'A', <= 'Z': - .v = .c-55 # .c-'A'+10 + v = c-55 # c-'A'+10 - case '*': .v = 36 - case '@': .v = 37 - case '#': .v = 38 + case '*': v = 36 + case '@': v = 37 + case '#': v = 38 default: return false } - if .i div 2: .v *= 2 - _for += .v \ 10 + .v rem 10 + if i div 2: v *= 2 + _for += v \ 10 + v rem 10 } - .s[9]-'0' == (10-(.sum rem 10)) rem 10 + s[9]-'0' == (10-(sum rem 10)) rem 10 } -val .candidates = w/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ +val candidates = fw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/ -for .c in .candidates { - writeln .c, ": ", if(.isCusip(.c): "good" ; "bad") +for c in candidates { + writeln c, ": ", if(isCusip(c): "good" ; "bad") } diff --git a/Task/Caesar-cipher/Elm/caesar-cipher.elm b/Task/Caesar-cipher/Elm/caesar-cipher.elm new file mode 100644 index 0000000000..b4a7c073f9 --- /dev/null +++ b/Task/Caesar-cipher/Elm/caesar-cipher.elm @@ -0,0 +1,88 @@ +module Main exposing (main) + +import Browser +import Html exposing (Html, h2, div, p, input, button, text, textarea) +import Html.Attributes exposing (style, class, placeholder, value) +import Html.Events exposing (onInput, onClick) + + +-- MAIN + +main = + Browser.sandbox { init = init, update = update, view = view } + + +-- MODEL + +type alias Model = + { codeKey : Int + , normtext : String + } + + +init : Model +init = + { codeKey = 3 + , normtext = "" } + + +-- UPDATE + +type Msg + = Change String + | DecKey + | IncKey + + +update : Msg -> Model -> Model +update msg model = + case msg of + DecKey -> + { model | codeKey = model.codeKey - 1} + IncKey -> + { model | codeKey = model.codeKey + 1} + Change newContent -> + { model | normtext = String.toUpper newContent } + + + +encodeChar : Int -> Char -> Char +encodeChar codeKey character = + if Char.isUpper character then + Char.fromCode (modBy 26 (Char.toCode character - 65 + codeKey) + 65) + + else if Char.isLower character then + Char.fromCode (modBy 26 (Char.toCode (Char.toUpper character) - 65 + codeKey) + 65) + + else + character + + +encodeText : Int -> String -> String +encodeText codeKey normtext = + String.map (encodeChar codeKey) normtext + + +subheads aKey = + if aKey > 0 then "Original" + else if aKey < 0 then "Encrypted text" + else "?" + +-- VIEW + +view : Model -> Html Msg +view model = + div [] + [ div [] + [h2 [class "h2style"] [text (subheads model.codeKey)] + , textarea [ class "textframe", placeholder "Write here your text!" + , value model.normtext, onInput Change ] [] + ] + , div [] + [h2 [class "h2style"] [text (subheads (negate model.codeKey))] + , textarea [ class "textframe", value (encodeText model.codeKey model.normtext) ] []] + , div [class "keystyle"] [ button [ class "butstyle", onClick DecKey ] [ text "-1" ] + , text (" Key " ++ String.fromInt model.codeKey) + , button [ class "butstyle", onClick IncKey ] [ text "+1" ] + ] + ] diff --git a/Task/Caesar-cipher/Langur/caesar-cipher.langur b/Task/Caesar-cipher/Langur/caesar-cipher.langur index 2b965df756..3161281621 100644 --- a/Task/Caesar-cipher/Langur/caesar-cipher.langur +++ b/Task/Caesar-cipher/Langur/caesar-cipher.langur @@ -1,10 +1,10 @@ -val .rot = fn(.s, .key) { - cp2s map(fn(.c) rotate(rotate(.c, .key, 'a'..'z'), .key, 'A'..'Z'), s2cp .s) +val rot = fn(s, key) { + cp2s map(fn(c) { rotate(rotate(c, key, 'a'..'z'), key, 'A'..'Z') }, s2cp(s)) } -val .s = "A quick brown fox jumped over something." -val .key = 3 +val s = "A quick brown fox jumped over something, you know." +val key = 3 -writeln " original: ", .s -writeln "encrypted: ", .rot(.s, .key) -writeln "decrypted: ", .rot(.rot(.s, .key), -.key) +writeln " original: ", s +writeln "encrypted: ", rot(s, key) +writeln "decrypted: ", rot(rot(s, key), -key) diff --git a/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol b/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol index 6a72c6a31e..d20ba6e3fe 100644 --- a/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol +++ b/Task/Calculating-the-value-of-e/COBOL/calculating-the-value-of-e.cobol @@ -1,25 +1,23 @@ - >>SOURCE FORMAT IS FIXED IDENTIFICATION DIVISION. - PROGRAM-ID. EULER. + PROGRAM-ID. euler. DATA DIVISION. WORKING-STORAGE SECTION. - 01 EPSILON USAGE COMPUTATIONAL-2 VALUE 1.0E-15. - 01 FACT USAGE BINARY-DOUBLE UNSIGNED VALUE 1. - 01 N USAGE BINARY-INT UNSIGNED. - 01 E USAGE COMPUTATIONAL-2 VALUE 2.0. - 01 E0 USAGE COMPUTATIONAL-2 value 0.0. - 01 RESULT-MESSAGE. - 03 FILLER PIC X(4) VALUE 'e = '. - 03 RESULT-VALUE PIC 9.9(18) USAGE DISPLAY. + 77 epsilon USAGE FLOAT-LONG VALUE IS 1.0E-15. + 77 fact USAGE IS BINARY-DOUBLE UNSIGNED VALUE IS 1. + 77 n USAGE IS BINARY-LONG UNSIGNED. + 77 e USAGE IS FLOAT-LONG VALUE IS 2.0. + 77 e0 USAGE IS FLOAT-LONG VALUE IS 0.0. + 01 result-message. + 03 FILLER PICTURE IS X(4) VALUE IS 'e = '. + 03 result-value PICTURE IS 9.9(18) USAGE IS DISPLAY. PROCEDURE DIVISION. - MAIN SECTION. - PERFORM - VARYING N FROM 2 BY 1 - UNTIL FUNCTION ABS(E - E0) < EPSILON - MOVE E TO E0 - COMPUTE FACT = FACT * N - COMPUTE E = E + 1.0 / FACT + PERFORM WITH TEST BEFORE VARYING n FROM 2 BY 1 + UNTIL FUNCTION ABS(e - e0) IS LESS THAN epsilon + MOVE e TO e0 + MULTIPLY n BY fact + COMPUTE e = e + 1.0 / fact END-PERFORM. - MOVE E TO RESULT-VALUE. - DISPLAY RESULT-MESSAGE. + MOVE e TO result-value. + DISPLAY result-message. STOP RUN. + END PROGRAM euler. diff --git a/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur b/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur index 6fda7d65b0..b56040b204 100644 --- a/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur +++ b/Task/Calculating-the-value-of-e/Langur/calculating-the-value-of-e.langur @@ -1,17 +1,14 @@ mode divMaxScale = 104 -val .epsilon = 1.0e-104 +val epsilon = 1e-104 -var .e = 2 +var e = 2 -for .fact, .n = 1, 2 ; ; .n += 1 { - val .e0 = .e - .fact *= .n - .e += 1 / .fact - if abs(.e - .e0) < .epsilon: break +for fact, n = 1, 2 ; ; n += 1 { + val e0 = e + fact *= n + e += 1 / fact + if abs(e - e0) < epsilon: break } -writeln ".e = ", .e - -# compare to built-in constant e -writeln " e = ", e +writeln "e = ", e diff --git a/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas b/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas new file mode 100644 index 0000000000..e59efe7c9a --- /dev/null +++ b/Task/Calculating-the-value-of-e/PascalABC.NET/calculating-the-value-of-e.pas @@ -0,0 +1,19 @@ +function MyExp(x: real): real; +const eps = 1e-15; +begin + var y := 1.0; + var s := y; + var i := 1; + while y > eps do + begin + y *= x / i; + s += y; + i += 1; + end; + Result := s; +end; + +begin + Println(MyExp(1)); + Println(Exp(1)); +end. diff --git a/Task/Calkin-Wilf-sequence/Uiua/calkin-wilf-sequence.uiua b/Task/Calkin-Wilf-sequence/Uiua/calkin-wilf-sequence.uiua new file mode 100644 index 0000000000..12ed65ccf7 --- /dev/null +++ b/Task/Calkin-Wilf-sequence/Uiua/calkin-wilf-sequence.uiua @@ -0,0 +1,28 @@ +# Generate Calkin-Wilf sequence, then use continued fractions +# to discover position in the sequence of any given a/b. + +Gcd ← ⊙◌⍢(⟜◿:|±,)°⊟ +Reduce ← ÷⊸Gcd # Reduce a rational [a b] to its normal form. +Add ← Reduce ⊟⊓/+(⊢⇌)∩×⇌,, # Add pair of rationals [a b] [c d] +Subtract ← Add ⊙⍜⊢¯ # Difference of pair of rationals [a b] [c d] +Multiply ← Reduce × # Multiply pair of rationals [a b] [c d] +Divide ← Multiply ⊙⇌ +Floor ← Reduce ⊟:1⌊/÷⇌ + +CwNext ← ⇌Subtract:⟜(Add1_1Multiply2_1Floor) +&p"First twenty terms of Calkin-Wilf sequence:" +&p/◇⊂≡(□$"_/_ "°⊟)⇌[⍥(CwNext.)20 [1 1]] + +Cf ← ⇌Subtract⟜(.⊟:1⌊÷:°⊟) + +ContFracRat ← ⇌≡⊢↘1[⍢(Cf|≠0⊡1)] # Continued Fraction for rational [a b]. +OddContFrac ← ⍥(⊂:1⍜(↙¯1|-1))¬◿2⧻.ContFracRat # Force length to be odd. +CwPos ← °⋯⇌∧(⊂↯°⊟)⍉⊟⟜(¬◿2⇡⧻):[] OddContFrac # Calculate pos as described. +&p"" +{[9 4] [83116 51639]} +≡◇(&p $"_/_ is at position _ in the sequence"°⊟⟜CwPos) +&p"" +# And show that the relation works in reverse +ContFracInt ← ⍥(⊂0)=0⊢⟜(⊜⧻.+1)⋯ +CwAt ← /(Add⇌)≡(⇌⊟1)⇌ContFracInt +&p$"The number at position _ is _/_"⟜(°⊟CwAt)123456789 diff --git a/Task/Call-a-foreign-language-function/Standard-ML/call-a-foreign-language-function.ml b/Task/Call-a-foreign-language-function/Standard-ML/call-a-foreign-language-function.ml new file mode 100644 index 0000000000..c9de9e4fa6 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Standard-ML/call-a-foreign-language-function.ml @@ -0,0 +1,6 @@ +local + val libc = Foreign.loadLibrary "libc.so.6" + val sym = Foreign.getSymbol libc "strdup" +in + val strdup = Foreign.buildCall1(sym, (Foreign.cString), Foreign.cString) +end diff --git a/Task/Call-a-function/Langur/call-a-function-1.langur b/Task/Call-a-function/Langur/call-a-function-1.langur index 018fdb5723..45f808f68d 100644 --- a/Task/Call-a-function/Langur/call-a-function-1.langur +++ b/Task/Call-a-function/Langur/call-a-function-1.langur @@ -1,2 +1 @@ -.x() -# call user-defined function +x() diff --git a/Task/Call-a-function/Langur/call-a-function-2.langur b/Task/Call-a-function/Langur/call-a-function-2.langur index 5848452119..cab69e190b 100644 --- a/Task/Call-a-function/Langur/call-a-function-2.langur +++ b/Task/Call-a-function/Langur/call-a-function-2.langur @@ -1,2 +1 @@ -write(.key, ": ", .value) -# call built-in with parentheses +write(somestring) diff --git a/Task/Call-a-function/Langur/call-a-function-3.langur b/Task/Call-a-function/Langur/call-a-function-3.langur index 5da32ae269..2b3c4cce69 100644 --- a/Task/Call-a-function/Langur/call-a-function-3.langur +++ b/Task/Call-a-function/Langur/call-a-function-3.langur @@ -1,2 +1 @@ -write .key, ": ", .value -# call built-in with unbounded list +writeln a, b, c diff --git a/Task/Call-a-function/Langur/call-a-function-4.langur b/Task/Call-a-function/Langur/call-a-function-4.langur index bc02bc601c..80e14451fb 100644 --- a/Task/Call-a-function/Langur/call-a-function-4.langur +++ b/Task/Call-a-function/Langur/call-a-function-4.langur @@ -1,3 +1,2 @@ -writeln "numbers: ", join ", ", [.a1, .a2, .a3, .a4] -# unbounded lists on writeln and join -# later function join takes remaining arguments +a -> len +# passes a to the len() function diff --git a/Task/Call-a-function/Langur/call-a-function-5.langur b/Task/Call-a-function/Langur/call-a-function-5.langur index f7b4acd094..7faa408981 100644 --- a/Task/Call-a-function/Langur/call-a-function-5.langur +++ b/Task/Call-a-function/Langur/call-a-function-5.langur @@ -1,3 +1 @@ -writeln "numbers: ", join(", ", [.a1, .a2, .a3, .a4]), " === " -# unbounded list on writeln -# join using parentheses so it doesn't take remaining arguments +val fibonacci = fn x:if x < 2 { x } else { fn((x - 1)) + fn((x - 2)) } diff --git a/Task/Call-a-function/Langur/call-a-function-6.langur b/Task/Call-a-function/Langur/call-a-function-6.langur index e124e037e9..1efc364d84 100644 --- a/Task/Call-a-function/Langur/call-a-function-6.langur +++ b/Task/Call-a-function/Langur/call-a-function-6.langur @@ -1,7 +1 @@ -val .sum = foldfrom( - fn(.sum, .i, .c) .sum + number(.c, 36) * .weight[.i], - 0, - pseries len .code, - split .code, -) -# split, pseries, and len using unbounded lists, ending before comma preceding line return +mapX(amb, wordsets...) diff --git a/Task/Call-a-function/Langur/call-a-function-7.langur b/Task/Call-a-function/Langur/call-a-function-7.langur deleted file mode 100644 index 803ab6fdcd..0000000000 --- a/Task/Call-a-function/Langur/call-a-function-7.langur +++ /dev/null @@ -1,4 +0,0 @@ -for .key in sort(keys .tests) { - ... -} -# unbounded list on keys bounded by closing parenthesis of sort diff --git a/Task/Call-an-object-method/PascalABC.NET/call-an-object-method.pas b/Task/Call-an-object-method/PascalABC.NET/call-an-object-method.pas new file mode 100644 index 0000000000..010e6cf3f9 --- /dev/null +++ b/Task/Call-an-object-method/PascalABC.NET/call-an-object-method.pas @@ -0,0 +1,16 @@ +type + Point = auto class // class with autogenerated constructor + x,y: real; + static function RandomPoint := new Point(Random(-10..10),Random(-10..10)); + procedure Print; + begin + Writeln($'{x} {y}'); + end; + end; + +begin + var p := new Point(2,3); + p.Print; // instance method call + p := Point.RandomPoint; // static method call + p.Print; +end. diff --git a/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur b/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur index 18aee6b560..88328fabe6 100644 --- a/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur +++ b/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur @@ -1,16 +1,16 @@ -val .X = fn(... .x) .x +val X = fn ...x:x -writeln mapX(.X, [1, 2], [3, 4]) == [[1, 3], [1, 4], [2, 3], [2, 4]] -writeln mapX(.X, [3, 4], [1, 2]) == [[3, 1], [3, 2], [4, 1], [4, 2]] -writeln mapX(.X, [1, 2], []) == [] -writeln mapX(.X, [], [1, 2]) == [] +writeln mapX(X, [1, 2], [3, 4]) == [[1, 3], [1, 4], [2, 3], [2, 4]] +writeln mapX(X, [3, 4], [1, 2]) == [[3, 1], [3, 2], [4, 1], [4, 2]] +writeln mapX(X, [1, 2], []) == [] +writeln mapX(X, [], [1, 2]) == [] writeln() -writeln mapX .X, [1776, 1789], [7, 12], [4, 14, 23], [0, 1] +writeln mapX(X, [1776, 1789], [7, 12], [4, 14, 23], [0, 1]) writeln() -writeln mapX .X, [1, 2, 3], [30], [500, 100] +writeln mapX(X, [1, 2, 3], [30], [500, 100]) writeln() -writeln mapX .X, [1, 2, 3], [], [500, 100] +writeln mapX(X, [1, 2, 3], [], [500, 100]) writeln() diff --git a/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua b/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua new file mode 100644 index 0000000000..2895add665 --- /dev/null +++ b/Task/Cartesian-product-of-two-or-more-lists/Uiua/cartesian-product-of-two-or-more-lists.uiua @@ -0,0 +1,9 @@ +# Cartesian products + +☇1⊞⊂[1 2] [3 4] +☇1⊞⊂[3 4] [1 2] +☇1⊞⊂[3 4] [] +C ← /◇(☇1⊞⊂) +≡⍚C{{[1776 1789] [7 12] [4 14 23] [0 1]} + {[1 2 3] [30] [500 100]} + {[1 2 3] [] [500 100]}} diff --git a/Task/Catalan-numbers/Langur/catalan-numbers.langur b/Task/Catalan-numbers/Langur/catalan-numbers.langur index b5b6f9f98e..81d8b2e82f 100644 --- a/Task/Catalan-numbers/Langur/catalan-numbers.langur +++ b/Task/Catalan-numbers/Langur/catalan-numbers.langur @@ -1,9 +1,9 @@ -val .factorial = fn(.x) if(.x < 2: 1; .x x self(.x - 1)) +val factorial = fn x:if(x < 2: 1; x * self(x - 1)) -val .catalan = fn(.n) .factorial(2 x .n) / .factorial(.n+1) / .factorial(.n) +val catalan = fn n:factorial(2 * n) / factorial(n+1) / factorial(n) -for .i in 0..15 { - writeln $"\.i:2;: \(.catalan(.i):10)" +for i in 0..15 { + writeln "{{i:2}}: {{catalan(i):10}}" } -writeln "10000: ", .catalan(10000) +writeln "10000: ", catalan(10000) diff --git a/Task/Catmull-Clark-subdivision-surface/C++/catmull-clark-subdivision-surface.cpp b/Task/Catmull-Clark-subdivision-surface/C++/catmull-clark-subdivision-surface.cpp new file mode 100644 index 0000000000..1fab0fe9be --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/C++/catmull-clark-subdivision-surface.cpp @@ -0,0 +1,261 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// A point of the current Catmull-Clark surface. +class Point { +public: + Point() : x(0.0), y(0.0), z(0.0) { } + Point(const double& aX, const double& aY, const double& aZ) : x(aX), y(aY), z(aZ) { } + + Point add(const Point& other) const { + return Point(x + other.x, y + other.y, z + other.z); + } + + Point multiply(const double& factor) const { + return Point(x * factor, y * factor, z * factor); + } + + Point divide(const double& factor) const { + return multiply(1.0 / factor); + } + + bool operator<(const Point& other) const { + return ( x < other.x ) || ( ( x == other.x && y < other.y ) ) + || ( x == other.x && y == other.y && z < other.z ); + } + + bool operator==(const Point& other) const { + return x == other.x && y == other.y && z == other.z; + } + + Point& operator=(const Point& other) { + if ( *this != other ) { + x = other.x; y = other.y; z = other.z; + } + return *this; + } + + std::string to_string() const { + return "(" + format(x) + ", " + format(y) + ", " + format(z) + ")"; + } + +private: + std::string format(const double& value) const { + std::stringstream stream; + stream << std::fixed << std::setprecision(3) << value; + return ( value >= 0 ) ? " " + stream.str() : stream.str(); + } + + double x, y, z; +}; + +// Return the centroid point of the given vector of points. +Point centroid(const std::vector& points) { + Point sum; + for ( const Point& point : points ) { + sum = sum.add(point); + } + return sum.divide(points.size()); +} + +// An edge of the current Catmull-Clark surface. +class Edge { +public: + Edge(Point aBegin, Point aEnd) { + if ( aEnd < aBegin ) { + std::swap(aBegin, aEnd); + } + begin = aBegin; end = aEnd; + + mid_edge = centroid({ begin, end }); + hole_edge = false; + } + + bool contains(const Point& point) const { + return point == begin || point == end; + } + + bool operator<(const Edge other) const { + return ( begin < other.begin ) || ( begin == other.begin && end < other.end ); + } + + bool operator==(const Edge& other) const { + return contains(other.begin) && contains(other.end); + } + + bool hole_edge; + Point begin, end, mid_edge, edge_point; +}; + +// A face of the current Catmull-Clark surface. +class Face { +public: + Face(std::vector aVertices) { + vertices = aVertices; + face_point = centroid(vertices); + + for ( uint64_t i = 0; i < vertices.size() - 1; ++i ) { + edges.emplace_back(Edge(vertices[i], vertices[i + 1])); + } + edges.emplace_back(Edge(vertices.back(), vertices.front())); + } + + bool contains(const Point& vertex) const { + return std::find(vertices.begin(), vertices.end(), vertex) != vertices.end(); + } + + bool contains(Edge edge) const { + return contains(edge.begin) && contains(edge.end); + } + + std::string toString() const { + std::string result = "Face: "; + for ( uint64_t i = 0; i < vertices.size() - 1; ++i ) { + result += vertices[i].to_string() + ", "; + } + return result + vertices.back().to_string(); + } + + std::vector vertices; + std::vector edges; + Point face_point; +}; + +// Return a map containing, for each vertex, +// the new vertex created by the current iteration of the Catmull-Clark surface subdivision algorithm. +std::map next_vertices(const std::vector& edges, const std::vector& faces) { + std::map next_vertices = { }; + std::set vertices = { }; + for ( const Face& face : faces ) { + for ( const Point& vertex : face.vertices ) { + vertices.emplace(vertex); + } + } + + for ( const Point& vertex : vertices ) { + std::vector faces_for_vertex = { }; + for ( const Face& face : faces ) { + if ( face.contains(vertex) ) { + faces_for_vertex.emplace_back(face); + } + } + + std::set edges_for_vertex = { }; + for ( const Edge& edge : edges ) { + if ( edge.contains(vertex) ) { + edges_for_vertex.emplace(edge); + } + } + + if ( faces_for_vertex.size() != edges_for_vertex.size() ) { + std::vector mid_edge_of_hole_edges = { }; + for ( const Edge& edge : edges_for_vertex ) { + if ( edge.hole_edge ) { + mid_edge_of_hole_edges.emplace_back(edge.mid_edge); + } + } + mid_edge_of_hole_edges.emplace_back(vertex); + next_vertices[vertex] = centroid(mid_edge_of_hole_edges); + } else { + const uint64_t face_count = faces_for_vertex.size(); + const double multiple_1 = static_cast(( face_count - 3 ) / face_count); + const double multiple_2 = 1.0 / face_count; + const double multiple_3 = 2.0 / face_count; + + Point next_vertex_1 = vertex.multiply(multiple_1); + std::vector face_points = { }; + for ( const Face& face : faces_for_vertex ) { + face_points.emplace_back(face.face_point); + } + Point next_vertex_2 = centroid(face_points).multiply(multiple_2); + std::vector mid_edges = { }; + for ( const Edge& edge : edges_for_vertex ) { + mid_edges.emplace_back(edge.mid_edge); + } + Point next_vertex_3 = centroid(mid_edges).multiply(multiple_3); + Point next_vertex_4 = next_vertex_1.add(next_vertex_2); + + next_vertices[vertex] = next_vertex_4.add(next_vertex_3); + } + } + return next_vertices; +} + +// The Catmull-Clarke surface subdivision algorithm. +std::vector catmull_clark_surface_subdivision(std::vector& faces) { + // Determine, for each edge, whether or not it is an edge of a hole, and set its edge point accordingly. + for ( Face& face : faces ) { + for ( Edge& edge : face.edges ) { + std::vector face_points_for_edge = { }; + for ( const Face& search_face : faces ) { + if ( search_face.contains(edge) ) { + face_points_for_edge.emplace_back(search_face.face_point); + } + } + + if ( face_points_for_edge.size() == 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; + } + } + } + + std::vector edges = { }; + for ( const Face& face : faces ) { + for ( const Edge& edge : face.edges ) { + edges.emplace_back(edge); + } + } + std::map next_vertex_map = next_vertices(edges, faces); + + std::vector next_faces = { }; + for ( Face face : faces ) { // The face may contain any number of points + if ( face.vertices.size() >= 3 ) { // A face with 2 or fewer points does not contribute to the surface + Point face_point = face.face_point; + for ( uint64_t i = 0; i < face.vertices.size(); ++i ) { + next_faces.emplace_back(Face({ + next_vertex_map[face.vertices[i]], + face.edges[i].edge_point, + face_point, + face.edges[( i - 1 + face.vertices.size() ) % face.vertices.size()].edge_point})); + } + } + } + return next_faces; +} + +// Display the current Catmull-Clark surface on the console. +void displaySurface(const std::vector faces) { + std::cout << "Surface {" << std::endl; + for ( const Face& face : faces ) { + std::cout << face.toString() << std::endl; + } + std::cout << "}" << std::endl << std::endl; +} + +int main() { + std::vector faces = { + Face({ Point(-1.0, 1.0, 1.0), Point(-1.0, -1.0, 1.0), Point( 1.0, -1.0, 1.0), Point( 1.0, 1.0, 1.0) }), + Face({ Point( 1.0, 1.0, 1.0), Point( 1.0, -1.0, 1.0), Point( 1.0, -1.0, -1.0), Point( 1.0, 1.0, -1.0) }), + Face({ Point( 1.0, 1.0, -1.0), Point( 1.0, -1.0, -1.0), Point(-1.0, -1.0, -1.0), Point(-1.0, 1.0, -1.0) }), + Face({ Point(-1.0, 1.0, -1.0), Point(-1.0, 1.0, 1.0), Point( 1.0, 1.0, 1.0), Point( 1.0, 1.0, -1.0) }), + Face({ Point(-1.0, 1.0, -1.0), Point(-1.0, -1.0, -1.0), Point(-1.0, -1.0, 1.0), Point(-1.0, 1.0, 1.0) }), + Face({ Point(-1.0, -1.0, -1.0), Point(-1.0, -1.0, 1.0), Point( 1.0, -1.0, 1.0), Point( 1.0, -1.0, -1.0) })}; + + displaySurface(faces); + const uint32_t iterations = 1; + for ( uint32_t i = 0; i < iterations; ++i ) { + faces = catmull_clark_surface_subdivision(faces); + } + displaySurface(faces); +} diff --git a/Task/Catmull-Clark-subdivision-surface/Java/catmull-clark-subdivision-surface.java b/Task/Catmull-Clark-subdivision-surface/Java/catmull-clark-subdivision-surface.java new file mode 100644 index 0000000000..2d363ef4da --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Java/catmull-clark-subdivision-surface.java @@ -0,0 +1,257 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +public final class CatmullClarkSurfaceSubdivision { + + public static void main(String[] args) { + List faces = List.of( new Face(List.of( 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(List.of( 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(List.of( 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(List.of( 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(List.of( 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(List.of( 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); + final int iterations = 1; + for ( int i = 0; i < iterations; i++ ) { + faces = catmullClarkSurfaceSubdivision(faces); + } + displaySurface(faces); + } + + // The Catmull-Clarke surface subdivision algorithm. + private static List catmullClarkSurfaceSubdivision(List faces) { + // Determine, for each edge, whether or not it is an edge of a hole, and set its edge point accordingly. + List edges = faces.stream().map( face -> face.edges.stream() ).flatMap(Function.identity()).toList(); + for ( Edge edge : edges ) { + List facePointsForEdge = + faces.stream().filter( face -> face.contains(edge) ).map( face -> face.facePoint ).toList(); + if ( facePointsForEdge.size() == 2 ) { + edge.holeEdge = false; + edge.edgePoint = centroid(List.of( edge.midEdge, centroid(facePointsForEdge) )); + } else { + edge.holeEdge = true; + edge.edgePoint = edge.midEdge; + } + } + + Map nextVertices = nextVertices(edges, faces); + + List nextFaces = new ArrayList(); + for ( Face face : faces ) { // The face may contain any number of points + if ( face.vertices.size() >= 3 ) { // A face with 2 or fewer points does not contribute to the surface + Point facePoint = face.facePoint; + for ( int i = 0; i < face.vertices.size(); i++ ) { + nextFaces.addLast( new Face(List.of( + nextVertices.get(face.vertices.get(i)), + face.edges.get(i).edgePoint, + facePoint, + face.edges.get(Math.floorMod(i - 1, face.vertices.size())).edgePoint )) ); + } + } + } + return nextFaces; + } + + // Return a map containing, for each vertex, + // the new vertex created by the current iteration of the Catmull-Clark surface subdivision algorithm. + private static Map nextVertices(List edges, List faces) { + Map nextVertices = new HashMap(); + List vertices = + faces.stream().map( face -> face.vertices.stream() ).flatMap(Function.identity()).distinct().toList(); + + for ( Point vertex : vertices ) { + List facesForVertex = faces.stream().filter( face -> face.contains(vertex) ).toList(); + List edgesForVertex = edges.stream().filter( edge -> edge.contains(vertex) ).distinct().toList(); + + if ( facesForVertex.size() != edgesForVertex.size() ) { + List midEdgeOfHoleEdges = edgesForVertex.stream().filter( edge -> edge.holeEdge ) + .map( edge -> edge.midEdge ).collect(Collectors.toList()); + midEdgeOfHoleEdges.add(vertex); + nextVertices.put(vertex, centroid(midEdgeOfHoleEdges)); + } else { + final int faceCount = facesForVertex.size(); + final double multipleOne = (double) ( faceCount - 3 ) / faceCount; + final double multipleTwo = 1.0 / faceCount; + final double multipleThree = 2.0 / faceCount; + + Point nextVertexOne = vertex.multiply(multipleOne); + List facePoints = facesForVertex.stream().map( face -> face.facePoint ).toList(); + Point nextVertexTwo = centroid(facePoints).multiply(multipleTwo); + List midEdges = edgesForVertex.stream().map( edge -> edge.midEdge ).toList(); + Point nextVertexThree = centroid(midEdges).multiply(multipleThree); + Point nextVertexFour = nextVertexOne.add(nextVertexTwo); + + nextVertices.put(vertex, nextVertexFour.add(nextVertexThree)); + } + } + return nextVertices; + } + + // Return the centroid point of the given list of points. + private static Point centroid(List points) { + return points.stream().reduce(Point.ZERO, (left, right) -> left.add(right) ).divide(points.size()); + } + + // Display the current Catmull-Clark surface on the console. + private static void displaySurface(List faces) { + System.out.println("Surface {"); + faces.stream().forEach(System.out::println); + System.out.println("}" + System.lineSeparator()); + } + + // A point of the current Catmull-Clark surface. + private static final class Point implements Comparable { + + public Point(double aX, double aY, double aZ) { + x = aX; y = aY; z = aZ; + } + + @Override + public int compareTo(Point other) { + if ( x == other.x ) { + if ( y == other.y ) { + return Double.compare(z, other.z); + } + return Double.compare(y, other.y); + } + return Double.compare(x, other.x); + } + + @Override + public boolean equals(Object other) { + return switch ( other ) { + case Point point -> x == point.x && y == point.y && z == point.z; + default -> false; + }; + } + + @Override + public int hashCode() { + return Objects.hash(x, y, z); + } + + public Point add(Point other) { + return new Point(x + other.x, y + other.y, z + other.z); + } + + public Point multiply(double factor) { + return new Point(x * factor, y * factor, z * factor); + } + + public Point divide(double factor) { + return multiply(1.0 / factor); + } + + public String toString() { + return "(" + format(x) + ", " + format(y) + ", " + format(z) + ")"; + } + + public static Point ZERO = new Point(0.0, 0.0, 0.0); + + private String format(double value) { + return ( value >= 0 ) ? String.format(" %.3f", value) : String.format("%.3f", value); + } + + private final double x, y, z; + + } + + // An edge of the current Catmull-Clark surface. + private static final class Edge { + + public Edge(Point aBegin, Point aEnd) { + if ( aBegin.compareTo(aEnd) <= 0 ) { + begin = aBegin; end = aEnd; + } else { + begin = aEnd; end = aBegin; + } + + midEdge = centroid(List.of( begin, end )); + } + + @Override + public boolean equals(Object other) { + return switch ( other ) { + case Edge edge -> begin.equals(edge.begin) && end.equals(edge.end); + default -> false; + }; + } + + @Override + public int hashCode() { + return Objects.hash(begin, end); + } + + public boolean contains(Point point) { + return point.equals(begin) || point.equals(end); + } + + public boolean holeEdge; + public Point edgePoint; + + public final Point begin, end, midEdge; + + } + + // A face of the current Catmull-Clark surface. + private static final class Face { + + public Face(List aVertices) { + vertices = new ArrayList(aVertices); + facePoint = centroid(vertices); + + edges = new ArrayList(); + for ( int i = 0; i < vertices.size() - 1; i++ ) { + edges.addLast( new Edge(vertices.get(i), vertices.get(i + 1)) ); + } + edges.addLast( new Edge(vertices.getLast(), vertices.getFirst()) );; + } + + public boolean contains(Point vertex) { + return vertices.contains(vertex); + } + + public boolean contains(Edge edge) { + return contains(edge.begin) && contains(edge.end); + } + + public String toString() { + return "Face: " + vertices.stream().map( point -> point.toString() ).collect(Collectors.joining("; ")); + } + + public final List vertices; + public final Point facePoint; + public final List edges; + + } + +} diff --git a/Task/Character-codes/Langur/character-codes.langur b/Task/Character-codes/Langur/character-codes.langur index 14eaab6abe..e24d7430fe 100644 --- a/Task/Character-codes/Langur/character-codes.langur +++ b/Task/Character-codes/Langur/character-codes.langur @@ -1,11 +1,11 @@ -val .a1 = 'a' -val .a2 = 97 -val .a3 = "a"[1] -val .a4 = s2cp "a", 1 -val .a5 = [.a1, .a2, .a3, .a4] +val a1 = 'a' +val a2 = 97 +val a3 = "a"[1] +val a4 = s2cp("a", 1) +val a5 = [a1, a2, a3, a4] -writeln .a1 == .a2 -writeln .a2 == .a3 -writeln .a3 == .a4 -writeln "numbers: ", join ", ", [.a1, .a2, .a3, .a4, .a5] -writeln "letters: ", join ", ", map cp2s, [.a1, .a2, .a3, .a4, .a5] +writeln a1 == a2 +writeln a2 == a3 +writeln a3 == a4 +writeln "numbers: ", join(", ", map(string, [a1, a2, a3, a4, a5])) +writeln "letters: ", join(", ", map(cp2s, [a1, a2, a3, a4, a5])) diff --git a/Task/Character-codes/PascalABC.NET/character-codes.pas b/Task/Character-codes/PascalABC.NET/character-codes.pas new file mode 100644 index 0000000000..deacfdd34e --- /dev/null +++ b/Task/Character-codes/PascalABC.NET/character-codes.pas @@ -0,0 +1,6 @@ +begin + var c := 'a'; + var i := c.Code; + Println(i); + Println(Chr(i)) +end. diff --git a/Task/Check-output-device-is-a-terminal/FutureBasic/check-output-device-is-a-terminal.basic b/Task/Check-output-device-is-a-terminal/FutureBasic/check-output-device-is-a-terminal.basic new file mode 100644 index 0000000000..28d25d962b --- /dev/null +++ b/Task/Check-output-device-is-a-terminal/FutureBasic/check-output-device-is-a-terminal.basic @@ -0,0 +1,17 @@ +include "NSLog.incl" + +local fn IsOutputDeviceTerminal as BOOL + int fileDescriptor + + cln fileDescriptor = fileno( stdout ); +end fn = fn isatty( fileDescriptor ) != 0 + +BOOL isTerminal : isTerminal = fn IsOutputDeviceTerminal + +if (isTerminal) + NSLog( @"Output is directed to a terminal." ) +else + NSLog( @"Output is not directed to a terminal." ) +end if + +HandleEvents diff --git a/Task/Check-that-file-exists/Langur/check-that-file-exists.langur b/Task/Check-that-file-exists/Langur/check-that-file-exists.langur index 841b121d3c..a275544023 100644 --- a/Task/Check-that-file-exists/Langur/check-that-file-exists.langur +++ b/Task/Check-that-file-exists/Langur/check-that-file-exists.langur @@ -1,7 +1,7 @@ -val .printresult = impure fn(.file) { - write .file, ": " - if val .p = prop(.file) { - if .p'isdir { +val printresult = impure fn(file) { + write file, ": " + if val p = prop(file) { + if p'isdir { writeln "is directory" } else { writeln "is file" @@ -11,7 +11,7 @@ val .printresult = impure fn(.file) { } } -.printresult("input.txt") -.printresult("/input.txt") -.printresult("docs") -.printresult("/docs") +printresult "input.txt" +printresult "/input.txt" +printresult "docs" +printresult "/docs" diff --git a/Task/Cheryls-birthday/11l/cheryls-birthday-1.11l b/Task/Cheryls-birthday/11l/cheryls-birthday-1.11l index 3412eb1266..c8d7794b3e 100644 --- a/Task/Cheryls-birthday/11l/cheryls-birthday-1.11l +++ b/Task/Cheryls-birthday/11l/cheryls-birthday-1.11l @@ -1,9 +1,4 @@ -T Date - String month - Int day - F (month, day) - .month = month - .day = day +T Date = (String month, Int day) V dates = [Date(‘May’, 15), Date(‘May’, 16), Date(‘May’, 19), Date(‘June’, 17), Date(‘June’, 18), Date(‘July’, 14), Date(‘July’, 16), Date(‘August’, 14), Date(‘August’, 15), Date(‘August’, 17)] diff --git a/Task/Circles-of-given-radius-through-two-points/11l/circles-of-given-radius-through-two-points.11l b/Task/Circles-of-given-radius-through-two-points/11l/circles-of-given-radius-through-two-points.11l index 1efeac8878..5bc57a434f 100644 --- a/Task/Circles-of-given-radius-through-two-points/11l/circles-of-given-radius-through-two-points.11l +++ b/Task/Circles-of-given-radius-through-two-points/11l/circles-of-given-radius-through-two-points.11l @@ -1,14 +1,7 @@ -T Circle - Float x, y, r - +T Circle((Float x, Float y, Float r)) F String() R ‘Circle(x=#.6, y=#.6, r=#.6)’.format(.x, .y, .r) - F (x, y, r) - .x = x - .y = y - .r = r - T Error String msg F (msg) diff --git a/Task/Classes/PascalABC.NET/classes.pas b/Task/Classes/PascalABC.NET/classes.pas new file mode 100644 index 0000000000..7d5590bdae --- /dev/null +++ b/Task/Classes/PascalABC.NET/classes.pas @@ -0,0 +1,16 @@ +type Person = class + Name: string; + Age: integer; +public + constructor (Name: string; Age: integer); + begin + Self.Name := Name; + Self.Age := Age; + end; + procedure Output := Print($'{Name} {Age}'); +end; + +begin + var p := new Person('John',18); + p.Output +end. diff --git a/Task/Closest-pair-problem/PascalABC.NET/closest-pair-problem.pas b/Task/Closest-pair-problem/PascalABC.NET/closest-pair-problem.pas new file mode 100644 index 0000000000..5d83e6b24a --- /dev/null +++ b/Task/Closest-pair-problem/PascalABC.NET/closest-pair-problem.pas @@ -0,0 +1,24 @@ +type Point = auto class + x,y: real; + function Distance(p: Point): real := Sqrt((x-p.x)**2 + (y-p.y)**2); +end; + +function Pnt(x,y: real) := new Point(x,y); + +function RandomPoint: Point := Pnt(RandomReal(0,10),RandomReal(0,10)); + +function ClosestPair(points: array of Point): (Point,Point); +begin + var pairs := points.Combinations(2); + var pair := pairs.MinBy(pair -> pair[0].Distance(pair[1])); + Result := (pair[0],pair[1]); +end; + +begin + var points := ArrGen(10,i -> RandomPoint); + points.Println; + + var ClPair := ClosestPair(points); + + Println(ClPair,ClPair[0].Distance(ClPair[1])); +end. diff --git a/Task/Closures-Value-capture/Free-Pascal-Lazarus/closures-value-capture.pas b/Task/Closures-Value-capture/Free-Pascal-Lazarus/closures-value-capture.pas new file mode 100644 index 0000000000..58142c4cd7 --- /dev/null +++ b/Task/Closures-Value-capture/Free-Pascal-Lazarus/closures-value-capture.pas @@ -0,0 +1,26 @@ +program testthis; +{$mode objfpc}{$modeswitch functionreferences}{$modeswitch anonymousfunctions} +type + TFuncIntResult = reference to function: Integer; + +// use function that returns anonymous method to avoid capturing the loop variable +function CreateFunc(i: Integer): TFuncIntResult; +begin + Result := + function: Integer + begin + Result := i * i; + end; +end; + +var + Funcs: array[0..9] of TFuncIntResult; + i: integer; +begin + // create 10 anonymous functions + for i := Low(Funcs) to High(Funcs) do + Funcs[i] := CreateFunc(i); + // call all 10 functions + for i := Low(Funcs) to High(Funcs) do + Writeln(Funcs[i]()); +end. diff --git a/Task/Closures-Value-capture/Go/closures-value-capture.go b/Task/Closures-Value-capture/Go/closures-value-capture-1.go similarity index 100% rename from Task/Closures-Value-capture/Go/closures-value-capture.go rename to Task/Closures-Value-capture/Go/closures-value-capture-1.go diff --git a/Task/Closures-Value-capture/Go/closures-value-capture-2.go b/Task/Closures-Value-capture/Go/closures-value-capture-2.go new file mode 100644 index 0000000000..432b04a5de --- /dev/null +++ b/Task/Closures-Value-capture/Go/closures-value-capture-2.go @@ -0,0 +1,14 @@ +package main + +import "fmt" + +func main() { + fs := make([]func() int, 10) + for i := range fs { + fs[i] = func() int { + return i * i + } + } + fmt.Println("func #0:", fs[0]()) + fmt.Println("func #3:", fs[3]()) +} diff --git a/Task/Collections/PascalABC.NET/collections.pas b/Task/Collections/PascalABC.NET/collections.pas new file mode 100644 index 0000000000..5b1d1d7212 --- /dev/null +++ b/Task/Collections/PascalABC.NET/collections.pas @@ -0,0 +1,25 @@ +begin + // build-in array + var a: array of integer := new integer[5] (1,2,3,4,5); + // build-in multidimensional array + var aa: array [,] of integer := new integer[4,3]((1,2,3),(4,5,6),(7,8,9),(1,2,3)); + // List is a resizable array + var lst := new List(a); + lst.Add(1); + lst.AddRange(|2,3|); + // HashSet is an unordered set, SortedSet is ordered + var hs := new HashSet; + var ss := new SortedSet; + hs.Add(1); ss.Add(2); + // Dictionary is an unordered map, SortedDictionary is ordered + var d := new Dictionary; + d['str1'] := 1; d['str2'] := 3; + var sd := new SortedDictionary; + sd['str1'] := 1; sd['str2'] := 3; + + // Stack and Queue + var s := new Stack; + s.Push(1); s.Push(2); s.Push(3); + var q := new Queue; + q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); +end. diff --git a/Task/Color-wheel/Ada/color-wheel.ada b/Task/Color-wheel/Ada/color-wheel.ada new file mode 100644 index 0000000000..24fc322aeb --- /dev/null +++ b/Task/Color-wheel/Ada/color-wheel.ada @@ -0,0 +1,89 @@ +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; +procedure Color_Wheel is + type Colour_Level is mod 2 ** 8; + type RGB is record + R, G, B : Colour_Level; + end record; + BLACK : constant RGB := (0, 0, 0); + type Image_Grid is array (Integer range <>, Integer range <>) of RGB; + + Diameter : constant Integer := 480; + Radius : constant Integer := Diameter / 2; + Radius_Fl : constant Float := Float (Radius); + Image : Image_Grid (-Radius .. Radius, -Radius .. Radius); + V : constant Float := 1.0; + + procedure Write_PPM (Grid : Image_Grid; Filename : String) is + PPM_File : File_Type; + begin + Create (PPM_File, Out_File, Filename); + Put_Line (PPM_File, "P3"); + Put_Line (PPM_File, Grid'Length (1)'Image & Grid'Length (2)'Image); + Put_Line (PPM_File, "255"); + for Y in reverse -Radius .. Radius loop + for X in -Radius .. Radius loop + Put_Line (PPM_File, Grid (X, Y).R'Image & Grid (X, Y).G'Image & Grid (X, Y).B'Image); + end loop; + end loop; + Close (PPM_File); + end Write_PPM; + + function Atan2 (Y, X : Float) return Float is + Res : Float; + begin + if X > 0.0 then Res := Arctan (Y / X); + elsif X < 0.0 and then Y >= 0.0 then Res := Arctan (Y / X) + Pi; + elsif X < 0.0 and then Y < 0.0 then Res := Arctan (Y / X) - Pi; + elsif X = 0.0 and then Y > 0.0 then Res := Pi / 2.0; + elsif X = 0.0 and then Y > 0.0 then Res := -Pi / 2.0; + else Res := -Pi / 2.0; -- Technically: Undefined + end if; + return Res; + end Atan2; +begin + for Y in -Radius .. Radius loop + for X in -Radius .. Radius loop + declare + XX : constant Float := Float (X); + YY : constant Float := Float (Y); + Dist : constant Float := Sqrt (XX ** 2 + YY ** 2); + Hue_Int, Hue_Frac, P, Q, T : Float; + Point : RGB; + begin + if Dist <= Radius_Fl then + declare + Sat : constant Float := Dist / Radius_Fl; + Hue : Float := Atan2 (YY, XX); + RR, GG, BB : Float; + begin + if Hue < 0.0 then Hue := Hue + 2.0 * Pi; end if; + Hue := (Hue * 180.0 / Pi) / 60.0; + Hue_Int := Float'Floor (Hue); + Hue_Frac := Hue - Hue_Int; + P := V - Sat; + Q := V - Sat * Hue_Frac; + T := V - Sat * (V - Hue_Frac); + case Integer (Hue_Int) is + when 0 => RR := V; GG := T; BB := P; + when 1 => RR := Q; GG := V; BB := P; + when 2 => RR := P; GG := V; BB := T; + when 3 => RR := P; GG := Q; BB := V; + when 4 => RR := T; GG := P; BB := V; + when 5 => RR := V; GG := P; BB := Q; + when others => null; + end case; + Point.R := Colour_Level (Integer (Float'Floor (RR * 255.0))); + Point.G := Colour_Level (Integer (Float'Floor (GG * 255.0))); + Point.B := Colour_Level (Integer (Float'Floor (BB * 255.0))); + Image (X, Y) := Point; + end; + else + Image (X, Y) := BLACK; + end if; + end; + end loop; + end loop; + Write_PPM (Image, "color_wheel.ppm"); +end Color_Wheel; diff --git a/Task/Combinations-and-permutations/Ada/combinations-and-permutations.ada b/Task/Combinations-and-permutations/Ada/combinations-and-permutations.ada new file mode 100644 index 0000000000..a93710e140 --- /dev/null +++ b/Task/Combinations-and-permutations/Ada/combinations-and-permutations.ada @@ -0,0 +1,69 @@ +pragma Ada_2022; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Big_Numbers.Big_Integers; +use Ada.Numerics.Big_Numbers.Big_Integers; +with Interfaces; use Interfaces; + +procedure Combs_Perms is + + function U64_Perm (N, K : Unsigned_64) return Unsigned_64 is + P : Unsigned_64 := 1; + begin + if K = 0 then + P := 0; + else + for I in 0 .. K - 1 loop + P := P * (N - I); + end loop; + end if; + return P; + end U64_Perm; + + function Big_Perm (N, K : Natural) return Big_Natural is + P : Big_Natural := 1; + begin + if K = 0 then + P := 0; + else + for I in 0 .. K - 1 loop + P := P * To_Big_Integer (N - I); + end loop; + end if; + return P; + end Big_Perm; + + function U64_Comb (N, K : Unsigned_64) return Unsigned_64 is + Adj_K : constant Unsigned_64 := (if N - K < K then N - K else K); + C : Unsigned_64 := U64_Perm (N, Adj_K); + begin + if K = 0 then + C := 0; + else + for I in reverse 1 .. Adj_K loop + C := C / I; + end loop; + end if; + return C; + end U64_Comb; + + function Big_Comb (N, K : Natural) return Big_Natural is + Adj_K : constant Natural := (if N - K < K then N - K else K); + C : Big_Natural := Big_Perm (N, Adj_K); + begin + for I in reverse 1 .. Adj_K loop + C := C / To_Big_Integer (I); + end loop; + return C; + end Big_Comb; + +begin + Put_Line ("P(1, 0) =" & U64_Perm (1, 0)'Image); + Put_Line ("P(12, 4) =" & U64_Perm (12, 4)'Image); + Put_Line ("P(60, 20) =" & U64_Perm (60, 20)'Image); + Put_Line ("P(105, 103) =" & Big_Perm (105, 103)'Image); + Put_Line ("P(15000, 333) =" & Big_Perm (10000, 333)'Image); + + Put_Line ("C(10, 5) =" & U64_Comb (10, 5)'Image); + Put_Line ("C(60, 30) =" & Big_Comb (60, 30)'Image); + Put_Line ("C(900, 674) =" & Big_Comb (900, 674)'Image); +end Combs_Perms; diff --git a/Task/Combinations/EasyLang/combinations.easy b/Task/Combinations/EasyLang/combinations.easy index 17b909ce4a..3ac717f830 100644 --- a/Task/Combinations/EasyLang/combinations.easy +++ b/Task/Combinations/EasyLang/combinations.easy @@ -3,13 +3,13 @@ m = 3 len result[] m # proc combinations pos val . . - if pos <= m - for i = val to n - m - result[pos] = pos + i - combinations pos + 1 i - . - else + if pos > m print result[] + return + . + for i = val to pos + n - m + result[pos] = i + combinations pos + 1 i + 1 . . -combinations 1 0 +combinations 1 1 diff --git a/Task/Combinations/FutureBasic/combinations.basic b/Task/Combinations/FutureBasic/combinations.basic new file mode 100644 index 0000000000..6953e2870c --- /dev/null +++ b/Task/Combinations/FutureBasic/combinations.basic @@ -0,0 +1,16 @@ +void local fn Combinations( currStr as CFStringRef, start as int, stp as int, depth as int ) + int i + + for i = start to stp + if depth = 0 then printf @"%@ %d", currStr, i + fn Combinations( fn StringWithFormat( @"%@ %d", currStr, i ), i+1, stp, depth-1 ) + next +end fn + +int n : n = 3 +int m : m = 5 + +printf @" %d combinations of integers 0 through %d are:", n, m-1 +fn Combinations( @"", 0, m-1, n-1 ) + +HandleEvents diff --git a/Task/Combinations/J/combinations-10.j b/Task/Combinations/J/combinations-10.j new file mode 100644 index 0000000000..13e4c36a64 --- /dev/null +++ b/Task/Combinations/J/combinations-10.j @@ -0,0 +1 @@ +combb=: (#~ ((-:/:~)>/:~-:\:~)"1)@(# #: [: i. ^~) diff --git a/Task/Combinations/J/combinations-6.j b/Task/Combinations/J/combinations-6.j index 980099ca22..73e2b25046 100644 --- a/Task/Combinations/J/combinations-6.j +++ b/Task/Combinations/J/combinations-6.j @@ -1,7 +1 @@ - combr=: dyad define - if.(x=#y) +. x=1 do. - y - else. - (({.y) ,. (x-1) combr (}.y)) , (x combr }.y) - end. -) +combr=: ((0,.$:&.<:),1+($:<:))` ([:i.<:,[) @.(>:+.0=[)M. diff --git a/Task/Combinations/J/combinations-7.j b/Task/Combinations/J/combinations-7.j index 13e4c36a64..399595ae74 100644 --- a/Task/Combinations/J/combinations-7.j +++ b/Task/Combinations/J/combinations-7.j @@ -1 +1,7 @@ -combb=: (#~ ((-:/:~)>/:~-:\:~)"1)@(# #: [: i. ^~) + combr1=: dyad define + if.(x=#y) +. x=1 do. + y + else. + (({.y) ,. (x-1) combr (}.y)) , (x combr }.y) + end. +) diff --git a/Task/Combinations/J/combinations-8.j b/Task/Combinations/J/combinations-8.j new file mode 100644 index 0000000000..ec65fe462f --- /dev/null +++ b/Task/Combinations/J/combinations-8.j @@ -0,0 +1 @@ +combr1=: (({.@],.<:@($:}.)),($:}.))` ] @.((= #)+.1=[) diff --git a/Task/Combinations/J/combinations-9.j b/Task/Combinations/J/combinations-9.j new file mode 100644 index 0000000000..b5d40efaeb --- /dev/null +++ b/Task/Combinations/J/combinations-9.j @@ -0,0 +1 @@ +comb3=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) diff --git a/Task/Combinations/Uiua/combinations.uiua b/Task/Combinations/Uiua/combinations.uiua new file mode 100644 index 0000000000..cd3971ba40 --- /dev/null +++ b/Task/Combinations/Uiua/combinations.uiua @@ -0,0 +1,10 @@ +# both from https://github.com/Omnikar/uiua-math/blob/main/lib.ua +PowerSet ← ⍚▽⋯⇡ⁿ:2⧻⟜¤ +Perms ← ☇1⍉∧(≡↻⇡⟜↯+1⟜⊂):¤¤°⊂ + +Permute ← ≡⊏⊙¤⊸(Perms⇡⧻) # Optional helper function. + +# Order is unimportant here. If order is important prepend `☇1≡Permute` to the results. +Choose ← ≡°□▽=⊙(⊸(≡◇⧻)PowerSet) + +⊏⊸⍏Choose 3 ⇡5 # Choose and sort results diff --git a/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas b/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas new file mode 100644 index 0000000000..657c2b12b1 --- /dev/null +++ b/Task/Command-line-arguments/PascalABC.NET/command-line-arguments.pas @@ -0,0 +1,4 @@ +begin + for var i:=1 to ParamCount do + Print(ParamStr(i)); +end. diff --git a/Task/Comments/FutureBasic/comments.basic b/Task/Comments/FutureBasic/comments.basic index d05a6c06d6..52cd38da36 100644 --- a/Task/Comments/FutureBasic/comments.basic +++ b/Task/Comments/FutureBasic/comments.basic @@ -1,5 +1,4 @@ // Single line comment -' Single line comment rem Single line comment /* Single line comment */ diff --git a/Task/Comments/PascalABC.NET/comments.pas b/Task/Comments/PascalABC.NET/comments.pas new file mode 100644 index 0000000000..3af3369dfc --- /dev/null +++ b/Task/Comments/PascalABC.NET/comments.pas @@ -0,0 +1,7 @@ +(* This is a + multiline comment *) + +{ This is also a + multiline comment } + +// This is a single line comment diff --git a/Task/Compare-a-list-of-strings/PascalABC.NET/compare-a-list-of-strings.pas b/Task/Compare-a-list-of-strings/PascalABC.NET/compare-a-list-of-strings.pas new file mode 100644 index 0000000000..dd7dd8fda0 --- /dev/null +++ b/Task/Compare-a-list-of-strings/PascalABC.NET/compare-a-list-of-strings.pas @@ -0,0 +1,12 @@ +function IsSorted(lst: sequence of string): boolean + := lst.Order.SequenceEqual(lst); + +function IsStrictAscending(lst: sequence of string): boolean + := lst.Pairwise.All(x -> x[0] < x[1]); + +begin + var strings := |'abc','abc','abc','abc'|; + Print(AllEqual(strings)); + var strings1 := |'abc','abd','ade','aef'|; + Print(IsStrictAscending(strings1)); +end. diff --git a/Task/Compare-length-of-two-strings/Emacs-Lisp/compare-length-of-two-strings.l b/Task/Compare-length-of-two-strings/Emacs-Lisp/compare-length-of-two-strings.l new file mode 100644 index 0000000000..2438b3da54 --- /dev/null +++ b/Task/Compare-length-of-two-strings/Emacs-Lisp/compare-length-of-two-strings.l @@ -0,0 +1,7 @@ +(defun sort-list-by-string-length (list-of-strings) + "Order LIST-OF-STRINGS from longest to shortest." + (sort list-of-strings 'longer-string)) ; sort by "longer-string" function below + +(defun longer-string (string-1 string-2) + "Test if STRING-1 is longer than STRING-2." + (> (length string-1) (length string-2))) ; is STRING-1 longer than STRING-2? diff --git a/Task/Compare-length-of-two-strings/Kotlin/compare-length-of-two-strings.kotlin b/Task/Compare-length-of-two-strings/Kotlin/compare-length-of-two-strings.kotlin new file mode 100644 index 0000000000..4e17dbcda7 --- /dev/null +++ b/Task/Compare-length-of-two-strings/Kotlin/compare-length-of-two-strings.kotlin @@ -0,0 +1,16 @@ +fun main() { + printTwoStrings("a short string", "a fairly long string") + printStringsInDescendingLengthOrder(listOf("abcd", "123456789", "abcdef", "1234567")) +} + +fun printTwoStrings(a: String, b: String) { + val (shorter, longer) = if (a.length < b.length) Pair(a, b) else Pair(b, a) + println("%3d: %s".format(longer.length, longer)) + println("%3d: %s".format(shorter.length, shorter)) +} + +fun printStringsInDescendingLengthOrder(strings: Collection) { + strings.sortedByDescending(String::length).forEach { + println("%3d: %s".format(it.length, it)) + } +} diff --git a/Task/Compare-length-of-two-strings/PascalABC.NET/compare-length-of-two-strings.pas b/Task/Compare-length-of-two-strings/PascalABC.NET/compare-length-of-two-strings.pas new file mode 100644 index 0000000000..db7a579134 --- /dev/null +++ b/Task/Compare-length-of-two-strings/PascalABC.NET/compare-length-of-two-strings.pas @@ -0,0 +1,10 @@ +begin + var (s1,s2) := ('Bye','Hello'); + if s1.Length < s2.Length then + Swap(s1,s2); + Println(s1,s1.Length); + Println(s2,s2.Length); + Println; + var strArr := |'wolf','cat','crocodile','tiger'|; + strArr.OrderByDescending(s -> s.Length).PrintLines(s -> $'{s,9} - {s.Length}'); +end. diff --git a/Task/Compare-length-of-two-strings/R/compare-length-of-two-strings.r b/Task/Compare-length-of-two-strings/R/compare-length-of-two-strings.r new file mode 100644 index 0000000000..8fc11937e0 --- /dev/null +++ b/Task/Compare-length-of-two-strings/R/compare-length-of-two-strings.r @@ -0,0 +1,13 @@ +length_of_strings <- function(list_of_strings){ + string_size = nchar(list_of_strings) + string_order = order(string_size,decreasing = T) + + for (k in string_order){ + cat("\n") + cat(paste0("string : ", list_of_strings[k]," | length : ", string_size[k] , " character(s)")) + } +} + +list_of_strings = c("abcd","123456789","abcdef","1234567") + +length_of_strings(list_of_strings) diff --git a/Task/Compare-length-of-two-strings/Swift/compare-length-of-two-strings.swift b/Task/Compare-length-of-two-strings/Swift/compare-length-of-two-strings.swift new file mode 100644 index 0000000000..7cb09c4575 --- /dev/null +++ b/Task/Compare-length-of-two-strings/Swift/compare-length-of-two-strings.swift @@ -0,0 +1,4 @@ + let list = ["abcd", "abcd🤦‍♂️", "123456789", "abcdef", "1234567"] + list.sorted { $0.count > $1.count }.forEach { string in + print("\(string) has \(string.count) characters") + } diff --git a/Task/Compare-length-of-two-strings/Transd/compare-length-of-two-strings.transd b/Task/Compare-length-of-two-strings/Transd/compare-length-of-two-strings.transd deleted file mode 100644 index ec3fe02caf..0000000000 --- a/Task/Compare-length-of-two-strings/Transd/compare-length-of-two-strings.transd +++ /dev/null @@ -1,11 +0,0 @@ -#lang transd - -MainModule: { - v: ["abcd","123456789","abcdef","1234567"], - - _start: (λ - (for s in (sort v (λ l String() r String() - (ret (< (size r) (size l))))) do - (lout width: 10 s " : " (size s) " code points") ) - ) -} diff --git a/Task/Compiler-AST-interpreter/00-TASK.txt b/Task/Compiler-AST-interpreter/00-TASK.txt index 36979628c5..dfc0b2f7ea 100644 --- a/Task/Compiler-AST-interpreter/00-TASK.txt +++ b/Task/Compiler-AST-interpreter/00-TASK.txt @@ -1,9 +1,9 @@ -AST interpreter +{{task heading|AST interpreter}} An AST interpreter interprets an [https://en.wikipedia.org/wiki/Abstract_syntax_tree Abstract Syntax Tree (AST)] produced by a [[Compiler/syntax_analyzer|Syntax Analyzer]]. -{{task heading}} +;Task Take the AST output from the Syntax analyzer [[Compiler/syntax_analyzer|task]], and interpret it as appropriate. Refer to the [[Compiler/syntax_analyzer|Syntax analyzer task]] for details of the AST. diff --git a/Task/Compiler-code-generator/00-TASK.txt b/Task/Compiler-code-generator/00-TASK.txt index 2db4f795f3..abd11dcc6f 100644 --- a/Task/Compiler-code-generator/00-TASK.txt +++ b/Task/Compiler-code-generator/00-TASK.txt @@ -1,5 +1,265 @@ -Code Generator +{{task heading|Code Generator}} A code generator translates the output of the syntax analyzer and/or semantic analyzer into lower level code, either assembly, object, or virtual. +;Task + +Take the output of the Syntax analyzer [[Compiler/syntax_analyzer|task]] - which is a [[Flatten_a_list|flattened]] Abstract Syntax Tree (AST) - and convert it to virtual machine code, that can be run by the +[[Compiler/virtual_machine_interpreter|Virtual machine interpreter]]. The output is in text format, and represents virtual assembly code. + +The program should read input from a file and/or stdin, and write output to a file and/or +stdout. + +;Example - given the simple program (below), stored in a file called while.t, create the list of tokens, using one of the Lexical analyzer [[Compiler/lexical_analyzer|solutions]] + + lex < while.t > while.lex + +;Run one of the Syntax analyzer [[Compiler/syntax_analyzer|solutions]]: + + parse < while.lex > while.ast + +;while.ast can be input into the code generator. + +;The following table shows the input to lex, lex output, the AST produced by the parser, and the generated virtual assembly code. + + Run as: lex < while.t | parse | gen + +{| class="wikitable" +|- +! Input to lex +! Output from lex, input to parse +! Output from parse +! Output from gen, input to VM +|- +| style="vertical-align:top" | +count = 1; +while (count < 10) { + print("count is: ", count, "\n"); + count = count + 1; +} + +| style="vertical-align:top" | +
+    1      1   Identifier      count
+    1      7   Op_assign
+    1      9   Integer              1
+    1     10   Semicolon
+    2      1   Keyword_while
+    2      7   LeftParen
+    2      8   Identifier      count
+    2     14   Op_less
+    2     16   Integer             10
+    2     18   RightParen
+    2     20   LeftBrace
+    3      5   Keyword_print
+    3     10   LeftParen
+    3     11   String          "count is: "
+    3     23   Comma
+    3     25   Identifier      count
+    3     30   Comma
+    3     32   String          "\n"
+    3     36   RightParen
+    3     37   Semicolon
+    4      5   Identifier      count
+    4     11   Op_assign
+    4     13   Identifier      count
+    4     19   Op_add
+    4     21   Integer              1
+    4     22   Semicolon
+    5      1   RightBrace
+    6      1   End_of_input
+ +| style="vertical-align:top" | +
Sequence
+Sequence
+;
+Assign
+Identifier    count
+Integer       1
+While
+Less
+Identifier    count
+Integer       10
+Sequence
+Sequence
+;
+Sequence
+Sequence
+Sequence
+;
+Prts
+String        "count is: "
+;
+Prti
+Identifier    count
+;
+Prts
+String        "\n"
+;
+Assign
+Identifier    count
+Add
+Identifier    count
+Integer       1
+ +| style="vertical-align:top" | +
Datasize: 1 Strings: 2
+"count is: "
+"\n"
+   0 push  1
+   5 store [0]
+  10 fetch [0]
+  15 push  10
+  20 lt
+  21 jz     (43) 65
+  26 push  0
+  31 prts
+  32 fetch [0]
+  37 prti
+  38 push  1
+  43 prts
+  44 fetch [0]
+  49 push  1
+  54 add
+  55 store [0]
+  60 jmp    (-51) 10
+  65 halt
+|} + +; Input format: + +As shown in the table, above, the output from the [[Compiler/syntax_analyzer|syntax analyzer]] is a flattened AST. + +In the AST, Identifier, Integer, and String, are terminal nodes, e.g, they do not have child nodes. + +Loading this data into an internal parse tree should be as simple as: + + +def load_ast() + line = readline() + # Each line has at least one token + line_list = tokenize the line, respecting double quotes + + text = line_list[0] # first token is always the node type + + if text == ";" + return None + + node_type = text # could convert to internal form if desired + + # A line with two tokens is a leaf node + # Leaf nodes are: Identifier, Integer String + # The 2nd token is the value + if len(line_list) > 1 + return make_leaf(node_type, line_list[1]) + + left = load_ast() + right = load_ast() + return make_node(node_type, left, right) + + +; Output format - refer to the table above + +* The first line is the header: Size of data, and number of constant strings. +** size of data is the number of 32-bit unique variables used. In this example, one variable, '''count''' +** number of constant strings is just that - how many there are +* After that, the constant strings +* Finally, the assembly code + +;Registers: + +* sp: the stack pointer - points to the next top of stack. The stack is a 32-bit integer array. + +* pc: the program counter - points to the current instruction to be performed. The code is an array of bytes. + +;Data: + +32-bit integers and strings + +;Instructions: + +Each instruction is one byte. The following instructions also have a 32-bit integer operand: + + fetch [index] + +where index is an index into the data array. + + store [index] + +where index is an index into the data array. + + push n + +where value is a 32-bit integer that will be pushed onto the stack. + + jmp (n) addr + +where (n) is a 32-bit integer specifying the distance between the current location and the +desired location. addr is an unsigned value of the actual code address. + + jz (n) addr + +where (n) is a 32-bit integer specifying the distance between the current location and the +desired location. addr is an unsigned value of the actual code address. + +The following instructions do not have an operand. They perform their operation directly +against the stack: + +For the following instructions, the operation is performed against the top two entries in +the stack: + + add + sub + mul + div + mod + lt + gt + le + ge + eq + ne + and + or + +For the following instructions, the operation is performed against the top entry in the +stack: + + neg + not + + prtc + +Print the word at stack top as a character. + + prti + +Print the word at stack top as an integer. + + prts + +Stack top points to an index into the string pool. Print that entry. + + halt + +Unconditional stop. + +; Additional examples + +Your solution should pass all the test cases above and the additional tests found '''[[Compiler/Sample_programs|Here]]'''. + +{{task heading|Reference}} + +The C and Python versions can be considered reference implementations. + +;Related Tasks + +* [[Compiler/lexical_analyzer|Lexical Analyzer task]] +* [[Compiler/syntax_analyzer|Syntax Analyzer task]] +* [[Compiler/virtual_machine_interpreter|Virtual Machine Interpreter task]] +* [[Compiler/AST_interpreter|AST Interpreter task]] + +
+__TOC__ + diff --git a/Task/Compiler-lexical-analyzer/00-TASK.txt b/Task/Compiler-lexical-analyzer/00-TASK.txt index 400132cd5a..c746bdc789 100644 --- a/Task/Compiler-lexical-analyzer/00-TASK.txt +++ b/Task/Compiler-lexical-analyzer/00-TASK.txt @@ -4,8 +4,6 @@ Definition from [https://en.wikipedia.org/wiki/Lexical_analysis Wikipedia]: : ''Lexical analysis is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of tokens (strings with an identified "meaning"). A program that performs lexical analysis may be called a lexer, tokenizer, or scanner (though "scanner" is also used to refer to the first stage of a lexer).'' -{{task heading}} - Create a lexical analyzer for the simple programming language specified below. The program should read input from a file and/or stdin, and write output to a file and/or stdout. If the language being used has a lexer module/library/class, it would be great diff --git a/Task/Compiler-syntax-analyzer/00-TASK.txt b/Task/Compiler-syntax-analyzer/00-TASK.txt index 543426c5ba..81e1d6fc05 100644 --- a/Task/Compiler-syntax-analyzer/00-TASK.txt +++ b/Task/Compiler-syntax-analyzer/00-TASK.txt @@ -1,10 +1,8 @@ -Syntax Analyzer +{{task heading|Syntax Analyzer}} A Syntax analyzer transforms a token stream (from the [[Compiler/lexical_analyzer|Lexical analyzer]]) into a Syntax tree, based on a grammar. -{{task heading}} - Take the output from the Lexical analyzer [[Compiler/lexical_analyzer|task]], and convert it to an [https://en.wikipedia.org/wiki/Abstract_syntax_tree Abstract Syntax Tree (AST)], based on the grammar below. The output should be in a [[Flatten_a_list|flattened format.]] diff --git a/Task/Compiler-virtual-machine-interpreter/00-TASK.txt b/Task/Compiler-virtual-machine-interpreter/00-TASK.txt index 9d3bfd9853..f2c48936bc 100644 --- a/Task/Compiler-virtual-machine-interpreter/00-TASK.txt +++ b/Task/Compiler-virtual-machine-interpreter/00-TASK.txt @@ -1,9 +1,7 @@ -Virtual Machine Interpreter +{{task heading|Virtual Machine Interpreter}} A virtual machine implements a computer in software. -{{task heading}} - Write a virtual machine interpreter. This interpreter should be able to run virtual assembly language programs created via the [[Compiler/code_generator|task]]. This is a byte-coded, 32-bit word stack based virtual machine. @@ -11,7 +9,7 @@ byte-coded, 32-bit word stack based virtual machine. The program should read input from a file and/or stdin, and write output to a file and/or stdout. -Input format: +{{task heading|Input format}} Given the following program: @@ -67,7 +65,7 @@ Next comes the actual virtual assembly code. The first number is the code addre instruction. After that is the instruction mnemonic, followed by optional operands, depending on the instruction. -Registers: +{{task heading|Registers}} sp: the stack pointer - points to the next top of stack. The stack is a 32-bit integer @@ -81,7 +79,7 @@ Data: data string pool -Instructions: +{{task heading|Instructions}} Each instruction is one byte. The following instructions also have a 32-bit integer operand: diff --git a/Task/Compiler-virtual-machine-interpreter/C++/compiler-virtual-machine-interpreter.cpp b/Task/Compiler-virtual-machine-interpreter/C++/compiler-virtual-machine-interpreter.cpp new file mode 100644 index 0000000000..0d2720106f --- /dev/null +++ b/Task/Compiler-virtual-machine-interpreter/C++/compiler-virtual-machine-interpreter.cpp @@ -0,0 +1,190 @@ +#include +#include +#include +#include +#include +#include +#include + +std::vector split_string(const std::string& text, const char& delimiter) { + std::vector lines; + std::istringstream stream(text); + std::string line; + while ( std::getline(stream, line, delimiter) ) { + if ( ! line.empty() ) { + lines.emplace_back(line); + } + } + return lines; +} + +std::string parseString(const std::string& text) { + std::string result = ""; + uint32_t i = 0; + while ( i < text.length() ) { + if ( text[i] == '\\' && i + 1 < text.length() ) { + if ( text[i + 1] == 'n' ) { + result += "\n"; + i++; + } else if ( text[i + 1] == '\\') { + result += "\\"; + i++; + } + } else { + result += text[i]; + } + i++; + } + + return result; +} + +void add_to_codes(const uint32_t& number, std::vector& codes) { + for ( uint32_t i = 0; i < 32; i += 8 ) { + codes.emplace_back((number >> i) & 0xff); + } +} + +uint32_t operand(const uint32_t& index, const std::vector& codes) { + uint32_t result = 0; + for ( uint32_t i = index + 3; i >= index; --i ) { + result = ( result << 8 ) + codes[i]; + } + + return result; +} + +struct VirtualMachineInfo { + uint32_t data_size; + std::vector vm_strings; + std::vector codes; +}; + +enum class Op_code { + HALT, ADD, SUB, MUL, DIV, MOD, LT, GT, LE, GE, EQ, NE, AND, OR, NEG, NOT, + PRTC, PRTI, PRTS, FETCH, STORE, PUSH, JMP, JZ +}; + +std::unordered_map string_to_enum = { + { "halt", Op_code::HALT }, { "add", Op_code::ADD }, { "sub", Op_code::SUB }, + { "mul", Op_code::MUL }, { "div", Op_code::DIV }, { "mod", Op_code::MOD }, + { "lt", Op_code::LT }, { "gt", Op_code::GT }, { "le", Op_code::LE }, + { "ge", Op_code::GE }, { "eq", Op_code::EQ }, { "ne", Op_code::NE }, + { "and", Op_code::AND }, { "or", Op_code::OR }, { "neg", Op_code::NEG }, + { "not", Op_code::NOT }, { "prtc", Op_code::PRTC }, { "prti", Op_code::PRTI }, + { "prts", Op_code::PRTS }, { "fetch", Op_code::FETCH }, { "store", Op_code::STORE }, + { "push", Op_code::PUSH }, { "jmp", Op_code::JMP }, { "jz", Op_code::JZ } +}; + +VirtualMachineInfo load_code(const std::string& file_path) { + std::ifstream stream(file_path); + std::vector lines; + std::string line; + + while ( std::getline(stream, line) ) { + lines.emplace_back(line); + } + + line = lines.front(); + if ( line.substr(0, 3) == "lex" ) { + lines.erase(lines.begin()); + line = lines.front(); + } + + std::vector sections = split_string(line, ' '); + const uint32_t data_size = std::stoi(sections[1]); + const uint32_t string_count = std::stoi(sections[3]); + + std::vector vm_strings = { }; + for ( uint32_t i = 1; i <= string_count; ++i ) { + std::string content = lines[i].substr(1, lines[i].length() - 2); + vm_strings.emplace_back(parseString(content)); + } + + uint32_t offset = 0; + std::vector codes = { }; + for ( uint32_t i = string_count + 1; i < lines.size(); ++i ) { + sections = split_string(lines[i], ' '); + offset = std::stoi(sections[0]); + Op_code op_code = string_to_enum[sections[1]]; + codes.emplace_back(static_cast(op_code)); + + switch ( op_code ) { + case Op_code::FETCH : + case Op_code::STORE : + add_to_codes(std::stoi(sections[2] + .substr(1, sections[2].length() - 2)), codes); break; + case Op_code::PUSH : add_to_codes(std::stoi(sections[2]), codes); break; + case Op_code::JMP : + case Op_code::JZ : add_to_codes(std::stoi(sections[3]) - offset - 1, codes); break; + default : break; + } + } + + return VirtualMachineInfo(data_size, vm_strings, codes); +} + +void runVirtualMachine( + const uint32_t& data_size, const std::vector& vm_strings, const std::vector& codes) { + const uint32_t word_size = 4; + std::vector stack(data_size, 0); + uint32_t index = 0; + Op_code op_code; + + while ( op_code != Op_code::HALT ) { + op_code = static_cast(codes[index]); + index++; + + switch ( op_code ) { + case Op_code::HALT : break; + case Op_code::ADD : stack[stack.size() - 2] += stack.back(); stack.pop_back(); break; + case Op_code::SUB : stack[stack.size() - 2] -= stack.back(); stack.pop_back(); break; + case Op_code::MUL : stack[stack.size() - 2] *= stack.back(); stack.pop_back(); break; + case Op_code::DIV : stack[stack.size() - 2] /= stack.back(); stack.pop_back(); break; + case Op_code::MOD : stack[stack.size() - 2] %= stack.back(); stack.pop_back(); break; + case Op_code::LT : { stack[stack.size() - 2] = ( stack[stack.size() - 2] < stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::GT : { stack[stack.size() - 2] = ( stack[stack.size() - 2] > stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::LE : { stack[stack.size() - 2] = ( stack[stack.size() - 2] <= stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::GE : { stack[stack.size() - 2] = ( stack[stack.size() - 2] >= stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::EQ : { stack[stack.size() - 2] = ( stack[stack.size() - 2] == stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::NE : { stack[stack.size() - 2] = ( stack[stack.size() - 2] != stack.back() ) ? 1 : 0; + stack.pop_back(); break; + } + case Op_code::AND : { uint32_t value = ( stack[stack.size() - 2] != 0 && stack.back() != 0 ) ? 1 : 0; + stack[stack.size() - 2] = value; stack.pop_back(); break; + } + case Op_code::OR : { uint32_t value = ( stack[stack.size() - 2] != 0 || stack.back() != 0 ) ? 1 : 0; + stack[stack.size() - 2] = value; stack.pop_back(); break; + } + case Op_code::NEG : stack.back() = -stack.back(); break; + case Op_code::NOT : stack.back() = ( stack.back() == 0 ) ? 1 : 0; break; + case Op_code::PRTC : std::cout << static_cast(stack.back()); stack.pop_back(); break; + case Op_code::PRTI : std::cout << stack.back(); stack.pop_back(); break; + case Op_code::PRTS : std::cout << vm_strings[stack.back()]; stack.pop_back(); break; + case Op_code::FETCH : stack.emplace_back(stack[operand(index, codes)]); index += word_size; break; + case Op_code::STORE : { stack[operand(index, codes)] = stack.back(); index += word_size; + stack.pop_back(); break; + } + case Op_code::PUSH : stack.emplace_back(operand(index, codes)); index += word_size; break; + case Op_code::JMP : index += operand(index, codes); break; + case Op_code::JZ : { index += ( stack.back() == 0 ) ? operand(index, codes) : word_size; + stack.pop_back(); break; + } + } + } +} + +int main() { + VirtualMachineInfo info = load_code("Compiler Test Cases/AsciiMandlebrot.txt"); + runVirtualMachine(info.data_size, info.vm_strings, info.codes); +} diff --git a/Task/Compiler-virtual-machine-interpreter/Java/compiler-virtual-machine-interpreter.java b/Task/Compiler-virtual-machine-interpreter/Java/compiler-virtual-machine-interpreter.java new file mode 100644 index 0000000000..25affabb2b --- /dev/null +++ b/Task/Compiler-virtual-machine-interpreter/Java/compiler-virtual-machine-interpreter.java @@ -0,0 +1,173 @@ +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public final class CompilerVirtualMachineInterpreter { + + public static void main(String[] args) throws IOException { + Path filePath = Path.of("Compiler Test Cases/AsciiMandlebrot.txt"); + VirtualMachineInfo info = loadCode(filePath); + runVirtualMachine(info.dataSize, info.vmStrings, info.codes()); + } + + private static void runVirtualMachine(int dataSize, List vmStrings, List codes) { + final int wordSize = 4; + Stack stack = new Stack(); + for ( int i = 0; i < dataSize; i++ ) { + stack.push(0); + } + + int index = 0; + OpCode opCode = null; + + while ( opCode != OpCode.HALT ) { + opCode = OpCode.havingCode(codes.get(index)); + index += 1; + + switch ( opCode ) { + case HALT -> { } + case ADD -> stack.set(stack.size() - 2, stack.get(stack.size() - 2) + stack.pop()); + case SUB -> stack.set(stack.size() - 2, stack.get(stack.size() - 2) - stack.pop()); + case MUL -> stack.set(stack.size() - 2, stack.get(stack.size() - 2) * stack.pop()); + case DIV -> stack.set(stack.size() - 2, stack.get(stack.size() - 2) / stack.pop()); + case MOD -> stack.set(stack.size() - 2, Math.floorMod(stack.get(stack.size() - 2), stack.pop())); + case LT -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) < stack.pop() ) ? 1 : 0); + case GT -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) > stack.pop() ) ? 1 : 0); + case LE -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) <= stack.pop() ) ? 1 : 0); + case GE -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) >= stack.pop() ) ? 1 : 0); + case EQ -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) == stack.pop() ) ? 1 : 0); + case NE -> stack.set(stack.size() - 2, ( stack.get(stack.size() - 2) != stack.pop() ) ? 1 : 0); + case AND -> { final int value = ( stack.get(stack.size() - 2) != 0 && stack.pop() != 0 ) ? 1 : 0; + stack.set(stack.size() - 1, value); + } + case OR -> { final int value = ( stack.get(stack.size() - 2) != 0 || stack.pop() != 0 ) ? 1 : 0; + stack.set(stack.size() - 1, value); + } + case NEG -> stack.set(stack.size() - 1, -stack.peek()); + case NOT -> stack.set(stack.size() - 1, ( stack.peek() == 0 ) ? 1 : 0); + case PRTC -> System.out.print((char) stack.pop().intValue()); + case PRTI -> System.out.print(stack.pop()); + case PRTS -> System.out.print(vmStrings.get(stack.pop())); + case FETCH -> { stack.push(stack.get(operand(index, codes))); index += wordSize; } + case STORE -> { stack.set(operand(index, codes), stack.pop()); index += wordSize; } + case PUSH -> { stack.push(operand(index, codes)); index += wordSize; } + case JMP -> index += operand(index, codes); + case JZ -> index += ( stack.pop() == 0 ) ? operand(index, codes) : wordSize; + } + } + } + + private static VirtualMachineInfo loadCode(Path filePath) throws IOException { + List lines = Files.readAllLines(filePath, StandardCharsets.UTF_8); + + String line = lines.getFirst(); + if ( line.startsWith("lex") ) { + lines.removeFirst(); + line = lines.getFirst(); + } + + String[] sections = line.trim().split(" "); + final int dataSize = Integer.parseInt(sections[1]); + final int stringCount = Integer.parseInt(sections[3]); + + List VMstrings = new ArrayList(); + for ( int i = 1; i <= stringCount; i++ ) { + String content = lines.get(i).substring(1, lines.get(i).length() - 1); + VMstrings.addLast(parseString(content)); + } + + int offset = 0; + List codes = new ArrayList(); + for ( int i = stringCount + 1; i < lines.size(); i++ ) { + sections = lines.get(i).trim().split("\\s+"); + offset = Integer.parseInt(sections[0]); + OpCode opCode = OpCode.valueOf(sections[1].toUpperCase()); + codes.addLast(opCode.byteCode()); + + switch ( opCode ) { + case FETCH, STORE -> addToCodes(Integer.parseInt(sections[2] + .substring(1, sections[2].length() - 1)), codes); + case PUSH -> addToCodes(Integer.parseInt(sections[2]), codes); + case JMP, JZ -> addToCodes(Integer.parseInt(sections[3]) - offset - 1, codes); + default -> { } + } + } + + return new VirtualMachineInfo(dataSize, VMstrings, codes); + } + + private static int operand(int index, List codes) { + byteBuffer.clear(); + for ( int i = index; i < index + 4; i++ ) { + byteBuffer.put(codes.get(i)); + } + byteBuffer.flip(); + + return byteBuffer.getInt(); + } + + private static void addToCodes(int number, List codes) { + byteBuffer.clear(); + byteBuffer.putInt(number); + byteBuffer.flip(); + for ( byte bb : byteBuffer.array() ) { + codes.addLast(bb); + } + } + + private static String parseString(String text) { + StringBuilder result = new StringBuilder(); + int i = 0; + while ( i < text.length() ) { + if ( text.charAt(i) == '\\' && i + 1 < text.length() ) { + if ( text.charAt(i + 1) == 'n' ) { + result.append("\n"); + i += 1; + } else if ( text.charAt(i + 1) == '\\') { + result.append("\\"); + i += 1; + } + } else { + result.append(text.charAt(i)); + } + i += 1; + } + + return result.toString(); + } + + private static ByteBuffer byteBuffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); + + private static enum OpCode { + + HALT(0), ADD(1), SUB(2), MUL(3), DIV(4), MOD(5), LT(6), GT(7), LE(8), GE(9), EQ(10), NE(11), + AND(12), OR(13), NEG(14), NOT(15), + PRTC(16), PRTI(17), PRTS(18), FETCH(19), STORE(20), PUSH(21), JMP(22), JZ(23); + + public byte byteCode() { + return (byte) byteCode; + } + + public static OpCode havingCode(Byte byteCode) { + return op_codes[(int) byteCode]; + } + + private OpCode(int aByteCode) { + byteCode = aByteCode; + } + + private int byteCode; + + private static OpCode[] op_codes = values(); + + } + + private static record VirtualMachineInfo(int dataSize, List vmStrings, List codes) {} + +} diff --git a/Task/Compound-data-type/PascalABC.NET/compound-data-type.pas b/Task/Compound-data-type/PascalABC.NET/compound-data-type.pas new file mode 100644 index 0000000000..b6b8293f37 --- /dev/null +++ b/Task/Compound-data-type/PascalABC.NET/compound-data-type.pas @@ -0,0 +1,16 @@ +type + Point = class + x,y: integer; + constructor(x,y: integer) := (Self.x,Self.y) := (x,y); + end; + PointRec = record + x,y: integer; + constructor(x,y: integer) := (Self.x,Self.y) := (x,y); + end; + +begin + var p := new Point(2,3); + Println(p.x,p.y); + var pr := new PointRec(4,5); + Println(pr.x,pr.y); +end. diff --git a/Task/Concurrent-computing/PascalABC.NET/concurrent-computing.pas b/Task/Concurrent-computing/PascalABC.NET/concurrent-computing.pas new file mode 100644 index 0000000000..4f5e24c6c3 --- /dev/null +++ b/Task/Concurrent-computing/PascalABC.NET/concurrent-computing.pas @@ -0,0 +1,8 @@ +uses System.Threading.Tasks; + +begin + Task.Run(() -> Print('Enjoy')); + Task.Run(() -> Print('Rosetta')); + Task.Run(() -> Print('Code')); + Sleep(100); +end. diff --git a/Task/Conditional-structures/Langur/conditional-structures-1.langur b/Task/Conditional-structures/Langur/conditional-structures-1.langur index f0a3414467..b8bceebc82 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-1.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-1.langur @@ -1,9 +1,9 @@ -if .x == 0 { +if x == 0 { ... -} else if .x > 0 { - val .y = 100 +} else if x > 0 { + val y = 100 ... } else { - val .y = 70 + val y = 70 ... } diff --git a/Task/Conditional-structures/Langur/conditional-structures-2.langur b/Task/Conditional-structures/Langur/conditional-structures-2.langur index d6d6ef7252..99b9dcafd7 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-2.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-2.langur @@ -1 +1 @@ -if(.x > .y: ...; .x < .y: ...; /* else */ ...) +if(x > y: ...; x < y: ...; /* else */ ...) diff --git a/Task/Conditional-structures/Langur/conditional-structures-3.langur b/Task/Conditional-structures/Langur/conditional-structures-3.langur index 6c6913c8fb..93a2b6daad 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-3.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-3.langur @@ -1 +1 @@ -if .x > .y: break +if x > y: break diff --git a/Task/Conditional-structures/Langur/conditional-structures-4.langur b/Task/Conditional-structures/Langur/conditional-structures-4.langur index 8be040d87e..940aec9a71 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-4.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-4.langur @@ -1,25 +1,25 @@ -switch .x, .y, .z { +switch x, y, z { case true: ... # any are true case false, _: ... - # .x == false + # x == false case _, null, true: ... - # .y == null or .z == true + # y == null or z == true case xor _, true, true: ... - # .y == true xor .z == true + # y == true xor z == true } switch 0 { - case .x, .y: ... - # .x or .y equals 0 + case x, y: ... + # x or y equals 0 ... } -switch[and] .x, .y, .z { +switch[and] x, y, z { case true: ... # all are true case false, _: ... - # .x == false + # x == false case _, null, true: ... - # .y == null and .z == true + # y == null and z == true } diff --git a/Task/Conditional-structures/Langur/conditional-structures-5.langur b/Task/Conditional-structures/Langur/conditional-structures-5.langur index 8ee9423979..a0c932ff9e 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-5.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-5.langur @@ -1,4 +1,4 @@ -switch .x { +switch x { case true: # implicit fallthrough case null: 0 diff --git a/Task/Conditional-structures/Langur/conditional-structures-6.langur b/Task/Conditional-structures/Langur/conditional-structures-6.langur index 90ba731409..bc35af9767 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-6.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-6.langur @@ -1,6 +1,6 @@ -switch .x { +switch x { case true: - if .y > 100 { + if y > 100 { fallthrough } else { 120 diff --git a/Task/Conditional-structures/Langur/conditional-structures-7.langur b/Task/Conditional-structures/Langur/conditional-structures-7.langur index 7a0f665429..27300db645 100644 --- a/Task/Conditional-structures/Langur/conditional-structures-7.langur +++ b/Task/Conditional-structures/Langur/conditional-structures-7.langur @@ -1,4 +1,4 @@ -switch(.x, .y, .z; +switch(x, y, z; true: ... ; # any are equal to true - _, >= .z: ...; # .y >= .z + _, >= z: ...; # y >= z ... ) # default diff --git a/Task/Conditional-structures/PascalABC.NET/conditional-structures.pas b/Task/Conditional-structures/PascalABC.NET/conditional-structures.pas new file mode 100644 index 0000000000..3b34271cf4 --- /dev/null +++ b/Task/Conditional-structures/PascalABC.NET/conditional-structures.pas @@ -0,0 +1,28 @@ +// if statement +if condition then + operator; + +if condition then + operator +else operator; + +if condition then + operator +else if condition then + operator +else operator; + +// case statement +case Month of + 3..5: Print('Spring'); + 6..8: Print('Summer'); + 9..11: Print('Autumn'); + 12,1,2: Print('Winter'); + else throw ArgumentException('Bad Month') +end; + +// ternary operator +var min := if a < b then a else b; + +// ternary operator in C style +var min := a < b ? a : b; diff --git a/Task/Conjugate-transpose/R/conjugate-transpose.r b/Task/Conjugate-transpose/R/conjugate-transpose.r new file mode 100644 index 0000000000..543b6a5d72 --- /dev/null +++ b/Task/Conjugate-transpose/R/conjugate-transpose.r @@ -0,0 +1,69 @@ +conjugate_transpose<- function(M){ + t(Conj(M))} + +is_hermitian <- function(M,eps=10**-10){ + all(abs(M-conjugate_transpose(M)) 0 Then + Stuff = fb.Item(fb.max) + fb.max -= 1 + End If +End Sub + +Type Gourmand + WeightGain As physical + SleepTime As physical +End Type + +Sub eats(Byref g As Gourmand, Byref stuff As ActualFood) + g.WeightGain += stuff.size * stuff.quantity * 0.75 + stuff.size = 0 + stuff.quantity = 0 +End Sub + +' Test +Dim As foodbox Hamper +Dim As Gourmand MrG +Dim As ActualFood Course + +put_(Hamper, food.pudding, 3, 7) +put_(Hamper, food.pie, 7, 3) +GetNext(Hamper, Course) +eats(MrG, Course) + +Print MrG.WeightGain ' result 15.75 + +Sleep diff --git a/Task/Constrained-genericity/PascalABC.NET/constrained-genericity.pas b/Task/Constrained-genericity/PascalABC.NET/constrained-genericity.pas new file mode 100644 index 0000000000..c7488df595 --- /dev/null +++ b/Task/Constrained-genericity/PascalABC.NET/constrained-genericity.pas @@ -0,0 +1,23 @@ +function Min(a: array of T): T; where T: IComparable; +begin + Result := a[0]; + for var i:=1 to a.Length - 1 do + if a[i].CompareTo(Result) < 0 then + Result := a[i]; +end; + +type Point = record(IComparable) + x,y: integer; + constructor (xx,yy: integer) := (x,y) := (xx,yy); + function CompareTo(p: Point): integer; + begin + Result := x.CompareTo(p.x); + if Result = 0 then + Result := y.CompareTo(p.y); + end; +end; + +begin + var a := Arr(new Point(2,3),new Point(1,4), new Point(3,1)); + Print(Min(a)); +end. diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Jq/continued-fraction-arithmetic-construct-from-rational-number.jq b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Jq/continued-fraction-arithmetic-construct-from-rational-number.jq new file mode 100644 index 0000000000..2b9225ddfc --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Jq/continued-fraction-arithmetic-construct-from-rational-number.jq @@ -0,0 +1,57 @@ +### Generic utilities + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; +def rpad($len): tostring | ($len - length) as $l | . + (" " * $l); + +# If $j is 0, then an error condition is raised; +# otherwise, assuming infinite-precision integer arithmetic, +# if the input and $j are integers, then the result will be a pair of integers. +def divmod($i; $j): + ($i % $j) as $mod + | [($i - $mod) / $j, $mod] ; + +def whilst(cond; update): + def _whilst: + if cond then update | (., _whilst) else empty end; + _whilst; + + +### Continued fractions + +# $a/$b +def toContFrac($a; $b): + {$a,$b} + | whilst( .b != 0; + divmod(.a; .b) as [$d, $r] + | .a = .b + | .b = $r + | .d = $d + | if .a == 1 then .b = 0 end) + | .d ; + +def examples: [ + {heading: "Examples ->", + group: [ [1, 2], [3, 1], [23, 8], [13, 11], [22, 7], [-151, 77] ], + lengths: [4,2] }, + + {heading: "Sqrt(2) ->", + group: [ [14142, 10000], [141421, 100000], [1414214, 1000000], [14142136, 10000000] ], + lengths: [8,8]}, + + {heading: "Pi ->", + group: [ [31, 10], [314, 100], [3142, 1000], [31428, 10000], [314285, 100000], [3142857, 1000000], + [31428571, 10000000], [314285714,100000000]], + lengths: [9, 9] } +]; + +def task: + examples[] + | .lengths as $lengths + | .heading, + (foreach .group[] as [$a, $b] (.; + .emit = "\($a|lpad($lengths[0])) / \($b|rpad($lengths[1]))" + | .emit += " = " + ([toContFrac($a;$b)] | join(" ")) ) + | .emit ), + ""; + +task diff --git a/Task/Convert-decimal-number-to-rational/11l/convert-decimal-number-to-rational.11l b/Task/Convert-decimal-number-to-rational/11l/convert-decimal-number-to-rational.11l index c0c5e0a9b5..dbb3d0b787 100644 --- a/Task/Convert-decimal-number-to-rational/11l/convert-decimal-number-to-rational.11l +++ b/Task/Convert-decimal-number-to-rational/11l/convert-decimal-number-to-rational.11l @@ -1,11 +1,4 @@ -T Rational - Int numerator - Int denominator - - F (numerator, denominator) - .numerator = numerator - .denominator = denominator - +T Rational((Int numerator, Int denominator)) F String() I .denominator == 1 R String(.numerator) diff --git a/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur b/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur index e635d318a0..baca41f3e5 100644 --- a/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur +++ b/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur @@ -1,17 +1,17 @@ -val .duration = fn(var .sec) { +val d = fn(var sec) { [ fw/wk d hr min sec/, - for[=[]] .dm in [7 * 24 * 60 * 60, 24 * 60 * 60, 60 * 60, 60] { - _for ~= [.sec \ .dm] - .sec rem= .dm - } ~ [.sec], + for[=[]] dm in [7 * 24 * 60 * 60, 24 * 60 * 60, 60 * 60, 60] { + _for ~= [sec \ dm] + sec rem= dm + } ~ [sec], ] } -for .seconds in [7259, 86400, 6000000] { - val .dur = .duration(.seconds) - write $"\.seconds:7; sec = " - writeln join ", ", for[=[]] .k of .dur[1] { - if .dur[2][.k] != 0: _for ~= [$"\.dur[2][.k]; \.dur[1][.k];"] - } +for seconds in [7259, 86400, 6000000] { + val dur = d(seconds) + write "{{seconds:7}} sec = " + writeln join(", ", for[=[]] k of dur[1] { + if dur[2][k] != 0: _for ~= ["{{dur[2][k]}} {{dur[1][k]}}"] + }) } diff --git a/Task/Convert-seconds-to-compound-duration/Uiua/convert-seconds-to-compound-duration.uiua b/Task/Convert-seconds-to-compound-duration/Uiua/convert-seconds-to-compound-duration.uiua new file mode 100644 index 0000000000..6383b22a67 --- /dev/null +++ b/Task/Convert-seconds-to-compound-duration/Uiua/convert-seconds-to-compound-duration.uiua @@ -0,0 +1,9 @@ +# Builds a string representation of a time period + +Units ← {"second" "minute" "hour" "day" "week"} +Durations ← [60 60 24 7 9999] + +Parts ← ⇌◌∧(⊙⊂⊃(⌊÷|◿))Durations⊙[] # seconds -> [S M H D W] +Sunit ← /⍚$"_ _"⍥⍜(⊡1|⍚⊂⊙@s)≠□"1"⊢. # Stringify a unit +String ← /◇$"_, _"⇌≡Sunit▽⊃(±|⍉⇌⊟Units°⋕) Parts +≡(&p$"_s \t= _"⟜(□String))[7259 86400 6000000 14000000 31449599 31449601] diff --git a/Task/Conways-Game-of-Life/Chapel/conways-game-of-life.chapel b/Task/Conways-Game-of-Life/Chapel/conways-game-of-life.chapel index 2a26b5bc69..f62d37fe29 100644 --- a/Task/Conways-Game-of-Life/Chapel/conways-game-of-life.chapel +++ b/Task/Conways-Game-of-Life/Chapel/conways-game-of-life.chapel @@ -1,66 +1,90 @@ -config const gridHeight: int = 3; -config const gridWidth: int = 3; +config const gridHeight : int = 3; +config const gridWidth : int = 3; -enum State { dead = 0, alive = 1 }; +enum state { dead = 0, alive = 1 }; -class ConwaysGameofLife { +class ConwaysGameofLife +{ + var gridDomain : domain(2, int); + var computeDomain : subdomain(gridDomain); + var grid : [gridDomain] state; - var gridDomain: domain(2); - var computeDomain: subdomain( gridDomain ); - var grid: [gridDomain] int; + proc init(height : int, width : int) + { + this.gridDomain = {0..#height+2, 0..#width+2}; + this.computeDomain = this.gridDomain.expand(-1); + } - proc ConwaysGameofLife( height: int, width: int ) { - this.gridDomain = {0..#height+2, 0..#width+2}; - this.computeDomain = this.gridDomain.expand( -1 ); - } - proc step(){ + proc step() : void + { + var tempGrid: [this.computeDomain] state; - var tempGrid: [this.computeDomain] State; - forall (i,j) in this.computeDomain { - var isAlive = this.grid[i,j] == State.alive; - var numAlive = (+ reduce this.grid[ i-1..i+1, j-1..j+1 ]) - if isAlive then 1 else 0; - tempGrid[i,j] = if ( (2 == numAlive && isAlive) || numAlive == 3 ) then State.alive else State.dead ; - } + forall (i,j) in this.computeDomain + { + var isAlive = this.grid[i,j] == state.alive; + var numAlive = (+ reduce this.grid[i-1..i+1, j-1..j+1]:int) - if isAlive then 1 else 0; + tempGrid[i,j] = if ( (2 == numAlive && isAlive) || numAlive == 3 ) then state.alive else state.dead ; + } - this.grid[this.computeDomain] = tempGrid; + this.grid[this.computeDomain] = tempGrid; + } - } + + proc this(i : int, j : int) ref : state + { + return this.grid[i,j]; + } - proc this( i: int, j: int ) ref : State { - return this.grid[i,j]; - } - proc prettyPrint(): string { - var str: string; - for i in this.gridDomain.dim(1) { - if i == 0 || i == gridDomain.dim(1).last { - for j in this.gridDomain.dim(2) { - str += "-"; - } - } else { - for j in this.gridDomain.dim(2) { - if j == 0 || j == this.gridDomain.dim(2).last { - str += "|"; - } else { - str += if this.grid[i,j] == State.alive then "#" else " "; - } - } - } - str += "\n"; - } - return str; - } + proc prettyPrint() : string + { + var str : string; + for i in this.gridDomain.dim(0) + { + if i == 0 || i == gridDomain.dim(0).last + { + for j in this.gridDomain.dim(1) + { + str += "-"; + } + } + else + { + for j in this.gridDomain.dim(1) + { + if j == 0 || j == this.gridDomain.dim(1).last + { + str += "|"; + } + else + { + str += if this.grid[i,j] == state.alive then "#" else " "; + } + } + } + + str += "\n"; + } + + return str; + } + } -proc main{ - var game = new ConwaysGameofLife( gridHeight, gridWidth ); - game[gridHeight/2 + 1, gridWidth/2 ] = State.alive; - game[gridHeight/2 + 1, gridWidth/2 + 1 ] = State.alive; - game[gridHeight/2 + 1, gridWidth/2 + 2 ] = State.alive; - for i in 1..3 { - writeln( game.prettyPrint() ); - game.step(); - } + +proc main() +{ + var game = new ConwaysGameofLife(gridHeight, gridWidth); + + game[gridHeight/2 + 1, gridWidth/2 ] = state.alive; + game[gridHeight/2 + 1, gridWidth/2 + 1 ] = state.alive; + game[gridHeight/2 + 1, gridWidth/2 + 2 ] = state.alive; + + for i in 1..3 + { + writeln(game.prettyPrint()); + game.step(); + } } diff --git a/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua b/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua new file mode 100644 index 0000000000..c2e9680614 --- /dev/null +++ b/Task/Conways-Game-of-Life/Uiua/conways-game-of-life.uiua @@ -0,0 +1,4 @@ +Life ← ↥⊙↧∩=3,2-,/+≡↻☇1-1⇡3_3¤. +⁅×0.6 ∵⋅⚂ ↯⟜⊚ 50 # Init +⇌◌⍥(⟜⊂Life)300⟜¤ # Run +≡(▽⟜≡▽4) # Upscale diff --git a/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas b/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas new file mode 100644 index 0000000000..92afc0925c --- /dev/null +++ b/Task/Copy-a-string/PascalABC.NET/copy-a-string.pas @@ -0,0 +1,4 @@ +begin + var s: string := 'Hello'; + var s1 := s; +end. diff --git a/Task/Copy-a-string/S-BASIC/copy-a-string.basic b/Task/Copy-a-string/S-BASIC/copy-a-string.basic new file mode 100644 index 0000000000..81d04da265 --- /dev/null +++ b/Task/Copy-a-string/S-BASIC/copy-a-string.basic @@ -0,0 +1,23 @@ +var original, copy = string +based referenced = string +var strloc = integer + +rem - position referenced string on top of original string +location var strloc = original +base referenced at strloc + +original = "Hello, World" +copy = original + +print "Original : ", original +print "Copy : ", copy +print "Referenced: ", referenced +print + +original = "Goodbye, World" + +print "Original : ", original rem - changed +print "Copy : ", copy rem - unchanged +print "Referenced: ", referenced rem - changed + +end diff --git a/Task/Copy-stdin-to-stdout/C/copy-stdin-to-stdout.c b/Task/Copy-stdin-to-stdout/C/copy-stdin-to-stdout.c index fc9c56899d..6d839bdaa4 100644 --- a/Task/Copy-stdin-to-stdout/C/copy-stdin-to-stdout.c +++ b/Task/Copy-stdin-to-stdout/C/copy-stdin-to-stdout.c @@ -1,8 +1,8 @@ #include -int main(){ - char c; - while ( (c=getchar()) != EOF ){ +int main() { + int c; + while ((c = getchar()) != EOF) { putchar(c); } return 0; diff --git a/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic b/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic new file mode 100644 index 0000000000..277e5331b6 --- /dev/null +++ b/Task/Copy-stdin-to-stdout/FutureBasic/copy-stdin-to-stdout.basic @@ -0,0 +1,13 @@ +// Create file handles for standard input and output +FileHandleRef stdIn = fn FileHandleWithStandardInput +FileHandleRef stdOut = fn FileHandleWithStandardOutput + +// Continuously read from standard input… +while (YES) + CFDataRef availableData = fn FileHandleAvailableData( stdIn ) + if ( fn DataLength( availableData ) == 0 ) + break // End of input + end if + // … and write to standard output + fn FileHandleWriteData( stdOut, availableData, NULL ) +wend diff --git a/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout.java b/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-1.java similarity index 100% rename from Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout.java rename to Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-1.java diff --git a/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java b/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java new file mode 100644 index 0000000000..df4b2adbe3 --- /dev/null +++ b/Task/Copy-stdin-to-stdout/Java/copy-stdin-to-stdout-2.java @@ -0,0 +1,5 @@ +public class CopyStdinToStdout { + public static void main(String[] args) throws java.io.IOException { + System.in.transferTo(System.out); + } +} diff --git a/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas b/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas new file mode 100644 index 0000000000..1b297471d0 --- /dev/null +++ b/Task/Copy-stdin-to-stdout/PascalABC.NET/copy-stdin-to-stdout.pas @@ -0,0 +1,2 @@ +## +Console.OpenStandardInput().CopyTo(Console.OpenStandardOutput()); diff --git a/Task/Copy-stdin-to-stdout/Refal/copy-stdin-to-stdout.refal b/Task/Copy-stdin-to-stdout/Refal/copy-stdin-to-stdout.refal new file mode 100644 index 0000000000..51e03c086c --- /dev/null +++ b/Task/Copy-stdin-to-stdout/Refal/copy-stdin-to-stdout.refal @@ -0,0 +1,6 @@ +$ENTRY Go { + , : { + 0 = ; + e.Line = >; + }; +}; diff --git a/Task/Count-in-factors/PascalABC.NET/count-in-factors.pas b/Task/Count-in-factors/PascalABC.NET/count-in-factors.pas new file mode 100644 index 0000000000..13d05e3e0a --- /dev/null +++ b/Task/Count-in-factors/PascalABC.NET/count-in-factors.pas @@ -0,0 +1,25 @@ +// https://rosettacode.org/wiki/Count_in_factors#PascalABC.NET + +function Factorize(x: integer): List; +begin + Result := new List; + if x = 1 then + begin + Result.Add(1); + exit + end; + var i := 2; + repeat + if x.Divs(i) then + begin + Result.Add(i); + x := x div i; + end + else i += 1; + until x = 1; +end; + +begin + var n := 22; + (1..n).PrintLines(x -> $'{x,3}: {Factorize(x).JoinToString('' * '')}') +end. diff --git a/Task/Count-in-octal/Langur/count-in-octal.langur b/Task/Count-in-octal/Langur/count-in-octal.langur index 75aba01e45..b8c0281275 100644 --- a/Task/Count-in-octal/Langur/count-in-octal.langur +++ b/Task/Count-in-octal/Langur/count-in-octal.langur @@ -1,5 +1,5 @@ -val .limit = 70000 +val limit = 70 -for .i of .limit { - writeln $"10x\.i; == 8x\.i:8x;" +for i of limit { + writeln "10x{{i}} == 8x{{i:8x}}" } diff --git a/Task/Count-in-octal/PascalABC.NET/count-in-octal.pas b/Task/Count-in-octal/PascalABC.NET/count-in-octal.pas new file mode 100644 index 0000000000..8c972a5d55 --- /dev/null +++ b/Task/Count-in-octal/PascalABC.NET/count-in-octal.pas @@ -0,0 +1,3 @@ +## +for var i:=0 to 20 do + Println(Convert.ToString(i,8)); diff --git a/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg b/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg index b78cae0a28..cb0dc4354e 100644 --- a/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg +++ b/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg @@ -1,5 +1,3 @@ -#!/usr/local/bin/a68g --script # - PROC count string in string = (STRING needle, haystack)INT: ( INT start:=LWB haystack, next, out:=0; FOR count WHILE string in string(needle, next, haystack[start:]) DO @@ -9,9 +7,8 @@ PROC count string in string = (STRING needle, haystack)INT: ( out ); -printf(($d" "$, - count string in string("th", "the three truths"), # expect 3 # - count string in string("abab", "ababababab"), # expect 2 # - count string in string("a*b", "abaabba*bbaba*bbab"), # expect 2 # - $l$ +print(( + whole( count string in string("th", "the three truths"), 0 ) # expect 3 #, " ", + whole( count string in string("abab", "ababababab"), 0 ) # expect 2 #, " ", + whole( count string in string("a*b", "abaabba*bbaba*bbab"), 0 ) # expect 2 #, newline )) diff --git a/Task/Count-occurrences-of-a-substring/Emacs-Lisp/count-occurrences-of-a-substring.l b/Task/Count-occurrences-of-a-substring/Emacs-Lisp/count-occurrences-of-a-substring.l index e5b07110f7..0789fc7e91 100644 --- a/Task/Count-occurrences-of-a-substring/Emacs-Lisp/count-occurrences-of-a-substring.l +++ b/Task/Count-occurrences-of-a-substring/Emacs-Lisp/count-occurrences-of-a-substring.l @@ -1,5 +1,20 @@ +;; version 1, which takes advantage of the how-many function, +;; which runs only in a buffer + (defun count-substrings (text substring) - (with-temp-buffer - (insert text) - (goto-char (point-min)) - (how-many substring))) + "Count non-overlapping occurrences of SUBSTRING in TEXT." + (with-temp-buffer ; create a temporary buffer, which will be deleted when function finishes + (insert text) ; insert TEXT into the empty buffer + (goto-char (point-min)) ; go to the beginning of the buffer + (how-many substring))) ; count how many occurrences of SUBSTRING + + +;; version 2, which operates on a string + +(defun count-substrings (text substring) + "Count non-overlapping occurences of SUBSTRING in TEXT." + (let ((substrings)) ; empty list to add occurrences of SUBSTRING as we find them + (while (string-match substring text) ; as long as we can find SUBSTRING in TEXT + (push (match-string 0 text) substrings) ; add the SUBSTRING we found to the list of substrings + (setq text (replace-match "" nil nil text))) ; remove SUBSTRING from text, and repeat while loop + (length substrings))) ; count number of items in substrings list diff --git a/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur b/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur index 2af267a23c..868b9d305f 100644 --- a/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur +++ b/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur @@ -1,2 +1,2 @@ -writeln len indices "th", "the three truths" -writeln len indices "abab", "ababababab" +writeln len(indices("th", "the three truths")) +writeln len(indices("abab", "ababababab")) diff --git a/Task/Count-occurrences-of-a-substring/PascalABC.NET/count-occurrences-of-a-substring.pas b/Task/Count-occurrences-of-a-substring/PascalABC.NET/count-occurrences-of-a-substring.pas new file mode 100644 index 0000000000..865822f8f1 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/PascalABC.NET/count-occurrences-of-a-substring.pas @@ -0,0 +1,6 @@ +function CountSubstrings(s,subs: string): integer := s.IndicesOf(subs).Count; + +begin + Print(CountSubstrings('the three truths','th')); + Print(CountSubstrings('ababababab','abab')); +end. diff --git a/Task/Count-the-coins/Ada/count-the-coins.ada b/Task/Count-the-coins/Ada/count-the-coins-1.ada similarity index 100% rename from Task/Count-the-coins/Ada/count-the-coins.ada rename to Task/Count-the-coins/Ada/count-the-coins-1.ada diff --git a/Task/Count-the-coins/Ada/count-the-coins-2.ada b/Task/Count-the-coins/Ada/count-the-coins-2.ada new file mode 100644 index 0000000000..41b7305e62 --- /dev/null +++ b/Task/Count-the-coins/Ada/count-the-coins-2.ada @@ -0,0 +1,26 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Main is + count: Integer; +begin + count := 0; + for penny in 0 .. 100 loop + for nickel in 0 .. 20 loop + for dime in 0 .. 10 loop + for quarter in 0 .. 4 loop + if (penny + 5 * nickel + 10 * dime + 25 * quarter = 100) + then + Put_Line(Integer'Image(count+1) & ": " & + Integer'Image(penny) & " pennies, " & + Integer'Image(nickel) & " nickels, " & + Integer'Image(dime) & " dimes, " & + Integer'Image(quarter) & " quarters"); + count := count + 1; + end if; + end loop; + end loop; + end loop; + end loop; + + Put_Line("The number of ways to make change for a dollar is: " & Integer'Image(count)); +end Main; diff --git a/Task/Count-the-coins/Pascal/count-the-coins.pas b/Task/Count-the-coins/Pascal/count-the-coins.pas new file mode 100644 index 0000000000..2aa438bdf5 --- /dev/null +++ b/Task/Count-the-coins/Pascal/count-the-coins.pas @@ -0,0 +1,24 @@ +program countTheCoins; + +{$mode objfpc}{$H+} + +var + count, quarter, dime, nickel, penny: integer; + +begin + count := 0; + + for penny := 0 to 100 do + for nickel := 0 to 20 do + for dime := 0 to 10 do + for quarter := 0 to 4 do + if (penny + 5 * nickel + 10 * dime + 25 * quarter = 100) then + begin + writeln(penny, ' pennies ', nickel, ' nickels ', dime, ' dimes ', quarter, ' quarters'); + count := count + 1; + end; + + + writeln('The number of ways to make change for a dollar is: ', count); // 242 ways to make change for a dollar + +end. diff --git a/Task/Create-a-file/Seed7/create-a-file.seed7 b/Task/Create-a-file/Seed7/create-a-file.seed7 index 755a9fcf51..e2f09790eb 100644 --- a/Task/Create-a-file/Seed7/create-a-file.seed7 +++ b/Task/Create-a-file/Seed7/create-a-file.seed7 @@ -7,8 +7,8 @@ const proc: main is func begin aFile := open("output.txt", "w"); close(aFile); - mkdir("docs"); + makeDir("docs"); aFile := open("/output.txt", "w"); close(aFile); - mkdir("/docs"); + makeDir("/docs"); end func; diff --git a/Task/Create-a-two-dimensional-array-at-runtime/PascalABC.NET/create-a-two-dimensional-array-at-runtime.pas b/Task/Create-a-two-dimensional-array-at-runtime/PascalABC.NET/create-a-two-dimensional-array-at-runtime.pas new file mode 100644 index 0000000000..1efbedf6b8 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/PascalABC.NET/create-a-two-dimensional-array-at-runtime.pas @@ -0,0 +1,8 @@ +begin + var (m,n) := ReadInteger2; + var a: array[,] of integer := new integer[m,n]; + a[0,0] := 1; a[m-1,n-1] := 55; + a.Println; + var a1 := MatrRandomInteger(m,n); + a1.Println; +end. diff --git a/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas b/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas new file mode 100644 index 0000000000..1feef12947 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/PascalABC.NET/create-an-object-at-a-given-address.pas @@ -0,0 +1,12 @@ +begin + var pi: ^integer; + New(pi); + pi^ := 3; + Writeln(pi,' ',pi^); + pi^ := 5; + Writeln(pi,' ',pi^); + var pi1: ^integer := pi; + pi1^ := 666; + Writeln(pi1,' ',pi1^); + Writeln(pi,' ',pi^); +end. diff --git a/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs b/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs new file mode 100644 index 0000000000..272a948842 --- /dev/null +++ b/Task/Cyclops-numbers/C-sharp/cyclops-numbers.cs @@ -0,0 +1,191 @@ +internal class Program +{ + private static void Main(string[] args) + { + long number = 1; + int displayMax = 50; + long highBar = 10_000_000; + + List cyclops = []; + int cyclopsCount = 0; + long firstCyclopsOverHighBar = 0; + int firstCyclopsOverHighBarIndex = 0; + List primeCyclops = []; + int primeCyclopsCount = 0; + long firstPrimeCyclopsOverHighBar = 0; + int firstPrimeCyclopsOverHighBarIndex = 0; + List primeBlindCyclops = []; + int primeBlindCyclopsCount = 0; + long firstPrimeBlindCyclopsOverHighBar = 0; + int firstPrimeBlindCyclopsOverHighBarIndex = 0; + List primePalindroneCyclops = []; + int primePalindromCyclopsCount = 0; + long firstPrimePalindromeCyclopsOverHighBar = 0; + int firstPrimePalindromeCyclopsOverHighBarIndex = 0; + + while (firstCyclopsOverHighBarIndex == 0 || cyclopsCount < displayMax + || firstPrimeCyclopsOverHighBarIndex == 0 || primeCyclopsCount < displayMax + || firstPrimeBlindCyclopsOverHighBarIndex == 0 || primeBlindCyclopsCount < displayMax + || firstPrimePalindromeCyclopsOverHighBarIndex == 0 || primePalindromCyclopsCount < displayMax) + { + if (IsCyclopsNumber(number)) + { + cyclopsCount++; + + if (cyclops.Count < displayMax) + { + cyclops.Add(number); + } + + if (firstCyclopsOverHighBarIndex == 0 && number > highBar) + { + firstCyclopsOverHighBar = number; + firstCyclopsOverHighBarIndex = cyclopsCount; + } + + if (IsPrime(number)) + { + primeCyclopsCount++; + + if (firstPrimeCyclopsOverHighBarIndex == 0 && number > highBar) + { + firstPrimeCyclopsOverHighBar = number; + firstPrimeCyclopsOverHighBarIndex = primeCyclopsCount; + } + + if (primeCyclops.Count < displayMax) + { + primeCyclops.Add(number); + } + + if (IsPrime(BlindCyclopsNumber(number))) + { + primeBlindCyclopsCount++; + + if (firstPrimeBlindCyclopsOverHighBarIndex == 0 && number > highBar) + { + firstPrimeBlindCyclopsOverHighBar = number; + firstPrimeBlindCyclopsOverHighBarIndex = primeBlindCyclopsCount; + } + + if (primeBlindCyclops.Count < displayMax) + { + primeBlindCyclops.Add(number); + } + } + + if (IsPalindrome(number.ToString())) + { + primePalindromCyclopsCount++; + + if (firstPrimePalindromeCyclopsOverHighBarIndex == 0 && number > highBar) + { + firstPrimePalindromeCyclopsOverHighBar = number; + firstPrimePalindromeCyclopsOverHighBarIndex = primePalindromCyclopsCount; + } + + if (primePalindroneCyclops.Count < displayMax) + { + primePalindroneCyclops.Add(number); + } + } + } + } + + number++; + } + + DisplayNumberSequence(cyclops, $"First {displayMax} Cyclops Numbers", highBar, firstCyclopsOverHighBarIndex, firstCyclopsOverHighBar); + DisplayNumberSequence(primeCyclops, $"First {displayMax} Prime Cyclops Numbers", highBar, firstPrimeCyclopsOverHighBarIndex, firstPrimeCyclopsOverHighBar); + DisplayNumberSequence(primeBlindCyclops, $"First {displayMax} Blind Prime Cyclops Numbers", highBar, firstPrimeBlindCyclopsOverHighBarIndex, firstPrimeBlindCyclopsOverHighBar); + DisplayNumberSequence(primePalindroneCyclops, $"First {displayMax} Palidrome Cyclops Numbers", highBar, firstPrimePalindromeCyclopsOverHighBarIndex, firstPrimePalindromeCyclopsOverHighBar); + } + + private static void DisplayNumberSequence(List numbers, string title, + long highBar, long firstIndexOverHighBar, long firstOverHighBar) + { + Console.WriteLine(title); + + for (int i = 0; i < numbers.Count; i++) + { + Console.Write($"{numbers[i],-7} "); + + if ((i + 1) % 10 == 0) + { + Console.WriteLine(); + } + } + + Console.WriteLine($"The first such number > {highBar} is the {firstIndexOverHighBar}th: {firstOverHighBar}"); + Console.WriteLine(); + } + + private static bool IsCyclopsNumber(long number ) + { + string numberAsString = number.ToString(); + int numberLength = numberAsString.Length; + int middleDigit = numberLength / 2; + + if (numberLength > 1 && numberLength % 2 !=0 // the number has an odd number of digits greater than one + && numberAsString.Count(c => c == '0') == 1 // there is only one zero + && numberAsString[middleDigit] == '0') // Zero is the middle digit + { + return true; + } + return false; + } + + private static bool IsPalindrome(string stringInput) + { + if (stringInput != null && stringInput.Length > 0) + { + var reversedString = new string(stringInput.ToCharArray().Reverse().ToArray()); + return stringInput == reversedString; + } + + return false; + } + + private static long BlindCyclopsNumber(long number) + { + string numberAsString = number.ToString(); + int numberLength = numberAsString.Length; + int middleDigit = numberLength / 2; + string blindNumber = string.Concat(numberAsString.AsSpan(0, middleDigit), numberAsString.AsSpan(middleDigit + 1, numberLength - (middleDigit + 1))); + return long.Parse(blindNumber); + } + + private static bool IsPrime(long number) + { + if (number < 2) + { + return false; + } + + if (number % 2 == 0) + { + return number == 2; + } + + if (number % 3 == 0) + { + return number == 3; + } + + int delta = 2; + long k = 5; + + while (k * k <= number) + { + if (number % k == 0) + { + return false; + } + + k += delta; + delta = 6 - delta; + } + + return true; + } +} diff --git a/Task/Damm-algorithm/ANSI-BASIC/damm-algorithm.basic b/Task/Damm-algorithm/ANSI-BASIC/damm-algorithm.basic new file mode 100644 index 0000000000..1635dfd92a --- /dev/null +++ b/Task/Damm-algorithm/ANSI-BASIC/damm-algorithm.basic @@ -0,0 +1,28 @@ +100 REM Damm algorithm +110 OPTION BASE 0 +120 DIM DT(9, 9) +130 FOR Y = 0 TO 9 +140 FOR X = 0 TO 9 +150 READ DT(X, Y) +160 NEXT X +170 NEXT Y +180 INPUT N$ +190 DO WHILE N$ <> "" +200 LET D = 0 +210 FOR I = 1 TO LEN(N$) +220 LET D = DT(VAL(MID$(N$, I, 1)), D) +230 NEXT I +240 IF D <> 0 THEN PRINT "FAIL" ELSE PRINT "PASS" +250 INPUT N$ +260 LOOP +270 DATA 0, 3, 1, 7, 5, 9, 8, 6, 4, 2 +280 DATA 7, 0, 9, 2, 1, 5, 4, 8, 6, 3 +290 DATA 4, 2, 0, 6, 8, 7, 1, 3, 5, 9 +300 DATA 1, 7, 5, 0, 9, 8, 3, 4, 2, 6 +310 DATA 6, 1, 2, 3, 0, 4, 5, 9, 7, 8 +320 DATA 3, 6, 7, 4, 2, 0, 9, 5, 8, 1 +330 DATA 5, 8, 6, 9, 7, 2, 0, 1, 3, 4 +340 DATA 8, 9, 4, 5, 3, 6, 2, 0, 1, 7 +350 DATA 9, 4, 3, 8, 6, 1, 7, 2, 0, 5 +360 DATA 2, 5, 8, 1, 4, 3, 6, 7, 9, 0 +370 END diff --git a/Task/Damm-algorithm/BASIC/damm-algorithm.basic b/Task/Damm-algorithm/GW-BASIC/damm-algorithm.basic similarity index 100% rename from Task/Damm-algorithm/BASIC/damm-algorithm.basic rename to Task/Damm-algorithm/GW-BASIC/damm-algorithm.basic diff --git a/Task/Damm-algorithm/Nascom-BASIC/damm-algorithm.basic b/Task/Damm-algorithm/Nascom-BASIC/damm-algorithm.basic new file mode 100644 index 0000000000..a37329be57 --- /dev/null +++ b/Task/Damm-algorithm/Nascom-BASIC/damm-algorithm.basic @@ -0,0 +1,23 @@ +10 REM Damm algorithm +20 DIM DT(9,9) +30 FOR Y=0 TO 9:FOR X=0 TO 9 +40 READ DT(X,Y) +50 NEXT X:NEXT Y +60 N$="":INPUT N$:IF N$="" THEN 130 +70 D=0 +80 FOR I=1 TO LEN(N$) +90 D=DT(VAL(MID$(N$,I,1)),D) +100 NEXT I +110 IF D THEN PRINT "FAIL":GOTO 60 +120 PRINT "PASS":GOTO 60 +130 END +140 DATA 0,3,1,7,5,9,8,6,4,2 +150 DATA 7,0,9,2,1,5,4,8,6,3 +160 DATA 4,2,0,6,8,7,1,3,5,9 +170 DATA 1,7,5,0,9,8,3,4,2,6 +180 DATA 6,1,2,3,0,4,5,9,7,8 +190 DATA 3,6,7,4,2,0,9,5,8,1 +200 DATA 5,8,6,9,7,2,0,1,3,4 +210 DATA 8,9,4,5,3,6,2,0,1,7 +220 DATA 9,4,3,8,6,1,7,2,0,5 +230 DATA 2,5,8,1,4,3,6,7,9,0 diff --git a/Task/Damm-algorithm/Refal/damm-algorithm.refal b/Task/Damm-algorithm/Refal/damm-algorithm.refal new file mode 100644 index 0000000000..5c36573e41 --- /dev/null +++ b/Task/Damm-algorithm/Refal/damm-algorithm.refal @@ -0,0 +1,38 @@ +$ENTRY Go { + = + + + ; +}; + +Test { + e.Ds = >; +}; + +Damm { + ('0') = Pass; + (s.Int) = Fail; + (s.Int) s.D e.Ds, + >: (e.Row), + e.Row>: s.Next + = ; + e.Ds = ; +}; + +DammTable { + = ('0317598642') + ('7092154863') + ('4206871359') + ('1750983426') + ('6123045978') + ('3674209581') + ('5869720134') + ('8945362017') + ('9438617205') + ('2581436790') +}; + +Item { + 0 t.I e.X = t.I; + s.N t.I e.X = e.X>; +}; diff --git a/Task/Damm-algorithm/SETL/damm-algorithm.setl b/Task/Damm-algorithm/SETL/damm-algorithm.setl new file mode 100644 index 0000000000..d48cef7478 --- /dev/null +++ b/Task/Damm-algorithm/SETL/damm-algorithm.setl @@ -0,0 +1,26 @@ +program damm_algorithm; + tests := [5724, 5727, 112946, 112949]; + + loop for test in tests do + print(str test + ': ' + if damm test then 'Pass' else 'Fail' end); + end loop; + + op damm(n); + dt := [[0,3,1,7,5,9,8,6,4,2], + [7,0,9,2,1,5,4,8,6,3], + [4,2,0,6,8,7,1,3,5,9], + [1,7,5,0,9,8,3,4,2,6], + [6,1,2,3,0,4,5,9,7,8], + [3,6,7,3,2,0,9,5,8,1], + [5,8,6,9,7,2,0,1,3,4], + [8,9,4,5,3,6,2,0,1,7], + [9,4,3,8,6,1,7,2,0,5], + [2,5,8,1,4,3,6,7,9,0]]; + + i := 0; + loop for d in str n do + i := dt(i+1)(val d+1); + end loop; + return i=0; + end op; +end program; diff --git a/Task/Date-format/Langur/date-format-1.langur b/Task/Date-format/Langur/date-format-1.langur index d68390fe38..9375725f6a 100644 --- a/Task/Date-format/Langur/date-format-1.langur +++ b/Task/Date-format/Langur/date-format-1.langur @@ -1,5 +1,2 @@ -var .now = dt// -var .format1 = "2006-01-02" -var .format2 = "Monday, January 2, 2006" -writeln $"\.now:dt.format1;" -writeln $"\.now:dt.format2;" +writeln string(dt//, "2006-01-02") +writeln string(dt//, "Monday, January 2, 2006") diff --git a/Task/Date-format/Langur/date-format-2.langur b/Task/Date-format/Langur/date-format-2.langur index 58006f8abc..b8821ea941 100644 --- a/Task/Date-format/Langur/date-format-2.langur +++ b/Task/Date-format/Langur/date-format-2.langur @@ -1,3 +1,2 @@ -var .now = dt// -writeln $"\.now:dt(2006-01-02);" -writeln $"\.now:dt(Monday, January 2, 2006);" +writeln "{{dt//:dt(2006-01-02)}}" +writeln "{{dt//:dt(Monday, January 2, 2006)}}" diff --git a/Task/Date-format/Langur/date-format-3.langur b/Task/Date-format/Langur/date-format-3.langur deleted file mode 100644 index 473f375e18..0000000000 --- a/Task/Date-format/Langur/date-format-3.langur +++ /dev/null @@ -1,2 +0,0 @@ -writeln string dt//, "2006-01-02" -writeln string dt//, "Monday, January 2, 2006" diff --git a/Task/Date-format/PascalABC.NET/date-format.pas b/Task/Date-format/PascalABC.NET/date-format.pas new file mode 100644 index 0000000000..b03b9f6d40 --- /dev/null +++ b/Task/Date-format/PascalABC.NET/date-format.pas @@ -0,0 +1,5 @@ +begin + var today := DateTime.Now; + Println(today.ToString('yyyy-MM-dd')); + Println($'{today:D}'); +end. diff --git a/Task/Date-manipulation/Emacs-Lisp/date-manipulation-1.l b/Task/Date-manipulation/Emacs-Lisp/date-manipulation-1.l new file mode 100644 index 0000000000..ead4f0f34d --- /dev/null +++ b/Task/Date-manipulation/Emacs-Lisp/date-manipulation-1.l @@ -0,0 +1,40 @@ +(defun fix-time-string (calendar-string) + "If CALENDAR-STRING has no space between time and am/a.m./pm/p.m., add a space. + Return string with space between time and am/a.m./pm/p.m." + (replace-regexp-in-string "\\([[:digit:]]\\)\\([ap]\\)" "\\1 \\2" calendar-string)) + +(defun is-pm (calendar-string) + "Test if CALENDAR-STRING has PM/pm/P.M/p.m in it." + (string-match-p "[Pp][.]?[Mm]" calendar-string)) + +(defun is-hour-1-to-11 (a-calendar-list) + "Test if hour in A-CALENDAR-LIST is between 1 and 11." + (let ((hour-value)) + (setq hour-value (nth 2 a-calendar-list)) + (and (>= hour-value 1) (<= hour-value 11)))) + +(defun adjust-if-pm (time-as-string) + "If TIME-AS-STRING includes pm/PM, and hour is 1 to 11, add 12 hours. + Return CALENDAR-LIST modified if date is pm and hour is 1-11; otherwise + return CALENDAR-LIST of original TIME-AS-STRING." + (let ((calendar-list)) + (setq calendar-list (parse-time-string time-as-string)) + (if (and (is-pm time-as-string) (is-hour-1-to-11 calendar-list)) + (decoded-time-add calendar-list (make-decoded-time :hour 12)) + calendar-list))) + +(defun add-hours (calendar-list number-of-hours) + "Add NUMBER-OF-HOURS to CALENDAR-LIST." + (decoded-time-add calendar-list (make-decoded-time :hour number-of-hours))) + +(defun calc-future-time (string-calendar-date number-of-hours-in-future) + "Calculate future time by adding NUMBER-OF-HOURS-IN-FUTURE to STRING-CALENDAR-DATE ." + (let ((fixed-calendar-string) + (24-hour-calendar-list) + (calendar-list-future-time) + (coded-future-time)) + (setq fixed-calendar-string (fix-time-string string-calendar-date)) + (setq 24-hour-calendar-list (adjust-if-pm fixed-calendar-string)) + (setq calendar-list-future-time (add-hours 24-hour-calendar-list number-of-hours-in-future)) + (setq coded-future-time (encode-time calendar-list-future-time)) + (format-time-string "%B %e %Y %R %p %Z" coded-future-time))) diff --git a/Task/Date-manipulation/Emacs-Lisp/date-manipulation-2.l b/Task/Date-manipulation/Emacs-Lisp/date-manipulation-2.l new file mode 100644 index 0000000000..5ebd017876 --- /dev/null +++ b/Task/Date-manipulation/Emacs-Lisp/date-manipulation-2.l @@ -0,0 +1,41 @@ +(defun fix-time-string (calendar-string) + "If CALENDAR-STRING has no space between time and a.m./p.m., add a space." + (replace-regexp-in-string "\\([[:digit:]]\\)\\([ap]\\)" "\\1 \\2" calendar-string)) + +(defun is-pm (calendar-string) + "Test if CALENDAR-STRING has PM/pm in it." + (string-match-p "[Pp][Mm]" time-as-string)) + +(defun is-hour-1-to-11 (a-calendar-list) + "Test if hour in A-CALENDAR-LIST is between 1 and 11." + (let ((hour-value)) + (setq hour-value (nth 2 a-calendar-list)) + (and (>= hour-value 1) (<= hour-value 11)))) + +(defun adjust-if-pm (time-as-string) + "If TIME-AS-STRING includes pm/PM, and hour is 1 to 11, add 12 hours. + Return time as integer of seconds past the epoch." + (let ((calendar-list) + (temp-time-stamp) + (time-stamp-as-integer)) + (setq calendar-list (parse-time-string time-as-string)) + (setq temp-time-stamp (encode-time calendar-list)) + (setq time-stamp-as-integer (time-convert temp-time-stamp 'integer)) + (if (and (is-pm time-as-string) (is-hour-1-to-11 calendar-list)) + (+ time-stamp-as-integer (* 12 60 60)) ; return time + 12 hours, so that hour is 13-23 + time-stamp-as-integer))) ; return time unchanged, leaving hour 0-12 + +(defun add-seconds (start-time-stamp-integer number-of-seconds) + "Add NUMBER-OF-HOURS to START-TIME-STAMP-INTEGER." + (+ start-time-stamp-integer number-of-seconds)) + +(defun calc-future-time (string-calendar-date number-of-seconds-in-future) + "Calculate future time by adding NUMBER-OF-SECONDS-IN-FUTURE to STRING-CALENDAR-DATE ." + (let ((fixed-calendar-string) + (time-stamp-as-integer) + (coded-current-time) + (future-time-as-integer)) + (setq fixed-calendar-string (fix-time-string string-calendar-date)) + (setq time-stamp-as-integer (adjust-if-pm fixed-calendar-string)) + (setq future-time-as-integer (add-seconds time-stamp-as-integer number-of-seconds-in-future)) + (format-time-string "%B %e %Y %R %p %Z" future-time-as-integer))) diff --git a/Task/Date-manipulation/Langur/date-manipulation.langur b/Task/Date-manipulation/Langur/date-manipulation.langur index 60e530d81b..d25c9c940e 100644 --- a/Task/Date-manipulation/Langur/date-manipulation.langur +++ b/Task/Date-manipulation/Langur/date-manipulation.langur @@ -1,24 +1,24 @@ -val .input = "March 7 2009 7:30pm -05:00" -val .iformat = "January 2 2006 3:04pm -07:00" -val .oformat = "January 2 2006 3:04pm MST" +val input = "March 7 2009 7:30pm -05:00" +val iformat = "January 2 2006 3:04pm -07:00" +val oformat = "January 2 2006 3:04pm MST" -val .d1 = datetime .input, .iformat -val .d2 = .d1 + dr/PT12H/ -val .d3 = datetime .d2, "US/Arizona" -val .d4 = datetime .d2, zls -val .d5 = datetime .d2, "Z" -val .d6 = datetime .d2, "+02:30" -val .d7 = datetime .d2, "EST" +val d1 = datetime(input, iformat) +val d2 = d1 + dr/T12h/ +val d3 = datetime(d2, "US/Arizona") +val d4 = datetime(d2, zls) +val d5 = datetime(d2, "Z") +val d6 = datetime(d2, "+02:30") +val d7 = datetime(d2, "EST") -writeln "input string: ", .input -writeln "input format string: ", .iformat -writeln "output format string: ", .oformat +writeln "input string: ", input +writeln "input format string: ", iformat +writeln "output format string: ", oformat writeln() -writeln $"original: \.d1; (\.d1:dt.oformat;)" -writeln $"+12 hours: \.d2; (\.d2:dt.oformat;)" -writeln $"in Arizona: \.d3; (\.d3:dt.oformat;)" -writeln $"in local time zone: \.d4; (\.d4:dt.oformat;)" -writeln $"in UTC: \.d5; (\.d5:dt.oformat;)" -writeln $"+02:30 time zone: \.d6; (\.d6:dt.oformat;)" -writeln $"in EST: \.d7; (\.d7:dt.oformat;)" +writeln "original: {{d1}} ({{d1:dt oformat}})" +writeln "+12 hours: {{d2}} ({{d2:dt oformat}})" +writeln "in Arizona: {{d3}} ({{d3:dt oformat}})" +writeln "in local time zone: {{d4}} ({{d4:dt oformat}})" +writeln "in UTC: {{d5}} ({{d5:dt oformat}})" +writeln "+02:30 time zone: {{d6}} ({{d6:dt oformat}})" +writeln "in EST: {{d7}} ({{d7:dt oformat}})" diff --git a/Task/Day-of-the-week/PascalABC.NET/day-of-the-week.pas b/Task/Day-of-the-week/PascalABC.NET/day-of-the-week.pas new file mode 100644 index 0000000000..276296d710 --- /dev/null +++ b/Task/Day-of-the-week/PascalABC.NET/day-of-the-week.pas @@ -0,0 +1,5 @@ +const Sunday = System.DayOfWeek.Sunday; + +begin + (2008..2121).Where(y -> DateTime.Create(y,12,25).DayOfWeek = Sunday).Println +end. diff --git a/Task/De-Bruijn-sequences/11l/de-bruijn-sequences.11l b/Task/De-Bruijn-sequences/11l/de-bruijn-sequences.11l index 00a2e2ffdf..26c684e6d5 100644 --- a/Task/De-Bruijn-sequences/11l/de-bruijn-sequences.11l +++ b/Task/De-Bruijn-sequences/11l/de-bruijn-sequences.11l @@ -5,7 +5,7 @@ F deBruijn(k, n) V a = [Byte(0)] * (k * n) [Byte] seq - F db(Int t, Int p) -> N + F db(Int t, Int p) -> Void I t > @n I @n % p == 0 @seq.extend(@a[1 .< p + 1]) diff --git a/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts b/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts new file mode 100644 index 0000000000..127f2fd09c --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/TypeScript/deal-cards-for-freecell.ts @@ -0,0 +1,133 @@ +/* TypeScript code for dealing Microsoft FreeCell / FreeCell Pro deals. + * Copyright by Shlomi Fish, 2011. + * Released under the MIT/Expat License + * ( http://en.wikipedia.org/wiki/MIT_License ). + */ +function perl_range(start: number, end: number): number[] { + const ret: number[] = []; + + for (let i = start; i <= end; ++i) { + ret.push(i); + } + + return ret; +} + +// 33 bit +const MAX_SEED: bigint = (BigInt(1) << BigInt(31 + 2)) - BigInt(1); +const X = BigInt(1) << BigInt(32); + +/* + * Microsoft C Run-time-Library-compatible Random Number Generator + * */ +class MSRand { + private gamenumber: string; + private _seed: bigint; + private _seedx: bigint; + constructor(args) { + const that = this; + that.gamenumber = args.gamenumber; + const _seed = BigInt(that.gamenumber); + that._seed = _seed; + that._seedx = _seed < X ? _seed : _seed - X; + return; + } + public getSeed(): bigint { + const that = this; + return that._seed; + } + private setSeed(seed: bigint): void { + const that = this; + that._seed = seed; + return; + } + + private _rando(): bigint { + const that = this; + that._seedx = + (that._seedx * BigInt(214013) + BigInt(2531011)) & MAX_SEED; + return (that._seedx >> BigInt(16)) & BigInt(0x7fff); + } + private _randp(): bigint { + const that = this; + that._seedx = + (that._seedx * BigInt(214013) + BigInt(2531011)) & MAX_SEED; + return (that._seedx >> BigInt(16)) & BigInt(0xffff); + } + public raw_rand(): bigint { + const that = this; + + if (that._seed < X) { + const ret = that._rando(); + return that._seed < BigInt(0x8) << BigInt(28) + ? ret + : ret | BigInt(0x8000); + } else { + return that._randp() + BigInt(1); + } + } + public max_rand(mymax: bigint): bigint { + const that = this; + return that.raw_rand() % mymax; + } + public shuffle(deck: Array): Array { + const that = this; + if (deck.length) { + let i = deck.length; + while (--i) { + const j = Number(that.max_rand(BigInt(i + 1))); + const tmp = deck[i]; + deck[i] = deck[j]; + deck[j] = tmp; + } + } + return deck; + } +} +/* + * Microsoft Windows Freecell / Freecell Pro boards generation. + * + * See: + * + * - http://rosettacode.org/wiki/Deal_cards_for_FreeCell + * + * - http://www.solitairelaboratory.com/mshuffle.txt + * + * Under MIT/Expat Licence. + * + * */ + +export function deal_ms_fc_board(gamenumber: string): string { + const randomizer = new MSRand({ + gamenumber: gamenumber, + }); + const num_cols: number = 8; + + const columns: Array> = perl_range(0, num_cols - 1).map( + () => { + return []; + }, + ); + let deck: Array = perl_range(0, 4 * 13 - 1); + + randomizer.shuffle(deck); + + deck = deck.reverse(); + + for (let i = 0; i < 52; ++i) { + columns[i % num_cols].push(deck[i]); + } + + function render_card(card: number): String { + const suit = card % 4; + const rank = Math.floor(card / 4); + + return "A23456789TJQK".charAt(rank) + "CDHS".charAt(suit); + } + + function render_column(col: Array): String { + return ": " + col.map(render_card).join(" ") + "\n"; + } + + return columns.map(render_column).join(""); +} diff --git a/Task/Death-Star/11l/death-star.11l b/Task/Death-Star/11l/death-star.11l index 23b604e42c..629b3b6f51 100644 --- a/Task/Death-Star/11l/death-star.11l +++ b/Task/Death-Star/11l/death-star.11l @@ -1,10 +1,4 @@ -T Sphere - Float cx, cy, cz, r - F (cx, cy, cz, r) - .cx = cx - .cy = cy - .cz = cz - .r = r +T Sphere = (Float cx, Float cy, Float cz, Float r) F dotp(v1, v2) V d = dot(v1, v2) diff --git a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur index c54868c2f7..acba2f2f8c 100644 --- a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur +++ b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur @@ -1,14 +1,16 @@ -val .isPrime = fn(.i) .i == 2 or .i > 2 and - not any fn(.x) .i div .x, pseries 2 .. .i ^/ 2 +val isPrime = fn(i) { + i == 2 or i > 2 and + not any(fn x: i div x, pseries(2 .. i ^/ 2)) +} -var .nums = [] -var .repunit = 111_111 +var nums = [] +var repunit = 111_111 -for .n = 9; len(.nums) < 10; .n += 2 { - .repunit = .repunit * 100 + 11 - if not .isPrime(.n) and .repunit div .n { - .nums = more .nums, .n +for n = 9; len(nums) < 10; n += 2 { + repunit = repunit * 100 + 11 + if not isPrime(n) and repunit div n { + nums = more(nums, n) } } -writeln .nums +writeln nums diff --git a/Task/Deconvolution-1D/Jq/deconvolution-1d.jq b/Task/Deconvolution-1D/Jq/deconvolution-1d.jq new file mode 100644 index 0000000000..49402b22d4 --- /dev/null +++ b/Task/Deconvolution-1D/Jq/deconvolution-1d.jq @@ -0,0 +1,22 @@ +def deconv($g; $f): + { h: [range(0; ($g|length) - ($f|length) + 1) | 0] } + | reduce range ( 0;.h|length) as $n (.; + .h[$n] = $g[$n] + | (if $n >= ($f|length) then $n - ($f|length) + 1 else 0 end) as $lower + | .i = $lower + | until(.i >= $n; + .h[$n] -= .h[.i] * $f[$n - .i] + | .i += 1 ) + | .h[$n] /= $f[0] ) + | .h ; + +### The tasks + +def h: [-8, -9, -3, -1, -6, 7]; +def f: [-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]; +def g: [24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7]; + +h, +deconv(g; f), +f, +deconv(g; h) diff --git a/Task/Define-a-primitive-data-type/PascalABC.NET/define-a-primitive-data-type.pas b/Task/Define-a-primitive-data-type/PascalABC.NET/define-a-primitive-data-type.pas new file mode 100644 index 0000000000..9c6fe7bcd7 --- /dev/null +++ b/Task/Define-a-primitive-data-type/PascalABC.NET/define-a-primitive-data-type.pas @@ -0,0 +1,27 @@ +type RangeInt = record + n: integer; +public + constructor(nn: integer); + begin + if nn not in 1..10 then + raise new System.ArgumentOutOfRangeException; + n := nn; + end; + function ToString: string; override := n.ToString; + static function operator implicit (n: integer): RangeInt := new RangeInt(n); + static function operator+(a,b: RangeInt): RangeInt := a.n + b.n; + static function operator-(a,b: RangeInt): RangeInt := a.n - b.n; + static function operator*(a,b: RangeInt): RangeInt := a.n * b.n; + static function operator/(a,b: RangeInt): real := a.n / b.n; + static function operator div(a,b: RangeInt): RangeInt := a.n div b.n; + static function operator mod(a,b: RangeInt): RangeInt := a.n mod b.n; +end; + +function RInt(n: integer) := new RangeInt(n); + +begin + var a: RangeInt := 7; + var b: RangeInt := 3; + Print(a + b, a - b, a div b, a mod b); + Print(a * b); // ArgumentOutOfRangeException exception +end. diff --git a/Task/Detect-division-by-zero/Langur/detect-division-by-zero.langur b/Task/Detect-division-by-zero/Langur/detect-division-by-zero.langur index e93045e0fb..86121c3cf6 100644 --- a/Task/Detect-division-by-zero/Langur/detect-division-by-zero.langur +++ b/Task/Detect-division-by-zero/Langur/detect-division-by-zero.langur @@ -1,5 +1,5 @@ -val .div = fn(.x, .y) { - [.x / .y, true] +val dz = fn(x, y) { + [x / y, true] catch { if _err'msg -> re/division by 0/ { [0, false] @@ -10,5 +10,5 @@ val .div = fn(.x, .y) { } } -writeln .div(3, 2) -writeln .div(3, 0) +writeln dz(3, 2) +writeln dz(3, 0) diff --git a/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua b/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua new file mode 100644 index 0000000000..0133fc0a7b --- /dev/null +++ b/Task/Determine-if-a-string-is-collapsible/Uiua/determine-if-a-string-is-collapsible.uiua @@ -0,0 +1,13 @@ +S ← {"" + "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln" + "..1111111111111111111111111111111111111111111111111111111111111117777888" + "I never give 'em hell, I just tell the truth, and they think it's hell. " + " --- Harry S Truman " + "The better the 4-wheel drive, the further you'll be from help when ya get stuck!" + "headmistressship" + "aardvark" + "😍😀🙌💃😍😍😍🙌" + "unnecessary bookkeeping"} + +Collapse ← ⊜⊢+1⊛. +≡(&p""≡(&p$"_ chars \t«_»" ⊸⧻°□))≡(⊟⟜⍜°□Collapse)S diff --git a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.l b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.l new file mode 100644 index 0000000000..bb17cf908b --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-1.l @@ -0,0 +1,12 @@ +(defun string-valid-number-p (str) + "Test if STR is a numeric string. +Eliminate strings with commas in them because ELisp numbers do +not contain commas. Then check if remaining strings would be +valid ELisp numbers if the quotation marks were removed." + (and + ;; no comma in string, because ELisp numbers do not have commas + ;; we need to eliminate any string with a comma, because the + ;; numberp function below will not weed out commas + (not (string-match-p "," str)) + ;; no errors from numberp function testing if a number + (ignore-errors (numberp (read str))))) diff --git a/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.l b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.l new file mode 100644 index 0000000000..ab8b39e2d0 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Emacs-Lisp/determine-if-a-string-is-numeric-2.l @@ -0,0 +1,17 @@ +(setq valid-strings '("3" "0" "-0" "2." "1000" "-4" "-5." "6.2" "-8.45" "+15e2" "-15e2" "#b101100" "#o54" "#x2c" "1500.0" "#24r1k" "3")) + +(setq invalid-strings '("3cat" "1,000" "5.6.7" "cat3" "def" "zero")) + +(with-current-buffer (pop-to-buffer "my-test") + (erase-buffer) + (insert "Test for valid strings:\n") + (dolist (test-string valid-strings) + (let ((test-result)) + (setq test-result (string-valid-number-p test-string)) + (insert (format "%-8s - %s \n" test-string test-result)))) + (insert "\n" "\n") + (insert "Test for invalid strings:\n") + (dolist (test-string invalid-strings) + (let ((test-result)) + (setq test-result (string-valid-number-p test-string)) + (insert (format "%-5s - %s \n" test-string test-result))))) diff --git a/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas b/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas new file mode 100644 index 0000000000..47846ad8c7 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/PascalABC.NET/determine-if-a-string-is-numeric.pas @@ -0,0 +1,11 @@ +function IsNumeric(s: string): boolean; +begin + var i: integer; + Result := integer.TryParse(s,i) +end; + +begin + var s := '123'; + if IsNumeric(s) then + Print('string is numeric') +end. diff --git a/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric.rust b/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-1.rust similarity index 100% rename from Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric.rust rename to Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-1.rust diff --git a/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-2.rust b/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-2.rust new file mode 100644 index 0000000000..6fa45d5e64 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric-2.rust @@ -0,0 +1,34 @@ +use std::str::FromStr; + +fn parsable(s: &str) -> bool { + s.parse::().is_ok() +} + +fn main() { + let test_cases = [ + "142857", + "3.14", + "not of this earth!" + ]; + + let types: &[(&str, fn(&str) -> bool)] = &[ + ("i32", parsable:: as fn(&str) -> bool), + ("i64", parsable:: as fn(&str) -> bool), + ("i128", parsable:: as fn(&str) -> bool), + + ("f64", parsable:: as fn(&str) -> bool), + ]; + + println!(""); + for &case in &test_cases { + for &(type_name, parse_fn) in types { + println!( + "'{}' {} be parsed as {}", + case, + if parse_fn(case) { "can" } else { "_cannot_" }, + type_name + ); + } + println!(""); + } +} diff --git a/Task/Determine-if-a-string-is-numeric/Zig/determine-if-a-string-is-numeric.zig b/Task/Determine-if-a-string-is-numeric/Zig/determine-if-a-string-is-numeric.zig new file mode 100644 index 0000000000..5c2a0ce361 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Zig/determine-if-a-string-is-numeric.zig @@ -0,0 +1,32 @@ +const std = @import("std"); +const stdout = std.io.getStdOut().writer(); + +fn isNumeric(str: []const u8) bool { + const num = std.mem.trim(u8, str, "\x20"); + _ = std.fmt.parseFloat(f64, num) catch return false; + return true; +} + +pub fn main() !void { + const s1 = " 123"; + const s2 = " +123"; + const s3 = " 12.3"; + const s4 = "-12.3"; + const s5 = "12e-3"; + const s6 = "=12-3"; + const s7 = "abcde"; + const s8 = "12cde"; + const s9 = "NaN"; + const s10 = "0xFF"; + + try stdout.print("Is {s} numeric? {}\n", .{ s1, isNumeric(s1) }); + try stdout.print("Is {s} numeric? {}\n", .{ s2, isNumeric(s2) }); + try stdout.print("Is {s} numeric? {}\n", .{ s3, isNumeric(s3) }); + try stdout.print("Is {s} numeric? {}\n", .{ s4, isNumeric(s4) }); + try stdout.print("Is {s} numeric? {}\n", .{ s5, isNumeric(s5) }); + try stdout.print("Is {s} numeric? {}\n", .{ s6, isNumeric(s6) }); + try stdout.print("Is {s} numeric? {}\n", .{ s7, isNumeric(s7) }); + try stdout.print("Is {s} numeric? {}\n", .{ s8, isNumeric(s8) }); + try stdout.print("Is {s} numeric? {}\n", .{ s9, isNumeric(s9) }); + try stdout.print("Is {s} numeric? {}\n", .{ s10, isNumeric(s10) }); +} diff --git a/Task/Determine-sentence-type/Emacs-Lisp/determine-sentence-type.l b/Task/Determine-sentence-type/Emacs-Lisp/determine-sentence-type.l new file mode 100644 index 0000000000..955366ef7c --- /dev/null +++ b/Task/Determine-sentence-type/Emacs-Lisp/determine-sentence-type.l @@ -0,0 +1,28 @@ +(defun get-last-character (str) + "Return the last character of STR." + (let ((str-length)) + (setq str-length (length str)) + (substring str (- str-length 1) str-length))) + +(defun classify-sentence (str) + "Classify the type of sentence based on final punctuation." + (let ((last-character (get-last-character str))) + (cond ((string= last-character ".") (format "S - %s" str)) + ((string= last-character "!") (format "E - %s" str)) + ((string= last-character "?") (format "Q - %s" str)) + (t (format "N - %s" str))))) + +(defun classify-multiple-sentences (str) + "Classify each sentence as Q, S, E, or N." + ;; sentence boundary is defined as: + ;; a period (full stop), comma, or question mark + ;; followed by one space + ;; followed by a capital letter + ;; while the above will work for this exercise, it won't + ;; work in other situations. See the Perl code in this section + ;; for cases that the above will not cover. + (let ((regex-sentence-boundary "\\([.?!]\\) \\([[:upper:]]\\)")) + ;; split the text into list of individual sentences + (dolist (one-sentence (split-string (replace-regexp-in-string regex-sentence-boundary "\\1\n\\2" str) "\n")) + ;; classify each sentence + (insert (format "\n%s" (classify-sentence one-sentence)))))) diff --git a/Task/Determine-sentence-type/FutureBasic/determine-sentence-type.basic b/Task/Determine-sentence-type/FutureBasic/determine-sentence-type.basic new file mode 100644 index 0000000000..1de7fb970c --- /dev/null +++ b/Task/Determine-sentence-type/FutureBasic/determine-sentence-type.basic @@ -0,0 +1,16 @@ +local fn SentenceType( sentence as CFStringRef ) as CFStringRef + CFStringRef type + select ( fn StringCharacterAtIndex( sentence, len(sentence)-1 ) ) + case _"?" : type = @"Q" + case _"." : type = @"S" + case _"!" : type = @"E" + case else : type = @"N" + end select +end fn = type + +print fn SentenceType( @"hi there, how are you today?" ) +print fn SentenceType( @"I'd like to present to you the washing machine 9001." ) +print fn SentenceType( @"You have been nominated to win one of these!" ) +print fn SentenceType( @"Just make sure you don't break it" ) + +HandleEvents diff --git a/Task/Determine-sentence-type/PascalABC.NET/determine-sentence-type.pas b/Task/Determine-sentence-type/PascalABC.NET/determine-sentence-type.pas new file mode 100644 index 0000000000..0e19ebfe52 --- /dev/null +++ b/Task/Determine-sentence-type/PascalABC.NET/determine-sentence-type.pas @@ -0,0 +1,18 @@ +function SentenceType(s: string): char; +begin + case s[^1] of + '?': Result := 'Q'; + '!': Result := 'E'; + '.': Result := 'S'; + else Result := 'N'; + end; +end; + +begin + var ss := Arr('hi there, how are you today?', + 'I''d like to present to you the washing machine 9001.', + 'You have been nominated to win one of these!', + 'Just make sure you don''t break it'); + foreach var s in ss do + Println(s,'->',SentenceType(s)); +end. diff --git a/Task/Determine-sentence-type/Refal/determine-sentence-type.refal b/Task/Determine-sentence-type/Refal/determine-sentence-type.refal new file mode 100644 index 0000000000..c1480b665e --- /dev/null +++ b/Task/Determine-sentence-type/Refal/determine-sentence-type.refal @@ -0,0 +1,17 @@ +$ENTRY Go { + , 'hi there, how are you today? I\'d like to ' + 'present to you the washing machine 9001. ' + 'You have been nominated to win one of these! ' + 'Just make sure you don\'t break it': e.Sentences + = >; +}; + +SentenceTypes { + e.X '?' = Q; + e.X '? ' e.Y = Q ; + e.X '.' = S; + e.X '. ' e.Y = S ; + e.X '!' = E; + e.X '! ' e.Y = E ; + e.X = N; +} diff --git a/Task/Dijkstras-algorithm/11l/dijkstras-algorithm.11l b/Task/Dijkstras-algorithm/11l/dijkstras-algorithm.11l index 40debc616d..5725c46344 100644 --- a/Task/Dijkstras-algorithm/11l/dijkstras-algorithm.11l +++ b/Task/Dijkstras-algorithm/11l/dijkstras-algorithm.11l @@ -1,12 +1,4 @@ -T Edge - String start - String end - Int cost - - F (start, end, cost) - .start = start - .end = end - .cost = cost +T Edge = (String start, String end, Int cost) T Graph [Edge] edges diff --git a/Task/Dinesmans-multiple-dwelling-problem/Quackery/dinesmans-multiple-dwelling-problem.quackery b/Task/Dinesmans-multiple-dwelling-problem/Quackery/dinesmans-multiple-dwelling-problem.quackery new file mode 100644 index 0000000000..42d42566ee --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Quackery/dinesmans-multiple-dwelling-problem.quackery @@ -0,0 +1,38 @@ + [ stack ] is problem ( --> s ) + + [ temp share 0 peek ] is baker ( --> n ) + [ temp share 1 peek ] is cooper ( --> n ) + [ temp share 2 peek ] is fletcher ( --> n ) + [ temp share 3 peek ] is miller ( --> n ) + [ temp share 4 peek ] is smith ( --> n ) + + [ temp share size = ] is top ( n --> b ) + [ 1 = ] is bottom ( n --> b ) + [ > ] is higher ( n n --> b ) + [ - abs 1 = ] is adjacent ( n n --> b ) + + [ if ]done[ ] is exclude ( b --> ) + [ not if ]done[ ] is require ( b --> ) + [ temp share nested join ] is include ( [ --> [ ) + + [ ]'[ ' include join + problem put + [] + ' [ 1 2 3 4 5 ] + permutations + witheach + [ temp put + problem share do + temp release ] + problem release + say " B C F M S" cr + witheach [ echo cr ] ] is solve ( --> ) + + solve + [ baker top exclude + cooper bottom exclude + fletcher top + fletcher bottom or exclude + miller cooper higher require + smith fletcher adjacent exclude + fletcher cooper adjacent exclude ] diff --git a/Task/Disarium-numbers/Refal/disarium-numbers.refal b/Task/Disarium-numbers/Refal/disarium-numbers.refal new file mode 100644 index 0000000000..24e17b740b --- /dev/null +++ b/Task/Disarium-numbers/Refal/disarium-numbers.refal @@ -0,0 +1,32 @@ +$ENTRY Go { + = ; +}; + +Digits { + 0 = ; + s.N, : (s.R) s.D = s.D; +}; + +Pow { + s.N 0 = 1; + s.N s.P = <* s.N >>; +}; + +PowSum { + () e.P = 0; + (s.I e.X) e.P = <+ >>; + e.X = ; +}; + +Disarium { + e.N, >: e.N = True; + e.N = False; +}; + +FindDisarium { + 0 s.N = ; + s.I s.N, : { + True = <+ s.N 1>>; + False = >; + }; +}; diff --git a/Task/Discordian-date/Refal/discordian-date.refal b/Task/Discordian-date/Refal/discordian-date.refal new file mode 100644 index 0000000000..1702d7bf77 --- /dev/null +++ b/Task/Discordian-date/Refal/discordian-date.refal @@ -0,0 +1,62 @@ +$ENTRY Go { + , >: s.GY + , >: s.GM + , >: s.GD + , : { + True e.Desc = ; + False = ; + }; +}; + +DisDate { + s.GY 2 29, : True = + True 'St. Tib\'s day in the YOLD ' >; + + s.GY s.GM s.GD, : '-' = False; + s.GY s.GM s.GD, : '+' = False; + s.GY s.GM s.GD, : '-' = False; + s.GY s.GM s.GD, >>: '+' = False; + + s.GY s.GM s.GD, + <+ > s.GD>: s.DOY, + 73>: (s.DS1) s.DD1, + <+ s.DS1 1>: s.DS, + <+ s.DD1 1>: s.DD, + <+ 5> 1>: s.DWD, + + >: (e.Weekday), + >: (e.Season), + + e.Weekday ', day ' ' of ' + e.Season ' in the YOLD ' >: e.Desc, + s.DD: { + 5, >: (e.H) = True e.Desc ': celebrate ' e.H; + 50, >: (e.H) = True e.Desc ': celebrate ' e.H; + s.X = True e.Desc; + }; +}; + +Item { + 1 t.I e.X = t.I; + s.N t.I e.X = e.X>; +}; + +IsLeapYear { + s.GY, : 0 = True; + s.GY, : 0 = False; + s.GY, : 0 = True; + s.GY = False; +}; + +MonthOffset { = 0 31 59 90 120 151 181 212 243 273 304 334; }; +MonthLength { = 31 28 31 30 31 30 31 31 30 31 30 31; }; + +Weekday { = ('Sweetmorn') ('Boomtime') ('Pungenday') + ('Prickle-Prickle') ('Setting Orange'); }; + +Seasons { = ('Chaos') ('Discord') ('Confusion') ('Bureaucracy') + ('The Aftermath'); }; + +Holy5 { = ('Mungday') ('Mojoday') ('Syaday') ('Zaraday') ('Maladay'); }; +Holy50 { = ('Chaoflux') ('Discoflux') ('Confuflux') + ('Bureflux') ('Afflux'); }; diff --git a/Task/Display-a-linear-combination/APL/display-a-linear-combination.apl b/Task/Display-a-linear-combination/APL/display-a-linear-combination.apl new file mode 100644 index 0000000000..d082f38e2b --- /dev/null +++ b/Task/Display-a-linear-combination/APL/display-a-linear-combination.apl @@ -0,0 +1,11 @@ + lincomb←{ + fmtco←{ + mul←(⍵≠1)/(⍕|⍵),'*' + mul,'e(',(⍕⍺),')' + } + + co←⊃¨fmtco/¨(⍵≠0)/(⍳⍴,⍵),¨|⍵ + sgn←'-+'[1+(×⍵)/×⍵] + lc←(('+'=⊃)↓⊢)∊sgn,¨co + 0=⍴lc:'0' ⋄ lc + } diff --git a/Task/Display-a-linear-combination/Applesoft-BASIC/display-a-linear-combination.basic b/Task/Display-a-linear-combination/Applesoft-BASIC/display-a-linear-combination.basic new file mode 100644 index 0000000000..1c3a5cdce5 --- /dev/null +++ b/Task/Display-a-linear-combination/Applesoft-BASIC/display-a-linear-combination.basic @@ -0,0 +1,22 @@ + 100 READ UX,UY + 110 DIM SCALARS(UX,UY) + 120 FOR N = 1 TO UX + 130 FOR M = 1 TO UY + 140 READ SCALARS(N,M) + 150 NEXT M,N + 160 DATA10,4 + 170 DATA1,2,3,0,0,1,2,3 + 180 DATA1,0,3,4,1,2,0,0 + 190 DATA0,0,0,0,0,0,0,0 + 200 DATA1,1,1,0,-1,-1,-1,0 + 210 DATA-1,-2,0,-3,-1,0,0,0 + 220 FOR N = 1 TO UX + 230 CADENA$ = "" + 240 FOR M = 1 TO UY + 250 SCALAR = SCALARS(N,M) + 260 IF SCALAR THEN CADENA$ = CADENA$ + CHR$ (44 - SGN (SCALAR)) + MID$ ( STR$ ( ABS (SCALAR)) + "*",1,255 * ( ABS (SCALAR) < > 1)) + "E" + STR$ (M) + 270 NEXT M + 280 IF CADENA$ = "" THEN CADENA$ = "0" + 290 IF LEFT$ (CADENA$,1) = "+" THEN CADENA$ = RIGHT$ (CADENA$, LEN (CADENA$) - 1) + 300 PRINT CADENA$ + 310 NEXT N diff --git a/Task/Display-a-linear-combination/Chipmunk-Basic/display-a-linear-combination.basic b/Task/Display-a-linear-combination/Chipmunk-Basic/display-a-linear-combination.basic new file mode 100644 index 0000000000..43ca40866a --- /dev/null +++ b/Task/Display-a-linear-combination/Chipmunk-Basic/display-a-linear-combination.basic @@ -0,0 +1,38 @@ +100 dim scalars(10,4) +110 scalars(1,1) = 1 : scalars(1,2) = 2 : scalars(1,3) = 3 +120 scalars(2,1) = 0 : scalars(2,2) = 1 : scalars(2,3) = 2 : scalars(2,4) = 3 +130 scalars(3,1) = 1 : scalars(3,2) = 0 : scalars(3,3) = 3 : scalars(3,4) = 4 +140 scalars(4,1) = 1 : scalars(4,2) = 2 : scalars(4,3) = 0 +150 scalars(5,1) = 0 : scalars(5,2) = 0 : scalars(5,3) = 0 +160 scalars(6,1) = 0 +170 scalars(7,1) = 1 : scalars(7,2) = 1 : scalars(7,3) = 1 +180 scalars(8,1) = -1 : scalars(8,2) = -1 : scalars(8,3) = -1 +190 scalars(9,1) = -1 : scalars(9,2) = -2 : scalars(9,3) = 0 : scalars(9,4) = -3 +200 scalars(10,1) = -1 +210 cls +220 for n = 1 to ubound(scalars) +230 cadena$ = "" +240 scalar = 0 +250 for m = 1 to ubound(scalars,2) +260 scalar = scalars(n,m) +270 if scalar <> 0 then +280 if scalar = 1 then +290 cadena$ = cadena$+"+e"+str$(m) +300 else +310 if scalar = -1 then +320 cadena$ = cadena$+"-e"+str$(m) +330 else +340 if scalar > 0 then +350 cadena$ = cadena$+chr$(43)+str$(scalar)+"*e"+str$(m) +360 else +370 cadena$ = cadena$+str$(scalar)+"*e"+str$(m) +380 endif +390 endif +400 endif +410 endif +420 next m +430 if cadena$ = "" then cadena$ = "0" +440 if left$(cadena$,1) = "+" then cadena$ = right$(cadena$,len(cadena$)-1) +450 print cadena$ +460 next n +470 end diff --git a/Task/Display-a-linear-combination/Cowgol/display-a-linear-combination.cowgol b/Task/Display-a-linear-combination/Cowgol/display-a-linear-combination.cowgol new file mode 100644 index 0000000000..70ebd193ef --- /dev/null +++ b/Task/Display-a-linear-combination/Cowgol/display-a-linear-combination.cowgol @@ -0,0 +1,60 @@ +include "cowgol.coh"; + +sub abs(n: int32): (r: uint32) is + if n < 0 + then r := (-n) as uint32; + else r := n as uint32; + end if; +end sub; + +sub lincomb(scalar: [int32], size: intptr) is + var first: uint8 := 1; + var item: uint8 := 1; + + sub print_sign() is + if first == 1 then + if [scalar] < 0 then print("-"); end if; + else + if [scalar] < 0 + then print(" - "); + else print(" + "); + end if; + end if; + end sub; + + sub print_term() is + if [scalar] == 0 then return; end if; + print_sign(); + if abs([scalar]) > 1 then + print_i32(abs([scalar])); + print("*"); + end if; + print("e("); + print_i8(item); + print(")"); + first := 0; + end sub; + + while size > 0 loop + print_term(); + scalar := @next scalar; + size := size - 1; + item := item + 1; + end loop; + + if first == 1 then + print("0"); + end if; + print_nl(); +end sub; + +var a1: int32[] := {1, 2, 3}; lincomb(&a1[0], @sizeof a1); +var a2: int32[] := {0, 1, 2, 3}; lincomb(&a2[0], @sizeof a2); +var a3: int32[] := {1, 0, 3, 4}; lincomb(&a3[0], @sizeof a3); +var a4: int32[] := {1, 2, 0}; lincomb(&a4[0], @sizeof a4); +var a5: int32[] := {0, 0, 0}; lincomb(&a5[0], @sizeof a5); +var a6: int32[] := {0}; lincomb(&a6[0], @sizeof a6); +var a7: int32[] := {1, 1, 1}; lincomb(&a7[0], @sizeof a7); +var a8: int32[] := {-1, -1, -1}; lincomb(&a8[0], @sizeof a8); +var a9: int32[] := {-1, -2, 0, 3}; lincomb(&a9[0], @sizeof a9); +var a10: int32[] := {-1}; lincomb(&a10[0], @sizeof a10); diff --git a/Task/Display-a-linear-combination/Draco/display-a-linear-combination.draco b/Task/Display-a-linear-combination/Draco/display-a-linear-combination.draco new file mode 100644 index 0000000000..68a3d6f49b --- /dev/null +++ b/Task/Display-a-linear-combination/Draco/display-a-linear-combination.draco @@ -0,0 +1,44 @@ +proc abs(int n) int: if n<0 then -n else n fi corp + +proc write_term(word index; int scalar; bool first) void: + if first then + if scalar<0 then write("-") fi + else + write(if scalar<0 then " - " else " + " fi) + fi; + if abs(scalar)>1 then + write(abs(scalar), '*') + fi; + write("e(",index,")") +corp + +proc lincomb([*]int terms) void: + bool first; + word index; + first := true; + + for index from 0 upto dim(terms,1)-1 do + if terms[index] /= 0 then + write_term(index+1, terms[index], first); + first := false + fi + od; + + writeln(if first then "0" else "" fi) +corp + +proc main() void: + [3]int a1 = (1,2,3); + [4]int a2 = (0,1,2,3); + [4]int a3 = (1,0,3,4); + [3]int a4 = (1,2,0); + [3]int a5 = (0,0,0); + [1]int a6 = (0); + [3]int a7 = (1,1,1); + [3]int a8 = (-1,-1,-1); + [4]int a9 = (-1,-2,0,3); + [1]int a10 = (-1); + lincomb(a1); lincomb(a2); lincomb(a3); lincomb(a4); + lincomb(a5); lincomb(a6); lincomb(a7); lincomb(a8); + lincomb(a9); lincomb(a10) +corp diff --git a/Task/Display-a-linear-combination/GW-BASIC/display-a-linear-combination.basic b/Task/Display-a-linear-combination/GW-BASIC/display-a-linear-combination.basic new file mode 100644 index 0000000000..f877d660ac --- /dev/null +++ b/Task/Display-a-linear-combination/GW-BASIC/display-a-linear-combination.basic @@ -0,0 +1,24 @@ +100 DIM SKLS(10, 4) +110 SKLS(1, 1) = 1: SKLS(1, 2) = 2: SKLS(1, 3) = 3 +120 SKLS(2, 1) = 0: SKLS(2, 2) = 1: SKLS(2, 3) = 2: SKLS(2, 4) = 3 +130 SKLS(3, 1) = 1: SKLS(3, 2) = 0: SKLS(3, 3) = 3: SKLS(3, 4) = 4 +140 SKLS(4, 1) = 1: SKLS(4, 2) = 2: SKLS(4, 3) = 0 +150 SKLS(5, 1) = 0: SKLS(5, 2) = 0: SKLS(5, 3) = 0 +160 SKLS(6, 1) = 0 +170 SKLS(7, 1) = 1: SKLS(7, 2) = 1: SKLS(7, 3) = 1 +180 SKLS(8, 1) = -1: SKLS(8, 2) = -1: SKLS(8, 3) = -1 +190 SKLS(9, 1) = -1: SKLS(9, 2) = -2: SKLS(9, 3) = 0: SKLS(9, 4) = -3 +200 SKLS(10, 1) = -1 +210 CLS +220 FOR N = 1 TO 10 +230 CAD$ = "" +240 SCL = 0 +250 FOR M = 1 TO 4 +260 SCL = SKLS(N, M) +270 IF SCL <> 0 THEN IF SCL = 1 THEN CAD$ = CAD$ + "+e" + STR$(M) ELSE IF SCL = -1 THEN CAD$ = CAD$ + "-e" + STR$(M) ELSE IF SCL > 0 THEN CAD$ = CAD$ + CHR$(43) + STR$(SCL) + "*e" + STR$(M) ELSE CAD$ = CAD$ + STR$(SCL) + "*e" + STR$(M) +280 NEXT M +290 IF CAD$ = "" THEN CAD$ = "0" +300 IF LEFT$(CAD$, 1) = "+" THEN CAD$ = RIGHT$(CAD$, LEN(CAD$) - 1) +310 PRINT CAD$ +320 NEXT N +330 END diff --git a/Task/Display-a-linear-combination/QBasic/display-a-linear-combination.basic b/Task/Display-a-linear-combination/QBasic/display-a-linear-combination.basic new file mode 100644 index 0000000000..f4fec89a91 --- /dev/null +++ b/Task/Display-a-linear-combination/QBasic/display-a-linear-combination.basic @@ -0,0 +1,37 @@ +DIM scalars(1 TO 10, 1 TO 4) +scalars(1, 1) = 1: scalars(1, 2) = 2: scalars(1, 3) = 3 +scalars(2, 1) = 0: scalars(2, 2) = 1: scalars(2, 3) = 2: scalars(2, 4) = 3 +scalars(3, 1) = 1: scalars(3, 2) = 0: scalars(3, 3) = 3: scalars(3, 4) = 4 +scalars(4, 1) = 1: scalars(4, 2) = 2: scalars(4, 3) = 0 +scalars(5, 1) = 0: scalars(5, 2) = 0: scalars(5, 3) = 0 +scalars(6, 1) = 0 +scalars(7, 1) = 1: scalars(7, 2) = 1: scalars(7, 3) = 1 +scalars(8, 1) = -1: scalars(8, 2) = -1: scalars(8, 3) = -1 +scalars(9, 1) = -1: scalars(9, 2) = -2: scalars(9, 3) = 0: scalars(9, 4) = -3 +scalars(10, 1) = -1 + +CLS +FOR n = 1 TO UBOUND(scalars) + cadena$ = "" + scalar = 0 + FOR m = 1 TO UBOUND(scalars, 2) + scalar = scalars(n, m) + IF scalar <> 0 THEN + IF scalar = 1 THEN + cadena$ = cadena$ + "+e" + STR$(m) + ELSEIF scalar = -1 THEN + cadena$ = cadena$ + "-e" + STR$(m) + ELSE + IF scalar > 0 THEN + cadena$ = cadena$ + CHR$(43) + STR$(scalar) + "*e" + STR$(m) + ELSE + cadena$ = cadena$ + STR$(scalar) + "*e" + STR$(m) + END IF + END IF + END IF + NEXT m + IF cadena$ = "" THEN cadena$ = "0" + IF LEFT$(cadena$, 1) = "+" THEN cadena$ = RIGHT$(cadena$, LEN(cadena$) - 1) + PRINT cadena$ +NEXT n +END diff --git a/Task/Display-a-linear-combination/Yabasic/display-a-linear-combination.basic b/Task/Display-a-linear-combination/Yabasic/display-a-linear-combination.basic new file mode 100644 index 0000000000..930d85eff3 --- /dev/null +++ b/Task/Display-a-linear-combination/Yabasic/display-a-linear-combination.basic @@ -0,0 +1,38 @@ +dim scalars(10,4) +scalars(1,1) = 1: scalars(1,2) = 2: scalars(1,3) = 3 +scalars(2,1) = 0: scalars(2,2) = 1: scalars(2,3) = 2: scalars(2,4) = 3 +scalars(3,1) = 1: scalars(3,2) = 0: scalars(3,3) = 3: scalars(3,4) = 4 +scalars(4,1) = 1: scalars(4,2) = 2: scalars(4,3) = 0 +scalars(5,1) = 0: scalars(5,2) = 0: scalars(5,3) = 0 +scalars(6,1) = 0 +scalars(7,1) = 1: scalars(7,2) = 1: scalars(7,3) = 1 +scalars(8,1) = -1: scalars(8,2) = -1: scalars(8,3) = -1 +scalars(9,1) = -1: scalars(9,2) = -2: scalars(9,3) = 0: scalars(9,4) = -3 +scalars(10,1) = -1 + +for n = 1 to arraysize(scalars(),1) + cadena$ = "" + + for m = 1 to arraysize(scalars(),2) + scalar = scalars(n, m) + if scalar <> 0 then + if scalar = 1 then + cadena$ = cadena$ + "+e" + str$(m) + else + if scalar = -1 then + cadena$ = cadena$ + "-e" + str$(m) + else + if scalar > 0 then + cadena$ = cadena$ + chr$(43) + str$(scalar) + "*e" + str$(m) + else + cadena$ = cadena$ + str$(scalar) + "*e" + str$(m) + fi + fi + fi + fi + next m + if cadena$ = "" cadena$ = "0" + if left$(cadena$, 1) = "+" cadena$ = right$(cadena$, len(cadena$)-1) + print cadena$ +next n +end diff --git a/Task/Display-an-outline-as-a-nested-table/Jq/display-an-outline-as-a-nested-table.jq b/Task/Display-an-outline-as-a-nested-table/Jq/display-an-outline-as-a-nested-table.jq new file mode 100644 index 0000000000..2c53129326 --- /dev/null +++ b/Task/Display-an-outline-as-a-nested-table/Jq/display-an-outline-as-a-nested-table.jq @@ -0,0 +1,135 @@ +def NNode($name; $children): {$name, $children}; +def INode($level; $name): {$level, $name}; + +# Input: {iNodes, n} where n is an NNode +# Output: the children of .n are updated +def toNest($start; $level): + if $level == 0 then .n.name = .iNodes[0].name end + | first( foreach (range( $start + 1; .iNodes|length), null) as $i (.; + if $i == null then .emit = true + elif .iNodes[$i].level == $level+1 + then (.n = NNode(.iNodes[$i].name; []) + | toNest($i; $level+1) + | .n) as $n + | .n.children += [$n] + | .emit = false + elif (.iNodes[$i].level <= $level) + then .emit = true + end; + if .emit then . else empty end) ) ; + +def makeIndent($outline; $tab): + (outline|split("\n")) as $lines + | reduce range(0; $lines|length) as $i ([]; + $lines[$i] as $line + | ($line|sub("^ *";"")) as $line2 + | ((($line|length) - ($line2|length)) / $tab | floor) as $level + | . + [INode($level; $line2)] ); + +# Input: NNode +def toMarkup($cols; $depth): + . as $n + | "|-" as $l1 + | "| |" as $l2 + + # input: {span} + | def colSpan($nn): + reduce range(0; $nn.children|length) as $i (.; + if ($i > 0) then .span += 1 end + | colSpan($nn.children[$i] )) + ; # end colSpan + + def nestedFor($nn; $level; $maxLevel; $col): + if $level == 1 and $maxLevel > $level + then reduce range(0; $nn.children|length) as $i (.; + $nn.children[$i] as $c + | nestedFor($c; 2; $maxLevel; $i) ) + elif $level < $maxLevel + then reduce $nn.children[] as $c (.; + nestedFor($c; $level+1; $maxLevel; $col) ) + elif $nn.children|length > 0 + then reduce range(0; $nn.children|length) as $i (.; + $nn.children[$i] as $c + | .span = 1 + | colSpan($c) + | (if $maxLevel == 1 then $i + 1 else $col + 1 end) as $cn + | .lines += ["| style=\"background: \($cols[$cn]) \" colspan=\(.span) | \($c.name)"] ) + else .lines += [$l2] + end + ; # end nestedFor + + reduce $n.children[] as $c (.span = 1; colSpan($c) ) + | .lines = ["{| class=\"wikitable\" style=\"text-align: center;\""] + | .lines += [$l1] + | .span = 1 + | colSpan($n) + | "| style=\"background: \(cols[0]) \" colSpan=\(.span) | \($n.name)" as $s + | .lines += [$s] + | .lines += [$l1] + + | reduce range(1; $depth) as $maxLevel (.; + nestedFor($n; 1; $maxLevel; 0) + | if $maxLevel < $depth-1 then .lines += [$l1] end) + | .lines += ["|}"] + | .lines|join("\n") ; + +def yellow: "#ffffe6;"; +def orange: "#ffebd2;"; +def green: "#f0fff0;"; +def blue: "#e6ffff;"; +def pink: "#ffeeff;"; + +### Examples + +def outline: +"Display an outline as a nested table.\n" + +" Parse the outline to a tree,\n" + +" measuring the indent of each line,\n" + +" translating the indentation to a nested structure,\n" + +" and padding the tree to even depth.\n" + +" count the leaves descending from each node,\n" + +" defining the width of a leaf as 1,\n" + +" and the width of a parent node as a sum.\n" + +" (The sum of the widths of its children) \n" + +" and write out a table with 'colspan' values\n" + +" either as a wiki table,\n" + +" or as HTML."; + + +def cols: [yellow, orange, green, blue, pink]; +def iNodes: makeIndent(outline; 4); +def n: NNode(""; []); + +def outline2: +"Display an outline as a nested table.\n" + +" Parse the outline to a tree,\n" + +" measuring the indent of each line,\n" + +" translating the indentation to a nested structure,\n" + +" and padding the tree to even depth.\n" + +" count the leaves descending from each node,\n" + +" defining the width of a leaf as 1,\n" + +" and the width of a parent node as a sum.\n" + +" (The sum of the widths of its children) \n" + +" Propagating the sums upward as necessary.\n" + +" and write out a table with 'colspan' values\n" + +" either as a wiki table,\n" + +" or as HTML.\n" + +" Optionally add color to the nodes.\n" ; + +def cols2: [blue, yellow, orange, green, pink]; + +def iNodes2: makeIndent(outline2; 4); + +def task1: + { iNodes: iNodes, n: n} + | toNest(0; 0) + | .n + | toMarkup(cols; 4) ; + +def task2: + { iNodes: iNodes2, n: n} + | toNest(0; 0) + | .n + | toMarkup(cols2; 4) ; + +task1, task2 diff --git a/Task/Distribution-of-0-digits-in-factorial-series/Quackery/distribution-of-0-digits-in-factorial-series.quackery b/Task/Distribution-of-0-digits-in-factorial-series/Quackery/distribution-of-0-digits-in-factorial-series.quackery new file mode 100644 index 0000000000..82ac1c78a8 --- /dev/null +++ b/Task/Distribution-of-0-digits-in-factorial-series/Quackery/distribution-of-0-digits-in-factorial-series.quackery @@ -0,0 +1,29 @@ + [ $ "bigrat.qky" loadfile ] now! + + [ stack ] is digits ( --> s ) + [ stack ] is zeroes ( --> s ) + + [ 0 digits put + 0 zeroes put + [ 1 digits tally + 10 /mod 0 = + zeroes tally + dup 0 = until ] + drop + zeroes take + digits take + reduce ] is zeroprop ( n --> n/d ) + + [ dup dip + [ 0 n->v + 1 ] + times + [ i^ 1+ * + dup zeroprop + rot dip v+ ] + drop + rot n->v v/ ] is distribution ( n --> n/d ) + + 100 distribution 10 point$ echo$ cr + 1000 distribution 10 point$ echo$ cr + 10000 distribution 10 point$ echo$ cr diff --git a/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas b/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas new file mode 100644 index 0000000000..a97277863b --- /dev/null +++ b/Task/Doubly-linked-list-Definition/PascalABC.NET/doubly-linked-list-definition.pas @@ -0,0 +1,75 @@ +type Node = auto class + data: T; + prev,next: Node; +end; + +type + MyLinkedList = class + first, last: Node; + procedure AddFirst(x: T); + begin + if first = nil then + begin + first := new Node(x,nil,nil); + last := first + end + else + begin + var p := new Node(x,nil,first); + first.prev := p; + first := p; + end; + end; + procedure AddLast(x: T); + begin + if first = nil then + begin + first := new Node(x,nil,nil); + last := first + end + else + begin + var p := new Node(x,last,nil); + last.next := p; + last := p; + end; + end; + procedure AddAfter(p: Node; x: T); + begin + if last = p then + AddLast(x) + else begin + var pp := new Node(x,p,p.next); + p.next := pp; + pp.next.prev := pp; + end + end; + procedure PrintList(); + begin + var p := first; + while p<>nil do + begin + Print(p.data); + p := p.next; + end; + end; + procedure PrintBack(); + begin + var p := last; + while p<>nil do + begin + Print(p.data); + p := p.prev; + end; + end; + end; + +begin + var lst := new MyLinkedList; + lst.AddFirst(2); lst.AddFirst(3); + lst.AddLast(5); + lst.AddAfter(lst.first,555); + lst.PrintList; + Println; + lst.PrintBack; +end. diff --git a/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas b/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas new file mode 100644 index 0000000000..41706415b2 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/PascalABC.NET/doubly-linked-list-element-definition.pas @@ -0,0 +1,4 @@ +type Node = auto class + data: T; + prev,next: Node; +end; diff --git a/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas b/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas new file mode 100644 index 0000000000..3b2f5422ce --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/PascalABC.NET/doubly-linked-list-element-insertion.pas @@ -0,0 +1,33 @@ +type Node = auto class + data: T; + prev,next: Node; +end; + +type + MyLinkedList = class + first, last: Node; + procedure AddLast(x: T); + begin + if first = nil then + begin + first := new Node(x,nil,nil); + last := first + end + else + begin + var p := new Node(x,last,nil); + last.next := p; + last := p; + end; + end; + procedure AddAfter(p: Node; x: T); + begin + if last = p then + AddLast(x) + else begin + var pp := new Node(x,p,p.next); + p.next := pp; + pp.prev.next := pp; + end + end; + end; diff --git a/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas b/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas new file mode 100644 index 0000000000..5e67b3187f --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/PascalABC.NET/doubly-linked-list-traversal.pas @@ -0,0 +1,9 @@ +begin + var lst := new LinkedList(1..10); + var current := lst.First; + while current <> nil do + begin + Print(current.Value); + current := current.Next; + end; +end. diff --git a/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas b/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas new file mode 100644 index 0000000000..7ac53bfab2 --- /dev/null +++ b/Task/Dragon-curve/PascalABC.NET/dragon-curve.pas @@ -0,0 +1,34 @@ +uses Turtle; + +var + Atom,FStr,XStr,YStr: string; + angle,len,x0,y0: real; + n: integer; + +procedure Init1; // Dragon +begin + (Atom,FStr,XStr,YStr) := ('fx','f','x+yf+','-fx-y'); + (angle,len,n,x0,y0) := (90,3,15,300,450); +end; + +procedure RunStr(s: string; n: integer); +begin + foreach var c in s do + case c of + '+': Turn(angle); + '-': Turn(-angle); + 'f','F': if n>0 then RunStr(FStr,n-1) else Forw(len); + 'x','X': if n>0 then RunStr(XStr,n-1); + 'y','Y': if n>0 then RunStr(YStr,n-1); + else Print('error') + end; +end; + +begin + Init1; + ToPoint(x0,y0); + SetWidth(0.5); + Down; + RunStr(Atom,n); + Up; +end. diff --git a/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 b/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 new file mode 100644 index 0000000000..bc2a9acaa1 --- /dev/null +++ b/Task/Draw-a-clock/XPL0/draw-a-clock.xpl0 @@ -0,0 +1,48 @@ +include xpllib; \for DrawCircle, DrawLine, LineWidth, MovePen, Deg2Rad +def X0=400, Y0=300; \center coordinate +int Hour, Minute, Second; + +proc DrawHand(Angle, Length, Width, Color); +real Angle, Length; +int Width, Color; +int X, Y; +[X:= fix(Length*Sin(Angle)); + Y:= fix(Length*Cos(Angle)); +LineWidth:= Width; +MovePen(X0, Y0); +DrawLine(X0+X, Y0-Y, Color); +]; + +proc DrawClock; \Show analog clock with current time +real Angle; +int N, X, Y; +[DrawCircle(X0, Y0, 299, LCyan, true); +Angle:= 0.; +for N:= 0 to 59 do \draw tick marks + [X:= fix(260.*Cos(Angle)); + Y:= fix(260.*Sin(Angle)); + DrawCircle(X+X0, Y+Y0, if rem(N/5) then 4 else 8, Black, true); + Angle:= Angle + 6.*Deg2Rad; + ]; +Angle:= float((Hour*60+Minute)/2) * Deg2Rad; +DrawHand(Angle, 210., 8, Black); +Angle:= float((Minute*60+Second)/10) * Deg2Rad; +DrawHand(Angle, 240., 5, Black); +Angle:= float(Second*6) * Deg2Rad; +DrawHand(Angle, 260., 3, LRed); +DrawCircle(X0, Y0, 8, Black, true); +]; + +int Second0; +char Time; +[SetVid($103); \800x600x8 +InitDraw; +repeat Time:= GetDateTime; + Hour:= Time(3); + if Hour>=12 then Hour:= Hour-12; + Minute:= Time(4); + Second:= Time(5); + if Second # Second0 then + [Second0:= Second; DrawClock]; +until KeyHit; +] diff --git a/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg b/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg new file mode 100644 index 0000000000..604f0aa481 --- /dev/null +++ b/Task/Draw-a-cuboid/ALGOL-68/draw-a-cuboid.alg @@ -0,0 +1,58 @@ +BEGIN # draw some cuboids using ASCII art # + + # draws a cuboid standing on one edge using ASCII art # + PROC aa cuboid = ( INT h, w, l )VOID: + BEGIN + # top line # + FOR i TO l DO print( ( " " ) ) OD; + FOR i TO w + 1 DO print( ( "_" ) ) OD; + print( ( newline ) ); + # rest of the top face and part of the visible side # + INT face width := 0; + INT edge pos := 0; + FOR i TO l DO + FOR j TO l - i DO print( ( " " ) ) OD; + print( ( "/" ) ); + FOR j TO w DO print( ( IF i = l THEN "_" ELSE " " FI ) ) OD; + print( ( "/" ) ); + edge pos +:= 1; + IF edge pos <= h THEN + # drsw the back edge # + face width := 2 * ( edge pos - 1 ); + FOR j TO face width DO print( ( " " ) ) OD; + print( ( "\" ) ) + ELSE + # draw the bottom edge # + FOR j TO face width + 1 DO print( ( " " ) ) OD; + print( ( "/" ) ) + FI; + print( ( newline ) ) + OD; + # other vidible face # + FOR i TO h DO + FOR j TO i - 1 DO print( ( " " ) ) OD; + print( ( "\" ) ); + FOR j TO w DO print( ( IF i = h THEN "_" ELSE " " FI ) ) OD; + print( ( "\" ) ); + edge pos +:= 1; + IF edge pos <= h THEN + # drsw the back edge # + FOR j TO face width + 1 DO print( ( " " ) ) OD; + print( ( "\" ) ) + ELSE + # draw the bottom edge # + FOR j TO face width DO print( ( " " ) ) OD; + face width -:= 2; + print( ( "/" ) ) + FI; + print( ( newline ) ) + OD + + END # aa cuboid # ; + + aa cuboid( 3, 2, 4 ); + aa cuboid( 4, 3, 2 ); + aa cuboid( 2, 4, 3 ); + aa cuboid( 2, 3, 4 ) + +END diff --git a/Task/Draw-a-cuboid/Jq/draw-a-cuboid.jq b/Task/Draw-a-cuboid/Jq/draw-a-cuboid.jq new file mode 100644 index 0000000000..6f59cbd05c --- /dev/null +++ b/Task/Draw-a-cuboid/Jq/draw-a-cuboid.jq @@ -0,0 +1,27 @@ +def cubLine($n; $dx; $dy; $cde): + def s: if . == 0 then "" else . * " " end; # for jaq + reduce range(1; 9*$dx) as $d ("\($n|s)\($cde[0:1])"; + . + $cde[1:2] ) + + $cde[0:1] + + ("\($dy|s)\($cde[2:])"); + +def cuboid($dx; $dy; $dz): + "cuboid \($dx) \($dy) \($dz):", + # top + cubLine($dy+1; $dx; 0; "+-"), + # top and side + (range(1; 1+$dy) as $i | cubLine($dy-$i+1; $dx; $i-1; "/ |")), + cubLine(0; $dx; $dy; "+-|"), + # front and side + (range(1; 4*$dz -$dy-2) as $i | cubLine(0; $dx; $dy; "| |")), + cubLine(0; $dx; $dy; "| +"), + # front and bottom + (range(1; 1+$dy) as $i | cubLine(0; $dx; $dy-$i; "| /")), + # bottom + cubLine(0; $dx; 0; "+-\n"); + +cuboid(2; 3; 4), +"", +cuboid(1; 1; 1), +"", +cuboid(6; 2; 1) diff --git a/Task/Draw-a-cuboid/Locomotive-Basic/draw-a-cuboid.basic b/Task/Draw-a-cuboid/Locomotive-Basic/draw-a-cuboid.basic new file mode 100644 index 0000000000..c7b41f6d6b --- /dev/null +++ b/Task/Draw-a-cuboid/Locomotive-Basic/draw-a-cuboid.basic @@ -0,0 +1,6 @@ +10 mode 2: origin 100,0: w=120: height=w*1.5: depth=w*2 +20 x=80: y=10 +30 plot x,y +40 drawr 0,height: drawr w,0: drawr 0,-height: drawr -w,0: rem front +50 plot x,y+height: drawr depth/2,height: drawr w,0: drawr 0,-height: drawr -w,-height +60 plot x+w,y+height: drawr depth/2,height diff --git a/Task/Draw-a-cuboid/PL-M/draw-a-cuboid.plm b/Task/Draw-a-cuboid/PL-M/draw-a-cuboid.plm new file mode 100644 index 0000000000..09220af2ea --- /dev/null +++ b/Task/Draw-a-cuboid/PL-M/draw-a-cuboid.plm @@ -0,0 +1,81 @@ +100H: /* DRAW SOME CUBOIDS USING ASCII ART */ + + /* CP/M BDOS SYSTEM CALL AND I/O ROUTINES */ + BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END; + PR$CHAR: PROCEDURE( C ); DECLARE C BYTE; CALL BDOS( 2, C ); END; + PR$NL: PROCEDURE; CALL PR$CHAR( 0DH ); CALL PR$CHAR( 0AH ); END; + + /* TASK */ + + /* DRAWS A CUBOID STANDING ON ONE EDGE USING ASCII ART */ + DRAW$CUBOID: PROCEDURE( H, W, L ); + DECLARE ( H, W, L ) BYTE; + DECLARE ( I, J, FACE$WIDTH, EDGE$POS ) BYTE; + + BACKSLASH: PROCEDURE; CALL PR$CHAR( 92 ); END; /* PRINTS A BACKSLASH */ + REPEAT$CHAR: PROCEDURE( CH, COUNT ); /* PRINTS CH COUNT TIMES */ + DECLARE ( CH, COUNT ) BYTE; + DECLARE I BYTE; + IF COUNT > 0 THEN DO; + DO I = 1 TO COUNT; CALL PR$CHAR( CH ); END; + END; + END REPEAT$CHAR; + UNDERSCORES: PROCEDURE( COUNT ); /* PRINTS COUNT UNDERSCORES */ + DECLARE COUNT BYTE; + CALL REPEAT$CHAR( 95, COUNT ); + END UNDERSCORES; + + /* TOP LINE */ + CALL REPEAT$CHAR( ' ', L ); CALL UNDERSCORES( W + 1 ); CALL PR$NL; + /* REST OF THE TOP FACE AND PART OF THE VISIBLE SIDE */ + FACE$WIDTH = 0; + EDGE$POS = 0; + DO I = 1 TO L; + CALL REPEAT$CHAR( ' ', L - I ); + CALL PR$CHAR( '/' ); + IF I = L THEN CALL UNDERSCORES( W ); + ELSE CALL REPEAT$CHAR( ' ', W ); + CALL PR$CHAR( '/' ); + EDGE$POS = EDGE$POS + 1; + IF EDGE$POS <= H THEN DO; + /* DRAW THE BACK EDGE */ + FACE$WIDTH = 2 * ( EDGE$POS - 1 ); + CALL REPEAT$CHAR( ' ', FACE$WIDTH ); + CALL BACKSLASH; + END; + ELSE DO; + /* DRAW THE BOTTOM EDGE AND THE MORE OF THE VISIBLE SIDE */ + CALL REPEAT$CHAR( ' ', FACE$WIDTH + 1 ); + CALL PR$CHAR( '/' ); + END; + CALL PR$NL; + END; + /* OTHER VISIBLE FACE */ + DO I = 1 TO H; + CALL REPEAT$CHAR( ' ', I - 1 ); + CALL BACKSLASH; + IF I = H THEN CALL UNDERSCORES( W ); + ELSE CALL REPEAT$CHAR( ' ', W ); + CALL BACKSLASH; + EDGE$POS = EDGE$POS + 1; + IF EDGE$POS <= H THEN DO; + /* DRAW THE BACK EDGE */ + CALL REPEAT$CHAR( ' ', FACE$WIDTH + 1 ); + CALL BACKSLASH; + END; + ELSE DO; + /* DRAW THE BOTTOM EDGE */ + CALL REPEAT$CHAR( ' ', FACE$WIDTH ); + FACE$WIDTH = FACE$WIDTH - 2; + CALL PR$CHAR( '/' ); + END; + CALL PR$NL; + END; + END DRAW$CUBOID; + + CALL DRAW$CUBOID( 3, 2, 4 ); + CALL DRAW$CUBOID( 4, 3, 2 ); + CALL DRAW$CUBOID( 2, 4, 3 ); + CALL DRAW$CUBOID( 2, 3, 4 ); + +EOF diff --git a/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas b/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas new file mode 100644 index 0000000000..caaee3cf72 --- /dev/null +++ b/Task/Draw-a-pixel/PascalABC.NET/draw-a-pixel.pas @@ -0,0 +1,6 @@ +uses GraphWPF; + +begin + Window.SetSize(320,240); + SetPixel(100,100,Colors.Red); +end. diff --git a/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas b/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas new file mode 100644 index 0000000000..37d716f15c --- /dev/null +++ b/Task/Draw-a-rotating-cube/PascalABC.NET/draw-a-rotating-cube.pas @@ -0,0 +1,6 @@ +uses Graph3D; + +begin + var Cube := Box(Origin,Sz3D(3,3,3),Colors.Green); + Cube.AnimRotate(OrtZ,180).Forever.Begin +end. diff --git a/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere.basic b/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-1.basic similarity index 100% rename from Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere.basic rename to Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-1.basic diff --git a/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic b/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic new file mode 100644 index 0000000000..c343edc95d --- /dev/null +++ b/Task/Draw-a-sphere/Locomotive-Basic/draw-a-sphere-2.basic @@ -0,0 +1,32 @@ +10 MODE 2:ORIGIN 320,200:INK 0,0:INK 1,26 +20 DIM v(2),vec(2) +30 v(0)=30:v(1)=30:v(2)=-50 +40 lung=SQR(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)) +50 v(0)=v(0)/lung +60 v(1)=v(1)/lung +70 v(2)=v(2)/lung +80 r=180:k=1.5:ambient=0.03 +90 FOR i=INT(-r) TO INT(r) +100 x=i +110 FOR j=INT(-2*r) TO INT(2*r) +120 y=j/2 +130 IF (x*x+y*y<=r*r) THEN GOSUB 1000 +140 NEXT j +160 NEXT i +170 END +1000 vec(0)=x +1010 vec(1)=y +1020 vec(2)=SQR(r*r-x*x-y*y) +1030 GOSUB 2000 +1040 GOSUB 3000 +1050 b=(d^k+ambient)/(1+ambient) +1060 IF b>rnd THEN PLOT x,-y +1100 RETURN +2000 lung=SQR(vec(0)*vec(0)+vec(1)*vec(1)+vec(2)*vec(2)) +2010 vec(0)=vec(0)/lung +2020 vec(1)=vec(1)/lung +2030 vec(2)=vec(2)/lung +2040 RETURN +3000 d=v(0)*vec(0)+v(1)*vec(1)+v(2)*vec(2) +3010 IF d<0 THEN d=-d ELSE d=0 +3020 RETURN diff --git a/Task/Dutch-national-flag-problem/Quackery/dutch-national-flag-problem.quackery b/Task/Dutch-national-flag-problem/Quackery/dutch-national-flag-problem.quackery new file mode 100644 index 0000000000..288a537074 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Quackery/dutch-national-flag-problem.quackery @@ -0,0 +1,16 @@ + [ 1 ] is red ( --> n ) + [ 2 ] is white ( --> n ) + [ 3 ] is blue ( --> n ) + + randomise + + [] ' [ red white blue ] + witheach + [ nested swap + 5 random times [ over join ] + swap join ] + + dup [ shuffle 2dup != until ] nip + + say "Before sorting: " dup echo cr + say " After sorting: " sortwith [ dip do do > ] echo cr diff --git a/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua b/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua new file mode 100644 index 0000000000..354f52209c --- /dev/null +++ b/Task/Dutch-national-flag-problem/Uiua/dutch-national-flag-problem.uiua @@ -0,0 +1,3 @@ +&p.[⍥(⊡⌊×3⚂"RWB")30] # Build it. +&p.⊏▽⊸>2⍏⊛.⊂"RWB" # Sort it, providing model for sort order. +&p⨬("oops"|"good")≍⊏⊸⍏.⊛ # Confirm it's sorted. diff --git a/Task/Eertree/11l/eertree.11l b/Task/Eertree/11l/eertree.11l index cbb87d6fd0..9cf90c9c9a 100644 --- a/Task/Eertree/11l/eertree.11l +++ b/Task/Eertree/11l/eertree.11l @@ -48,7 +48,7 @@ F eertree(s) F subPalindromes(tree) [String] s - F children(Int n, String =p) -> N + F children(Int n, String =p) -> Void L(c, n) @tree[n].edges p = c‘’p‘’c @s [+]= p diff --git a/Task/Egyptian-division/Zig/egyptian-division.zig b/Task/Egyptian-division/Zig/egyptian-division.zig new file mode 100644 index 0000000000..b6eed56815 --- /dev/null +++ b/Task/Egyptian-division/Zig/egyptian-division.zig @@ -0,0 +1,52 @@ +const std = @import("std"); + +pub fn egyptianDivision(dividend: u64, divisor: u64) [2]u64 { + const SIZE = 64; + var powers = [_]u64{0} ** SIZE; + var doublings = [_]u64{0} ** SIZE; + + var i: u64 = 0; + + while (i < SIZE) { + powers[i] = std.math.shl(u64, 1, i); + doublings[i] = std.math.shl(u64, divisor, i); + if (doublings[i] > dividend) { + break; + } + i += 1; + } + + var accumulator: u64 = 0; + var answer: u64 = 0; + i -= 1; + while (i >= 0) { + if (accumulator + doublings[i] <= dividend) { + accumulator += doublings[i]; + answer += powers[i]; + } + if (i > 0) { + i -= 1; + } else { + break; + } + } + var remainder = dividend - accumulator; + return .{ answer, remainder }; +} + +test "Expect 10, 0 from egyptianDivision(20, 2)" { + var output = egyptianDivision(20, 2); + try std.testing.expect(output[0] == 10); + try std.testing.expect(output[1] == 0); +} + +test "Expect 580 divided by 34 is 17 and the remainder is 2" { + var output = egyptianDivision(580, 34); + try std.testing.expect(output[0] == 17); + try std.testing.expect(output[1] == 2); +} + +pub fn main() !void { + var result = egyptianDivision(20, 2); + std.debug.print("20 divided by 2 is {} with remainder {}\n", .{ result[0], result[1] }); +} diff --git a/Task/Empty-program/PascalABC.NET/empty-program.pas b/Task/Empty-program/PascalABC.NET/empty-program.pas new file mode 100644 index 0000000000..ba38a01c6c --- /dev/null +++ b/Task/Empty-program/PascalABC.NET/empty-program.pas @@ -0,0 +1 @@ +## diff --git a/Task/Entropy-Narcissist/Jq/entropy-narcissist.jq b/Task/Entropy-Narcissist/Jq/entropy-narcissist.jq new file mode 100644 index 0000000000..882d3833c9 --- /dev/null +++ b/Task/Entropy-Narcissist/Jq/entropy-narcissist.jq @@ -0,0 +1,11 @@ +def chars: explode[] | [.] | implode; + +def bow(stream): + reduce stream as $word ({}; .[($word|tostring)] += 1); + +def sum(s): reduce s as $x (0; .+$x); + +length as $l +| bow(chars) +| sum(keys[] as $k | .[$k] as $c | $c * ($c|log2) ) +| ($l|log2) - ./$l diff --git a/Task/Enumerations/PascalABC.NET/enumerations.pas b/Task/Enumerations/PascalABC.NET/enumerations.pas new file mode 100644 index 0000000000..5a84af8534 --- /dev/null +++ b/Task/Enumerations/PascalABC.NET/enumerations.pas @@ -0,0 +1,6 @@ +type MyEnum = (One, Two = 2, Three = 3); + +begin + var my: MyEnum := One; + Print(my); +end. diff --git a/Task/Environment-variables/Langur/environment-variables-1.langur b/Task/Environment-variables/Langur/environment-variables-1.langur deleted file mode 100644 index 6491b51cb7..0000000000 --- a/Task/Environment-variables/Langur/environment-variables-1.langur +++ /dev/null @@ -1,3 +0,0 @@ -writeln "HOME: ", _env["HOME"] -writeln "PATH: ", _env["PATH"] -writeln "USER: ", _env["USER"] diff --git a/Task/Environment-variables/Langur/environment-variables-2.langur b/Task/Environment-variables/Langur/environment-variables.langur similarity index 100% rename from Task/Environment-variables/Langur/environment-variables-2.langur rename to Task/Environment-variables/Langur/environment-variables.langur diff --git a/Task/Esthetic-numbers/11l/esthetic-numbers.11l b/Task/Esthetic-numbers/11l/esthetic-numbers.11l index 63303794c8..27c380b3dc 100644 --- a/Task/Esthetic-numbers/11l/esthetic-numbers.11l +++ b/Task/Esthetic-numbers/11l/esthetic-numbers.11l @@ -13,7 +13,7 @@ F isEsthetic(=n, b) F listEsths(Int64 n1, n2, m1, m2; perLine, all) [Int64] esths - F dfs(Int64 n, m, i) -> N + F dfs(Int64 n, m, i) -> Void I i C n .. m @esths.append(i) I i == 0 | i > m {R} diff --git a/Task/Euler-method/XBasic/euler-method.basic b/Task/Euler-method/XBasic/euler-method.basic new file mode 100644 index 0000000000..25778eeb35 --- /dev/null +++ b/Task/Euler-method/XBasic/euler-method.basic @@ -0,0 +1,43 @@ +PROGRAM "Euclidean rhythm" +VERSION "0.0001" +IMPORT "xma" + +DECLARE FUNCTION Entry () +DECLARE FUNCTION Euler (paso) + +FUNCTION Entry () + PRINT "Time "; + tiempo! = 0.0 + DO WHILE tiempo! <= 100.1 + PRINT FORMAT$ ("#######", tiempo!); + tiempo! = tiempo! + 10.0 + LOOP + PRINT + + PRINT "Dif eq "; + tiempo! = 0.0 + DO WHILE tiempo! <= 100.1 + temperatura! = 20.0 + (100.0 - 20.0) * EXP(-0.07 * tiempo!) + PRINT FORMAT$ ("####.##", temperatura!); + tiempo! = tiempo! + 10.0 + LOOP + PRINT + + Euler(2) + Euler(5) + Euler(10) +END FUNCTION + +FUNCTION Euler (paso) + tiempo! = 0 + temperatura! = 100.0 + PRINT FORMAT$ ("Step ## ", paso); + + DO WHILE tiempo! <= 100 + IF (tiempo! MOD 10) = 0 THEN PRINT FORMAT$ ("####.##", temperatura!); + temperatura! = temperatura! + SINGLE(paso) * (-0.07 * (temperatura! - 20.0)) + tiempo! = tiempo! + paso + LOOP + PRINT +END FUNCTION +END PROGRAM diff --git a/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg b/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg new file mode 100644 index 0000000000..4b49f4d0c2 --- /dev/null +++ b/Task/Eulers-constant-0.5772.../ALGOL-W/eulers-constant-0.5772....alg @@ -0,0 +1,89 @@ +begin % calculate Euler's constant, translated from the XPL0 sample % + % which is translated from the C sample % + + long real A, B, H, N2, R, U, V; + long real array S ( 0 :: 1 ); + long real array B2( 0 :: 9 ); + long real Epsilon; + integer K, K2, M, N; + + Epsilon := 1'-6; + + % set output format % + i_w := 1; s_w := 0; r_w := 18; r_d := 15; r_format := "A"; + + write( "From the definition, error 3e-10" ); + N := 400; H := 1.0; + for K1 := 2 until N do H := H + 1.0 / K1; + comment Faster convergence: Negoi, 1997 ; + A := Ln( N + 0.5 + 1.0/( 24.0 * N ) ); + write( "Hn ", H ); + write( "gamma ", H - A ); write( "K = ", N ); write(); + + write( "Sweeney, 1963, error 3e-10" ); + N := 21; S( 0 ) := 0; S( 1 ) := N; + R := N; K:= 1; + while begin K := K + 1; + R := R * N / K; + S( K rem 2 ) := S( K rem 2 ) + R / K; + R > Epsilon + end + do begin end; + write( "gamma ", S( 1 ) - S( 0 ) - ln( N ) );write( "K = ", K ); write(); + + write( "Bailey, 1988" ); + N := 5; A := 1; H := 1; + N2 := 2 ** N; + R := 1; K := 1; + while begin K := K + 1; + R := R * N2 / K; + H := H + 1 / K; + B := A; A := A + R * H; + abs( B - A ) > Epsilon + end + do begin end; + A := A * N2 / Exp(N2); + write( "gamma ", A - N * Ln( 2 ) ); write( "K = ", K ); write(); + + write( "Brent-McMillan, 1980" ); + N := 13; A := -Ln( N ); + B := 1; U := A; V := B; + N2 := N * N; K2 := 0; K := 0; + while begin K2 := K2 + 2 * K + 1; + K := K + 1; + A := A * N2 / K; + B := B * N2 / K2; + A := ( A + B ) / K; + U := U + A; + V := V + B; + abs( A ) > Epsilon + end + do begin end; + write( "gamma ", U / V ); write( "K = ", K ); write(); + + write( "How Euler did it in 1735" ); + comment Bernoulli numbers with even indices; + + B2( 0 ) := 1; B2( 1 ) := 1 / 6; B2( 2 ) := -1 / 30; + B2( 3 ) := 1 / 42; B2( 4 ) := -1 / 30; B2( 5 ) := 5 / 66; + B2( 6 ) := -691 / 2730; B2( 7 ) := 7 / 6; B2( 8 ) := -3617 / 510; + B2( 9 ) := 43867 / 98; + M := 7; N := 10; + comment Nth harmonic number; + H := 1; + for K1 := 2 until N do H := H + 1 / K1; + write( "Hn ", H ); + H := H - Ln( N ); + write( " -ln ", H ); + comment Expansion C:= -digamma(1); + A := -1 / ( 2 * N ); + N2 := N * N; + R := 1; + for K1 := 1 until M do begin + R := R * N2; + A := A + B2( K1 ) / (2 * K1 * R ) + end for_K1; + write( "err ", A ); write( "gamma ", H + A ); write( "K = ", N + M ); + write(); + write( "C = 0.57721566490153286..." ); write() +end. diff --git a/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....ada b/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....ada new file mode 100644 index 0000000000..b27ada83d7 --- /dev/null +++ b/Task/Eulers-constant-0.5772.../Ada/eulers-constant-0.5772....ada @@ -0,0 +1,47 @@ +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Numerics.Long_Elementary_Functions; use Ada.Numerics.Long_Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Eulers_Constant is + + function Euler_Vacca (Iterations : Integer) return Long_Float is + Gamma : Long_Float := 1.0; + Term : Long_Float; + Power : Long_Integer; + Sign : Long_Float; + begin + Gamma := 0.5 - (1.0 / 3.0); + for I in 2 .. Iterations loop + Power := 2 ** Natural (I); + Sign := -1.0; + Term := 0.0; + for Domin in Power .. (2 * Power - 1) loop + Sign := - (Sign); + Term := Term + Sign / Long_Float (Domin); + end loop; + Gamma := Gamma + (Long_Float (I) * Term); + end loop; + return Gamma; + end Euler_Vacca; + + -- Ada Float type is IEEE 754 32-bit, giving 9 decimal digits of precision + Euler_Castellanos_Float : constant Float := + (((80.0 ** 3) + 92.0) / + (61.0 ** 4)) ** (1.0 / 6.0); + + -- Ada Long_Float type is IEEE 754 32-bit, giving 14 decimal digits of precision + Euler_Castellanos_Long_Float : constant Long_Float := + (990.0 ** 3 - 55.0 ** 3 - 79.0 ** 2 - 16.0) / + 70.0 ** 5; + + Iters : Integer; +begin + Put_Line ("Its. Vacca"); + Iters := 2; + while Iters <= 32 loop + Put_Line (Iters'Image & " " & Euler_Vacca (Iters)'Image); + Iters := Iters + 2; + end loop; + Put_Line ("Castellanos approximation for standard Float (9 digits): " & Euler_Castellanos_Float'Image); + Put_Line ("Castellanos approximation for Long Float (14 digits): " & Euler_Castellanos_Long_Float'Image); +end Eulers_Constant; diff --git a/Task/Eulers-constant-0.5772.../REXX/eulers-constant-0.5772....rexx b/Task/Eulers-constant-0.5772.../REXX/eulers-constant-0.5772....rexx new file mode 100644 index 0000000000..6a6280da94 --- /dev/null +++ b/Task/Eulers-constant-0.5772.../REXX/eulers-constant-0.5772....rexx @@ -0,0 +1,272 @@ +arg n; if n = '' then n = 100; numeric digits n +parse version version; say version; glob. = '' +say 'Euler-Mascheroni constant to' n 'decimal places' +say 'Method Brent-McMillan' +say +call time('r'); a = Brent(); e = format(time('e'),,3) +say 'Brent ' a '('e 'seconds)' +call time('r'); a = TrueValue(); e = format(time('e'),,3) +say 'True value' a '('e 'seconds)' +exit + +Brent: +procedure expose glob. +numeric digits Digits()+2 +-- Brent McMillan +n = Ceil((Digits()*Ln(10)+Ln(Pi()))*0.25); m = Ceil(2.07*Digits()) +n2 = n*n; ak = -Ln(n); bk = 1; s = ak; v = 1 +do k = 1 to m + bk = bk*n2/(k*k); ak = (ak*n2/k+bk)/k + s = s+ak; v = v+bk +end +y = s/v +numeric digits Digits()-2 +return y+0 + +TrueValue: +procedure expose glob. +return 0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495+0 + +E: +-- Euler number +procedure expose glob. +p = Digits() +-- In memory? +if glob.e.p <> '' then + return glob.e.p +if p < 101 then +-- Fast value + glob.e.p = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516643+0 +else do + numeric digits Digits()+2 +-- Taylor + y = 2; t = 1; v = y + do n = 2 + t = t/n; y = y+t + if y = v then + leave + v = y + end + numeric digits Digits()-2 + glob.e.p = y+0 +end +return glob.e.p + +Fact: +-- Factorial n! +procedure expose glob. +arg x +-- Validity +if \ Whole(x) then + return 'X' +if x < 0 then + return 'X' +-- Current in memory? +if glob.fact.x <> '' then + return glob.fact.x +w = x-1 +-- Previous in memory? +if glob.fact.w = '' then do +-- Loop cf definition + y = 1 + do n = 2 to x + y = y*n + end + glob.fact.x = y +end +else +-- Multiply + glob.fact.x = glob.fact.w*x +return glob.fact.x + +Ln2: +-- Natural log of 2 constant +procedure expose glob. +-- Fast value +y = 0.6931471805599453094172321214581765680755001343602552541206800094933936219696947156058633269964186875 +return y+0 + +Ln4: +-- Natural log of 4 constant +procedure expose glob. +-- Fast value +y = 1.386294361119890618834464242916353136151000268720510508241360018986787243939389431211726653992837375 +return y+0 + +Ln8: +-- Natural log of 8 constant +procedure expose glob. +-- Fast value +y = 2.079441541679835928251696364374529704226500403080765762362040028480180865909084146817589980989256063 +return y+0 + +Ln10: +-- Natural log of 10 constant +procedure expose glob. +-- Fast value +y = 2.30258509299404568401799145468436420760110148862877297603332790096757260967735248023599720508959830 +return y+0 + +Pi: +-- Pi constant +procedure expose glob. +p = Digits() +-- In memory? +if glob.pi.p <> '' then + return glob.pi.p +if p < 101 then +-- Fast value + glob.pi.p = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211707+0 +else do + numeric digits Digits()+2 + if p < 201 then do +-- Chudnovsky + y = 0 + do n = 0 + v = y; y = y + Fact(6*n)*(13591409+545140134*n)/(Fact(3*n)*Fact(n)**3*-640320**(3*n)) + if y = v then + leave + end + y = 4270934400/(Sqrt(10005)*y) + end + else do +-- Agmean + y = 0.25; a = 1; g = Sqrt(0.5); n = 1 + do until a = v + v = a + x = (a+g)*0.5; g = Sqrt(a*g) + y = y-n*(x-a)**2; n = n+n; a = x + end + y = a*a/y + end + numeric digits Digits()-2 + glob.pi.p = y+0 +end +return glob.pi.p + +Ceil: +-- Ceiling +procedure expose glob. +arg x +-- Formulas +if Whole(x) then + return x +else + return Trunc(x)+(x>=0) + +Ln: +-- Natural logarithm base e +procedure expose glob. +arg x +-- Validity +if x <= 0 then + return 'X' +-- Fast values +if x = 1 then + return 0 +p = Digits() +-- In memory? +if glob.ln.x.p <> '' then + return glob.ln.x.p +-- Precalculated values +if x = 2 & p < 101 then do + glob.ln.x.p = Ln2() + return glob.ln.x.p +end +if x = 4 & p < 101 then do + glob.ln.x.p = Ln4() + return glob.ln.x.p +end +if x = 8 & p < 101 then do + glob.ln.x.p = Ln8() + return glob.ln.x.p +end +if x = 10 & p < 101 then do + glob.ln.x.p = Ln10() + return glob.ln.x.p +end +numeric digits p+2 +-- Argument reduction +z = x; i = 0; e = 1/E() +if z < 0.5 then do + y = 1/z + do while y > 1.5 + y = y*e; i = i-1 + end + z = 1/y +end +if z > 1.5 then do + do while z > 1.5 + z = z*e; i = i+1 + end +end +-- Taylor series +q = (z-1)/(z+1); f = q; y = q; v = q; q = q*q +do n = 3 by 2 + f = f*q; y = y+f/n + if y = v then + leave + v = y +end +numeric digits p +-- Inverse reduction +glob.ln.x.p = 2*y+i +return glob.ln.x.p + +Sqrt: +-- Square root x^(1/2) +procedure expose glob. +arg x +-- Validity +if x < 0 then + return 'X' +-- Fast values +if x = 0 then + return 0 +if x = 1 then + return 1 +p = Digits() +-- Predefined values +if x = 2 & p < 101 then + return Sqrt2() +if x = 3 & p < 101 then + return Sqrt3() +if x = 5 & p < 101 then + return Sqrt5() +numeric digits p+2 +-- Argument reduction to [0,100) +i = Xpon(x); i = (i-(i<0))%2; x = x/100**i +-- First guess 1 digit accurate +t = '2.5 6.5 12.5 20.5 30.5 42.5 56.5 72.5 90.5 100' +do y = 1 until word(t,y) > x +end +-- Dynamic precision +d = Digits() +do n = 1 while d > 2 + d.n = d; d = d%2+1 +end +d.n = 2 +-- Method Heron +do k = n to 1 by -1 + numeric digits d.k + y = (y+x/y)*0.5 +end +numeric digits p +return y*10**i + +Whole: +-- Is a number integer? +procedure expose glob. +arg x +-- Formula +return Datatype(x,'w') + +Xpon: +-- Exponent +procedure expose glob. +arg x +-- Formula +if x = 0 then + return 0 +else + return Right(x*1E+99999,6)-99999 diff --git a/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas b/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas new file mode 100644 index 0000000000..d3cc8e5417 --- /dev/null +++ b/Task/Even-or-odd/PascalABC.NET/even-or-odd.pas @@ -0,0 +1,14 @@ +function IsOddRemainder(x: integer) := x mod 2 <> 0; + +function IsEvenRemainder(x: integer) := x mod 2 = 0; + +function IsOddBitwise(x: integer) := x and 1 = 1; + +function IsEvenBitwise(x: integer) := x and 1 = 0; + +begin + var x := 3; + Println(x.IsEven,x.IsOdd); // Standard Predicates + Println(IsEvenRemainder(x),IsOddRemainder(x)); + Println(IsEvenBitwise(x),IsOddBitwise(x)); +end. diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur index 0094318f1c..e376e53714 100644 --- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur @@ -1,15 +1,15 @@ -val .U0 = h{"msg": "U0"} -val .U1 = h{"msg": "U1"} +val U0 = {"msg": "U0"} +val U1 = {"msg": "U1"} -val .baz = fn(.i) throw if(.i==0: .U0; .U1) -val .bar = fn(.i) .baz(.i) +val baz = fn i: throw if(i==0: U0; U1) +val bar = fn i: baz(i) -val .foo = impure fn() { - for .i in [0, 1] { - .bar(.i) +val foo = impure fn() { + for i in [0, 1] { + bar(i) catch { - if _err'msg == .U0'msg { - writeln "caught .U0 in .foo()" + if _err'msg == U0'msg { + writeln "caught U0 in foo()" } else { throw } @@ -17,4 +17,4 @@ val .foo = impure fn() { } } -.foo() +foo() diff --git a/Task/Exceptions/Langur/exceptions-1.langur b/Task/Exceptions/Langur/exceptions-1.langur index a61a70b482..d9858c6b98 100644 --- a/Task/Exceptions/Langur/exceptions-1.langur +++ b/Task/Exceptions/Langur/exceptions-1.langur @@ -1,7 +1,7 @@ throw "not a math exception" -catch[.e] { - if .e'cat == "math" { +catch[e] { + if e'cat == "math" { # change result... } else { # rethrow the exception diff --git a/Task/Exceptions/Langur/exceptions-3.langur b/Task/Exceptions/Langur/exceptions-3.langur index e3e28e19f6..8a26842677 100644 --- a/Task/Exceptions/Langur/exceptions-3.langur +++ b/Task/Exceptions/Langur/exceptions-3.langur @@ -1,3 +1,3 @@ -val .safediv = fn(.x, .y) { .x / .y ; catch : 0 } -.safediv(7, 7) # 1 -.safediv(7, 0) # 0 +val safediv = fn(x, y) { x / y ; catch : 0 } +safediv(7, 7) # 1 +safediv(7, 0) # 0 diff --git a/Task/Exceptions/PascalABC.NET/exceptions-1.pas b/Task/Exceptions/PascalABC.NET/exceptions-1.pas new file mode 100644 index 0000000000..3234ceef1c --- /dev/null +++ b/Task/Exceptions/PascalABC.NET/exceptions-1.pas @@ -0,0 +1 @@ +type MyException = class(Exception) end; diff --git a/Task/Exceptions/PascalABC.NET/exceptions-2.pas b/Task/Exceptions/PascalABC.NET/exceptions-2.pas new file mode 100644 index 0000000000..d48f94c6ed --- /dev/null +++ b/Task/Exceptions/PascalABC.NET/exceptions-2.pas @@ -0,0 +1 @@ +raise new MyException; diff --git a/Task/Exceptions/PascalABC.NET/exceptions-3.pas b/Task/Exceptions/PascalABC.NET/exceptions-3.pas new file mode 100644 index 0000000000..15454868bd --- /dev/null +++ b/Task/Exceptions/PascalABC.NET/exceptions-3.pas @@ -0,0 +1,6 @@ +try + ... +except + on e: MyException do + statement +end; diff --git a/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic b/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic new file mode 100644 index 0000000000..ba59ec50ab --- /dev/null +++ b/Task/Execute-Computer-Zero/FreeBASIC/execute-computer-zero.basic @@ -0,0 +1,120 @@ +' Define the opcodes +Enum + NOP = 0 + LDA + STA + ADD + SUV + BRZ + JMP + STP +End Enum + +Function instr_(op As Ubyte, v As Ubyte) As Ubyte + Return (32 * op) + v +End Function + +Function NOP_(v As Ubyte) As Ubyte + Return instr_(NOP, v) +End Function + +Function LDA_(v As Ubyte) As Ubyte + Return instr_(LDA, v) +End Function + +Function STA_(v As Ubyte) As Ubyte + Return instr_(STA, v) +End Function + +Function ADD_(v As Ubyte) As Ubyte + Return instr_(ADD, v) +End Function + +Function SUB_(v As Ubyte) As Ubyte + Return instr_(SUV, v) +End Function + +Function BRZ_(v As Ubyte) As Ubyte + Return instr_(BRZ, v) +End Function + +Function JMP_(v As Ubyte) As Ubyte + Return instr_(JMP, v) +End Function + +Function STP_(v As Ubyte) As Ubyte + Return instr_(STP, v) +End Function + +Sub execute(nombre As String, program() As Ubyte) + ' Initialize memory and program counter + Dim As Ubyte m(Ubound(program)) + Dim As Short m_pos = -1 + + For i As Ubyte = Lbound(program) To Ubound(program) + m(m_pos + 1) = program(i) + m_pos += 1 + Next + + Dim As Boolean running = True + Dim As Ubyte pc = 0 + Dim As Ubyte a = 0 + Dim As Ubyte op + Dim As Ubyte operand + + While running + op = m(pc) \ 32 + operand = m(pc) Mod 32 + pc = (pc + 1) Mod 32 + + Select Case op + Case NOP + ' No operation + Case LDA + a = m(operand) + Case STA + m(operand) = a + Case ADD + a = (a + m(operand)) Mod 256 + If a > 255 Then a = 0 + Case SUV + a = (a - m(operand)) Mod 256 + If a < 0 Then a = 255 + Case BRZ + If a = 0 Then pc = operand + Case JMP + pc = operand + Case Else + ' Stop + running = False + Print Space(12 - Len(nombre)) & nombre & ": " & a + End Select + Wend +End Sub + +' Test programs +Dim poly1(4) As Ubyte = {LDA_(3), ADD_(4), STP_(0), 2, 2} +execute("2+2", poly1()) + +Dim poly2(13) As Ubyte = {LDA_(12), ADD_(10), STA_(12), LDA_(11), SUB_(13), STA_(11), BRZ_(8), JMP_(0), LDA_(12), STP_(0), 8, 7, 0, 1} +execute("7*8", poly2()) + +Dim poly3(0 To ...) As Ubyte = {LDA_(14), STA_(15), ADD_(13), STA_(14), LDA_(15), STA_(13), LDA_(16), SUB_(17), BRZ_(11), STA_(16), JMP_(0), LDA_(14), STP_(0), 1, 1, 0, 8, 1} +execute("fibonacci", poly3()) + +Dim poly4(0 To ...) As Ubyte = {LDA_(13), ADD_(15), STA_(5), ADD_(16), STA_(7), NOP_(0), STA_(14), NOP_(0), BRZ_(11), STA_(15), JMP_(0), LDA_(14), STP_(0), LDA_(0), 0, 28, 1, 0, 0, 0, 6, 0, 2, 26, 5, 20, 3, 30, 1, 22, 4, 24} +execute("linkedList", poly4()) + +Dim poly5(0 To ...) As Ubyte = {NOP_(0), NOP_(0), STP_(0), 0, LDA_(3), SUB_(29), BRZ_(18), LDA_(3), STA_(29), BRZ_(14), LDA_(1), ADD_(31), STA_(1), JMP_(2), LDA_(0), ADD_(31), STA_(0), JMP_(2), LDA_(3), STA_(29), LDA_(1), ADD_(30), ADD_(3), STA_(1), LDA_(0), ADD_(30), ADD_(3), STA_(0), JMP_(2), 0, 1, 3} +execute("prisoner", poly5()) + +Dim poly6(0 To ...) As Ubyte = {LDA_(3), SUB_(4), STP_(0), 0, 255} +execute("0-255", poly6()) + +Dim poly7(0 To ...) As Ubyte = {LDA_(3), SUB_(4), STP_(0), 0, 1} +execute("0-1", poly7()) + +Dim poly8(0 To ...) As Ubyte = {LDA_(3), ADD_(4), STP_(0), 1, 255} +execute("1+255", poly8()) + +Sleep diff --git a/Task/Execute-HQ9+/11l/execute-hq9+.11l b/Task/Execute-HQ9+/11l/execute-hq9+.11l index f78b71196e..61c3364c3b 100644 --- a/Task/Execute-HQ9+/11l/execute-hq9+.11l +++ b/Task/Execute-HQ9+/11l/execute-hq9+.11l @@ -38,7 +38,7 @@ F incr() :start: src = File(:argv[1]).read() -[Char = (() -> N)] dispatch +[Char = (() -> Void)] dispatch dispatch[Char(‘h’)] = hello dispatch[Char(‘q’)] = quine dispatch[Char(‘9’)] = bottles diff --git a/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic b/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic new file mode 100644 index 0000000000..2a3ce48e9f --- /dev/null +++ b/Task/Execute-SNUSP/FreeBASIC/execute-snusp.basic @@ -0,0 +1,77 @@ +' Rosetta Code problem: https://rosettacode.org/wiki/Execute_SNUSP +' by Jjuanhdez, 05/2024 +' The interpreter below implements Core SNUSP: + +Const HW = "/++++!/===========?\>++.>+.+++++++..+++" & Chr(10) & _ +"\+++\ | /+>+++++++>/ /++++++++++<<.++>./" & Chr(10) & _ +"$+++/ | \+++++++++>\ \+++++.>.+++.-----\" & Chr(10) & _ +" \==-<<<<+>+++/ /=.>.+>.--------.-/" + +Dim Shared As Integer ipf, ipc ' instruction pointers in row and column +Dim Shared As Integer direcc ' direction (0 = right, 1 = down, 2 = left, 3 = up) + +Sub Paso() + If direcc And 1 Then + ipf += 1 - (direcc And 2) + Else + ipc += 1 - (direcc And 2) + End If +End Sub + +Sub SNUSP (dsLen As Integer, SNUSPcode As String) + Dim As Ubyte ad(dsLen - 1) ' data store + Dim As Integer dp ' data pointer + Dim As String cb(dsLen) ' two-way code storage + Dim As String fila, op, linea + Dim As Integer r, i, j + + dp = 0 + i = 1 + j = 1 + ipf = 0 + ipc = 0 + direcc = 0 + + While i <= Len(SNUSPcode) + If Mid(SNUSPcode, i, 1) = Chr(10) Then + cb(j) = linea + linea = "" + j += 1 + Else + linea &= Mid(SNUSPcode, i, 1) + End If + i += 1 + Wend + cb(j) = linea + + For r = 0 To Ubound(cb) + fila = cb(r) + ipc = Instr(fila, "$") - 1 + If ipc >= 0 Then + ipf = r + Exit For + End If + Next r + + While ipf >= 0 And ipf <= Ubound(cb) And ipc >= 0 And ipc < Len(cb(ipf)) + op = Mid(cb(ipf), ipc + 1, 1) + Select Case op + Case ">": dp += 1 ' RIGTH + Case "<": dp -= 1 ' LEFT + Case "+": ad(dp) += 1 ' INCR + Case "-": ad(dp) -= 1 ' DECR + Case ",": Input ad(dp) ' READ + Case ".": Print Chr(ad(dp)); ' WRITE + Case "/": direcc = Not direcc ' RULD + Case "\": direcc Xor= 1 ' LURD + Case "!": Paso ' SKIP + Case "?": If ad(dp) = 0 Then Paso ' SKIPZ + End Select + Paso + Wend + Print Chr(ad(dp)); +End Sub + +SNUSP(5, HW) + +Sleep diff --git a/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l b/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l index 5c8a789dc8..4c3cf6cc78 100644 --- a/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l +++ b/Task/Execute-a-Markov-algorithm/11l/execute-a-markov-algorithm.11l @@ -1,11 +1,4 @@ -T Rule - String pattern - String replacement - Bool terminating - F (pattern, replacement, terminating) - .pattern = pattern - .replacement = replacement - .terminating = terminating +T Rule = (String pattern, String replacement, Bool terminating) F parse(rules) [Rule] result diff --git a/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic b/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic new file mode 100644 index 0000000000..8d0a5ec743 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/FreeBASIC/execute-a-markov-algorithm.basic @@ -0,0 +1,139 @@ +Sub Markov (rules As String, entrada As String, expected As String) + Dim As String subs(), reps(), lines() + Dim As String sub_, rep, li, res + Dim As Integer i, k + Dim As Integer start = 1, finish = 1 + + While finish <= Len(rules) + If Mid(rules, finish, 1) = Chr(10) Then + Redim Preserve lines(Ubound(lines) + 1) + lines(Ubound(lines)) = Mid(rules, start, finish - start) + start = finish + 1 + End If + finish += 1 + Wend + For i = 0 To Ubound(lines) + li = lines(i) + If Len(li) > 0 And Asc(li, 1) <> Asc("#") Then + k = Instr(li, " -> ") + If k > 0 Then + Redim Preserve subs(Ubound(subs) + 1) + subs(Ubound(subs)) = Trim(Mid(li, 1, k - 1)) + Redim Preserve reps(Ubound(reps) + 1) + reps(Ubound(reps)) = Trim(Mid(li, k + 4)) + End If + End If + Next i + + res = entrada + Dim As Boolean term = False, found = False + Do + found = False + For i = 0 To Ubound(subs) + sub_ = subs(i) + k = Instr(res, sub_) + If k > 0 Then + found = True + rep = reps(i) + If Len(rep) > 0 And Asc(rep, 1) = Asc(".") Then + rep = Mid(rep, 2) + term = True + End If + Mid(res, k, Len(sub_)) = rep + Exit For + End If + If Not term Then Exit For + Next i + If Not term Or Not found Then Exit Do + Loop + Print """"; entrada;""""; ", "; """"; expected; """"; ", "; Iif(res = expected, "**ERROR**", "ok") +End Sub + +Dim As String ruleset1 = _ +"# This rules file is extracted from Wikipedia:" & _ +"# http://en.wikipedia.org/wiki/Markov_Algorithm" & _ +"A -> apple" & _ +"B -> bag" & _ +"S -> shop" & _ +"T -> the" & _ +"the shop -> my brother" & _ +"a never used -> .terminating rule" +Markov(ruleset1,"I bought a B of As from T S.","I bought a bag of apples from my brother.") + +Dim As String ruleset2 = _ +"# Slightly modified from the rules on Wikipedia" & _ +"A -> apple" & _ +"B -> bag" & _ +"S -> .shop" & _ +"T -> the" & _ +"the shop -> my brother" & _ +"a never used -> .terminating rule" +Markov(ruleset2,"I bought a B of As from T S.","I bought a bag of apples from T shop.") + +Dim As String ruleset3 = _ +"# BNF Syntax testing rules" & _ +"A -> apple" & _ +"WWWW -> with" & _ +"Bgage -> ->.*" & _ +"B -> bag" & _ +"->.* -> money" & _ +"W -> WW" & _ +"S -> .shop" & _ +"T -> the" & _ +"the shop -> my brother" & _ +"a never used -> .terminating rule""" +Markov(ruleset3,"I bought a B of As W my Bgage from T S.","I bought a bag of apples with my money from T shop.") + +Dim As String ruleset4 = _ +"### Unary Multiplication Engine, for testing Markov Algorithm implementations" & _ +"### By Donal Fellows." & _ +"# Unary addition engine" & _ +"_+1 -> _1+" & _ +"1+1 -> 11+" & _ +"# Pass for converting from the splitting of multiplication into ordinary" & _ +"# addition" & _ +"1! -> !1" & _ +",! -> !+" & _ +"_! -> _" & _ +"# Unary multiplication by duplicating left side, right side times" & _ +"1*1 -> x,@y" & _ +"1x -> xX" & _ +"X, -> 1,1" & _ +"X1 -> 1X" & _ +"_x -> _X" & _ +",x -> ,X" & _ +"y1 -> 1y" & _ +"y_ -> _" & _ +"# Next phase of applying" & _ +"1@1 -> x,@y" & _ +"1@_ -> @_" & _ +",@_ -> !_" & _ +"++ -> +" & _ +"# Termination cleanup for addition" & _ +"_1 -> 1" & _ +"1+_ -> 1" & _ +"_+_ -> " +Markov(ruleset4,"_1111*11111_","11111111111111111111") + +Dim As String ruleset5 = _ +"# Turing machine: three-state busy beaver" & _ +"#" & _ +"# state A, symbol 0 => write 1, move right, new state B" & _ +"A0 -> 1B" & _ +"# state A, symbol 1 => write 1, move left, new state C" & _ +"0A1 -> C01" & _ +"1A1 -> C11" & _ +"# state B, symbol 0 => write 1, move left, new state A" & _ +"0B0 -> A01" & _ +"1B0 -> A11" & _ +"# state B, symbol 1 => write 1, move right, new state B" & _ +"B1 -> 1B" & _ +"# state C, symbol 0 => write 1, move left, new state B" & _ +"0C0 -> B01" & _ +"1C0 -> B11" & _ +"# state C, symbol 1 => write 1, move left, halt" & _ +"0C1 -> H01" & _ +"1C1 -> H11" +Markov(ruleset5,"000000A000000","00011H1111000") + +Sleep diff --git a/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 b/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 index eafaacc2ca..7de9dc25a3 100644 --- a/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 +++ b/Task/Execute-a-system-command/Seed7/execute-a-system-command.seed7 @@ -3,5 +3,5 @@ $ include "seed7_05.s7i"; const proc: main is func begin - cmd_sh("ls"); + shellCmd("ls"); end func; diff --git a/Task/Extend-your-language/Langur/extend-your-language-2.langur b/Task/Extend-your-language/Langur/extend-your-language-2.langur deleted file mode 100644 index ee25f3a906..0000000000 --- a/Task/Extend-your-language/Langur/extend-your-language-2.langur +++ /dev/null @@ -1,7 +0,0 @@ -switch[and] .x, .y { - case true: ... # both true - case true, false: ... # first true, second false - case false, true: ... # first false, second true - case null, _: ... # first null - default: ... # other -} diff --git a/Task/Extend-your-language/Langur/extend-your-language-1.langur b/Task/Extend-your-language/Langur/extend-your-language.langur similarity index 86% rename from Task/Extend-your-language/Langur/extend-your-language-1.langur rename to Task/Extend-your-language/Langur/extend-your-language.langur index 45647137b3..13bd34e454 100644 --- a/Task/Extend-your-language/Langur/extend-your-language-1.langur +++ b/Task/Extend-your-language/Langur/extend-your-language.langur @@ -1,4 +1,4 @@ -switch[and] .x nxor, .y nxor { +switch[and] x nxor, y nxor { case true: ... # both true case true, false: ... # first true, second false case false, true: ... # first false, second true diff --git a/Task/Extreme-floating-point-values/PascalABC.NET/extreme-floating-point-values.pas b/Task/Extreme-floating-point-values/PascalABC.NET/extreme-floating-point-values.pas new file mode 100644 index 0000000000..3cb7d97575 --- /dev/null +++ b/Task/Extreme-floating-point-values/PascalABC.NET/extreme-floating-point-values.pas @@ -0,0 +1,14 @@ +begin + Println(1.0/real.PositiveInfinity); // 0 + Println(1.0/real.NegativeInfinity); // 0 + Println(0.0/0.0); // NaN + Println(1.0/0.0); // Infinity + Println(-1.0/0.0); // -Infinity + Println(real.NegativeInfinity < real.PositiveInfinity); // True + Println(real.NegativeInfinity + real.PositiveInfinity); // NaN + Println(real.PositiveInfinity + real.PositiveInfinity); // Infinity + Println(real.PositiveInfinity / real.PositiveInfinity); // NaN + Println(Sqrt(-1)); // NaN + Println(real.NaN = real.NaN); // False + Println(real.IsNaN(Sqrt(-1))); // True +end. diff --git a/Task/FTP/Ada/ftp.ada b/Task/FTP/Ada/ftp.ada new file mode 100644 index 0000000000..a7565b49eb --- /dev/null +++ b/Task/FTP/Ada/ftp.ada @@ -0,0 +1,57 @@ +with Ada.Text_IO; +with Sf.Network.Ftp; +with Sf.Network.IpAddress; +with Sf.System.Time; + +procedure Main is + use Sf; use Sf.Network; use Sf.Network.Ftp; + FTP_Error : exception; + + FTP_Object : constant sfFtp_Ptr := create; + + procedure Check_Response (FTP_Response : sfFtpResponse_Ptr) is + Message : constant String := Response.getMessage (FTP_Response); + begin + Response.destroy (FTP_Response); + if not Response.isOk (FTP_Response) then + raise FTP_Error with Message; + else + Ada.Text_IO.Put_Line ("OK: " & Message); + end if; + end Check_Response; + + procedure List_Directory (Path : String) is + Response : sfFtpListingResponse_Ptr; + begin + Response := getDirectoryListing (FTP_Object, Path); + if ListingResponse.isOk (Response) then + for Index in 0 .. ListingResponse.getCount (Response) - 1 loop + Ada.Text_IO.Put_Line (ListingResponse.getName (Response, Index)); + end loop; + else + Ada.Text_IO.Put_Line (ListingResponse.getMessage (Response)); + end if; + ListingResponse.destroy (Response); + end List_Directory; + +begin + + Check_Response + (connect (FTP_Object, + server => IpAddress.fromString ("speedtest.tele2.net"), + port => 21, + timeout => Sf.System.Time.sfSeconds (30.0))); + + Check_Response (loginAnonymous (FTP_Object)); + + Check_Response (changeDirectory (FTP_Object, "/upload")); + Check_Response (changeDirectory (FTP_Object, "/")); + + List_Directory ("."); + + Check_Response (download (FTP_Object, + remoteFile => "100KB.zip", + localPath => ".", + mode => sfFtpBinary)); + destroy (FTP_Object); +end Main; diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++/factorial-base-numbers-indexing-permutations-of-a-collection.cpp b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++/factorial-base-numbers-indexing-permutations-of-a-collection.cpp new file mode 100644 index 0000000000..cb53769288 --- /dev/null +++ b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/C++/factorial-base-numbers-indexing-permutations-of-a-collection.cpp @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include + +std::string stringify(const std::string& text) { + return text; +} + +std::string stringify(const uint32_t& number) { + return std::to_string(number); +} + +template +std::string to_string(const std::vector& factoradic, const std::string& delimiter) { + std::string result = ""; + for ( uint32_t i = 0; i < factoradic.size() - 1; ++i ) { + result += stringify(factoradic[i]) + delimiter; + } + result += stringify(factoradic.back()); + return result; +} + +uint32_t factorial(const uint32_t& n) { + uint32_t factorial = 1; + for ( uint32_t i = 2; i <= n; ++i ) { + factorial *= i; + } + return factorial; +} + +void increment(std::vector& factoradic) { + uint64_t index = factoradic.size() - 1; + while ( index >= 0 && factoradic[index] == factoradic.size() - index ) { + factoradic[index] = 0; + index -= 1; + } + if ( index >= 0 ) { + factoradic[index] += 1; + } +} + +std::vector split_string(const std::string& text, const char& delimiter) { + std::vector lines; + std::istringstream stream(text); + std::string line; + while ( std::getline(stream, line, delimiter) ) { + if ( ! line.empty() ) { + lines.emplace_back(line); + } + } + return lines; +} + +std::vector convert_to_vector_of_integer(const std::string& text) { + std::vector result = { }; + std::vector numbers = split_string(text, '.'); + for ( const std::string& number : numbers ) { + result.emplace_back(std::stoi(number)); + } + return result; +} + +template +std::vector permutation(std::vector elements, const std::vector& factoradic) { + uint32_t m = 0; + for ( const uint32_t& g : factoradic ) { + const T element = elements[m + g]; + elements.erase(elements.begin() + m + g); + elements.insert(elements.begin() + m, element); + m += 1; + } + return elements; +} + +int main() { + // Part 1 + std::vector elements = convert_to_vector_of_integer("0.1.2.3"); + std::vector factoradic = convert_to_vector_of_integer("0.0.0"); + for ( uint32_t i = 0; i < factorial(4); ++i ) { + std::vector rotated = permutation(elements, factoradic); + std::cout << to_string(factoradic, ".") + " --> " + to_string(rotated, " ") << std::endl; + increment(factoradic); + } + std::cout << std::endl; + + // Part 2 + std::cout << "Generating the permutations of 11 digits:" << std::endl; + const uint32_t limit = factorial(11); + elements = convert_to_vector_of_integer("0.1.2.3.4.5.6.7.8.9.10"); + factoradic = convert_to_vector_of_integer("0.0.0.0.0.0.0.0.0.0"); + for ( uint32_t i = 0; i < limit; ++i ) { + std::vector rotated = permutation(elements, factoradic); + if ( i < 3 || i > limit - 4 ) { + std::cout << to_string(factoradic, ".") + " --> " + to_string(rotated, " ") + << std::endl; + } else if ( i == 3 ) { + std::cout << " [ ... ] " << std::endl; + } + increment(factoradic); + } + std::cout << "Number of permutations is 11! = " << limit << std::endl << std::endl; + + // Part 3 + std::vector codes = { "39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14.20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0", +"51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4.7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1" }; + + std::vector cards = { "A♠", "K♠", "Q♠", "J♠", "10♠", "9♠", "8♠", "7♠", "6♠", "5♠", "4♠", "3♠", "2♠", + "A♥", "K♥", "Q♥", "J♥", "10♥", "9♥", "8♥", "7♥", "6♥", "5♥", "4♥", "3♥", "2♥", + "A♦", "K♦", "Q♦", "J♦", "10♦", "9♦", "8♦", "7♦", "6♦", "5♦", "4♦", "3♦", "2♦", + "A♣", "K♣", "Q♣", "J♣", "10♣", "9♣", "8♣", "7♣", "6♣", "5♣", "4♣", "3♣", "2♣" + }; + + std::cout << "Original deck of cards:" << std::endl; + std::cout << to_string(cards, " ") << std::endl << std::endl; + std::cout << "Task shuffles:" << std::endl; + for ( const std::string& code : codes ) { + std::cout << code + " --> " << std::endl; + factoradic = convert_to_vector_of_integer(code); + std::cout << to_string(permutation(cards, factoradic), " ") + << std::endl << std::endl; + } + + std::cout << "Random shuffle:" << std::endl;; + std::random_device random; + std::mt19937 generator(random()); + + factoradic.clear(); + for ( uint32_t i = 0; i < cards.size() - 1; ++i ) { + std::uniform_int_distribution distribution(0, cards.size() - i - 1); + factoradic.emplace_back(distribution(generator)); + } + + std::cout << to_string(factoradic, ".") + " --> " << std::endl; + std::cout << to_string(permutation(cards, factoradic), " ") << std::endl; +} diff --git a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java index 9e7609637e..3f126f2202 100644 --- a/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java +++ b/Task/Factorial-base-numbers-indexing-permutations-of-a-collection/Java/factorial-base-numbers-indexing-permutations-of-a-collection.java @@ -58,7 +58,7 @@ public final class FactorialBaseNumbersIndexingPermutations { System.out.println("Random shuffle:"); ThreadLocalRandom random = ThreadLocalRandom.current(); factoradic.clear(); - for ( int i = 0; i < 52; i++ ) { + for ( int i = 0; i < cards.size() - 1; i++ ) { factoradic.add(random.nextInt(cards.size() - i)); } System.out.println(toString(factoradic, ".") + " --> "); diff --git a/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp b/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp new file mode 100644 index 0000000000..0e28867922 --- /dev/null +++ b/Task/Factorial-primes/Common-Lisp/factorial-primes.lisp @@ -0,0 +1,27 @@ +(defun factorial (x) + (if (= x 1) + x + (* x (factorial (- x 1))))) + +(defun is-factor (x y) + (zerop (mod x y))) + +(defun is-prime (n) + (cond ((< n 4) (or (= n 2) (= n 3))) + ((or (zerop (mod n 2)) (zerop (mod n 3))) nil) + (t (loop for i from 5 to (floor (sqrt n)) by 6 + never (or (is-factor n i) + (is-factor n (+ i 2))))))) + +(defun main (&optional (limit 10)) + (let ((n 0) + (f 0)) + (loop while (< n limit) + for i from 1 + do (setf f (factorial i)) + (when (is-prime (+ f 1)) + (incf n) + (format t "~2d: ~2d! + 1 = ~12d~%" n i (+ f 1))) + (when (is-prime (- f 1)) + (incf n) + (format t "~2d: ~2d! - 1 = ~12d~%" n i (- f 1)))))) diff --git a/Task/Factorial-primes/Go/factorial-primes.go b/Task/Factorial-primes/Go/factorial-primes.go new file mode 100644 index 0000000000..a808dfb619 --- /dev/null +++ b/Task/Factorial-primes/Go/factorial-primes.go @@ -0,0 +1,59 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + n, count := 0, 0 + + for count < 10 { + n++ + f := factorial(n) + + if isPrime(f.Sub(f, big.NewInt(1))) { + count++ + fmt.Printf("%2d: %2d! - 1 = %s\n", count, n, f.String()) + } + + if isPrime(f.Add(f, big.NewInt(2))) { + count++ + fmt.Printf("%2d: %2d! + 1 = %s\n", count, n, f.String()) + } + } +} + +func factorial(n int) *big.Int { + result := big.NewInt(1) + + for i := 2; i <= n; i++ { + result.Mul(result, big.NewInt(int64(i))) + } + + return result +} + +func isPrime(num *big.Int) bool { + if num.Cmp(big.NewInt(2)) < 0 { + return false + } + + if num.Cmp(big.NewInt(2)) == 0 { + return true + } + + if new(big.Int).Mod(num, big.NewInt(2)).Cmp(big.NewInt(0)) == 0 { + return false + } + + sqrt := new(big.Int).Sqrt(num) + + for i := big.NewInt(3); i.Cmp(sqrt) <= 0; i.Add(i, big.NewInt(2)) { + if new(big.Int).Mod(num, i).Cmp(big.NewInt(0)) == 0 { + return false + } + } + + return true +} diff --git a/Task/Factorial-primes/Kotlin/factorial-primes.kotlin b/Task/Factorial-primes/Kotlin/factorial-primes.kotlin new file mode 100644 index 0000000000..22db036df6 --- /dev/null +++ b/Task/Factorial-primes/Kotlin/factorial-primes.kotlin @@ -0,0 +1,43 @@ +import java.math.BigInteger +import java.math.BigInteger.ONE + +enum class Difference(private val displayText: String) { + MINUS_ONE("- 1"), PLUS_ONE("+ 1"); + + override fun toString(): String { + return displayText + } +} + +fun main() { + var currentFactorial = ONE + var highestFactor = 1L + var found = 0 + + while(found < 30) { + if ((currentFactorial - ONE).isProbablePrime(25)) { + printlnFactorialPrime(currentFactorial - ONE, highestFactor, Difference.MINUS_ONE) + found++ + } + if ((currentFactorial + ONE).isProbablePrime(25)) { + printlnFactorialPrime(currentFactorial + ONE, highestFactor, Difference.PLUS_ONE) + found++ + } + + highestFactor++ + currentFactorial *= BigInteger.valueOf(highestFactor) + } +} + +fun printlnFactorialPrime(factorialPrime: BigInteger, base: Long, difference: Difference) = + println("${base}! $difference = ${factorialPrime.shortenIfNecessary()}") + +fun BigInteger.shortenIfNecessary(): String { + val digits = toString() + val length = digits.length + return if (length <= 40) { + digits + } else { + "${digits.take(20)}...${digits.takeLast(20)} ($length digits)" + } +} diff --git a/Task/Factorial/Langur/factorial-1.langur b/Task/Factorial/Langur/factorial-1.langur index 8d8674f4b4..607783ad36 100644 --- a/Task/Factorial/Langur/factorial-1.langur +++ b/Task/Factorial/Langur/factorial-1.langur @@ -1,2 +1,2 @@ -val .factorial = fn(.n) fold(fn{*}, 2 .. .n) -writeln .factorial(7) +val factorial = fn n: fold(fn{*}, 2 .. n) +writeln factorial(7) diff --git a/Task/Factorial/Langur/factorial-2.langur b/Task/Factorial/Langur/factorial-2.langur index a40e149332..862defdc58 100644 --- a/Task/Factorial/Langur/factorial-2.langur +++ b/Task/Factorial/Langur/factorial-2.langur @@ -1,2 +1,2 @@ -val .factorial = fn(.x) if(.x < 2: 1; .x * self(.x - 1)) -writeln .factorial(7) +val factorial = fn x: if(x < 2: 1; x * fn((x - 1))) +writeln factorial(7) diff --git a/Task/Factorial/Langur/factorial-3.langur b/Task/Factorial/Langur/factorial-3.langur index a630ad30d4..69f55844e4 100644 --- a/Task/Factorial/Langur/factorial-3.langur +++ b/Task/Factorial/Langur/factorial-3.langur @@ -1,9 +1,9 @@ -val .factorial = fn(.i) { - var .answer = 1 - for .x in 2 .. .i { - .answer *= .x +val factorial = fn(i) { + var answer = 1 + for x in 2 .. i { + answer *= x } - .answer + answer } -writeln .factorial(7) +writeln factorial(7) diff --git a/Task/Factorial/Langur/factorial-4.langur b/Task/Factorial/Langur/factorial-4.langur index 482796f7ea..676ccfbd38 100644 --- a/Task/Factorial/Langur/factorial-4.langur +++ b/Task/Factorial/Langur/factorial-4.langur @@ -1,2 +1,2 @@ -val .factorial = fn(.n) for[=1] .x in .n { _for *= .x } -writeln .factorial(7) +val factorial = fn n: for[=1] x in n { _for *= x } +writeln factorial(7) diff --git a/Task/Factorial/PascalABC.NET/factorial.pas b/Task/Factorial/PascalABC.NET/factorial.pas new file mode 100644 index 0000000000..87563d6ab2 --- /dev/null +++ b/Task/Factorial/PascalABC.NET/factorial.pas @@ -0,0 +1,19 @@ +function FactIter(n: integer): BigInteger; +begin + Result := 1; + for var i:=2 to n do + Result *= i; +end; + +function FactRec(n: integer): BigInteger; +begin + if n = 0 then + Result := 1 + else Result := n * FactRec(n - 1); +end; + + +begin + for var i:=1 to 20 do + Println(i,FactRec(i),FactIter(i)); +end. diff --git a/Task/Factorial/S-BASIC/factorial-1.basic b/Task/Factorial/S-BASIC/factorial-1.basic new file mode 100644 index 0000000000..3899ac1bd1 --- /dev/null +++ b/Task/Factorial/S-BASIC/factorial-1.basic @@ -0,0 +1,13 @@ +function factorial(n=real.double)=real.double + if n = 0 then n = 1 else n = n * factorial(n-1) +end = n + +var i=integer +print "Factorial Calculator" +print " n n!" +print "----------------------" +for i=1 to 15 + print using "## #,###,###,###,###";i;factorial(i) +next i + +end diff --git a/Task/Factorial/S-BASIC/factorial-2.basic b/Task/Factorial/S-BASIC/factorial-2.basic new file mode 100644 index 0000000000..91fbb1fce5 --- /dev/null +++ b/Task/Factorial/S-BASIC/factorial-2.basic @@ -0,0 +1,7 @@ +function factorial(n=real.double)=real.double + var i, f = real.double + f = 1 + for i = 1 to n + f = f * i + next i +end = f diff --git a/Task/Factorial/Uiua/factorial.uiua b/Task/Factorial/Uiua/factorial.uiua new file mode 100644 index 0000000000..7b2a3e07ea --- /dev/null +++ b/Task/Factorial/Uiua/factorial.uiua @@ -0,0 +1 @@ +Factorial = /×+1⇡ diff --git a/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq b/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq new file mode 100644 index 0000000000..2846586599 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Jq/factors-of-a-mersenne-number.jq @@ -0,0 +1,61 @@ +# Generic filters: + +# Integer division (for gojq and jaq) +# If $j is 0, then an error condition is raised; +# otherwise, assuming infinite-precision integer arithmetic, +# if the input and $j are integers, then the result will be an integer. +def idivide($j): + (. % $j) as $mod + | (. - $mod) / $j | round; + +# Convert the input integer to a stream of 0s and 1s, least significant bit first +def bitwise: + recurse( if . >= 2 then idivide(2) else empty end) | . % 2; + +def is_prime: + . as $n + | if ($n < 2) then false + elif ($n % 2 == 0) then $n == 2 + elif ($n % 3 == 0) then $n == 3 + elif ($n % 5 == 0) then $n == 5 + elif ($n % 7 == 0) then $n == 7 + elif ($n % 11 == 0) then $n == 11 + elif ($n % 13 == 0) then $n == 13 + elif ($n % 17 == 0) then $n == 17 + elif ($n % 19 == 0) then $n == 19 + else sqrt as $s + | 23 + | until( . > $s or ($n % . == 0); . + 2) + | . > $s + end; + +### Factors of Mersene numbers + +def trialFactor($base; $exp; $mod): + [$exp | bitwise] as $bits + | ($bits|length) as $length + | reduce range( 0; $length) as $i (1; + (. * . * (if $bits[$length-$i-1] == 1 then $base else 1 end)) % $mod ) + | . == 1 ; + +def mersenneFactor($p): + ((pow(2;$p) - 1) | sqrt | floor) as $limit + | {k: 1} + | until ((2*.k*$p - 1) >= $limit or .emit; + (2*.k*$p + 1 ) as $q + | if ($q%8 == 1 or $q%8 == 7) and trialFactor(2; $p; $q) and ($q | is_prime) + then .emit = $q # q is a factor of 2^p - 1 + else .k += 1 + end) + | if .emit then .emit else null end; + +### Examples: + +def m: [3, 5, 11, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 929]; + +m[] +| mersenneFactor(.) as $f +| "2^\(.) - 1 is " + + if $f then "composite (factor \($f))" + else "prime" + end diff --git a/Task/Factors-of-an-integer/PascalABC.NET/factors-of-an-integer.pas b/Task/Factors-of-an-integer/PascalABC.NET/factors-of-an-integer.pas new file mode 100644 index 0000000000..8e3be19d51 --- /dev/null +++ b/Task/Factors-of-an-integer/PascalABC.NET/factors-of-an-integer.pas @@ -0,0 +1,16 @@ +function Factors(n: integer): List; +begin + var res := HSet(1,n); + for var i:=2 to n.Sqrt.Trunc do + if n.Divs(i) then + begin + res.Add(i); + res.Add(n div i); + end; + Result := res.Order.ToList; +end; + +begin + foreach var x in |45,53,64| do + Println(x,Factors(x)); +end. diff --git a/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal b/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal new file mode 100644 index 0000000000..86b75f81c5 --- /dev/null +++ b/Task/Factors-of-an-integer/Refal/factors-of-an-integer.refal @@ -0,0 +1,13 @@ +$ENTRY Go { + = >; +} + +Factors { + s.N = ; + (s.N s.D), >: '-' = ; + (s.N s.D), : { + (s.D) 0 = s.D; + (s.F) 0 = s.D )> s.F; + (s.X) s.Y = )>; + }; +}; diff --git a/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua b/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua new file mode 100644 index 0000000000..a36731f5c3 --- /dev/null +++ b/Task/Factors-of-an-integer/Uiua/factors-of-an-integer.uiua @@ -0,0 +1,2 @@ +Factors ← ◴⊂⟜(⇌÷)⊸(▽:⟜≡(=0◿)⊙¤⊸(↘1⇡+1⌊√)) +⍚Factors {45 53 64} diff --git a/Task/Farey-sequence/Langur/farey-sequence.langur b/Task/Farey-sequence/Langur/farey-sequence.langur index 046064cc89..2743d7c155 100644 --- a/Task/Farey-sequence/Langur/farey-sequence.langur +++ b/Task/Farey-sequence/Langur/farey-sequence.langur @@ -1,23 +1,23 @@ -val .farey = fn(.n) { - var .a, .b, .c, .d = 0, 1, 1, .n - while[=[[0, 1]]] .c <= .n { - val .k = (.n + .b) // .d - .a, .b, .c, .d = .c, .d, .k * .c - .a, .k * .d - .b - _while ~= [[.a, .b]] +val farey = fn(n) { + var a, b, c, d = 0, 1, 1, n + while[=[[0, 1]]] c <= n { + val k = (n + b) // d + a, b, c, d = c, d, k * c - a, k * d - b + _while ~= [[a, b]] } } -val .testFarey = impure fn() { +val testFarey = fn*() { writeln "Farey sequence for orders 1 through 11" - for .i of 11 { - writeln $"\.i:2;: ", join " ", map(fn(.f) $"\.f[1];/\.f[2];", .farey(.i)) + for i of 11 { + writeln "{{i:2}}: ", join(" ", map(fn f: "{{f[1]}}/{{f[2]}}", farey(i))) } } -.testFarey() +testFarey() writeln() writeln "count of Farey sequence fractions for 100 to 1000 by hundreds" -for .i = 100; .i <= 1000; .i += 100 { - writeln $"\.i:4;: ", len(.farey(.i)) +for i = 100; i <= 1000; i += 100 { + writeln "{{i:4}}: ", len(farey(i)) } diff --git a/Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation.rexx b/Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-1.rexx similarity index 100% rename from Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation.rexx rename to Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-1.rexx diff --git a/Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-2.rexx b/Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-2.rexx new file mode 100644 index 0000000000..81e8fa6e36 --- /dev/null +++ b/Task/Feigenbaum-constant-calculation/REXX/feigenbaum-constant-calculation-2.rexx @@ -0,0 +1,63 @@ +arg n; if n = '' then n = 30; numeric digits n +parse version version; say version; glob. = '' +say 'First Fiegenbaum constant, correct to about 11 decimals' +say 'Using algorithm cf RosettaCode' +say +call time('r'); a = Original(); e = format(time('e'),,3) +say 'Original ' a '('e 'seconds)' +call time('r'); a = Optimized(); e = format(time('e'),,3) +say 'Optimized ' a '('e 'seconds)' +call time('r'); a = TrueValue(); e = format(time('e'),,3) +say 'True value' a '('e 'seconds)' +exit + +Original: +procedure expose glob. +/* Outer 2 loops with a fixed value */ +numeric digits digits()+2 +im = 20; jm = 10 +a1 = 1; a2 = 0; d1 = 3.2 +do i = 2 to im + a = a1 + (a1-a2)/d1 + do j = 1 to jm + x = 0; y = 0 + do k = 1 to 2**i + y = 1 - 2*x*y; x = a - x*x + end + a = a - x/y + end + d = (a1-a2) / (a-a1) + parse value d a1 a with d1 a2 a1 +end +numeric digits digits()-2 +return d+0 + +Optimized: +procedure expose glob. +/* Center loop stops on achieving desired accuracy */ +numeric digits digits()+4; numeric fuzz 4 +/* Only outer loop maximum */ +im = 20 +a1 = 1; a2 = 0; d1 = 3.2 +do i = 2 to im + a = a1 + (a1-a2)/d1; v = 0 + do forever + x = 0; y = 0 + do 2**i + y = 1 - 2*x*y; x = a - x*x + end + a = a - x/y +/* Stop second loop when a does not change anymore */ + if a = v then + leave + v = a + end + d = (a1-a2) / (a-a1) + parse value d a1 a with d1 a2 a1 +end +numeric digits digits()-4 +return d+0 + +TrueValue: +procedure expose glob. +return 4.66920160910299067185320382046620161725818557747576863274565134300413433021131473713868974402394801381716+0 diff --git a/Task/Fermat-numbers/Langur/fermat-numbers.langur b/Task/Fermat-numbers/Langur/fermat-numbers.langur index 84749505e2..c530d67ef7 100644 --- a/Task/Fermat-numbers/Langur/fermat-numbers.langur +++ b/Task/Fermat-numbers/Langur/fermat-numbers.langur @@ -1,28 +1,29 @@ -val .fermat = fn(.i) 2 ^ 2 ^ .i + 1 +val fermat = fn i: 2 ^ 2 ^ i + 1 +val sz = '\u2080' # small zero code point -val .factors = fn(var .x) { - for[.f=[]] .i, .s = 2, trunc .x ^/ 2; .i < .s; .i += 1 { - if .x div .i { - .f ~= [.i] - .x \= .i - .s = trunc .x ^/ 2 +val factors = fn(var x) { + for[f=[]] i, s = 2, trunc(x ^/ 2); i < s; i += 1 { + if x div i { + f ~= [i] + x \= i + s = trunc(x ^/ 2) } - } ~ [.x] + } ~ [x] } writeln "first 10 Fermat numbers" -for .i in 0..9 { - writeln $"F\(.i + 16x2080:cp) = \(.fermat(.i))" +for i in 0..9 { + writeln "F{{i + sz:cp}} = {{fermat(i)}}" } writeln() writeln "factors of first few Fermat numbers" -for .i in 0..9 { - val .ferm = .fermat(.i) - val .fac = .factors(.ferm) - if len(.fac) == 1 { - writeln $"F\(.i + 16x2080:cp) is prime" +for i in 0..9 { + val ferm = fermat(i) + val fac = factors(ferm) + if len(fac) == 1 { + writeln "F{{i + sz:cp}} is prime" } else { - writeln $"F\(.i + 16x2080:cp) factors: ", .fac + writeln "F{{i + sz:cp}} factors: {{fac}}" } } diff --git a/Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic/fibonacci-n-step-number-sequences.basic b/Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic/fibonacci-n-step-number-sequences.basic new file mode 100644 index 0000000000..ec56103a56 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Chipmunk-Basic/fibonacci-n-step-number-sequences.basic @@ -0,0 +1,34 @@ +100 sub fib(a()) +110 erase f +120 dim f(24) +130 b = 0 +140 for x = 1 to ubound(a) +150 b = b+1 +160 f(x) = a(x) +170 next x +180 for i = b to 12+b +190 print using "#### ";f(i-b+1); +200 for j = (i-b+1) to i +210 f(i+1) = f(i+1)+f(j) +220 next j +230 next i +240 print +250 end sub +260 cls +270 print " fibonacci =>"; +280 dim a(2) +290 a(1) = 1 : a(2) = 1 +300 fib(a()) +310 print " tribonacci =>"; +320 dim a(3) +330 a(1) = 1 : a(2) = 1 : a(3) = 2 +340 fib(a()) +350 print " tetranacci =>"; +360 dim c(4) +370 c(1) = 1 : c(2) = 1 : c(3) = 2 : c(4) = 4 +380 fib(c()) +390 print " lucas =>"; +400 dim d(2) +410 d(1) = 2 : d(2) = 1 +420 fib(d()) +430 end diff --git a/Task/Fibonacci-n-step-number-sequences/QB64/fibonacci-n-step-number-sequences.qb64 b/Task/Fibonacci-n-step-number-sequences/QB64/fibonacci-n-step-number-sequences.qb64 new file mode 100644 index 0000000000..b435ca561c --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/QB64/fibonacci-n-step-number-sequences.qb64 @@ -0,0 +1,37 @@ +Rem $Dynamic + +Cls +Print " fibonacci =>"; +Dim a(1 To 2) As Integer +a(1) = 1 +a(2) = 1 +Call fib(a()) +Print " tribonacci =>"; +ReDim _Preserve a(1 To 3) +a(3) = 2 +Call fib(a()) +Print " tetranacci =>"; +ReDim _Preserve a(1 To 4) +a(4) = 4 +Call fib(a()) +Print " lucas =>"; +ReDim a(1 To 2) +a(1) = 2 +a(2) = 1 +Call fib(a()) +End + +Sub fib (a() As Integer) + Dim f(24) + b = 0 + For x = 1 To UBound(a) + b = b + 1 + f(x) = a(x) + Next x + For i = b To 12 + b + Print Using "#### "; f(i - b + 1); + For j = (i - b + 1) To i + f(i + 1) = f(i + 1) + f(j) + Next j + Next i +End Sub diff --git a/Task/Fibonacci-n-step-number-sequences/QBasic/fibonacci-n-step-number-sequences.basic b/Task/Fibonacci-n-step-number-sequences/QBasic/fibonacci-n-step-number-sequences.basic new file mode 100644 index 0000000000..187dffd3ca --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/QBasic/fibonacci-n-step-number-sequences.basic @@ -0,0 +1,35 @@ +DECLARE SUB fib (a() AS INTEGER) + +CLS +PRINT " fibonacci =>"; +DIM a(1 TO 2) AS INTEGER +a(1) = 1: a(2) = 1 +CALL fib(a()) +PRINT " tribonacci =>"; +DIM b(1 TO 3) AS INTEGER +b(1) = 1: b(2) = 1: b(3) = 2 +CALL fib(b()) +PRINT " tetranacci =>"; +DIM c(1 TO 4) AS INTEGER +c(1) = 1: c(2) = 1: c(3) = 2: c(4) = 4 +CALL fib(c()) +PRINT " lucas =>"; +DIM d(1 TO 2) AS INTEGER +d(1) = 2: d(2) = 1 +CALL fib(d()) +END + +SUB fib (a() AS INTEGER) + DIM f(24) + b = 0 + FOR x = 1 TO UBOUND(a) + b = b + 1 + f(x) = a(x) + NEXT x + FOR i = b TO 12 + b + PRINT USING "#### "; f(i - b + 1); + FOR j = (i - b + 1) TO i + f(i + 1) = f(i + 1) + f(j) + NEXT j + NEXT i +END SUB diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-15.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-15.hs index 7d1f929f9b..8206515707 100644 --- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-15.hs +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-15.hs @@ -1,44 +1,7 @@ -import Data.List (transpose) +import Data.List (unfoldr) -fib - :: (Integral b, Num a) - => b -> a -fib 0 = 0 -- this line is necessary because "something ^ 0" returns "fromInteger 1", which unfortunately --- in our case is not our multiplicative identity (the identity matrix) but just a 1x1 matrix of 1 -fib n = (last . head . unMat) (Mat [[1, 1], [1, 0]] ^ n) +fibs :: [Integer] +fibs = unfoldr (\(x, y) -> Just (x, (y, x + y))) (0, 1) --- Code adapted from Matrix exponentiation operator task --------------------- -(<+>) - :: Num c - => [c] -> [c] -> [c] -(<+>) = zipWith (+) - -(<*>) - :: Num a - => [a] -> [a] -> a -(<*>) = (sum .) . zipWith (*) - -newtype Mat a = Mat - { unMat :: [[a]] - } deriving (Eq) - -instance Show a => - Show (Mat a) where - show xm = "Mat " ++ show (unMat xm) - -instance Num a => - Num (Mat a) where - negate xm = Mat $ map (map negate) $ unMat xm - xm + ym = Mat $ zipWith (<+>) (unMat xm) (unMat ym) - xm * ym = - Mat - [ [ xs Main.<*> ys -- to distinguish from standard applicative operator - | ys <- transpose $ unMat ym ] - | xs <- unMat xm ] - fromInteger n = Mat [[fromInteger n]] - abs = undefined - signum = undefined - --- TEST ---------------------------------------------------------------------- -main :: IO () -main = (print . take 10 . show . fib) (10 ^ 5) +fib n :: Integer -> Integer +fib n = fibs !! n diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-16.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-16.hs index 593d8551aa..7d1f929f9b 100644 --- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-16.hs +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-16.hs @@ -1,35 +1,44 @@ -import Control.Arrow ((&&&)) +import Data.List (transpose) -fibstep :: (Integer, Integer) -> (Integer, Integer) -fibstep (a, b) = (b, a + b) +fib + :: (Integral b, Num a) + => b -> a +fib 0 = 0 -- this line is necessary because "something ^ 0" returns "fromInteger 1", which unfortunately +-- in our case is not our multiplicative identity (the identity matrix) but just a 1x1 matrix of 1 +fib n = (last . head . unMat) (Mat [[1, 1], [1, 0]] ^ n) -fibnums :: [Integer] -fibnums = map fst $ iterate fibstep (0, 1) +-- Code adapted from Matrix exponentiation operator task --------------------- +(<+>) + :: Num c + => [c] -> [c] -> [c] +(<+>) = zipWith (+) -fibN2 :: Integer -> (Integer, Integer) -fibN2 m - | m < 10 = iterate fibstep (0, 1) !! fromIntegral m -fibN2 m = fibN2_next (n, r) (fibN2 n) - where - (n, r) = quotRem m 3 +(<*>) + :: Num a + => [a] -> [a] -> a +(<*>) = (sum .) . zipWith (*) -fibN2_next (n, r) (f, g) - | r == 0 = (a, b) -- 3n ,3n+1 - | r == 1 = (b, c) -- 3n+1,3n+2 - | r == 2 = (c, d) -- 3n+2,3n+3 (*) - where - a = - 5 * f ^ 3 + - if even n - then 3 * f - else (-3 * f) -- 3n - b = g ^ 3 + 3 * g * f ^ 2 - f ^ 3 -- 3n+1 - c = g ^ 3 + 3 * g ^ 2 * f + f ^ 3 -- 3n+2 - d = - 5 * g ^ 3 + - if even n - then (-3 * g) - else 3 * g -- 3(n+1) (*) +newtype Mat a = Mat + { unMat :: [[a]] + } deriving (Eq) +instance Show a => + Show (Mat a) where + show xm = "Mat " ++ show (unMat xm) + +instance Num a => + Num (Mat a) where + negate xm = Mat $ map (map negate) $ unMat xm + xm + ym = Mat $ zipWith (<+>) (unMat xm) (unMat ym) + xm * ym = + Mat + [ [ xs Main.<*> ys -- to distinguish from standard applicative operator + | ys <- transpose $ unMat ym ] + | xs <- unMat xm ] + fromInteger n = Mat [[fromInteger n]] + abs = undefined + signum = undefined + +-- TEST ---------------------------------------------------------------------- main :: IO () -main = print $ (length &&& take 20) . show . fst $ fibN2 (10 ^ 2) +main = (print . take 10 . show . fib) (10 ^ 5) diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs index c69d736bc9..593d8551aa 100644 --- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs @@ -1,2 +1,35 @@ - *Main> (length &&& take 20) . show . fst $ fibN2 (10^6) -(208988,"19532821287077577316") +import Control.Arrow ((&&&)) + +fibstep :: (Integer, Integer) -> (Integer, Integer) +fibstep (a, b) = (b, a + b) + +fibnums :: [Integer] +fibnums = map fst $ iterate fibstep (0, 1) + +fibN2 :: Integer -> (Integer, Integer) +fibN2 m + | m < 10 = iterate fibstep (0, 1) !! fromIntegral m +fibN2 m = fibN2_next (n, r) (fibN2 n) + where + (n, r) = quotRem m 3 + +fibN2_next (n, r) (f, g) + | r == 0 = (a, b) -- 3n ,3n+1 + | r == 1 = (b, c) -- 3n+1,3n+2 + | r == 2 = (c, d) -- 3n+2,3n+3 (*) + where + a = + 5 * f ^ 3 + + if even n + then 3 * f + else (-3 * f) -- 3n + b = g ^ 3 + 3 * g * f ^ 2 - f ^ 3 -- 3n+1 + c = g ^ 3 + 3 * g ^ 2 * f + f ^ 3 -- 3n+2 + d = + 5 * g ^ 3 + + if even n + then (-3 * g) + else 3 * g -- 3(n+1) (*) + +main :: IO () +main = print $ (length &&& take 20) . show . fst $ fibN2 (10 ^ 2) diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs index 7f0a39dbc2..c69d736bc9 100644 --- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs @@ -1 +1,2 @@ -f (n,(a,b)) = (2*n,(a*a+b*b,2*a*b+b*b)) -- iterate f (1,(0,1)) ; b is nth + *Main> (length &&& take 20) . show . fst $ fibN2 (10^6) +(208988,"19532821287077577316") diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs index dd052ec7a3..7f0a39dbc2 100644 --- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs @@ -1 +1 @@ -g (n,(a,b)) = (2*n,(2*a*b-a*a,a*a+b*b)) -- iterate g (1,(1,1)) ; a is nth +f (n,(a,b)) = (2*n,(a*a+b*b,2*a*b+b*b)) -- iterate f (1,(0,1)) ; b is nth diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs new file mode 100644 index 0000000000..dd052ec7a3 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs @@ -0,0 +1 @@ +g (n,(a,b)) = (2*n,(2*a*b-a*a,a*a+b*b)) -- iterate g (1,(1,1)) ; a is nth diff --git a/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur b/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur index fa8ff6700e..1eaa61b5f6 100644 --- a/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur +++ b/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur @@ -1,3 +1,3 @@ -val .fibonacci = fn(.x) if(.x < 2: .x ; self(.x - 1) + self(.x - 2)) +val fibonacci = fn x:if(x < 2: x ; fn((x - 1)) + fn((x - 2))) -writeln map .fibonacci, series 2..20 +writeln map(fibonacci, series(2..20)) diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-14.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-14.parigp index 5af4b4f310..94a6418871 100644 --- a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-14.parigp +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-14.parigp @@ -1 +1 @@ -fib(n)=n--;polchebyshev(n,2,I/2)*I^n; +fib(n)=real(2/sqrt(5)/I^n*sinh(n*log(I*(1+sqrt(5))/2)))\/1; diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-15.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-15.parigp index 8620df4d05..5af4b4f310 100644 --- a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-15.parigp +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-15.parigp @@ -1 +1 @@ -fib(n)=abs(polchebyshev(n-1,2,I/2)); +fib(n)=n--;polchebyshev(n,2,I/2)*I^n; diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-16.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-16.parigp index 49a2f5b231..8620df4d05 100644 --- a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-16.parigp +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-16.parigp @@ -1,7 +1 @@ -matantihadamard(n)={ - matrix(n,n,i,j, - my(t=j-i+1); - if(t<1,t%2,t<3) - ); -} -fib(n)=matdet(matantihadamard(n)) +fib(n)=abs(polchebyshev(n-1,2,I/2)); diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-17.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-17.parigp index 78ccd47534..49a2f5b231 100644 --- a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-17.parigp +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-17.parigp @@ -1,7 +1,7 @@ -fib(n)= -{ - my(g=2^(n+1)-1); - sum(i=2^(n-1),2^n-1, - bitor(i,i<<1)==g +matantihadamard(n)={ + matrix(n,n,i,j, + my(t=j-i+1); + if(t<1,t%2,t<3) ); } +fib(n)=matdet(matantihadamard(n)) diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-18.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-18.parigp index 2f2e9ab577..78ccd47534 100644 --- a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-18.parigp +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-18.parigp @@ -1 +1,7 @@ -fib(n)=my(k=0);while(n--,k++;while(!issquare(5*k^2+4)&&!issquare(5*k^2-4),k++));k +fib(n)= +{ + my(g=2^(n+1)-1); + sum(i=2^(n-1),2^n-1, + bitor(i,i<<1)==g + ); +} diff --git a/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-19.parigp b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-19.parigp new file mode 100644 index 0000000000..2f2e9ab577 --- /dev/null +++ b/Task/Fibonacci-sequence/PARI-GP/fibonacci-sequence-19.parigp @@ -0,0 +1 @@ +fib(n)=my(k=0);while(n--,k++;while(!issquare(5*k^2+4)&&!issquare(5*k^2-4),k++));k diff --git a/Task/Fibonacci-sequence/PL-0/fibonacci-sequence.pl0 b/Task/Fibonacci-sequence/PL-0/fibonacci-sequence.pl0 index ef184c2558..c65591c33a 100644 --- a/Task/Fibonacci-sequence/PL-0/fibonacci-sequence.pl0 +++ b/Task/Fibonacci-sequence/PL-0/fibonacci-sequence.pl0 @@ -8,5 +8,5 @@ begin tmp := b; b := a + b; a := tmp; i := i + 1 end; - ! b; + ! b end. diff --git a/Task/File-input-output/FutureBasic/file-input-output.basic b/Task/File-input-output/FutureBasic/file-input-output.basic index ecd46eda24..6fc45a678d 100644 --- a/Task/File-input-output/FutureBasic/file-input-output.basic +++ b/Task/File-input-output/FutureBasic/file-input-output.basic @@ -1,39 +1,57 @@ /* Rosetta Code File input/output example -FutureBasic 7.0.14 +FutureBasic 7.0.24 Rich Love -9/25/22 - -Before running this, use TextEdit to create a file called input.txt on your desktop. -Format as plain text and create a few lines of text. -Then save. +5/11/24 */ output file "FileInputOutput.app" + +void Local fn doIt CFURLRef ParentDirectory // Create a url for the desktop ParentDirectory = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask ) -CFURLRef inputURL // Create a url for input.txt on the desktop -inputURL = fn URLByAppendingPathComponent( ParentDirectory, @"input.txt" ) - CFURLRef outputURL // Create a url for output.txt on the desktop outputURL = fn URLByAppendingPathComponent( ParentDirectory, @"output.txt" ) -open "O", 1, outputURL -open "I", 2, inputURL + +CFURLRef inputURL = openpanel( 1, @"Open a text file",@"txt") +if inputURL = NULL then end str255 dataLine +dataLine = "" +if fn FileManagerContentsAtURL(inputURL) <> NULL +open "I", 1, inputURL +open "O", 2, outputURL -While Not Eof(2) - Line Input #2, dataLine - Print #1, dataLine +While Not Eof(1) +Line Input #1, dataLine +Print #2, dataLine Wend - -Close #1 Close #2 - +Close #1 +alert 3,,@"File created on Desktop",@"output.txt",@"OK" end +else +alert 3,,@"File Not Found on Desktop",@"input.txt",@"OK" +end +end if + +end fn + +void local fn DoAppEvent( ev as long ) +select (ev) +case _appDidFinishLaunching +fn doIt +end select +end fn + + +on AppEvent fn DoAppEvent + + +handleevents diff --git a/Task/File-input-output/PascalABC.NET/file-input-output.pas b/Task/File-input-output/PascalABC.NET/file-input-output.pas new file mode 100644 index 0000000000..d29ad1ed55 --- /dev/null +++ b/Task/File-input-output/PascalABC.NET/file-input-output.pas @@ -0,0 +1,4 @@ +begin + var s := ReadAllText('input.txt'); + WriteAllText('output.txt',s); +end. diff --git a/Task/File-size-distribution/Jq/file-size-distribution.jq b/Task/File-size-distribution/Jq/file-size-distribution.jq new file mode 100644 index 0000000000..efa5ac0150 --- /dev/null +++ b/Task/File-size-distribution/Jq/file-size-distribution.jq @@ -0,0 +1,15 @@ +# bag of words +def bow(stream): + reduce stream as $word ({}; .[($word|tostring)] += 1); + +# `stream` is expected to be a stream of non-negative numbers or numeric strings. +# The output is a stream of [bucket, count] pairs, sorted by the value of `bucket`. +# No sorting except for the sorting of these bucket boundaries takes place. +def histogram(stream): + bow(stream) + | to_entries + | map( [(.key | tonumber), .value] ) + | sort_by(.[0]) + | .[]; + +histogram(.[] | .size | if . == 0 then 0 else 1 + (log10 | trunc) end) diff --git a/Task/File-size/PascalABC.NET/file-size.pas b/Task/File-size/PascalABC.NET/file-size.pas new file mode 100644 index 0000000000..f4a99b6adb --- /dev/null +++ b/Task/File-size/PascalABC.NET/file-size.pas @@ -0,0 +1,6 @@ +uses System.IO; + +begin + FileInfo.Create('input.txt').Length.Println; + FileInfo.Create('/input.txt').Length.Println; +end. diff --git a/Task/Filter/Langur/filter.langur b/Task/Filter/Langur/filter.langur index ab9e005e2b..330dbc2ec2 100644 --- a/Task/Filter/Langur/filter.langur +++ b/Task/Filter/Langur/filter.langur @@ -1,4 +1,4 @@ -val .list = series 7 +val zlist = series(7) -writeln " list: ", .list -writeln "filtered: ", filter fn{div 2}, .list +writeln " list: ", zlist +writeln "filtered: ", filter(fn{div 2}, zlist) diff --git a/Task/Filter/PascalABC.NET/filter.pas b/Task/Filter/PascalABC.NET/filter.pas new file mode 100644 index 0000000000..3af872fd92 --- /dev/null +++ b/Task/Filter/PascalABC.NET/filter.pas @@ -0,0 +1,5 @@ +begin + var a := Arr(1..10); + var even := a.Where(x -> x mod 2 = 0); + even.Print +end. diff --git a/Task/Find-Chess960-starting-position-identifier/Jq/find-chess960-starting-position-identifier.jq b/Task/Find-Chess960-starting-position-identifier/Jq/find-chess960-starting-position-identifier.jq new file mode 100644 index 0000000000..d0b15801d3 --- /dev/null +++ b/Task/Find-Chess960-starting-position-identifier/Jq/find-chess960-starting-position-identifier.jq @@ -0,0 +1,82 @@ +### Generic functions + +# Output: a stream of the characters (glyphs) of the input string +def chars: split("")[]; + +def count(s): reduce s as $x (0; .+1); + +# Variant of index/1 +def index($target; $offset): + if $offset >= length then null + else (.[$offset:]|index($target)) as $ix + | if $ix then $ix + $offset + else null + end + end; + +### Chess: + +def glyphs: "♜♞♝♛♚♖♘♗♕♔"; + +def letters: "RNBQKRNBQK"; + +def names: { "R": "rook", "N": "knight", "B": "bishop", "Q": "queen", "K": "king" }; + +# a map of glyphs to letters +def g2lMap: + [glyphs,letters] + | map(split("")) + | transpose + | map( {(.[0]): .[1]}) + | add; + +# convert glyphs to letters +# Input: pieces (a string) +# Output: a string +def g2l: + g2lMap as $g2lMap + | reduce chars as $p (""; . + $g2lMap[$p] ); + +def ntable: + { "01":0, "02":1, "03":2, "04":3, "12":4, "13":5, "14":6, "23":7, "24":8, "34":9 }; + +# Input: pieces, a string +def spid: + # convert glyphs to letters + g2l as $pieces + # check for errors + | last( + if $pieces|length != 8 then "There must be exactly 8 pieces." | error end, + ("KQ"|split("")[] as $one + | if 1 != count( $pieces|chars | select(. == $one)) then "There must be one \(names[$one])" | error end), + ("RNB" | split("")[] as $two + | if 2 != count( $pieces|chars | select(. == $two)) then "There must be two \(names[$two])" | error end)) + | ($pieces | index("R")) as $r1 + | ($pieces | index("R"; $r1 + 1)) as $r2 + | ($pieces|index("K")) as $k + | if ($k < $r1 or $k > $r2) then "The king must be between the rooks." | error end + | ($pieces|index("B")) as $b1 + | ($pieces|index("B"; $b1 + 1)) as $b2 + | if (($b2 - $b1) % 2 == 0) then "The bishops must be on opposite color squares." | error end + + # compute SP_ID + | ($pieces|sub("Q"; "")|gsub("B"; "")) as $piecesN + | ($piecesN|index("N")) as $n1 + | ($piecesN|index("N"; $n1+1)) as $n2 + + | ntable["\($n1)\($n2)"] as $N + + | ($pieces|gsub("B"; "")) as $piecesQ + | ($piecesQ|index("Q")) as $Q + | ("0246" | index($b1|tostring)) as $D + | if $D == null + then {D: ("0246"|index($b2|tostring)), + L: ("1357"|index($b1|tostring)) } + else {D: $D, + L: ("1357"|index($b2|tostring))} + end + | 96*$N + 16*$Q + 4*.D + .L ; + +# The task +"♕♘♖♗♗♘♔♖", "♖♘♗♕♔♗♘♖", "♜♛♞♝♝♚♜♞", "♜♞♛♝♝♚♜♞" +| "\(.) or \(g2l) has SP-ID of \(spid)" diff --git a/Task/Find-common-directory-path/K/find-common-directory-path.k b/Task/Find-common-directory-path/K/find-common-directory-path.k new file mode 100644 index 0000000000..6b7ec47690 --- /dev/null +++ b/Task/Find-common-directory-path/K/find-common-directory-path.k @@ -0,0 +1,6 @@ +fcp:{"/"/(+/*\1=#'?'+y\'x)#("/"\ x@0)} + +/example usage + l:("/home/user1/tmp/coverage/test"; "/home/user1/tmp/covert/operator"; "/home/user1/tmp/coven/members") + fcp[l;"/"] +"/home/user1/tmp" diff --git a/Task/Find-common-directory-path/PascalABC.NET/find-common-directory-path.pas b/Task/Find-common-directory-path/PascalABC.NET/find-common-directory-path.pas new file mode 100644 index 0000000000..7bdbcc5ad1 --- /dev/null +++ b/Task/Find-common-directory-path/PascalABC.NET/find-common-directory-path.pas @@ -0,0 +1,21 @@ +function CommonPrefix(arrs: array of array of string): array of string; +begin + var min: integer := arrs.Min(a -> a.Length); + // транспонируем эту часть + var at := ArrGen(min, j -> ArrGen(arrs.Length, i -> arrs[i][j])); + Result := at.TakeWhile(x -> x.Skip(1).All(y -> y = x.First)).Select(a -> a[0]).ToArray +end; + +function CommonDirectoryPath(paths: array of string; sep: char := '/'): string; +begin + var arrs := paths.Select(a -> a.Split(sep)).ToArray; + Result := CommonPrefix(arrs).JoinToString(sep); +end; + +begin + //CommonPrefix(||'ww','ee'|,|'ww','ee','hh'|,|'ww','ee','tt'||).Print + print(CommonDirectoryPath(| + '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', + '/home/user1/tmp/coven/members'|)) +end. diff --git a/Task/Find-duplicate-files/Jq/find-duplicate-files.jq b/Task/Find-duplicate-files/Jq/find-duplicate-files.jq new file mode 100644 index 0000000000..cccd6d21d4 --- /dev/null +++ b/Task/Find-duplicate-files/Jq/find-duplicate-files.jq @@ -0,0 +1,9 @@ +# The following jq program assumes the input consists of a JSON array of objects having +# keys named "hash" and "filename". +def dictionary(stream; f; g): + reduce stream as $x ({}; .[($x|f)] += [$x|g]); + +dictionary(inputs[]; .hash; .filename) +| to_entries[].value +| select(length > 1) +| [.[]] diff --git a/Task/Find-if-a-point-is-within-a-triangle/11l/find-if-a-point-is-within-a-triangle.11l b/Task/Find-if-a-point-is-within-a-triangle/11l/find-if-a-point-is-within-a-triangle.11l index 307688a44b..1259c17d99 100644 --- a/Task/Find-if-a-point-is-within-a-triangle/11l/find-if-a-point-is-within-a-triangle.11l +++ b/Task/Find-if-a-point-is-within-a-triangle/11l/find-if-a-point-is-within-a-triangle.11l @@ -14,14 +14,7 @@ F distanceSquarePointToSegment(p1, p2, p) R pP1SquareLength - dotProduct * dotProduct * p1P2SquareLength R sqlen(p - p2) -T Triangle - (Float, Float) p1, p2, p3 - - F (p1, p2, p3) - .p1 = p1 - .p2 = p2 - .p3 = p3 - +T Triangle((DVec2 p1, DVec2 p2, DVec2 p3)) F String() R ‘Triangle[’(.p1)‘, ’(.p2)‘, ’(.p3)‘]’ diff --git a/Task/Find-limit-of-recursion/PascalABC.NET/find-limit-of-recursion.pas b/Task/Find-limit-of-recursion/PascalABC.NET/find-limit-of-recursion.pas new file mode 100644 index 0000000000..a6e57f4e83 --- /dev/null +++ b/Task/Find-limit-of-recursion/PascalABC.NET/find-limit-of-recursion.pas @@ -0,0 +1,9 @@ +procedure Recur(i: integer); +begin + System.Console.WriteLine(i); + Recur(i + 1); +end; + +begin + Recur(0); +end. diff --git a/Task/Find-the-intersection-of-two-lines/ALGOL-W/find-the-intersection-of-two-lines.alg b/Task/Find-the-intersection-of-two-lines/ALGOL-W/find-the-intersection-of-two-lines.alg new file mode 100644 index 0000000000..db5ca3d348 --- /dev/null +++ b/Task/Find-the-intersection-of-two-lines/ALGOL-W/find-the-intersection-of-two-lines.alg @@ -0,0 +1,33 @@ +begin % find the intersection of two lines % + + record Point ( real x, y ); + record Line ( real m, c ); % y = mx + c % + + % returns the line that passes through p1 and p2 % + reference(Line) procedure findLine ( reference(Point) value p1, p2 ) ; + if x(p1) = x(p2) then begin % the line is verticval % + Line( 0, x(p1) ) + end + else begin % the line is not vertical % + real m1; + m1 := ( y(p1) - y(p2) ) / ( x(p1) - x(p2) ); + Line( m1, y(p1) - ( m1 * x(p1) ) ) + end findLine ; + + % returns the intersection of two lines % + % - the lines must be distinct and not parallel % + reference(Point) procedure intersection ( reference(Line) value l1, l2 ) ; + begin + real x; + x := ( c(l2) - c(l1) ) / ( m(l1) - m(l2) ); + Point( x, ( m(l1) * x ) + c(l1) ) + end intersection ; + + begin % find the intersection of the lines as per the task % + reference(Point) i; + i := intersection( findLine( Point( 4.0, 0.0 ), Point( 6.0, 10.0 ) ) + , findLine( Point( 0.0, 3.0 ), Point( 10.0, 7.0 ) ) + ); + write( r_format := "A", r_w := 8, r_d := 4, x(i), y(i) ) + end +end. diff --git a/Task/Find-the-intersection-of-two-lines/Python/find-the-intersection-of-two-lines-4.py b/Task/Find-the-intersection-of-two-lines/Python/find-the-intersection-of-two-lines-4.py new file mode 100644 index 0000000000..ca6053b96f --- /dev/null +++ b/Task/Find-the-intersection-of-two-lines/Python/find-the-intersection-of-two-lines-4.py @@ -0,0 +1,19 @@ +import pygame as pg + +def segment_intersection(a, b, c, d): + """ returns a pygame.Vector2 or None if there is no intersection """ + ab, cd, ac = a - b, c - d, a - c + if not (denom:= ab.x * cd.y - ab.y * cd.x): + return + + t = (ac.x * cd.y - ac.y * cd.x) / denom + u = -(ab.x * ac.y - ab.y * ac.x) / denom + if 0 <= t <= 1 and 0 <= u <= 1: + return a.lerp(b, t) + + +if __name__ == '__main__': + a,b = pg.Vector2(4,0), pg.Vector2(6,10) # try (4, 0), (6, 4) + c,d = pg.Vector2(0,3), pg.Vector2(10,7) # for non intersecting test + pt = segment_intersection(a, b, c, d) + print(pt) diff --git a/Task/Find-the-missing-permutation/Uiua/find-the-missing-permutation.uiua b/Task/Find-the-missing-permutation/Uiua/find-the-missing-permutation.uiua new file mode 100644 index 0000000000..166b1bdb66 --- /dev/null +++ b/Task/Find-the-missing-permutation/Uiua/find-the-missing-permutation.uiua @@ -0,0 +1,2 @@ +Perms ← ⊜∘⊸≠@ "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB" +/⊂≡(▽-⟜/↥:⊕⊃⊢⧻⊛.)⍉ Perms diff --git a/Task/First-class-functions/PascalABC.NET/first-class-functions.pas b/Task/First-class-functions/PascalABC.NET/first-class-functions.pas new file mode 100644 index 0000000000..091decbbb2 --- /dev/null +++ b/Task/First-class-functions/PascalABC.NET/first-class-functions.pas @@ -0,0 +1,15 @@ +function Cube(x: real) := x**3; +function CubeRoot(x: real) := x**(1/3); + +function Composition(f1,f2: T -> T): T -> T := x -> f1(f2(x)); + +begin + var A := Arr(Sin,Cos,Cube); + var B := Arr(ArcSin,ArcCos,CubeRoot); + for var i:=0 to A.Length-1 do + Println(Composition(A[i],B[i])(0.5)); + + // Build-in composition f1 * f2 + foreach var (f1,f2) in A.Zip(B) do + Println((f1 * f2)(0.5)); +end. diff --git a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua index f1237f1504..d4f0b612f4 100644 --- a/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua +++ b/Task/First-perfect-square-in-base-n-with-n-unique-digits/Uiua/first-perfect-square-in-base-n-with-n-unique-digits.uiua @@ -1,15 +1,14 @@ -BaseN ← setinv(↘2⍢(⊂⊂:⊙(⊃(↙1)(↘2))⊂⊃(⌊÷)◿°⊟↙2.)(>0 ⊢↘1)⊟|/+×ⁿ:⊙(⇌⇡⧻.)) -IsPan ← =⧻◴: # IsPan 3 [0 1 2] -# Smallest pan number for given base -# = [1 0 2 3 4...] in base n -MinPanBase ← °BaseN ⟜(↙:⊂[1 0]↘2⇡+1.) -MinPanSqrBase ← ⊙◌⍢(+1)(¬IsPan :BaseN ,×.) ⌊√MinPanBase. -ShowMinPan ← ( - ≡( - &pf "\t" &pf . &pf "Base " - MinPanSqrBase . - &p BaseN : &pf "\t" &pf. × &pf "\t" &pf. . - ) -) +Base₁₀ ← /+×ⁿ:⊙(⇌⇡⧻.) # (b, [digits]) -> n +BaseN ← ⊙◌⊂⍢(⊙⊂⌊⊃÷◿⊃⋅⋅∘⊙⊙∘|≤⊙⋅∘)⊙[]: # (b, n) -> [digits] -⍜now (ShowMinPan ↘2⇡13) +IsPan ← =⧻◴: # IsPan 3 [0 1 2] -> true +# Smallest pan number for given base +# will always be = [1 0 2 3 4...] in base n +MinPanBase ← Base₁₀ ⟜(↙:⊂1_0↘2⇡+1.) +# Take sqrt of the smallest pan number and inc until found. +MinPanSqrBase ← ⊙◌⍢(+1|¬IsPan:BaseN,×.) ⌊√MinPanBase. +ShowMinPan ← ( + ⊃(⊙∘|⋅(×.)|BaseN ⊙(×.)) ⟜MinPanSqrBase + &p $"Base _\t_\t_\t_\t" +) +⍜now (≡ShowMinPan ↘2⇡13) diff --git a/Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp b/Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp index 2afcb58497..be01ddcb5d 100644 --- a/Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp +++ b/Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp @@ -1,20 +1,15 @@ -;; Project : FizzBuzz +(defun range (min max) + (loop + :for x :from min :to max + :collect x)) -(defun fizzbuzz (&optional n) - (let ((n (or n 1))) - (if (> n 100) - nil - (progn - (let ((mult-3 (is-mult-p n 3)) - (mult-5 (is-mult-p n 5))) - (if mult-3 - (princ "Fizz")) - (if mult-5 - (princ "Buzz")) - (if (not (or mult-3 mult-5)) - (princ n)) - (princ #\linefeed) - (fizzbuzz (+ n 1))))))) -(defun is-mult-p (n multiple) - (= (rem n multiple) 0)) -(fizzbuzz 1) +(defun fizzbuzz () + (map 'nil #'(lambda (n) + (princ + (cond + ((zerop (mod n 15)) "FizzBuzz!") + ((zerop (mod n 5)) "Buzz!") + ((zerop (mod n 3)) "Fizz!") + (t n)) + (terpri))) + (range 1 100))) diff --git a/Task/FizzBuzz/Common-Lisp/fizzbuzz-9.lisp b/Task/FizzBuzz/Common-Lisp/fizzbuzz-9.lisp new file mode 100644 index 0000000000..2afcb58497 --- /dev/null +++ b/Task/FizzBuzz/Common-Lisp/fizzbuzz-9.lisp @@ -0,0 +1,20 @@ +;; Project : FizzBuzz + +(defun fizzbuzz (&optional n) + (let ((n (or n 1))) + (if (> n 100) + nil + (progn + (let ((mult-3 (is-mult-p n 3)) + (mult-5 (is-mult-p n 5))) + (if mult-3 + (princ "Fizz")) + (if mult-5 + (princ "Buzz")) + (if (not (or mult-3 mult-5)) + (princ n)) + (princ #\linefeed) + (fizzbuzz (+ n 1))))))) +(defun is-mult-p (n multiple) + (= (rem n multiple) 0)) +(fizzbuzz 1) diff --git a/Task/FizzBuzz/Langur/fizzbuzz-1.langur b/Task/FizzBuzz/Langur/fizzbuzz-1.langur deleted file mode 100644 index d5e5445c4f..0000000000 --- a/Task/FizzBuzz/Langur/fizzbuzz-1.langur +++ /dev/null @@ -1,3 +0,0 @@ -for .i of 100 { - writeln switch(0; .i rem 15: "FizzBuzz"; .i rem 5: "Buzz"; .i rem 3: "Fizz"; .i) -} diff --git a/Task/FizzBuzz/Langur/fizzbuzz-2.langur b/Task/FizzBuzz/Langur/fizzbuzz-2.langur deleted file mode 100644 index 462cdfb81b..0000000000 --- a/Task/FizzBuzz/Langur/fizzbuzz-2.langur +++ /dev/null @@ -1,3 +0,0 @@ -for .i of 100 { - writeln if(.i div 15: "FizzBuzz"; .i div 5: "Buzz"; .i div 3: "Fizz"; .i) -} diff --git a/Task/FizzBuzz/Langur/fizzbuzz.langur b/Task/FizzBuzz/Langur/fizzbuzz.langur new file mode 100644 index 0000000000..d932f4e024 --- /dev/null +++ b/Task/FizzBuzz/Langur/fizzbuzz.langur @@ -0,0 +1,3 @@ +for i of 100 { + writeln switch(0; i rem 15: "FizzBuzz"; i rem 5: "Buzz"; i rem 3: "Fizz"; i) +} diff --git a/Task/FizzBuzz/PascalABC.NET/fizzbuzz.pas b/Task/FizzBuzz/PascalABC.NET/fizzbuzz.pas new file mode 100644 index 0000000000..88b4afba1d --- /dev/null +++ b/Task/FizzBuzz/PascalABC.NET/fizzbuzz.pas @@ -0,0 +1,10 @@ +begin + for var i:=1 to 100 do + if i mod 15 = 0 then + Print('FizzBuzz') + else if i mod 3 = 0 then + Print('Fizz') + else if i mod 5 = 0 then + Print('Buzz') + else Print(i) +end. diff --git a/Task/FizzBuzz/Q/fizzbuzz-1.q b/Task/FizzBuzz/Q/fizzbuzz-1.q index ddc5895375..5f657a4e59 100644 --- a/Task/FizzBuzz/Q/fizzbuzz-1.q +++ b/Task/FizzBuzz/Q/fizzbuzz-1.q @@ -1 +1 @@ -{(2 sv not x mod/:5 3)'[;`fizz;`buzz;`fizzbuzz]`$string x} +{(`$string x)^`fizzbuzz`buzz`fizz`(x mod\:15 5 3)?'0} diff --git a/Task/FizzBuzz/Q/fizzbuzz-2.q b/Task/FizzBuzz/Q/fizzbuzz-2.q index 0dc95fabd9..66d6c2f2af 100644 --- a/Task/FizzBuzz/Q/fizzbuzz-2.q +++ b/Task/FizzBuzz/Q/fizzbuzz-2.q @@ -1,4 +1,4 @@ q)/ Fizzbuzz -q)fb:{(2 sv not x mod/:5 3)'[;`fizz;`buzz;`fizzbuzz]`$string x} +q)fb:{(`$string x)^`fizzbuzz`buzz`fizz`(x mod\:15 5 3)?'0} q)fb 1+til 20 `1`2`fizz`4`buzz`fizz`7`8`fizz`buzz`11`fizz`13`14`fizzbuzz`16`17`fizz`19`buzz diff --git a/Task/FizzBuzz/Q/fizzbuzz-3.q b/Task/FizzBuzz/Q/fizzbuzz-3.q index 091461983f..e9e1c43a46 100644 --- a/Task/FizzBuzz/Q/fizzbuzz-3.q +++ b/Task/FizzBuzz/Q/fizzbuzz-3.q @@ -1,17 +1,18 @@ q)show x:1+til 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -q)x mod/:5 3 -1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 -1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 -q)not x mod/:5 3 -00001000010000100001b -00100100100100100100b -q)show i:2 sv not x mod/:5 3 / binary decode -0 0 1 0 2 1 0 0 1 2 0 1 0 0 3 0 0 1 0 2 -q)(`$string x;`fizz;`buzz;`fizzbuzz) +q)x mod\:15 5 3 +1 1 1 +2 2 2 +3 3 0 +4 4 1 +5 0 2 +6 1 0 +.. +q)(x mod\:15 5 3)?'0 +3 3 2 3 1 2 3 3 2 1 3 2 3 3 0 3 3 2 3 1 +q)`fizzbuzz`buzz`fizz`(x mod\:15 5 3)?'0 / substitutions +```fizz``buzz`fizz```fizz`buzz``fizz```fizzbuzz```fizz``buzz +q)`$string x / numbers => symbols `1`2`3`4`5`6`7`8`9`10`11`12`13`14`15`16`17`18`19`20 -`fizz -`buzz -`fizzbuzz -q)i'[`$string x;`fizz;`buzz;`fizzbuzz] / Case iterator +q)(`$string x)^`fizzbuzz`buzz`fizz`(x mod\:15 5 3)?'0 / replace nulls with numbers `1`2`fizz`4`buzz`fizz`7`8`fizz`buzz`11`fizz`13`14`fizzbuzz`16`17`fizz`19`buzz diff --git a/Task/FizzBuzz/Uiua/fizzbuzz.uiua b/Task/FizzBuzz/Uiua/fizzbuzz.uiua index cfe142f2d5..c870fe1baa 100644 --- a/Task/FizzBuzz/Uiua/fizzbuzz.uiua +++ b/Task/FizzBuzz/Uiua/fizzbuzz.uiua @@ -1 +1 @@ -⟨⟨⟨&p|&p"Fizz"◌⟩=0◿3.|&p"Buzz"◌⟩=0◿5.|&p"Fizzbuzz"◌⟩=0◿15.+1⇡100 +⟨&p|&p"Fizz"|&p"Buzz"|&p"Fizzbuzz"⟩°⋯⍉=0⊞◿3_5.+1⇡100 diff --git a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-1.l similarity index 100% rename from Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l rename to Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-1.l diff --git a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.l b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.l new file mode 100644 index 0000000000..939c2dd810 --- /dev/null +++ b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list-2.l @@ -0,0 +1 @@ +(flatten-tree mylist) diff --git a/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas b/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas new file mode 100644 index 0000000000..4c3aff9618 --- /dev/null +++ b/Task/Flatten-a-list/PascalABC.NET/flatten-a-list.pas @@ -0,0 +1,16 @@ +function Flatten(lst: List): List; +begin + Result := new List; + foreach var x in lst do + if x is List then + Result.Addrange(Flatten(x as List)) + else Result.Add(x) +end; + +function LstObj(params a: array of object): List := new List(a); + +begin + var lst := LstObj(1,LstObj(2, LstObj(3,4), LstObj(5,6)), LstObj(LstObj(7,8), 9)); + Println(lst); + Println(Flatten(lst)); +end. diff --git a/Task/Flatten-a-list/Refal/flatten-a-list.refal b/Task/Flatten-a-list/Refal/flatten-a-list.refal new file mode 100644 index 0000000000..b60af64c4b --- /dev/null +++ b/Task/Flatten-a-list/Refal/flatten-a-list.refal @@ -0,0 +1,10 @@ +$ENTRY Go { + , ((1) 2 ((3 4) 5) ((())) (((6))) 7 8 ()): e.List + = ' > +}; + +Flatten { + = ; + s.I e.X = s.I ; + (e.X) e.Y = ; +}; diff --git a/Task/Flatten-a-list/Uiua/flatten-a-list.uiua b/Task/Flatten-a-list/Uiua/flatten-a-list.uiua new file mode 100644 index 0000000000..346aa99a26 --- /dev/null +++ b/Task/Flatten-a-list/Uiua/flatten-a-list.uiua @@ -0,0 +1 @@ +⍥/◇⊂∞{{1} 2 {{3 4} 5} {{{}}} {{{6}}} 7 8 {}} diff --git a/Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery b/Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery new file mode 100644 index 0000000000..85e6f72690 --- /dev/null +++ b/Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery @@ -0,0 +1,60 @@ + [ [] over times + [ over [] swap times + [ 2 random join ] + nested join ] + nip ] is makeboard ( n --> [ ) + + [ [] swap witheach [ not join ] ] is invert ( [ --> [ ) + + [ 2dup peek invert unrot poke ] is fliprow ( [ n --> [ ) + + [ dip transpose fliprow transpose ] is flipcolumn ( [ n --> [ ) + + [ dup + [ dup size dup * times + [ dup size random + 2 random iff + fliprow + else flipcolumn ] + 2dup != until ] + nip ] is mix ( [ --> [ ) + + [ say " " + dup size times + [ sp i^ char a + emit ] + witheach + [ cr sp i^ echo say ":" + witheach + [ sp echo ] ] ] is display ( [ --> ) + + [ cr $ "a..., or 0...: " + input $ "." join + trim 0 peek lower + 2dup char a rot over + + within iff + [ nip char a - + ' flipcolumn ] + done + 2dup char 0 rot over + + within iff + [ nip char 0 - + ' fliprow ] + done + drop again ] is getmove ( n --> n x ) + + [ 0 temp put + makeboard + dup mix + [ say "Moves: " + temp share echo cr + 1 temp tally + 2dup swap + say "Target" cr + display cr cr + say "Current" cr + display cr + dup size getmove do cr + 2dup = until ] + 2drop + temp take + say "Moves taken: " echo ] is flipbits ( n --> ) diff --git a/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua b/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua new file mode 100644 index 0000000000..a38d6ba848 --- /dev/null +++ b/Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua @@ -0,0 +1,19 @@ +S ← 9 +Fr ← ⊙◌⍜⊡¬⊙. +Fc ← ⊙◌⍉Fr⊙(⍉.) +Shuffle ← ⍥(⟨Fr|Fc⟩<0.5⚂ ⌊×S⚂)×3S +T ← Shuffle ↯S_S 0 # Target setup. Omit `Shuffle` for plain grid. +D ← /+/+⌵-T + +# Could use A*, but this is easily solved without it. +# ◌astar(⊂⊃(≡Fr|≡Fc)⇡S¤|÷S D|=0D) +⟜[∘] Shuffle T # Shuffle and keep a copy for the output. +◌⍢( + + ⊂⊃(≡Fr|≡Fc)⇡S¤ # All neighbours. + ⊚=/↧.≡D. # Find min dist, get indices that give that. + ⊡⊢ # Pick first one. ⊡(⊡⌊×⚂⧻.) to pick at random. + ⊙⊂. # Save a copy of the new state. +| ≠0D +) +⟜($"_ steps."-1⧻)⇌ diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-2.ada b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada index 158400ca3d..b793ba8f93 100644 --- a/Task/Flow-control-structures/Ada/flow-control-structures-2.ada +++ b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada @@ -2,7 +2,9 @@ Outer: loop -- do something loop + if Finished then + exit Outer; -- exits both the inner and outer loops + end if; -- do something else - exit Outer; -- exits both the inner and outer loops end loop; end loop Outer; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-3.ada b/Task/Flow-control-structures/Ada/flow-control-structures-3.ada index 1af014edb3..ed66f3714c 100644 --- a/Task/Flow-control-structures/Ada/flow-control-structures-3.ada +++ b/Task/Flow-control-structures/Ada/flow-control-structures-3.ada @@ -1,7 +1,8 @@ -select - delay 10.0; - Put_Line ("Cannot finish this in 10s"); -then abort - -- do some lengthy calculation - ... -end select; +Outer: +loop + -- do something + loop + exit Outer when Finished; + -- do something else + end loop; +end loop Outer; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-4.ada b/Task/Flow-control-structures/Ada/flow-control-structures-4.ada new file mode 100644 index 0000000000..ef06de0b59 --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-4.ada @@ -0,0 +1,8 @@ +procedure Foo is +begin + -- do something + if Nothing_More_To_Do then + return; + end if; + -- do more +end Foo; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-5.ada b/Task/Flow-control-structures/Ada/flow-control-structures-5.ada new file mode 100644 index 0000000000..1af014edb3 --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-5.ada @@ -0,0 +1,7 @@ +select + delay 10.0; + Put_Line ("Cannot finish this in 10s"); +then abort + -- do some lengthy calculation + ... +end select; diff --git a/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic b/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic new file mode 100644 index 0000000000..cd7e9cb937 --- /dev/null +++ b/Task/Floyds-triangle/FutureBasic/floyds-triangle.basic @@ -0,0 +1,18 @@ +void local fn FloydsTriangle( rows as int ) + int col, row, num = 1 + + printf @"%d rows:", rows + for row = 1 to rows + for col = 1 to row + printf @"%4d\b", num + num++ + next + print + next + print +end fn + +fn FloydsTriangle( 5 ) +fn FloydsTriangle( 14 ) + +HandleEvents diff --git a/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas b/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas new file mode 100644 index 0000000000..4bdce7f681 --- /dev/null +++ b/Task/Floyds-triangle/PascalABC.NET/floyds-triangle.pas @@ -0,0 +1,19 @@ +procedure FloydTriangle(rows: integer); +begin + var r := 1; + for var i:=1 to rows do + begin + for var j:=1 to i do + begin + Write(r: (j>8 ? 4 : 3)); + r += 1; + end; + Writeln + end; +end; + +begin + FloydTriangle(5); + Writeln; + FloydTriangle(14); +end. diff --git a/Task/Floyds-triangle/Uiua/floyds-triangle.uiua b/Task/Floyds-triangle/Uiua/floyds-triangle.uiua index 98661007d6..041e5d1781 100644 --- a/Task/Floyds-triangle/Uiua/floyds-triangle.uiua +++ b/Task/Floyds-triangle/Uiua/floyds-triangle.uiua @@ -1,19 +1,13 @@ -Floyd ← ⇌⍥(⊂⍚(+⇡∩(+1)⊃⧻(⊢⇌))⊢.):{[1]}-1 - -JoinUsing ← ↘1/◇⊂≡(□◇⊂)↯:⊙(⧻.)□ -PadL ← ⊂/⊂↯:" " -Lengths ← ⍚∵◇∵(⧻°⋕)°□ - -PrintIt ← ( - # Create table of [last row sizes] [this row sizes] [this row numbers] - ⊢⊞⊂⊢⊢↙¯1.⍉[Lengths.] - +Floyd ← ⊜□⇌/(⊂↯.:)⟜(+1⇡/+)+1⇡ +Print ← ( + ≡(□≡(°⋕)) # Stringify terms. + ≡(⊢⬚""↯⊟∞:°□)⟜(◇/↥⧻) # Pad rows with "" to same dims. + ≡⊟¤+1≡◇⧻⊡¯1. # Find pads and couple with each. ≡( - # Calculate last row sizes - this row sizes and use to calculate paddings - ⍉⊟⊃(-:↙:⊙(⧻.)∩°□°⊟↙2)(°⋕°□⊢↘2) - &pJoinUsing " " ≡(⍚PadL°⊟) + ≡(□/◇⊂↙¯⟜(⊂↯⊙@ )∩°□°⊟)⍉ # Prepad each term. + &p/⍚⊂ # Join each row and print. ) ) - -PrintIt Floyd 4 -PrintIt Floyd 14 +Print Floyd 4 +&p"" +Print Floyd 14 diff --git a/Task/Forest-fire/Uiua/forest-fire.uiua b/Task/Forest-fire/Uiua/forest-fire.uiua new file mode 100644 index 0000000000..785847abee --- /dev/null +++ b/Task/Forest-fire/Uiua/forest-fire.uiua @@ -0,0 +1,9 @@ +S ← 60 +Pt ← 0.01 +Pf ← 0.00005 +⊞(0|⋅0)⟜NsOnFire.)200] +⇌≡∵⨬(0_0_0|0_1_0|1_0_0) +≡(▽⟜≡▽2) # Upscale diff --git a/Task/Formatted-numeric-output/ANSI-BASIC/formatted-numeric-output.basic b/Task/Formatted-numeric-output/ANSI-BASIC/formatted-numeric-output.basic new file mode 100644 index 0000000000..8cee480fb1 --- /dev/null +++ b/Task/Formatted-numeric-output/ANSI-BASIC/formatted-numeric-output.basic @@ -0,0 +1,12 @@ +100 REM Formatted numeric output +110 LET N = 7.125 +120 PRINT USING ("%%%%.###"): N +130 PRINT USING ("****.###"): N +140 PRINT USING ("####.###"): N +150 PRINT USING ("+%%%.###"): N +160 PRINT USING ("+%%%.###"): -N +170 PRINT USING (".###^^^^^"): N +180 PRINT USING ("#.###^^^^^"): N +190 PRINT USING ("##.###^^^^^"): N +200 PRINT USING ("+.###^^^^^"): -N +210 END diff --git a/Task/Formatted-numeric-output/PascalABC.NET/formatted-numeric-output.pas b/Task/Formatted-numeric-output/PascalABC.NET/formatted-numeric-output.pas new file mode 100644 index 0000000000..dea857165e --- /dev/null +++ b/Task/Formatted-numeric-output/PascalABC.NET/formatted-numeric-output.pas @@ -0,0 +1,4 @@ +## +var Pi := 3.1415926536; +Println($'{Pi,8:f2}'); +Println($'{Pi,-8:f3}!'); diff --git a/Task/Fractal-tree/11l/fractal-tree.11l b/Task/Fractal-tree/11l/fractal-tree.11l index 813cda8321..9c40657170 100644 --- a/Task/Fractal-tree/11l/fractal-tree.11l +++ b/Task/Fractal-tree/11l/fractal-tree.11l @@ -6,7 +6,7 @@ StartingAngle = 1.5 * math:pi DeltaAngle = 0.2 * math:pi -F drawTree(outfile, Float x, Float y; len, theta) -> N +F drawTree(outfile, Float x, y; len, theta) -> Void I len >= 1 V x2 = x + len * cos(theta) V y2 = y + len * sin(theta) diff --git a/Task/French-Republican-calendar/Jq/french-republican-calendar.jq b/Task/French-Republican-calendar/Jq/french-republican-calendar.jq new file mode 100644 index 0000000000..dde45845bc --- /dev/null +++ b/Task/French-Republican-calendar/Jq/french-republican-calendar.jq @@ -0,0 +1,149 @@ +include "Date" {search: "."}; + +### Generic functions + +def assertEq($p;$q): + if $p == $q + then . + else debug("assertion violation: \($p) != \($q)") as $debug | . + end; + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +def trim: sub("^ *";"") | sub(" *$";""); + +# Input: string such as "12 Mar 2012" +# Output: Date +def parseDayMonthYear: + def months: + {Jan:1, Feb:2, Mar:3, Apr: 4, May: 5, Jun: 6, + Jul:7, Aug:8, Sep:9, Oct:10, Nov:11, Dec:12}; + capture("(?[0-9]+) *(?[A-Za-z]+) *(?[0-9]+)") + | .month |= months[ .[:3] ] + | map_values(tonumber) + | {year, month, day}; + +### French Republican Calendar (FRC) + +def introductionDate: Date(1792; 9; 22); + +# Use the 'continuous method' for years after 1805 +def isLeapYearFRC: + (. + 1) + | (. % 4 == 0) and ((. % 100 != 0) or (. % 400 == 0)); + +# If the numbers $year, $month, and $day specify a valid date +# in the French Republican Calendar, then emit {$year, $month, $day}; +# otherwise generate an informative error message. +def FrenchRCDate($year; $month; $day): + def err(msg): "Invalid date (\(msg)): FrenchRCDate(\($year); \($month); \($day))" | error; + if ($year <= 0 or $month < 1 or $month > 13) then err(if $year <= 0 then "year" else "month" end) end + | if $month < 13 + then if $day < 1 or $day > 30 then err("day") end + else ($year | isLeapYearFRC) as $leap + | if $leap and ($day < 1 or $day > 6) then err("invalid day in leap year") end + | if ($leap|not) and ($day < 1 or $day > 5) then err("invalid day in non-leap year") end + end + | {$year, $month, $day}; + +# for convenience we treat 'Sansculottide' as an extra month with 5 or 6 days +def months: + ["Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse", "Ventôse", "Germinal", + "Floréal", "Prairial", "Messidor", "Thermidor", "Fructidor", "Sansculottide"] ; + +def intercal: + ["Fête de la vertu", "Fête du génie", "Fête du travail", + "Fête de l'opinion", "Fête des récompenses", "Fête de la Révolution"]; + +# Input: a string specifying a FRC date +def parse: + . as $frcDate + | (trim|split(" ")) as $splits + | if $splits|length == 3 + then (months | index($splits[1]) + 1) as $month + | if $month < 1 or $month > 13 then "Invalid month." | error end + | ($splits[2]|tonumber) as $year + | if $year < 1 then "Invalid year." | error end + | (if ($month < 13) then 30 elif $year|isLeapYearFRC then 6 else 5 end) as $monthLength + | ($splits[0] | tonumber) as $day + | if $day < 1 or $day > $monthLength then "Invalid day." | error end + | FrenchRCDate($year; $month; $day) + + elif ($splits|length | IN(4,5)) + then $splits[-1] as $yearStr + | ($yearStr|tonumber) as $year + | if $year < 1 then "Invalid year." | error end + | ($frcDate | trim[0: -($yearStr|length + 1)] ) as $scDay + | (intercal | index($scDay) + 1) as $day + | (if $year | isLeapYearFRC then 6 else 5 end) as $maxDay + | if $day < 1 or $day > $maxDay then "Invalid day." | error end + | FrenchRCDate($year; 13; $day) + else "Invalid French Republican date." | error + end +; + +# Input: Date (Gregorian) +# Output: +def fromLocalDate: + # $start and $finish should be two Date objects + def daysFrom($start; $finish): + ($finish|daysBeforeDate) - ($start|daysBeforeDate); + + (daysFrom(introductionDate; .) + 1) as $daysDiff + | if ($daysDiff <= 0) then "Date can't be before 22 September 1792." | error end + | {year: 1, startDay: 1} + | until(.done; + (.startDay + (if .year|isLeapYearFRC then 365 else 364 end)) as $endDay + | if ($daysDiff >= .startDay and $daysDiff <= $endDay) then .done = true + else .year += 1 + | .startDay = $endDay + 1 + end ) + | ($daysDiff - .startDay) as $remDays + | (($remDays / 30)|floor) as $month + | ($remDays - $month * 30) as $day + | FrenchRCDate(.year; $month + 1; $day + 1) +; + +# Input: an FRC Date +def toString: + if .month < 13 then "\(.day) \(months[.month - 1]) \(.year)" + else "\(intercal[.day - 1]) \(.year)" + end; + +# Input: an FRC Date +def toLocalDate: + (reduce range(1; .year) as $i (0; . + (if $i|isLeapYearFRC then 366 else 365 end))) as $sumDays + | ((.month - 1) * 30 + .day - 1) as $dayInYear + | introductionDate | addDays($sumDays + $dayInYear) ; + + +### Examples + +def dates: [ + "22 September 1792", "20 May 1795", "15 July 1799", "23 September 1803", + "31 December 1805", "18 March 1871", "25 August 1944", "19 September 2016", + "22 September 2017", "28 September 2017" +]; + +def task: + def format: + "\(.day) \(monthNames[.month]) \(.year)"; + + dates as $dates + | reduce range(0; $dates|length) as $i ({}; + .date = $dates[$i] + | .thisDate = (.date|parseDayMonthYear) + | .frcd = (.thisDate|fromLocalDate) + | .frcDates[$i] = (.frcd|toString) + | .emit += "\(.date|lpad(26)) => \(.frcDates[$i])\n") + | .emit, + + # now process the other way around + range(0; $dates|length) as $i + | .frcDates[$i] as $frcDate + | ($frcDate|parse|toLocalDate|format) as $lds + | assertEq($dates[$i]; $lds) + | "\($frcDate|lpad(26)) => \($lds)" +; + +task diff --git a/Task/Function-definition/ANSI-BASIC/function-definition.basic b/Task/Function-definition/ANSI-BASIC/function-definition.basic new file mode 100644 index 0000000000..9caf26d3c9 --- /dev/null +++ b/Task/Function-definition/ANSI-BASIC/function-definition.basic @@ -0,0 +1,13 @@ +100 DEF Multiply(A, B) = A * B +110 DECLARE FUNCTION MultiplyI +120 DECLARE EXTERNAL FUNCTION MultiplyE +130 PRINT Multiply(3, 1.23456) +140 PRINT MultiplyI(3, 1.23456) +150 PRINT MultiplyE(3, 1.23456) +160 FUNCTION MultiplyI(X, Y) +170 LET MultiplyI = X * Y +180 END FUNCTION +190 END +200 EXTERNAL FUNCTION MultiplyE(A, B) +210 LET MultiplyE = A * B +220 END FUNCTION diff --git a/Task/Function-definition/Chapel/function-definition-1.chapel b/Task/Function-definition/Chapel/function-definition-1.chapel new file mode 100644 index 0000000000..dce621a59f --- /dev/null +++ b/Task/Function-definition/Chapel/function-definition-1.chapel @@ -0,0 +1,4 @@ +proc multiply(a, b) +{ + return a * b; +} diff --git a/Task/Function-definition/Chapel/function-definition-2.chapel b/Task/Function-definition/Chapel/function-definition-2.chapel new file mode 100644 index 0000000000..cd4150861a --- /dev/null +++ b/Task/Function-definition/Chapel/function-definition-2.chapel @@ -0,0 +1,4 @@ +proc multiply(a : ?t ... 2) +{ + return a(0) * a(1) +} diff --git a/Task/Function-definition/Langur/function-definition-1.langur b/Task/Function-definition/Langur/function-definition-1.langur index 5f5be48e73..5878a47bf8 100644 --- a/Task/Function-definition/Langur/function-definition-1.langur +++ b/Task/Function-definition/Langur/function-definition-1.langur @@ -1,2 +1 @@ -val .multiply = fn(.x, .y) { .x * .y } -.multiply(3, 4) +val multiply = fn{*} diff --git a/Task/Function-definition/Langur/function-definition-2.langur b/Task/Function-definition/Langur/function-definition-2.langur index acbe918263..cfdc4aa62b 100644 --- a/Task/Function-definition/Langur/function-definition-2.langur +++ b/Task/Function-definition/Langur/function-definition-2.langur @@ -1,2 +1 @@ -val .multiply = fn(.x, .y) .x * .y -.multiply(3, 4) +val multiply = fn a, b: a * b diff --git a/Task/Function-definition/Langur/function-definition-3.langur b/Task/Function-definition/Langur/function-definition-3.langur index d66762792a..0445f67e8d 100644 --- a/Task/Function-definition/Langur/function-definition-3.langur +++ b/Task/Function-definition/Langur/function-definition-3.langur @@ -1,2 +1 @@ -val .multiply = fn{*} -.multiply(3, 4) +val multiply = fn(a, b) { a * b } diff --git a/Task/Function-definition/Langur/function-definition-4.langur b/Task/Function-definition/Langur/function-definition-4.langur deleted file mode 100644 index 69bbd2fc56..0000000000 --- a/Task/Function-definition/Langur/function-definition-4.langur +++ /dev/null @@ -1,2 +0,0 @@ -val .times3 = fn{* 3} -map .times3, [1, 2, 3] diff --git a/Task/Function-definition/Langur/function-definition-5.langur b/Task/Function-definition/Langur/function-definition-5.langur deleted file mode 100644 index 3f55f3d068..0000000000 --- a/Task/Function-definition/Langur/function-definition-5.langur +++ /dev/null @@ -1 +0,0 @@ -val .writeit = impure fn(.x) { writeln .x } diff --git a/Task/Function-definition/PascalABC.NET/function-definition.pas b/Task/Function-definition/PascalABC.NET/function-definition.pas new file mode 100644 index 0000000000..5cdaeef57d --- /dev/null +++ b/Task/Function-definition/PascalABC.NET/function-definition.pas @@ -0,0 +1 @@ +function multiply(a,b: real): real := a + b; diff --git a/Task/Function-definition/BASIC/function-definition.basic b/Task/Function-definition/QuickBASIC/function-definition.basic similarity index 100% rename from Task/Function-definition/BASIC/function-definition.basic rename to Task/Function-definition/QuickBASIC/function-definition.basic diff --git a/Task/Function-prototype/FutureBasic/function-prototype.basic b/Task/Function-prototype/FutureBasic/function-prototype.basic new file mode 100644 index 0000000000..547ce06eff --- /dev/null +++ b/Task/Function-prototype/FutureBasic/function-prototype.basic @@ -0,0 +1,3 @@ +def fn NoArgs +def fn TwoArgs( a as long, b as long ) +def fn VarArgs( n as long, ... ) diff --git a/Task/Gamma-function/REXX/gamma-function-3.rexx b/Task/Gamma-function/REXX/gamma-function-3.rexx new file mode 100644 index 0000000000..5b4f4665cd --- /dev/null +++ b/Task/Gamma-function/REXX/gamma-function-3.rexx @@ -0,0 +1,517 @@ +parse version version; say version; glob. = '' +say 'Gamma function in arbitrary precision' +say +say '(Half)integers formulas' +w = '-99.5 -10.5 -5.5 -2.5 -1.5 -0.5 0.5 1 1.5 2 2.5 5 5.5 10 10.5 99 99.5' +numeric digits 100 +do i = 1 to words(w) + x = word(w,i); call time('r'); r = Gamma(x); e = format(time('e'),,3) + say 'Formulas' format(x,4,1) r '('e 'seconds)' +end +say +say 'Lanczos (max 60 digits) vs Spouge (no limit) vs Stirling (no limit) approximation' +w = '-12.8 -6.4 -3.2 -1.6 -0.8 -0.4 -0.2 -0.1 0.1 0.2 0.4 0.8 1.6 3.2 6.4 12.8' +do i = 1 to words(w) + x = word(w,i) + numeric digits 60 + call time('r'); r = Gamma(x); e = format(time('e'),,3) + say 'Lanczos ' format(x,4,1) r '('e 'seconds)' + numeric digits 61 + call time('r'); r = Gamma(x); e = format(time('e'),,3) + say 'Spouge ' format(x,4,1) r '('e 'seconds)' + if x > 0 then do + call time('r'); r = Stirling(x); e = format(time('e'),,3) + say 'Stirling' format(x,4,1) r '('e 'seconds)' + end +end +say +say 'Same for a bigger number' +w = '-99.9 99.9' +do i = 1 to words(w) + x = word(w,i) + numeric digits 60 + call time('r'); r = Gamma(x); e = format(time('e'),,3) + say 'Lanczos ' format(x,4,1) r '('e 'seconds)' + numeric digits 100 + call time('r'); r = Gamma(x); e = format(time('e'),,3) + say 'Spouge ' format(x,4,1) r '('e 'seconds)' + if x > 0 then do + call time('r'); r = Stirling(x); e = format(time('e'),,3) + say 'Stirling' format(x,4,1) r '('e 'seconds)' + end +end +exit + +Gamma: +/* Gamma */ +procedure expose glob. +arg x +/* Validity */ +if x < 1 & Whole(x) then + return 'X' +/* Formulas for negative and positive (half)integers */ +if x < 0 then do + if Half(x) then do + numeric digits Digits()+2 + i = Abs(Floor(x)); y = (-1)**i*2**(2*i)*Fact(i)*Sqrt(Pi())/Fact(2*i) + numeric digits Digits()-2 + return y+0 + end +end +if x > 0 then do + if Whole(x) then + return Fact(x-1) + if Half(x) then do + numeric digits Digits()+2 + i = Floor(x); y = Fact(2*i)*Sqrt(Pi())/(2**(2*i)*Fact(i)) + numeric digits Digits()-2 + return y+0 + end +end +p = Digits() +if p < 61 then do +/* Lanczos with predefined coefficients */ +/* Map negative x to positive x */ + if x < 0 then + return Pi()/(Gamma(1-x)*Sin(Pi()*x)) +/* Argument reduction to interval (0.5,1.5) */ + numeric digits p+2 + c = Trunc(x); x = x-c + if x < 0.5 then do + x = x+1; c = c-1 + end +/* Series coefficients 1/Gamma(x) in 80 digits Fransen & Wrigge */ + c.1 = 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000 + c.2 = 0.57721566490153286060651209008240243104215933593992359880576723488486772677766467 + c.3 = -0.65587807152025388107701951514539048127976638047858434729236244568387083835372210 + c.4 = -0.04200263503409523552900393487542981871139450040110609352206581297618009687597599 + c.5 = 0.16653861138229148950170079510210523571778150224717434057046890317899386605647425 + c.6 = -0.04219773455554433674820830128918739130165268418982248637691887327545901118558900 + c.7 = -0.00962197152787697356211492167234819897536294225211300210513886262731167351446074 + c.8 = 0.00721894324666309954239501034044657270990480088023831800109478117362259497415854 + c.9 = -0.00116516759185906511211397108401838866680933379538405744340750527562002584816653 + c.10 = -0.00021524167411495097281572996305364780647824192337833875035026748908563946371678 + c.11 = 0.00012805028238811618615319862632816432339489209969367721490054583804120355204347 + c.12 = -0.00002013485478078823865568939142102181838229483329797911526116267090822918618897 + c.13 = -0.00000125049348214267065734535947383309224232265562115395981534992315749121245561 + c.14 = 0.00000113302723198169588237412962033074494332400483862107565429550539546040842730 + c.15 = -0.00000020563384169776071034501541300205728365125790262933794534683172533245680371 + c.16 = 0.00000000611609510448141581786249868285534286727586571971232086732402927723507435 + c.17 = 0.00000000500200764446922293005566504805999130304461274249448171895337887737472132 + c.18 = -0.00000000118127457048702014458812656543650557773875950493258759096189263169643391 + c.19 = 0.00000000010434267116911005104915403323122501914007098231258121210871073927347588 + c.20 = 0.00000000000778226343990507125404993731136077722606808618139293881943550732692987 + c.21 = -0.00000000000369680561864220570818781587808576623657096345136099513648454655443000 + c.22 = 0.00000000000051003702874544759790154813228632318027268860697076321173501048565735 + c.23 = -0.00000000000002058326053566506783222429544855237419746091080810147188058196444349 + c.24 = -0.00000000000000534812253942301798237001731872793994898971547812068211168095493211 + c.25 = 0.00000000000000122677862823826079015889384662242242816545575045632136601135999606 + c.26 = -0.00000000000000011812593016974587695137645868422978312115572918048478798375081233 + c.27 = 0.00000000000000000118669225475160033257977724292867407108849407966482711074006109 + c.28 = 0.00000000000000000141238065531803178155580394756670903708635075033452562564122263 + c.29 = -0.00000000000000000022987456844353702065924785806336992602845059314190367014889830 + c.30 = 0.00000000000000000001714406321927337433383963370267257066812656062517433174649858 + c.31 = 0.00000000000000000000013373517304936931148647813951222680228750594717618947898583 + c.32 = -0.00000000000000000000020542335517666727893250253513557337960820379352387364127301 + c.33 = 0.00000000000000000000002736030048607999844831509904330982014865311695836363370165 + c.34 = -0.00000000000000000000000173235644591051663905742845156477979906974910879499841377 + c.35 = -0.00000000000000000000000002360619024499287287343450735427531007926413552145370486 + c.36 = 0.00000000000000000000000001864982941717294430718413161878666898945868429073668232 + c.37 = -0.00000000000000000000000000221809562420719720439971691362686037973177950067567580 + c.38 = 0.00000000000000000000000000012977819749479936688244144863305941656194998646391332 + c.39 = 0.00000000000000000000000000000118069747496652840622274541550997151855968463784158 + c.40 = -0.00000000000000000000000000000112458434927708809029365467426143951211941179558301 + c.41 = 0.00000000000000000000000000000012770851751408662039902066777511246477487720656005 + c.42 = -0.00000000000000000000000000000000739145116961514082346128933010855282371056899245 + c.43 = 0.00000000000000000000000000000000001134750257554215760954165259469306393008612196 + c.44 = 0.00000000000000000000000000000000004639134641058722029944804907952228463057968680 + c.45 = -0.00000000000000000000000000000000000534733681843919887507741819670989332090488591 + c.46 = 0.00000000000000000000000000000000000032079959236133526228612372790827943910901464 + c.47 = -0.00000000000000000000000000000000000000444582973655075688210159035212464363740144 + c.48 = -0.00000000000000000000000000000000000000131117451888198871290105849438992219023663 + c.49 = 0.00000000000000000000000000000000000000016470333525438138868182593279063941453996 + c.50 = -0.00000000000000000000000000000000000000001056233178503581218600561071538285049997 + c.51 = 0.00000000000000000000000000000000000000000026784429826430494783549630718908519485 + c.52 = 0.00000000000000000000000000000000000000000002424715494851782689673032938370921241 +/* Series expansion */ + x = x-1; s = 0 + do k = 52 by -1 to 1 + s = s*x+c.k + end + y = 1/s +/* Undo reduction */ + if c = -1 then + y = y/x + else do + do i = 1 to c + y = (x+i)*y + end + end +end +else do + x = x-1 +/* Spouge */ +/* Estimate digits and iterations */ + q = Floor(p*1.5); a = Floor(p*1.3) + numeric digits q +/* Series */ + s = 0 + do k = 1 to a-1 + s = s+((-1)**(k-1)*Power(a-k,k-0.5)*Exp(a-k))/(Fact(k-1)*(x+k)) + end + s = s+Sqrt(2*Pi()); y = Power(x+a,x+0.5)*Exp(-a-x)*s +end +/* Normalize */ +numeric digits p +return y+0 + +Stirling: +/* Sterling */ +procedure expose glob. +arg x +return sqrt(2*pi()/x) * power(x/e(),x) + +E: +/* Euler number */ +procedure expose glob. +p = Digits() +/* In memory? */ +if glob.e.p <> '' then + return glob.e.p +if p < 101 then +/* Fast value */ + glob.e.p = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516643+0 +else do + numeric digits Digits()+2 +/* Taylor series */ + y = 2; t = 1; v = y + do n = 2 + t = t/n; y = y+t + if y = v then + leave + v = y + end + numeric digits Digits()-2 + glob.e.p = y+0 +end +return glob.e.p + +Exp: +/* Exponential e^x */ +procedure expose glob. +arg x +numeric digits Digits()+2 +/* Fast values */ +if Whole(x) then + return E()**x +/* Argument reduction */ +i = x%1 +if Abs(x-i) > 0.5 then + i = i+Sign(x) +/* Taylor series */ +x = x-i; y = 1; t = 1; v = y +do n = 1 + t = (t*x)/n; y = y+t + if y = v then + leave + v = y +end +/* Inverse reduction */ +y = y*e()**i +numeric digits Digits()-2 +return y+0 + +Fact: +/* Factorial n! */ +procedure expose glob. +arg x +/* Validity */ +if \ Whole(x) then + return 'X' +if x < 0 then + return 'X' +/* Current in memory? */ +if glob.fact.x <> '' then + return glob.fact.x +w = x-1 +/* Previous in memory? */ +if glob.fact.w = '' then do +/* Loop cf definition */ + y = 1 + do n = 2 to x + y = y*n + end + glob.fact.x = y +end +else +/* Multiply */ + glob.fact.x = glob.fact.w*x +return glob.fact.x + +Floor: +/* Floor */ +procedure expose glob. +arg x +/* Formula */ +if Whole(x) then + return x +else + return Trunc(x)-(x<0) + +Frac: +/* Fractional part */ +procedure expose glob. +arg x +/* Formula */ +return x-x%1 + +Half: +/* Is a number half integer? */ +procedure expose glob. +arg x +/* Formula */ +return (Frac(Abs(x))=0.5) + +Ln: +/* Natural logarithm base e */ +procedure expose glob. +arg x +/* Validity */ +if x <= 0 then + return 'X' +/* Fast values */ +if x = 1 then + return 0 +p = Digits() +/* In memory? */ +if glob.ln.x.p <> '' then + return glob.ln.x.p +/* Precalculated values */ +if x = 2 & p < 101 then do + glob.ln.x.p = Ln2() + return glob.ln.x.p +end +if x = 4 & p < 101 then do + glob.ln.x.p = Ln4() + return glob.ln.x.p +end +if x = 8 & p < 101 then do + glob.ln.x.p = Ln8() + return glob.ln.x.p +end +if x = 10 & p < 101 then do + glob.ln.x.p = Ln10() + return glob.ln.x.p +end +numeric digits p+2 +/* Argument reduction */ +z = x; i = 0; e = 1/E() +if z < 0.5 then do + y = 1/z + do while y > 1.5 + y = y*e; i = i-1 + end + z = 1/y +end +if z > 1.5 then do + do while z > 1.5 + z = z*e; i = i+1 + end +end +/* Taylor series */ +q = (z-1)/(z+1); f = q; y = q; v = q; q = q*q +do n = 3 by 2 + f = f*q; y = y+f/n + if y = v then + leave + v = y +end +numeric digits p +/* Inverse reduction */ +glob.ln.x.p = 2*y+i +return glob.ln.x.p + +Power: +/* Power function x^y */ +procedure expose glob. +arg x,y +/* Validity */ +if x < 0 then + return 'X' +/* Fast values */ +if x = 0 then + return 0 +if y = 0 then + return 1 +/* Fast formula */ +if Whole(y) then + return x**y +/* Formulas */ +if Abs(y//1) = 0.5 then + return Sqrt(x)**Sign(y)*x**(y%1) +else + return Exp(y*Ln(x)) + +Sin: +/* Sine */ +procedure expose glob. +arg x +numeric digits Digits()+2 +/* Argument reduction */ +u = Pi(); x = x//(2*u) +if Abs(x) > u then + x = x-Sign(x)*2*u +/* Taylor series */ +t = x; y = x; x = x*x; v = y +do n = 2 by 2 + t = -t*x/(n*(n+1)); y = y+t + if y = v then + leave + v = y +end +numeric digits Digits()-2 +return y+0 + +Sqrt: +/* Square root x^(1/2) */ +procedure expose glob. +arg x +/* Validity */ +if x < 0 then + return 'X' +/* Fast values */ +if x = 0 then + return 0 +if x = 1 then + return 1 +p = Digits() +/* Predefined values */ +if x = 2 & p < 101 then + return Sqrt2() +if x = 3 & p < 101 then + return Sqrt3() +if x = 5 & p < 101 then + return Sqrt5() +numeric digits p+2 +/* Argument reduction to [0,100) */ +i = Xpon(x); i = (i-(i<0))%2; x = x/100**i +/* First guess 1 digit accurate */ +t = '2.5 6.5 12.5 20.5 30.5 42.5 56.5 72.5 90.5 100' +do y = 1 until word(t,y) > x +end +/* Dynamic precision */ +d = Digits() +do n = 1 while d > 2 + d.n = d; d = d%2+1 +end +d.n = 2 +/* Method Heron */ +do k = n to 1 by -1 + numeric digits d.k + y = (y+x/y)*0.5 +end +numeric digits p +return y*10**i + +Whole: +/* Is a number integer? */ +procedure expose glob. +arg x +/* Formula */ +return Datatype(x,'w') + +Xpon: +/* Exponent */ +procedure expose glob. +arg x +/* Formula */ +if x = 0 then + return 0 +else + return Right(x*1E+99999,6)-99999 + +Ln2: +/* Natural log of 2 */ +procedure expose glob. +/* Fast value */ +y = 0.6931471805599453094172321214581765680755001343602552541206800094933936219696947156058633269964186875 +return y+0 + +Ln4: +/* Natural log of 4 */ +procedure expose glob. +/* Fast value */ +y = 1.386294361119890618834464242916353136151000268720510508241360018986787243939389431211726653992837375 +return y+0 + +Ln8: +/* Natural log of 8 */ +procedure expose glob. +/* Fast value */ +y = 2.079441541679835928251696364374529704226500403080765762362040028480180865909084146817589980989256063 +return y+0 + +Ln10: +/* Natural log of 10 */ +procedure expose glob. +/* Fast value */ +y = 2.30258509299404568401799145468436420760110148862877297603332790096757260967735248023599720508959830 +return y+0 + +Pi: +/* Pi */ +procedure expose glob. +p = Digits() +/* In memory? */ +if glob.pi.p <> '' then + return glob.pi.p +if p < 101 then +/* Fast value */ + glob.pi.p = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211707+0 +else do + numeric digits Digits()+2 + if p < 201 then do +/* Method Chudnovsky series */ + y = 0 + do n = 0 + v = y; y = y + Fact(6*n)*(13591409+545140134*n)/(Fact(3*n)*Fact(n)**3*-640320**(3*n)) + if y = v then + leave + end + y = 4270934400/(Sqrt(10005)*y) + end + else do +/* Method Agmean series */ + y = 0.25; a = 1; g = Sqrt(0.5); n = 1 + do until a = v + v = a + x = (a+g)*0.5; g = Sqrt(a*g) + y = y-n*(x-a)**2; n = n+n; a = x + end + y = a*a/y + end + numeric digits Digits()-2 + glob.pi.p = y+0 +end +return glob.pi.p + +Sqrt2: +/* Square root of 2 */ +procedure expose glob. +/* Fast value */ +y = 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573 +return y+0 + +Sqrt3: +/* Square root of 3 */ +procedure expose glob. +/* Fast value */ +y = 1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248576 +return y+0 + +Sqrt5: +/* Square root of 5 */ +procedure expose glob. +/* Fast value */ +y = 2.236067977499789696409173668731276235440618359611525724270897245410520925637804899414414408378782275 +return y+0 diff --git a/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas b/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas new file mode 100644 index 0000000000..dc3d777a26 --- /dev/null +++ b/Task/General-FizzBuzz/PascalABC.NET/general-fizzbuzz.pas @@ -0,0 +1,14 @@ +## +for var i:=1 to 20 do +begin + var s := ''; + if i mod 3 = 0 then + s += 'Fizz'; + if i mod 5 = 0 then + s += 'Buzz'; + if i mod 7 = 0 then + s += 'Baxx'; + if s = '' then + Println(i) + else Println(s); +end diff --git a/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal b/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal new file mode 100644 index 0000000000..7519a97553 --- /dev/null +++ b/Task/General-FizzBuzz/Refal/general-fizzbuzz.refal @@ -0,0 +1,54 @@ +$ENTRY Go { + , >: s.Max + , : e.Factors + , : e.Nums + = ; +}; + +Fizz { + s.I e.Facs, : { + = >; + e.X = ; + }; +} + +Fac { + (s.Fac e.FacWord) s.I, : { + 0 = e.FacWord; + s.X = ; + }; +}; + +ReadFactors { + , : { + 0 = ; = ; + e.Line = () ; + }; +}; + +Line { + e.X, : (e.Num) e.Word = + ; +}; + +Split { + s.C e.X s.C e.Y = (e.X) e.Y; + s.C e.X = (e.X); +}; + +Trim { + s.C = ; + s.C s.C e.X = ; + s.C e.X s.C = ; + s.C s.I e.X = s.I ; +}; + +Iota { + s.End s.End = s.End; + s.Start s.End = s.Start s.End>; +}; + +Each { + s.F (e.Arg) = ; + s.F (e.Arg) t.I e.X = ; +}; diff --git a/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl b/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl new file mode 100644 index 0000000000..4caf8b65f4 --- /dev/null +++ b/Task/General-FizzBuzz/SETL/general-fizzbuzz.setl @@ -0,0 +1,9 @@ +program general_fizzbuzz; + fizzbuzz(20, {[3,"Fizz"], [5,"Buzz"], [7,"Baxx"]}); + + proc fizzbuzz(maxno, factors); + loop for i in [1..maxno] do + print(+/[word : word = factors(f) | i mod f=0] ? str i); + end loop; + end proc; +end program; diff --git a/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas b/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas new file mode 100644 index 0000000000..ab01a49532 --- /dev/null +++ b/Task/Generate-lower-case-ASCII-alphabet/PascalABC.NET/generate-lower-case-ascii-alphabet.pas @@ -0,0 +1,5 @@ +## +var a := Arr('a'..'z'); +a.Println; +var s := ('a'..'z').JoinToString(' ');; +s.Println diff --git a/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq b/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq new file mode 100644 index 0000000000..56cc2d10dd --- /dev/null +++ b/Task/Generate-random-chess-position/Jq/generate-random-chess-position.jq @@ -0,0 +1,94 @@ +### Pseuo-random numbers + +# Output: a prn in range(0;$n) where $n is `.` +def prn: + if . == 1 then 0 + else . as $n + | ([1, (($n-1)|tostring|length)]|max) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +def sample: + if length == 0 # e.g. null or [] + then null + else .[length|prn] + end; + +def randFloat: + (1000|prn) / 1000; + +### Chess + +def isEmpty: . == "." or . == "•"; + +def grid: + [range(0;4) | (".","•") ] as $black + | [range(0;4) | ("•", ".")] as $white + | [range(0;4) | ($black, $white)] ; + +# input: {grid} +def placeKings: + .done = false + | until(.done; + [8 | prn, prn, prn, prn] as [$r1, $c1, $r2, $c2] + | if $r1 != $r2 and (($r1 - $r2)|length) > 1 and (($c1 - $c2)|length) > 1 + then .grid[$r1][$c1] = "K" + | .grid[$r2][$c2] = "k" + | .done = true + else . + end ) + | del(.done); + +# input: {grid} +def placePieces($pieces; $isPawn): + ($pieces|length|prn) as $numToPlace + | .n = -1 + | until(.n == $numToPlace; + .n += 1 + | .done = false + | until(.done; + .r = (8 | prn) + | .c = (8 | prn) + | if (.grid[.r][.c] | isEmpty) and (($isPawn and (.r == 7 or .r == 0))|not) + then .done = true + else . + end ) + | .grid[.r][.c] = $pieces[.n:.n+1] ) ; + +def toFen: + { grid, + fen: "", + countEmpty: 0 } + | reduce range (0;8) as $r (.; + reduce range(0;8) as $c (.; + .grid[$r][$c] as $ch + | .emit += " \($ch) " + | if ($ch | isEmpty) + then .countEmpty += 1 + else + if .countEmpty > 0 + then .fen += (.countEmpty|tostring) + | .countEmpty = 0 + end + | .fen += $ch + end ) + | if .countEmpty > 0 + then .fen += (.countEmpty|tostring) + | .countEmpty = 0 + end + | .fen += "/" + | .emit += "\n" ) + | .emit, + .fen + " w - - 0 1" ; + +def createFen: + {grid: grid} + | placeKings + | placePieces("PPPPPPPP"; true) + | placePieces("pppppppp"; true) + | placePieces("RNBQBNR"; false) + | placePieces("rnbqbnr"; false) + | toFen; + +createFen diff --git a/Task/Generic-swap/Langur/generic-swap.langur b/Task/Generic-swap/Langur/generic-swap.langur index 72306571e6..936f15ccbf 100644 --- a/Task/Generic-swap/Langur/generic-swap.langur +++ b/Task/Generic-swap/Langur/generic-swap.langur @@ -1,7 +1,7 @@ -var .abc = [1, 2, 3] -var .def = [5, 6, 7] +var abc = [1, 2, 3] +var def = [5, 6, 7] -.abc[3], .def[3] = .def[3], .abc[3] +abc[3], def[3] = def[3], abc[3] -writeln .abc -writeln .def +writeln abc +writeln def diff --git a/Task/Generic-swap/PascalABC.NET/generic-swap.pas b/Task/Generic-swap/PascalABC.NET/generic-swap.pas new file mode 100644 index 0000000000..38de981788 --- /dev/null +++ b/Task/Generic-swap/PascalABC.NET/generic-swap.pas @@ -0,0 +1,10 @@ +procedure Swap (var a,b: T) := (a,b) := (b,a); + +begin + var (i,j) := (1,2); + Swap(i,j); + Println(i,j); + var (s1,s2) := ('PascalABC.NET','Hello'); + Swap(s1,s2); + Println(s1,s2); +end. diff --git a/Task/Giuga-numbers/Jq/giuga-numbers.jq b/Task/Giuga-numbers/Jq/giuga-numbers.jq new file mode 100644 index 0000000000..09d889298a --- /dev/null +++ b/Task/Giuga-numbers/Jq/giuga-numbers.jq @@ -0,0 +1,24 @@ +# `div/1` is defined firstly to take advantage of gojq's infinite-precision +# integer arithmetic, and secondly to ensure jaq returns an integer. +def div($j): + (. - (. % $j)) / $j | round; # round is for the sake of jaq + +# For convenience +def div($i; $j): $i|div($j); + +def is_giuga: + . as $m + | sqrt as $limit + | {n: $m, f: 2} + | until(.ans; + if (.n % .f) == 0 + then if ((div($m; .f) - 1) % .f) != 0 then .ans = 0 + else .n = div(.n; .f) + | if .f > .n then .ans = 1 end + end + else .f += 1 + | if .f > $limit then .ans = 0 end + end) + | .ans == 1 ; + +limit(4; range(4; infinite) | select(is_giuga)) diff --git a/Task/Go-Fish/FutureBasic/go-fish.basic b/Task/Go-Fish/FutureBasic/go-fish.basic new file mode 100644 index 0000000000..7b2722e3ce --- /dev/null +++ b/Task/Go-Fish/FutureBasic/go-fish.basic @@ -0,0 +1,559 @@ +/* + +Go Fish +-- Rich Love -- + +FutureBasic app For Macintosh +Get the latest FutureBasic here +http://www.brilorsoftware.com/fb/pages/home.html + +*/ + + +_window = 1 +begin enum 1 + _scrollView + _textView +end enum + +override _forLoopsAlwaysExecuteAtLeastOnce = _true + +begin globals + +str255 cards +cards = "A234567890JQK" +short play(13), Computer(13), deck(13), guess(13), poss(13), asked(13) +str255 YourName, Someone +//bool gNeedToClearScreen +short Points(2) : Points(0) = 0 : Points(1) = 0 +short i, k, j, CardNumber +short RemainingCards + +end globals + + +local fn CheckForFaceCard(TheCard as short) as str255 + str255 WantsCard + WantsCard = str$(TheCard) + + if TheCard = 0 then WantsCard = "10" + if TheCard = 11 then WantsCard = "jack" + if TheCard = 12 then WantsCard = "Queen" + if TheCard = 13 then WantsCard = "King" + if TheCard = 1 then WantsCard = "Ace" +end fn = WantsCard + + +void local fn PrintViewScrollToBottom( printView as ViewRef ) + BeginCCode + NSScrollView *scrollView = [printView enclosingScrollView]; + NSClipView *clipView = [scrollView contentView]; + [clipView scrollToPoint:NSMakePoint(0,printView.frame.size.height-scrollView.contentSize.height + 20)]; + [scrollView reflectScrolledClipView:clipView]; + EndC +end fn + + +void local fn DealCards + + RemainingCards -= 1 + short sc + sc = rnd(RemainingCards) + 1 // 5/2/24 Rich added + 1 + + For k = 1 To 13 + sc -= deck(k) + If sc <= 0 Then exit fn + Next k + +End fn + +void local fn youGoFishing + + fn DealCards + + str255 WantsCard + WantsCard = fn CheckForFaceCard(k) + + if WantsCard = "0" then WantsCard = "10" + + Print " " + WantsCard + "." + deck(k) -= 1 + play(k) += 1 + +End fn + + +void local fn cpuGoFishing + + fn DealCards + Print " a card from the deck." + if k > 13 then k = 13 + deck(k) -= 1 + Computer(k) += 1 + +End fn + + +void local fn CheckForCompletedBook + + For i = 1 To 13 + If play(i) <> 4 + Else + text ,,fn colorcyan + + str255 WantsCard + WantsCard = Mid$(cards,i,1) + + if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" + if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" + if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" + if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" + if WantsCard = "0" then WantsCard = "10" + + Print YourName + " completed the book of " + WantsCard + "'s." + text ,,fn colorWhite + play(i) = 0 + Points(0) += 1 + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + End If + Next i + +End fn + +local fn CheckCPUForCompletedBook + + For i = 1 To 13 + + If Computer(i) <> 4 + Else + text ,,fn colorCyan + str255 WantsCard + WantsCard = Mid$(cards,i,1) + + if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" + if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" + if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" + if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" + if WantsCard = "0" then WantsCard = "10" + + Print "CPU completed the book of " + WantsCard + "'s." + + text ,,fn colorWhite + Computer(i) = 0 + Points(1) += 1 + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + End If + Next i + +End fn + + +local fn InitCards + + cards = "A234567890JQK" + RemainingCards = 4 * len$(cards) // the length of cards is 13. There are 4 suits of cards. so RemainingCards is 52 + i = 0:k = 0:j = 0:CardNumber = 0 + + For i = 0 to 1 + Points(i) = 0 + next i + + For i = 1 TO 13 // Reset each element to 0 + play(i) = 0 + Computer(i) = 0 + deck(i) = 0 + guess(i) = 0 + poss(i) = 0 + asked(i) = 0 + + NEXT i + + + For i = 1 To 13 + deck(i) = 4 + Next i + For i = 1 To 9 + fn DealCards + deck(k) -= 1 + Computer(k) += 1 + fn DealCards + deck(k) -= 1 + play(k) += 1 + Next i + + fn CheckForCompletedBook // Rich added 5/1/24 + fn CheckCPUForCompletedBook // Rich added 5/5/24 +end fn + + +local fn QuitOrPlayAlert(GameResult as CFStringRef) + + alert -2,,GameResult,@"Game Over",@"Quit;Play Again" + AlertButtonSetKeyEquivalent( 2, 2, @"\e" ) + short result + result = alert 2 + if ( result != NSAlertSecondButtonReturn ) then end + +end fn + +local fn QuitOrResumeAlert(GameResult as CFStringRef) + + alert -3,,GameResult,@"Quit the game?",@"Quit;Resume game" + AlertButtonSetKeyEquivalent( 3, 2, @"\e" ) + short result + result = alert 3 + if ( result != NSAlertSecondButtonReturn ) then end + +end fn + +local fn CheckForEndGame as boolean + + bool PlayAgain = _False + short np = 0, nc = 0 + For i = 1 To 13 + np += play(i) + nc += Computer(i) + Next i + + If RemainingCards = 0 || np = 0 || nc = 0 + + text ,,fn colorRed + Print "*** Game Over! ***" + Print + If Points(0) < Points(1) + Print "The CPU has won." + print:print + fn QuitOrPlayAlert(@"the CPU won!") + PlayAgain = _True + Else if Points(0) > Points(1) + Print YourName + " has won." + print:print + fn QuitOrPlayAlert(@"You Won!") + PlayAgain = _True + Else + Print "­It's a tie!" + fn QuitOrPlayAlert(@"It's a tie!.") + PlayAgain = _True + End If + fn PrintViewScrollToBottom( fn WindowPrintView(1) ) + + End If + + PlayAgain = _True + +End If + +End fn = PlayAgain + + +void local fn Intro + + text ,,fn colorGreen + Print " __ _ _ " + Print " __ _ ___ / _(_)___| |__ " + Print " / ` |/ _ \ | |_| / __| //_ \ " + Print "| (_) | (_) | | _| \__ \ | | | " + Print " \__, |\___/ |_| |_|___/_| |_| " + Print " |___/ " + Print "" + + text ,,fn colorCyan + print %(301,90),"( x to exit the game )" + text ,,fn colorWhite + + print " Go Fish Rules:" + print + print " You are playing against the CPU." + print " You are dealt nine cards to start with." + print " The remaining cards are placed face down in the center of the table" + print " to form the draw pile (the fish pond)." + print " On your turn, you ask the CPU For a card." + print " You must already have at least one card of a given rank to ask For more." + print " (A rank is one or more of any card.)" + print " If the CPU has any cards of the named rank, it must hand over all such cards," + print " and you can then ask again." + print " If the CPU has no cards of the named rank, a card will be drawn from the pile," + print " and placed in your hand, which then ends your turn." + print " A book is a collection of four cards in a given rank." + print " Whenever you complete a book, it will be removed from your hand." + print " If at any time, your hand is empty, a new card will be drawn from the pile." + print " The game ends when every book is complete," + print " or there are no more cards left in the pile." + print " The player with the most books wins." + + + CFStringRef UserInput + "InputYourName" + UserInput = input % (300, 70), @"What's your name?: " + if ( UserInput == NULL ) then "InputYourName" // Rich added this 5/1/24 + fn CFStringGetPascalString (UserInput, @YourName, 256, _kCFStringEncodingMacRoman) + cls + + if YourName = "X" || YourName = "x" || YourName = chr$(127) then fn QuitOrResumeAlert(@"EXIT") + +End fn + + +local fn WhatCardInputHeight as short + + CGRect mainScreenFrame = fn ScreenMainFrame + float InputHeight = int(mainScreenFrame.size.height - 120) + +end fn = InputHeight + + +local fn BuildWindow + + // ---> Get the size of the Main Screen. <--- + CGRect mainScreenFrame = fn ScreenMainFrame + float msh = mainScreenFrame.size.height + CGRect r = fn CGRectMake( 0, 0, 600, int(msh) - 110) + + window 1, @"Go Fish", r + windowcenter(1) + WindowSetBackgroundColor(1,fn ColorBlack) + +end fn + +//--- Start --- + +fn BuildWindow + +fn Intro + +fn InitCards + +str255 AddTheS +bool RequestCard = _false +short v = 0 +short po = 0 +boolean ShowHand = _false +str255 WantsCard + +"Main" + +ShowHand = _false + +str255 RequestedCard + +While ShowHand = _false + text ,,fn colorGreen + Print Chr$(10) + "Points >> "; + text ,,fn colorYellow + print YourName + ": "; + text ,,fn colorGreen + print Points(0); + text ,,fn colorOrange + print " CPU: "; + text ,,fn colorGreen + print Points(1) + text ,,fn colorWhite + Print Chr$(10) + " " + str$(RemainingCards) + " remaining cards" + text ,,fn colorWhite + + + /* + // Uncomment this to see the CPUs cards For testing + Print Chr$(10) + "CPU Cards: "; + For i = 1 To 13 + if Computer(i) <> 0 + For j = 1 To Computer(i) + if Mid$(cards,i,1) = "0" + Print @"10"; " "; + else + Print Mid$(cards,i,1); " "; + end if + Next j + End If + Next i + Print + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + */ + + + Print Chr$(10) + "Your Cards: "; + For i = 1 To 13 + if play(i) <> 0 + For j = 1 To play(i) + if Mid$(cards,i,1) = "0" + Print @"10"; " "; + else + Print Mid$(cards,i,1); " "; + end if + Next j + End If + Next i + Print + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + + RequestCard = _false + + While RequestCard = _false + if fn CheckForEndGame = _True then cls:fn InitCards:goto "Loop" + + Someone = YourName + + CFStringRef UserInput = 0 + "InputCard" + UserInput = input % (20, fn WhatCardInputHeight),@"What card do you want? " + if ( UserInput == NULL ) then "InputCard" // Rich added this 5/1/24 + fn CFStringGetPascalString (UserInput, @RequestedCard, 256, _kCFStringEncodingMacRoman) + if RequestedCard = "10" then RequestedCard = "0"// card zero is a 10 + text ,,fn ColorYellow + Print + + WantsCard = RequestedCard + + if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" + if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" + if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" + if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" + if WantsCard = "0" then WantsCard = "10" + + print "-------------------------------------" + print + str255 AorAn + AorAn = "a" + if WantsCard = "Ace" then AorAn = "an" + print YourName + " asked For " + AorAn + " " + WantsCard + print + text ,,fn ColorWhite + + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + + if RequestedCard = "X" || RequestedCard = "x" then fn QuitOrResumeAlert(@"EXIT") + + If RequestedCard <> "" Then CardNumber = Instr$(1,cards, Ucase$(RequestedCard)): RequestCard = _true + + If CardNumber = 0 + text,,fn ColorRed + Print "Sorry, that is not a valid card.": RequestCard = _false + print + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + Else if play(CardNumber) = 0 Then text ,,fn colorRed: Print "You don//t have that card!": text ,,fn colorRed: RequestCard = _false + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + text,,fn ColorWhite + + End If + + Wend + + guess(CardNumber) = 1 + + If Computer(CardNumber) = 0 + Print Someone + ","; + text ,,fn colorRed + Print " Go fish!" + text ,,fn colorWhite + Print Someone + " got a";: fn youGoFishing + print + fn CheckForCompletedBook + ShowHand = _true + Else + v = Computer(CardNumber) + Computer(CardNumber) = 0 + play(CardNumber) += v + if v > 1 then AddTheS = "s" else AddTheS = "" + Print Someone + " got" + str$(v) + " card" + AddTheS + fn CheckForCompletedBook + fn PrintViewScrollToBottom( fn WindowPrintView(1)) + ShowHand = _false + End If + +Wend + + + +Someone = "CPU" +For i = 1 To 13 + asked(i) = 0 +Next i + +bool CPUsTurn = _false + +While CPUsTurn = _false + if fn CheckForEndGame = _True then cls:fn InitCards:goto "Loop" + + po = 0 + For i = 1 To 13 + If (Computer(i) > 0) && (guess(i) > 0) Then poss(i) = 1: po += 1 + Next i + + short whilecounter + WhileCounter = 0 + + + If po = 0 + // this k is the go fish card. + + k = rnd(12) +1 + while Computer(k) = 0 || asked(k) + whilecounter ++ + k = rnd(12) +1 + if WhileCounter > 100 then k = 0: exit while //5/5/24 Rich added this to prevent hangs + wend + + Else + + k = rnd(12) + 1 + while poss(k) = 0 + k = rnd(12) + 1 + if WhileCounter > 100 then k = 0: exit while //5/5/24 Rich added this to prevent hangs + wend + + guess(k) = 0 + asked(k) = 1 + + end if + + + if k = 0 then "Loop" //5/5/24 Rich added this to prevent hangs + + WantsCard = fn CheckForFaceCard(k) + + if WantsCard = "j" || WantsCard = "J" then WantsCard = "Jack" + if WantsCard = "q" || WantsCard = "Q" then WantsCard = "Queen" + if WantsCard = "k" || WantsCard = "K" then WantsCard = "King" + if WantsCard = "a" || WantsCard = "A" then WantsCard = "Ace" + if WantsCard = "0" then WantsCard = "10" + + text ,,fn ColorOrange + + print "-------------------------------------" + + + + Print:Print Someone + " wants your " + wantsCard + "'s." + print + + text ,,fn ColorWhite + + asked(k) = 1 + + + If play(k) = 0 + Print Someone + ", "; + text ,,fn colorRed: Print "go fish!" + text ,,fn colorWhite:Print Someone + " got";: fn cpuGoFishing + + fn CheckCPUForCompletedBook + CPUsTurn = _true + + Else + + v = play(k) + play(k) = 0 + Computer(k) += v + if v > 1 then AddTheS = "s" else AddTheS = "" + Print Someone + " got" + str$(v) + " card" + AddTheS + fn CheckCPUForCompletedBook + CPUsTurn = _false + End If + + +Wend + +"Loop" +goto "Main" + +handleevents diff --git a/Task/Golden-ratio-Convergence/R/golden-ratio-convergence.r b/Task/Golden-ratio-Convergence/R/golden-ratio-convergence.r new file mode 100644 index 0000000000..602f93267d --- /dev/null +++ b/Task/Golden-ratio-Convergence/R/golden-ratio-convergence.r @@ -0,0 +1,8 @@ +phi <- c(1, 1+1/1) + +while (abs(phi[length(phi)]-phi[length(phi)-1])>10**-5){ +phi <- c(phi, 1+1/phi[length(phi)]) +} + +print(paste("Result : ", phi[length(phi)], " after ", length(phi)-1 , "iterations.")) +print(paste("Error is approximately : ", phi[length(phi)]-(1+sqrt(5))/2 )) diff --git a/Task/Graph-colouring/Jq/graph-colouring.jq b/Task/Graph-colouring/Jq/graph-colouring.jq new file mode 100644 index 0000000000..fa4dfa15df --- /dev/null +++ b/Task/Graph-colouring/Jq/graph-colouring.jq @@ -0,0 +1,100 @@ +# Add a single edge assuming it is not already there +# Input: a JSON object with at least the key .start +def addEdge($n1; $n2): + # adjust to starting node number + ($n1 - .start) as $n1 + | ($n2 - .start) as $n2 + | .nbr[$n1] += [$n2] + | if $n1 != $n2 then .nbr[$n2] += [$n1] end ; + +# Build a Graph object from $start and $edges assuming there are no isolated edges +def Graph($start; $edges): + ([$edges[][]] | unique | length) as $nns + | {$start, # node numbering starts from $start + $nns, # number of nodes + $edges, # array of edges + nbr: [range(0;$nns) | [] ] # .nbr[$i] will be the array of neighbors of node $i + } + | reduce $edges[] as $e (.; addEdge($e[0]; $e[1])); + +# Use greedy algorithm +def greedyColoring: + # create a list with a color for each node + .cols = [range(0; .nns) | -1] # -1 denotes no color assigned + | .cols[0] = 0 # first node assigned color 0 + # create a bool list to keep track of which colors are available + | .available = [range(0; .nns) | false] + # assign colors to all nodes after the first + | reduce range(1; .nns) as $i (.; + # iterate through neighbors and mark their colors as available + reduce .nbr[$i][] as $j (.; + if .cols[$j] != -1 then .available[.cols[$j]] = true end ) + # find the first available color + | (.available | index(false)) as $c + | if $c + then .cols[$i] = $c # assign it to the current node + # reset the colors of the neighbors to unavailable + # before the next iteration + | reduce .nbr[$i][] as $j (.; + if (.cols[$j] != -1) then .available[.cols[$j]] = false end ) + else debug("greedyColoring unexpectedly did not find 'false'") + end ) + | .cols; + +# (n)umber of node and its (v)alence i.e. number of neighbors +def NodeVal($n; $v): {$n, $v}; + + +### Example graphs + +def Graph1: + {start: 0, + edges: [[0, 1], [1, 2], [2, 0], [3, 3]]} ; + +def Graph2: + {start: 1, + edges: + [[1, 6], [1, 7], [1, 8], [2, 5], [2, 7], [2, 8], + [3, 5], [3, 6], [3, 8], [4, 5], [4, 6], [4, 7]] }; + +def Graph3: + {start: 1, + edges: + [[1, 4], [1, 6], [1, 8], [3, 2], [3, 6], [3, 8], + [5, 2], [5, 4], [5, 8], [7, 2], [7, 4], [7, 6]] }; + +def Graph4: + {start: 1, + edges: + [[1, 6], [7, 1], [8, 1], [5, 2], [2, 7], [2, 8], + [3, 5], [6, 3], [3, 8], [4, 5], [4, 6], [4, 7]] }; + +# Use `Function` to find a coloring for each of the examples given as an array: +def task(Function): + . as $examples + | length as $n + | range(0; $n) as $i + | $examples[$i] as $g + | "\nExample \($i+1)", + ( $g + | Graph( .start; .edges ) + | Function as $cols + | .ecount = 0 # counts edges + | .emit = null + | reduce .edges[] as $e (.; + if ($e[0] != $e[1]) + then .emit += " Edge \($e[0])-\($e[1]) -> Color \($cols[$e[0] - .start]), \($cols[$e[1] - .start])\n" + | .ecount += 1 + else .emit += " Node \($e[0]) -> Color \($cols[$e[0] - .start])\n" + end) + | .emit, + (reduce $cols[] as $col (.maxCol = 0; # maximum color number used + if ($col > .maxCol) then .maxCol = $col end) + | + " Number of nodes : \(.nns)", + " Number of edges : \(.ecount)", + " Number of colors : \(.maxCol+1)" + ) ) ; + +"Using the greedyColoring algorithm", +([Graph1, Graph2, Graph3, Graph4] | task(greedyColoring)) diff --git a/Task/Gray-code/FreeBASIC/gray-code.basic b/Task/Gray-code/FreeBASIC/gray-code.basic index 95722fd32a..54d111804c 100644 --- a/Task/Gray-code/FreeBASIC/gray-code.basic +++ b/Task/Gray-code/FreeBASIC/gray-code.basic @@ -2,31 +2,23 @@ ' compile with: fbc -s console Function gray2bin(g As UInteger) As UInteger - Dim As UInteger b = g - While g g Shr= 1 b Xor= g Wend - Return b - End Function Function bin2gray(b As UInteger) As UInteger - Return b Xor (b Shr 1) - End Function ' ------=< MAIN >=------ Dim As UInteger i - Print " i binary gray gra2bin" Print String(32,"=") - For i = 0 To 31 Print Using "## --> "; i; print Bin(i,5); " --> "; diff --git a/Task/Gray-code/BASIC/gray-code.basic b/Task/Gray-code/GW-BASIC/gray-code.basic similarity index 100% rename from Task/Gray-code/BASIC/gray-code.basic rename to Task/Gray-code/GW-BASIC/gray-code.basic diff --git a/Task/Gray-code/Liberty-BASIC/gray-code.basic b/Task/Gray-code/Liberty-BASIC/gray-code.basic index 14888831e6..44f2129ea9 100644 --- a/Task/Gray-code/Liberty-BASIC/gray-code.basic +++ b/Task/Gray-code/Liberty-BASIC/gray-code.basic @@ -7,7 +7,6 @@ B$ =Gray2Bin$( G$) print B$; " in pure binary." next r - end function Bin2Gray$( bin$) ' Given a binary number as a string, returns Gray code as a string. diff --git a/Task/Gray-code/Modula-2/gray-code.mod2 b/Task/Gray-code/Modula-2/gray-code.mod2 new file mode 100644 index 0000000000..135aaa93e7 --- /dev/null +++ b/Task/Gray-code/Modula-2/gray-code.mod2 @@ -0,0 +1,57 @@ +MODULE GrayCode; + +FROM STextIO IMPORT + WriteString, WriteLn; +FROM SWholeIO IMPORT + WriteInt; +FROM Conversions IMPORT + LongBaseToStr; +FROM FormatString IMPORT + FormatString; (* for justifying *) + +VAR + I, G, D: CARDINAL; + Ok: BOOLEAN; + BinS, OutBinS: ARRAY[0 .. 5] OF CHAR; + +PROCEDURE Encode(V: CARDINAL): CARDINAL; +BEGIN + RETURN V BXOR (V SHR 1) +END Encode; + +PROCEDURE Decode(V: CARDINAL): CARDINAL; +VAR + Result: CARDINAL; +BEGIN + Result := 0; + WHILE V > 0 DO + Result := Result BXOR V; + V := V SHR 1 + END; + RETURN Result +END Decode; + +BEGIN + WriteString("decimal binary gray decoded"); + WriteLn; + FOR I := 0 TO 31 DO + G := Encode(I); + D := Decode(G); + WriteInt(I, 4); + WriteString(" "); + Ok := LongBaseToStr(I, 2, BinS); + Ok := FormatString("%'05s", OutBinS, BinS); + (* Padded with 0; width: 5; type: string *) + WriteString(OutBinS); + WriteString(" "); + Ok := LongBaseToStr(G, 2, BinS); + Ok := FormatString("%'05s", OutBinS, BinS); + WriteString(OutBinS); + WriteString(" "); + Ok := LongBaseToStr(D, 2, BinS); + Ok := FormatString("%'05s", OutBinS, BinS); + WriteString(OutBinS); + WriteInt(D, 4); + WriteLn; + END +END GrayCode. diff --git a/Task/Grayscale-image/11l/grayscale-image.11l b/Task/Grayscale-image/11l/grayscale-image.11l index 2d3c981e9e..3f4f195f10 100644 --- a/Task/Grayscale-image/11l/grayscale-image.11l +++ b/Task/Grayscale-image/11l/grayscale-image.11l @@ -1,13 +1,4 @@ -T Colour - Byte r, g, b - - F (r, g, b) - .r = r - .g = g - .b = b - - F ==(other) - R .r == other.r & .g == other.g & .b == other.b +T Colour = BVec3 V black = Colour(0, 0, 0) V white = Colour(255, 255, 255) diff --git a/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas b/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas new file mode 100644 index 0000000000..7457c48563 --- /dev/null +++ b/Task/Greatest-common-divisor/PascalABC.NET/greatest-common-divisor.pas @@ -0,0 +1,18 @@ +function GCD(a,b: integer): integer; +begin + while b > 0 do + (a,b) := (b,a mod b); + Result := a; +end; + +function GCDRec(a,b: integer): integer; +begin + if b = 0 then + Result := a + else Result := GCDRec(b, a mod b); +end; + +begin + Println(GCD(72,30),GCDRec(72,30)); + Println(GCD(49865, 69811),GCDRec(49865, 69811)); +end. diff --git a/Task/Greatest-common-divisor/TypeScript/greatest-common-divisor-3.ts b/Task/Greatest-common-divisor/Uiua/greatest-common-divisor.uiua similarity index 100% rename from Task/Greatest-common-divisor/TypeScript/greatest-common-divisor-3.ts rename to Task/Greatest-common-divisor/Uiua/greatest-common-divisor.uiua diff --git a/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy b/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy new file mode 100644 index 0000000000..acb989f2c7 --- /dev/null +++ b/Task/Greatest-subsequential-sum/EasyLang/greatest-subsequential-sum.easy @@ -0,0 +1,23 @@ +proc max_subseq . seq[] start stop maxsum . + maxsum = 0 + i = 1 + start = 1 + stop = 0 + for j to len seq[] + sum += seq[j] + if sum < 0 + i = j + 1 + sum = 0 + elif sum > maxsum + start = i + stop = j + maxsum = sum + . + . +. +a[] = [ -1 -2 3 5 6 -2 -1 4 -4 2 -1 ] +max_subseq a[] a b sum +print "Max sum = " & sum +for i = a to b + write a[i] & " " +. diff --git a/Task/Guess-the-number-With-feedback-player-/EasyLang/guess-the-number-with-feedback-player-.easy b/Task/Guess-the-number-With-feedback-player-/EasyLang/guess-the-number-with-feedback-player-.easy new file mode 100644 index 0000000000..b22b0d8067 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player-/EasyLang/guess-the-number-with-feedback-player-.easy @@ -0,0 +1,21 @@ +min = 1 +max = 100 +print "Think of a number between " & min & " and " & max +print "I will try to guess your number." +repeat + guess = (min + max) div 2 + print "My guess is " & guess + write "Is it higher than, lower than or equal to your number? " + answer$ = input + print answer$ + ans$ = substr answer$ 1 1 + until ans$ = "e" + if ans$ = "l" + min = guess + 1 + elif ans$ = "h" + max = guess - 1 + else + print "Sorry, i didn't understand your answer." + . +. +print "Goodbye." diff --git a/Task/Guess-the-number/Langur/guess-the-number.langur b/Task/Guess-the-number/Langur/guess-the-number.langur index 236a07c78b..fe84301d0f 100644 --- a/Task/Guess-the-number/Langur/guess-the-number.langur +++ b/Task/Guess-the-number/Langur/guess-the-number.langur @@ -1,13 +1,13 @@ writeln "Guess a number from 1 to 10" -val .n = string random 10 +val n = string(random(10)) for { - val .guess = read ">> ", RE/^0*(?:[1-9]|10)(?:\.0+)?$/, "bad data\n", 7, "" - if .guess == "" { + val guess = read(">> ", RE/^0*(?:[1-9]|10)(?:\.0+)?$/, "bad data\n", 7, "") + if guess == "" { writeln "too much bad data" break } - if .guess == .n { + if guess == n { writeln "That's it." break } diff --git a/Task/Guess-the-number/PascalABC.NET/guess-the-number.pas b/Task/Guess-the-number/PascalABC.NET/guess-the-number.pas new file mode 100644 index 0000000000..454da1cca8 --- /dev/null +++ b/Task/Guess-the-number/PascalABC.NET/guess-the-number.pas @@ -0,0 +1,13 @@ +begin + var randomNumber := Random(1..10); + Println('I''m thinking of a number between 1 and 10. Can you guess it?'); + while True do + begin + Print('Guess:'); + var x := ReadlnInteger; + if x = randomNumber then + break; + Println('That''s not it. Guess again.'); + end; + Println('Congrats!! You guessed right!6'); +end. diff --git a/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy b/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy new file mode 100644 index 0000000000..cb387a3101 --- /dev/null +++ b/Task/Halt-and-catch-fire/EasyLang/halt-and-catch-fire.easy @@ -0,0 +1,2 @@ +a[] = [ ] +print a[1] diff --git a/Task/Hamming-numbers/EasyLang/hamming-numbers.easy b/Task/Hamming-numbers/EasyLang/hamming-numbers.easy new file mode 100644 index 0000000000..5f54b97603 --- /dev/null +++ b/Task/Hamming-numbers/EasyLang/hamming-numbers.easy @@ -0,0 +1,27 @@ +func hamming lim . + len h[] lim + h[1] = 1 + x2 = 2 ; x3 = 3 ; x5 = 5 + i = 1 ; j = 1 ; k = 1 + for n = 2 to lim + h[n] = lower x2 lower x3 x5 + if x2 = h[n] + i += 1 + x2 = 2 * h[i] + . + if x3 = h[n] + j += 1 + x3 = 3 * h[j] + . + if x5 = h[n] + k += 1 + x5 = 5 * h[k] + . + . + return h[lim] +. +for nr = 1 to 20 + write hamming nr & " " +. +print "" +print hamming 1691 diff --git a/Task/Harmonic-series/Bruijn/harmonic-series.bruijn b/Task/Harmonic-series/Bruijn/harmonic-series.bruijn new file mode 100644 index 0000000000..747d370e68 --- /dev/null +++ b/Task/Harmonic-series/Bruijn/harmonic-series.bruijn @@ -0,0 +1,16 @@ +:import std/List . +:import std/Combinator . +:import std/Math/Rational Q +:import std/Number N + +# fun Church iteration hack +harmonic [0 &[[(Q.add 1 op) : N.++0]] start [[1]]] ⧗ Unary → Rational + op (+1) : N.--0 + start (+0.0f) : (+1) + +custom-gt? &[[[N.gt? 2 (N.mul 0 N.++1)]]] ⧗ Rational → Νumber → Boolean + +main [φ cons first-20 first-10-above (harmonic <$> (iterate [[[1 (2 1 0)]]] (+0u)))] + first-20 take (+20) + first-10-above [take (+10) first-above] + first-above [find-index [custom-gt? 0 1] 1] <$> (iterate N.inc (+0)) diff --git a/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-1.langur b/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-1.langur index 3c66fddceb..2091d73583 100644 --- a/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-1.langur +++ b/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-1.langur @@ -1 +1 @@ -writeln(hash fw/a b c d/, [1, 2, 3, 4]) +writeln hash(fw/a b c d/, [1, 2, 3, 4]) diff --git a/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-2.langur b/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-2.langur index a638f45f67..02fa5dea1e 100644 --- a/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-2.langur +++ b/Task/Hash-from-two-arrays/Langur/hash-from-two-arrays-2.langur @@ -1,6 +1,5 @@ -val .new = foldfrom( - fn(.hash, .key, .value) more .hash, h{.key: .value}, - h{}, fw/a b c d/, [1, 2, 3, 4], +val new = foldfrom( + fn h, key, value:more(h, {key: value}), + {:}, fw/a b c d/, [1, 2, 3, 4], ) - -writeln .new +writeln new diff --git a/Task/Hash-from-two-arrays/PascalABC.NET/hash-from-two-arrays.pas b/Task/Hash-from-two-arrays/PascalABC.NET/hash-from-two-arrays.pas new file mode 100644 index 0000000000..20f1a2c478 --- /dev/null +++ b/Task/Hash-from-two-arrays/PascalABC.NET/hash-from-two-arrays.pas @@ -0,0 +1,6 @@ +begin + var Keys := Arr('aa','bb','cc'); + var Values := Arr(1..3); + var dct := Dict(Keys.Zip(Values)); + dct.Println; +end. diff --git a/Task/Hello-world-Graphical/AutoHotKey-V2/hello-world-graphical.ahk b/Task/Hello-world-Graphical/Autohotkey-V2/hello-world-graphical.ahk similarity index 100% rename from Task/Hello-world-Graphical/AutoHotKey-V2/hello-world-graphical.ahk rename to Task/Hello-world-Graphical/Autohotkey-V2/hello-world-graphical.ahk diff --git a/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-1.vim b/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-1.vim new file mode 100644 index 0000000000..0c12485895 --- /dev/null +++ b/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-1.vim @@ -0,0 +1 @@ +:call popup_notification("Hello world", {}) diff --git a/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-2.vim b/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-2.vim new file mode 100644 index 0000000000..0f6224a5a4 --- /dev/null +++ b/Task/Hello-world-Graphical/Vim-Script/hello-world-graphical-2.vim @@ -0,0 +1 @@ +:echow "Hello world" diff --git a/Task/Hello-world-Line-printer/PascalABC.NET/hello-world-line-printer.pas b/Task/Hello-world-Line-printer/PascalABC.NET/hello-world-line-printer.pas new file mode 100644 index 0000000000..6d74b7d4b5 --- /dev/null +++ b/Task/Hello-world-Line-printer/PascalABC.NET/hello-world-line-printer.pas @@ -0,0 +1,12 @@ +{$reference 'System.Drawing.dll'} + +uses System.Drawing; +uses System.Drawing.Printing; + +begin + var doc := new PrintDocument(); + doc.PrintPage += (s,e) -> begin + e.Graphics.DrawString('Hello World!', new Font('Arial', 14), Brushes.Black, 0, 0); + end; + doc.Print; +end. diff --git a/Task/Hello-world-Newline-omission/PascalABC.NET/hello-world-newline-omission.pas b/Task/Hello-world-Newline-omission/PascalABC.NET/hello-world-newline-omission.pas new file mode 100644 index 0000000000..70fe199707 --- /dev/null +++ b/Task/Hello-world-Newline-omission/PascalABC.NET/hello-world-newline-omission.pas @@ -0,0 +1,2 @@ +## +Write('Goodbye, World!'); diff --git a/Task/Hello-world-Standard-error/PascalABC.NET/hello-world-standard-error.pas b/Task/Hello-world-Standard-error/PascalABC.NET/hello-world-standard-error.pas new file mode 100644 index 0000000000..44d1e224dd --- /dev/null +++ b/Task/Hello-world-Standard-error/PascalABC.NET/hello-world-standard-error.pas @@ -0,0 +1,2 @@ +## +Console.Error.WriteLine('Goodbye, World!'); diff --git a/Task/Hello-world-Text/PascalABC.NET/hello-world-text.pas b/Task/Hello-world-Text/PascalABC.NET/hello-world-text-1.pas similarity index 100% rename from Task/Hello-world-Text/PascalABC.NET/hello-world-text.pas rename to Task/Hello-world-Text/PascalABC.NET/hello-world-text-1.pas diff --git a/Task/Hello-world-Text/PascalABC.NET/hello-world-text-2.pas b/Task/Hello-world-Text/PascalABC.NET/hello-world-text-2.pas new file mode 100644 index 0000000000..609ebe662f --- /dev/null +++ b/Task/Hello-world-Text/PascalABC.NET/hello-world-text-2.pas @@ -0,0 +1,4 @@ +program HelloWorld; +begin + writeln('Hello World!'); +end. diff --git a/Task/Hello-world-Text/PascalABC.NET/hello-world-text-3.pas b/Task/Hello-world-Text/PascalABC.NET/hello-world-text-3.pas new file mode 100644 index 0000000000..858e451b6c --- /dev/null +++ b/Task/Hello-world-Text/PascalABC.NET/hello-world-text-3.pas @@ -0,0 +1,2 @@ +## +println('Hello World!'); diff --git a/Task/Here-document/Langur/here-document-1.langur b/Task/Here-document/Langur/here-document-1.langur index 1c58f00525..a44fa5c4c8 100644 --- a/Task/Here-document/Langur/here-document-1.langur +++ b/Task/Here-document/Langur/here-document-1.langur @@ -1,4 +1,4 @@ -val .s = qs:block END +val s = qs:block END We put our text here. Here we are, Doc. END diff --git a/Task/Here-document/Langur/here-document-2.langur b/Task/Here-document/Langur/here-document-2.langur index 779240b08a..750f6d00f9 100644 --- a/Task/Here-document/Langur/here-document-2.langur +++ b/Task/Here-document/Langur/here-document-2.langur @@ -1,4 +1,4 @@ -val .s = qs:lead:block END +val s = qs:lead:block END We put our text here. Here we are, Doc. END diff --git a/Task/Here-document/Langur/here-document-3.langur b/Task/Here-document/Langur/here-document-3.langur index d576eaddd9..d90990f75e 100644 --- a/Task/Here-document/Langur/here-document-3.langur +++ b/Task/Here-document/Langur/here-document-3.langur @@ -1,4 +1,4 @@ -val .re = re:block END +val r = re:block END a regex pattern here Still here, Doc. END diff --git a/Task/Here-document/Langur/here-document-4.langur b/Task/Here-document/Langur/here-document-4.langur index 150246b3d6..4aab9b4c7f 100644 --- a/Task/Here-document/Langur/here-document-4.langur +++ b/Task/Here-document/Langur/here-document-4.langur @@ -1,4 +1,4 @@ -val .re = re:x:block END +val r = re:x:block END a free-spacing regex pattern here Somewhere, Doc. END diff --git a/Task/Here-document/Vim-Script/here-document-1.vim b/Task/Here-document/Vim-Script/here-document-1.vim new file mode 100644 index 0000000000..1c51292a24 --- /dev/null +++ b/Task/Here-document/Vim-Script/here-document-1.vim @@ -0,0 +1,5 @@ +let hw =<< END +Hello + World +END +echo join(hw, "\n") diff --git a/Task/Here-document/Vim-Script/here-document-2.vim b/Task/Here-document/Vim-Script/here-document-2.vim new file mode 100644 index 0000000000..69a9eb10fe --- /dev/null +++ b/Task/Here-document/Vim-Script/here-document-2.vim @@ -0,0 +1,6 @@ +let d58 = "5 6 7 8" +let d =<< eval DOZEN + 1 2 3 4 {d58} + 9 10 11 12 +DOZEN +call append(line('$'), d) diff --git a/Task/Hex-words/Ada/hex-words.ada b/Task/Hex-words/Ada/hex-words.ada new file mode 100644 index 0000000000..a6fca096c0 --- /dev/null +++ b/Task/Hex-words/Ada/hex-words.ada @@ -0,0 +1,149 @@ +-- Hex Words: find words of 4 or more characters, all characters of which are hex digits +-- J. Carter 2024 May + +with Ada.Characters.Handling; +with Ada.Containers.Vectors; +with Ada.Strings.Unbounded; +with Ada.Text_IO; + +procedure Hex_Words is + use Ada.Strings.Unbounded; + + subtype Hex_Digit is Character range 'a' .. 'f'; + subtype Digit_Value is Integer range 0 .. 9; + + function Hex_Word (Line : in String) return Boolean is + (Line'Length > 3 and (for all C of Line => C in Hex_Digit) ); + + function Digital_Root (Number : in Natural) return Digit_Value; + -- Returns the decimal digital root of Number + + function Four_Distinct (Word : in String) return Boolean with + Pre => Hex_Word (Word); + -- Returns True if Word has at least 4 distinct letters; False otherwise + + function Image (Number : in Natural) return String with + Post => Image'Result'Length = 9; + -- Returns the blank-filled decimal image of Number + + type Word_Info is record + Word : Unbounded_String; + Value : Natural; + Root : Digit_Value; + end record; + + function Root_Less (Left : in Word_Info; Right : in Word_Info) return Boolean is + (if Left.Root /= Right.Root then Left.Root < Right.Root else Left.Word < Right.Word); + + function Value_Greater (Left : in Word_Info; Right : in Word_Info) return Boolean is + (if Left.Value /= Right.Value then Left.Value > Right.Value else Left.Word < Right.Word); + + package Word_Lists is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Word_Info); + + package Root_Sorting is new Word_Lists.Generic_Sorting ("<" => Root_Less); + package Value_Sorting is new Word_Lists.Generic_Sorting ("<" => Value_Greater); + + function Digital_Root (Number : in Natural) return Digit_Value is + function Digit_Sum return Natural; + -- Sums the digits of the decimal representation of Number + + function Digit_Sum return Natural is + Image : constant String := Number'Image; + + Sum : Natural := 0; + begin -- Digit_Sum + All_Digits : for I in 2 .. Image'Last loop + Sum := Sum + Character'Pos (Image (I) ) - Character'Pos ('0'); + end loop All_Digits; + + return Sum; + end Digit_Sum; + + Sum : Natural := Digit_Sum; + begin -- Digital_Root + if Sum in Digit_Value then + return Sum; + end if; + + return Digital_Root (Sum); + end Digital_Root; + + function Four_Distinct (Word : in String) return Boolean is + type Hex_Set is array (Hex_Digit) of Boolean; + + Set : Hex_Set := (others => False); + Count : Natural := 0; + begin -- Four_Distinct + Check_All : for C of Word loop + Set (C) := True; + end loop Check_All; + + Count_Them : for B of Set loop + if B then + Count := Count + 1; + end if; + end loop Count_Them; + + return Count > 3; + end Four_Distinct; + + function Image (Number : in Natural) return String is + Result : constant String := Number'Image; + begin -- Image + return (1 .. 9 - Result'Length => ' ') & Result; + end Image; + + Input : Ada.Text_IO.File_Type; + Info : Word_Info; + Word : Word_Lists.Vector; + Distinct : Word_Lists.Vector; +begin -- Hex_Words + Ada.Text_IO.Open (File => Input, Mode => Ada.Text_IO.In_File, Name => "unixdict.txt"); + + All_Words : loop + exit All_Words when Ada.Text_IO.End_Of_File (Input); + + One_Word : declare + Line : constant String := Ada.Characters.Handling.To_Lower (Ada.Text_IO.Get_Line (Input) ); + begin -- One_Word + if Hex_Word (Line) then + Info.Word := To_Unbounded_String (Line); + Info.Value := Integer'Value ("16#" & Line & '#'); + Info.Root := Digital_Root (Info.Value); + Word.Append (New_Item => Info); + + if Four_Distinct (Line) then + Distinct.Append (New_Item => Info); + end if; + end if; + end One_Word; + end loop All_Words; + + Ada.Text_IO.Close (File => Input); + + Root_Sorting.Sort (Container => Word); + Value_Sorting.Sort (Container => Distinct); + + Print_All : for I in 1 .. Word.Last_Index loop + Print_One : declare + Info : Word_Info renames Word.Element (I); + begin -- Print_One + Ada.Text_IO.Put_Line + (Item => To_String (Info.Word) & (1 .. 6 - Length (Info.Word) => ' ') & Image (Info.Value) & Info.Root'Image); + end Print_One; + end loop Print_All; + + Ada.Text_IO.Put_Line (Item => Word.Last_Index'Image & " total words"); + Ada.Text_IO.New_Line; + + Output_Distinct : for I in 1 ..Distinct.Last_Index loop + One_Distinct : declare + Info : Word_Info renames Distinct.Element (I); + begin -- One_Distinct + Ada.Text_IO.Put_Line + (Item => To_String (Info.Word) & (1 .. 6 - Length (Info.Word) => ' ') & Image (Info.Value) & Info.Root'Image); + end One_Distinct; + end loop Output_Distinct; + + Ada.Text_IO.Put_Line (Item => Distinct.Last_Index'Image & " words with 4 or more distinct letters"); +end Hex_Words; diff --git a/Task/Hofstadter-Figure-Figure-sequences/EasyLang/hofstadter-figure-figure-sequences.easy b/Task/Hofstadter-Figure-Figure-sequences/EasyLang/hofstadter-figure-figure-sequences.easy new file mode 100644 index 0000000000..5cd6bf9baf --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/EasyLang/hofstadter-figure-figure-sequences.easy @@ -0,0 +1,47 @@ +global rs[] ss[] . +procdecl RS_append . . +func R n . + while n > len rs[] + RS_append + . + return rs[n] +. +func S n . + while n > len ss[] + RS_append + . + return ss[n] +. +proc RS_append . . + n = len rs[] + r = R n + S n + s = S len ss[] + rs[] &= r + repeat + s += 1 + until s = r + ss[] &= s + . + ss[] &= r + 1 +. +rs[] = [ 1 ] +ss[] = [ 2 ] +write "R(1 .. 10): " +for i to 10 + write R i & " " +. +print "" +len seen[] 1000 +for i to 40 + seen[R i] = 1 +. +for i to 960 + seen[S i] = 1 +. +for i to 1000 + if seen[i] = 0 + print i & " not seen" + return + . +. +print "first 1000 ok" diff --git a/Task/Honeycombs/FutureBasic/honeycombs.basic b/Task/Honeycombs/FutureBasic/honeycombs.basic new file mode 100644 index 0000000000..ee756dca3e --- /dev/null +++ b/Task/Honeycombs/FutureBasic/honeycombs.basic @@ -0,0 +1,115 @@ +void local fn BuildWindow + long tag, index + CFStringRef title + CFMutableStringRef letters = fn MutableStringWithString( @"ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) + + window 1, @"Honeycombs", (0,0,419,443), NSWindowStyleMaskTitled + WindowSetBackgroundColor( 1, fn ColorWhite ) + + CGrect r = {20,339,95,85} + for tag = 1 to 20 + subclass button tag,,, @"", r,, NSBezelStyleSmallSquare + index = rnd(len(letters)-1) + title = mid(letters,index,1) + ButtonSetTitle( tag, title ) + ButtonSetKeyEquivalent( tag, lcase(title) ) + MutableStringDeleteCharacters( letters, fn RangeMake( index, 1 ) ) + ButtonSetTransparent( tag, YES ) + r = fn CGRectOffset( r, 0, -82 ) + if ( tag mod 4 == 0 ) + r.origin.x += 71 + if ( r.origin.y < -21.0 ) + r.origin.y = 339 + else + r.origin.y = 298 + end if + end if + next + + textlabel 21,, (18,20,383,24) + ControlSetFont( 21, fn FontSystemFontOfSize(20) ) + ControlSetAlignment( 21, NSTextAlignmentCenter ) +end fn + +void local fn ViewDrawRect( tag as long ) + CGRect r = fn ViewBounds( tag ) + ColorRef titleColor, fillColor + + if ( fn ControlIsEnabled( tag ) ) + titleColor = fn ColorRed + fillColor = fn ColorYellow + else + titleColor = fn ColorBlack + fillColor = fn ColorMagenta + end if + + BezierPathRef path = fn BezierPathInit + BezierPathSetLineWidth( path, 5.0 ) + BezierpathSetLineCapStyle( path, NSRoundLineCapStyle ) + + CGPoint pt = {0,41} + BezierPathMoveToPoint( path, pt ) + + pt.x += 23.67 : pt.y += 41 + BezierPathLineToPoint( path, pt ) + + pt.x += 47.34 + BezierPathLineToPoint( path, pt ) + + pt.x += 23.67 : pt.y -= 41 + BezierPathLineToPoint( path, pt ) + + pt.x -= 23.67 : pt.y -= 41 + BezierPathLineToPoint( path, pt ) + + pt.x -= 47.34 + BezierPathLineToPoint( path, pt ) + + pt.x -= 23.67 : pt.y += 41 + BezierPathLineToPoint( path, pt ) + + ColorSet( fillColor ) + BezierPathFill( path ) + + ColorSet( fn ColorBlack ) + BezierPathStroke( path ) + + CFStringRef title = fn ButtonTitle( tag ) + CFDictionaryRef attrs = @{ + NSFontAttributeName:fn FontWithName( @"Helvetica-Bold", 52), + NSForegroundColorAttributeName:titleColor} + + CFMutableAttributedStringRef aString = fn MutableAttributedStringWithAttributes( title, attrs ) + MutableAttributedStringSetAlignment( aString, NSTextAlignmentCenter ) + r.origin.y += 10 + AttributedStringDrawInRect( aString, r ) +end fn + +void local fn Finished + long tag + for tag = 1 to 20 + if ( fn ControlIsEnabled( tag ) ) then exit fn + next + end +end fn + +void local fn ButtonAction( tag as long ) + CFStringRef string = fn StringByAppendingString( fn ControlStringValue(21), fn ButtonTitle(tag) ) + ControlSetStringValue( 21, string ) + ControlSetEnabled( tag, NO ) + fn Finished +end fn + +void local fn DoDialog( ev as long, tag as long ) + select ( ev ) + case _btnClick : fn ButtonAction( tag ) + case _viewDrawRect : fn ViewDrawRect( tag ) + end select +end fn + +random +fn BuildWindow + +on Dialog fn DoDialog + +HandleEvents diff --git a/Task/Huffman-coding/11l/huffman-coding.11l b/Task/Huffman-coding/11l/huffman-coding.11l index f8277da1fb..814945f8e7 100644 --- a/Task/Huffman-coding/11l/huffman-coding.11l +++ b/Task/Huffman-coding/11l/huffman-coding.11l @@ -1,11 +1,4 @@ -T Element - Int weight - [(Char, String)] symbols - - F (weight, symbols) - .weight = weight - .symbols = symbols - +T Element((Int weight, [(Char, String)] symbols)) F <(other) R (.weight, .symbols) < (other.weight, other.symbols) diff --git a/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c b/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c new file mode 100644 index 0000000000..79b70d3cf7 --- /dev/null +++ b/Task/Hunt-the-Wumpus/C/hunt-the-wumpus.c @@ -0,0 +1,129 @@ +#include +#include +#include + +#define NUM_ROOMS 20 +#define ARROWS 5 + +typedef enum { false, true } bool; + +typedef struct { + int connected[3]; + bool has_wumpus; + bool has_bat; + bool has_pit; +} Room; + +Room cave[NUM_ROOMS + 1]; // Cave rooms are numbered from 1 to 20 + +void initialize_cave() { + int i, j; + // Initialize cave rooms + for (i = 1; i <= NUM_ROOMS; i++) { + for (j = 0; j < 3; j++) { + cave[i].connected[j] = (i + j) % NUM_ROOMS + 1; // Circular connections + } + cave[i].has_wumpus = false; + cave[i].has_bat = false; + cave[i].has_pit = false; + } + // Randomly place wumpus, bats, and pits + cave[rand() % NUM_ROOMS + 1].has_wumpus = true; + for (i = 0; i < 2; i++) { + cave[rand() % NUM_ROOMS + 1].has_bat = true; + cave[rand() % NUM_ROOMS + 1].has_pit = true; + } +} + +void sense(int room) { + printf("You are in room %d.\n", room); + int i, adjacent_room; + for (i = 0; i < 3; i++) { + adjacent_room = cave[room].connected[i]; + if (cave[adjacent_room].has_wumpus) + printf("You smell something terrible nearby.\n"); + if (cave[adjacent_room].has_bat) + printf("You hear a rustling.\n"); + if (cave[adjacent_room].has_pit) + printf("You feel a cold wind blowing from a nearby cavern.\n"); + } +} + +void move(int *room) { + int choice; + printf("Choose an adjacent room to move into: "); + scanf("%d", &choice); + if (choice < 1 || choice > 3) { + printf("Invalid choice. Please choose a number between 1 and 3.\n"); + move(room); + return; + } + *room = cave[*room].connected[choice - 1]; +} + +void shoot(int room, int *arrows, bool *game_over) { + int choice, adjacent_room; + printf("Choose an adjacent room to shoot into: "); + scanf("%d", &choice); + if (choice < 1 || choice > 3) { + printf("Invalid choice. Please choose a number between 1 and 3.\n"); + shoot(room, arrows, game_over); + return; + } + adjacent_room = cave[room].connected[choice - 1]; + if (cave[adjacent_room].has_wumpus) { + printf("Congratulations! You've killed the Wumpus!\n"); + *game_over = true; + return; + } + else { + if (rand() % 4 != 0) { // 75% chance of waking up the wumpus + if (cave[adjacent_room].has_wumpus) { + printf("The Wumpus has woken up and eaten you!\n"); + *game_over = true; + return; + } + } + printf("You missed! The Wumpus is still asleep.\n"); + } + (*arrows)--; +} + +int main() { + srand(time(NULL)); + initialize_cave(); + int current_room = 1; + int arrows = ARROWS; + bool game_over = false; + + printf("Welcome to Hunt the Wumpus!\n"); + + while (!game_over) { + sense(current_room); + printf("Choose your action:\n"); + printf("1. Move to an adjacent room\n"); + printf("2. Shoot into an adjacent room\n"); + + int choice; + printf("Enter your choice (1 or 2): "); + scanf("%d", &choice); + + switch(choice) { + case 1: + move(¤t_room); + break; + case 2: + if (arrows > 0) { + shoot(current_room, &arrows, &game_over); + } else { + printf("You're out of arrows! You lost the game.\n"); + game_over = true; + } + break; + default: + printf("Invalid choice. Please choose 1 or 2.\n"); + } + } + + return 0; +} diff --git a/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur b/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur new file mode 100644 index 0000000000..3393c6b40c --- /dev/null +++ b/Task/I-before-E-except-after-C/Langur/i-before-e-except-after-c.langur @@ -0,0 +1,24 @@ +val words = split("\n", readfile("./data/unixdict.txt")) -> rest + +val print = impure fn(support, against) { + val ratio = support / against + writeln "{{support}} / {{against}} = {{ratio : r2}}:", (ratio < 2) * " NOT", " PLAUSIBLE" + return if(ratio >= 2: 1; 0) +} + +val ks = fw/ei cei ie cie/ +var cnt = {:} + +for w in words { + for k in ks { + cnt[k; 0] += if(k in w: 1; 0) + } +} + +var support = cnt'ie - cnt'cie +var against = cnt'ei - cnt'cei + +var result = print(support, against) +result += print(cnt'cei, cnt'cie) + +writeln "Overall:", (result < 2) * " NOT", " PLAUSIBLE\n" diff --git a/Task/IBAN/EasyLang/iban.easy b/Task/IBAN/EasyLang/iban.easy new file mode 100644 index 0000000000..20ac406d24 --- /dev/null +++ b/Task/IBAN/EasyLang/iban.easy @@ -0,0 +1,63 @@ +cc$[] = [ "AD" "AE" "AL" "AO" "AT" "AZ" "BA" "BE" "BF" "BG" "BH" "BI" "BJ" "BR" "CG" "CH" "CI" "CM" "CR" "CV" "CY" "CZ" "DE" "DK" "DO" "DZ" "EE" "EG" "ES" "FI" "FO" "FR" "GA" "GB" "GE" "GI" "GL" "GR" "GT" "HR" "HU" "IE" "IL" "IR" "IS" "IT" "JO" "KW" "KZ" "LB" "LI" "LT" "LU" "LV" "MC" "MD" "ME" "MG" "MK" "ML" "MR" "MT" "MU" "MZ" "NL" "NO" "PK" "PL" "PS" "PT" "QA" "RO" "RS" "SA" "SE" "SI" "SK" "SM" "SN" "TN" "TR" "UA" "VG" ] +ln[] = [ 24 23 28 25 20 28 20 16 27 22 22 16 28 29 27 21 28 27 21 25 28 24 22 18 28 24 20 27 24 18 18 27 27 22 22 23 18 27 28 21 28 22 23 26 26 27 30 30 20 28 21 20 20 21 27 24 22 27 19 28 27 31 30 25 18 15 24 28 29 25 29 24 22 24 24 19 24 27 28 24 26 29 24 ] +# +func validcc iban$ . + c$ = substr iban$ 1 2 + for i to len cc$[] + if c$ = cc$[i] + return if len iban$ = ln[i] + . + . + return 0 +. +func mod97 s$ . + while s$ <> "" + h$ = r div 10 + h$ &= r mod 10 + h$ &= substr s$ 1 13 + s$ = substr s$ 14 9999 + r = number h$ mod 97 + . + return r +. +func isvalid hiban$ . + for c$ in strchars hiban$ + c = strcode c$ + if c > 32 + if c >= 97 and c < 122 + c -= 32 + c$ = strchar c + elif c < 48 or c > 57 and c < 65 or c > 90 + return 0 + . + miban$ &= c$ + . + . + if validcc miban$ = 0 + return 0 + . + for c$ in strchars substr miban$ 5 999 & substr miban$ 1 4 + c = strcode c$ + if c >= 65 and c <= 90 + t$ &= (c - 55) div 10 + t$ &= (c - 55) mod 10 + else + t$ &= c$ + . + . + return if mod97 t$ = 1 +. +proc check s$ . . + write s$ & " is " + if isvalid s$ = 1 + print "valid" + else + print "not valid" + . +. +check "GB82 WEST 1234 5698 7654 32" +check "GB82WEST12345698765432" +check "gb82 west 1234 5698 7654 32" +check "GB82 TEST 1234 5698 7654 32" +check "GB82 WEST 1243 5698 7654 32" +check "GB82 west 1243 5698 7654 32" diff --git a/Task/ISBN13-check-digit/Langur/isbn13-check-digit.langur b/Task/ISBN13-check-digit/Langur/isbn13-check-digit.langur index a4415c04d1..d8bb48c1ff 100644 --- a/Task/ISBN13-check-digit/Langur/isbn13-check-digit.langur +++ b/Task/ISBN13-check-digit/Langur/isbn13-check-digit.langur @@ -1,18 +1,18 @@ -val .isbn13checkdigit = fn(var .s) { - .s = replace(.s, RE/[\- ]/) - .s -> re/^[0-9]{13}$/ and - fold(fn{+}, map [_, fn{*3}], s2n .s) div 10 +val isbn13checkdigit = fn(var s) { + s = replace(s, RE/[\- ]/) + s -> re/^[0-9]{13}$/ and + fold(fn{+}, map([_, fn{*3}], s2n(s))) div 10 } -val .tests = h{ +val tests = { "978-0596528126": true, "978-0596528120": false, "978-1788399081": true, "978-1788399083": false, } -for .key of .tests { - val .pass = .isbn13checkdigit(.key) - write .key, ": ", if(.pass: "good"; "bad") - writeln if(.pass == .tests[.key]: ""; " (ISBN-13 CHECK DIGIT TEST FAILED)") +for key of tests { + val pass = isbn13checkdigit(key) + write key, ": ", if(pass: "good"; "bad") + writeln if(pass == tests[key]: ""; " (ISBN-13 CHECK DIGIT TEST FAILED)") } diff --git a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml new file mode 100644 index 0000000000..55acb3f3db --- /dev/null +++ b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-1.ml @@ -0,0 +1,22 @@ +(* these type decorations are optional, you could just as well put: + fun isValidISBN s = +*) +fun isValidISBN (s : string) : bool = + let + val digits = List.filter Char.isDigit (explode s) + val nums = map (fn x => ord x - ord #"0") digits + val len = length nums + fun sumISBN [] = raise Domain + | sumISBN [x] = x + | sumISBN (x1::x2::xs) = x1 + 3*x2 + sumISBN xs + in + len = 13 andalso sumISBN nums mod 10 = 0 + end + +val test = ["978-1734314502", "978-1734314509", + "978-1788399081", "978-1788399083"] + +fun printTest (s : string) : unit = + (print s; print (if isValidISBN s then ": good\n" else ": bad\n")) + +fun main () = app printTest test diff --git a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml similarity index 98% rename from Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml rename to Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml index 14abd4e5fc..c81cfd25c5 100644 --- a/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit.ml +++ b/Task/ISBN13-check-digit/Standard-ML/isbn13-check-digit-2.ml @@ -1,4 +1,4 @@ -local +let fun check (c, p as (m, n)) = if Char.isDigit c then (not m, (if m then 3 * (ord c - 48) else ord c - 48) + n) diff --git a/Task/Identity-matrix/Kotlin/identity-matrix.kotlin b/Task/Identity-matrix/Kotlin/identity-matrix.kotlin index 8e873fc892..4b0278fd6e 100644 --- a/Task/Identity-matrix/Kotlin/identity-matrix.kotlin +++ b/Task/Identity-matrix/Kotlin/identity-matrix.kotlin @@ -1,17 +1,16 @@ -// version 1.0.6 - -fun main(args: Array) { +fun main() { print("Enter size of matrix : ") - val n = readLine()!!.toInt() + val n = readln().toInt() println() - val identity = Array(n) { IntArray(n) } // create n x n matrix of integers - - // enter 1s in diagonal elements - for(i in 0 until n) identity[i][i] = 1 + val identity = Array(n) { i -> + IntArray(n) { j -> + if (i == j) 1 else 0 + } + } // print identity matrix if n <= 40 if (n <= 40) - for (i in 0 until n) println(identity[i].joinToString(" ")) + for (row in identity) println(row.joinToString(" ")) else println("Matrix is too big to display on 80 column console") } diff --git a/Task/Identity-matrix/PascalABC.NET/identity-matrix.pas b/Task/Identity-matrix/PascalABC.NET/identity-matrix.pas new file mode 100644 index 0000000000..ba0f8caad4 --- /dev/null +++ b/Task/Identity-matrix/PascalABC.NET/identity-matrix.pas @@ -0,0 +1,5 @@ +begin + var n := ReadInteger; + var matrix: array [,] of integer := MatrGen(n,n,(i,j) -> i = j ? 1 : 0); + matrix.Println +end. diff --git a/Task/Identity-matrix/Uiua/identity-matrix.uiua b/Task/Identity-matrix/Uiua/identity-matrix.uiua new file mode 100644 index 0000000000..2c76013a8d --- /dev/null +++ b/Task/Identity-matrix/Uiua/identity-matrix.uiua @@ -0,0 +1,2 @@ +IdMatrix ← ⊞=.⇡ +IdMatrix 7 diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.ada b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.ada new file mode 100644 index 0000000000..d2d6842033 --- /dev/null +++ b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Ada/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.ada @@ -0,0 +1,12 @@ +with Ada.Strings.Maps; use Ada.Strings.Maps; +with Ada.Text_IO; + +procedure Show_Valid_Identifiers is + Valid_First_Character : constant Character_Set := To_Set (Ranges => (1 => ('a', 'z'), 2 => ('A', 'Z'))); + Valid_Last_Character : constant Character_Set := Valid_First_Character or To_Set (Ranges => (1 => ('0', '9'))); + Valid_Middle_Character : constant Character_Set := Valid_Last_Character or To_Set ('_'); +begin + Ada.Text_IO.Put_Line ("Valid for the first character: " & String (To_Sequence (Valid_First_Character))); + Ada.Text_IO.Put_Line ("Valid for any middle character: " & String (To_Sequence (Valid_Middle_Character))); + Ada.Text_IO.Put_Line ("Valid for the last character: " & String (To_Sequence (Valid_Last_Character))); +end Show_Valid_Identifiers; diff --git a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren index 381544e810..8e2277f929 100644 --- a/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren +++ b/Task/Idiomatically-determine-all-the-characters-that-can-be-used-for-symbols/Wren/idiomatically-determine-all-the-characters-that-can-be-used-for-symbols.wren @@ -1,3 +1,4 @@ for (i in 97..122) System.write(String.fromByte(i)) for (i in 65..90) System.write(String.fromByte(i)) +for (i in 48..57) System.write(String.fromByte(i)) System.print("_") diff --git a/Task/Im-a-software-engineer-get-me-out-of-here/C++/im-a-software-engineer-get-me-out-of-here.cpp b/Task/Im-a-software-engineer-get-me-out-of-here/C++/im-a-software-engineer-get-me-out-of-here.cpp new file mode 100644 index 0000000000..5a053ff371 --- /dev/null +++ b/Task/Im-a-software-engineer-get-me-out-of-here/C++/im-a-software-engineer-get-me-out-of-here.cpp @@ -0,0 +1,236 @@ +#include +#include +#include +#include +#include + +const std::string gmooh = R"( +.........00000......... +......00003130000...... +....000321322221000.... +...00231222432132200... +..0041433223233211100.. +..0232231612142618530.. +.003152122326114121200. +.031252235216111132210. +.022211246332311115210. +00113232262121317213200 +03152118212313211411110 +03231234121132221411410 +03513213411311414112320 +00427534125412213211400 +.013322444412122123210. +.015132331312411123120. +.003333612214233913300. +..0219126511415312570.. +..0021321524341325100.. +...00211415413523200... +....000122111322000.... +......00001120000...... +.........00000.........)"; + +std::vector split_string(const std::string& text, const char& delimiter) { + std::vector lines; + std::istringstream stream(text); + std::string line; + while ( std::getline(stream, line, delimiter) ) { + if ( ! line.empty() ) { + lines.emplace_back(line); + } + } + return lines; +} + +const std::vector GMOOH = split_string(gmooh, '\n'); +const int32_t WIDTH = GMOOH[0].length(); +const int32_t HEIGHT = GMOOH.size(); + +class Cell { +public: + Cell(const int32_t& aRow, const int32_t& aCol) : row(aRow), col(aCol) { } + + std::string to_string() const { + return "(" + std::to_string(row) + ", " + std::to_string(col) + ")"; + } + + int32_t row, col; +}; + +class Cell_With_Cost { +public: + Cell_With_Cost(const int32_t& aFrom_Row, const int32_t& aFrom_Col, const int32_t& aCost) + : from_row(aFrom_Row), from_col(aFrom_Col), cost(aCost) { } + + std::string to_string() const { + return "(" + std::to_string(from_row) + ", " + std::to_string(from_col) + " : " + std::to_string(cost) + ")"; + } + + bool operator==(const Cell_With_Cost& other) const { + return cost == other.cost && from_row == other.from_row && from_col == other.from_col; + } + + int32_t from_row, from_col, cost; +}; + +const Cell_With_Cost ZERO_CELL_WITH_COST = Cell_With_Cost(0, 0, 0); + +const std::vector directions = { Cell(1, -1), Cell(1, 0), Cell(1, 1), + Cell(0, -1), Cell(0, 1), + Cell(-1, -1), Cell(-1, 0), Cell(-1, 1) }; + +std::vector> routes = { }; + +void print_vector(const std::vector& cells) { + std::cout << "["; + for ( uint64_t i = 0; i < cells.size() - 1; ++i ) { + std::cout << cells[i].to_string() << ", "; + } + std::cout << cells.back().to_string() << "]" << std::endl; +} + +std::vector create_route_to_cell(int32_t row, int32_t col) { + std::vector route = { }; + route.emplace_back(Cell(row, col)); + + while ( true ) { + Cell_With_Cost current_cell = routes[row][col]; + if ( current_cell.cost == 0 ) { + break; + } + + row = current_cell.from_row; + col = current_cell.from_col; + route.insert(route.begin(), Cell(row, col)); + } + return route; +} + +void show_cells_with_longest_route_from_HQ() { + int32_t maximum_cost = INT_MIN; + std::vector cells = { }; + for ( int32_t col = 0; col < WIDTH; ++col ) { + for ( int32_t row = 0; row < HEIGHT; ++row ) { + if ( GMOOH[row][col] >= '0' ) { + Cell_With_Cost current_cell = routes[row][col]; + if ( ! ( current_cell == ZERO_CELL_WITH_COST ) ) { + const int32_t cost = current_cell.cost; + if ( cost >= maximum_cost) { + if ( cost > maximum_cost ) { + cells.clear(); + maximum_cost = cost; + } + cells.emplace_back(Cell(row, col)); + } + } + } + } + } + + std::cout << "There are " << cells.size() << " cells that require " << maximum_cost + << " days to receive reinforcements from HQ:" << std::endl; + for ( const Cell& cell : cells ) { + print_vector(create_route_to_cell(cell.row, cell.col)); + } +} + +void show_unreachable_cells() { + std::vector unreachableCells = { }; + for ( int32_t col = 0; col < WIDTH; ++col ) { + for ( int32_t row = 0; row < HEIGHT; ++row ) { + if ( GMOOH[row][col] >= '0' && routes[row][col] == ZERO_CELL_WITH_COST ) { + unreachableCells.emplace_back(Cell(row, col)); + } + } + } + + std::cout << "The following cells are unreachable:" << std::endl; + print_vector(unreachableCells); +} + +void search_from_cell(int32_t row, int32_t col) { + routes = { static_cast(HEIGHT), std::vector(WIDTH, ZERO_CELL_WITH_COST) }; + routes[row][col] = Cell_With_Cost(row, col, 0); + + std::vector route = { }; + int32_t cost = 0; + + while ( true ) { + const int32_t start_digit = GMOOH[row][col] - '0'; + for ( Cell direction : directions ) { + const int32_t next_row = row + start_digit * direction.row; + const int32_t next_col = col + start_digit * direction.col; + if ( next_col >= 0 && next_col < WIDTH && next_row >= 0 && next_row < HEIGHT + && GMOOH[next_row][next_col] >= '0' ) { + Cell_With_Cost current_cell = routes[next_row][next_col]; + if ( current_cell == ZERO_CELL_WITH_COST || current_cell.cost > cost + 1 ) { + routes[next_row][next_col] = Cell_With_Cost(row, col, cost + 1); + if ( GMOOH[next_row][next_col] > '0' ) { + route.emplace_back(Cell_With_Cost(next_row, next_col, cost + 1)); + } + } + } + } + + if ( route.empty() ) { // All routes have been searched + break; + } + + Cell_With_Cost next_cell = route.front(); + route.erase(route.begin()); + row = next_cell.from_row; + col = next_cell.from_col; + cost = next_cell.cost; + } +} + +void show_shortest_routes_to_safety() { + int32_t minimum_cost = INT_MAX; + std::vector route = { }; + for ( int32_t col = 0; col < WIDTH; ++col ) { + for ( int32_t row = 0; row < HEIGHT; ++row ) { + if ( GMOOH[row][col] == '0' ) { + Cell_With_Cost current_cell = routes[row][col]; + if ( ! ( current_cell == ZERO_CELL_WITH_COST ) ) { + const int32_t cost = current_cell.cost; + if ( cost <= minimum_cost ) { + if ( cost < minimum_cost ) { + route.clear(); + minimum_cost = cost; + } + route.emplace_back(Cell(row, col)); + } + } + } + } + } + + const std::string are_is = ( route.size() > 1 ) ? "are " : "is "; + const std::string plural = ( route.size() > 1 ) ? "s" : ""; + std::cout << "There " << are_is << route.size() << " shortest route" << plural + << " of " << minimum_cost << " days to safety:" << std::endl; + for ( const Cell& cell : route ) { + print_vector(create_route_to_cell(cell.row, cell.col)); + } +} + +int main() { + search_from_cell(11, 11); + show_shortest_routes_to_safety(); + std::cout << std::endl; + + search_from_cell(21, 11); + std::cout << "The shortest route from (21, 11) to (1, 11):" << std::endl; + print_vector((create_route_to_cell(1, 11))); + std::cout << std::endl; + + search_from_cell(1, 11); + std::cout << "The shortest route from (1, 11) to (21, 11):" << std::endl; + print_vector((create_route_to_cell(21, 11))); + std::cout << std::endl; + + search_from_cell(11, 11); + show_unreachable_cells(); + std::cout << std::endl; + + show_cells_with_longest_route_from_HQ(); +} diff --git a/Task/Im-a-software-engineer-get-me-out-of-here/Java/im-a-software-engineer-get-me-out-of-here.java b/Task/Im-a-software-engineer-get-me-out-of-here/Java/im-a-software-engineer-get-me-out-of-here.java new file mode 100644 index 0000000000..5efa32bba9 --- /dev/null +++ b/Task/Im-a-software-engineer-get-me-out-of-here/Java/im-a-software-engineer-get-me-out-of-here.java @@ -0,0 +1,211 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public final class ImASoftwareEngineerGetMeOutOfHere { + + public static void main(String[] args) { + searchFromCell(11, 11); + showShortestRoutesToSafety(); + System.out.println(); + + searchFromCell(21, 11); + System.out.println("The shortest route from (21, 11) to (1, 11):"); + System.out.println(createRouteToCell(1, 11)); + System.out.println(); + + searchFromCell(1, 11); + System.out.println("The shortest route from (1, 11) to (21, 11):"); + System.out.println(createRouteToCell(21, 11)); + System.out.println(); + + searchFromCell(11, 11); + showUnreachableCells(); + System.out.println(); + + showCellsWithLongestRouteFromHQ(); + } + + private static void searchFromCell(int row, int col) { + routes = IntStream.range(0, HEIGHT).boxed() + .map( i -> new ArrayList(Collections.nCopies(WIDTH, CellWithCost.ZERO)) ) + .collect(Collectors.toList()); + routes.get(row).set(col, new CellWithCost(row, col, 0)); + + List route = new ArrayList(); + int cost = 0; + + while ( true ) { + final int startDigit = Character.digit(GMOOH[row].charAt(col), 10); + for ( Cell direction : directions ) { + final int nextRow = row + startDigit * direction.row; + final int nextCol = col + startDigit * direction.col; + if ( nextCol >= 0 && nextCol < WIDTH && nextRow >= 0 && nextRow < HEIGHT + && Character.digit(GMOOH[nextRow].charAt(nextCol), 10) >= 0 ) { + CellWithCost currentCell = routes.get(nextRow).get(nextCol); + if ( currentCell.equals(CellWithCost.ZERO) || currentCell.cost > cost + 1 ) { + routes.get(nextRow).set(nextCol, new CellWithCost(row, col, cost + 1)); + if ( Character.digit(GMOOH[nextRow].charAt(nextCol), 10) > 0 ) { + route.addLast( new CellWithCost(nextRow, nextCol, cost + 1) ); + } + } + } + } + + if ( route.isEmpty() ) { // All routes have been searched + break; + } + + CellWithCost nextCell = route.removeFirst(); + row = nextCell.fromRow; + col = nextCell.fromCol; + cost = nextCell.cost; + } + } + + private static void showShortestRoutesToSafety() { + int minimumCost = Integer.MAX_VALUE; + List cells = new ArrayList(); + for ( int col = 0; col < WIDTH; col++ ) { + for ( int row = 0; row < HEIGHT; row++ ) { + if ( Character.digit(GMOOH[row].charAt(col), 10) == 0 ) { + CellWithCost currentCell = routes.get(row).get(col); + if ( ! currentCell.equals(CellWithCost.ZERO) ) { + final int cost = currentCell.cost; + if ( cost <= minimumCost ) { + if ( cost < minimumCost ) { + cells.clear(); + minimumCost = cost; + } + cells.addLast( new Cell(row, col) ); + } + } + } + } + } + + String areIs = ( cells.size() > 1 ) ? "are " : "is "; + String plural = ( cells.size() > 1 ) ? "s" : ""; + System.out.println("There " + areIs + cells.size() + " shortest route" + plural + + " of " + minimumCost + " days to safety:"); + for ( Cell cell : cells ) { + System.out.println(createRouteToCell(cell.row, cell.col)); + } + } + + private static List createRouteToCell(int row, int col) { + List route = new ArrayList(); + route.addLast( new Cell(row, col) ); + + while ( true ) { + CellWithCost currentCell = routes.get(row).get(col); + if ( currentCell.cost == 0 ) { + break; + } + + row = currentCell.fromRow; + col = currentCell.fromCol; + route.addFirst( new Cell(row, col) ); + } + return route; + } + + private static void showUnreachableCells() { + List unreachableCells = new ArrayList(); + for ( int col = 0; col < WIDTH; col++ ) { + for ( int row = 0; row < HEIGHT; row++ ) { + if ( Character.digit(GMOOH[row].charAt(col), 10) >= 0 + && routes.get(row).get(col).equals(CellWithCost.ZERO) ) { + unreachableCells.addLast( new Cell(row, col) ); + } + } + } + + System.out.println("The following cells are unreachable:"); + System.out.println(unreachableCells); + } + + private static void showCellsWithLongestRouteFromHQ() { + int maximumCost = Integer.MIN_VALUE; + List cells = new ArrayList(); + for ( int col = 0; col < WIDTH; col++ ) { + for ( int row = 0; row < HEIGHT; row++ ) { + if ( Character.digit(GMOOH[row].charAt(col), 10) >= 0 ) { + CellWithCost currentCell = routes.get(row).get(col); + if ( ! currentCell.equals(CellWithCost.ZERO) ) { + final int cost = currentCell.cost; + if ( cost >= maximumCost) { + if ( cost > maximumCost ) { + cells.clear(); + maximumCost = cost; + } + cells.addLast( new Cell(row, col) ); + } + } + } + } + } + + System.out.println("There are " + cells.size() + " cells that require " + maximumCost + + " days to receive reinforcements from HQ:"); + for ( Cell cell : cells ) { + System.out.println(createRouteToCell(cell.row, cell.col)); + } + } + + private static List> routes; + + private static final List directions = List.of( new Cell(1, -1), new Cell(1, 0), new Cell(1, 1), + new Cell(0, -1), new Cell(0, 1), + new Cell(-1, -1), new Cell(-1, 0), new Cell(-1, 1) ); + + private static record CellWithCost(int fromRow, int fromCol, int cost) { + + public boolean equals(CellWithCost other) { + return cost == other.cost && fromRow == other.fromRow && fromCol == other.fromCol; + } + + public static CellWithCost ZERO = new CellWithCost(0, 0, 0); + + } + + private static record Cell(int row, int col) { + + public String toString() { + return "(" + row + ", " + col + ")"; + } + + } + + private static final String[] GMOOH = """ + .........00000......... + ......00003130000...... + ....000321322221000.... + ...00231222432132200... + ..0041433223233211100.. + ..0232231612142618530.. + .003152122326114121200. + .031252235216111132210. + .022211246332311115210. + 00113232262121317213200 + 03152118212313211411110 + 03231234121132221411410 + 03513213411311414112320 + 00427534125412213211400 + .013322444412122123210. + .015132331312411123120. + .003333612214233913300. + ..0219126511415312570.. + ..0021321524341325100.. + ...00211415413523200... + ....000122111322000.... + ......00001120000...... + .........00000......... + """.split("\n"); + + private static final int WIDTH = GMOOH[0].length(); + private static final int HEIGHT = GMOOH.length; + +} diff --git a/Task/Imaginary-base-numbers/FreeBASIC/imaginary-base-numbers.basic b/Task/Imaginary-base-numbers/FreeBASIC/imaginary-base-numbers.basic new file mode 100644 index 0000000000..27125de4df --- /dev/null +++ b/Task/Imaginary-base-numbers/FreeBASIC/imaginary-base-numbers.basic @@ -0,0 +1,168 @@ +#define ceil(x) (-((-x*2.0-0.5) Shr 1)) + +Type Complex + real As Double + imag As Double +End Type + +Type QuaterImaginary + b2i As String +End Type + +Dim Shared As Complex c1, c2 + +Function StrReverse(Byval txt As String) As String + Dim result As String + For i As Integer = Len(txt) To 1 Step -1 + result &= Mid(txt, i, 1) + Next i + Return result +End Function + +Function ToChar(n As Integer) As String + Return Chr(n + Asc("0")) +End Function + +Function ComplexMul(lhs As Complex, rhs As Complex) As Complex + Dim As Complex result + result.real = rhs.real * lhs.real - rhs.imag * lhs.imag + result.imag = rhs.real * lhs.imag + rhs.imag * lhs.real + Return result +End Function + +Function ComplexMulR(lhs As Complex, rhs As Double) As Complex + Dim As Complex result + result.real = lhs.real * rhs + result.imag = lhs.imag * rhs + Return result +End Function + +Function ComplexInv(c As Complex) As Complex + Dim As Double denom + Dim As Complex result + denom = c.real * c.real + c.imag * c.imag + result.real = c.real / denom + result.imag = -c.imag / denom + Return result +End Function + +Function ComplexDiv(lhs As Complex, rhs As Complex) As Complex + Return ComplexMul(lhs, ComplexInv(rhs)) +End Function + +Function ComplexNeg(c As Complex) As Complex + Dim As Complex result + result.real = -c.real + result.imag = -c.imag + Return result +End Function + +Function ComplexSum(lhs As Complex, rhs As Complex) As Complex + Dim As Complex result + result.real = lhs.real + rhs.real + result.imag = lhs.imag + rhs.imag + Return result +End Function + +Function ToQuaterImaginary(c As Complex) As QuaterImaginary + Dim As Integer re, im, fi, rem_, index + Dim As Double f + Dim As Complex t + Dim As QuaterImaginary result + Dim As String sb + re = Int(c.real) + im = Int(c.imag) + fi = -1 + While re <> 0 + rem_ = (re Mod -4) + re = re \ (-4) + If rem_ < 0 Then + rem_ = 4 + rem_ + re += 1 + End If + sb &= ToChar(rem_) & "0" + Wend + If im <> 0 Then + t = ComplexDiv(Type(0.0, c.imag), Type(0.0, 2.0)) + f = t.real + im = Ceil(f) + f = -4.0 * (f - Cdbl(im)) + index = 1 + While im <> 0 + rem_ = im Mod -4 + im \= -4 + If rem_ < 0 Then + rem_ = 4 + rem_ + im += 1 + End If + If index < Len(sb) Then + Mid(sb, index + 1, 1) = ToChar(rem_) + Else + sb &= "0" & ToChar(rem_) + End If + index += 2 + Wend + fi = Int(f) + End If + sb = StrReverse(sb) + If fi <> -1 Then sb &= "." & ToChar(fi) + sb = Ltrim(sb, "0") + If Left(sb, 1) = "." Then sb = "0" & sb + result.b2i = sb + Return result +End Function + +Function ToComplex(qi As QuaterImaginary) As Complex + Dim As Integer j, pointPos, posLen, b2iLen + Dim As Double k + Dim As Complex sum, prod + pointPos = Instr(qi.b2i, ".") + posLen = Iif(pointPos = 0, Len(qi.b2i), pointPos - 1) + sum.real = 0.0 + sum.imag = 0.0 + prod.real = 1.0 + prod.imag = 0.0 + For j = 0 To posLen - 1 + k = Val(Mid(qi.b2i, posLen - j, 1)) + If k > 0.0 Then sum = ComplexSum(sum, ComplexMulR(prod, k)) + prod = ComplexMul(prod, Type(0.0, 2.0)) + Next + If pointPos <> 0 Then + prod = ComplexInv(Type(0.0, 2.0)) + b2iLen = Len(qi.b2i) + For j = posLen + 1 To b2iLen - 1 + k = Val(Mid(qi.b2i, j + 1, 1)) + If k > 0.0 Then sum = ComplexSum(sum, ComplexMulR(prod, k)) + prod = ComplexMul(prod, ComplexInv(Type(0.0, 2.0))) + Next + End If + Return sum +End Function + +Dim As QuaterImaginary qi +Dim As Integer i +For i = 1 To 16 + c1.real = Cdbl(i) + c1.imag = 0.0 + qi = ToQuaterImaginary(c1) + c2 = ToComplex(qi) + Print c1.real; "i -> "; qi.b2i; " -> "; c2.real; "i"; + c1 = ComplexNeg(c1) + qi = ToQuaterImaginary(c1) + c2 = ToComplex(qi) + Print c1.real; "i -> "; qi.b2i; " -> "; c2.real; "i" +Next +Print +For i = 1 To 16 + c1.real = 0.0 + c1.imag = Cdbl(i) + qi = ToQuaterImaginary(c1) + c2 = ToComplex(qi) + Print c1.imag; "i -> "; qi.b2i; " -> "; c2.imag; "i"; + c1 = ComplexNeg(c1) + qi = ToQuaterImaginary(c1) + c2 = ToComplex(qi) + Print c1.imag; "i -> "; qi.b2i; " -> "; c2.imag; "i" +Next + +Sleep diff --git a/Task/Include-a-file/PascalABC.NET/include-a-file-1.pas b/Task/Include-a-file/PascalABC.NET/include-a-file-1.pas new file mode 100644 index 0000000000..6dcd659652 --- /dev/null +++ b/Task/Include-a-file/PascalABC.NET/include-a-file-1.pas @@ -0,0 +1,5 @@ +{$include a.inc} + +begin + Hello +end. diff --git a/Task/Include-a-file/PascalABC.NET/include-a-file-2.pas b/Task/Include-a-file/PascalABC.NET/include-a-file-2.pas new file mode 100644 index 0000000000..ae2d6061f5 --- /dev/null +++ b/Task/Include-a-file/PascalABC.NET/include-a-file-2.pas @@ -0,0 +1 @@ +procedure Hello := Print('Hello'); diff --git a/Task/Increasing-gaps-between-consecutive-Niven-numbers/Sidef/increasing-gaps-between-consecutive-niven-numbers.sidef b/Task/Increasing-gaps-between-consecutive-Niven-numbers/Sidef/increasing-gaps-between-consecutive-niven-numbers.sidef new file mode 100644 index 0000000000..d2d19b6612 --- /dev/null +++ b/Task/Increasing-gaps-between-consecutive-Niven-numbers/Sidef/increasing-gaps-between-consecutive-niven-numbers.sidef @@ -0,0 +1,12 @@ +var threshold = 10_000_000 + +say "Gap Index of gap Starting Niven" +for (var (n=1, index=0, gap=0, prev=1); index <= threshold; ++n) { + n.is_div(n.digits_sum) || next + if ((var diff = (n - prev)) > gap) { + gap = diff + printf("%3d %15s %15s\n", gap, index, prev) + } + prev = n + ++index +} diff --git a/Task/Increment-a-numerical-string/Uiua/increment-a-numerical-string.uiua b/Task/Increment-a-numerical-string/Uiua/increment-a-numerical-string.uiua new file mode 100644 index 0000000000..eaabfbd1b3 --- /dev/null +++ b/Task/Increment-a-numerical-string/Uiua/increment-a-numerical-string.uiua @@ -0,0 +1,2 @@ +IncString ← ⍜⋕(+1) +IncString "99" diff --git a/Task/Infinity/PascalABC.NET/infinity.pas b/Task/Infinity/PascalABC.NET/infinity.pas new file mode 100644 index 0000000000..6ba97dc78a --- /dev/null +++ b/Task/Infinity/PascalABC.NET/infinity.pas @@ -0,0 +1,2 @@ +## +Write(real.PositiveInfinity); diff --git a/Task/Inheritance-Multiple/PascalABC.NET/inheritance-multiple.pas b/Task/Inheritance-Multiple/PascalABC.NET/inheritance-multiple.pas new file mode 100644 index 0000000000..6409dc0ced --- /dev/null +++ b/Task/Inheritance-Multiple/PascalABC.NET/inheritance-multiple.pas @@ -0,0 +1,19 @@ +type + IMy1 = interface + procedure My1; + end; + IMy2 = interface + procedure My2; + end; + MyClass = class(IMy1,IMy2) + public + procedure My1 := Writeln('My1'); + procedure My2 := Writeln('My2'); + end; + MyClassD = class(MyClass,IMy1,IMy2) + end; + +begin + var my := new MyClassD; + my.My1; my.My2; +end. diff --git a/Task/Inheritance-Single/PascalABC.NET/inheritance-single.pas b/Task/Inheritance-Single/PascalABC.NET/inheritance-single.pas new file mode 100644 index 0000000000..fa5f1a7069 --- /dev/null +++ b/Task/Inheritance-Single/PascalABC.NET/inheritance-single.pas @@ -0,0 +1,6 @@ +type + Animal = class end; + Dog = class(Animal) end; + Cat = class(Animal) end; + Lab = class(Dog) end; + Collie = class(Dog) end; diff --git a/Task/Input-loop/PascalABC.NET/input-loop.pas b/Task/Input-loop/PascalABC.NET/input-loop.pas new file mode 100644 index 0000000000..7214f03b64 --- /dev/null +++ b/Task/Input-loop/PascalABC.NET/input-loop.pas @@ -0,0 +1,6 @@ +begin + var f := OpenRead('a.txt'); + while not f.Eof do + Println(f.ReadString); + f.Close; +end. diff --git a/Task/Integer-comparison/PascalABC.NET/integer-comparison.pas b/Task/Integer-comparison/PascalABC.NET/integer-comparison.pas new file mode 100644 index 0000000000..9902a57821 --- /dev/null +++ b/Task/Integer-comparison/PascalABC.NET/integer-comparison.pas @@ -0,0 +1,8 @@ +begin + var (a,b) := ReadInteger2('Enter a,b:'); + if a < b then + Println($'{a} is less then {b}') + else if a > b then + Println($'{a} is greater then {b}') + else Println($'{a} is equal to then {b}') +end. diff --git a/Task/Integer-sequence/Kotlin/integer-sequence.kotlin b/Task/Integer-sequence/Kotlin/integer-sequence.kotlin index 72fec53d9d..f4dbecd12e 100644 --- a/Task/Integer-sequence/Kotlin/integer-sequence.kotlin +++ b/Task/Integer-sequence/Kotlin/integer-sequence.kotlin @@ -1,15 +1,10 @@ import java.math.BigInteger -// version 1.0.5-2 +fun main() { + // Using a 64-bit unsigned type, print until 18446744073709551615 + (1u..ULong.MAX_VALUE).forEach { println(it) } -fun main(args: Array) { - // print until 2147483647 - (0..Int.MAX_VALUE).forEach { println(it) } - - // print forever - var n = BigInteger.ZERO - while (true) { - println(n) - n += BigInteger.ONE - } + // Using unlimited-size integers, print forever + var n = BigInteger.ONE + while (true) println(n++) } diff --git a/Task/Integer-sequence/PascalABC.NET/integer-sequence.pas b/Task/Integer-sequence/PascalABC.NET/integer-sequence-1.pas similarity index 100% rename from Task/Integer-sequence/PascalABC.NET/integer-sequence.pas rename to Task/Integer-sequence/PascalABC.NET/integer-sequence-1.pas diff --git a/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas b/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas new file mode 100644 index 0000000000..7b206716fb --- /dev/null +++ b/Task/Integer-sequence/PascalABC.NET/integer-sequence-2.pas @@ -0,0 +1 @@ +## 1.Step.Print diff --git a/Task/Integer-sequence/Uiua/integer-sequence.uiua b/Task/Integer-sequence/Uiua/integer-sequence.uiua new file mode 100644 index 0000000000..008b417081 --- /dev/null +++ b/Task/Integer-sequence/Uiua/integer-sequence.uiua @@ -0,0 +1 @@ +⍢(&p.+1)1 1 diff --git a/Task/Integer-sequence/Zig/integer-sequence.zig b/Task/Integer-sequence/Zig/integer-sequence.zig new file mode 100644 index 0000000000..b3e6c9abd9 --- /dev/null +++ b/Task/Integer-sequence/Zig/integer-sequence.zig @@ -0,0 +1,9 @@ +const stdout = @import("std").io.getStdOut().writer(); + +pub fn main() !void { + var i: u128 = 1; + + while (true) : (i += 1) { + try stdout.print("{}, ", .{i}); + } +} diff --git a/Task/Introspection/Jq/introspection.jq b/Task/Introspection/Jq/introspection.jq new file mode 100644 index 0000000000..62605aed02 --- /dev/null +++ b/Task/Introspection/Jq/introspection.jq @@ -0,0 +1,23 @@ +def checkVersion: + $version + | capture("^[^- ]*(?[- ])(?[0-9]*)[.](?[0-9]*)") // {jq: 0} + | if .jq == 0 then "unrecognized version identification: \($version)" | error + elif .jq == "-" # jq + and (.major < "1" or (.major == "1" and .minor < "5")) + then "version \($version) is too old" | error + elif .jq == " " # gojq + and (.major == "0" and (.minor | tonumber) < 12) + then "version \($version) is too old" | error + else . + end; + + checkVersion + + # Check that abs/0 is defined + | (builtins | index("abs/0")) as $ix + | if $ix == null then "abs/0 not available" | error else . end + + # Is bloop a global variable? + | if ($ARGS.named | has("bloop")) then $ARGS.named["bloop"] | abs + else "There is no globally defined variable name $bloop." | error + end diff --git a/Task/Inverted-index/Ada/inverted-index-7.ada b/Task/Inverted-index/Ada/inverted-index-7.ada index 7146057dd2..d12c9b489b 100644 --- a/Task/Inverted-index/Ada/inverted-index-7.ada +++ b/Task/Inverted-index/Ada/inverted-index-7.ada @@ -68,8 +68,8 @@ package body Generic_Inverted_Index is procedure Iterate(The_Sources: Vector) is begin - for Some_Element in The_Sources loop - Do_Something(Element(Some_Element)); + for Some_Element of The_Sources loop + Do_Something(Some_Element); end loop; end Iterate; diff --git a/Task/Iterated-digits-squaring/EasyLang/iterated-digits-squaring.easy b/Task/Iterated-digits-squaring/EasyLang/iterated-digits-squaring.easy new file mode 100644 index 0000000000..e28ec70bb3 --- /dev/null +++ b/Task/Iterated-digits-squaring/EasyLang/iterated-digits-squaring.easy @@ -0,0 +1,38 @@ +fastfunc ends89 n . + repeat + s = 0 + while n > 0 + d = n mod 10 + s += d * d + n = n div 10 + . + n = s + if n = 89 + return 1 + . + until n = 1 + . + return 0 +. +k = 8 +arrbase sums[] 0 +len sums[] k * 81 + 1 +sums[0] = 1 +for n = 1 to k + for i = n * 81 downto 1 + for j = 1 to 9 + s = j * j + if s > i + break 1 + . + sums[i] += sums[i - s] + . + . +. +cnt = 0 +for i = 1 to k * 81 + if ends89 i = 1 + cnt += sums[i] + . +. +print cnt diff --git a/Task/JSON/PascalABC.NET/json.pas b/Task/JSON/PascalABC.NET/json.pas new file mode 100644 index 0000000000..cec8dbb76f --- /dev/null +++ b/Task/JSON/PascalABC.NET/json.pas @@ -0,0 +1,20 @@ +{$reference System.Web.Extensions.dll} +uses System.Web.Script.Serialization; + +begin + var serializer := new JavaScriptSerializer; + var people := new Dictionary; + people.Add('1', 'John'); + people.Add('2', 'Susan'); + var json := serializer.Serialize(people); + Println(json); + var res := serializer.Deserialize&>(json); + Println(TypeName(res)); + Println(res); + + var jsonObject := serializer.DeserializeObject('{ "foo": 1, "bar": [10, "apples"] }') + as Dictionary; + Println(jsonObject); + var arr := jsonObject['bar'] as array of object; + arr.Println; +end. diff --git a/Task/Jaro-Winkler-distance/Sidef/jaro-winkler-distance.sidef b/Task/Jaro-Winkler-distance/Sidef/jaro-winkler-distance.sidef new file mode 100644 index 0000000000..0e03bd574e --- /dev/null +++ b/Task/Jaro-Winkler-distance/Sidef/jaro-winkler-distance.sidef @@ -0,0 +1,26 @@ +func jaro_winkler_distance(s,t) { + + var jaro_similarity = jaro(s, t) + + var prefix = 0 + for i in (0 .. min(3, s.len, t.len)) { + s.char(i) == t.char(i) ? ++prefix : break + } + + 1 - (prefix * 0.1 * (1 - jaro_similarity) + jaro_similarity) +} + +# usage: +# sidef script.sf < unixdict.txt + +var words = ARGF.slurp.words + +%w(accomodate definately goverment occured publically recieve seperate untill wich).each {|word| + + var result = Hash(words.map { (_, jaro_winkler_distance(word, _)) }...) + + say "\nClosest 5 dictionary words with a Jaro-Winkler distance < .15 from #{word}:" + result.grep {|_,v| v < .15 }.sort_by{|_,v| v }.head(5).each_2d {|k,v| + printf("%15s : %0.4f\n", k, v) + } +} diff --git a/Task/Jensens-Device/Asymptote/jensens-device.asymptote b/Task/Jensens-Device/Asymptote/jensens-device.asymptote new file mode 100644 index 0000000000..6aa8d24907 --- /dev/null +++ b/Task/Jensens-Device/Asymptote/jensens-device.asymptote @@ -0,0 +1,5 @@ +real temp = 0; +for(int i = 1; i <= 100; ++i) { + temp += 1/i; +} +write(temp); diff --git a/Task/Jensens-Device/BASIC256/jensens-device.basic b/Task/Jensens-Device/BASIC256/jensens-device.basic index 57eca3f589..4ab66b031f 100644 --- a/Task/Jensens-Device/BASIC256/jensens-device.basic +++ b/Task/Jensens-Device/BASIC256/jensens-device.basic @@ -1,3 +1,6 @@ +call Evaluation() +end + subroutine Evaluation() lo = 1 : hi = 100 : temp = 0 for i = lo to hi @@ -5,6 +8,3 @@ subroutine Evaluation() next i print temp end subroutine - -call Evaluation() -end diff --git a/Task/Jensens-Device/Chipmunk-Basic/jensens-device.basic b/Task/Jensens-Device/Chipmunk-Basic/jensens-device.basic new file mode 100644 index 0000000000..d04c6d6fef --- /dev/null +++ b/Task/Jensens-Device/Chipmunk-Basic/jensens-device.basic @@ -0,0 +1,11 @@ +100 call evaluation +110 end +120 sub evaluation() +130 lo = 1 +140 hi = 100 +150 temp = 0 +160 for i = lo to hi +170 temp = temp+(1/i) +180 next i +190 print temp +200 end sub diff --git a/Task/Jensens-Device/Dart/jensens-device.dart b/Task/Jensens-Device/Dart/jensens-device.dart new file mode 100644 index 0000000000..410c0687cb --- /dev/null +++ b/Task/Jensens-Device/Dart/jensens-device.dart @@ -0,0 +1,14 @@ +double i = 0; +double sum(int lo, int hi, double Function() term) { + double temp = 0; + for (i = lo.toDouble(); i <= hi; i++) temp += term(); + return temp; +} + +double termFunc() { + return 1.0 / i; +} + +void main() { + print(sum(1, 100, termFunc)); +} diff --git a/Task/Jensens-Device/GW-BASIC/jensens-device.basic b/Task/Jensens-Device/GW-BASIC/jensens-device.basic new file mode 100644 index 0000000000..951bc5e857 --- /dev/null +++ b/Task/Jensens-Device/GW-BASIC/jensens-device.basic @@ -0,0 +1,11 @@ +100 GOSUB 120 +110 END +120 REM Evaluation +130 LET A = 1 +140 LET B = 100 +150 LET T = 0 +160 FOR I = A TO B +170 LET T = T + (1/I) +180 NEXT I +190 PRINT T +200 RETURN diff --git a/Task/Jensens-Device/Gambas/jensens-device.gambas b/Task/Jensens-Device/Gambas/jensens-device.gambas new file mode 100644 index 0000000000..ecfb8848c9 --- /dev/null +++ b/Task/Jensens-Device/Gambas/jensens-device.gambas @@ -0,0 +1,17 @@ +Sub Evaluation() + + Dim i As Integer, lo As Integer = 1, hi As Integer = 100 + Dim tmp As Float = 0 + + For i = lo To hi + tmp += (1 / i) + Next + Print tmp + +End Sub + +Public Sub Main() + + Evaluation + +End diff --git a/Task/Jensens-Device/Minimal-BASIC/jensens-device.basic b/Task/Jensens-Device/Minimal-BASIC/jensens-device.basic new file mode 100644 index 0000000000..bab897a7b5 --- /dev/null +++ b/Task/Jensens-Device/Minimal-BASIC/jensens-device.basic @@ -0,0 +1,12 @@ +100 GOSUB 120 +110 GOTO 210 +120 REM Evaluation +130 LET A = 1 +140 LET B = 100 +150 LET T = 0 +160 FOR I = A TO B +170 LET T = T+(1/I) +180 NEXT I +190 PRINT T +200 RETURN +210 END diff --git a/Task/Jensens-Device/QBasic/jensens-device.basic b/Task/Jensens-Device/QBasic/jensens-device.basic new file mode 100644 index 0000000000..336575755d --- /dev/null +++ b/Task/Jensens-Device/QBasic/jensens-device.basic @@ -0,0 +1,12 @@ +CALL EVALUATION +END + +SUB Evaluation + LET lo = 1 + LET hi = 100 + LET temp = 0 + FOR i = lo TO hi + LET temp = temp + (1 / i) + NEXT i + PRINT temp +END SUB diff --git a/Task/Jensens-Device/Yabasic/jensens-device.basic b/Task/Jensens-Device/Yabasic/jensens-device.basic index 5296d4d9e6..8df2e59253 100644 --- a/Task/Jensens-Device/Yabasic/jensens-device.basic +++ b/Task/Jensens-Device/Yabasic/jensens-device.basic @@ -1,3 +1,6 @@ +Evaluation() +end + sub Evaluation() lo = 1 : hi = 100 : temp = 0 for i = lo to hi @@ -5,5 +8,3 @@ sub Evaluation() next i print temp end sub - -Evaluation() diff --git a/Task/JortSort/EasyLang/jortsort.easy b/Task/JortSort/EasyLang/jortsort.easy new file mode 100644 index 0000000000..eff2004f35 --- /dev/null +++ b/Task/JortSort/EasyLang/jortsort.easy @@ -0,0 +1,16 @@ +proc sort . d[] . + for i = 1 to len d[] - 1 + for j = i + 1 to len d[] + if d[j] < d[i] + swap d[j] d[i] + . + . + . +. +func jortsort arr[] . + orig[] = arr[] + sort arr[] + return if orig[] = arr[] +. +print jortsort [ 2 4 6 ] +print jortsort [ 4 2 6 ] diff --git a/Task/Josephus-problem/Ada/josephus-problem.ada b/Task/Josephus-problem/Ada/josephus-problem.ada index 4691ba817b..f17eb315f4 100644 --- a/Task/Josephus-problem/Ada/josephus-problem.ada +++ b/Task/Josephus-problem/Ada/josephus-problem.ada @@ -2,14 +2,14 @@ with Ada.Command_Line, Ada.Text_IO; procedure Josephus is - function Arg(Idx, Default: Positive) return Positive is -- read Argument(Idx) + function Arg(Index, Default: Positive) return Natural is -- read Argument(Index) (if Ada.Command_Line.Argument_Count >= Index - then Positive'Value(Ada.Command_Line.Argument(Index)) else Default); + then Natural'Value(Ada.Command_Line.Argument(Index)) else Default); - Prisoners: constant Positive := Arg(Idx => 1, Default => 41); - Steps: constant Positive := Arg(Idx => 2, Default => 3); - Survivors: constant Positive := Arg(Idx => 3, Default => 1); - Print: Boolean := (Arg(Idx => 4, Default => 1) = 1); + Prisoners: constant Positive := Arg(Index => 1, Default => 41); + Steps: constant Positive := Arg(Index => 2, Default => 3); + Survivors: constant Positive := Arg(Index => 3, Default => 1); + Print: Boolean := (Arg(Index => 4, Default => 1) = 1); subtype Index_Type is Natural range 0 .. Prisoners-1; Next: array(Index_Type) of Index_Type; @@ -20,8 +20,8 @@ begin ("N =" & Positive'Image(Prisoners) & ", K =" & Positive'Image(Steps) & (if Survivors > 1 then ", #survivors =" & Positive'Image(Survivors) else "")); - for Idx in Next'Range loop -- initialize Next - Next(Idx) := (Idx+1) mod Prisoners; + for Index in Next'Range loop -- initialize Next + Next(Index) := (Index+1) mod Prisoners; end loop; if Print then Ada.Text_IO.Put("Executed: "); diff --git a/Task/Jump-anywhere/PascalABC.NET/jump-anywhere.pas b/Task/Jump-anywhere/PascalABC.NET/jump-anywhere.pas new file mode 100644 index 0000000000..b4267993a6 --- /dev/null +++ b/Task/Jump-anywhere/PascalABC.NET/jump-anywhere.pas @@ -0,0 +1,15 @@ +label finish; + +begin + var a := MatrRandomInteger(3,4); + var found := False; + for var i:=0 to a.RowCount-1 do + for var j:=0 to a.ColCount-1 do + if a[i,j] = 10 then + begin + found := True; + goto finish; + end; +finish: + Print(found); +end. diff --git a/Task/Knights-tour/Jq/knights-tour.jq b/Task/Knights-tour/Jq/knights-tour.jq new file mode 100644 index 0000000000..92064b6305 --- /dev/null +++ b/Task/Knights-tour/Jq/knights-tour.jq @@ -0,0 +1,50 @@ +# The number of columns +def boardSize: 8; + +# {x,y} with .x >= 0 and .y >= 0 +def Square($x; $y): {$x, $y}; + +# Input: a Square assuming .x <= 25 +def notate: + .x as $x + | "abcdefghijklmnopqrstuvwxyz"[$x:$x+1] + "\(.y + 1)"; + +# Input: a Square +# Output: a stream of possible Squares reachable from . +def knightMoves: + def axisMoves: [1, 2, -1, -2]; + + # Is the input Square on the board? + def onBoard: + 0 <= .x and .x < boardSize and 0 <= .y and .y < boardSize; + + . as $s + | axisMoves + | combinations(2) + | select( (.[0]|length) != (.[1]|length) ) # abs + | Square($s.x + .[0]; $s.y + .[1]) + | select(onBoard) ; + +# $moves should be a non-empty array specifying an initial fragment of a possible tour +def knightTour($moves): + # Find the array of relevant possible one-step moves from the Square specified by . + def findMoves: + [ knightMoves | select( IN($moves[]) | not) ] ; + + ($moves[-1] | findMoves) as $fm + | if $fm == [] then $moves + else ($fm | min_by( findMoves|length )) as $next + | knightTour($moves + [$next]) + end ; + +def knightTourFrom($start): + knightTour([$start]) ; + +def example($square): + knightTourFrom($square) + | (_nwise(boardSize) | map("\(.x),\(.y)") | join(" ")), + "\nAlgebraic notation:", + (_nwise(boardSize) | map( notate ) | join(" ")) + ; + +example(Square(1; 1)) diff --git a/Task/Knuth-shuffle/PascalABC.NET/knuth-shuffle.pas b/Task/Knuth-shuffle/PascalABC.NET/knuth-shuffle.pas new file mode 100644 index 0000000000..6a208684e7 --- /dev/null +++ b/Task/Knuth-shuffle/PascalABC.NET/knuth-shuffle.pas @@ -0,0 +1,11 @@ +procedure Shuffle(a: array of T); +begin + for var i := a.Length - 1 downto 1 do + Swap(a[i], a[Random(i + 1)]); +end; + +begin + var a := Arr(1..9); + Shuffle(a); + a.Print; +end. diff --git a/Task/Kosaraju/11l/kosaraju.11l b/Task/Kosaraju/11l/kosaraju.11l index c23d8b7325..d3d13d5ea4 100644 --- a/Task/Kosaraju/11l/kosaraju.11l +++ b/Task/Kosaraju/11l/kosaraju.11l @@ -5,7 +5,7 @@ F kosaraju(g) V x = size V t = [[Int]()] * size - F visit(Int u) -> N + F visit(Int u) -> Void I !@vis[u] @vis[u] = 1B L(v) @g[u] @@ -18,7 +18,7 @@ F kosaraju(g) visit(u) V c = [0] * size - F assign(Int u, root) -> N + F assign(Int u, root) -> Void I @vis[u] @vis[u] = 0B @c[u] = root diff --git a/Task/Kronecker-product-based-fractals/EasyLang/kronecker-product-based-fractals.easy b/Task/Kronecker-product-based-fractals/EasyLang/kronecker-product-based-fractals.easy new file mode 100644 index 0000000000..30c4fe6ab0 --- /dev/null +++ b/Task/Kronecker-product-based-fractals/EasyLang/kronecker-product-based-fractals.easy @@ -0,0 +1,38 @@ +func[][] krpr a[][] b[][] . + for m = 1 to len a[][] + for p = 1 to len b[][] + r[][] &= [ ] + for n = 1 to len a[m][] + for q = 1 to len b[p][] + r[$][] &= a[m][n] * b[p][q] + . + . + . + . + return r[][] +. +func[][] krpow a[][] n . + r[][] = [ [ 1 ] ] + for i to n + r[][] = krpr a[][] r[][] + . + return r[][] +. +proc show p[][] . . + clear + n = len p[][] + sc = 100 / n + for r to n + for c to n + x = (c - 1) * sc + y = (r - 1) * sc + move x y + if p[r][c] = 1 + rect sc sc + . + . + . +. +show krpow [ [ 1 1 1 ] [ 1 0 1 ] [ 1 1 1 ] ] 5 +sleep 2 +show krpow [ [ 0 1 0 ] [ 1 1 1 ] [ 0 1 0 ] ] 5 diff --git a/Task/Kronecker-product/BASIC256/kronecker-product.basic b/Task/Kronecker-product/BASIC256/kronecker-product.basic new file mode 100644 index 0000000000..e8e357e6f5 --- /dev/null +++ b/Task/Kronecker-product/BASIC256/kronecker-product.basic @@ -0,0 +1,42 @@ +arraybase 1 +dim a(2, 2) +a[1,1] = 1 : a[1,2] = 2 : a[2,1] = 3 : a[2,2] = 4 +dim b(2, 2) +b[1,1] = 0 : b[1,2] = 5 : b[2,1] = 6 : b[2,2] = 7 +call kronecker_product(a, b) + +print +dim x(3, 3) +x[1,1] = 0 : x[1,2] = 1 : x[1,3] = 0 +x[2,1] = 1 : x[2,2] = 1 : x[2,3] = 1 +x[3,1] = 0 : x[3,2] = 1 : x[3,3] = 0 +dim y(3, 4) +y[1,1] = 1 : y[1,2] = 1 : y[1,3] = 1 : y[1,4] = 1 +y[2,1] = 1 : y[2,2] = 0 : y[2,3] = 0 : y[2,4] = 1 +y[3,1] = 1 : y[3,2] = 1 : y[3,3] = 1 : y[3,4] = 1 +call kronecker_product(x, y) +end + +subroutine kronecker_product(a, b) + ua1 = a[?][] + ua2 = a[][?] + + ub1 = b[?][] + ub2 = b[][?] + + for i = 1 to ua1 + for k = 1 to ub1 + print "["; + for j = 1 to ua2 + for l = 1 to ub2 + print rjust(a[i, j] * b[k, l], 2); + if j = ua1 and l = ub2 then + print "]" + else + print " "; + endif + next + next + next + next +end subroutine diff --git a/Task/Kronecker-product/EasyLang/kronecker-product.easy b/Task/Kronecker-product/EasyLang/kronecker-product.easy new file mode 100644 index 0000000000..a7f264cb44 --- /dev/null +++ b/Task/Kronecker-product/EasyLang/kronecker-product.easy @@ -0,0 +1,15 @@ +func[][] krpr a[][] b[][] . + for m = 1 to len a[][] + for p = 1 to len b[][] + r[][] &= [ ] + for n = 1 to len a[m][] + for q = 1 to len b[p][] + r[$][] &= a[m][n] * b[p][q] + . + . + . + . + return r[][] +. +print krpr [ [ 1 2 ] [ 3 4 ] ] [ [ 0 5 ] [ 6 7 ] ] +print krpr [ [ 0 1 0 ] [ 1 1 1 ] [ 0 1 0 ] ] [ [ 1 1 1 1 ] [ 1 0 0 1 ] [ 1 1 1 1 ] ] diff --git a/Task/Kronecker-product/Yabasic/kronecker-product.basic b/Task/Kronecker-product/Yabasic/kronecker-product.basic new file mode 100644 index 0000000000..07bfd6f99f --- /dev/null +++ b/Task/Kronecker-product/Yabasic/kronecker-product.basic @@ -0,0 +1,42 @@ +print +dim a(2, 2) +a(1,1) = 1 : a(1,2) = 2 : a(2,1) = 3 : a(2,2) = 4 +dim b(2, 2) +b(1,1) = 0 : b(1,2) = 5 : b(2,1) = 6 : b(2,2) = 7 +kronecker_product(a, b) + +print +dim a(3, 3) +a(1,1) = 0 : a(1,2) = 1 : a(1,3) = 0 +a(2,1) = 1 : a(2,2) = 1 : a(2,3) = 1 +a(3,1) = 0 : a(3,2) = 1 : a(3,3) = 0 +dim b(3, 4) +b(1,1) = 1 : b(1,2) = 1 : b(1,3) = 1 : b(1,4) = 1 +b(2,1) = 1 : b(2,2) = 0 : b(2,3) = 0 : b(2,4) = 1 +b(3,1) = 1 : b(3,2) = 1 : b(3,3) = 1 : b(3,4) = 1 +kronecker_product(a, b) +end + +sub kronecker_product(a, b) + local i, j, k, l + ua1 = arraysize(a(), 1) + ua2 = arraysize(a(), 2) + ub1 = arraysize(b(), 1) + ub2 = arraysize(b(), 2) + + for i = 1 to ua1 + for k = 1 to ub1 + print "["; + for j = 1 to ua2 + for l = 1 to ub2 + print a(i, j) * b(k, l) using "##"; + if j = ua1 and l = ub2 then + print "]" + else + print " "; + endif + next + next + next + next +end sub diff --git a/Task/Langtons-ant/Uiua/langtons-ant.uiua b/Task/Langtons-ant/Uiua/langtons-ant.uiua new file mode 100644 index 0000000000..a5117b76c4 --- /dev/null +++ b/Task/Langtons-ant/Uiua/langtons-ant.uiua @@ -0,0 +1,14 @@ +# Draw Langton's Ant. + +N ← 100 +# initialise dir pos map +[¯1 0] [50 50] ↯N_N 1 +# Run until out of bounds +⍢( + ⊙(⟜(⍜⊡(-:1))) + ⟨⍜(⊡1|¯)⇌|⇌⍜(⊡1|¯)⟩:⊙(⊡,,) + ⟜+ +| ≥0⋅/↧ +) +# Scale up +▽⟜≡▽4◌◌ diff --git a/Task/Largest-int-from-concatenated-ints/EasyLang/largest-int-from-concatenated-ints.easy b/Task/Largest-int-from-concatenated-ints/EasyLang/largest-int-from-concatenated-ints.easy new file mode 100644 index 0000000000..58f2ca1bef --- /dev/null +++ b/Task/Largest-int-from-concatenated-ints/EasyLang/largest-int-from-concatenated-ints.easy @@ -0,0 +1,23 @@ +func con a b . + t = 10 + while b >= t + t *= 10 + . + return a * t + b +. +func$ max a[] . + n = len a[] + for i to n - 1 + for j = i + 1 to n + if con a[i] a[j] < con a[j] a[i] + swap a[i] a[j] + . + . + . + for v in a[] + r$ &= v + . + return r$ +. +print max [ 1 34 3 98 9 76 45 4 ] +print max [ 54 546 548 60 ] diff --git a/Task/Largest-int-from-concatenated-ints/Uiua/largest-int-from-concatenated-ints.uiua b/Task/Largest-int-from-concatenated-ints/Uiua/largest-int-from-concatenated-ints.uiua new file mode 100644 index 0000000000..be87ff429a --- /dev/null +++ b/Task/Largest-int-from-concatenated-ints/Uiua/largest-int-from-concatenated-ints.uiua @@ -0,0 +1,2 @@ +A ← {[212 21221] [1 34 3 98 9 76 45 4][54 546 548 60]} +≡(⋕/◇⊂⊏⊸(⍖≡↯[/↥≡⧻]).°⋕)A diff --git a/Task/Largest-number-divisible-by-its-digits/Ada/largest-number-divisible-by-its-digits.ada b/Task/Largest-number-divisible-by-its-digits/Ada/largest-number-divisible-by-its-digits.ada new file mode 100644 index 0000000000..442f3edee6 --- /dev/null +++ b/Task/Largest-number-divisible-by-its-digits/Ada/largest-number-divisible-by-its-digits.ada @@ -0,0 +1,48 @@ +-- Largest number divisible by its digits; analysis under Raku +-- J. Carter 2024 May + +with Ada.Text_IO; + +procedure LNDBID is + Magic : constant := 9 * 8 * 7; + + function Good (Number : in Positive) return Boolean; + -- Returns True if Number's decimal representation has only unique digits and is evenly divisible by each of its digits + + function Good (Number : in Positive) return Boolean is + subtype Digit is Character range '1' .. '9'; + + type Count_List is array (Digit) of Natural; + + Count : Count_List := (Digit => 0); + + Raw : String renames Number'Image; + Image : String renames Raw (2 .. Raw'Last); + begin -- Good + if (for some D of Image => D in '0' | '5') then + return False; + end if; + + Count_Them : for D of Image loop + Count (D) := Count (D) + 1; + end loop Count_Them; + + if (for some V of Count => V > 1) then + return False; + end if; + + return (for all D of Image => Number rem (Character'Pos (D) - Character'Pos ('0') ) = 0); + end Good; + + Number : Positive := Magic * (9876432 / Magic); +begin -- LNDBID + Check : loop + if Good (Number) then + Ada.Text_IO.Put_Line (Item => Number'Image); + + return; + end if; + + Number := Number - Magic; + end loop Check; +end LNDBID; diff --git a/Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits.cpp b/Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-1.cpp similarity index 100% rename from Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits.cpp rename to Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-1.cpp diff --git a/Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-2.cpp b/Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-2.cpp new file mode 100644 index 0000000000..f5419a2916 --- /dev/null +++ b/Task/Largest-number-divisible-by-its-digits/C++/largest-number-divisible-by-its-digits-2.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +std::string to_hex_string(const uint64_t& hexadecimal) { + std::stringstream stream; + stream << std::hex << hexadecimal; + return stream.str(); +} + +bool is_lynch_bell(const uint64_t& hexadecimal) { + std::string hex_string = to_hex_string(hexadecimal); + if ( hex_string.find('0') != std::string::npos ) { + return false; + } + + std::unordered_set distinct_digits = { }; + for ( const char ch : hex_string ) { + distinct_digits.insert(( ch >= 'a') ? ( ch - 'a' + 10 ) : ( ch - '0' )); + } + if ( distinct_digits.size() < hex_string.size() ) { + return false; + } + + for ( const uint32_t& digit : distinct_digits ) { + if ( hexadecimal % digit > 0 ) { + return false; + } + } + return true; +} + +int main() { + const uint64_t hex_divisor = 15 * 14 * 13 * 12 * 11; + + uint64_t hexadecimal = ( 0xfedcba987654321L / hex_divisor ) * hex_divisor; + while ( ! is_lynch_bell(hexadecimal) ) { + hexadecimal -= hex_divisor; + } + std::cout << "The largest hexadecimal Lynch-Bell number is " << to_hex_string(hexadecimal) << std::endl; +} diff --git a/Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits.java b/Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-1.java similarity index 100% rename from Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits.java rename to Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-1.java diff --git a/Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-2.java b/Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-2.java new file mode 100644 index 0000000000..9189c73708 --- /dev/null +++ b/Task/Largest-number-divisible-by-its-digits/Java/largest-number-divisible-by-its-digits-2.java @@ -0,0 +1,56 @@ +import java.util.Arrays; +import java.util.List; + +public final class LargestNumberDivisibleByItsDigits { + + public static void main(String[] args) { + // Base 10 + final int decimalDivisor = 9 * 8 * 7; + int decimal = ( 9876432 / decimalDivisor ) * decimalDivisor; + + while ( ! isLynchBellDecimal(decimal) ) { + decimal -= decimalDivisor; + } + System.out.println("The largest decimal Lynch-Bell number is " + decimal); + + // Base 16 + final long hexDivisor = 15L * 14 * 13 * 12 * 11; + + long hexadecimal = ( 0xfedcba987654321L / hexDivisor ) * hexDivisor; + while ( ! isLynchBellHex(hexadecimal) ) { + hexadecimal -= hexDivisor; + } + System.out.println("The largest hexadecimal Lynch-Bell number is " + Long.toHexString(hexadecimal)); + } + + private static boolean isLynchBellDecimal(int decimal) { + String decimalString = Integer.toString(decimal); + if ( decimalString.contains("0") || decimalString.contains("5") ) { + return false; + } + + List distinctDigits = + Arrays.stream(decimalString.split("")).map( s -> Integer.valueOf(s) ).distinct().toList(); + if ( distinctDigits.size() < decimalString.length() ) { + return false; + } + + return distinctDigits.stream().allMatch( i -> ( decimal % i ) == 0 ); + } + + private static boolean isLynchBellHex(long hexadecimal) { + String hexString = Long.toHexString(hexadecimal); + if ( hexString.contains("0") ) { + return false; + } + + List distinctDigits = + Arrays.stream(hexString.split("")).map( s -> Integer.valueOf(s, 16) ).distinct().toList(); + if ( distinctDigits.size() < hexString.length() ) { + return false; + } + + return distinctDigits.stream().allMatch( i -> ( hexadecimal % i ) == 0 ); + } + +} diff --git a/Task/Last-letter-first-letter/EasyLang/last-letter-first-letter.easy b/Task/Last-letter-first-letter/EasyLang/last-letter-first-letter.easy new file mode 100644 index 0000000000..fc6da4d81f --- /dev/null +++ b/Task/Last-letter-first-letter/EasyLang/last-letter-first-letter.easy @@ -0,0 +1,43 @@ +repeat + s$ = input + until s$ = "" + for n$ in strsplit s$ " " + pok$[] &= n$ + . +. +# +chain$[] = [ ] +proc search lng . . + if lng > len chain$[] + chain$[] = [ ] + for j to lng + chain$[] &= pok$[j] + . + . + lastc$ = substr pok$[lng] len pok$[lng] 1 + for i = lng + 1 to len pok$[] + if substr pok$[i] 1 1 = lastc$ + swap pok$[i] pok$[lng + 1] + search lng + 1 + swap pok$[i] pok$[lng + 1] + . + . +. +for i to len pok$[] + swap pok$[i] pok$[1] + search 1 + swap pok$[i] pok$[1] +. +for p$ in chain$[] + write p$ & " " +. +# +input_data +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 diff --git a/Task/Latin-Squares-in-reduced-form/11l/latin-squares-in-reduced-form.11l b/Task/Latin-Squares-in-reduced-form/11l/latin-squares-in-reduced-form.11l index de09bb38e8..e6c75a51df 100644 --- a/Task/Latin-Squares-in-reduced-form/11l/latin-squares-in-reduced-form.11l +++ b/Task/Latin-Squares-in-reduced-form/11l/latin-squares-in-reduced-form.11l @@ -6,7 +6,7 @@ F dList(n, =start) a.sort_range(1..) V first = a[1] [[Int]] r - F recurse(Int last) -> N + F recurse(Int last) -> Void I (last == @first) L(v) @a[1..] I L.index + 1 == v @@ -41,7 +41,7 @@ F reducedLatinSquares(n, echo) rlatin[0][j] = j + 1 V count = 0 - F recurse(Int i) -> N + F recurse(Int i) -> Void V rows = dList(@n, i) L(r) 0 .< rows.len diff --git a/Task/Least-common-multiple/PascalABC.NET/least-common-multiple.pas b/Task/Least-common-multiple/PascalABC.NET/least-common-multiple.pas new file mode 100644 index 0000000000..6435af5741 --- /dev/null +++ b/Task/Least-common-multiple/PascalABC.NET/least-common-multiple.pas @@ -0,0 +1,12 @@ +function GCD(a,b: integer): integer; +begin + while b > 0 do + (a,b) := (b,a mod b); + Result := a; +end; + +function LCM(a,b: integer): integer := a = 0 ? 0 : a div GCD(a,b) * b; + +begin + Println(LCM(12,18)); +end. diff --git a/Task/Least-common-multiple/Standard-ML/least-common-multiple-1.ml b/Task/Least-common-multiple/Standard-ML/least-common-multiple-1.ml new file mode 100644 index 0000000000..f8dab0fca7 --- /dev/null +++ b/Task/Least-common-multiple/Standard-ML/least-common-multiple-1.ml @@ -0,0 +1,4 @@ +fun gcd (0,n) = n + | gcd (m,n) = gcd(n mod m, m) + +fun lcm (m,n) = abs(x * y) div gcd (m, n) diff --git a/Task/Least-common-multiple/Standard-ML/least-common-multiple.ml b/Task/Least-common-multiple/Standard-ML/least-common-multiple-2.ml similarity index 100% rename from Task/Least-common-multiple/Standard-ML/least-common-multiple.ml rename to Task/Least-common-multiple/Standard-ML/least-common-multiple-2.ml diff --git a/Task/Least-common-multiple/Uiua/least-common-multiple.uiua b/Task/Least-common-multiple/Uiua/least-common-multiple.uiua new file mode 100644 index 0000000000..8fac60e0d5 --- /dev/null +++ b/Task/Least-common-multiple/Uiua/least-common-multiple.uiua @@ -0,0 +1,4 @@ +# Greatest Common Divisor using Euclidean algorithm +Gcd ← ⊙◌⍢(⟜◿:|±,) +# Least Common Multiple +Lcm ← ÷⊃(Gcd|⌵×) diff --git a/Task/Letter-frequency/Emacs-Lisp/letter-frequency.l b/Task/Letter-frequency/Emacs-Lisp/letter-frequency.l index 3daa2b94ea..3d9cd34ac1 100644 --- a/Task/Letter-frequency/Emacs-Lisp/letter-frequency.l +++ b/Task/Letter-frequency/Emacs-Lisp/letter-frequency.l @@ -1,14 +1,15 @@ (defun tally-letter-frequency-in-file () - (let ((alphabet "abcdefghijklmnopqrstuvwxyz") - (current-letter) - (count) - (case-fold-search t)) ; ignores case - (find-file "~/Documents/Elisp/MobyDick.txt") ; identify file to work with - (while (>= (length alphabet) 1) ; as long as there is at least 1 letter left in alphabet - (beginning-of-buffer) + "Open a file and count the number of times each letter appears." + (let ((alphabet "abcdefghijklmnopqrstuvwxyz") ; variable to hold letters we will be counting + (current-letter) ; variable to hold current letter we will be counting + (count) ; variable to count how many times current letter appears + (case-fold-search t)) ; ignores case + (find-file "~/Documents/Elisp/MobyDick.txt") ; open file in a buffer (or switch to buffer if file is already open) + (while (>= (length alphabet) 1) ; as long as there is at least 1 letter left in alphabet + (beginning-of-buffer) ; go to the beginning of the buffer (setq current-letter (substring alphabet 0 1)) ; set current-letter to first letter of alphabet - (setq count (how-many current-letter)) ; count how many of this letter in file - (end-of-buffer) - (insert (format "\n%s%s - %7d" current-letter (upcase current-letter) count)) - (setq alphabet (substring alphabet 1 nil))) ; remove first letter from alphabet + (setq count (how-many current-letter)) ; count how many of this letter in file + (end-of-buffer) ; go to the end of the buffer + (insert (format "\n%s%s - %7d" current-letter (upcase current-letter) count)) ; write how many times that letter appears + (setq alphabet (substring alphabet 1 nil))) ; remove first letter from alphabet (insert "\n"))) diff --git a/Task/Letter-frequency/Langur/letter-frequency.langur b/Task/Letter-frequency/Langur/letter-frequency.langur index 085e7258f8..c21156b15c 100644 --- a/Task/Letter-frequency/Langur/letter-frequency.langur +++ b/Task/Letter-frequency/Langur/letter-frequency.langur @@ -1,8 +1,8 @@ -val .countLetters = fn(.s) { - for[=h{}] .s2 in split(replace(.s, RE/\P{L}/)) { - _for[.s2; 0] += 1 +val countLetters = fn(s) { + for[={:}] s2 in split(replace(s, RE/\P{L}/)) { + _for[s2; 0] += 1 } } -val .counts = .countLetters(readfile "./fuzz.txt") -writeln join "\n", map fn(.k) $"\.k;: \.counts[.k];", keys .counts +val counts = countLetters(readfile("./fuzz.txt")) +writeln join("\n", map(fn(k) { "{{k}}: {{counts[k]}}" }, keys(counts))) diff --git a/Task/Letter-frequency/Refal/letter-frequency.refal b/Task/Letter-frequency/Refal/letter-frequency.refal new file mode 100644 index 0000000000..9319452d9f --- /dev/null +++ b/Task/Letter-frequency/Refal/letter-frequency.refal @@ -0,0 +1,48 @@ +$ENTRY Go { + , : { + = ; + e.File, : e.Text, + : e.Counts + = >; + }; +}; + +Letters { + = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; +}; + +ShowLetterCounts { + (e.T) = ; + (e.T) s.L e.Ls, + : s.UL, : s.ULN, + : s.LL, : s.LLN, + <+ s.ULN s.LLN>: s.Total + = > + ; +}; + +ReadFile { + s.Chan e.Filename = + + ; + (s.Chan), : { + 0 = ; + e.Line = e.Line '\n' ; + }; +}; + +Tally { + (e.T) = e.T; + (e.T) s.X e.Xs = ) e.Xs>; + e.Xs = ; +} + +Inc { + (e.1 (s.I s.N) e.2) s.I = e.1 (s.I <+ 1 s.N>) e.2; + (e.X) s.I = e.X (s.I 1); +}; + +Item { + (e.1 (s.I s.N) e.2) s.I = s.N; + (e.X) s.I = 0; +}; diff --git a/Task/Levenshtein-distance-Alignment/Jq/levenshtein-distance-alignment.jq b/Task/Levenshtein-distance-Alignment/Jq/levenshtein-distance-alignment.jq new file mode 100644 index 0000000000..4b89daf811 --- /dev/null +++ b/Task/Levenshtein-distance-Alignment/Jq/levenshtein-distance-alignment.jq @@ -0,0 +1,44 @@ +def reverseString: explode | reverse | implode; + +def levenshteinAlign($x; $y): + def min($a;$b): [$a,$b]|min; + + ($x|length + 1) as $a1 + | ($y|length + 1) as $b1 + | ($x | ascii_downcase) as $a + | ($y | ascii_downcase) as $b + | [range(0; $b1) | 0] as $zeros + | {costs: [range(0; $a1) | $zeros]} + | reduce range(0; $b1) as $j (.; .costs[0][$j] = $j) + | reduce range(1; $a1) as $i (.; + .costs[$i][0] = $i + | reduce range(1; $b1) as $j (.; + (.costs[$i - 1][$j - 1] + (if $a[$i - 1: $i] == $b[$j - 1: $j] then 0 else 1 end)) as $temp + | .costs[$i][$j] = min( $temp; 1 + min(.costs[$i - 1][$j]; .costs[$i][$j - 1] )) )) + + # walk back through matrix to figure out path + | .aPathRev = "" + | .bPathRev = "" + | .i = ($a|length) + | .j = ($b|length) + | until (.i == 0 or .j == 0; + (.costs[.i - 1][.j - 1] + (if $a[.i - 1: .i] == $b[.j - 1: .j] then 0 else 1 end)) as $temp + | .costs[.i][.j] as $cij + | if $cij == $temp + then .i += -1 + | .aPathRev += $a[.i: .i+1] + | .j += -1 + | .bPathRev += $b[.j: .j+1] + elif $cij == 1 + .costs[.i-1][.j] + then .i += -1 + | .aPathRev += $a[.i:.i+1] + | .bPathRev += "-" + elif $cij == 1 + .costs[.i][.j-1] + then .aPathRev += "-" + | .j += -1 + | .bPathRev += $b[.j: .j+1] + end) + | [.aPathRev, .bPathRev ] | map(reverseString); + +levenshteinAlign("place"; "palace"), +levenshteinAlign("rosettacode";"raisethysword") diff --git a/Task/Levenshtein-distance/JavaScript/levenshtein-distance-2.js b/Task/Levenshtein-distance/JavaScript/levenshtein-distance-2.js index 62203cea9b..c9624b62d5 100644 --- a/Task/Levenshtein-distance/JavaScript/levenshtein-distance-2.js +++ b/Task/Levenshtein-distance/JavaScript/levenshtein-distance-2.js @@ -1,32 +1,44 @@ (() => { - 'use strict'; + "use strict"; + + // ------------ LEVENSHTEIN EDIT DISTANCE ------------ // levenshtein :: String -> String -> Int - const levenshtein = sa => sb => { - const cs = chars(sa); - const go = (ns, c) => { - const calc = z => tpl => { - const [c1, x, y] = Array.from(tpl); - return minimum([ - succ(y), - succ(z), - x + (c !== c1 ? 1 : 0) - ]); + const levenshtein = sa => + // The Levenshtein edit distance + // between two given strings. + sb => { + const cs = [...sa]; + const go = (ns, c) => { + const calc = z => tpl => { + const [c1, x, y] = Array.from(tpl); + + return Math.min( + 1 + y, + 1 + z, + x + ( + c1 === c + ? 0 + : 1 + ) + ); + }; + const [n, ...ns1] = ns; + + return scanl(calc)(1 + n)( + zip3(cs)(ns)(ns1) + ); }; - const [n, ns1] = [ns[0], ns.slice(1)]; - return scanl(calc)(succ(n))( - zip3(cs)(ns)(ns1) + + return last( + [...sb].reduce( + go, + enumFromTo(0)(cs.length) + ) ); }; - return last( - chars(sb).reduce( - go, - enumFromTo(0)(cs.length) - ) - ); - }; - // ----------------------- TEST ------------------------ + // ---------------------- TEST ----------------------- const main = () => [ ["kitten", "sitting"], ["sitting", "kitten"], @@ -35,38 +47,7 @@ ].map(uncurry(levenshtein)); - // ----------------- GENERIC FUNCTIONS ----------------- - - // Tuple (,) :: a -> b -> (a, b) - const Tuple = a => - b => ({ - type: 'Tuple', - '0': a, - '1': b, - length: 2 - }); - - - // TupleN :: a -> b ... -> (a, b ... ) - function TupleN() { - const - args = Array.from(arguments), - n = args.length; - return 2 < n ? Object.assign( - args.reduce((a, x, i) => Object.assign(a, { - [i]: x - }), { - type: 'Tuple' + n.toString(), - length: n - }) - ) : args.reduce((f, x) => f(x), Tuple); - }; - - - // chars :: String -> [Char] - const chars = s => - s.split(''); - + // ---------------- GENERIC FUNCTIONS ---------------- // enumFromTo :: Int -> Int -> [Int] const enumFromTo = m => @@ -76,68 +57,53 @@ // last :: [a] -> a - const last = xs => ( + const last = xs => { // The last item of a list. - ys => 0 < ys.length ? ( - ys.slice(-1)[0] - ) : undefined - )(xs); + const n = xs.length; - - // minimum :: Ord a => [a] -> a - const minimum = xs => ( - // The least value of xs. - ys => 0 < ys.length ? ( - ys.slice(1) - .reduce((a, y) => y < a ? y : a, ys[0]) - ) : undefined - )(xs); - - - // length :: [a] -> Int - const length = xs => - // Returns Infinity over objects without finite - // length. This enables zip and zipWith to choose - // the shorter argument when one is non-finite, - // like cycle, repeat etc - 'GeneratorFunction' !== xs.constructor.constructor.name ? ( - xs.length - ) : Infinity; + return 0 < n + ? xs[n - 1] + : null; + }; // scanl :: (b -> a -> b) -> b -> [a] -> [b] - const scanl = f => startValue => xs => - xs.reduce((a, x) => { - const v = f(a[0])(x); - return Tuple(v)(a[1].concat(v)); - }, Tuple(startValue)([startValue]))[1]; + const scanl = f => + // The series of interim values arising + // from a catamorphism. Parallel to foldl. + startValue => xs => + xs.reduce( + (a, x) => { + const v = f(a[0])(x); - - // succ :: Enum a => a -> a - const succ = x => - 1 + x; + return [v, a[1].concat(v)]; + }, [startValue, [startValue]] + )[1]; // uncurry :: (a -> b -> c) -> ((a, b) -> c) const uncurry = f => // A function over a pair, derived // from a curried function. - function () { + (...args) => { const - args = arguments, - xy = Boolean(args.length % 2) ? ( - args[0] - ) : args; - return f(xy[0])(xy[1]); + [x, y] = Boolean(args.length % 2) + ? args[0] + : args; + + return f(x)(y); }; // zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] const zip3 = xs => - ys => zs => xs - .slice(0, Math.min(...[xs, ys, zs].map(length))) - .map((x, i) => TupleN(x, ys[i], zs[i])); + ys => zs => xs.slice( + 0, + Math.min(...[xs, ys, zs].map(x => x.length)) + ) + .map((x, i) => [x, ys[i], zs[i]]); + // MAIN --- - return JSON.stringify(main()) + return JSON.stringify(main()); })(); diff --git a/Task/Levenshtein-distance/SETL/levenshtein-distance.setl b/Task/Levenshtein-distance/SETL/levenshtein-distance.setl new file mode 100644 index 0000000000..4d9a4a07c3 --- /dev/null +++ b/Task/Levenshtein-distance/SETL/levenshtein-distance.setl @@ -0,0 +1,26 @@ +program levenshtein_distance; + tests := {['kitten', 'sitting'], ['rosettacode', 'raisethysword']}; + loop for dest = tests(src) do + print(src + ' -> ' + dest + ': ' + str levenshtein(src, dest)); + end loop; + + proc levenshtein(s, t); + d := {}; + loop for i in [1..#s] do + d(i,0) := i; + end loop; + loop for j in [1..#t] do + d(0,j) := j; + end loop; + loop for j in [1..#t] do + loop for i in [1..#s] do + d(i,j) := min/[ + (d(i-1,j) ? 0) + 1, + (d(i,j-1) ? 0) + 1, + (d(i-1,j-1) ? 0) + if s(i) = t(j) then 0 else 1 end + ]; + end loop; + end loop; + return d(#s, #t); + end proc; +end program; diff --git a/Task/Levenshtein-distance/Uiua/levenshtein-distance.uiua b/Task/Levenshtein-distance/Uiua/levenshtein-distance.uiua new file mode 100644 index 0000000000..992383e0b3 --- /dev/null +++ b/Task/Levenshtein-distance/Uiua/levenshtein-distance.uiua @@ -0,0 +1,15 @@ +Lev ← |1 memo( + ±/↧≡◇⧻. + ⨬( + /↥≡◇⧻ # If either is zero, return length of other + | /≍≡◇⊢. # Both start with same letter? + ⨬( + # NO: 1 + min(Lev of (tail a, tail b), (tail a, b), (a, tail b)) + +1/↧≡Lev[⊃(⍚↘1|⍜⊢⍚↘1|⍜(⊡1|⍚↘1))] + | + Lev ⍚↘1 # YES: = Lev of (tail a, tail b) + ) + ) +) +Lev {"kitten" "sitting"} +Lev {"rosettacode" "raisethysword"} diff --git a/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas b/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas new file mode 100644 index 0000000000..3c888aa14f --- /dev/null +++ b/Task/List-comprehensions/PascalABC.NET/list-comprehensions.pas @@ -0,0 +1,2 @@ +## +(1..20).CartesianPower(3).Where(\(x,y,z) -> (x*x + y*y = z*z) and (x < y)).PrintLines diff --git a/Task/List-comprehensions/Uiua/list-comprehensions.uiua b/Task/List-comprehensions/Uiua/list-comprehensions.uiua new file mode 100644 index 0000000000..e4bed8401a --- /dev/null +++ b/Task/List-comprehensions/Uiua/list-comprehensions.uiua @@ -0,0 +1,3 @@ +☇1⊞≡⊂⊞⊂..+1⇡20 # Cartesian product, flattened. +▽⊸≡(=1/↧/≥◫2) # Keep triplets which are in ascending order. +▽⊸≡(=⊃(/+⊏0_1|⊡2)×.) # Keep pythagorean triplets. diff --git a/Task/Literals-Floating-point/PascalABC.NET/literals-floating-point.pas b/Task/Literals-Floating-point/PascalABC.NET/literals-floating-point.pas new file mode 100644 index 0000000000..f755fdbcca --- /dev/null +++ b/Task/Literals-Floating-point/PascalABC.NET/literals-floating-point.pas @@ -0,0 +1,3 @@ +1.0 +1e3 +2.5E-4 diff --git a/Task/Literals-String/PascalABC.NET/literals-string.pas b/Task/Literals-String/PascalABC.NET/literals-string.pas new file mode 100644 index 0000000000..c329e34bb9 --- /dev/null +++ b/Task/Literals-String/PascalABC.NET/literals-string.pas @@ -0,0 +1,4 @@ +## +var s1 := 'Hello'; +var s2 := 'quotes ''in'' string'; +var s3 := 'chars with a'#13#10'given code in string'; diff --git a/Task/Logical-operations/Langur/logical-operations.langur b/Task/Logical-operations/Langur/logical-operations.langur index bdcc9fcb79..ef567db8c9 100644 --- a/Task/Logical-operations/Langur/logical-operations.langur +++ b/Task/Logical-operations/Langur/logical-operations.langur @@ -1,24 +1,26 @@ -val .test = fn(.a, .b) join("\n", [ - $"not \.a;: \{not .a}", - $"\.a; and \.b;: \.a and .b;", - $"\.a; or \.b;: \.a or .b;", - $"\.a; nand \.b;: \.a nand .b;", - $"\.a; nor \.b;: \.a nor .b;", - $"\.a; xor \.b;: \.a xor .b;", - $"\.a; nxor \.b;: \.a nxor .b;", - "", +val test = fn(a, b) { + join("\n", [ + "not {{a}}: {{not a}}", + "{{a}} and {{b}}: {{a and b}}", + "{{a}} nand {{b}}: {{a nand b}}", + "{{a}} or {{b}}: {{a or b}}", + "{{a}} nor {{b}}: {{a nor b}}", + "{{a}} xor {{b}}: {{a xor b}}", + "{{a}} nxor {{b}}: {{a nxor b}}", + "", + + "not? {{a}}: {{not? a}}", + "{{a}} and? {{b}}: {{a and? b}}", + "{{a}} nand? {{b}}: {{a nand? b}}", + "{{a}} or? {{b}}: {{a or? b}}", + "{{a}} nor? {{b}}: {{a nor? b}}", + "{{a}} xor? {{b}}: {{a xor? b}}", + "{{a}} nxor? {{b}}: {{a nxor? b}}", + "\n", + ]) +} - $"not? \.a;: \{not? .a}", - $"\.a; and? \.b;: \.a and? .b;", - $"\.a; or? \.b;: \.a or? .b;", - $"\.a; nand? \.b;: \.a nand? .b;", - $"\.a; nor? \.b;: \.a nor? .b;", - $"\.a; xor? \.b;: \.a xor? .b;", - $"\.a; nxor? \.b;: \.a nxor? .b;", - "\n", -]) - -val .tests = [ +val tests = [ [true, false], [false, true], [true, true], @@ -32,6 +34,6 @@ val .tests = [ [null, null], ] -for .t in .tests { - write .test(.t[1], .t[2]) +for t in tests { + write test(t[1], t[2]) } diff --git a/Task/Longest-common-subsequence/EasyLang/longest-common-subsequence.easy b/Task/Longest-common-subsequence/EasyLang/longest-common-subsequence.easy index 91136e30d9..b7a1c9c571 100644 --- a/Task/Longest-common-subsequence/EasyLang/longest-common-subsequence.easy +++ b/Task/Longest-common-subsequence/EasyLang/longest-common-subsequence.easy @@ -1,5 +1,5 @@ func$ right a$ n . - return substr a$ -n n + return substr a$ (len a$ - n + 1) n . func$ left a$ n . if n < 0 diff --git a/Task/Longest-common-subsequence/PascalABC.NET/longest-common-subsequence.pas b/Task/Longest-common-subsequence/PascalABC.NET/longest-common-subsequence.pas new file mode 100644 index 0000000000..dd3ca9502b --- /dev/null +++ b/Task/Longest-common-subsequence/PascalABC.NET/longest-common-subsequence.pas @@ -0,0 +1,30 @@ +function Lengths(x,y: string): array[,] of integer; +begin + var (m,n) := (x.Length,y.Length); + var C := new integer[m+1, n+1]; // filled with zeroes + for var i:=1 to m do + for var j:=1 to n do + if x[i] = y[j] then + C[i,j] := C[i-1,j-1] + 1 + else C[i,j] := max(C[i,j-1], C[i-1,j]); + Result := C; +end; + +function lcshelper(x,y: string; i,j: integer): string; +begin + var C := Lengths(x,y); + if (i = 0) or (j = 0) then + Result := '' + else if X[i] = Y[j] then + Result := lcshelper(X, Y, i-1, j-1) + X[i] + else if C[i,j-1] > C[i-1,j] then + Result := lcshelper(X, Y, i, j-1) + else Result := lcshelper(X, Y, i-1, j) +end; + +function lcs(x,y: string) := lcshelper(x,y,x.Length,y.Length); + +begin + Println(lcs('1234','1224533324')); + Println(lcs('thisisatest','testing123testing')); +end. diff --git a/Task/Longest-common-substring/Langur/longest-common-substring.langur b/Task/Longest-common-substring/Langur/longest-common-substring.langur index 8cb9c31797..951978e86f 100644 --- a/Task/Longest-common-substring/Langur/longest-common-substring.langur +++ b/Task/Longest-common-substring/Langur/longest-common-substring.langur @@ -1,16 +1,16 @@ -val .lcs = fn(.s1, .s2) { - var .l, .r, .sublen = 1, 0, 0 - for .i of .s1 { - for .j in .i .. len(.s1) { - if not matching(s2s(.s1, .i .. .j), .s2): break - if .sublen <= .j - .i { - .l, .r = .i, .j - .sublen = .j - .i +val lcs = fn(s1, s2) { + var l, r, sublen = 1, 0, 0 + for i of s1 { + for j in i .. len(s1) { + if not matching(s2s(s1, i .. j), s2): break + if sublen <= j - i { + l, r = i, j + sublen = j - i } } } - if .r == 0: return "" - s2s .s1, .l .. .r + if r == 0: return "" + s2s s1, l .. r } -writeln .lcs("thisisatest", "testing123testing") +writeln lcs("thisisatest", "testing123testing") diff --git a/Task/Longest-increasing-subsequence/EasyLang/longest-increasing-subsequence.easy b/Task/Longest-increasing-subsequence/EasyLang/longest-increasing-subsequence.easy new file mode 100644 index 0000000000..139bb77f76 --- /dev/null +++ b/Task/Longest-increasing-subsequence/EasyLang/longest-increasing-subsequence.easy @@ -0,0 +1,37 @@ +func[] lis x[] . + n = len x[] + len p[] n + len m[] n + for i to n + lo = 1 + hi = lng + while lo <= hi + mid = (lo + hi) div 2 + if x[m[mid]] < x[i] + lo = mid + 1 + else + hi = mid - 1 + . + . + if lo > 1 + p[i] = m[lo - 1] + . + m[lo] = i + if lo > lng + lng = lo + . + . + len res[] lng + if lng > 0 + k = m[lng] + for i = lng downto 1 + res[i] = x[k] + k = p[k] + . + . + return res[] +. +tests[][] = [ [ 3 2 6 4 5 1 ] [ 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 ] ] +for x to len tests[][] + print lis tests[x][] +. diff --git a/Task/Look-and-say-sequence/ABC/look-and-say-sequence.abc b/Task/Look-and-say-sequence/ABC/look-and-say-sequence.abc new file mode 100644 index 0000000000..ddf99eaef0 --- /dev/null +++ b/Task/Look-and-say-sequence/ABC/look-and-say-sequence.abc @@ -0,0 +1,19 @@ +HOW TO RETURN look.and.say seq: + PUT "" IN result + PUT 0 IN n + PUT "" IN c + FOR ch IN seq: + SELECT: + c=ch: + PUT n+1 IN n + ELSE: + IF n>0: PUT result^"`n`"^c IN result + PUT 1 IN n + PUT ch IN c + RETURN result^"`n`"^c + +PUT "1" IN item + +FOR i IN {1..14}: + WRITE item/ + PUT look.and.say item IN item diff --git a/Task/Look-and-say-sequence/EasyLang/look-and-say-sequence.easy b/Task/Look-and-say-sequence/EasyLang/look-and-say-sequence.easy index 2a924dee19..94c6316232 100644 --- a/Task/Look-and-say-sequence/EasyLang/look-and-say-sequence.easy +++ b/Task/Look-and-say-sequence/EasyLang/look-and-say-sequence.easy @@ -1,5 +1,4 @@ proc lookandsay . a$ . - s$ = "" c = 1 p$ = substr a$ 1 1 for i = 2 to len a$ diff --git a/Task/Look-and-say-sequence/Uiua/look-and-say-sequence.uiua b/Task/Look-and-say-sequence/Uiua/look-and-say-sequence.uiua new file mode 100644 index 0000000000..2c91933898 --- /dev/null +++ b/Task/Look-and-say-sequence/Uiua/look-and-say-sequence.uiua @@ -0,0 +1,2 @@ +Rle ← /◇⊂≡⍚(⊂⊃(°⋕⧻|⊢))⊜□⊸(+1⊛) +⇌[⍥(⍚Rle.)10□] "1" diff --git a/Task/Loop-over-multiple-arrays-simultaneously/PascalABC.NET/loop-over-multiple-arrays-simultaneously.pas b/Task/Loop-over-multiple-arrays-simultaneously/PascalABC.NET/loop-over-multiple-arrays-simultaneously.pas new file mode 100644 index 0000000000..c2252b2610 --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/PascalABC.NET/loop-over-multiple-arrays-simultaneously.pas @@ -0,0 +1,12 @@ +begin + var a1 := Arr('a','b','c'); + var a2 := Arr('A','B','C'); + var a3 := Arr(1,2,3); + for var i:=0 to a1.Length-1 do + Writeln(a1[i],a2[i],a3[i]); + Writeln; + foreach var (x,y,z) in a1.Zip(a2,a3) do + Writeln(x,y,z); + Writeln; + a1.Zip(a2,a3).PrintLines(t -> t[0]+t[1]+t[2]); +end. diff --git a/Task/Loop-over-multiple-arrays-simultaneously/Python/loop-over-multiple-arrays-simultaneously-5.py b/Task/Loop-over-multiple-arrays-simultaneously/Python/loop-over-multiple-arrays-simultaneously-5.py new file mode 100644 index 0000000000..533838e409 --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/Python/loop-over-multiple-arrays-simultaneously-5.py @@ -0,0 +1,5 @@ +a1 = ['a', 'b', 'c'] +a2 = ['A', 'B', 'C'] +a3 = [1, 2, 3] +for i in range(len(a1)): + print(a1[i] + a2[i] + str(a3[i])) diff --git a/Task/Loop-over-multiple-arrays-simultaneously/Uiua/loop-over-multiple-arrays-simultaneously.uiua b/Task/Loop-over-multiple-arrays-simultaneously/Uiua/loop-over-multiple-arrays-simultaneously.uiua new file mode 100644 index 0000000000..be1c9e378f --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/Uiua/loop-over-multiple-arrays-simultaneously.uiua @@ -0,0 +1 @@ +≡(⊂⊂) "abc" "ABC" "123" diff --git a/Task/Loop-over-multiple-arrays-simultaneously/Vim-Script/loop-over-multiple-arrays-simultaneously.vim b/Task/Loop-over-multiple-arrays-simultaneously/Vim-Script/loop-over-multiple-arrays-simultaneously.vim new file mode 100644 index 0000000000..5272194e0b --- /dev/null +++ b/Task/Loop-over-multiple-arrays-simultaneously/Vim-Script/loop-over-multiple-arrays-simultaneously.vim @@ -0,0 +1,6 @@ +let a1 = ['a', 'b', 'c'] +let a2 = ['A', 'B', 'C'] +let a3 = [1, 2, 3] +for i in range(0, len(a1) - 1) + echo a1[i] .. a2[i] .. a3[i] +endfor diff --git a/Task/Loops-Break/Langur/loops-break.langur b/Task/Loops-Break/Langur/loops-break.langur index ec8897cb73..7733b80fed 100644 --- a/Task/Loops-Break/Langur/loops-break.langur +++ b/Task/Loops-Break/Langur/loops-break.langur @@ -1,5 +1,5 @@ for { - val .i = random 0..19 - write .i, " " - if .i == 10 { writeln(); break } + val i = random(0..19) + write i, " " + if i == 10 { writeln(); break } } diff --git a/Task/Loops-Break/PascalABC.NET/loops-break.pas b/Task/Loops-Break/PascalABC.NET/loops-break.pas new file mode 100644 index 0000000000..849c5593e4 --- /dev/null +++ b/Task/Loops-Break/PascalABC.NET/loops-break.pas @@ -0,0 +1,10 @@ +begin + while True do + begin + var x := Random(0,19); + Print(x); + if x = 10 then + break; + Print(Random(0,19)); + end; +end. diff --git a/Task/Loops-Break/S-BASIC/loops-break-1.basic b/Task/Loops-Break/S-BASIC/loops-break-1.basic new file mode 100644 index 0000000000..24f1eddf52 --- /dev/null +++ b/Task/Loops-Break/S-BASIC/loops-break-1.basic @@ -0,0 +1,13 @@ +var n = integer + +while (1 = 1) do + begin + n = int(rnd(1) * 20) + print n; + if n = 10 then goto 0_done + n = int(rnd(1) * 20) + print n + end +0_done print " That's all!" + +end diff --git a/Task/Loops-Break/S-BASIC/loops-break-2.basic b/Task/Loops-Break/S-BASIC/loops-break-2.basic new file mode 100644 index 0000000000..a4ab30ae07 --- /dev/null +++ b/Task/Loops-Break/S-BASIC/loops-break-2.basic @@ -0,0 +1,14 @@ +var n = integer + +repeat + begin + n = int(rnd(1) * 20) + print n; + if n <> 10 then + print int(rnd(1) * 20) + end +until n = 10 + +print " That's all!" + +end diff --git a/Task/Loops-Continue/Langur/loops-continue.langur b/Task/Loops-Continue/Langur/loops-continue.langur index 6cb0ac4dee..f255b18d30 100644 --- a/Task/Loops-Continue/Langur/loops-continue.langur +++ b/Task/Loops-Continue/Langur/loops-continue.langur @@ -1,5 +1,5 @@ -for .i of 10 { - write .i - if .i div 5 { writeln(); next } +for i of 10 { + write i + if i div 5 { writeln(); next } write ", " } diff --git a/Task/Loops-Continue/PascalABC.NET/loops-continue.pas b/Task/Loops-Continue/PascalABC.NET/loops-continue.pas new file mode 100644 index 0000000000..f6e8c98877 --- /dev/null +++ b/Task/Loops-Continue/PascalABC.NET/loops-continue.pas @@ -0,0 +1,12 @@ +begin + for var i:=1 to 10 do + begin + Write(i); + if i mod 5 = 0 then + begin + Writeln; + continue + end; + Write(', '); + end; +end. diff --git a/Task/Loops-Do-while/PascalABC.NET/loops-do-while.pas b/Task/Loops-Do-while/PascalABC.NET/loops-do-while.pas new file mode 100644 index 0000000000..fc9076dbda --- /dev/null +++ b/Task/Loops-Do-while/PascalABC.NET/loops-do-while.pas @@ -0,0 +1,7 @@ +begin + var a := 0; + repeat + a += 1; + Print(a); + until a mod 6 = 0; +end. diff --git a/Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-2.basic b/Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-2.basic deleted file mode 100644 index 933db6e6c5..0000000000 --- a/Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-2.basic +++ /dev/null @@ -1,6 +0,0 @@ -10 REM Loops/Do-while -20 LET I = 0 -30 LET I = I + 1 -40 PRINT I -50 IF (I / 6) * 6 <> I THEN GOTO 30 -60 END diff --git a/Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-1.basic b/Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while.basic similarity index 100% rename from Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while-1.basic rename to Task/Loops-Do-while/Sinclair-ZX81-BASIC/loops-do-while.basic diff --git a/Task/Loops-Downward-for/Langur/loops-downward-for-1.langur b/Task/Loops-Downward-for/Langur/loops-downward-for-1.langur index bfbdf6d896..3da248bfae 100644 --- a/Task/Loops-Downward-for/Langur/loops-downward-for-1.langur +++ b/Task/Loops-Downward-for/Langur/loops-downward-for-1.langur @@ -1,3 +1,3 @@ -for .i in 10..0 { - writeln .i +for i in 10..0 { + writeln i } diff --git a/Task/Loops-Downward-for/Langur/loops-downward-for-2.langur b/Task/Loops-Downward-for/Langur/loops-downward-for-2.langur index 7417b2f17f..8c69aae949 100644 --- a/Task/Loops-Downward-for/Langur/loops-downward-for-2.langur +++ b/Task/Loops-Downward-for/Langur/loops-downward-for-2.langur @@ -1,3 +1,3 @@ -for .i = 10; .i > -1; .i -= 1 { - writeln .i +for i = 10; i > -1; i -= 1 { + writeln i } diff --git a/Task/Loops-Downward-for/PascalABC.NET/loops-downward-for.pas b/Task/Loops-Downward-for/PascalABC.NET/loops-downward-for.pas new file mode 100644 index 0000000000..b13c08d2b2 --- /dev/null +++ b/Task/Loops-Downward-for/PascalABC.NET/loops-downward-for.pas @@ -0,0 +1,3 @@ +## +for var i:=10 downto 0 do + Print(i); diff --git a/Task/Loops-For-with-a-specified-step/Langur/loops-for-with-a-specified-step.langur b/Task/Loops-For-with-a-specified-step/Langur/loops-for-with-a-specified-step.langur index 2a6ab6d93e..bd20903a7f 100644 --- a/Task/Loops-For-with-a-specified-step/Langur/loops-for-with-a-specified-step.langur +++ b/Task/Loops-For-with-a-specified-step/Langur/loops-for-with-a-specified-step.langur @@ -1,3 +1,3 @@ -for .i = 1; .i < 10; .i += 2 { - writeln .i +for i = 1; i < 10; i += 2 { + writeln i } diff --git a/Task/Loops-For-with-a-specified-step/PascalABC.NET/loops-for-with-a-specified-step.pas b/Task/Loops-For-with-a-specified-step/PascalABC.NET/loops-for-with-a-specified-step.pas new file mode 100644 index 0000000000..6f406a3d66 --- /dev/null +++ b/Task/Loops-For-with-a-specified-step/PascalABC.NET/loops-for-with-a-specified-step.pas @@ -0,0 +1,7 @@ +begin + for var i:=1 to 10 step 2 do + Print(i); + Println; + for var i:=20 to 1 step -3 do + Print(i); +end. diff --git a/Task/Loops-For/Langur/loops-for-1.langur b/Task/Loops-For/Langur/loops-for-1.langur index faf638231a..1c4053bfc5 100644 --- a/Task/Loops-For/Langur/loops-for-1.langur +++ b/Task/Loops-For/Langur/loops-for-1.langur @@ -1,5 +1,5 @@ -for .i = 0; .i < 5; .i += 1 { - for .j = 0; .j <= .i; .j += 1 { +for i = 0; i < 5; i += 1 { + for j = 0; j <= i; j += 1 { write "*" } writeln() diff --git a/Task/Loops-For/Langur/loops-for-2.langur b/Task/Loops-For/Langur/loops-for-2.langur index 3d2d45c2d0..0e7ff47e68 100644 --- a/Task/Loops-For/Langur/loops-for-2.langur +++ b/Task/Loops-For/Langur/loops-for-2.langur @@ -1,5 +1,5 @@ -for .i of 5 { - for of .i { +for i of 5 { + for of i { write "*" } writeln() diff --git a/Task/Loops-For/Langur/loops-for-3.langur b/Task/Loops-For/Langur/loops-for-3.langur index d52639ebf5..0c62403bc2 100644 --- a/Task/Loops-For/Langur/loops-for-3.langur +++ b/Task/Loops-For/Langur/loops-for-3.langur @@ -1,3 +1,3 @@ -for .i of 5 { - writeln "*" * .i +for i of 5 { + writeln "*" * i } diff --git a/Task/Loops-For/PascalABC.NET/loops-for.pas b/Task/Loops-For/PascalABC.NET/loops-for.pas new file mode 100644 index 0000000000..a87216ea7a --- /dev/null +++ b/Task/Loops-For/PascalABC.NET/loops-for.pas @@ -0,0 +1,7 @@ +## +for var i:=1 to 5 do +begin + for var j:=1 to i do + Write('*'); + Writeln +end; diff --git a/Task/Loops-For/Vim-Script/loops-for-1.vim b/Task/Loops-For/Vim-Script/loops-for-1.vim new file mode 100644 index 0000000000..ad46a6c764 --- /dev/null +++ b/Task/Loops-For/Vim-Script/loops-for-1.vim @@ -0,0 +1,6 @@ +for i in range(1, 5) + call append(line('$'), '') + for j in range(1, i) + call setline(line('$'), getline('$') .. '*') + endfor +endfor diff --git a/Task/Loops-For/Vim-Script/loops-for-2.vim b/Task/Loops-For/Vim-Script/loops-for-2.vim new file mode 100644 index 0000000000..e80fbf9b77 --- /dev/null +++ b/Task/Loops-For/Vim-Script/loops-for-2.vim @@ -0,0 +1,3 @@ +for i in range(1, 5) + echoc repeat('*', i) +endfor diff --git a/Task/Loops-Foreach/Langur/loops-foreach.langur b/Task/Loops-Foreach/Langur/loops-foreach.langur index 0306b4b976..b393ec64e9 100644 --- a/Task/Loops-Foreach/Langur/loops-foreach.langur +++ b/Task/Loops-Foreach/Langur/loops-foreach.langur @@ -1,17 +1,17 @@ -for .i in [1, 2, 3] { - writeln .i +for i in [1, 2, 3] { + writeln i } -val .abc = "abc" +val abc = "abc" -for .i in .abc { - writeln .i +for i in abc { + writeln i } -for .i of .abc { - writeln .abc[.i] +for i of abc { + writeln abc[i] } -for .i in .abc { - writeln cp2s .i +for i in abc { + writeln cp2s(i) } diff --git a/Task/Loops-Foreach/PascalABC.NET/loops-foreach.pas b/Task/Loops-Foreach/PascalABC.NET/loops-foreach.pas new file mode 100644 index 0000000000..754dbfc90b --- /dev/null +++ b/Task/Loops-Foreach/PascalABC.NET/loops-foreach.pas @@ -0,0 +1,3 @@ +## +foreach var s in |'Pascal','ABC','.NET'| do + Print(s); diff --git a/Task/Loops-Increment-loop-index-within-loop-body/EasyLang/loops-increment-loop-index-within-loop-body.easy b/Task/Loops-Increment-loop-index-within-loop-body/EasyLang/loops-increment-loop-index-within-loop-body.easy index 210317dd18..6575777e2d 100644 --- a/Task/Loops-Increment-loop-index-within-loop-body/EasyLang/loops-increment-loop-index-within-loop-body.easy +++ b/Task/Loops-Increment-loop-index-within-loop-body/EasyLang/loops-increment-loop-index-within-loop-body.easy @@ -1,13 +1,10 @@ fastfunc isprim num . - if num mod 2 = 0 and num > 2 - return 0 - . - i = 3 + i = 2 while i <= sqrt num if num mod i = 0 return 0 . - i += 2 + i += 1 . return 1 . diff --git a/Task/Loops-Increment-loop-index-within-loop-body/PascalABC.NET/loops-increment-loop-index-within-loop-body.pas b/Task/Loops-Increment-loop-index-within-loop-body/PascalABC.NET/loops-increment-loop-index-within-loop-body.pas new file mode 100644 index 0000000000..12a0633a37 --- /dev/null +++ b/Task/Loops-Increment-loop-index-within-loop-body/PascalABC.NET/loops-increment-loop-index-within-loop-body.pas @@ -0,0 +1,17 @@ +function IsPrime(n: BigInteger) + := (2..n.Sqrt.Round).All(x -> n mod x <> 0); + +begin + var i := 1; + var n := 42bi; + while i <= 42 do + begin + if IsPrime(n) then + begin + Println($'{i,3} {n,15}'); + i += 1; + n += n - 1; + end; + n += 1; + end; +end. diff --git a/Task/Loops-N-plus-one-half/PascalABC.NET/loops-n-plus-one-half.pas b/Task/Loops-N-plus-one-half/PascalABC.NET/loops-n-plus-one-half.pas new file mode 100644 index 0000000000..429ebdd949 --- /dev/null +++ b/Task/Loops-N-plus-one-half/PascalABC.NET/loops-n-plus-one-half.pas @@ -0,0 +1,3 @@ +## +for var i:=1 to 10 do + Write(i, i = 10 ? '' : ', '); diff --git a/Task/Loops-Nested/PascalABC.NET/loops-nested.pas b/Task/Loops-Nested/PascalABC.NET/loops-nested.pas new file mode 100644 index 0000000000..e4dc21d0d2 --- /dev/null +++ b/Task/Loops-Nested/PascalABC.NET/loops-nested.pas @@ -0,0 +1,16 @@ +label 1; + +begin + var a: array [,] of integer := MatrRandomInteger(3,4,1,10); + a.Println; + + var found := False; + for var i:=0 to a.RowCount-1 do + for var j:=0 to a.ColCount-1 do + if a[i,j] = 5 then + begin + found := True; + goto 1; + end; + 1: Println(found); +end. diff --git a/Task/Loops-While/Langur/loops-while.langur b/Task/Loops-While/Langur/loops-while.langur index 600f93e7fc..1f18ddc634 100644 --- a/Task/Loops-While/Langur/loops-while.langur +++ b/Task/Loops-While/Langur/loops-while.langur @@ -1,5 +1,5 @@ -var .i = 1024 -while .i > 0 { - writeln .i - .i \= 2 +var i = 1024 +while i > 0 { + writeln i + i \= 2 } diff --git a/Task/Loops-While/Mia/loops-while.mia b/Task/Loops-While/Mia/loops-while.mia new file mode 100644 index 0000000000..61cd5b0957 --- /dev/null +++ b/Task/Loops-While/Mia/loops-while.mia @@ -0,0 +1,5 @@ +i = 1024 +while i > 0 { + print i + i = i :/ 2 +} diff --git a/Task/Loops-While/PascalABC.NET/loops-while.pas b/Task/Loops-While/PascalABC.NET/loops-while.pas new file mode 100644 index 0000000000..de30e15776 --- /dev/null +++ b/Task/Loops-While/PascalABC.NET/loops-while.pas @@ -0,0 +1,7 @@ +## +var n := 1024; +while n > 0 do +begin + Println(n); + n := n div 2; +end; diff --git a/Task/Loops-With-multiple-ranges/PascalABC.NET/loops-with-multiple-ranges.pas b/Task/Loops-With-multiple-ranges/PascalABC.NET/loops-with-multiple-ranges.pas new file mode 100644 index 0000000000..9c32b9fc5a --- /dev/null +++ b/Task/Loops-With-multiple-ranges/PascalABC.NET/loops-with-multiple-ranges.pas @@ -0,0 +1,20 @@ +## +var (x,y,z) := (+5,-5,-2); +var (one,three,seven) := (1,3,7); + +var seq := (-three .. Round(3 ** 3)).Step(three) + + (-seven .. +seven).Step(x) + + (555 .. 550 - y) + + (22 .. -28).Step(-three) + + (1927 .. 1939) + + (x .. y).Step(z) + + (Round(11 ** x) .. Round(11 ** x) + one); + +var sum := seq.Sum(x -> Abs(x)); + +var prod := 1; +foreach var t in seq do + if (Abs(prod) < 2bi ** 27) and (t <> 0) then + prod *= t; +Println('sum =',sum); +Println('prod =',prod); diff --git a/Task/Loops-Wrong-ranges/Langur/loops-wrong-ranges.langur b/Task/Loops-Wrong-ranges/Langur/loops-wrong-ranges.langur index 7d224fefcf..211984fe9b 100644 --- a/Task/Loops-Wrong-ranges/Langur/loops-wrong-ranges.langur +++ b/Task/Loops-Wrong-ranges/Langur/loops-wrong-ranges.langur @@ -1,4 +1,4 @@ -val .data = qs:block END +val data = qs:block END start stop increment comment -2 2 1 Normal -2 2 0 Zero increment @@ -11,21 +11,22 @@ val .data = qs:block END 0 0 0 Start equal stop equal zero: zero increment END -var .table = submatches(RE/([^ ]+) +([^ ]+) +([^ ]+) +(.+)\n?/, .data) +# Process data string into table. +# We could have just started with a list of lists, of course. +var table = submatches(RE/([^ ]+) +([^ ]+) +([^ ]+) +(.+)\n?/, data) -val .f = fn(.x) number .x -for .i in 2..len(.table) { - .table[.i] = map [.f, .f, .f, _], .table[.i] +for i in 2..len(table) { + table[i] = map([number, number, number, _], table[i]) } -for .test in rest(.table) { - val .start, .stop, .inc, .comment = .test +for test in rest(table) { + val start, stop, inc, comment = test { - val .series = series(.start .. .stop, .inc) + val s = series(start .. stop, inc) catch { - writeln $"\.comment;\nERROR: \._err["msg"]:L200(...);\n" + writeln "{{comment}}\nERROR: {{_err'msg:L200(...)}}\n" } else { - writeln $"\.comment;\nresult: \.series;\n" + writeln "{{comment}}\nresult: {{s}}\n" } } } diff --git a/Task/Loops-Wrong-ranges/PascalABC.NET/loops-wrong-ranges.pas b/Task/Loops-Wrong-ranges/PascalABC.NET/loops-wrong-ranges.pas new file mode 100644 index 0000000000..2071d0b607 --- /dev/null +++ b/Task/Loops-Wrong-ranges/PascalABC.NET/loops-wrong-ranges.pas @@ -0,0 +1,15 @@ +procedure DisplayRange(first, last, step: integer); +begin + Print($'({first,2}, {last,2}, {step,2}): '); + if step = 0 then + Println('not allowed') + else Println(Range(first, last, step)); +end; + +begin + var ranges := |(-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)|; + foreach var (f, l, s) in ranges do + DisplayRange(f,l,s); +end. diff --git a/Task/Lucas-Lehmer-test/Langur/lucas-lehmer-test.langur b/Task/Lucas-Lehmer-test/Langur/lucas-lehmer-test.langur index 48ba9c07fe..f7a86123a0 100644 --- a/Task/Lucas-Lehmer-test/Langur/lucas-lehmer-test.langur +++ b/Task/Lucas-Lehmer-test/Langur/lucas-lehmer-test.langur @@ -1,15 +1,16 @@ -val .isPrime = fn(.i) .i == 2 or - .i > 2 and not any(fn(.x) .i div .x, - pseries 2 .. .i ^/ 2) +val isPrime = fn(i) { + i == 2 or i > 2 and + not any(fn x:i div x, pseries(2 .. i ^/ 2)) +} -val .isMersennePrime = fn(.p) { - if .p == 2: return true - if not .isPrime(.p): return false +val isMersennePrime = fn(p) { + if p == 2: return true + if not isPrime(p): return false - val .mp = 2 ^ .p - 1 - for[.s=4] of 3 .. .p { - .s = (.s ^ 2 - 2) rem .mp + val mp = 2 ^ p - 1 + for[s=4] of 3 .. p { + s = (s ^ 2 - 2) rem mp } == 0 } -writeln join " ", map fn(.x) $"M\.x;", filter .isMersennePrime, series 2300 +writeln join(" ", map(fn x:"M{{x}}", filter(isMersennePrime, series(2300)))) diff --git a/Task/Ludic-numbers/EasyLang/ludic-numbers.easy b/Task/Ludic-numbers/EasyLang/ludic-numbers.easy new file mode 100644 index 0000000000..06bb876321 --- /dev/null +++ b/Task/Ludic-numbers/EasyLang/ludic-numbers.easy @@ -0,0 +1,27 @@ +proc initLudicArray n . res[] . + len res[] n + res[1] = 1 + for i = 2 to n + k = 0 + for j = i - 1 downto 2 + k = k * res[j] div (res[j] - 1) + 1 + . + res[i] = k + 2 + . +. +initLudicArray 2005 arr[] +for i = 1 to 25 + write arr[i] & " " +. +print "" +print "" +i = 1 +while arr[i] <= 1000 + cnt += 1 + i += 1 +. +print cnt +print "" +for i = 2000 to 2005 + write arr[i] & " " +. diff --git a/Task/Luhn-test-of-credit-card-numbers/Langur/luhn-test-of-credit-card-numbers.langur b/Task/Luhn-test-of-credit-card-numbers/Langur/luhn-test-of-credit-card-numbers.langur index e67b35d78d..61b17ec279 100644 --- a/Task/Luhn-test-of-credit-card-numbers/Langur/luhn-test-of-credit-card-numbers.langur +++ b/Task/Luhn-test-of-credit-card-numbers/Langur/luhn-test-of-credit-card-numbers.langur @@ -1,22 +1,22 @@ -val .luhntest = fn(.s) { - val .t = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] - val .numbers = s2n .s - val .oddeven = len(.numbers) rem 2 +val luhntest = fn(s) { + val t = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] + val numbers = s -> s2n + val oddeven = len(numbers) rem 2 - for[=0] .i of .numbers { - _for += if(.i rem 2 == .oddeven: .numbers[.i]; .t[.numbers[.i]+1]) + for[=0] i of numbers { + _for += if(i rem 2 == oddeven: numbers[i]; t[numbers[i]+1]) } div 10 } -val .tests = h{ +val tests = { "49927398716": true, "49927398717": false, "1234567812345678": false, "1234567812345670": true, } -for .key of .tests { - val .pass = .luhntest(.key) - write .key, ": ", .pass - writeln if(.pass == .tests[.key]: ""; " (LUHN TEST FAILED)") +for key in sort(keys(tests)) { + val pass = luhntest(key) + write key, ": ", pass + writeln if(pass == tests[key]: ""; " (LUHN TEST FAILED)") } diff --git a/Task/Luhn-test-of-credit-card-numbers/Lua/luhn-test-of-credit-card-numbers.lua b/Task/Luhn-test-of-credit-card-numbers/Lua/luhn-test-of-credit-card-numbers.lua index 3f987b4d70..0898194946 100644 --- a/Task/Luhn-test-of-credit-card-numbers/Lua/luhn-test-of-credit-card-numbers.lua +++ b/Task/Luhn-test-of-credit-card-numbers/Lua/luhn-test-of-credit-card-numbers.lua @@ -1,31 +1,20 @@ -function luhn(n) - n=string.reverse(n) - print(n) - local s1=0 - --sum odd digits - for i=1,n:len(),2 do - s1=s1+n:sub(i,i) - end - --evens - local s2=0 - for i=2,n:len(),2 do - local doubled=n:sub(i,i)*2 - doubled=string.gsub(doubled,'(%d)(%d)',function(a,b)return a+b end) - s2=s2+doubled - end - print(s1) - print(s2) - local total=s1+s2 - if total%10==0 then - return true - end - return false -end +function luhn_test(cc_number) + assert(type(cc_number) == 'string') + local sum = 0 + local is_odd = true + for idx = #cc_number , 1 , -1 do -- reverse order + -- extract single character as string then convert to integer + local digit = cc_number:sub(idx, idx) + 0 + if is_odd then + sum = sum + digit + else + sum = sum + ((digit * 2) % 10) + (digit // 5) + end -- if + is_odd = not is_odd -- toggle between odd and even + end -- for + return (sum % 10) == 0 +end -- function luhn_test --- Note that this function takes strings, not numbers. --- 16-digit numbers tend to be problematic --- when looking at individual digits. -print(luhn'49927398716') -print(luhn'49927398717') -print(luhn'1234567812345678') -print(luhn'1234567812345670') +for _, val in ipairs{"49927398716", "49927398717", "1234567812345678", "1234567812345670"} do + print(val, luhn_test(val)) +end -- for diff --git a/Task/Luhn-test-of-credit-card-numbers/SETL/luhn-test-of-credit-card-numbers.setl b/Task/Luhn-test-of-credit-card-numbers/SETL/luhn-test-of-credit-card-numbers.setl new file mode 100644 index 0000000000..73d45aa270 --- /dev/null +++ b/Task/Luhn-test-of-credit-card-numbers/SETL/luhn-test-of-credit-card-numbers.setl @@ -0,0 +1,18 @@ +program luhn_test; + tests := [ + 49927398716, + 49927398717, + 1234567812345678, + 1234567812345670 + ]; + + loop for test in tests do + print(test, if luhn test then "pass" else "fail" end); + end loop; + + op luhn(n); + fac := 2; + digits := [val d * (fac := 3-fac) : d in reverse str n]; + return 0 = +/[d - if d>9 then 9 else 0 end : d in digits] mod 10; + end op; +end program; diff --git a/Task/Luhn-test-of-credit-card-numbers/Uiua/luhn-test-of-credit-card-numbers.uiua b/Task/Luhn-test-of-credit-card-numbers/Uiua/luhn-test-of-credit-card-numbers.uiua new file mode 100644 index 0000000000..46ed815ca7 --- /dev/null +++ b/Task/Luhn-test-of-credit-card-numbers/Uiua/luhn-test-of-credit-card-numbers.uiua @@ -0,0 +1,6 @@ +Luhn ← =0◿10+⊃(/+⊢|/+∵(⍥(-9)>9.×2)⊡1)⍉⬚0↯∞_2⇌ +T ← {"49927398716" + "49927398717" + "1234567812345678" + "1234567812345670"} +≡◇(Luhn ≡⋕) T diff --git a/Task/M-bius-function/Gambas/m-bius-function.gambas b/Task/M-bius-function/Gambas/m-bius-function.gambas new file mode 100644 index 0000000000..b62750334b --- /dev/null +++ b/Task/M-bius-function/Gambas/m-bius-function.gambas @@ -0,0 +1,27 @@ +Public Sub Main() + + Dim outstr As String = " . " + + For i As Integer = 1 To 200 + If mobius(i) >= 0 Then outstr &= " " + outstr &= Str(mobius(i)) & " " + If i Mod 10 = 9 Then + Print outstr + outstr = "" + End If + Next + +End + +Function mobius(n As Integer) As Integer + + If n = 1 Then Return 1 + For d As Integer = 2 To Int(Sqr(n)) + If n Mod d = 0 Then + If n Mod (d * d) = 0 Then Return 0 + Return -mobius(n / d) + End If + Next + Return -1 + +End Function diff --git a/Task/M-bius-function/PureBasic/m-bius-function.basic b/Task/M-bius-function/PureBasic/m-bius-function.basic new file mode 100644 index 0000000000..3959515d0e --- /dev/null +++ b/Task/M-bius-function/PureBasic/m-bius-function.basic @@ -0,0 +1,30 @@ +Procedure.i mobius(n) + If n = 1: + ProcedureReturn 1 + EndIf + For d = 2 To Int(Sqr(n)) + If Mod(n, d) = 0: + If Mod(n, d * d) = 0: + ProcedureReturn 0 + EndIf + ProcedureReturn -mobius(n / d) + EndIf + Next d + ProcedureReturn -1 +EndProcedure + +OpenConsole() +outstr$ = " . " +For i = 1 To 200 + If mobius(i) >= 0: + outstr$ = outstr$ + " " + EndIf + outstr$ = outstr$ + Str(mobius(i)) + " " + If Mod(i, 10) = 9: + PrintN(outstr$) + outstr$ = "" + EndIf +Next i + +PrintN(#CRLF$ + "Press ENTER to exit"): Input() +CloseConsole() diff --git a/Task/M-bius-function/XBasic/m-bius-function.basic b/Task/M-bius-function/XBasic/m-bius-function.basic new file mode 100644 index 0000000000..7c3fec5047 --- /dev/null +++ b/Task/M-bius-function/XBasic/m-bius-function.basic @@ -0,0 +1,31 @@ +PROGRAM "Möbius function" +VERSION "0.0000" +IMPORT "xma" + + +DECLARE FUNCTION Entry () +DECLARE FUNCTION mobius (n) + +FUNCTION Entry () + outstr$ = " . " + FOR i = 1 TO 200 + IF mobius(i) >= 0 THEN outstr$ = outstr$ + outstr$ = outstr$ + STR$(mobius(i)) + " " + IF i MOD 10 = 9 THEN + PRINT outstr$ + outstr$ = "" + END IF + NEXT i +END FUNCTION + +FUNCTION mobius (n) + IF n = 1 THEN RETURN 1 + FOR d = 2 TO INT(SQRT(n)) + IF n MOD d = 0 THEN + IF n MOD (d*d) = 0 THEN RETURN 0 + RETURN -mobius(n/d) + END IF + NEXT d + RETURN -1 +END FUNCTION +END PROGRAM diff --git a/Task/MD5-Implementation/Raku/md5-implementation.raku b/Task/MD5-Implementation/Raku/md5-implementation.raku index 7d3d56b8c0..96ff90376b 100644 --- a/Task/MD5-Implementation/Raku/md5-implementation.raku +++ b/Task/MD5-Implementation/Raku/md5-implementation.raku @@ -1,7 +1,6 @@ proto md5($msg) returns Blob is export {*} multi md5(Str $msg) { md5 $msg.encode } multi md5(Blob $msg) { - my \bits = 8 * $msg.elems; my buf8 $buf .= new; $buf.write-uint32: $buf.elems, $_, LittleEndian for reduce -> Blob $blob, blob32 $X { @@ -29,9 +28,9 @@ multi md5(Blob $msg) { (BEGIN blob32.new: 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476), |map { blob32.new: @$_ }, { - $^b.push(blob8.new(@$_).read-uint32(0)) for (@$msg, 0x80, 0x00 xx (-(bits div 8 + 1 + 8) % 64)) + $^b.push(blob8.new(@$_).read-uint32(0)) for (@$msg, 0x80, 0x00 xx (-($msg.elems + 1 + 8) % 64)) .flat.rotor(4); - $b.write-uint64: $b.elems, bits, LittleEndian; + $b.write-uint64: $b.elems, 8*$msg.elems, LittleEndian; $b; }(buf32.new) .rotor(16); diff --git a/Task/Magic-constant/Ada/magic-constant.ada b/Task/Magic-constant/Ada/magic-constant.ada new file mode 100644 index 0000000000..eada801d57 --- /dev/null +++ b/Task/Magic-constant/Ada/magic-constant.ada @@ -0,0 +1,68 @@ +-- Magic constants +-- J. Carter 2024 May + +with Ada.Text_IO; +with System; + +procedure Magic_Constant is + type Big_U is mod System.Max_Binary_Modulus; + + function Magic (Order : in Big_U) return Big_U with + Pre => Order > 2; + -- Returns the constant for the magic square of order Order + + function Order (Guess : in Big_U) return Big_U; + -- Returns the order of the smallest magic square with constant > Guess + + function Image (N : in Big_U; Width : in Positive) return String; + -- Returns a blank-filled image of N of at least width characters + + function Magic (Order : in Big_U) return Big_U is + (Order * (Order ** 2 + 1) / 2); + + function Order (Guess : in Big_U) return Big_U is + Min : Big_U := 3; + Max : Big_U := 5_850_000; + Mid : Big_U; + Prev : Big_U := 0; + begin -- Order + Search : loop + Mid := Min + (Max - Min) / 2; + + exit Search when Mid = Prev; + + Prev := Mid; + + if Magic (Mid) > Guess and (Mid = 3 or else Magic (Mid - 1) <= Guess) then + return Mid; + end if; + + if Magic (Mid) > Guess then + Max := Mid; + else + Min := Mid; + end if; + end loop Search; + + raise Program_Error with "Order: no solution for" & Guess'Image; + end Order; + + function Image (N : in Big_U; Width : in Positive) return String is + Raw : String renames N'Image; + Img : String renames Raw (2 .. Raw'Last); + begin -- Image + return (1 .. Width - Img'Length => ' ') & Img; + end Image; +begin -- Magic_Constant + First_20 : for N in Big_U range 3 .. 22 loop + Ada.Text_IO.Put_Line (Item => Image (N, 2) & Image (Magic (N), 5) ); + end loop First_20; + + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line (Item => "1000" & Magic (1000)'Image); + Ada.Text_IO.New_Line; + + Ten_To : for P in 1 .. (if Big_U'Size < 64 then 9 elsif Big_U'Size < 128 then 18 else 20) loop + Ada.Text_IO.Put_Line (Item => "10 ** " & Image (Big_U (P), 2) & Image (Order (10 ** P), 8) ); + end loop Ten_To; +end Magic_Constant; diff --git a/Task/Make-directory-path/Seed7/make-directory-path-1.seed7 b/Task/Make-directory-path/Seed7/make-directory-path-1.seed7 deleted file mode 100644 index 1fd23c97f7..0000000000 --- a/Task/Make-directory-path/Seed7/make-directory-path-1.seed7 +++ /dev/null @@ -1,7 +0,0 @@ -$ include "seed7_05.s7i"; - include "cli_cmds.s7i"; - -const proc: main is func - begin - doMkdirCmd(argv(PROGRAM), TRUE); - end func; diff --git a/Task/Make-directory-path/Seed7/make-directory-path-2.seed7 b/Task/Make-directory-path/Seed7/make-directory-path-2.seed7 deleted file mode 100644 index 54ab614118..0000000000 --- a/Task/Make-directory-path/Seed7/make-directory-path-2.seed7 +++ /dev/null @@ -1,10 +0,0 @@ -$ include "seed7_05.s7i"; - include "cli_cmds.s7i"; - -const proc: main is func - local - var string: parameters is ""; - begin - parameters := join(argv(PROGRAM), " "); - doMkdir(parameters); - end func; diff --git a/Task/Make-directory-path/Seed7/make-directory-path.seed7 b/Task/Make-directory-path/Seed7/make-directory-path.seed7 new file mode 100644 index 0000000000..13dbfb7ff9 --- /dev/null +++ b/Task/Make-directory-path/Seed7/make-directory-path.seed7 @@ -0,0 +1,21 @@ +$ include "seed7_05.s7i"; + include "osfiles.s7i"; + +const proc: makeDirectoryPath (in string: dirPath) is func + begin + makeParentDirs(dirPath); + if fileTypeSL(dirPath) <> FILE_DIR then + makeDir(dirPath); + end if; + end func; + +const proc: main is func + begin + if length(argv(PROGRAM)) <> 1 then + writeln("usage: makeDirectoryPath path"); + elsif succeeds(makeDirectoryPath(convDosPath(argv(PROGRAM)[1]))) then + writeln("Directory path now exists"); + else + writeln("Failed to create directory path"); + end if; + end func; diff --git a/Task/Man-or-boy-test/PascalABC.NET/man-or-boy-test.pas b/Task/Man-or-boy-test/PascalABC.NET/man-or-boy-test.pas new file mode 100644 index 0000000000..f9b73c30f1 --- /dev/null +++ b/Task/Man-or-boy-test/PascalABC.NET/man-or-boy-test.pas @@ -0,0 +1,13 @@ +function A(k: integer; x1, x2, x3, x4, x5: function: integer): integer; +begin + var B: function: integer; + B := () -> begin + k := k - 1; + Result := A(k, B, x1, x2, x3, x4); + end; + Result := if k <= 0 then x4() + x5() else B() +end; + +begin + Print(A(10, () -> 1, () -> -1, () -> -1, () -> 1, () -> 0)) +end. diff --git a/Task/Mandelbrot-set/Dart/mandelbrot-set.dart b/Task/Mandelbrot-set/Dart/mandelbrot-set.dart index 596617a8a7..7fc985c03e 100644 --- a/Task/Mandelbrot-set/Dart/mandelbrot-set.dart +++ b/Task/Mandelbrot-set/Dart/mandelbrot-set.dart @@ -1,35 +1,35 @@ class Complex { - double _r,_i; + double _r, _i; - Complex(this._r,this._i); - double get r => _r; - double get i => _i; - String toString() => "($r,$i)"; + Complex(this._r, this._i); + get r => _r; + get i => _i; + toString() => "($r,$i)"; - Complex operator +(Complex other) => new Complex(r+other.r,i+other.i); - Complex operator *(Complex other) => - new Complex(r*other.r-i*other.i,r*other.i+other.r*i); - double abs() => r*r+i*i; + operator +(Complex other) => Complex(r + other.r, i + other.i); + operator *(Complex other) => + Complex(r * other.r - i * other.i, r * other.i + other.r * i); + abs() => r * r + i * i; } void main() { - double start_x=-1.5; - double start_y=-1.0; - double step_x=0.03; - double step_y=0.1; + const startX = -1.5; + const startY = -1.0; + const stepX = 0.03; + const stepY = 0.1; - for(int y=0;y<20;y++) { - String line=""; - for(int x=0;x<70;x++) { - Complex c=new Complex(start_x+step_x*x,start_y+step_y*y); - Complex z=new Complex(0.0, 0.0); - for(int i=0;i<100;i++) { - z=z*(z)+c; - if(z.abs()>2) { + for (int y = 0; y < 20; y++) { + String line = ""; + for (int x = 0; x < 70; x++) { + var c = Complex(startX + stepX * x, startY + stepY * y); + var z = Complex(0.0, 0.0); + for (int i = 0; i < 100; i++) { + z = z * z + c; + if (z.abs() > 2) { break; } } - line+=z.abs()>2 ? " " : "*"; + line += z.abs() > 2 ? " " : "*"; } print(line); } diff --git a/Task/Mandelbrot-set/Uiua/mandelbrot-set.uiua b/Task/Mandelbrot-set/Uiua/mandelbrot-set.uiua new file mode 100644 index 0000000000..1ab364b82e --- /dev/null +++ b/Task/Mandelbrot-set/Uiua/mandelbrot-set.uiua @@ -0,0 +1,9 @@ +Size ← 800 +Cs ← ÷ 5[5_5_5 4_5_5 4_5_5 3_5_5 5_3_5 3_3_5 2_5_0 5_2_2 2_2_5 0_0_0] +# Initialise complex co-ordinates. +×2.5 ⊞ℂ:-1/4. ÷:-÷2,⇡.⟜(↯:0⊟.)Size +# Iterate 50 times (a, b, got_there) -> (a*a+b, b, got_there) +# got_there counts when corresponding value in b hits 2. +⍥⊃(+×.|⋅∘|+<2⌵⊙◌)50 0 +# Scale the results down and display +⊏:Cs⌈×9÷:⟜(/↥/↥)ₙ2◌◌ diff --git a/Task/Map-range/EasyLang/map-range.easy b/Task/Map-range/EasyLang/map-range.easy new file mode 100644 index 0000000000..6e2c4c89cd --- /dev/null +++ b/Task/Map-range/EasyLang/map-range.easy @@ -0,0 +1,6 @@ +func map_range a1 a2 b1 b2 s . + return b1 + (s - a1) * (b2 - b1) / (a2 - a1) +. +for i = 0 to 10 + print i & " -> " & map_range 0 10 -1 0 i +. diff --git a/Task/Matrix-multiplication/EasyLang/matrix-multiplication.easy b/Task/Matrix-multiplication/EasyLang/matrix-multiplication.easy index 72b50c1d7c..aaa1da88b9 100644 --- a/Task/Matrix-multiplication/EasyLang/matrix-multiplication.easy +++ b/Task/Matrix-multiplication/EasyLang/matrix-multiplication.easy @@ -1,5 +1,4 @@ -proc matmul . m1[][] m2[][] r[][] . - r[][] = [ ] +func[][] matmul m1[][] m2[][] . for i to len m1[][] r[][] &= [ ] for j = 1 to len m2[1][] @@ -9,8 +8,8 @@ proc matmul . m1[][] m2[][] r[][] . . . . + return r[][] . -mat1[][] = [ [ 1 2 3 ] [ 4 5 6 ] ] -mat2[][] = [ [ 1 2 ] [ 3 4 ] [ 5 6 ] ] -matmul mat1[][] mat2[][] erg[][] -print erg[][] +a[][] = [ [ 1 2 3 ] [ 4 5 6 ] ] +b[][] = [ [ 1 2 ] [ 3 4 ] [ 5 6 ] ] +print matmul a[][] b[][] diff --git a/Task/Matrix-multiplication/Uiua/matrix-multiplication.uiua b/Task/Matrix-multiplication/Uiua/matrix-multiplication.uiua new file mode 100644 index 0000000000..7e3097a8a2 --- /dev/null +++ b/Task/Matrix-multiplication/Uiua/matrix-multiplication.uiua @@ -0,0 +1,8 @@ +MatMul ← ≡(≡(/+×)¤:⍉)¤ +[[2 1 4] + [0 1 1]] + +[[6 3 ¯1 0] + [1 1 0 4] + [¯2 5 0 2]] +MatMul diff --git a/Task/Mayan-calendar/Jq/mayan-calendar.jq b/Task/Mayan-calendar/Jq/mayan-calendar.jq new file mode 100644 index 0000000000..c5fdcc2844 --- /dev/null +++ b/Task/Mayan-calendar/Jq/mayan-calendar.jq @@ -0,0 +1,105 @@ +### General utilities + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; +def rpad($len): tostring | ($len - length) as $l | . + (" " * $l); + +# days_between("2020-01-01"; "2020-01-02") #=> 1 +# days_between("2020-01-02"; "2020-01-01") #=> -1 +def days_between($yyyymmddBefore; $yyyymmddAfter): + (yyyymmddBefore | strptime("%Y-%m-%d") | mktime) as $before + | (yyyymmddAfter | strptime("%Y-%m-%d") | mktime) as $after + # leap seconds are always inserted + | (($after - $before) / (24*60*60) | floor) ; + +### `Date` objects + +def Date($year; $month; $day): {$year, $month, $day}; + +# Convert a Date object to a string yyyy-mm-dd +# Other inputs are (currently) unscathed. +def yyyymmdd: + if type == "object" then "\(.year)-\(.month)-\(.day)" + else . + end; + +### Mayan Calendar + +def sacred: + "Imix’ Ik’ Ak’bal K’an Chikchan Kimi Manik’ Lamat Muluk Ok Chuwen Eb Ben Hix Men K’ib’ Kaban Etz’nab’ Kawak Ajaw" + | split(" "); + +def civil: + "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’" + | split(" "); + +def CREATION_TZOLKIN: "2012-12-21"; + +# Input: Date or yyyy-mm-dd +def tzolkin: + (days_between(CREATION_TZOLKIN; yyyymmdd)) as $diff + | {rem: ($diff % 13)} + | if .rem < 0 then .rem += 13 end + | .num = (if .rem <= 9 then .rem + 4 else .rem - 9 end) + | .rem = $diff % 20 + | if .rem <= 0 then .rem += 20 end + | [.num, sacred[.rem-1] ] ; + +# Input: Date or yyyy-mm-dd +def haab: + def ZERO_HAAB: "2019-04-02"; + (days_between(ZERO_HAAB; yyyymmdd)) as $diff + | {rem: ($diff % 365)} + | if .rem < 0 then .rem += 365 end + | .month = civil[((.rem+1)/20)|floor] + | .last = (if .month == "Wayeb'" then 5 else 20 end) + | .d = .rem%20 + 1 + | if .d < .last then [(.d|tostring), .month] + else ["Chum", .month] + end; + +# Input: Date or yyyy-mm-dd +def longCount: + {diff: days_between(CREATION_TZOLKIN; yyyymmdd)} + | .diff += 13*400*360 + | .baktun = ((.diff/(400*360)) | floor) + | .diff = .diff % (400*360) + | .katun = ((.diff/(20 * 360))|floor) + | .diff = .diff % (20*360) + | .tun = ((.diff/360)|floor) + | .diff = .diff % 360 + | .winal = ((.diff/20)|floor) + | .kin = .diff % 20 + | [.baktun, .katun, .tun, .winal, .kin] + | join("."); + +# Input: Date or yyyy-mm-dd +def lord: + {diff: days_between(CREATION_TZOLKIN; yyyymmdd)} + | .rem = .diff % 9 + | if .rem <= 0 then .rem += 9 end + | "G\(.rem)"; + + +def dates: [ + "1961-10-06", + "1963-11-21", + "2004-06-19", + "2012-12-18", + "2012-12-21", + "2019-01-19", + "2019-03-27", + "2020-02-29", + "2020-03-01", + "2071-05-16" +]; + +" Gregorian Tzolk’in Haab’ Long Lord of", +" Date # Name Day Month Count the Night", +"---------- -------- ------------- -------------- ---------", +# Date.default = Date.isoDate +(dates[] + | tzolkin as [$n, $s] + | haab as [$d, $m] + | [., ($n | lpad(4)), ($s | rpad(8)), ($d|lpad(4)), ($m|rpad(8)), (longCount|lpad(20)), (lord|lpad(6))] + | join(" ") +) diff --git a/Task/Maze-generation/11l/maze-generation.11l b/Task/Maze-generation/11l/maze-generation.11l index b9c8f0c56d..3364852bb2 100644 --- a/Task/Maze-generation/11l/maze-generation.11l +++ b/Task/Maze-generation/11l/maze-generation.11l @@ -3,7 +3,7 @@ F make_maze(w = 16, h = 8) V ver = [[‘| ’] * w [+] [String(‘|’)]] * h [+] [[String]()] V hor = [[‘+--’] * w [+] [String(‘+’)]] * (h + 1) - F walk(Int x, Int y) -> N + F walk(Int x, Int y) -> Void @vis[y][x] = 1 V d = [(x - 1, y), (x, y + 1), (x + 1, y), (x, y - 1)] random:shuffle(&d) diff --git a/Task/Maze-generation/Chapel/maze-generation.chapel b/Task/Maze-generation/Chapel/maze-generation.chapel new file mode 100644 index 0000000000..b2304bd9bd --- /dev/null +++ b/Task/Maze-generation/Chapel/maze-generation.chapel @@ -0,0 +1,56 @@ +use Random; + +config const rows: int = 9; +config const cols: int = 16; +if rows < 1 || cols < 1 { + writeln("Maze must be at least 1x1 in size."); + exit(1); +} + +enum direction {N = 1, E = 2, S = 3, W = 4}; + +record Cell { + var spaces: [direction.N .. direction.W] bool; + var visited: bool; +} + +const dirs = [ + ((-1, 0), direction.N, direction.S), // ((rowDir, colDir), myWall, neighbourWall) + ((0, 1), direction.E, direction.W), + ((1, 0), direction.S, direction.N), + ((0, -1), direction.W, direction.E) +]; + +var maze: [1..rows, 1..cols] Cell; +var startingCell = (choose(maze.dim(0)), choose(maze.dim(1))); + +checkCell(maze, startingCell); +displayMaze(maze); + +proc checkCell(ref maze, cell) { + maze[cell].visited = true; + for dir in permute(dirs) { + var (offset, thisDir, neighbourDir) = dir; + var neighbour = cell + offset; + if maze.domain.contains(neighbour) && !maze[neighbour].visited { + maze[cell].spaces[thisDir] = true; + maze[neighbour].spaces[neighbourDir] = true; + checkCell(maze, neighbour); + } + } +} + +proc displayMaze(maze) { + for row in maze.dim(0) { + for col in maze.dim(1) { + write(if maze[row, col].spaces[direction.N] then "+ " else "+---"); + } + writeln("+"); + for col in maze.dim(1) { + write(if maze[row, col].spaces[direction.W] then " " else "| "); + } + writeln("|"); + } + write("+---" * maze.dim(1).size); + writeln("+"); +} diff --git a/Task/Maze-generation/POV-Ray/maze-generation.povray b/Task/Maze-generation/POV-Ray/maze-generation.povray new file mode 100644 index 0000000000..d358c4ed68 --- /dev/null +++ b/Task/Maze-generation/POV-Ray/maze-generation.povray @@ -0,0 +1,181 @@ +#version 3.7; + +global_settings { + assumed_gamma 1 +} + +#declare Rows = 15; +#declare Cols = 17; + +#declare Seed = seed(2); // A seed produces a fixed sequence of pseudorandom numbers + +#declare Wall = prism { + 0, 0.8, 7, + <0, -0.5>, <0.05, -0.45>, <0.05, 0.45>, <0, 0.5>, + <-0.05, 0.45>, <-0.05, -0.45>, <0, -0.5> + texture { + pigment { + brick colour rgb 1, colour rgb <0.8, 0.25, 0.1> // Colour mortar, colour brick + brick_size 3*<0.25, 0.0525, 0.125> + mortar 3*0.01 // Size of the mortar + } + normal { wrinkles 0.75 scale 0.01 } + finish { diffuse 0.9 phong 0.2 } + } +} + +#macro Fisher_Yates_Shuffle(Stack, Start, Top) + #for (I, Top, Start+1, -1) + #local J = floor(rand(Seed)*I + 0.5); + #if (J != I) // Waste of time swapping an element with itself + #local Src_Row = Stack[I][0]; + #local Src_Col = Stack[I][1]; + #local Dst_Row = Stack[I][2]; + #local Dst_Col = Stack[I][3]; + #declare Stack[I][0] = Stack[J][0]; + #declare Stack[I][1] = Stack[J][1]; + #declare Stack[I][2] = Stack[J][2]; + #declare Stack[I][3] = Stack[J][3]; + #declare Stack[J][0] = Src_Row; + #declare Stack[J][1] = Src_Col; + #declare Stack[J][2] = Dst_Row; + #declare Stack[J][3] = Dst_Col; + #end + #end +#end + +#macro Initialise(Visited, North_Walls, East_Walls) + #for (R, 0, Rows-1) + #for (C, 0, Cols-1) + #declare Visited[R][C] = false; + #declare North_Walls[R][C] = true; + #declare East_Walls[R][C] = true; + #end + #end +#end + +#macro Push(Stack, Top, Src_Row, Src_Col, Dst_Row, Dst_Col) + #declare Top = Top + 1; + #declare Stack[Top][0] = Src_Row; + #declare Stack[Top][1] = Src_Col; + #declare Stack[Top][2] = Dst_Row; + #declare Stack[Top][3] = Dst_Col; +#end + +#macro Generate_Maze(Visited, North_Walls, East_Walls) + #local Stack = array[Rows*Cols][4]; // 0: from row, 1: from col, 2: to row, 3: to col + #local Row = floor(rand(Seed)*(Rows-1) + 0.5); // Random start row + #local Col = floor(rand(Seed)*(Cols-1) + 0.5); // Random start column + #local Top = -1; + Push(Stack, Top, Row, Col, Row, Col) + + #while (Top >= 0) + #declare Visited[Row][Col] = true; + #local Start = Top + 1; + + #if (Row < Rows-1) // Add north neighbour + #if (Visited[Row+1][Col] = false) + Push(Stack, Top, Row, Col, Row+1, Col) + #end + #end + + #if (Col < Cols-1) // Add east neighbour + #if (Visited[Row][Col+1] = false) + Push(Stack, Top, Row, Col, Row, Col+1) + #end + #end + + #if (Row > 0) // Add south neighbour + #if (Visited[Row-1][Col] = false) + Push(Stack, Top, Row, Col, Row-1, Col) + #end + #end + + #if (Col > 0) // Add west neighbour + #if (Visited[Row][Col-1] = false) + Push(Stack, Top, Row, Col, Row, Col-1) + #end + #end + + Fisher_Yates_Shuffle(Stack, Start, Top) + + #local Removed_Wall = false; + #while (Top >= 0 & Removed_Wall = false) + #local Src_Row = Stack[Top][0]; + #local Src_Col = Stack[Top][1]; + #local Dst_Row = Stack[Top][2]; + #local Dst_Col = Stack[Top][3]; + #declare Top = Top - 1; + + #if (Visited[Dst_Row][Dst_Col] = false) + #if (Dst_Row = Src_Row+1 & Dst_Col = Src_Col) // North wall + #declare North_Walls[Src_Row][Src_Col] = false; + #elseif (Dst_Row = Src_Row & Dst_Col = Src_Col+1) // East wall + #declare East_Walls[Src_Row][Src_Col] = false; + #elseif (Dst_Row = Src_Row-1 & Dst_Col = Src_Col) // South wall + #declare North_Walls[Dst_Row][Src_Col] = false; + #elseif (Dst_Row = Src_Row & Dst_Col = Src_Col-1) // West wall + #declare East_Walls[Src_Row][Dst_Col] = false; + #else + #error "Unknown wall!\n" + #end + + #declare Row = Dst_Row; + #declare Col = Dst_Col; + #declare Removed_Wall = true; + #end + #end + #end +#end + +#macro Draw_Maze(North_Walls, East_Walls) + merge { + #for (R, 0, Rows-1) + object { Wall translate <1, 0, 0.5> translate <-1, 0, R> } // West edge + #for (C, 0, Cols-1) + #if (R = 0) // South edge + object { Wall rotate y*90 translate <0.5, 0, 1> translate } + #end + #if (North_Walls[R][C]) + object { Wall rotate y*90 translate <0.5, 0, 1> translate } + #end + #if (East_Walls[R][C]) + object { Wall translate <1, 0, 0.5> translate } + #end + #end + #end + translate <-0.5*Cols, 0, 0> // Centre maze on x=0 + } +#end + +camera { + location <0, 13, -2> + right x*image_width/image_height + look_at <0, 2, 5> +} + +light_source { + <-0.1*Cols, Rows, 0.5*Rows>, colour rgb <1, 1, 1> + area_light + x, y, 3, 3 + circular orient +} + +box { + <-0.5*Cols, -0.1, 0>, <0.5*Cols, 0, Rows> + texture { + pigment { + checker colour rgb <0, 0.3, 0> colour rgb <0, 0.4, 0> + scale 0.5 + } + finish { specular 0.5 reflection { 0.1 } } + } +} + +#declare Visited = array[Rows][Cols]; +#declare North_Walls = array[Rows][Cols]; +#declare East_Walls = array[Rows][Cols]; + +Initialise(Visited, North_Walls, East_Walls) +Generate_Maze(Visited, North_Walls, East_Walls) +Draw_Maze(North_Walls, East_Walls) diff --git a/Task/Maze-generation/Uiua/maze-generation.uiua b/Task/Maze-generation/Uiua/maze-generation.uiua index 1138a832b7..79b95d19ee 100644 --- a/Task/Maze-generation/Uiua/maze-generation.uiua +++ b/Task/Maze-generation/Uiua/maze-generation.uiua @@ -1,37 +1,33 @@ -H ← 8 -W ← 18 -Ver ← 0 -Hor ← 1 -Vis ← 2 +# Build and solve a maze. +# Experimental! +W ← 10 +H ← 6 -BreakNS ← ⊂Ver⊂⊃(/↥≡⊡0|⊡0_1) -BreakEW ← ⊂Hor⊂⊃(⊡0_0|/↥≡⊡1) +GetWall ← -:⊡1:÷2/-. # ([here, next], maze) -> (maze') -BreakWall ← ⍜⊡(0◌)⟨BreakNS|BreakEW⟩=°⊟≡⊢. +BreakWall ← ⍜(⊡|⋅@ )GetWall -Neighbours ← +⊙¤[[¯1 0] [1 0] [0 1] [0 ¯1]] # Gives N4 +Nfour ← +⊙¤[¯2_0 2_0 0_2 0_¯2] # Gives N4 Shuffle ← ⊏⍏[⍥⚂]⧻. -IsVisited ← ¬⊡⊂Vis -MarkAsVisited ← ⟜(⍜(⊡|1◌)⊂Vis) -OnlyInBounds ← ▽≡IsVisited ⊙¤,, # (finds the boundary 1's) - +# (pos maze) -> T if it's already a star. +IsVisited ← ≠@.⊡ +MarkAsVisited ← ⟜(⍜⊡⋅@.) +# (pos) -> (bool) +InBounds ← ▽⊸≡(↧⊃(/↧≥1_1|/↧< +1 × 2 H_W)) # (here, maze) -> (maze') Walk ← |2 ( MarkAsVisited # (here, maze) -> ([[here, next] x(up to)4], maze) - ≡⊟¤⟜(Shuffle OnlyInBounds Neighbours) + ≡⊟¤⟜(Shuffle InBounds Nfour) # Update maze for each in turn. For each, if it # still isn't visited, break the wall, recurse into it. - ∧(⟨◌|Walk ⊡1 ⟜BreakWall⟩IsVisited◌°⊟,,) + ∧(⨬(◌|Walk⊡1⟜BreakWall)IsVisited◌°⊟,,) ) -⊂↯H⊂↯W0 1↯+1W1 # vis (added 1's help bounds checks) -⊂↯H⊂↯W1 1↯+1W 0 # ver -↯+1H⊂↯W1 0 # hor -⊂⊟ -# Stack: ([hor, ver, vis]) -Walk [0 0] - -PP! ← ≡/⊂∵^! # Pretty print using switch. -≡(&p$"_\n_")⊃(PP!⟨"+ "|"+--"⟩⊡Ver|PP!⟨" "|"| "⟩⊡Hor) +# Generate a maze. +Maze ← ( + ↘¯1☇1↯(+1H)⊟⊂/⊂↯W"+-" @+⊂/⊂↯W"| " @| # Build a filled maze. + Walk 1_1 # Walk around breaking walls. +) +Maze diff --git a/Task/Maze-solving/Uiua/maze-solving.uiua b/Task/Maze-solving/Uiua/maze-solving.uiua new file mode 100644 index 0000000000..c1336f9e68 --- /dev/null +++ b/Task/Maze-solving/Uiua/maze-solving.uiua @@ -0,0 +1,26 @@ +# You can delete from here to SOLVE THE MAZE +# if you're appending this to the maze generator code. +# Experimental! +["+-+-+-+-+-+-+" + "|. . .|. . .|" + "+-+-+ + + + +" + "|.|. .|.|.|.|" + "+ + +-+-+ + +" + "|.|. . . .|.|" + "+ +-+-+-+-+ +" + "|. . . . . .|" + "+-+-+-+-+-+-+"] +H ← 4 +W ← 6 +Nfour ← +⊙¤[¯2_0 2_0 0_2 0_¯2] # Gives N4 +InBounds ← ▽⊸≡(↧⊃(/↧≥1_1|/↧< +1 × 2 H_W)) +GetWall ← -:⊡1:÷2/-. +# S O L V E T H E M A Z E # +. +Start ← 1_1 +End ← -Start ×2 H_W +Heur ← /+⌵-End # Manhattan distance. +# (pos grid) -> 1-4 next steps, in bounds, without walls in the way. +Ns ← ≡⊡1▽:⟜(≡(=@ ⊡)⊙¤≡GetWall)≡⊟¤:InBounds Nfour. +astar(Ns|Heur|≍End) Start # Solve (costs = 1 => djikstra) +$"_ moves" ⊙⟜(⍜(⊡|+33)):°□⊢ diff --git a/Task/McNuggets-problem/Refal/mcnuggets-problem.refal b/Task/McNuggets-problem/Refal/mcnuggets-problem.refal new file mode 100644 index 0000000000..877827269a --- /dev/null +++ b/Task/McNuggets-problem/Refal/mcnuggets-problem.refal @@ -0,0 +1,37 @@ +$ENTRY Go { + , : e.A + , : e.B + , : e.C + , : e.Nums + , )>: e.Nuggets + , : e.NonNuggets + , e.NonNuggets: e.X s.Last + = ; +}; + +SumPairs { + () (e.Y) = ; + (s.I e.X) (e.Y) = ; +}; + +SumPairs1 { + s.I () = ; + s.I (s.X e.X) = <+ s.I s.X> ; +}; + +Remove { + s.I e.X s.I e.Y = e.X ; + s.I e.X = e.X; +}; + +RemoveAll { + () e.X = e.X; + (s.R e.R) e.X = >; +}; + +Iota { + s.Start s.Step s.End, : { + '+' = ; + s.X = s.Start s.Step s.End>; + }; +}; diff --git a/Task/McNuggets-problem/Uiua/mcnuggets-problem.uiua b/Task/McNuggets-problem/Uiua/mcnuggets-problem.uiua new file mode 100644 index 0000000000..1400394615 --- /dev/null +++ b/Task/McNuggets-problem/Uiua/mcnuggets-problem.uiua @@ -0,0 +1,4 @@ +# Get s/m/l ranges to (100/6, 100/9, 100/20) and multipiy out. +⟜(◴≡/+פ⟜(☇1⇡⌊÷)6_9_20) 100 +# Compare against 0-100 for missing, return highest. +/↥▽:⟜(¬∊)⇡⟜(▽⊸≤) diff --git a/Task/Memory-allocation/PascalABC.NET/memory-allocation.pas b/Task/Memory-allocation/PascalABC.NET/memory-allocation.pas new file mode 100644 index 0000000000..580aad83a1 --- /dev/null +++ b/Task/Memory-allocation/PascalABC.NET/memory-allocation.pas @@ -0,0 +1,16 @@ +procedure ppp; +begin + var i,j: integer; // i,j are allocated automatically on the stack when we call procedure +end; + +begin + ppp; + var p: ^integer; + New(p); // memory is allocated on the heap + p^ := 666; + Dispose(p); // explicit memory deallocation + + var ri := new integer[5]; // memory is allocated on the heap + ri[0] := 555; + ri := nil; // memory is controlled by .NET garbage collector +end. diff --git a/Task/Menu/Langur/menu.langur b/Task/Menu/Langur/menu.langur index 122e18c86d..44a20d9a8e 100644 --- a/Task/Menu/Langur/menu.langur +++ b/Task/Menu/Langur/menu.langur @@ -1,21 +1,21 @@ -val .select = impure fn(.entries) { - if .entries is not list: throw "invalid args" - if len(.entries) == 0: return "" +val choose = impure fn(entries) { + if entries is not list: throw "invalid args" + if not entries: return "" # print the menu - writeln join "\n", map(fn(.e, .i) $"\.i:2;: \.e;", .entries, 1..len .entries) + writeln join("\n", map(fn e, i: "{{i:2}}: {{e}}", entries, 1..len(entries))) - val .idx = number read( + val idx = read( "Select entry #: ", - fn(.x) { - if not .x -> RE/^[0-9]+$/: return false - val .y = number .x - .y > 0 and .y <= len(.entries) + fn(x) { + if not x -> RE/^[0-9]+$/: return false + val y = x -> number + y > 0 and y <= len(entries) }, "invalid selection\n", -1, - ) + ) -> number - .entries[.idx] + entries[idx] } -writeln .select(["fee fie", "eat pi", "huff and puff", "tick tock"]) +writeln choose(["fee fie", "eat pi", "huff and puff", "tick tock"]) diff --git a/Task/Middle-three-digits/Uiua/middle-three-digits.uiua b/Task/Middle-three-digits/Uiua/middle-three-digits.uiua new file mode 100644 index 0000000000..c688251689 --- /dev/null +++ b/Task/Middle-three-digits/Uiua/middle-three-digits.uiua @@ -0,0 +1,9 @@ +[123 12345 1234567 987654321 10001 ¯10001 ¯123 ¯100 100 ¯12345 + 1 2 ¯1 ¯10 2002 ¯2002 0] +Mid ← ( + ⍤("too short")≥3.⧻.°□°⋕⌵ + ⍤("even length")≠0◿2. + ↘¯⟜↘⌊÷2-3 +) +⍉⊟⟜≡⍚⍣(Mid|⊂"Error: "◌) # Convert each +≡(&p$"_\t->\t_"°⊟) # Display diff --git a/Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test.rexx b/Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-1.rexx similarity index 100% rename from Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test.rexx rename to Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-1.rexx diff --git a/Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-2.rexx b/Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-2.rexx new file mode 100644 index 0000000000..b7d044c45f --- /dev/null +++ b/Task/Miller-Rabin-primality-test/REXX/miller-rabin-primality-test-2.rexx @@ -0,0 +1,167 @@ +parse version version +say version +glob. = '' +numeric digits 1000 +say '25 numbers of the form 2^n-1, mostly Mersenne primes' +say 'Up to about 25 digits deterministic, above probabilistic' +say +mm = '2 3 5 7 11 13 17 19 23 31 61 89 97 107 113 127 131 521 607 1279 2203 2281 2293 3217 3221' +do nn = 1 to 25 + a = Word(mm,nn); b = 2**a-1; l = Length(b) + call time('r'); p = Prime(b); e = time('e') + if l > 25 then + b = Left(b,12)'...'Right(b,13) + select + when p = 0 then + p = 'not' + when l < 26 then + p = 'for sure' + otherwise + p = 'probable' + end + say '2^('a'-1)' '=' b '('l' digits) is' p 'prime' '('format(e,,3) 'seconds)' +end +return + +Prime: +/* Is a number prime? */ +procedure expose glob. +arg x +/* Validity */ +if \ Whole(x) then + return 'X' +if x < 2 then + return 'X' +/* Low primes also used as deterministic witnesses */ +w1 = ' 2 3 5 7 11 13 17 19 23 29 31 37 41 ' +/* Fast values */ +w = x +if Pos(' 'w' ',w1) > 0 then + return 1 +if x//2 = 0 then + return 0 +if x//3 = 0 then + return 0 +if Right(x,1) = 5 then + return 0 +/* Miller-Rabin primality test */ +numeric digits 2*Length(x) +d = x-1; e = d +/* Reduce n-1 by factors of 2 */ +do s = -1 while d//2 = 0 + d = d%2 +end +/* Thresholds deterministic witnesses */ +w2 = ' 2047 1373653 25326001 3215031751 2152302898747 3474749660383 341550071728321 0 ', +|| ' 3825123056546413051 0 0 318665857834031151167461 3317044064679887385961981 ' +w = Words(w2) +/* Up to 13 deterministic trials */ +if x < Word(w2,w) then do + do k = 1 to w + if x < Word(w2,k) then + leave + end +end +/* or 3 probabilistic trials */ +else do + w1 = ' ' + do k = 1 to 3 + r = Rand(2,e)/1; w1 = w1||r||' ' + end + k = k-1 +end +/* Algorithm using generated witnesses */ +do k = 1 to k + a = Word(w1,k); y = powermod(a,d,x) + if y = 1 then + iterate + if y = e then + iterate + do s + y = (y*y)//x + if y = 1 then + return 0 + if y = e then + leave + end + if y <> e then + return 0 +end +return 1 + +Floor: +/* Floor */ +procedure expose glob. +arg x +/* Formula */ +if Whole(x) then + return x +else + return Trunc(x)-(x<0) + +Powermod: +/* Power modulus function x^y mod z */ +procedure expose glob. +arg x,y,z +/* Validity */ +if \ Whole(x) then + return 'X' +if \ Whole(x) then + return 'X' +if \ Whole(x) then + return 'X' +if x < 0 then + return 'X' +if y < 0 then + return 'X' +if z < 1 then + return 'X' +/* Special values */ +if z = 1 then + return 0 +/* Binary method */ +numeric digits Max(Length(Format(x,,,0)),Length(Format(y,,,0)),2*Length(Format(z,,,0))) +b = x//z; r = 1 +do while y > 0 + if y//2 then + r = r*x//z + x = x*x//z; y = y%2 +end +return r + +Rand: +/* Random number 12 digits precision */ +procedure expose glob. +arg x,y +/* Validity */ +if x <> '' then do + if \ Whole(x) then + return 'X' + if \ Whole(x) then + return 'X' + if x >= y then + return 'X' +end +/* Fixed precision */ +p = Digits(); numeric digits 30 +/* Get and save first seed from system Date and Time */ +if glob.rand = '' then do + a = Date('s'); b = Time('l') + glob.rand = Substr(b,10,3)||Substr(b,7,2)||Substr(b,4,2)||Substr(b,1,2)||Substr(a,7,2)||Substr(a,5,2)||Substr(a,3,2) +end +/* Calculate next random number method HP calculators */ +glob.rand = Right((glob.rand*2851130928467),15) +/* Uniform deviate [0,1) */ +z = '0.'Left(glob.rand,Length(glob.rand)-3) +numeric digits 12 +if x = '' then + return z/1 +else + return Floor(z*(y+1-x)+x) + +Whole: +/* Is a number integer? */ +procedure expose glob. +arg x +/* Formula */ +return Datatype(x,'w') diff --git a/Task/Mind-boggling-card-trick/Ada/mind-boggling-card-trick.ada b/Task/Mind-boggling-card-trick/Ada/mind-boggling-card-trick.ada new file mode 100644 index 0000000000..afc0404d1f --- /dev/null +++ b/Task/Mind-boggling-card-trick/Ada/mind-boggling-card-trick.ada @@ -0,0 +1,100 @@ +-- Check the "Mind boggling card trick" +-- J. Carter 2024 May +-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC) + +with Ada.Text_IO; +with Ada.Numerics.Discrete_Random; +with PragmARC.Cards.Decks.US; +with PragmARC.Cards.US; + +procedure Card_Trick is + package Cards renames PragmARC.Cards.US; + package Decks renames PragmARC.Cards.Decks.US; + + function Is_Red (Card : in Cards.Card_Info) return Boolean is + (Card.Suit in Cards.Diamond | Cards.Heart); + + function Correct return Boolean; + -- Performs the trick and returns True if the assertion that 'The number of black cards in the "black" pile equals the number + -- of red cards in the "red" pile' holds; False if it does not + + function Correct return Boolean is + function Num_Red (Deck : in Decks.Deck_52) return Natural; + -- Returns the number of red cards in Deck + + function Num_Black (Deck : in Decks.Deck_52) return Natural; + -- Returns the number of black cards in Deck + + function Num_Red (Deck : in Decks.Deck_52) return Natural is + Result : Natural := 0; + begin -- Num_Red + Count : for I in 1 .. Deck.Size loop + if Is_Red (Deck.Value (I) ) then + Result := Result + 1; + end if; + end loop Count; + + return Result; + end Num_Red; + + function Num_Black (Deck : in Decks.Deck_52) return Natural is + (Deck.Size - Num_Red (Deck) ); + + Hand : Decks.Deck_52; + Red : Decks.Deck_52; + Black : Decks.Deck_52; + Card : Cards.Card_Info; + begin -- Correct + Decks.Standard_Deck (Item => Hand); + Hand.Shuffle; + + All_Cards : loop + exit All_Cards when Hand.Is_Empty; + + Hand.Deal (To => Card); + + if Is_Red (Card) then + Hand.Deal (To => Card); + Red.Add (Item => Card); + else + Hand.Deal (To => Card); + Black.Add (Item => Card); + end if; + end loop All_Cards; + + Swap : declare + Number : constant Natural := Integer'Min (Red.Size, Black.Size) - 1; + + subtype Bunch_Value is Integer range 1 .. Number; + + package Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Bunch_Value); + + Gen : Random.Generator; + Bunch : Bunch_Value; + begin -- Swap + Random.Reset (Gen => Gen); + Bunch := Random.Random (Gen); + + One_Bunch : for I in 1 .. Bunch loop + Red.Deal (To => Card); + Black.Add (Item => Card); + Black.Deal (To => Card); + Red.Add (Item => Card); + end loop One_Bunch; + + return Num_Red (Red) = Num_Black (Black); + end Swap; + end Correct; + + Total : constant := 10_000; + + Good : Natural := 0; +begin -- Card_Trick + Check_All : for I in 1 .. Total loop + if Correct then + Good := Good + 1; + end if; + end loop Check_All; + + Ada.Text_IO.Put_Line (Item => Good'Image & " correct out of" & Total'Image & " tries"); +end Card_Trick; diff --git a/Task/Mind-boggling-card-trick/Jq/mind-boggling-card-trick.jq b/Task/Mind-boggling-card-trick/Jq/mind-boggling-card-trick.jq new file mode 100644 index 0000000000..4a6717d63f --- /dev/null +++ b/Task/Mind-boggling-card-trick/Jq/mind-boggling-card-trick.jq @@ -0,0 +1,105 @@ +### Generic utilities +def count(s): reduce s as $x (0; . + 1); + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + + +### Pseuo-random numbers + +# Output: a prn in range(0;$n) where $n is `.` +def prn: + if . == 1 then 0 + else . as $n + | ([1, (($n-1)|tostring|length)]|max) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +def sample: + if length == 0 # e.g. null or [] + then null + else .[length|prn] + end; + +def knuthShuffle: + length as $n + | if $n <= 1 then . + else {i: $n, a: .} + | until(.i == 0; + .i += -1 + | (.i + 1 | prn) as $j + | .a[.i] as $t + | .a[.i] = .a[$j] + | .a[$j] = $t) + | .a + end; + + +### Cards + +def R: "R"; # 82 ASCII +def B: "B"; # 66 ASCII + +# Create deck, half red, half black and shuffle it. +def deck: + ([range(0;26)|R] + [range(0;26)|B]) | knuthShuffle; + +# Deal from `deck` into three stacks: {black, red, discard} +def deal: + deck as $deck + | reduce range(0; 51; 2) as $i (.; + if $deck[$i] == B + then .black += [$deck[$i+1]] + else .red += [$deck[$i+1]] + end + | .discard += [$deck[$i]] ); + +def proceed: + def p: join(" "); + + (.red|length) as $lr + | (.black|length) as $lb + | (.discard|length) as $ld + + | def displayStacks($discard): + " Red : \($lr|lpad(2)) cards -> \(.red|p)", + " Black : \($lb|lpad(2)) cards -> \(.black|p)", + (select($discard) + | " Discard: \($ld) cards -> \(.discard|p)") ; + + # Input: {red, black} + def swap($n): + . + { rp: ([range(0; $lr)] | knuthShuffle[0:$n] ), + bp: ([range(0; $lb)] | knuthShuffle[0:$n]) } + | reduce range(0;$n) as $i (.; + .red[.rp[$i]] as $t + | .red[.rp[$i]] = .black[.bp[$i]] + | .black[.bp[$i]] = $t); + + def epilog: + # Check that the number of black cards in the black stack equals + # the number of red cards in the red stack: + count(select(.red[] == R)) as $rcount + | count(select(.black[] == B)) as $bcount + | "\nThe number of red cards in the red stack = \($rcount)", + "The number of black cards in the black stack = \($bcount)", + if $rcount == $bcount + then "So the assertion is correct!" + else "So the assertion is incorrect!" + end; + + "After dealing the cards, the stacks are as follows:", + displayStacks(true), + # Swap the same, random, number of cards between the red and black stacks. + ( (if $lr < $lb then $lr else $lb end) as $min + | (($min - 1|prn) + 1) as $n + | swap($n) + | "\n\($n) card(s) are to be swapped.", + "The respective zero-based indices of the cards to be swapped are:", + " Red : \(.rp|map(lpad(3))|p)", + " Black : \(.bp|map(lpad(3))|p)", + "\nAfter swapping, the red and black stacks are as follows:", + displayStacks(false), + epilog ) ; + +deal | proceed diff --git a/Task/Minimal-steps-down-to-1/Jq/minimal-steps-down-to-1.jq b/Task/Minimal-steps-down-to-1/Jq/minimal-steps-down-to-1.jq new file mode 100644 index 0000000000..5163ced4b4 --- /dev/null +++ b/Task/Minimal-steps-down-to-1/Jq/minimal-steps-down-to-1.jq @@ -0,0 +1,82 @@ +### Generic functions + +def array($n): . as $in | [range(0;$n)|$in]; + +def max(stream): reduce stream as $x (-infinite; if $x > . then $x else . end); + +def plural: if . == 1 then " " else "s" end; + +### Minimal Steps +# Input: { divs, subs, limit, mins } +# where .divs and .subs are the arrays of divisors and subtractors respectively, +# and .limit the value specified for task/1; +# .mins should be an array of arrays. +def minsteps($n): + if $n == 1 + then .mins[1] = [] + else .min = .limit + | .p = 0 + | .q = 0 + | .op = "" + | reduce .divs[] as $div (.; + if ($n % $div == 0) + then (($n/$div)|floor) as $d + | (.mins[$d]|length + 1) as $steps + | if $steps < .min + then .min = $steps + | .p = $d + | .q = $div + | .op = "/" + end + end ) + | reduce .subs[] as $sub (.; + ($n - $sub) as $d + | if $d >= 1 + then (.mins[$d]|length + 1) as $steps + | if $steps < .min + then .min = $steps + | .p = $d + | .q = $sub + | .op = "-" + end + end) + | .mins[$n] = ["\(.op)\(.q) -> \(.p)"] + .mins[.p] + end ; + +def task($limit): + range(0;2) as $r + | { divs: [2, 3], + subs: (if $r == 0 then [1] else [2] end), + mins: [], + $limit + } + | "\nWith: Divisors: \(.divs), Subtractors: \(.subs) =>", + " Minimum number of steps to diminish the following numbers down to 1 is:", + ( foreach range(1; 1+$limit) as $i (.; + minsteps($i) # sets .min[$i] + | if ($i <= 10) + then (.mins[$i]|length) as $steps + | .emit = " \($i): \($steps) step\($steps|plural): \(.mins[$i] | join(", "))" + else .emit = null + end; + select(.emit).emit, + + # ... and when all is done: + (select($i==$limit) + | foreach (2000, 20000, $limit) as $lim (.; + .max = max( .mins[0: 1 + $lim][] | length) + | .maxs = [] + | .i = 0 + | reduce .mins[0: 1 + $lim][] as $min (.; + if ($min|length) == .max then .maxs += [.i] end + | .i += 1 ) + | .nums = (.maxs|length) + | (if .nums == 1 then "is" else "are" end) as $are + | (if .nums == 1 then "has" else "have" end) as $have + | .emit = " There \($are) \(.nums) number\(.nums|plural) in the range 1-\($lim)" + | .emit += " that \($have) maximum 'minimal steps' of \(.max):" + | .emit += "\n \(.maxs)"; + .emit) ) ) ) +; + +task(50000) diff --git a/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Quackery/minimum-multiple-of-m-where-digital-sum-equals-m.quackery b/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Quackery/minimum-multiple-of-m-where-digital-sum-equals-m.quackery new file mode 100644 index 0000000000..aee9d4fb1a --- /dev/null +++ b/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/Quackery/minimum-multiple-of-m-where-digital-sum-equals-m.quackery @@ -0,0 +1,14 @@ + [ 0 swap + [ 10 /mod + rot + swap + dup 0 = until ] + drop ] is digitsum ( n --> n ) + + [] 1 + 40 times + [ 1 from + [ dup dup index * + digitsum = if + [ index swap end ] ] + 1+ dip join ] + drop echo diff --git a/Task/Modified-random-distribution/Jq/modified-random-distribution.jq b/Task/Modified-random-distribution/Jq/modified-random-distribution.jq new file mode 100644 index 0000000000..c095dfdc88 --- /dev/null +++ b/Task/Modified-random-distribution/Jq/modified-random-distribution.jq @@ -0,0 +1,50 @@ +# Output: a PRN (integer) in range(0; .) +def prn: + if . == 1 then 0 + else . as $n + | (($n-1)|tostring|length) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +def rgen: + 1000 | prn / 1000; + +# Modified random number generator. +# `modifier` should be a zero-arity filter +def rng(modifier): + {} + | until(.r1 and (.r2 < (.r1|modifier)); + .r1 = rgen + | .r2 = rgen ) + | .r1; + +def modifier: + if (. < 0.5) then 2 * (0.5 - .) + else 2 * (. - 0.5) + end; + +def N:100000; +def NUM_BINS: 20; +def HIST_CHAR: "■"; +def HIST_CHAR_SIZE: 500; +def binSize:1 / NUM_BINS; + +def task: + # tidy decimals + def round($ndec): pow(10;$ndec) as $p | . * $p | round / $p; + def zpad($len): tostring | ($len - length) as $l | . + ("0" * $l); + def r: if . == 0 then "0.00" else round(2) | zpad(4) end; + reduce range(0; N) as $i ([]; + rng(modifier) as $rn + | (($rn / binSize)|floor) as $bn + | .[$bn] += 1) + | {bins: .} + | "Modified random distribution with \(N) samples in range [0, 1):", + " Range Number of samples within that range", + (foreach range(0; NUM_BINS) as $i (.; + (HIST_CHAR * (((.bins[$i] // 0) / HIST_CHAR_SIZE) | round)) as $hist + | .emit = "\(binSize * $i|r) - \($hist) \(.bins[$i] // 0)" ) + | .emit); + +task diff --git a/Task/Monty-Hall-problem/ANSI-BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/ANSI-BASIC/monty-hall-problem.basic new file mode 100644 index 0000000000..53ef155626 --- /dev/null +++ b/Task/Monty-Hall-problem/ANSI-BASIC/monty-hall-problem.basic @@ -0,0 +1,41 @@ +100 PROGRAM MontyHallProblem +110 DEF NGames = 10000 +120 RANDOMIZE +130 LET NWins = 0 +140 FOR Game = 0 TO NGames +150 IF IsGameWon(0) <> 0 THEN LET NWins = NWins + 1 +160 NEXT Game +170 PRINT "NOT switching doors wins car in "; +180 PRINT USING "##.#": NWins / NGames * 100; +190 PRINT "% of games." +200 LET NWins = 0 +210 FOR Game = 0 TO NGames +220 IF IsGameWon(1) <> 0 THEN LET NWins = NWins + 1 +230 NEXT Game +240 PRINT "But switching doors wins car in "; +250 PRINT USING "##.#": NWins / NGames * 100; +260 PRINT "% of games." +270 END +280 REM *** +290 EXTERNAL FUNCTION IsGameWon(Sw) +300 REM Play one game. +310 REM Switching if and only if Sw <> 0. +320 REM Returns 1 if the game is won, 0 otherwise. +330 LET Car = INT(RND * 3) ! Randomly place car behind a door. +340 LET Player0 = INT(RND * 3) ! Player randomly chooses a door. +350 DO +360 LET Monty = INT(RND * 3) ! Monty opens door revealing a goat. +370 LOOP UNTIL (Monty <> Car) AND (Monty <> Player0) +380 IF Sw <> 0 THEN ! Player switches TO remaining door. +390 DO +400 LET Player = INT(RND * 3) +410 LOOP UNTIL (Player <> Player0) AND (Player <> Monty) +420 ELSE +430 LET Player = Player0 ! Player sticks with original door. +440 END IF +450 IF Player = Car THEN +460 LET IsGameWon = 1 +470 ELSE +480 LET IsGameWon = 0 +490 END IF +500 END FUNCTION diff --git a/Task/Monty-Hall-problem/Euphoria/monty-hall-problem.euphoria b/Task/Monty-Hall-problem/Euphoria/monty-hall-problem.euphoria index bf9079eb9b..7a9c8a7886 100644 --- a/Task/Monty-Hall-problem/Euphoria/monty-hall-problem.euphoria +++ b/Task/Monty-Hall-problem/Euphoria/monty-hall-problem.euphoria @@ -16,5 +16,5 @@ for plays = 1 to 10000 do stayWins += choice = winner switchWins += 6-choice-shown = winner end for -printf(1, "Switching wins %d times\n", switchWins) -printf(1, "Staying wins %d times\n", stayWins) +printf(1, "Switching wins %d times.\n", switchWins) +printf(1, "Staying wins %d times.\n", stayWins) diff --git a/Task/Monty-Hall-problem/FutureBasic/monty-hall-problem.basic b/Task/Monty-Hall-problem/FutureBasic/monty-hall-problem.basic new file mode 100644 index 0000000000..2785dc0df4 --- /dev/null +++ b/Task/Monty-Hall-problem/FutureBasic/monty-hall-problem.basic @@ -0,0 +1,60 @@ +// Monty Hall problem +// May 2024 - Rich Love + +local fn IsGameWon(Sw as int) as bool + REM Play one game. + REM Switching if and only if Sw <> 0. + REM Returns 1 if the game is won, 0 otherwise. + + short Car = INT(RND(3)) //Randomly place car behind a door. + short Player0 = INT(RND(3)) // Player randomly chooses a door. + short Monty + short IsGameWon + short Player + + DO + Monty = INT(RND(3)) // Monty opens door revealing a goat. + UNTIL (Monty <> Car) AND (Monty <> Player0) + 380 + + IF Sw <> 0 // Player switches TO remaining door. + + DO + Player = INT(RND(3)) + UNTIL (Player <> Player0) AND (Player <> Monty) + Monty = INT(RND(3)) + + ELSE + Player = Player0 // Player sticks with original door. + END IF + IF Player = Car + IsGameWon = 1 + ELSE + IsGameWon = 0 + END IF +END fn = IsgameWon + + +_NGames = 10000 + +float NWins = 0 +short Game + +FOR Game = 0 TO _NGames + IF fn IsGameWon(0) <> 0 THEN NWins = NWins + 1 +NEXT Game + + +PRINT "NOT switching doors wins car in "; +PRINT USING "##.##" ; NWins / 100 ; +PRINT " % of games." + +NWins = 0 +FOR Game = 0 TO _NGames + IF fn IsGameWon(1) <> 0 THEN NWins = NWins + 1 +NEXT Game +PRINT "But switching doors wins car in "; +PRINT USING "##.##" ; NWins / _NGames * 100; +PRINT " % of games." + +handleevents diff --git a/Task/Monty-Hall-problem/K/monty-hall-problem.k b/Task/Monty-Hall-problem/K/monty-hall-problem.k new file mode 100644 index 0000000000..aee2321694 --- /dev/null +++ b/Task/Monty-Hall-problem/K/monty-hall-problem.k @@ -0,0 +1,3 @@ +montyhall:{t:,/ 1_ x {`prng@`t[];ch:1?3;pr:1?3;sw:1?2;$[sw;a:ch=pr;a:~(ch=pr)];a}\0N;("KEEP %";(+/t)%x;"SWAP %";(+/~t)%x)} + +montyhall 100000 diff --git a/Task/Monty-Hall-problem/Liberty-BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/Liberty-BASIC/monty-hall-problem.basic index 5ea4ac78fc..6c55b34911 100644 --- a/Task/Monty-Hall-problem/Liberty-BASIC/monty-hall-problem.basic +++ b/Task/Monty-Hall-problem/Liberty-BASIC/monty-hall-problem.basic @@ -1,4 +1,3 @@ -'adapted from BASIC solution DIM doors(3) '0 is a goat, 1 is a car total = 10000 'set desired number of iterations diff --git a/Task/Monty-Hall-problem/Minimal-BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/Minimal-BASIC/monty-hall-problem.basic new file mode 100644 index 0000000000..95d94159bb --- /dev/null +++ b/Task/Monty-Hall-problem/Minimal-BASIC/monty-hall-problem.basic @@ -0,0 +1,47 @@ +10 REM Monty Hall problem +20 LET N = 10000 +30 RANDOMIZE +40 LET W = 0 +50 FOR G = 0 TO N +60 LET S = 0 +70 GOSUB 230 +80 IF V = 0 THEN 100 +90 LET W = W+1 +100 NEXT G +110 PRINT "NOT switching doors wins car in"; +120 PRINT W/N*100; "per cent of games." +130 LET W = 0 +140 FOR G = 0 TO N +150 LET S = 1 +160 GOSUB 230 +170 IF V = 0 THEN 190 +180 LET W = W+1 +190 NEXT G +200 PRINT "But switching doors wins car in"; +210 PRINT W/N*100; "per cent of games." +220 END +230 REM ** Is game won? +240 REM Play one game. +250 REM Switching if and only if S <> 0. +260 REM Randomly place car behind a door. +270 LET C = INT(RND*3) +280 REM Player randomly chooses a door. +290 LET P0 = INT(RND*3) +300 REM Monty opens door revealing a goat. +310 LET M = INT(RND*3) +320 IF M = C THEN 310 +330 IF M = P0 THEN 310 +340 IF S = 0 THEN 410 +350 REM Player switches to remaining door. +360 LET P = INT(RND*3) +370 IF P = P0 THEN 360 +380 IF P = M THEN 360 +390 GOTO 430 +400 REM Player sticks with original door. +410 LET P = P0 +420 REM Victory? +430 IF P <> C THEN 460 +440 LET V = 1 +450 RETURN +460 LET V = 0 +470 RETURN diff --git a/Task/Monty-Hall-problem/Modula-2/monty-hall-problem.mod2 b/Task/Monty-Hall-problem/Modula-2/monty-hall-problem.mod2 new file mode 100644 index 0000000000..a251b80c6f --- /dev/null +++ b/Task/Monty-Hall-problem/Modula-2/monty-hall-problem.mod2 @@ -0,0 +1,58 @@ +MODULE MontyHallProblem; + +FROM STextIO IMPORT + WriteLn, WriteString; +FROM RandomNumbers IMPORT + Randomize, Rnd; +FROM SRealIO IMPORT + WriteFixed; + +CONST + NGames = 10000; (* number of games simulated *) +VAR + NWins, Game: CARDINAL; + +PROCEDURE IsGameWon(Sw: BOOLEAN): BOOLEAN; + (* Play one game. *) +VAR + Car, Player, Player0, Monty: CARDINAL; +BEGIN + Car := Rnd(3); (* Randomly place car behind a door. *) + Player0 := Rnd(3); (* Player randomly chooses a door. *) + REPEAT + Monty := Rnd(3); (* Monty opens door revealing a goat. *) + UNTIL (Monty <> Car) AND (Monty <> Player0); + IF Sw THEN + (* Player switches to remaining door. *) + REPEAT + Player := Rnd(3); + UNTIL (Player <> Player0) AND (Player <> Monty) + ELSE + Player := Player0 (* Player sticks with original door. *) + END; + RETURN (Player = Car); +END IsGameWon; + +BEGIN + Randomize(0); + NWins := 0; + FOR Game := 0 TO NGames DO + IF IsGameWon(FALSE) THEN + NWins := NWins + 1 + END + END; + WriteString('NOT switching doors wins car in '); + WriteFixed(FLOAT(NWins) / FLOAT(NGames) * 100.0, 1, 4); + WriteString('% of games.'); + WriteLn; + NWins := 0; + FOR Game := 0 TO NGames DO + IF IsGameWon(TRUE) THEN + NWins := NWins + 1 + END + END; + WriteString('But switching doors wins car in '); + WriteFixed(FLOAT(NWins) / FLOAT(NGames) * 100.0, 1, 4); + WriteString('% of games.'); + WriteLn; +END MontyHallProblem. diff --git a/Task/Monty-Hall-problem/BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/QuickBASIC/monty-hall-problem.basic similarity index 100% rename from Task/Monty-Hall-problem/BASIC/monty-hall-problem.basic rename to Task/Monty-Hall-problem/QuickBASIC/monty-hall-problem.basic diff --git a/Task/Monty-Hall-problem/Run-BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/Run-BASIC/monty-hall-problem.basic index fb0a783b31..d2efed63ce 100644 --- a/Task/Monty-Hall-problem/Run-BASIC/monty-hall-problem.basic +++ b/Task/Monty-Hall-problem/Run-BASIC/monty-hall-problem.basic @@ -1,5 +1,3 @@ -' adapted from BASIC solution - input "Number of tries;";tries ' gimme the number of iterations FOR plays = 1 TO tries winner = INT(RND(1) * 3) + 1 diff --git a/Task/Monty-Hall-problem/SETL/monty-hall-problem.setl b/Task/Monty-Hall-problem/SETL/monty-hall-problem.setl new file mode 100644 index 0000000000..5b124f5c39 --- /dev/null +++ b/Task/Monty-Hall-problem/SETL/monty-hall-problem.setl @@ -0,0 +1,29 @@ +program monty_hall; + setrandom(0); + + n_simulations := 100000; + print('Chance to win:'); + print('When switching doors:', win_chance(true, n_simulations) * 100, '%'); + print('When not switching doors:', win_chance(false, n_simulations) * 100, '%'); + + proc win_chance(switch, n_simulations); + wins := 0; + loop for i in [1..n_simulations] do + wins +:= if simulate(switch) then 1 else 0 end; + end loop; + return wins / n_simulations; + end proc; + + proc simulate(switch); + doors := {1, 2, 3}; + car := random doors; + goats := doors less car; + choice := random doors; + opened := random (goats less choice); + + if switch then + choice := arb (doors less choice less opened); + end if; + return choice = car; + end proc; +end program; diff --git a/Task/Monty-Hall-problem/True-BASIC/monty-hall-problem.basic b/Task/Monty-Hall-problem/True-BASIC/monty-hall-problem.basic index 579bf8536f..bc77002ccb 100644 --- a/Task/Monty-Hall-problem/True-BASIC/monty-hall-problem.basic +++ b/Task/Monty-Hall-problem/True-BASIC/monty-hall-problem.basic @@ -1,19 +1,21 @@ +OPTION BASE 0 +DIM puertas(3) + LET numTiradas = 1000000 -FOR i = 1 TO numTiradas +FOR i = 0 TO numTiradas LET pta_coche = INT(RND * 3) + 1 + LET puertas(pta_coche) = 1 LET pta_elegida = INT(RND * 3) + 1 - IF pta_coche <> pta_elegida THEN - LET pta_montys = 6 - pta_coche - pta_elegida + DO + LET pta_montys = INT(RND * 3) + 1 + LOOP WHILE puertas(pta_montys) = 1 OR pta_montys = pta_elegida + IF puertas(pta_elegida) = 1 THEN + LET cambia = cambia + 1 ELSE - DO - LET pta_montys = INT(RND * 3) + 1 - LOOP UNTIL pta_montys <> pta_coche + LET permanece = permanece + 1 END IF - ! mantener elección - IF pta_coche = pta_elegida THEN LET permanece = permanece + 1 - ! cambiar elección - IF pta_coche = 6 - pta_montys - pta_elegida THEN LET cambia = cambia + 1 + LET puertas(pta_coche) = 0 NEXT i PRINT "Cambiar gana el"; permanece / numTiradas * 100; "% de las veces." diff --git a/Task/Monty-Hall-problem/XPL0/monty-hall-problem.xpl0 b/Task/Monty-Hall-problem/XPL0/monty-hall-problem.xpl0 index ab854bdcac..df718f59af 100644 --- a/Task/Monty-Hall-problem/XPL0/monty-hall-problem.xpl0 +++ b/Task/Monty-Hall-problem/XPL0/monty-hall-problem.xpl0 @@ -17,17 +17,17 @@ return Player = Car; ]; [Format(2,1); -Text(0, "NOT switching doors wins car in "); NWins:= 0; for Game:= 0 to NGames-1 do if IsGameWon(false) then NWins:= NWins+1; +Text(0, "NOT switching doors wins car in "); RlOut(0, float(NWins)/float(NGames)*100.0); Text(0, "% of games.^M^J"); -Text(0, "But switching doors wins car in "); NWins:= 0; for Game:= 0 to NGames-1 do if IsGameWon(true) then NWins:= NWins+1; +Text(0, "But switching doors wins car in "); RlOut(0, float(NWins)/float(NGames)*100.0); Text(0, "% of games.^M^J"); ] diff --git a/Task/Monty-Hall-problem/Zig/monty-hall-problem.zig b/Task/Monty-Hall-problem/Zig/monty-hall-problem.zig new file mode 100644 index 0000000000..5d00cc875b --- /dev/null +++ b/Task/Monty-Hall-problem/Zig/monty-hall-problem.zig @@ -0,0 +1,29 @@ +const std = @import("std"); + +const number_of_simulations: u32 = 10_000_000; + +pub fn main() !void { + var stick_wins: u32 = 0; + var switch_wins: u32 = 0; + var doors = [3]bool{ true, false, false }; + + var t = std.rand.DefaultPrng.init(42); + const r = t.random(); + + var guess: u8 = undefined; + var door_shown: u8 = undefined; + + for (0..number_of_simulations) |_| { + std.rand.Random.shuffle(r, bool, &doors); + guess = r.intRangeAtMost(u8, 0, 2); + door_shown = r.intRangeAtMost(u8, 0, 2); + while (!doors[door_shown] and door_shown != guess) door_shown = r.intRangeAtMost(u8, 0, 2); + if (doors[guess]) { + stick_wins += 1; + } else { + switch_wins += 1; + } + } + + std.debug.print("After {} simulations:\nStick wins: {}\nSwitch wins: {}\n", .{ number_of_simulations, stick_wins, switch_wins }); +} diff --git a/Task/Motzkin-numbers/Uiua/motzkin-numbers.uiua b/Task/Motzkin-numbers/Uiua/motzkin-numbers.uiua new file mode 100644 index 0000000000..602850f4f5 --- /dev/null +++ b/Task/Motzkin-numbers/Uiua/motzkin-numbers.uiua @@ -0,0 +1,12 @@ +# Uses following formula to generate successive terms: +# m[i] = (m[i-2]*(3*i-3) + m[i-1]*(2*i+1)) / (i + 2) + +# Collect the multiplicands from the above formula. +Multiplicands ← [⊃(-3×3|+1×2|÷:1+2)]⧻ +# Apply formula to generate next Motzkin number. +Mn ← ×⊃(/+↙2|⊢↙¯1)×⊃(⊂:1↙¯2|Multiplicands) +# Generate list of terms to reasonable limit. +⍢(⊂⟜Mn|<36⧻) [1 1] +# Simple (=slow) prime test. +IsPrime ← ⊙◌⟨⟨=1⧻⍢(↘1|≠0◿⊢)⊂:1+2⇡⌊√.|1⟩=2.|0⟩≤1. +⍉⊟⟜∵IsPrime diff --git a/Task/Mouse-position/PascalABC.NET/mouse-position.pas b/Task/Mouse-position/PascalABC.NET/mouse-position.pas new file mode 100644 index 0000000000..0fd6e9634b --- /dev/null +++ b/Task/Mouse-position/PascalABC.NET/mouse-position.pas @@ -0,0 +1,7 @@ +## +uses GraphWPF; +Font.Size := 80; +OnMouseMove := (x,y,mb) -> begin + Window.Clear; + DrawText(Window.ClientRect,$'{x,0:f0}, {y,0:f0}'); +end; diff --git a/Task/Move-to-front-algorithm/EasyLang/move-to-front-algorithm.easy b/Task/Move-to-front-algorithm/EasyLang/move-to-front-algorithm.easy new file mode 100644 index 0000000000..9ec20dfb56 --- /dev/null +++ b/Task/Move-to-front-algorithm/EasyLang/move-to-front-algorithm.easy @@ -0,0 +1,39 @@ +subr init + symt$[] = strchars "abcdefghijklmnopqrstuvwxyz" +. +proc rot k . . + c$ = symt$[k] + for j = k downto 2 + symt$[j] = symt$[j - 1] + . + symt$[1] = c$ +. +func[] encode s$ . + init + for c$ in strchars s$ + k = 1 + while symt$[k] <> c$ + k += 1 + . + res[] &= k - 1 + rot k + . + return res[] +. +func$ decode s[] . + init + for k in s[] + k += 1 + c$ = symt$[k] + res$ &= c$ + rot k + . + return res$ +. +for word$ in [ "broood" "babanaaa" "hiphophiphop" ] + enc[] = encode word$ + print word$ & " -> " & enc[] + if decode enc[] <> word$ + print "error" + . +. diff --git a/Task/Multiple-regression/BASIC256/multiple-regression.basic b/Task/Multiple-regression/BASIC256/multiple-regression.basic new file mode 100644 index 0000000000..cfb6654e95 --- /dev/null +++ b/Task/Multiple-regression/BASIC256/multiple-regression.basic @@ -0,0 +1,70 @@ +arraybase 0 +N = 14: M = 2: Q = 3 # number of points and M.R. polynom degree + +dim X(N+1) # data points +X[0] = 1.47 : X[1] = 1.50 : X[2] = 1.52 +X[3] = 1.55 : X[4] = 1.57 : X[5] = 1.60 +X[6] = 1.63 : X[7] = 1.65 : X[8] = 1.68 +X[9] = 1.70 : X[10] = 1.73 : X[11] = 1.75 +X[12] = 1.78 : X[13] = 1.80 : X[14] = 1.83 +dim Y(N+1) # data points +Y[0] = 52.21 : Y[1] = 53.12 : Y[2] = 54.48 +Y[3] = 55.84 : Y[4] = 57.20 : Y[5] = 58.57 +Y[6] = 59.93 : Y[7] = 61.29 : Y[8] = 63.11 +Y[9] = 64.47 : Y[10] = 66.28 : Y[11] = 68.10 +Y[12] = 69.92 : Y[13] = 72.19 : Y[14] = 74.46 +dim S(N+1): dim T(N+1) # linear system coefficient +dim A(M+1, Q+1) # system to be solved +dim p(M+1, Q+1) + +for k = 0 to 2 * M + S[k] = 0: T[k] = 0 + for i = 0 to N + S[k] = S[k] + X[i] ^ k + if k <= M then T[k] = T[k] + Y[i] * X[i] ^ k + next i +next k + +# build linear system +for fila = 0 to M + for columna = 0 to M + A[fila, columna] = S[fila + columna] + next columna + A[fila, columna] = T[fila] +next fila + +print "Linear system coefficents:" +for i = 0 to M + for j = 0 to M + 1 + print rjust(A[i, j], 14.1); + next j + print +next i + +for j = 0 to M + for i = j to M + if A[i, j] <> 0 then exit for + next i + if i = M + 1 then print: print "SINGULAR MATRIX '" : end + for k = 0 to M + 1 + p[j,k] = A[i,k] : A[i,k] = p[j,k] : A[j,k] = A[i,k] + next k + z = 1 / A[j, j] + for k = 0 to M + 1 + A[j, k] = z * A[j, k] + next k + for i = 0 to M + if i <> j then + z = -A[i, j] + for k = 0 to M + 1 + A[i, k] = A[i, k] + z * A[j, k] + next k + end if + next i +next j + +print: print "Solutions:" +for i = 0 to M + print rjust(A[i, M + 1], 16.7); +next i +end diff --git a/Task/Multiple-regression/Chipmunk-Basic/multiple-regression.basic b/Task/Multiple-regression/Chipmunk-Basic/multiple-regression.basic new file mode 100644 index 0000000000..941fdbe096 --- /dev/null +++ b/Task/Multiple-regression/Chipmunk-Basic/multiple-regression.basic @@ -0,0 +1,68 @@ +100 cls +110 n = 14 : m = 2 : q = 3 ' number of points and M.R. polynom degree +120 dim x(n)' data points +130 data 1.47,1.5,1.52,1.55,1.57,1.6,1.63,1.65,1.68,1.7,1.73,1.75,1.78,1.8,1.83 +140 for c = 0 to n +150 read x(c) +160 next c +170 dim y(n)' data points +180 data 52.21,53.12,54.48,55.84,57.2,58.57,59.93,61.29,63.11,64.47,66.28,68.1,69.92,72.19,74.46 +190 for c = 0 to n +200 read y(c) +210 next c +220 dim s(n) : dim t(n)' linear system coefficient +230 dim a(m,q)' sistem to be solved +240 dim p(m,q) +250 for k = 0 to 2*m +260 s(k) = 0 : t(k) = 0 +270 for i = 0 to n +280 s(k) = s(k)+x(i)^k +290 if k <= m then t(k) = t(k)+y(i)*x(i)^k +300 next i +310 next k +320 ' build linear system +330 for fila = 0 to m +340 for columna = 0 to m +350 a(fila,columna) = s(fila+columna) +360 next columna +370 a(fila,columna) = t(fila) +380 next fila +390 print "Linear system coefficents:" +400 for i = 0 to m +410 for j = 0 to m+1 +420 print using "######.#";a(i,j); +430 next j +440 print +450 next i +460 for j = 0 to m +470 for i = j to m +480 if a(i,j) <> 0 then goto 500 +490 next i +500 if i = m+1 then +510 print : print "SINGULAR MATRIX '" +520 end +530 endif +540 for k = 0 to m+1 +560 p(j,k) = a(i,k) +570 a(i,k) = p(j,k) +580 a(j,k) = a(i,k) +590 next k +600 z = 1/a(j,j) +610 for k = 0 to m+1 +620 a(j,k) = z*a(j,k) +630 next k +640 for i = 0 to m +650 if i <> j then +660 z = -a(i,j) +670 for k = 0 to m+1 +680 a(i,k) = a(i,k)+z*a(j,k) +690 next k +700 endif +710 next i +720 next j +730 print : print "Solutions:" +740 for i = 0 to m +750 print using " #####.#######";a(i,m+1); +760 next i +770 print +780 end diff --git a/Task/Multiple-regression/QB64/multiple-regression.qb64 b/Task/Multiple-regression/QB64/multiple-regression.qb64 new file mode 100644 index 0000000000..5f39849aef --- /dev/null +++ b/Task/Multiple-regression/QB64/multiple-regression.qb64 @@ -0,0 +1,71 @@ +Const N = 14, M = 2, Q = 3 ' number of points and M.R. polynom degree + +Dim X(N) As Double ' data points +Data 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 +For c = LBound(X) To UBound(X) + Read X(c) +Next c +Dim As Double Y(N) ' data points +Data 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 +For c = LBound(Y) To UBound(Y) + Read Y(c) +Next c +Dim As Double S(N), T(N) ' linear system coefficient +Dim As Double A(M, Q) ' system to be solved +Dim As Integer i, k, j, fila, columna +Dim As Double z + +For k = 0 To 2 * M + S(k) = 0: T(k) = 0 + For i = 0 To N + S(k) = S(k) + X(i) ^ k + If k <= M Then T(k) = T(k) + Y(i) * X(i) ^ k + Next i +Next k + +' build linear system +For fila = 0 To M + For columna = 0 To M + A(fila, columna) = S(fila + columna) + Next columna + A(fila, columna) = T(fila) +Next fila + +Print "Linear system coefficents:" +For i = 0 To M + For j = 0 To M + 1 + Print Using "######.#"; A(i, j); + Next j + Print +Next i + +For j = 0 To M + For i = j To M + If A(i, j) <> 0 Then Exit For + Next i + If i = M + 1 Then + Print: Print "SINGULAR MATRIX '" + End + End If + For k = 0 To M + 1 + Swap A(j, k), A(i, k) + Next k + z = 1 / A(j, j) + For k = 0 To M + 1 + A(j, k) = z * A(j, k) + Next k + For i = 0 To M + If i <> j Then + z = -A(i, j) + For k = 0 To M + 1 + A(i, k) = A(i, k) + z * A(j, k) + Next k + End If + Next i +Next j + +Print: Print "Solutions:" +For i = 0 To M + Print Using " #####.#######"; A(i, M + 1); +Next i +End diff --git a/Task/Multiple-regression/True-BASIC/multiple-regression.basic b/Task/Multiple-regression/True-BASIC/multiple-regression.basic new file mode 100644 index 0000000000..2b3314a060 --- /dev/null +++ b/Task/Multiple-regression/True-BASIC/multiple-regression.basic @@ -0,0 +1,80 @@ +OPTION BASE 0 +LET n = 14 ! number of points and M.R. polynom degree +LET m = 2 +LET q = 3 +DIM x(0) ! data points +MAT REDIM x(n) +DATA 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 +FOR c = LBOUND(x) TO UBOUND(x) + READ x(c) +NEXT c +DIM y(0) ! data points +MAT REDIM y(n) +DATA 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 +FOR c = LBOUND(y) TO UBOUND(y) + READ y(c) +NEXT c +DIM s(0) ! linear system coefficient +MAT REDIM s(n) +DIM t(0) +MAT REDIM t(n) +DIM a(0,0) ! system to be solved +MAT REDIM a(m, q) +DIM p(0,0) +MAT REDIM p(m, q) + +FOR k = 0 TO 2*m + LET s(k) = 0 + LET t(k) = 0 + FOR i = 0 TO n + LET s(k) = s(k)+x(i)^k + IF k <= m THEN LET t(k) = t(k)+y(i)*x(i)^k + NEXT i +NEXT k +! build linear system +FOR fila = 0 TO m + FOR columna = 0 TO m + LET a(fila, columna) = s(fila+columna) + NEXT columna + LET a(fila, columna) = t(fila) +NEXT fila +PRINT "Linear system coefficents:" +FOR i = 0 TO m + FOR j = 0 TO m+1 + PRINT USING "######.#": a(i, j); + NEXT j + PRINT +NEXT i +FOR j = 0 TO m + FOR i = j TO m + IF a(i, j) <> 0 THEN EXIT FOR + NEXT i + IF i = m+1 THEN + PRINT + PRINT "SINGULAR MATRIX '" + STOP + END IF + FOR k = 0 TO m+1 + LET p(j, k) = a(i, k) + LET a(i, k) = p(j, k) + LET a(j, k) = a(i, k) + NEXT k + LET z = 1/a(j, j) + FOR k = 0 TO m+1 + LET a(j, k) = z*a(j, k) + NEXT k + FOR i = 0 TO m + IF i <> j THEN + LET z = -a(i, j) + FOR k = 0 TO m+1 + LET a(i, k) = a(i, k)+z*a(j, k) + NEXT k + END IF + NEXT i +NEXT j +PRINT +PRINT "Solutions:" +FOR i = 0 TO m + PRINT USING " #####.#######": a(i, m+1); +NEXT i +END diff --git a/Task/Multiple-regression/Yabasic/multiple-regression.basic b/Task/Multiple-regression/Yabasic/multiple-regression.basic new file mode 100644 index 0000000000..2e464e1799 --- /dev/null +++ b/Task/Multiple-regression/Yabasic/multiple-regression.basic @@ -0,0 +1,77 @@ +// number of points and M.R. polynom degree +N = 14 +M = 2 +Q = 3 + +dim X(N) // data points +X(0) = 1.47 : X(1) = 1.50 : X(2) = 1.52 +X(3) = 1.55 : X(4) = 1.57 : X(5) = 1.60 +X(6) = 1.63 : X(7) = 1.65 : X(8) = 1.68 +X(9) = 1.70 : X(10) = 1.73 : X(11) = 1.75 +X(12) = 1.78 : X(13) = 1.80 : X(14) = 1.83 +dim Y(N) // data points +Y(0) = 52.21 : Y(1) = 53.12 : Y(2) = 54.48 +Y(3) = 55.84 : Y(4) = 57.20 : Y(5) = 58.57 +Y(6) = 59.93 : Y(7) = 61.29 : Y(8) = 63.11 +Y(9) = 64.47 : Y(10) = 66.28 : Y(11) = 68.10 +Y(12) = 69.92 : Y(13) = 72.19 : Y(14) = 74.46 + +dim S(N), T(N) // linear system coefficient +dim A(M, Q) // sistem to be solved +dim p(M, Q) + +for k = 0 to 2*M + S(k) = 0 : T(k) = 0 + for i = 0 to N + S(k) = S(k) + X(i) ^ k + if k <= M T(k) = T(k) + Y(i) * X(i) ^ k + next i +next k + +// build linear system +for fila = 0 to M + for columna = 0 to M + A(fila, columna) = S(fila+columna) + next columna + A(fila, columna) = T(fila) +next fila + +print "Linear system coefficents:" +for i = 0 to M + for j = 0 to M+1 + print A(i,j) using "#####.#"; + next j + print +next i + +for j = 0 to M + for i = j to M + if A(i,j) <> 0 break + next i + if i = M+1 then + print "\nSINGULAR MATRIX '" + end + end if + for k = 0 to M+1 + p(j,k) = A(i,k) : A(i,k) = p(j,k) : A(j,k) = A(i,k) + next k + z = 1 / A(j,j) + for k = 0 to M+1 + A(j,k) = z * A(j,k) + next k + for i = 0 to M + if i <> j then + z = -A(i,j) + for k = 0 to M+1 + A(i,k) = A(i,k) + z * A(j,k) + next k + end if + next i +next j + +print "\nSolutions:" +for i = 0 to M + print A(i,M+1) using "#######.#######"; +next i +print +end diff --git a/Task/Multiplicative-order/11l/multiplicative-order.11l b/Task/Multiplicative-order/11l/multiplicative-order.11l index 895e57c750..373554e391 100644 --- a/Task/Multiplicative-order/11l/multiplicative-order.11l +++ b/Task/Multiplicative-order/11l/multiplicative-order.11l @@ -1,9 +1,4 @@ -T PExp - BigInt prime - Int exp - F (prime, exp) - .prime = prime - .exp = exp +T PExp = (BigInt prime, Int exp) F isqrt(self) V b = self diff --git a/Task/Multiplicative-order/Jq/multiplicative-order.jq b/Task/Multiplicative-order/Jq/multiplicative-order.jq new file mode 100644 index 0000000000..207f72ac47 --- /dev/null +++ b/Task/Multiplicative-order/Jq/multiplicative-order.jq @@ -0,0 +1,181 @@ +# Part 1: Library functions + +### Counting and integer arithmetic + +def count(s): reduce s as $x (0; .+1); + +# If $j is 0, then an error condition is raised; +# otherwise, assuming infinite-precision integer arithmetic, +# if the input and $j are integers, then the result will be an integer. +def idivide($j): + (. - (. % $j)) / $j ; + +def idivide($i; $j): + $i | idivide($j); + +# Emit [dividend, mod] +def divmod($j): + (. % $j) as $mod + | [(. - $mod) / $j, $mod] ; + +# input should be a non-negative integer for accuracy +# but may be any non-negative finite number +def isqrt: + def irt: + . as $x + | 1 | until(. > $x; . * 4) as $q + | {$q, $x, r: 0} + | until( .q <= 1; + .q |= idivide(4) + | .t = .x - .r - .q + | .r |= idivide(2) + | if .t >= 0 + then .x = .t + | .r += .q + else . + end) + | .r ; + if type == "number" and (isinfinite|not) and (isnan|not) and . >= 0 + then irt + else "isqrt requires a non-negative integer for accuracy" | error + end ; + +# It is assumed that $n >= 0 +def power($n): + . as $in + | reduce range(0;$n) as $i (1; .* $in); + +# For syntactic convenience +def power($in; $n): $in | power($n); + +def gcd(a; b): + # subfunction expects [a,b] as input + # i.e. a ~ .[0] and b ~ .[1] + def rgcd: if .[1] == 0 then .[0] + else [.[1], .[0] % .[1]] | rgcd + end; + [a,b] | rgcd; + + +### Bit arrays and streams + +def rightshift($n): + reduce range(0;$n) as $i (.; idivide(2)); + +# Convert the input integer to a stream of 0s and 1s, least significant bit first +def bitwise: + recurse( if . >= 2 then idivide(2) else empty end) | . % 2; + +def bitLength: count(bitwise); + +def firstBit: + if . == 0 then empty + else first( foreach bitwise as $b (-1; .+1; if $b == 1 then . else empty end)) + end; + +# Return true if the $i-th least-significant bit is 1, and false otherwise +def testBit($i): + (nth($i; bitwise) // 0) == 1; + +# Part 2: "modulo" functions + +# The multiplicative inverse of . modulo $n +def modInv($n): + . as $in + | { r: $n, + newR: length, # abs + t: 0, + newT: 1 } + | until (.newR != 0.; + idivide(.r; .newR) as $q + | .lastT = .t + | .lastR = .r + | .t = .newT + | .r = .newR + | .newT = .lastT - $q*.newT + | .newR = .lastR - $q*.newR ) + | if .r != 1 + then "\($in) and \($n) are not co-prime." | error + else if (.t < 0) then .t += $n end + | if ($in < 0) then - .t else .t end + end; + +# Return . to the power $exp modulo $mod +def modPow($exp; $mod): + def isOdd: . % 2 == 1; + if $mod == 0 then "Cannot take modPow with modulus 0." | error + else {r: 1, base: (. % $mod), $exp} + | if .exp < 0 + then .exp *= -1 + | .base |= modInv($mod) + end + | until ((.exp == 0) or .emit; + if .base == 0 then .emit = 0 + else if (.exp | isOdd) then .r = (.r * .base) % $mod end + | .exp |= idivide(2) + | .base |= (.*.) % $mod + end ) + | (.emit // .r) + end ; + +# Part 3: Multiplicative order + +def moBachShallit58($a; $n; $pf): + {n1: ($n - 1), + mo: 1 } + | reduce $pf[] as $pe (.; + (.n1 | idivide($pe.prime | power($pe.exp))) as $y + | .o = 0 + | .x = ($a | modPow($y; ($n|length))) + | until (.x <= 1; + .x |= modPow($pe.prime; ($n|length) ) + | .o += 1 ) + | .o1 = .o + | .o1 = power($pe.prime;.o1) + | .o1 = idivide(.o1; gcd(.mo; .o1) ) + | .mo = .mo * .o1 ) + | .mo ; + +def factor($n): + { pf: [], + nn: $n, + e: ($n | firstBit)} + | if .e > 0 + then .e as $e + | .nn |= rightshift($e) + | .pf = [{prime: 2, exp: .e}] + end + | (.nn | isqrt) as $s + | .d = 3 + | until (.nn <= 1; + if .d > $s then .d = .nn end + | .e = 0 + | .done = null + | until( .done; + .d as $d + | (.nn | divmod($d)) as $dm + | if $dm[1] > 0 + then .done = true + else .nn = $dm[0] + | .e += 1 + end ) + | if .e > 0 + then .pf += [{prime: .d, exp: .e}] + |.s = (.nn|isqrt) + end + | .d += 2 + ) + | .pf ; + +# $n should be prime +def moTest($a; $n): + if ($a|bitLength) < 100 then "ord(\($a)) " else "ord([big]) " end + + if ($n|bitLength) < 100 then "mod \($n) " else "mod [big] " end + + "= \(moBachShallit58($a; $n; factor($n - 1)))" ; + +moTest(37; 3343), +moTest(1 + power(10;100); 7919), +moTest(1 + power(10;100); 15485863), +moTest(power(10;10000) - 1; 22801763489), +moTest(1511678068; 7379191741), +moTest(3047753288; 2257683301) diff --git a/Task/Multisplit/EasyLang/multisplit.easy b/Task/Multisplit/EasyLang/multisplit.easy new file mode 100644 index 0000000000..ac60f0d2ff --- /dev/null +++ b/Task/Multisplit/EasyLang/multisplit.easy @@ -0,0 +1,17 @@ +proc multisplit str$ sep$[] . . + repeat + min = 1 / 0 + for sep$ in sep$[] + pos = strpos str$ sep$ + if pos > 0 and pos < min + min = pos + msep$ = sep$ + . + . + until min = 1 / 0 + write substr str$ 1 (min - 1) & "{" & msep$ & "}" + str$ = substr str$ (min + len msep$) 9999 + . + print str$ +. +multisplit "a!===b=!=c" [ "==" "!=" "=" ] diff --git a/Task/Munchausen-numbers/Langur/munchausen-numbers.langur b/Task/Munchausen-numbers/Langur/munchausen-numbers.langur index 745bbd073b..b97ba6c9a9 100644 --- a/Task/Munchausen-numbers/Langur/munchausen-numbers.langur +++ b/Task/Munchausen-numbers/Langur/munchausen-numbers.langur @@ -1,5 +1,5 @@ # sum power of digits -val .spod = fn(.n) fold fn{+}, map(fn(.x) .x^.x, s2n string .n) +val spod = fn n:fold(fn{+}, map(fn x:x^x, n -> string -> s2n)) # Munchausen -writeln "Answers: ", filter fn(.n) .n == .spod(.n), series 0..5000 +writeln "Answers: ", filter(fn n: n == spod(n), series(1..5000)) diff --git a/Task/Munchausen-numbers/Rust/munchausen-numbers.rust b/Task/Munchausen-numbers/Rust/munchausen-numbers-1.rust similarity index 100% rename from Task/Munchausen-numbers/Rust/munchausen-numbers.rust rename to Task/Munchausen-numbers/Rust/munchausen-numbers-1.rust diff --git a/Task/Munchausen-numbers/Rust/munchausen-numbers-2.rust b/Task/Munchausen-numbers/Rust/munchausen-numbers-2.rust new file mode 100644 index 0000000000..3f1f196de9 --- /dev/null +++ b/Task/Munchausen-numbers/Rust/munchausen-numbers-2.rust @@ -0,0 +1,35 @@ +use num_bigint::BigUint; +use num_traits::cast::ToPrimitive; +use rayon::prelude::*; + +fn main() { + // Helper function to compute the Munchausen sum + fn munchausen_sum(num: &BigUint) -> BigUint { + num.to_string() + .chars() + .map(|c| { + let digit = c.to_digit(10).unwrap(); + if digit == 0 { + BigUint::from(0u32) + } else { + BigUint::from(digit).pow(digit) + } + }) + .sum::() + } + + // Loop through the desired range + let start = BigUint::from(0u128); + let end = BigUint::from(1_000_00u128); + let solutions: Vec = (start.to_u128().unwrap()..end.to_u128().unwrap()) + .into_par_iter() + .map(|n| BigUint::from(n)) + .filter(|num| munchausen_sum(num) == *num) + .collect(); + + for solution in &solutions { + println!("Munchausen number found: {:?}", solution); + } + + println!("Munchausen numbers below {:?}: {:?}", end, solutions); +} diff --git a/Task/Musical-scale/Ada/musical-scale.ada b/Task/Musical-scale/Ada/musical-scale.ada new file mode 100644 index 0000000000..ba11498f78 --- /dev/null +++ b/Task/Musical-scale/Ada/musical-scale.ada @@ -0,0 +1,74 @@ +pragma Ada_2022; +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Sequential_IO; +with Interfaces; use Interfaces; + +procedure Musical_Scale is + package Byte_IO is new Ada.Sequential_IO (Unsigned_8); use Byte_IO; + + SAMPLE_RATE : constant Unsigned_32 := 44100; + DURATION : constant Unsigned_32 := 8; + DATA_LENGTH : constant Unsigned_32 := SAMPLE_RATE * DURATION; + WAV_HDR_LEN : constant Integer := 44; + FILE_SIZE_8 : constant Unsigned_32 := Unsigned_32 (WAV_HDR_LEN) + DATA_LENGTH + 4; + + type Byte_Arr is array (Positive range <>) of Unsigned_8; + Wav_Header : constant Byte_Arr (1 .. WAV_HDR_LEN) := [ + Character'Pos ('R'), Character'Pos ('I'), Character'Pos ('F'), Character'Pos ('F'), + Unsigned_8 (FILE_SIZE_8 and 16#ff#), + Unsigned_8 (Shift_Right (FILE_SIZE_8, 8) and 16#ff#), + Unsigned_8 (Shift_Right (FILE_SIZE_8, 16) and 16#ff#), + Unsigned_8 (Shift_Right (FILE_SIZE_8, 24) and 16#ff#), + Character'Pos ('W'), Character'Pos ('A'), Character'Pos ('V'), Character'Pos ('E'), + Character'Pos ('f'), Character'Pos ('m'), Character'Pos ('t'), Character'Pos (' '), + 16#10#, 0, 0, 0, 1, 0, 1, 0, 16#44#, 16#ac#, 0, 0, 16#44#, 16#ac#, 0, 0, 1, 0, 8, 0, + Character'Pos ('d'), Character'Pos ('a'), Character'Pos ('t'), Character'Pos ('a'), + Unsigned_8 (DATA_LENGTH and 16#ff#), + Unsigned_8 (Shift_Right (DATA_LENGTH, 8) and 16#ff#), + Unsigned_8 (Shift_Right (DATA_LENGTH, 16) and 16#ff#), + Unsigned_8 (Shift_Right (DATA_LENGTH, 24) and 16#ff#) + ]; + MIDI_Header : constant Byte_Arr (1 .. 22) := [ + Character'Pos ('M'), Character'Pos ('T'), Character'Pos ('h'), Character'Pos ('d'), + 0, 0, 0, 6, 0, 0, 0, 1, 0, 96, -- File header + Character'Pos ('M'), Character'Pos ('T'), Character'Pos ('r'), Character'Pos ('k'), + 0, 0, 0, 8 * 8 + 4 -- Track header + ]; + MIDI_Trailer : constant Byte_Arr := [0, 16#ff#, 16#2f#, 0]; + type Freq_Arr is array (Positive range <>) of Float; + Freqs : constant Freq_Arr := [261.63, 293.67, 329.63, 349.23, 392.0, 440.0, 493.88, 523.25]; + Notes : constant Byte_Arr := [60, 62, 64, 65, 67, 69, 71, 72]; + Note_On_Off : Byte_Arr := [0, 16#90#, 0, 16#40#, 16#60#, 16#80#, 0, 0]; + + Wav_File, MIDI_File : File_Type; + Omega : Float; + + procedure Write_Arr (File : File_Type; Arr : Byte_Arr) is + begin + for B of Arr loop + Write (File, B); + end loop; + end Write_Arr; + +begin + Create (Wav_File, Out_File, "scale.wav"); + Write_Arr (Wav_File, Wav_Header); + for Freq of Freqs loop + Omega := 2.0 * Pi * Freq; + for Tick in 0 .. Integer (DATA_LENGTH) / 8 loop + Write (Wav_File, Unsigned_8 (32.0 * (Sin (Omega * Float (Tick) / Float (SAMPLE_RATE)) + 1.0))); + end loop; + end loop; + Close (Wav_File); + + Create (MIDI_File, Out_File, "scale.mid"); + Write_Arr (MIDI_File, MIDI_Header); + for Note of Notes loop + Note_On_Off (3) := Note; + Note_On_Off (7) := Note; + Write_Arr (MIDI_File, Note_On_Off); + end loop; + Write_Arr (MIDI_File, MIDI_Trailer); + Close (MIDI_File); +end Musical_Scale; diff --git a/Task/Mutual-recursion/EMal/mutual-recursion.emal b/Task/Mutual-recursion/EMal/mutual-recursion.emal new file mode 100644 index 0000000000..4eec1403e0 --- /dev/null +++ b/Task/Mutual-recursion/EMal/mutual-recursion.emal @@ -0,0 +1,8 @@ +fun F ← #include +#include -int count = 0; -void solve(int n, int col, int *hist) -{ - if (col == n) { - printf("\nNo. %d\n-----\n", ++count); - for (int i = 0; i < n; i++, putchar('\n')) - for (int j = 0; j < n; j++) - putchar(j == hist[i] ? 'Q' : ((i + j) & 1) ? ' ' : '.'); +// In column order, print out the given positions in chess notation. +// For example, when N = 8, the first solution printed is: +// "a1 b5 c8 d6 e3 f7 g2 h4" +static void print_positions(int x[], const size_t n) { + static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; - return; + // There are only 26 letters in the ASCII alphabet, so + // so don't bother with chess notation above 26. + if (n <= 26) { + for (size_t i = 0; i < n; ++i) + printf("%c%u ", alphabet[i], x[i] + 1); + } else { + for (size_t i = 0; i < n; ++i) + printf("%u ", x[i] + 1); } + putchar('\n'); +} -# define attack(i, j) (hist[j] == i || abs(hist[j] - i) == col - j) - for (int i = 0, j = 0; i < n; i++) { - for (j = 0; j < col && !attack(i, j); j++); - if (j < col) continue; +// Print all solutions to the N queens problem, holding the results in +// the intermediate array x, and with the auxiliary boolean arrays a, b, and c. +// x and a are both N elements long, while b and c are 2*N-1 elements long. +// It is assumed that these arrays are zeroed before this routine is called. +static void queens(int x[], bool a[], bool b[], bool c[], const size_t n) { + size_t col, row = 0; - hist[col] = i; - solve(n, col + 1, hist); +advance_row: + if (row >= n) { + print_positions(x, n); + goto backtrack; + } + col = 0; +try_column: + if (!a[col] && !b[col+row-1] && !c[col-row+n]) { + a[col] = true; + b[col+row-1] = true; + c[col-row+n] = true; + x[row] = col; + row++; + goto advance_row; + } +try_again: + if (col < n-1) { + col++; + goto try_column; + } +backtrack: + if (row != 0) { + --row; + col = x[row]; + c[col-row+n] = false; + b[col+row-1] = false; + a[col] = false; + goto try_again; } } -int main(int n, char **argv) -{ - if (n <= 1 || (n = atoi(argv[1])) <= 0) n = 8; - int hist[n]; - solve(n, 0, hist); +static void *calloc_wrapper(size_t count, size_t bytesize) { + void *r; + if ((r = calloc(count, bytesize)) == NULL) { + exit(EXIT_FAILURE); + } + return r; +} + +int main(int argc, char **argv) { + bool *a, *b, *c; + int n, *x; + + if (argc != 2 || (n = atoi(argv[1])) <= 0) { + printf("%s: specify a natural number argument\n", argv[0]); + return 1; + } + + x = calloc_wrapper(n, sizeof(x[0])); + a = calloc_wrapper(n, sizeof(a[0])); + b = calloc_wrapper((2 * n - 1), sizeof(b[0])); + c = calloc_wrapper((2 * n - 1), sizeof(c[0])); + + queens(x, a, b, c, n); + + // Don't bother freeing before exiting. + return 0; } diff --git a/Task/N-queens-problem/C/n-queens-problem-2.c b/Task/N-queens-problem/C/n-queens-problem-2.c index dcc46bb728..2dc59e4e1f 100644 --- a/Task/N-queens-problem/C/n-queens-problem-2.c +++ b/Task/N-queens-problem/C/n-queens-problem-2.c @@ -1,38 +1,31 @@ #include #include -#include -typedef uint32_t uint; -uint full, *qs, count = 0, nn; - -void solve(uint d, uint c, uint l, uint r) +int count = 0; +void solve(int n, int col, int *hist) { - uint b, a, *s; - if (!d) { - count++; -#if 0 - printf("\nNo. %d\n===========\n", count); - for (a = 0; a < nn; a++, putchar('\n')) - for (b = 0; b < nn; b++, putchar(' ')) - putchar(" -QQ"[((b == qs[a])<<1)|((a + b)&1)]); -#endif + if (col == n) { + printf("\nNo. %d\n-----\n", ++count); + for (int i = 0; i < n; i++, putchar('\n')) + for (int j = 0; j < n; j++) + putchar(j == hist[i] ? 'Q' : ((i + j) & 1) ? ' ' : '.'); + return; } - a = (c | (l <<= 1) | (r >>= 1)) & full; - if (a != full) - for (*(s = qs + --d) = 0, b = 1; b <= full; (*s)++, b <<= 1) - if (!(b & a)) solve(d, b|c, b|l, b|r); +# define attack(i, j) (hist[j] == i || abs(hist[j] - i) == col - j) + for (int i = 0, j = 0; i < n; i++) { + for (j = 0; j < col && !attack(i, j); j++); + if (j < col) continue; + + hist[col] = i; + solve(n, col + 1, hist); + } } int main(int n, char **argv) { - if (n <= 1 || (nn = atoi(argv[1])) <= 0) nn = 8; - - qs = calloc(nn, sizeof(int)); - full = (1U << nn) - 1; - - solve(nn, 0, 0, 0); - printf("\nSolutions: %d\n", count); - return 0; + if (n <= 1 || (n = atoi(argv[1])) <= 0) n = 8; + int hist[n]; + solve(n, 0, hist); } diff --git a/Task/N-queens-problem/C/n-queens-problem-3.c b/Task/N-queens-problem/C/n-queens-problem-3.c index 3316ea1a70..dcc46bb728 100644 --- a/Task/N-queens-problem/C/n-queens-problem-3.c +++ b/Task/N-queens-problem/C/n-queens-problem-3.c @@ -1,91 +1,38 @@ #include #include +#include -typedef unsigned int uint; -uint count = 0; +typedef uint32_t uint; +uint full, *qs, count = 0, nn; -#define ulen sizeof(uint) * 8 - -/* could have defined as int solve(...), but void may have less - chance to confuse poor optimizer */ -void solve(int n) +void solve(uint d, uint c, uint l, uint r) { - int cnt = 0; - const uint full = -(int)(1 << (ulen - n)); - register uint bits, pos, *m, d, e; - - uint b0, b1, l[32], r[32], c[32], mm[33] = {0}; - n -= 3; - /* require second queen to be left of the first queen, so - we ever only test half of the possible solutions. This - is why we can't handle n=1 here */ - for (b0 = 1U << (ulen - n - 3); b0; b0 <<= 1) { - for (b1 = b0 << 2; b1; b1 <<= 1) { - d = n; - /* c: columns occupied by previous queens. - l: columns attacked by left diagonals - r: by right diagnoals */ - c[n] = b0 | b1; - l[n] = (b0 << 2) | (b1 << 1); - r[n] = (b0 >> 2) | (b1 >> 1); - - /* availabe columns on current row. m is stack */ - bits = *(m = mm + 1) = full & ~(l[n] | r[n] | c[n]); - - while (bits) { - /* d: depth, aka row. counting backwards - because !d is often faster than d != n */ - while (d) { - /* pos is right most nonzero bit */ - pos = -(int)bits & bits; - - /* mark bit used. only put current bits - on stack if not zero, so backtracking - will skip exhausted rows (because reading - stack variable is sloooow compared to - registers) */ - if ((bits &= ~pos)) - *m++ = bits | d; - - /* faster than l[d+1] = l[d]... */ - e = d--; - l[d] = (l[e] | pos) << 1; - r[d] = (r[e] | pos) >> 1; - c[d] = c[e] | pos; - - bits = full & ~(l[d] | r[d] | c[d]); - - if (!bits) break; - if (!d) { cnt++; break; } - } - /* Bottom of stack m is a zero'd field acting - as sentinel. When saving to stack, left - 27 bits are the available columns, while - right 5 bits is the depth. Hence solution - is limited to size 27 board -- not that it - matters in foreseeable future. */ - d = (bits = *--m) & 31U; - bits &= ~31U; - } - } + uint b, a, *s; + if (!d) { + count++; +#if 0 + printf("\nNo. %d\n===========\n", count); + for (a = 0; a < nn; a++, putchar('\n')) + for (b = 0; b < nn; b++, putchar(' ')) + putchar(" -QQ"[((b == qs[a])<<1)|((a + b)&1)]); +#endif + return; } - count = cnt * 2; + + a = (c | (l <<= 1) | (r >>= 1)) & full; + if (a != full) + for (*(s = qs + --d) = 0, b = 1; b <= full; (*s)++, b <<= 1) + if (!(b & a)) solve(d, b|c, b|l, b|r); } -int main(int c, char **v) +int main(int n, char **argv) { - int nn; - if (c <= 1 || (nn = atoi(v[1])) <= 0) nn = 8; + if (n <= 1 || (nn = atoi(argv[1])) <= 0) nn = 8; - if (nn > 27) { - fprintf(stderr, "Value too large, abort\n"); - exit(1); - } - - /* Can't solve size 1 board; might as well skip 2 and 3 */ - if (nn < 4) count = nn == 1; - else solve(nn); + qs = calloc(nn, sizeof(int)); + full = (1U << nn) - 1; + solve(nn, 0, 0, 0); printf("\nSolutions: %d\n", count); return 0; } diff --git a/Task/N-queens-problem/C/n-queens-problem-4.c b/Task/N-queens-problem/C/n-queens-problem-4.c index 113b40fdcc..3316ea1a70 100644 --- a/Task/N-queens-problem/C/n-queens-problem-4.c +++ b/Task/N-queens-problem/C/n-queens-problem-4.c @@ -1,69 +1,91 @@ #include -#define MAXN 31 +#include -int nqueens(int n) +typedef unsigned int uint; +uint count = 0; + +#define ulen sizeof(uint) * 8 + +/* could have defined as int solve(...), but void may have less + chance to confuse poor optimizer */ +void solve(int n) { - int q0,q1; - int cols[MAXN], diagl[MAXN], diagr[MAXN], posibs[MAXN]; // Our backtracking 'stack' - int num=0; - // - // The top level is two fors, to save one bit of symmetry in the enumeration by forcing second queen to - // be AFTER the first queen. - // - for (q0=0; q0>1 | bit1)>>1; + int cnt = 0; + const uint full = -(int)(1 << (ulen - n)); + register uint bits, pos, *m, d, e; - // The variable posib contains the bitmask of possibilities we still have to try in a given row ... - int posib = ~(cols[0] | diagl[0] | diagr[0]); + uint b0, b1, l[32], r[32], c[32], mm[33] = {0}; + n -= 3; + /* require second queen to be left of the first queen, so + we ever only test half of the possible solutions. This + is why we can't handle n=1 here */ + for (b0 = 1U << (ulen - n - 3); b0; b0 <<= 1) { + for (b1 = b0 << 2; b1; b1 <<= 1) { + d = n; + /* c: columns occupied by previous queens. + l: columns attacked by left diagonals + r: by right diagnoals */ + c[n] = b0 | b1; + l[n] = (b0 << 2) | (b1 << 1); + r[n] = (b0 >> 2) | (b1 >> 1); - while (d >= 0) { - while(posib) { - int bit = posib & -posib; // The standard trick for getting the rightmost bit in the mask - int ncols= cols[d] | bit; - int ndiagl = (diagl[d] | bit) << 1; - int ndiagr = (diagr[d] | bit) >> 1; - int nposib = ~(ncols | ndiagl | ndiagr); - posib^=bit; // Eliminate the tried possibility. + /* availabe columns on current row. m is stack */ + bits = *(m = mm + 1) = full & ~(l[n] | r[n] | c[n]); - // The following is the main additional trick here, as recognizing solution can not be done using stack level (d), - // since we save the depth+backtrack time at the end of the enumeration loop. However by noticing all coloumns are - // filled (comparison to -1) we know a solution was reached ... - // Notice also that avoiding an if on the ncols==-1 comparison is more efficient! - num += ncols==-1; + while (bits) { + /* d: depth, aka row. counting backwards + because !d is often faster than d != n */ + while (d) { + /* pos is right most nonzero bit */ + pos = -(int)bits & bits; - if (nposib) { - if (posib) { // This if saves stack depth + backtrack operations when we passed the last possibility in a row. - posibs[d++] = posib; // Go lower in stack .. - } - cols[d] = ncols; - diagl[d] = ndiagl; - diagr[d] = ndiagr; - posib = nposib; - } - } - posib = posibs[--d]; // backtrack ... - } - } - } - return num*2; + /* mark bit used. only put current bits + on stack if not zero, so backtracking + will skip exhausted rows (because reading + stack variable is sloooow compared to + registers) */ + if ((bits &= ~pos)) + *m++ = bits | d; + + /* faster than l[d+1] = l[d]... */ + e = d--; + l[d] = (l[e] | pos) << 1; + r[d] = (r[e] | pos) >> 1; + c[d] = c[e] | pos; + + bits = full & ~(l[d] | r[d] | c[d]); + + if (!bits) break; + if (!d) { cnt++; break; } + } + /* Bottom of stack m is a zero'd field acting + as sentinel. When saving to stack, left + 27 bits are the available columns, while + right 5 bits is the depth. Hence solution + is limited to size 27 board -- not that it + matters in foreseeable future. */ + d = (bits = *--m) & 31U; + bits &= ~31U; + } + } + } + count = cnt * 2; } - -main(int ac , char **av) +int main(int c, char **v) { - if(ac != 2) { - printf("usage: nq n\n"); - return 1; - } - int n = atoi(av[1]); - if(n<1 || n > MAXN) { - printf("n must be between 2 and 31!\n"); - } - printf("Number of solution for %d is %d\n",n,nqueens(n)); + int nn; + if (c <= 1 || (nn = atoi(v[1])) <= 0) nn = 8; + + if (nn > 27) { + fprintf(stderr, "Value too large, abort\n"); + exit(1); + } + + /* Can't solve size 1 board; might as well skip 2 and 3 */ + if (nn < 4) count = nn == 1; + else solve(nn); + + printf("\nSolutions: %d\n", count); + return 0; } diff --git a/Task/N-queens-problem/C/n-queens-problem-5.c b/Task/N-queens-problem/C/n-queens-problem-5.c new file mode 100644 index 0000000000..113b40fdcc --- /dev/null +++ b/Task/N-queens-problem/C/n-queens-problem-5.c @@ -0,0 +1,69 @@ +#include +#define MAXN 31 + +int nqueens(int n) +{ + int q0,q1; + int cols[MAXN], diagl[MAXN], diagr[MAXN], posibs[MAXN]; // Our backtracking 'stack' + int num=0; + // + // The top level is two fors, to save one bit of symmetry in the enumeration by forcing second queen to + // be AFTER the first queen. + // + for (q0=0; q0>1 | bit1)>>1; + + // The variable posib contains the bitmask of possibilities we still have to try in a given row ... + int posib = ~(cols[0] | diagl[0] | diagr[0]); + + while (d >= 0) { + while(posib) { + int bit = posib & -posib; // The standard trick for getting the rightmost bit in the mask + int ncols= cols[d] | bit; + int ndiagl = (diagl[d] | bit) << 1; + int ndiagr = (diagr[d] | bit) >> 1; + int nposib = ~(ncols | ndiagl | ndiagr); + posib^=bit; // Eliminate the tried possibility. + + // The following is the main additional trick here, as recognizing solution can not be done using stack level (d), + // since we save the depth+backtrack time at the end of the enumeration loop. However by noticing all coloumns are + // filled (comparison to -1) we know a solution was reached ... + // Notice also that avoiding an if on the ncols==-1 comparison is more efficient! + num += ncols==-1; + + if (nposib) { + if (posib) { // This if saves stack depth + backtrack operations when we passed the last possibility in a row. + posibs[d++] = posib; // Go lower in stack .. + } + cols[d] = ncols; + diagl[d] = ndiagl; + diagr[d] = ndiagr; + posib = nposib; + } + } + posib = posibs[--d]; // backtrack ... + } + } + } + return num*2; +} + + +main(int ac , char **av) +{ + if(ac != 2) { + printf("usage: nq n\n"); + return 1; + } + int n = atoi(av[1]); + if(n<1 || n > MAXN) { + printf("n must be between 2 and 31!\n"); + } + printf("Number of solution for %d is %d\n",n,nqueens(n)); +} diff --git a/Task/N-queens-problem/Commodore-BASIC/n-queens-problem.basic b/Task/N-queens-problem/Commodore-BASIC/n-queens-problem.basic new file mode 100644 index 0000000000..9fc67f1733 --- /dev/null +++ b/Task/N-queens-problem/Commodore-BASIC/n-queens-problem.basic @@ -0,0 +1,55 @@ +100 REM N-QUEENS PROBLEM IN CBM BASIC 2 +110 NQ = 8: GOSUB 200: IF A THEN NQ=A +120 PRINT CHR$(147) "SOLVING FOR" NQ "QUEENS" +130 DIM B(NQ), C(NQ), R(NQ):REM BOARD, COLUMN, ROW +140 SP = 0: REM STACK POINTER +150 TI$ = "000000": REM RESET TIMER +160 R(SP) = 0: SP = SP + 1: GOSUB 500: SP = SP - 1:REM PLACE.QUEEN(0) +170 PRINT "FOUND" SC "SOLUTIONS IN" TI / 60 "SECONDS" +180 END +190 REM +200 REM PARSE COMMAND-LINE ARGUMENT +210 P = 512 +220 C = PEEK(P): P = P + 1: IF C <> 0 THEN 220 +230 C = PEEK(P): P = P + 1: IF C = 78 THEN 290 +240 A = 0 +250 IF C = 0 THEN 290 +260 IF C < 48 OR C > 57 THEN PRINT "USAGE: RUN:": END +270 A = A * 10 + C - 48 +280 C = PEEK(P): P = P + 1: GOTO 250 +290 RETURN +295 REM +300 REM COULD.PLACE(ROW, COL): BOOL +310 CP = -1 +320 R = R(SP - 1): IF R = 0 THEN RETURN +330 C = C(SP - 1) +340 FOR I = 0 TO R - 1 +350 : IF B(I) = C OR B(I) - I = C - R OR B(I) + I = C + R THEN CP = 0 +360 : IF CP = 0 THEN I = R - 1 +370 NEXT I +380 RETURN +390 REM +400 REM PRINT.SOLUTION +410 SC = SC + 1: PRINT CHR$(19) CHR$(17) CHR$(17) "FOUND SOLUTION" SC CHR$(13) +420 FOR I=0 TO NQ - 1 +430 : PRINT " "; +440 : IF B(I) THEN N=B(I):CH=46:GOSUB 600 +450 : PRINT "Q"; +460 : IF B(I) < NQ - 1 THEN N=NQ - 1 - B(I):CH=46:GOSUB 600 +470 : PRINT +480 NEXT I +490 PRINT: RETURN +495 REM PLACE.QUEEN(ROW) +500 IF R(SP - 1) = NQ THEN GOSUB 400: RETURN +510 C(SP - 1) = 0 +520 IF C(SP - 1) = NQ THEN 590 +530 GOSUB 300: IF CP = 0 THEN 570 +540 B(R(SP - 1)) = C(SP - 1) +550 R(SP) = R(SP - 1) + 1: SP = SP + 1:GOSUB 500: SP = SP - 1 +560 B(R(SP - 1)) = 0 +570 C(SP - 1) = C(SP - 1) + 1 +580 GOTO 520 +590 RETURN +600 REM PRINT A CHARACTER N TIMES +610 FOR QQ=1 TO N:PRINT CHR$(CH);:NEXT +620 RETURN diff --git a/Task/N-queens-problem/Pascal/n-queens-problem-1.pas b/Task/N-queens-problem/Pascal/n-queens-problem-1.pas index 617a48c86c..698c6fc391 100644 --- a/Task/N-queens-problem/Pascal/n-queens-problem-1.pas +++ b/Task/N-queens-problem/Pascal/n-queens-problem-1.pas @@ -1,81 +1,34 @@ -program queens; +program eightqueens(output); +var i: integer; + a: array [1..8] of boolean; { a[j]: no queen in row j } + b: array [2..16] of boolean; { b[k]: no queen in kth diagonal down-left } + c: array [-7..7] of boolean; { c[k]: no queen in kth diagonal down-right } + x: array [1..8] of integer; { x[i]: position of queen in column i } +procedure print; + var k: integer; +begin + for k := 1 to 8 do write(x[k]: 4); + writeln +end { print } ; -const l=16; - -var i,j,k,m,n,p,q,r,y,z: integer; - a,s: array[1..l] of integer; - u: array[1..4*l-2] of integer; - -label L3,L4,L5,L6,L7,L8,L9,L10; +procedure try(i: integer); + var j: integer; +begin + for j := 1 to 8 do + if a[j] and b[i+j] and c[i-j] then + begin + { place queen } + x[i] := j; + a[j] := false; b[i+j] := false; c[i-j] := false; + if i < 8 then try(i+1) else print; + { remove queen } + a[j] := true; b[i+j] := true; c[i-j] := true + end +end { try } ; begin - for i:=1 to l do a[i]:=i; - for i:=1 to 4*l-2 do u[i]:=0; - for n:=1 to l do - begin - m:=0; - i:=1; - r:=2*n-1; - goto L4; -L3: - s[i]:=j; - u[p]:=1; - u[q+r]:=1; - i:=i+1; -L4: - if i>n then goto L8; - j:=i; -L5: - z:=a[i]; - y:=a[j]; - p:=i-y+n; - q:=i+y-1; - a[i]:=y; - a[j]:=z; - if (u[p]=0) and (u[q+r]=0) then goto L3; -L6: - j:=j+1; - if j<=n then goto L5; -L7: - j:=j-1; - if j=i then goto L9; - z:=a[i]; - a[i]:=a[j]; - a[j]:=z; - goto L7; -L8: - m:=m+1; - { uncomment the following to print solutions } - { write(n,' ',m,':'); - for k:=1 to n do write(' ',a[k]); - writeln; } -L9: - i:=i-1; - if i=0 then goto L10; - p:=i-a[i]+n; - q:=i+a[i]-1; - j:=s[i]; - u[p]:=0; - u[q+r]:=0; - goto L6; -L10: - writeln(n,' ',m); - end; -end. - -{ 1 1 - 2 0 - 3 0 - 4 2 - 5 10 - 6 4 - 7 40 - 8 92 - 9 352 - 10 724 - 11 2680 - 12 14200 - 13 73712 - 14 365596 - 15 2279184 - 16 14772512 } + for i := 1 to 8 do a[i] := true; + for i := 2 to 16 do b[i] := true; + for i := -7 to 7 do c[i] := true; + try(1) +end . diff --git a/Task/N-queens-problem/Pascal/n-queens-problem-2.pas b/Task/N-queens-problem/Pascal/n-queens-problem-2.pas index 92b7279557..617a48c86c 100644 --- a/Task/N-queens-problem/Pascal/n-queens-problem-2.pas +++ b/Task/N-queens-problem/Pascal/n-queens-problem-2.pas @@ -1,112 +1,81 @@ -program NQueens; -{$IFDEF FPC} - {$MODE DELPHI} - {$OPTIMIZATION ON}{$OPTIMIZATION REGVAR}{$OPTIMIZATION PeepHole} - {$OPTIMIZATION CSE}{$OPTIMIZATION ASMCSE} -{$ELSE} - {$Apptype console} -{$ENDIF} +program queens; + +const l=16; + +var i,j,k,m,n,p,q,r,y,z: integer; + a,s: array[1..l] of integer; + u: array[1..4*l-2] of integer; + +label L3,L4,L5,L6,L7,L8,L9,L10; -uses - sysutils;// TDatetime -const - nmax = 17; -type -{$IFNDEF FPC} - NativeInt = longInt; -{$ENDIF} - //ala Nikolaus Wirth A-1 = H - 8 - //diagonal left (A1) to rigth (H8) - tLR_diagonale = array[-nmax-1..nmax-1] of char; - //diagonal right (A8) to left (H1) - tRL_diagonale = array[0..2*nmax-2] of char; - //up to Col are the used Cols, after that the unused - tFreeCol = array[0..nmax-1] of nativeInt; -var - LR_diagonale:tLR_diagonale; - RL_diagonale:tRL_diagonale; - //Using pChar, cause it is implicit an array - //It is always set to - //@LR_diagonale[row] ,@RL_diagonale[row] - pLR,pRL : pChar; - FreeCol : tFreeCol; - i, - n : nativeInt; - gblCount : nativeUInt; - T0,T1 : TdateTime; -procedure Solution; -var - i : NativeInt; begin -// Take's a lot of time under DOS/Win32 - If gblCount AND $FFF = 0 then - write(gblCount:10,#8#8#8#8#8#8#8#8#8#8); - // IF n< 9 then - IF n < 0 then + for i:=1 to l do a[i]:=i; + for i:=1 to 4*l-2 do u[i]:=0; + for n:=1 to l do begin - For i := 1 to n do - write(FreeCol[i]:4); - writeln; + m:=0; + i:=1; + r:=2*n-1; + goto L4; +L3: + s[i]:=j; + u[p]:=1; + u[q+r]:=1; + i:=i+1; +L4: + if i>n then goto L8; + j:=i; +L5: + z:=a[i]; + y:=a[j]; + p:=i-y+n; + q:=i+y-1; + a[i]:=y; + a[j]:=z; + if (u[p]=0) and (u[q+r]=0) then goto L3; +L6: + j:=j+1; + if j<=n then goto L5; +L7: + j:=j-1; + if j=i then goto L9; + z:=a[i]; + a[i]:=a[j]; + a[j]:=z; + goto L7; +L8: + m:=m+1; + { uncomment the following to print solutions } + { write(n,' ',m,':'); + for k:=1 to n do write(' ',a[k]); + writeln; } +L9: + i:=i-1; + if i=0 then goto L10; + p:=i-a[i]+n; + q:=i+a[i]-1; + j:=s[i]; + u[p]:=0; + u[q+r]:=0; + goto L6; +L10: + writeln(n,' ',m); end; -end; - -procedure SetQueen(Row:nativeInt); -var - i,Col : nativeInt; -begin -IF row <= n then - begin - For i := row to n do - begin - Col := FreeCol[i]; - //check diagonals occupied - If (ORD(pLR[-Col]) AND ORD(pRL[Col]))<>0 then - begin - //a "free" position is found - //mark it - pRL[ Col]:=#0; //RL_Diagonale[ Row +Col] := 0; - pLR[-Col]:=#0; //LR_Diagonale[ Row -Col] := 0; - //swap FreeRow[Row<->i] - FreeCol[i] := FreeCol[Row]; - //next row - inc(pRL); - inc(pLR); - FreeCol[Row] := Col; - // check next row - SetQueen(Row+1); - //Undo - dec(pLR); - dec(pRL); - FreeCol[Row] := FreeCol[i]; - FreeCol[i] := Col; - pRL[ Col]:=#1; - pLR[-Col]:=#1; - end; - end; - end -else - begin - //solution ist found - inc(gblCount); - //Solution - end; -end; - -begin - For i := 0 to nmax-1 do - FreeCol[i] := i; - //diagonals filled with True = #1 , something <>0 - fillchar(LR_Diagonale[low(LR_Diagonale)],sizeof(tLR_Diagonale),#1); - fillchar(RL_Diagonale[low(RL_Diagonale)],sizeof(tRL_Diagonale),#1); - For n := 1 to nMax do - begin - t0 := time; - pLR:=@LR_Diagonale[0]; - pRL:=@RL_Diagonale[0]; - gblCount := 0; - SetQueen(1); - t1:= time; - WriteLn(n:6,gblCount:12,FormatDateTime(' NN:SS.ZZZ',T1-t0),' secs'); - end; - WriteLn('Fertig'); end. + +{ 1 1 + 2 0 + 3 0 + 4 2 + 5 10 + 6 4 + 7 40 + 8 92 + 9 352 + 10 724 + 11 2680 + 12 14200 + 13 73712 + 14 365596 + 15 2279184 + 16 14772512 } diff --git a/Task/N-queens-problem/Pascal/n-queens-problem-3.pas b/Task/N-queens-problem/Pascal/n-queens-problem-3.pas new file mode 100644 index 0000000000..92b7279557 --- /dev/null +++ b/Task/N-queens-problem/Pascal/n-queens-problem-3.pas @@ -0,0 +1,112 @@ +program NQueens; +{$IFDEF FPC} + {$MODE DELPHI} + {$OPTIMIZATION ON}{$OPTIMIZATION REGVAR}{$OPTIMIZATION PeepHole} + {$OPTIMIZATION CSE}{$OPTIMIZATION ASMCSE} +{$ELSE} + {$Apptype console} +{$ENDIF} + +uses + sysutils;// TDatetime +const + nmax = 17; +type +{$IFNDEF FPC} + NativeInt = longInt; +{$ENDIF} + //ala Nikolaus Wirth A-1 = H - 8 + //diagonal left (A1) to rigth (H8) + tLR_diagonale = array[-nmax-1..nmax-1] of char; + //diagonal right (A8) to left (H1) + tRL_diagonale = array[0..2*nmax-2] of char; + //up to Col are the used Cols, after that the unused + tFreeCol = array[0..nmax-1] of nativeInt; +var + LR_diagonale:tLR_diagonale; + RL_diagonale:tRL_diagonale; + //Using pChar, cause it is implicit an array + //It is always set to + //@LR_diagonale[row] ,@RL_diagonale[row] + pLR,pRL : pChar; + FreeCol : tFreeCol; + i, + n : nativeInt; + gblCount : nativeUInt; + T0,T1 : TdateTime; +procedure Solution; +var + i : NativeInt; +begin +// Take's a lot of time under DOS/Win32 + If gblCount AND $FFF = 0 then + write(gblCount:10,#8#8#8#8#8#8#8#8#8#8); + // IF n< 9 then + IF n < 0 then + begin + For i := 1 to n do + write(FreeCol[i]:4); + writeln; + end; +end; + +procedure SetQueen(Row:nativeInt); +var + i,Col : nativeInt; +begin +IF row <= n then + begin + For i := row to n do + begin + Col := FreeCol[i]; + //check diagonals occupied + If (ORD(pLR[-Col]) AND ORD(pRL[Col]))<>0 then + begin + //a "free" position is found + //mark it + pRL[ Col]:=#0; //RL_Diagonale[ Row +Col] := 0; + pLR[-Col]:=#0; //LR_Diagonale[ Row -Col] := 0; + //swap FreeRow[Row<->i] + FreeCol[i] := FreeCol[Row]; + //next row + inc(pRL); + inc(pLR); + FreeCol[Row] := Col; + // check next row + SetQueen(Row+1); + //Undo + dec(pLR); + dec(pRL); + FreeCol[Row] := FreeCol[i]; + FreeCol[i] := Col; + pRL[ Col]:=#1; + pLR[-Col]:=#1; + end; + end; + end +else + begin + //solution ist found + inc(gblCount); + //Solution + end; +end; + +begin + For i := 0 to nmax-1 do + FreeCol[i] := i; + //diagonals filled with True = #1 , something <>0 + fillchar(LR_Diagonale[low(LR_Diagonale)],sizeof(tLR_Diagonale),#1); + fillchar(RL_Diagonale[low(RL_Diagonale)],sizeof(tRL_Diagonale),#1); + For n := 1 to nMax do + begin + t0 := time; + pLR:=@LR_Diagonale[0]; + pRL:=@RL_Diagonale[0]; + gblCount := 0; + SetQueen(1); + t1:= time; + WriteLn(n:6,gblCount:12,FormatDateTime(' NN:SS.ZZZ',T1-t0),' secs'); + end; + WriteLn('Fertig'); +end. diff --git a/Task/N-queens-problem/Python/n-queens-problem-7.py b/Task/N-queens-problem/Python/n-queens-problem-7.py index f7d7633fb1..f404b4c1dc 100644 --- a/Task/N-queens-problem/Python/n-queens-problem-7.py +++ b/Task/N-queens-problem/Python/n-queens-problem-7.py @@ -1,23 +1,23 @@ -def queens(n): - a = list(range(n)) - up = [True]*(2*n - 1) - down = [True]*(2*n - 1) - def sub(i): - if i == n: - yield tuple(a) - else: +def queens(n: int): + + def sub(i: int): + if i < n: for k in range(i, n): j = a[k] - p = i + j - q = i - j + n - 1 - if up[p] and down[q]: - up[p] = down[q] = False + if b[i + j] and c[i - j]: a[i], a[k] = a[k], a[i] + b[i + j] = c[i - j] = False yield from sub(i + 1) - up[p] = down[q] = True + b[i + j] = c[i - j] = True a[i], a[k] = a[k], a[i] + else: + yield a + + a = list(range(n)) + b = [True] * (2 * n - 1) + c = [True] * (2 * n - 1) yield from sub(0) -#Count solutions for n=8: -sum(1 for p in queens(8)) + +sum(1 for p in queens(8)) # count solutions 92 diff --git a/Task/N-queens-problem/Python/n-queens-problem-8.py b/Task/N-queens-problem/Python/n-queens-problem-8.py index bf6b25cd22..3a6b107381 100644 --- a/Task/N-queens-problem/Python/n-queens-problem-8.py +++ b/Task/N-queens-problem/Python/n-queens-problem-8.py @@ -1,31 +1,29 @@ -def queens_lex(n): - a = list(range(n)) - up = [True]*(2*n - 1) - down = [True]*(2*n - 1) - def sub(i): - if i == n: - yield tuple(a) - else: +def queens_lex(n: int): + + def sub(i: int): + if i < n: for k in range(i, n): + j = a[k] a[i], a[k] = a[k], a[i] - j = a[i] - p = i + j - q = i - j + n - 1 - if up[p] and down[q]: - up[p] = down[q] = False + if b[i + j] and c[i - j]: + b[i + j] = c[i - j] = False yield from sub(i + 1) - up[p] = down[q] = True - x = a[i] - for k in range(i + 1, n): - a[k - 1] = a[k] - a[n - 1] = x + b[i + j] = c[i - j] = True + a[i:(n - 1)], a[n - 1] = a[(i + 1):n], a[i] + else: + yield a + + a = list(range(n)) + b = [True] * (2 * n - 1) + c = [True] * (2 * n - 1) yield from sub(0) + next(queens(31)) -(0, 2, 4, 1, 3, 8, 10, 12, 14, 6, 17, 21, 26, 28, 25, 27, 24, 30, 7, 5, 29, 15, 13, 11, 9, 18, 22, 19, 23, 16, 20) +[0, 2, 4, 1, 3, 8, 10, 12, 14, 6, 17, 21, 26, 28, 25, 27, 24, 30, 7, 5, 29, 15, 13, 11, 9, 18, 22, 19, 23, 16, 20] next(queens_lex(31)) -(0, 2, 4, 1, 3, 8, 10, 12, 14, 5, 17, 22, 25, 27, 30, 24, 26, 29, 6, 16, 28, 13, 9, 7, 19, 11, 15, 18, 21, 23, 20) +[0, 2, 4, 1, 3, 8, 10, 12, 14, 5, 17, 22, 25, 27, 30, 24, 26, 29, 6, 16, 28, 13, 9, 7, 19, 11, 15, 18, 21, 23, 20] #Compare to A065188 #1, 3, 5, 2, 4, 9, 11, 13, 15, 6, 8, 19, 7, 22, 10, 25, 27, 29, 31, 12, 14, 35, 37, ... diff --git a/Task/N-queens-problem/Uiua/n-queens-problem.uiua b/Task/N-queens-problem/Uiua/n-queens-problem.uiua new file mode 100644 index 0000000000..2aa0c5ea4d --- /dev/null +++ b/Task/N-queens-problem/Uiua/n-queens-problem.uiua @@ -0,0 +1,4 @@ +N ← 8 +Good ← =1⧻◴[⧻◴⟜(∩(⧻◴)⊃+-⇡⧻.)⟜⧻] +⊙◌⍥(⊏⊚≡Good.☇1⊞⊂⇡,),[[]]N +≡(≡(/(⊂⊂)@|/⊂⍜(⊡|@Q◌):↯:@_)⊸⧻) diff --git a/Task/Negative-base-numbers/EasyLang/negative-base-numbers.easy b/Task/Negative-base-numbers/EasyLang/negative-base-numbers.easy new file mode 100644 index 0000000000..84baeb9cc1 --- /dev/null +++ b/Task/Negative-base-numbers/EasyLang/negative-base-numbers.easy @@ -0,0 +1,32 @@ +func$ encode n b . + if n = 0 + return "0" + . + while n <> 0 + r = n mod b + n = n div b + if r < 0 + n += 1 + r -= b + . + out$ = strchar (r + 48) & out$ + . + return out$ +. +func decode n$ b . + if n$ = "0" + return 0 + . + for c$ in strchars n$ + c = strcode c$ - 48 + tot = tot * b + c + . + return tot +. +proc test n b . . + h$ = encode n b + print n & " -> " & h$ & "_" & b & " -> " & decode h$ b +. +test 10 -2 +test 146 -3 +test 15 -10 diff --git a/Task/Nested-function/PL-M/nested-function.plm b/Task/Nested-function/PL-M/nested-function.plm new file mode 100644 index 0000000000..cc83a2961f --- /dev/null +++ b/Task/Nested-function/PL-M/nested-function.plm @@ -0,0 +1,74 @@ +100H: /* USE A NESTED PROCEDURE TO CONSTRUCT A STRING, UPDATING VARIABLES IN */ + /* THE CONTAINING PROCEDURE */ + + /* CP/M BDOS SYSTEM CALL */ + BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5;END; + /* CONSOLE OUTPUT ROUTINES */ + PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END; + + /* CONCATENATES ITEM TO THE END OF STR. STR MUST BE LONG ENOUGH TO HOLD */ + /* THE CONCATENATED VALUE */ + CONCAT: PROCEDURE( STR, ITEM ); + DECLARE ( STR, ITEM ) ADDRESS; + + DECLARE STR$S BASED STR ( 0 )BYTE; + DECLARE ITEM$S BASED ITEM ( 0 )BYTE; + DECLARE ( STR$POS, ITEM$POS ) BYTE; + + /* FIND THE CURRENT END OF STR */ + STR$POS = 0; + DO WHILE STR$S( STR$POS ) <> '$'; + STR$POS = STR$POS + 1; + END; + + /* COPY ITEM TO THE END OF STR */ + ITEM$POS = 0; + DO WHILE ITEM$S( ITEM$POS ) <> '$'; + STR$S( STR$POS ) = ITEM$S( ITEM$POS ); + ITEM$POS = ITEM$POS + 1; + STR$POS = STR$POS + 1; + END; + STR$S( STR$POS ) = '$'; + + END CONCAT ; + + /* TASK */ + + /* RETURNS THE ADDRESS OF A STRING CONCATENATED FROM CALLS TO THE NESTED */ + /* MAKE$ITEM PROCEDURE - THE RESULTANT STRING MUST NOT BE MORE */ + /* THAN 64 CHARACTERS IN LENGTH */ + MAKE$LIST: PROCEDURE( SEPARATOR )ADDRESS; + DECLARE SEPARATOR ADDRESS; + + DECLARE LIST$VALUE ( 65 )BYTE; + DECLARE COUNTER BYTE; + + /* RETURNS THE ADDRESS OF A LIST ITEM, THE LENGTH OF THE ITEM MUST'NT */ + /* BE MORE THAN 32 CHARACTERS */ + MAKE$ITEM: PROCEDURE( ITEM )ADDRESS; + DECLARE ITEM ADDRESS; + + DECLARE LIST$ITEM ( 33 )BYTE; + + COUNTER = COUNTER + 1; + LIST$ITEM( 0 ) = '0' + COUNTER; + LIST$ITEM( 1 ) = '$'; + CALL CONCAT( .LIST$ITEM, SEPARATOR ); + CALL CONCAT( .LIST$ITEM, ITEM ); + CALL CONCAT( .LIST$ITEM, .( 0DH, 0AH, '$' ) ); + + RETURN .LIST$ITEM; + END MAKE$ITEM ; + + COUNTER = 0; + LIST$VALUE( 0 ) = '$'; + CALL CONCAT( .LISTVALUE, MAKE$ITEM( .'FIRST$' ) ); + CALL CONCAT( .LISTVALUE, MAKE$ITEM( .'SECOND$' ) ); + CALL CONCAT( .LISTVALUE, MAKE$ITEM( .'THIRD$' ) ); + + RETURN .LIST$VALUE; + END MAKE$LIST ; + + CALL PR$STRING( MAKE$LIST( .'. $' ) ); + +EOF diff --git a/Task/Nested-function/PascalABC.NET/nested-function.pas b/Task/Nested-function/PascalABC.NET/nested-function.pas new file mode 100644 index 0000000000..21f28104f2 --- /dev/null +++ b/Task/Nested-function/PascalABC.NET/nested-function.pas @@ -0,0 +1,21 @@ +procedure MakeList(separator: string); + var counter := 1; + procedure MakeItem; + begin + Write(counter, separator); + case counter of + 1: Writeln('first'); + 2: Writeln('second'); + 3: Writeln('third'); + end; + counter += 1; + end; +begin + MakeItem; + MakeItem; + MakeItem; +end; + +begin + MakeList('. '); +end. diff --git a/Task/Nested-templated-data/BASIC256/nested-templated-data.basic b/Task/Nested-templated-data/BASIC256/nested-templated-data.basic new file mode 100644 index 0000000000..cc817a033c --- /dev/null +++ b/Task/Nested-templated-data/BASIC256/nested-templated-data.basic @@ -0,0 +1,31 @@ +dim p(7) +dim p$(7) +p$[0] = "Payload#0" : p$[1] = "Payload#1" +p$[2] = "Payload#2" : p$[3] = "Payload#3" +p$[4] = "Payload#4" : p$[5] = "Payload#5" +p$[6] = "Payload#6" +dim q(7) fill false +dim t(4, 5) +t[0, 0] = 1: t[0, 1] = 2 +t[1, 0] = 3: t[1, 1] = 4: t[1, 2] = 1 +t[2, 0] = 5 + +for i = 0 to t[?][]-1 + for j = 0 to t[?][]-1 + if t[i, j] <> 0 then + q[t[i, j]] = true + t[i, j] += 1 + end if + next j +next i + +for i = 0 to t[?][]-1 + for j = 0 to t[?][]-1 + if t[i, j] <> 0 then print p$[t[i, j] -1]; " "; + next j + print +next i + +for i = 0 to q[?]-1 + if not q[i] then print p$[i]; " is not used" +next i diff --git a/Task/Nested-templated-data/Chipmunk-Basic/nested-templated-data.basic b/Task/Nested-templated-data/Chipmunk-Basic/nested-templated-data.basic new file mode 100644 index 0000000000..91dfaa29c1 --- /dev/null +++ b/Task/Nested-templated-data/Chipmunk-Basic/nested-templated-data.basic @@ -0,0 +1,30 @@ +100 cls +110 dim i,j,p(6) +120 dim p$(6) +130 p$(0) = "Payload#0" : p$(1) = "Payload#1" +140 p$(2) = "Payload#2" : p$(3) = "Payload#3" +150 p$(4) = "Payload#4" : p$(5) = "Payload#5" +160 p$(6) = "Payload#6" +170 dim q(6) +180 dim t(2,3) +190 t(0,0) = 1 : t(0,1) = 2 +200 t(1,0) = 3 : t(1,1) = 4 : t(1,2) = 1 +210 t(2,0) = 5 +220 for i = 0 to ubound(t) +230 for j = 0 to ubound(t,2) +240 if t(i,j) <> 0 then +250 q(t(i,j)) = true +260 t(i,j) = t(i,j)+1 +270 endif +280 next j +290 next i +300 for i = 0 to ubound(t) +310 for j = 0 to ubound(t,2) +320 if t(i,j) <> 0 then print p$(t(i,j)-1);" "; +330 next j +340 print +350 next i +360 for i = 0 to ubound(q) +370 if not q(i) then print p$(i);" is not used" +380 next i +390 end diff --git a/Task/Nested-templated-data/FreeBASIC/nested-templated-data.basic b/Task/Nested-templated-data/FreeBASIC/nested-templated-data.basic new file mode 100644 index 0000000000..c94e716a0c --- /dev/null +++ b/Task/Nested-templated-data/FreeBASIC/nested-templated-data.basic @@ -0,0 +1,26 @@ +Dim As Integer t(2, 3) = {{1,2},{3,4,1},{5}} +Dim As Integer i, j, p(6) +Dim As String pStr(6) = {"Payload#0", "Payload#1", "Payload#2", "Payload#3", "Payload#4", "Payload#5", "Payload#6"} +Dim As Boolean q(6) + +For i = Lbound(t) To Ubound(t) + For j = Lbound(t, 2) To Ubound(t, 2) + If t(i, j) <> 0 Then + q(t(i, j)) = True + t(i, j) += 1 + End If + Next j +Next i + +For i = Lbound(t) To Ubound(t) + For j = Lbound(t, 2) To Ubound(t, 2) + If t(i, j) <> 0 Then Print pStr(t(i, j)-1); " "; + Next j + Print +Next i + +For i = Lbound(q) To Ubound(q) + If q(i) = False Then Print pStr(i); " is not used" +Next i + +Sleep diff --git a/Task/Nested-templated-data/GW-BASIC/nested-templated-data.basic b/Task/Nested-templated-data/GW-BASIC/nested-templated-data.basic new file mode 100644 index 0000000000..eb52047593 --- /dev/null +++ b/Task/Nested-templated-data/GW-BASIC/nested-templated-data.basic @@ -0,0 +1,28 @@ +110 TRUE = -1 +120 FALSE = NOT TRUE +130 DIM I,J,P(6) +140 DIM P$(6) +150 P$(0) = "Payload#0" : P$(1) = "Payload#1" +160 P$(2) = "Payload#2" : P$(3) = "Payload#3" +170 P$(4) = "Payload#4" : P$(5) = "Payload#5" +180 P$(6) = "Payload#6" +190 DIM Q(6) +200 DIM T(2,3) +210 T(0,0) = 1 : T(0,1) = 2 +220 T(1,0) = 3 : T(1,1) = 4 : T(1,2) = 1 +230 T(2,0) = 5 +240 FOR I = 0 TO 2 +250 FOR J = 0 TO 3 +260 IF T(I,J) <> 0 THEN Q(T(I,J)) = TRUE : T(I,J) = T(I,J)+1 +270 NEXT J +280 NEXT I +290 FOR I = 0 TO 2 +300 FOR J = 0 TO 3 +310 IF T(I,J) <> 0 THEN PRINT P$(T(I,J)-1);" "; +320 NEXT J +330 PRINT +340 NEXT I +350 FOR I = 0 TO 6 +360 IF Q(I) = FALSE THEN PRINT P$(I);" is not used" +370 NEXT I +380 END diff --git a/Task/Nested-templated-data/QBasic/nested-templated-data.basic b/Task/Nested-templated-data/QBasic/nested-templated-data.basic new file mode 100644 index 0000000000..e83933c6ab --- /dev/null +++ b/Task/Nested-templated-data/QBasic/nested-templated-data.basic @@ -0,0 +1,33 @@ +True = -1: False = NOT True + +DIM p(6) +DIM p$(6) +p$(0) = "Payload#0": p$(1) = "Payload#1" +p$(2) = "Payload#2": p$(3) = "Payload#3" +p$(4) = "Payload#4": p$(5) = "Payload#5" +p$(6) = "Payload#6" +DIM q(6) +DIM t(2, 3) +t(0, 0) = 1: t(0, 1) = 2 +t(1, 0) = 3: t(1, 1) = 4: t(1, 2) = 1 +t(2, 0) = 5 + +FOR i = LBOUND(t) TO UBOUND(t) '0 To 2 + FOR j = LBOUND(t, 2) TO UBOUND(t, 2) '0 To 3 + IF t(i, j) <> 0 THEN + q(t(i, j)) = True + t(i, j) = t(i, j) + 1 + END IF + NEXT j +NEXT i + +FOR i = LBOUND(t) TO UBOUND(t) '0 To 2 + FOR j = LBOUND(t, 2) TO UBOUND(t, 2) '0 To 3 + IF t(i, j) <> 0 THEN PRINT p$(t(i, j) - 1); " "; + NEXT j + PRINT +NEXT i + +FOR i = LBOUND(q) TO UBOUND(q) + IF q(i) = False THEN PRINT p$(i); " is not used" +NEXT i diff --git a/Task/Nested-templated-data/Refal/nested-templated-data.refal b/Task/Nested-templated-data/Refal/nested-templated-data.refal new file mode 100644 index 0000000000..da9645d26d --- /dev/null +++ b/Task/Nested-templated-data/Refal/nested-templated-data.refal @@ -0,0 +1,17 @@ +$ENTRY Go { + , (((1 2) (3 4 1) 5)): e.Template + , "Payload#0" "Payload#1" "Payload#2" "Payload#3" + "Payload#4" "Payload#5" "Payload#6": e.Payload + = >; +}; + +Subst { + (e.P) = ; + (e.P) s.I e.X = ; + (e.P) (e.X) e.Y = () ; +}; + +Item { + 0 t.I e.X = t.I; + s.N t.I e.X = e.X>; +}; diff --git a/Task/Nested-templated-data/Run-BASIC/nested-templated-data.basic b/Task/Nested-templated-data/Run-BASIC/nested-templated-data.basic new file mode 100644 index 0000000000..90a2d37d4c --- /dev/null +++ b/Task/Nested-templated-data/Run-BASIC/nested-templated-data.basic @@ -0,0 +1,31 @@ +DIM p(6) +DIM p$(6) +p$(0) = "Payload#0": p$(1) = "Payload#1" +p$(2) = "Payload#2": p$(3) = "Payload#3" +p$(4) = "Payload#4": p$(5) = "Payload#5" +p$(6) = "Payload#6" +DIM q(6) +DIM t(2, 3) +t(0, 0) = 1: t(0, 1) = 2 +t(1, 0) = 3: t(1, 1) = 4: t(1, 2) = 1 +t(2, 0) = 5 + +FOR i = 0 TO 2 + FOR j = 0 TO 3 + IF t(i, j) <> 0 THEN + q(t(i, j)) = -1 + t(i, j) = t(i, j) + 1 + END IF + NEXT j +NEXT i + +FOR i = 0 TO 2 + FOR j = 0 TO 3 + IF t(i, j) <> 0 THEN PRINT p$(t(i, j) - 1); " "; + NEXT j + PRINT +NEXT i + +FOR i = 0 TO 6 + IF q(i) = 0 THEN PRINT p$(i); " is not used" +NEXT i diff --git a/Task/Nested-templated-data/SETL/nested-templated-data.setl b/Task/Nested-templated-data/SETL/nested-templated-data.setl new file mode 100644 index 0000000000..eded655838 --- /dev/null +++ b/Task/Nested-templated-data/SETL/nested-templated-data.setl @@ -0,0 +1,21 @@ +program substitution; + template := [[[1,2],[3,4,1],5]]; + payload := { + [0,"Payload#0"], [1,"Payload#1"], [2,"Payload#2"], [3,"Payload#3"], + [4,"Payload#4"], [5,"Payload#5"], [6,"Payload#6"] + }; + + print(subst(template, payload)); + + proc subst(template, payload); + if not is_tuple(template) then + return(payload(template)); + end if; + + result := []; + loop for item in template do + result with:= subst(item, payload); + end loop; + return result; + end proc; +end program; diff --git a/Task/Nested-templated-data/Yabasic/nested-templated-data.basic b/Task/Nested-templated-data/Yabasic/nested-templated-data.basic new file mode 100644 index 0000000000..192fdfb647 --- /dev/null +++ b/Task/Nested-templated-data/Yabasic/nested-templated-data.basic @@ -0,0 +1,31 @@ +dim p(6) +dim p$(6) +p$(0) = "Payload#0" : p$(1) = "Payload#1" +p$(2) = "Payload#2" : p$(3) = "Payload#3" +p$(4) = "Payload#4" : p$(5) = "Payload#5" +p$(6) = "Payload#6" +dim q(6) +dim t(2, 3) +t(0, 0) = 1: t(0, 1) = 2 +t(1, 0) = 3: t(1, 1) = 4: t(1, 2) = 1 +t(2, 0) = 5 + +for i = 0 to arraysize(t(), 1) + for j = 0 to arraysize(t(), 2) + if t(i, j) <> 0 then + q(t(i, j)) = True + t(i, j) = t(i, j) + 1 + fi + next j +next i + +for i = 0 to arraysize(t(), 1) + for j = 0 to arraysize(t(), 2) + if t(i, j) <> 0 print p$(t(i, j) -1), " "; + next j + print +next i + +for i = 0 to arraysize(q(), 1) + if not q(i) print p$(i), " is not used" +next i diff --git a/Task/Next-highest-int-from-digits/00-TASK.txt b/Task/Next-highest-int-from-digits/00-TASK.txt index 453d8b629c..0af8f68359 100644 --- a/Task/Next-highest-int-from-digits/00-TASK.txt +++ b/Task/Next-highest-int-from-digits/00-TASK.txt @@ -1,5 +1,4 @@ -Given a zero or positive integer, the task is to generate the next largest -integer using only the given digits*1. +Given a zero or positive integer, the task is to generate the next largest integer with the same digits*1. *   Numbers will not be padded to the left with zeroes. *   Use all given digits, with their given multiplicity. (If a digit appears twice in the input number, it should appear twice in the result). @@ -22,8 +21,8 @@ digits, but should be easy to reason about its correctness. ;Algorithm 2: #   Scan right-to-left through the digits of the number until you find a digit with a larger digit somewhere to the right of it. -#   Exchange that digit with the digit on the right that is ''both'' more than it, and closest to it. -#   Order the digits to the right of this position, after the swap; lowest-to-highest, left-to-right. (I.e. so they form the lowest numerical representation) +#   Exchange that digit with the smallest digit on the right that is greater than it. +#   Order the digits to the right of this position, after the swap; lowest-to-highest, left-to-right. (that is, so they form the lowest numerical representation) '''E.g.:''' @@ -47,7 +46,7 @@ algorithms for random numbers generated from a range that the first algorithm ca ;Task requirements: -Calculate the next highest int from the digits of the following numbers: +Calculate the next highest integer from the digits of the following numbers: :*   0 :*   9 :*   12 diff --git a/Task/Next-highest-int-from-digits/Ada/next-highest-int-from-digits.ada b/Task/Next-highest-int-from-digits/Ada/next-highest-int-from-digits.ada new file mode 100644 index 0000000000..38a3d3b97f --- /dev/null +++ b/Task/Next-highest-int-from-digits/Ada/next-highest-int-from-digits.ada @@ -0,0 +1,125 @@ +-- Next highest integer with same digits +-- J. Carter 2024 June +-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC) + +with Ada.Text_IO; +with PragmARC.Permutations; +with PragmARC.Sorting.Insertion; + +procedure Next_Highest is + package Permutations is new PragmARC.Permutations (Element => Character); + procedure Sort is new PragmARC.Sorting.Insertion (Element => Character, Index => Positive, Sort_Set => String); + + subtype Digit is Character range '0' .. '9'; + + function Valid (S : in String) return Boolean is + (S'First = 1 and S'Length > 0 and (for all C of S => C in Digit) ); + + function Next_P (Value : in String) return String with + Pre => Valid (Value); + -- Returns the smallest integer > Value that can be produced from Value's decimal digits, using permutations + -- Returns zero if there is no such integer + + function Next_S (Value : in String) return String with + Pre => Valid (Value); + -- Returns the smallest integer > Value that can be produced from Value's decimal digits, using the Scan, Sort, Scan, and Swap + -- (SSSS) algorithm + -- Returns zero if there is no such integer + + function Next_P (Value : in String) return String is + procedure Check (Image : in Permutations.Sequence; Stop : in out Boolean); + -- Checks if Image represents an integer > Value and smaller than Smallest + -- If so, sets Found to True and Smallest to the represented value + + Found : Boolean := False; + Smallest : String := (Value'Range => '9'); + + procedure Check (Image : in Permutations.Sequence; Stop : in out Boolean) is + Number : constant String := String (Image); + begin -- Check + if Number > Value then + Found := True; + Smallest := (if Number < Smallest then Number else Smallest); + end if; + end Check; + begin -- Next_P + if Value'Length < 2 or (Value'Length = 2 and Value < "12") then + return "0"; + end if; + + Permutations.Generate (Initial => Permutations.Sequence (Value), Process => Check'Access); + + return (if Found then Smallest else "0"); + end Next_P; + + function Next_S (Value : in String) return String is + Work : String := Value; + Found : Boolean := False; + Lower : Positive; + Higher : Positive; + begin -- Next_S + Scan_Lower : for I in reverse 1 .. Work'Last - 1 loop + if (for some C of Work (I + 1 .. Work'Last) => Work (I) < C) then + Found := True; + Lower := I; + + exit Scan_Lower; + end if; + end loop Scan_Lower; + + if not Found then + return "0"; + end if; + + Sort (Set => Work (Lower + 1 .. Work'Last) ); + + Scan_Higher : for I in Lower + 1 .. Work'Last loop -- The Found test above ensures that this will always assign to Higher + if Work (I) > Work (Lower) then + Higher := I; + + exit Scan_Higher; + end if; + end loop Scan_Higher; + + Swap : declare + Temp : constant Character := Work (Lower); + begin -- Swap + Work (Lower) := Work (Higher); + Work (Higher) := Temp; + end Swap; + + return Work; + end Next_S; + + Test_1 : constant String := "0"; + Test_2 : constant String := "9"; + Test_3 : constant String := "12"; + Test_4 : constant String := "21"; + Test_5 : constant String := "12453"; + Test_6 : constant String := "738440"; + Test_7 : constant String := "45072010"; + Test_8 : constant String := "95322020"; + Stretch : constant String := "9589776899767587796600"; +begin -- Next_Highest + Ada.Text_IO.Put_Line (Item => "Using permutations"); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_1'Length => ' ') & Test_1 & ' ' & Next_P (Test_1) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_2'Length => ' ') & Test_2 & ' ' & Next_P (Test_2) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_3'Length => ' ') & Test_3 & ' ' & Next_P (Test_3) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_4'Length => ' ') & Test_4 & ' ' & Next_P (Test_4) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_5'Length => ' ') & Test_5 & ' ' & Next_P (Test_5) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_6'Length => ' ') & Test_6 & ' ' & Next_P (Test_6) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_7'Length => ' ') & Test_7 & ' ' & Next_P (Test_7) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_8'Length => ' ') & Test_8 & ' ' & Next_P (Test_8) ); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line (Item => "Using SSSS"); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_1'Length => ' ') & Test_1 & ' ' & Next_S (Test_1) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_2'Length => ' ') & Test_2 & ' ' & Next_S (Test_2) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_3'Length => ' ') & Test_3 & ' ' & Next_S (Test_3) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_4'Length => ' ') & Test_4 & ' ' & Next_S (Test_4) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_5'Length => ' ') & Test_5 & ' ' & Next_S (Test_5) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_6'Length => ' ') & Test_6 & ' ' & Next_S (Test_6) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_7'Length => ' ') & Test_7 & ' ' & Next_S (Test_7) ); + Ada.Text_IO.Put_Line (Item => (1 .. 8 - Test_8'Length => ' ') & Test_8 & ' ' & Next_S (Test_8) ); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line (Item => Stretch & ' ' & Next_S (Stretch) ); +end Next_Highest; diff --git a/Task/Next-highest-int-from-digits/Phix/next-highest-int-from-digits-1.phix b/Task/Next-highest-int-from-digits/Phix/next-highest-int-from-digits-1.phix index 3d27d9f2ac..9db8b8ed6f 100644 --- a/Task/Next-highest-int-from-digits/Phix/next-highest-int-from-digits-1.phix +++ b/Task/Next-highest-int-from-digits/Phix/next-highest-int-from-digits-1.phix @@ -1,21 +1,19 @@ -(phixonline)--> - function nigh(string n) - sequence p = repeat("",factorial(length(n))) - for i=1 to length(p) do - p[i] = permute(i,n) - end for - p = sort(p) - integer k = rfind(n,p) - return iff(k=length(p)?"0",p[k+1]) - end function +function nigh(string n) + sequence p = repeat("",factorial(length(n))) + for i=1 to length(p) do + p[i] = permute(i,n) + end for + p = sort(p) + integer k = rfind(n,p) + return iff(k=length(p)?"0",p[k+1]) +end function - constant tests = {"0","9","12","21","12453", - "738440","45072010","95322020"} - -- (crashes on) "9589776899767587796600"} - atom t0 = time() - for i=1 to length(tests) do - string t = tests[i] - printf(1,"%22s => %s\n",{t,nigh(t)}) - end for - ?elapsed(time()-t0) - - function nigh(string n) - integer hi = n[$] - for i=length(n)-1 to 1 by -1 do - integer ni = n[i] - if ni<hi then - string sr = sort(n[i..$]) - integer k = rfind(ni,sr)+1 - n[i] = sr[k] - sr[k..k] = "" - n[i+1..$] = sr - return n - end if - hi = max(hi,ni) - end for - return "0" - end function +function nigh(string n) + integer hi = n[$] + for i=length(n)-1 to 1 by -1 do + integer ni = n[i] + if niconstant tests = {"0","9","12","21","12453", - "738440","45072010","95322020", - "9589776899767587796600"} - atom t0 = time() - for i=1 to length(tests) do - string t = tests[i] - printf(1,"%22s => %s\n",{t,nigh(t)}) - end for - ?elapsed(time()-t0) - - -- - -- demo\rosetta\Ormiston_triplets.exw - -- ================================== - -- - -- Uses a segmented sieve, which is about half the speed of get_primes_le(), but uses far less memory. - -- If permited, get_primes_le(1e10) would generate a result of 455,052,511 primes, more than 32 bit - -- can cope with, and use over 6GB of ram, and take about 11mins 44s, that is on this box at least, - -- whereas this processes them on-the-fly, and only uses about 6MB of memory (ie 0.1% of 6GB). - -- - with javascript_semantics +-- +-- demo\rosetta\Ormiston_triplets.exw +-- ================================== +-- +-- Uses a segmented sieve, which is about half the speed of get_primes_le(), but uses far less memory. +-- If permited, get_primes_le(1e10) would generate a result of 455,052,511 primes, more than 32 bit +-- can cope with, and use over 6GB of ram, and take about 11mins 44s, that is on this box at least, +-- whereas this processes them on-the-fly, and only uses about 6MB of memory (ie 0.1% of 6GB). +-- +with javascript_semantics - atom t0 = time() +atom t0 = time() - procedure ormiston_triplets(atom limit) - // Generate primes using the segmented sieve of Eratosthenes. - // credit: https://gist.github.com/kimwalisch/3dc39786fab8d5b34fee - integer segment_size = floor(sqrt(limit)), - count = 0, i = 3, s = 3, triplen = 1 - atom p1 = 2, p2, n = 3, nc = min(1e9,limit), low = 0, t1 = time()+1 +procedure ormiston_triplets(atom limit) + // Generate primes using the segmented sieve of Eratosthenes. + // credit: https://gist.github.com/kimwalisch/3dc39786fab8d5b34fee + integer segment_size = floor(sqrt(limit)), + count = 0, i = 3, s = 3, triplen = 1 + atom p1 = 2, p2, n = 3, nc = min(1e9,limit), low = 0, t1 = time()+1 - sequence isprime = repeat(true,segment_size+1), - primes = {}, - multiples = {}, - orm25 = repeat(0,25) + sequence isprime = repeat(true,segment_size+1), + primes = {}, + multiples = {}, + orm25 = repeat(0,25) - while low<=limit do - sequence sieve = repeat(true,segment_size+1) - if time()>t1 then - progress("Processing %,d/%,d (%3.2f%%)\r",{low,limit,(low/limit)*100}) - t1 = time()+1 - end if + while low<=limit do + sequence sieve = repeat(true,segment_size+1) + if time()>t1 then + progress("Processing %,d/%,d (%3.2f%%)\r",{low,limit,(low/limit)*100}) + t1 = time()+1 + end if - // current segment = [low, high] - atom high = min(low+segment_size,limit) - // generate sieving primes using simple sieve of Eratosthenes - while i*i<=min(high,segment_size) do - if isprime[i+1] then - for j=i*i to segment_size by i do - isprime[j+1] = false - end for - end if - i += 2 - end while + // current segment = [low, high] + atom high = min(low+segment_size,limit) + // generate sieving primes using simple sieve of Eratosthenes + while i*i<=min(high,segment_size) do + if isprime[i+1] then + for j=i*i to segment_size by i do + isprime[j+1] = false + end for + end if + i += 2 + end while - // initialize sieving primes for segmented sieve - while s*s<=high do - if isprime[s+1] then - primes &= s - multiples &= s*s-low - end if - s += 2 - end while + // initialize sieving primes for segmented sieve + while s*s<=high do + if isprime[s+1] then + primes &= s + multiples &= s*s-low + end if + s += 2 + end while - // sieve the current segment - for mi,j in multiples do - integer k = primes[mi]*2 - while j<segment_size do - sieve[j+1] = false - j += k - end while - multiples[mi] = j - segment_size - end for + // sieve the current segment + for mi,j in multiples do + integer k = primes[mi]*2 + while jwhile n<=high do - if sieve[n-low+1] then // n is a prime - if triplen=1 then - if remainder(n-p1,18)=0 - and sort(sprint(p1))=sort(sprint(n)) then - p2 = n - triplen = 2 - else - p1 = n - end if - elsif triplen=2 - and remainder(n-p2,18)=0 - and sort(sprint(p2))=sort(sprint(n)) then - -- triplet found! - if p1>=nc then - string e = elapsed_short(time()-t0) - progress("%,d Ormiston triplets before %,d (%s)\n", {count, nc, e}) - nc *= 10 - end if - count += 1 - if count<=25 then - orm25[count] = sprintf("%d",{p1}) - if count=25 then - printf(1,"Smallest members of first 25 Ormiston triplets:\n%s\n",join_by(orm25,1,5)) - end if - end if - -- overlapping (and leave triplen set to 2): - p1 = p2 - p2 = n - -- (for disjoint-only just set triplen to 0) - else - p1 = n - triplen = 1 - end if - end if - n += 2 - end while - low += segment_size - end while - string e = elapsed_short(time()-t0) - progress("%,d Ormiston triplets before %,d (%s)\n", {count, nc, e}) - end procedure - ormiston_triplets(iff(platform()=JS?1e8:1e9)) - - requires("1.0.3") - requires(WINDOWS) - requires(64,true) - include builtins/primesieve.e - atom t0 = time(), t1 = time()+1, - p = primesieve_next_prime(), - p1 = p, p2, count = 0, nc = 1e9 - sequence orm25 = repeat(0,25) +requires("1.0.3") +requires(WINDOWS) +requires(64,true) +include builtins/primesieve.e +atom t0 = time(), t1 = time()+1, + p = primesieve_next_prime(), + p1 = p, p2, count = 0, nc = 1e9 +sequence orm25 = repeat(0,25) - procedure showt() - if count=25 then - progress("Smallest members of first 25 Ormiston triplets:\n") - progress("%s\n",join_by(orm25,1,5)) - else - string e = elapsed_short(time()-t0) - progress("%,6d Ormiston triplets before %,d (%s)\n",{count,nc,e}) - nc *= 10 - end if - end procedure +procedure showt() + if count=25 then + progress("Smallest members of first 25 Ormiston triplets:\n") + progress("%s\n",join_by(orm25,1,5)) + else + string e = elapsed_short(time()-t0) + progress("%,6d Ormiston triplets before %,d (%s)\n",{count,nc,e}) + nc *= 10 + end if +end procedure - while p<1e10 do - p2 = p1 - p1 = p - p = primesieve_next_prime() - if remainder(p-p1,18)=0 - and remainder(p1-p2,18)=0 then - string s = sort(sprint(p)) - if sort(sprint(p1))=s - and sort(sprint(p2))=s then - if p>=nc then showt() end if - count += 1 - if count<=25 then - orm25[count] = sprintf("%d",{p2}) - if count=25 then showt() end if - end if - end if - elsif time()>t1 then - progress("%,d\r",{p}) - t1 = time()+1 - end if - end while - showt() - [ ) + + [ char a char z range ] constant is lowers ( --> $ ) + + [ char A char Z range ] constant is uppers ( --> $ ) + + [ char 0 char 9 range ] constant is digits ( --> $ ) + + [ $ \!"#$%&'()*+,-./:;<=>?@[]^_{|}~\ ] is others ( --> $ ) + + [ [] ' [ lowers uppers digits others ] + tuck witheach + [ do dup size random peek join ] + [] rot witheach [ do join ] + rot 4 - times + [ dup dup size random peek + rot join swap ] + drop shuffle ] is password ( n --> $ ) + + [ swap times + [ dup password echo$ cr ] drop ] is passwords ( n n --> ) + + [ say "'passwords' generates a specified" cr + say "number of passwords of a specified" cr + say "length. For example," cr + cr + say " 5 10 passwords" cr + cr + say "will generate five ten-character" cr + say "passwords." cr ] is help + + say "Type 'help' for help with passwords." diff --git a/Task/Pathological-floating-point-problems/EasyLang/pathological-floating-point-problems.easy b/Task/Pathological-floating-point-problems/EasyLang/pathological-floating-point-problems.easy new file mode 100644 index 0000000000..cc6ad6edbf --- /dev/null +++ b/Task/Pathological-floating-point-problems/EasyLang/pathological-floating-point-problems.easy @@ -0,0 +1,51 @@ +numfmt 10 0 +proc task1 . . + print "--- Task 1 pathologic ---" + vpp = 2 + vp = -4 + for i = 3 to 100 + v = 111 - 1130 / vp + 3000 / (vp * vpp) + if i <= 8 or i = 20 or i = 30 or i = 50 or i = 100 + print i & ": " & v + . + vpp = vp + vp = v + . +. +task1 +print "" +# +proc task2 . . + print "--- Task 2 pathologic ---" + e = 2.718281828459045 + bal = e - 1 + for i = 1 to 25 + bal = bal * i - 1 + . + print "Balance after 25 years: $" & bal +. +task2 +print "" +# +proc mul f . bal bal$[] . + for i = len bal$[] downto 1 + dig = number bal$[i] + h = dig * f + c + bal$[i] = h mod 10 + c = h div 10 + . + bal += c +. +proc task2ok . . + print "--- Task 2 OK ---" + e$ = "2.7182818284590452353602874713526624977572470" + bal = number substr e$ 1 1 + bal$[] = strchars substr e$ 3 999 + bal -= 1 + for i = 1 to 25 + mul i bal bal$[] + bal -= 1 + . + print "Balance after 25 years: $" & bal & "." & substr strjoin bal$[] 1 16 +. +task2ok diff --git a/Task/Peaceful-chess-queen-armies/Jq/peaceful-chess-queen-armies.jq b/Task/Peaceful-chess-queen-armies/Jq/peaceful-chess-queen-armies.jq new file mode 100644 index 0000000000..0cde59231c --- /dev/null +++ b/Task/Peaceful-chess-queen-armies/Jq/peaceful-chess-queen-armies.jq @@ -0,0 +1,81 @@ +# Is the queen at position . attacking the position $pos ? +def isAttacking($pos): + .x == $pos.x or + .y == $pos.y or + (((.x - $pos.x)|length) == ((.y - $pos.y)|length)); # i.e. abs + +# Place $q black and $q white queens on an $n*$n board, +# where .blackQueens holds the positions of existing black Queens, +# and similarly for .whiteQueens. +# input: {blackQueens, whiteQueens} +# output: updated input on success, otherwise null. +def place($queens; $n): + def place($q): + if $q == 0 then .ok = true + else .placingBlack = true + | first( + foreach range(0; $n) as $i (.; + foreach range(0; $n) as $j (.; + {x:$i, y:$j} as $pos + | .placingBlack as $placingBlack + | if any( .blackQueens[], .whiteQueens[]; + ((.x == $pos.x) and (.y == $pos.y))) + then . # failure + elif .placingBlack + then if any( .whiteQueens[]; isAttacking($pos) ) + then . + else .blackQueens += [$pos] + | .placingBlack = false + end + elif any( .blackQueens[]; isAttacking($pos) ) + then . + else .whiteQueens += [$pos] + | place($q-1) as $place + | if $place then $place # success + else .blackQueens |= .[:-1] + | .whiteQueens |= .[:-1] + | .placingBlack = true + end + end + | if $i == $n-1 and $j == $n-1 then .ok = false end ); + select(.ok) ) + ) // null + end; + {blackQueens: [], whiteQueens: [] } | place($queens); + +# Input {blackQueens, whiteQueens} +def printBoard($n): + [range(0; $n) | 0] as $row + | .board = [range(0; $n) | $row] + | reduce .blackQueens[] as $queen (.; .board[$queen.x][$queen.y] = "B ") + | reduce .whiteQueens[] as $queen (.; .board[$queen.x][$queen.y] = "W ") + | foreach range(0; $n) as $i (.; + reduce range(0; $n) as $j (.row=""; + .board[$i][$j] as $b + | .row += + (if $b != 0 then $b + elif $i%2 == $j%2 + then "• " + else "◦ " + end) ) ) + | .row; + +# Use an object {squares, queens} to record the task: +# $squares is the number of squares on each side of the board, +# and $queens is the number of queens of each color. +def Task($squares; $queens): {$squares, $queens}; + +def tasks: [ + Task(2; 1), Task(3; 1), Task(3; 2), Task(4; 1), Task(4; 2), Task(4; 3), + Task(5; 1), Task(5; 2), Task(5; 3), Task(5; 4), Task(5; 5), + Task(6; 1), Task(6; 2), Task(6; 3), Task(6; 4), Task(6; 5), Task(6; 6), + Task(7; 1), Task(7; 2), Task(7; 3), Task(7; 4), Task(7; 5), Task(7; 6), Task(7; 7) +]; + +tasks[] as $t +| "\($t.queens) black and \($t.queens) white queens on a \($t.squares) x \($t.squares) board:", + ((place($t.queens; $t.squares) + | select(.) + | printBoard($t.squares)) + // "No solution exists."), + "" diff --git a/Task/Pells-equation/Langur/pells-equation.langur b/Task/Pells-equation/Langur/pells-equation.langur index c2e101a25d..ec0697af10 100644 --- a/Task/Pells-equation/Langur/pells-equation.langur +++ b/Task/Pells-equation/Langur/pells-equation.langur @@ -1,31 +1,31 @@ -val .fun = fn(.a, .b, .c) [.b, .b * .c + .a] +val fun = fn a, b, c: [b, b * c + a] -val .solvePell = fn(.n) { - val .x = trunc .n ^/ 2 - var .y, .z, .r = .x, 1, .x * 2 - var .e1, .e2, .f1, .f2 = 1, 0, 0, 1 +val solvePell = fn(n) { + val x = trunc(n ^/ 2) + var y, z, r = x, 1, x * 2 + var e1, e2, f1, f2 = 1, 0, 0, 1 for { - .y = .r * .z - .y - .z = (.n - .y * .y) \ .z - .r = (.x + .y) \ .z - .e1, .e2 = .fun(.e1, .e2, .r) - .f1, .f2 = .fun(.f1, .f2, .r) - val .b, .a = .fun(.e2, .f2, .x) - if .a^2 - .n * .b^2 == 1: return [.a, .b] + y = r * z - y + z = (n - y * y) \ z + r = (x + y) \ z + e1, e2 = fun(e1, e2, r) + f1, f2 = fun(f1, f2, r) + val b, a = fun(e2, f2, x) + if a^2 - n * b^2 == 1: return [a, b] } } -val .C = fn(.x) { +val C = fn(x) { # format number string with commas - var .neg, .s = "", string .x - if .s[1] == '-' { - .neg, .s = "-", rest .s + var neg, s = "", x -> string + if s[1] == '-' { + neg, s = "-", s -> rest } - .neg ~ join ",", split -3, .s + neg ~ join(",", split(-3, s)) } -for .n in [61, 109, 181, 277, 8941] { - val .x, .y = .solvePell(.n) - writeln $"x² - \.n;y² = 1 for:\n\tx = \.x:.C;\n\ty = \.y:.C;\n" +for n in [61, 109, 181, 277, 8941] { + val x, y = solvePell(n) + writeln "x² - {{n}}y² = 1 for:\n\tx = {{x:fn C}}\n\ty = {{y:fn C}}\n" } diff --git a/Task/Penneys-game/Ada/penneys-game.ada b/Task/Penneys-game/Ada/penneys-game.ada new file mode 100644 index 0000000000..ba8ce593b0 --- /dev/null +++ b/Task/Penneys-game/Ada/penneys-game.ada @@ -0,0 +1,102 @@ +-- Penney's game +-- J. Carter 2024 Jun + +with Ada.Characters.Handling; +with Ada.Numerics.Discrete_Random; +with Ada.Text_IO; + +procedure Penney_Game is + package Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Boolean); + + type Choice_List is array (1 .. 3) of Boolean; + + procedure Get (List : out Choice_List); + -- Gets the player's choice + + procedure Put (Bool : in Boolean); + -- Puts False => 'T', True => 'H' + + procedure Put (List : in Choice_List); + -- Outputs a choice + + type Optimum_Map is array (Boolean, Boolean, Boolean) of Choice_List; + + Optimum : constant Optimum_Map := + (False => (False => (False => (True, False, False), True => (True, False, False) ), + True => (False => (False, False, True), True => (False, False, True) ) ), + True => (False => (False => (True, True, False), True => (True, True, False) ), + True => (False => (False, True, True), True => (False, True, True) ) ) ); + + procedure Get (List : out Choice_List) is + -- Empty + begin -- Get + All_Tries : loop + Ada.Text_IO.Put (Item => "Enter your sequence as three letters, H or T: "); + + One_Try : declare + Line : constant String := Ada.Characters.Handling.To_Upper (Ada.Text_IO.Get_Line); + begin -- One_Try + if Line'Length = 3 and (for all C of Line => C in 'H' |'T') then + Convert : for I in List'Range loop + List (I) := Line (I) = 'H'; + end loop Convert; + + return; + end if; + end One_Try; + end loop All_Tries; + end Get; + + procedure Put (Bool : in Boolean) is + -- Empty + begin -- Put + Ada.Text_IO.Put (Item => (if Bool then 'H' else 'T') ); + end Put; + + procedure Put (List : in Choice_List) is + -- Empty + begin -- Put + Put_All : for B of List loop + Put (Bool => B); + end loop Put_All; + end Put; + + Gen : Random.Generator; + Play_First : Boolean; + Comp_Choice : Choice_List; + Play_Choice : Choice_List; + Actual : Choice_List; +begin -- Penney_Game + Random.Reset (Gen => Gen); + Play_First := Random.Random (Gen); + + if Play_First then + Get (List => Play_Choice); + Comp_Choice := Optimum (Play_Choice (1), Play_Choice (2), Play_Choice (3) ); + else + Comp_Choice := (others => Random.Random (Gen) ); + end if; + + Ada.Text_IO.Put (Item => "Computer's sequence is "); + Put (List => Comp_Choice); + Ada.Text_IO.New_Line; + + if not Play_First then + Get (List => Play_Choice); + end if; + + Actual := (others => Random.Random (Gen) ); + Put (List => Actual); + + Check : loop + if Actual = Comp_Choice or Actual = Play_Choice then + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line (Item => (if Actual = Comp_Choice then "Computer" else "Player") & " wins"); + + return; + end if; + + Actual := Actual (2 .. 3) & Random.Random (Gen); + Put (Bool => Actual (3) ); + end loop Check; +end Penney_Game; diff --git a/Task/Pentomino-tiling/Jq/pentomino-tiling.jq b/Task/Pentomino-tiling/Jq/pentomino-tiling.jq new file mode 100644 index 0000000000..a9d861e9cd --- /dev/null +++ b/Task/Pentomino-tiling/Jq/pentomino-tiling.jq @@ -0,0 +1,178 @@ +# Output: a PRN in range(0; .) +def prn: + if . == 1 then 0 + else . as $n + | (($n-1)|tostring|length) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +### Generic functions + +def array($n): . as $in | [range(0;$n)|$in]; + +def array_swap($i; $j): + if $i < $j then array_swap($j;$i) + elif $i == $j then . + else .[$i] as $t | .[:$j] + [$t] + .[$j:$i] + .[$i + 1:] + end ; + +### Pentominos + +def F: [ + [1, -1, 1, 0, 1, 1, 2, 1], [0, 1, 1, -1, 1, 0, 2, 0], + [1, 0, 1, 1, 1, 2, 2, 1], [1, 0, 1, 1, 2, -1, 2, 0], + [1, -2, 1, -1, 1, 0, 2, -1], [0, 1, 1, 1, 1, 2, 2, 1], + [1, -1, 1, 0, 1, 1, 2, -1], [1, -1, 1, 0, 2, 0, 2, 1] +]; + +def I: [ + [0, 1, 0, 2, 0, 3, 0, 4], [1, 0, 2, 0, 3, 0, 4, 0] +]; + +def L: [ + [1, 0, 1, 1, 1, 2, 1, 3], [1, 0, 2, 0, 3, -1, 3, 0], + [0, 1, 0, 2, 0, 3, 1, 3], [0, 1, 1, 0, 2, 0, 3, 0], + [0, 1, 1, 1, 2, 1, 3, 1], [0, 1, 0, 2, 0, 3, 1, 0], + [1, 0, 2, 0, 3, 0, 3, 1], [1, -3, 1, -2, 1, -1, 1, 0] +]; + +def N: [ + [0, 1, 1, -2, 1, -1, 1, 0], [1, 0, 1, 1, 2, 1, 3, 1], + [0, 1, 0, 2, 1, -1, 1, 0], [1, 0, 2, 0, 2, 1, 3, 1], + [0, 1, 1, 1, 1, 2, 1, 3], [1, 0, 2, -1, 2, 0, 3, -1], + [0, 1, 0, 2, 1, 2, 1, 3], [1, -1, 1, 0, 2, -1, 3, -1] +]; + +def P: [ + [0, 1, 1, 0, 1, 1, 2, 1], [0, 1, 0, 2, 1, 0, 1, 1], + [1, 0, 1, 1, 2, 0, 2, 1], [0, 1, 1, -1, 1, 0, 1, 1], + [0, 1, 1, 0, 1, 1, 1, 2], [1, -1, 1, 0, 2, -1, 2, 0], + [0, 1, 0, 2, 1, 1, 1, 2], [0, 1, 1, 0, 1, 1, 2, 0] +]; + +def T: [ + [0, 1, 0, 2, 1, 1, 2, 1], [1, -2, 1, -1, 1, 0, 2, 0], + [1, 0, 2, -1, 2, 0, 2, 1], [1, 0, 1, 1, 1, 2, 2, 0] +]; + +def U: [ + [0, 1, 0, 2, 1, 0, 1, 2], [0, 1, 1, 1, 2, 0, 2, 1], + [0, 2, 1, 0, 1, 1, 1, 2], [0, 1, 1, 0, 2, 0, 2, 1] +]; + +def V: [ + [1, 0, 2, 0, 2, 1, 2, 2], [0, 1, 0, 2, 1, 0, 2, 0], + [1, 0, 2, -2, 2, -1, 2, 0], [0, 1, 0, 2, 1, 2, 2, 2] +]; + +def W: [ + [1, 0, 1, 1, 2, 1, 2, 2], [1, -1, 1, 0, 2, -2, 2, -1], + [0, 1, 1, 1, 1, 2, 2, 2], [0, 1, 1, -1, 1, 0, 2, -1] +]; + +def X: [[1, -1, 1, 0, 1, 1, 2, 0]]; + +def Y: [ + [1, -2, 1, -1, 1, 0, 1, 1], [1, -1, 1, 0, 2, 0, 3, 0], + [0, 1, 0, 2, 0, 3, 1, 1], [1, 0, 2, 0, 2, 1, 3, 0], + [0, 1, 0, 2, 0, 3, 1, 2], [1, 0, 1, 1, 2, 0, 3, 0], + [1, -1, 1, 0, 1, 1, 1, 2], [1, 0, 2, -1, 2, 0, 3, 0] +]; + +def Z: [ + [0, 1, 1, 0, 2, -1, 2, 0], [1, 0, 1, 1, 1, 2, 2, 2], + [0, 1, 1, 1, 2, 1, 2, 2], [1, -2, 1, -1, 1, 0, 2, -2] +]; + +def shapes: [F, I, L, N, P, T, U, V, W, X, Y, Z]; + +def symbols: "FILNPTUVWXYZ-" | split(""); + +def nRows: 8; +def nCols: 8; +def blank: 12; + +def printResult: + .symbols as $symbols + | .grid[] as $row + | reduce $row[] as $i (""; . + $symbols[$i]); + +# Input: {grid} +def placeOrientation($o; $r; $c; $shapeIndex): + .grid[$r][$c] = $shapeIndex + | reduce range(0; $o|length; 2) as $io (.; + .grid[$r + $o[$io]][$c + $o[$io + 1]] = $shapeIndex); + +# Input and output: {grid} +# If the placement is feasible, call placeOrientation/3 +def tryPlaceOrientation($o; $r; $c; $shapeIndex): + .grid as $grid + | if any( range(0; $o|length; 2); + . as $io + | ($c + $o[$io + 1]) as $x + | ($r + $o[$io] ) as $y + | $x < 0 or $x >= nCols or $y < 0 or $y >= nRows or $grid[$y][$x] != -1 ) + then empty + else placeOrientation($o; $r; $c; $shapeIndex) + end + ; + +# Input: {grid, placed, shapes} +def solve($pos; $numPlaced): + if $numPlaced == (.shapes|length) + then . + else (($pos / nCols)|floor) as $row + | ($pos % nCols ) as $col + | if .grid[$row][$col] != -1 + then solve($pos + 1; $numPlaced) + else .emit = false + | foreach range(0; .shapes|length) as $i (.; + if .placed[$i] then . + else foreach .shapes[$i][] as $orientation (.; + (tryPlaceOrientation($orientation; $row; $col; $i) + | .placed[$i] = true + | solve($pos + 1; $numPlaced + 1) + | .emit = true) + // .) + end ) + | select(.emit) + end + end; + +# input: {shapes, symbols} +def shuffleShapes: + (.shapes|length) as $n + | reduce range(0; $n) as $i (.; + ($n | prn) as $r + | .shapes |= array_swap($r; $i) + | .symbols |= array_swap($r; $i) ) +; + +def task: + def grid: + 0 | array(nCols) | array(nRows); + def placed: + false | array(symbols|length - 1); + + { shapes: shapes, + symbols: symbols, + grid: grid, + placed: placed} + | shuffleShapes + | reduce range(0; nRows) as $r (.; + reduce range(0; .grid[$r]|length) as $c (.; + .grid[$r][$c] = -1)) + | reduce range(0; 4) as $i (.; + .done = false + | until(.done; + .randRow = (nRows | prn) + | .randCol = (nCols | prn) + | .done = (.grid[.randRow][.randCol] != blank) ) + | .grid[.randRow][.randCol] = blank + ) + | first(solve(0; 0)) + | printResult + // "No solution" +; +task diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada index 41b6d6249b..d280e4185e 100644 --- a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada @@ -1,4 +1,4 @@ function "-" (Left, Right : Pixel) return Count is begin - return (Left.R - Right.R) + (Left.G - Left.G) + (Left.B - Right.B); + return (Left.R - Right.R) + (Left.G - Right.G) + (Left.B - Right.B); end "-"; diff --git a/Task/Percolation-Bond-percolation/11l/percolation-bond-percolation.11l b/Task/Percolation-Bond-percolation/11l/percolation-bond-percolation.11l index 33890bac0c..0bbedbbc8c 100644 --- a/Task/Percolation-Bond-percolation/11l/percolation-bond-percolation.11l +++ b/Task/Percolation-Bond-percolation/11l/percolation-bond-percolation.11l @@ -3,12 +3,7 @@ F nonrandom() :seed = 1664525 * :seed + 1013904223 R Int(:seed >> 16) / Float(FF'FF) -T Grid - [[Int]] cell, hwall, vwall - F (cell, hwall, vwall) - .cell = cell - .hwall = hwall - .vwall = vwall +T Grid = ([[Int]] cell, [[Int]] hwall, [[Int]] vwall) V (M, nn, t) = (10, 10, 100) @@ -37,7 +32,7 @@ F pgrid(grid, percolated) V where = percolated[0] print(‘!) ’(‘ ’ * where)‘ ’f[1]) -F flood_fill(m, n, &cell, hwall, vwall) -> N +F flood_fill(m, n, &cell, hwall, vwall) -> Void cell[n][m] = 1 I n < :nn - 1 & !hwall[n + 1][m] & !cell[n + 1][m] flood_fill(m, n + 1, &cell, hwall, vwall) diff --git a/Task/Percolation-Mean-cluster-density/11l/percolation-mean-cluster-density.11l b/Task/Percolation-Mean-cluster-density/11l/percolation-mean-cluster-density.11l index d36d38f1a0..b8d418dcc8 100644 --- a/Task/Percolation-Mean-cluster-density/11l/percolation-mean-cluster-density.11l +++ b/Task/Percolation-Mean-cluster-density/11l/percolation-mean-cluster-density.11l @@ -13,7 +13,7 @@ V NRange = [4, 64, 256, 1024, 4096] F newGrid(n, p) R (0 .< n).map(i -> (0 .< @n).map(i -> Int(nonrandom() < @@p))) -F walkMaze(&grid, m, n, idx) -> N +F walkMaze(&grid, m, n, idx) -> Void grid[n][m] = idx I n < grid.len - 1 & grid[n + 1][m] == NotClustered walkMaze(&grid, m, n + 1, idx) diff --git a/Task/Percolation-Site-percolation/11l/percolation-site-percolation.11l b/Task/Percolation-Site-percolation/11l/percolation-site-percolation.11l index 3d409734ed..abebe89ea5 100644 --- a/Task/Percolation-Site-percolation/11l/percolation-site-percolation.11l +++ b/Task/Percolation-Site-percolation/11l/percolation-site-percolation.11l @@ -10,7 +10,6 @@ V NOT_VISITED = 1 T PercolatedException (Int, Int) t - F (t) .t = t @@ -24,7 +23,7 @@ F pgrid(cell, percolated) V where = percolated[0] print(‘!) ’(‘ ’ * where)‘’:cell2char[cell[:nn - 1][where]]) -F walk_maze(m, n, &cell, indx) X(PercolatedException) -> N +F walk_maze(m, n, &cell, indx) X(PercolatedException) -> Void cell[n][m] = indx I n < :nn - 1 & cell[n + 1][m] == :NOT_VISITED walk_maze(m, n + 1, &cell, indx) diff --git a/Task/Percolation-Site-percolation/FreeBASIC/percolation-site-percolation.basic b/Task/Percolation-Site-percolation/FreeBASIC/percolation-site-percolation.basic index 88160101f9..1dbf5565b1 100644 --- a/Task/Percolation-Site-percolation/FreeBASIC/percolation-site-percolation.basic +++ b/Task/Percolation-Site-percolation/FreeBASIC/percolation-site-percolation.basic @@ -2,28 +2,28 @@ #define EMPTY " " #define WET "v" -Dim Shared As String grid() +Dim Shared As String grid Dim Shared As Integer last, lastrow, m, n -Sub make_grid(x As Integer, y As Integer, p As Double) - m = x - n = y - Redim Preserve grid(x*(y+1)+1) - last = Len(grid) - Dim As Integer lastrow = last-n +Sub makeGrid(x As Integer, y As Integer, p As Double) Dim As Integer i, j + m = x + n = y + grid = String(x*(y+1)+1, Chr(10)) + last = Len(grid) + lastrow = last - n For i = 0 To x-1 For j = 1 To y - grid(1+i*(y+1)+j) = Iif(Rnd < p, EMPTY, SOLID) + Mid(grid, 1+i*(y+1)+j, 1) = Iif(Rnd < p, EMPTY, SOLID) Next j Next i End Sub -Function ff(i As Integer) As Boolean - If i <= 0 Or i >= last Or grid(i) <> EMPTY Then Return 0 - grid(i) = WET - Return i >= lastrow Or (ff(i+m+1) Or ff(i+1) Or ff(i-1) Or ff(i-m-1)) +Function ff(i As Integer) As Integer + If i <= 0 Or i >= last Or Mid(grid, i, 1) <> EMPTY Then Return 0 + Mid(grid, i, 1) = WET + Return (i >= lastrow) Or ff(i+m+1) Or ff(i+1) Or ff(i-1) Or ff(i-m-1) End Function Function percolate() As Integer @@ -33,24 +33,23 @@ Function percolate() As Integer Return 0 End Function +Randomize Timer +makeGrid(15, 15, 0.55) +percolate() +Print "15x15 grid:"; +Print grid + +Print "running 10,000 tests for each case:" Dim As Double p -Dim As Integer ip, i, cont - -make_grid(15, 15, 0.55) -Print "15x15 grid:" -For i = 1 To Ubound(grid) - Print grid(i); - If i Mod 15 = 0 Then Print -Next i - -Print !"\nrunning 10,000 tests for each case:" -For ip As Ubyte = 0 To 10 +Dim As Integer ip, i, cnt +For ip = 0 To 10 p = ip / 10 - cont = 0 + cnt = 0 For i = 1 To 10000 - make_grid(15, 15, p) - cont += percolate() + makeGrid(15, 15, p) + cnt += (percolate() = 1) Next i - Print Using "p=#.#: #.####"; p; cont/10000 + Print Using "p=#.#: #.####"; p; Abs(cnt / 10000) Next ip + Sleep diff --git a/Task/Perfect-numbers/ALGOL-60/perfect-numbers.alg b/Task/Perfect-numbers/ALGOL-60/perfect-numbers.alg index 5a8f6073f3..57c14c3c9f 100644 --- a/Task/Perfect-numbers/ALGOL-60/perfect-numbers.alg +++ b/Task/Perfect-numbers/ALGOL-60/perfect-numbers.alg @@ -1,10 +1,10 @@ begin -comment - return p mod q; -integer procedure mod(p, q); - value p, q; integer p, q; +comment - return n mod m; +integer procedure mod(n, m); + value n, m; integer n, m; begin - mod := p - q * entier(p / q); + mod := n - m * entier(n / m); end; comment - return true if n is perfect, otherwise false; @@ -38,6 +38,6 @@ for i := 2 step 1 until 10000 do end; outstring(1,"\n"); outinteger(1,found); -outstring(1,"perfect numbers were found"); +outstring(1," were found"); end diff --git a/Task/Perfect-numbers/EasyLang/perfect-numbers.easy b/Task/Perfect-numbers/EasyLang/perfect-numbers.easy index b558cc5ca8..068527c206 100644 --- a/Task/Perfect-numbers/EasyLang/perfect-numbers.easy +++ b/Task/Perfect-numbers/EasyLang/perfect-numbers.easy @@ -1,13 +1,18 @@ -func perf n . - for i = 1 to n - 1 +fastfunc perf n . + i = 1 + while i < n if n mod i = 0 sum += i . + i += 1 . - return if sum = n + if sum = n + return 1 + . + return 0 . for i = 2 to 10000 if perf i = 1 - print i + write i & " " . . diff --git a/Task/Perfect-numbers/S-BASIC/perfect-numbers.basic b/Task/Perfect-numbers/S-BASIC/perfect-numbers.basic index 43d5ffc386..844e69ce17 100644 --- a/Task/Perfect-numbers/S-BASIC/perfect-numbers.basic +++ b/Task/Perfect-numbers/S-BASIC/perfect-numbers.basic @@ -1,8 +1,8 @@ $lines -rem - return p mod q -function mod(p, q = integer) = integer -end = p - q * (p/q) +rem - return n mod m +function mod(n, m = integer) = integer +end = n - m * (n/m) rem - return true if n is perfect, otherwise false function isperfect(n = integer) = integer diff --git a/Task/Peripheral-drift-illusion/EasyLang/peripheral-drift-illusion.easy b/Task/Peripheral-drift-illusion/EasyLang/peripheral-drift-illusion.easy new file mode 100644 index 0000000000..9b329f16a0 --- /dev/null +++ b/Task/Peripheral-drift-illusion/EasyLang/peripheral-drift-illusion.easy @@ -0,0 +1,27 @@ +n = 15 +offs = 0.7 +r = (100 / (3 * n + 1)) +step = 360 * 2 / (n - 1) +# +background 470 +clear +for row = 0 to n - 1 + for col = 0 to n - 1 + x = (3 * col + 2) * r + y = (3 * row + 2) * r + # + h = col * step + row * step + move (x + offs * cos h) (y + offs * sin h) + color 999 + circle r + # + h += 180 + move (x + offs * cos h) (y + offs * sin h) + color 000 + circle r + # + move x y + color 128 + circle r + . +. diff --git a/Task/Perlin-noise/ALGOL-68/perlin-noise.alg b/Task/Perlin-noise/ALGOL-68/perlin-noise.alg new file mode 100644 index 0000000000..8d1e72dc1c --- /dev/null +++ b/Task/Perlin-noise/ALGOL-68/perlin-noise.alg @@ -0,0 +1,77 @@ +BEGIN # perlin noise - translated from the 11l sample # + [ 0 : 511 ]INT p; + p[ 256 : ] := (151,160,137,91,90,15 + ,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23 + ,190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33 + ,88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166 + ,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244 + ,102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196 + ,135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123 + ,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42 + ,223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9 + ,129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228 + ,251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107 + ,49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254 + ,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 + ); + p[ 0 : 255 ] := p[ 256 : ]; + + OP AND = ( INT a, b )INT: + IF a >= 0 + THEN ABS ( BIN a AND BIN b ) + ELSE ABS ( NOT BIN ( - ( a + 1 ) ) AND BIN b ) + FI # AND # ; + + PROC fade = ( REAL t )REAL: ( t * t * t ) * ( t * ( t * 6 - 15 ) + 10 ); + PROC linerp = ( REAL t, a, b )REAL: a + ( t * ( b - a ) ); + PROC grad = ( INT hash, REAL x, y, z )REAL: + BEGIN + INT h = hash AND 15; + REAL u = IF h < 8 THEN x ELSE y FI; + REAL v = IF h < 4 THEN y ELIF h = 12 OR h = 14 THEN x ELSE z FI; + IF ( h AND 1 ) = 0 THEN u ELSE -u FI + IF ( h AND 2 ) = 0 THEN v ELSE -v FI + END # grad # ; + PROC perlin noise = ( REAL x in, y in, z in )REAL: + BEGIN + REAL x := x in, y := y in, z := z in; + INT xx = ENTIER x AND 255; + INT yy = ENTIER y AND 255; + INT zz = ENTIER z AND 255; + x -:= ENTIER x; + y -:= ENTIER y; + z -:= ENTIER z; + REAL u = fade( x ); + REAL v = fade( y ); + REAL w = fade( z ); + INT a = p[ xx ] + yy; + INT aa = p[ a ] + zz; + INT ab = p[ a + 1 ] + zz; + INT b = p[ xx + 1 ] + yy; + INT ba = p[ b ] + zz; + INT bb = p[ b + 1 ] + zz; + linerp( w + , linerp( v + , linerp( u + , grad( p[ aa ], x, y, z ) + , grad( p[ ba ], x - 1, y, z ) + ) + , linerp( u + , grad( p[ ab ], x, y - 1, z ) + , grad( p[ bb ], x - 1, y - 1, z ) + ) + ) + , linerp( v + , linerp( u + , grad( p[ aa + 1 ], x, y, z - 1 ) + , grad( p[ ba + 1 ], x - 1, y, z - 1 ) + ) + , linerp( u + , grad( p[ ab + 1 ], x, y - 1, z - 1 ) + , grad( p[ bb + 1 ], x - 1, y - 1, z - 1 ) + ) + ) + ) + END # perlin noise # ; + + print( ( fixed( perlin noise( 3.14, 42, 7 ), -18, 15 ) ) ) +END diff --git a/Task/Perlin-noise/Jq/perlin-noise.jq b/Task/Perlin-noise/Jq/perlin-noise.jq new file mode 100644 index 0000000000..9c5cb1c0bc --- /dev/null +++ b/Task/Perlin-noise/Jq/perlin-noise.jq @@ -0,0 +1,99 @@ +### Generic functions +# (-3.2|fraction) #=> -0.2 +def fraction: + if . >= 0 then . - trunc + else - (-. | fraction) + end; + +# For gojq +def div($y): + (. - (. % y)) / $y; + +# Convert the input integer to a stream of 0s and 1s, least significant bit first +def bitwise: + recurse( if . >= 2 then div(2) else empty end) | . % 2; + +# Inverse of bitwise: +def stream_to_integer(stream): + reduce stream as $c ( {power:1 , ans: 0}; + .ans += ($c * .power) | .power *= 2 ) + | .ans; + +# . & 2^($n-1) +def bits($n): + stream_to_integer(limit($n; bitwise)); + +### Perlin Noise +def permutation: [ + 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, + 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, + 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, + 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, + 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, + 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, + 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, + 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, + 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, + 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, + 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, + 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, + 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, + 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, + 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, + 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 +]; + +def grad($hash; $x; $y; $z): + def bit2: nth(1; bitwise); + # Convert low 4 bits of hash code into 12 gradient directions: + ( $hash|bits(4) ) as $h + | (if $h < 8 then $x else $y end) as $u + | (if $h < 4 then $y elif ($h == 12 or $h == 14) then $x else $z end) as $v + | (if ($h % 2 == 0) then $u else -$u end) + + (if (($h | bit2) == 0) then $v else -$v end) ; + +def noise($x; $y; $z): + def p: + permutation as $p + | $p[:256] + [range(256;512) | $p[.-256]]; + + def fade: + . * . * . * (. * (. * 6 - 15) + 10) ; + + def lerp($t; $a; $b): $a + $t * ($b - $a); + + # Find unit cube that contains point + ([$x,$y,$z] | map(floor | bits(8))) as [$xi, $yi, $zi] + + # Find relative x, y, z of point in cube + | ([$x,$y,$z] | map(fraction)) as [$xx, $yy, $zz] + + # Compute fade curves for each of xx, yy, zz + | ([$xx,$yy,$zz] | map(fade)) as [$u, $v, $w] + + | p as $p + # Hash co-ordinates of the 8 cube corners + # and add blended results from 8 corners of cube + | ($p[$xi] + $yi) as $a + | ($p[$a] + $zi) as $aa + | ($p[$a + 1] + $zi) as $ab + | ($p[$xi + 1] + $yi) as $b + | ($p[$b] + $zi) as $ba + | ($p[$b + 1] + $zi) as $bb + | lerp($w; + lerp($v; + lerp($u; + grad($p[$aa]; $xx; $yy; $zz); + grad($p[$ba]; $xx - 1; $yy; $zz)); + lerp($u; + grad($p[$ab]; $xx; $yy - 1; $zz); + grad($p[$bb]; $xx - 1; $yy - 1; $zz))); + lerp($v; + lerp($u; + grad($p[$aa + 1]; $xx; $yy; $zz - 1); + grad($p[$ba + 1]; $xx - 1; $yy; $zz - 1)); + lerp($u; + grad($p[$ab + 1]; $xx; $yy - 1; $zz - 1); + grad($p[$bb + 1]; $xx - 1; $yy - 1; $zz - 1))) ); + +noise(3.14; 42; 7) diff --git a/Task/Permutations-Rank-of-a-permutation/EasyLang/permutations-rank-of-a-permutation.easy b/Task/Permutations-Rank-of-a-permutation/EasyLang/permutations-rank-of-a-permutation.easy new file mode 100644 index 0000000000..db99f09c13 --- /dev/null +++ b/Task/Permutations-Rank-of-a-permutation/EasyLang/permutations-rank-of-a-permutation.easy @@ -0,0 +1,59 @@ +func[] init n . + for i to n + r[] &= i - 1 + . + return r[] +. +func fac n . + f = 1 + for i to n + f *= i + . + return f +. +func[] perm n r . + perm[] = init n + fa = fac n + for i = n downto 1 + fa /= i + d = r div fa + 1 + r = r mod fa + r[] &= perm[d] + for j = d to i - 1 + perm[j] = perm[j + 1] + . + . + return r[] +. +func rank n p[] . + perm[] = init n + fa = fac n + for i = n downto 1 + fa /= i + h = p[n - i + 1] + d = 1 + while perm[d] <> h + d += 1 + . + r += fa * (d - 1) + for j = d to i - 1 + perm[j] = perm[j + 1] + . + . + return r +. +proc show . . + for i = 0 to 5 + h[] = perm 3 i + print i & " -> " & h[] & " -> " & rank 3 h[] + . + print "" + for i to 4 + r = random fac 12 - 1 + write r & " -> " + h[] = perm 12 r + write h[] + print " -> " & rank 12 h[] + . +. +show diff --git a/Task/Permutations-by-swapping/Ada/permutations-by-swapping.ada b/Task/Permutations-by-swapping/Ada/permutations-by-swapping.ada new file mode 100644 index 0000000000..2cd2c9231e --- /dev/null +++ b/Task/Permutations-by-swapping/Ada/permutations-by-swapping.ada @@ -0,0 +1,28 @@ +-- Permutations by swapping +-- J. Carter 2024 Jun +-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC) + +with Ada.Text_IO; +with PragmARC.Permutations; + +procedure Permutations_By_Swapping is + package Permutations is new PragmARC.Permutations (Element => Positive); + + Permutation : Permutations.Sequence_Lists.Vector; +begin -- Permutations_By_Swapping + Permutations.Generate (Initial => (1, 2, 3), Result => Permutation); + + Output : for I in 1 .. Permutation.Last_Index loop + One_Permutation : declare + Sequence : Permutations.Sequence renames Permutation.Element (I); + begin -- One_Permutation + Ada.Text_IO.Put (Item => '('); + + Print : for J in Sequence'Range loop + Ada.Text_IO.Put (Item => (if J > 1 then "," else "") & Sequence (J)'Image); + end loop Print; + + Ada.Text_IO.Put_Line (Item => ") " & (if I rem 2 = 0 then '-' else '+') & '1'); + end One_Permutation; + end loop Output; +end Permutations_By_Swapping; diff --git a/Task/Permutations/Langur/permutations.langur b/Task/Permutations/Langur/permutations.langur index 0dfb1b0d5c..b94494e034 100644 --- a/Task/Permutations/Langur/permutations.langur +++ b/Task/Permutations/Langur/permutations.langur @@ -1,39 +1,39 @@ -val .factorial = fn(.x) if(.x < 2: 1; .x * self(.x - 1)) +val factorial = fn x:if(x < 2: 1; x * fn((x - 1))) -val .permute = fn(.list) { - if .list is not list: throw "expected list" +val permute = fn(plist) { + if plist is not list: throw "expected list" - val .limit = 10 - if len(.list) > .limit: throw $"permutation limit exceeded (currently \.limit;)" + val limit = 10 + if len(plist) > limit: throw "permutation limit exceeded (currently {{limit}})" - var .elements = .list - var .ordinals = pseries len .elements + var elements = plist + var ordinals = pseries(len(elements)) - val .n = len(.ordinals) - var .i, .j + val n = len(ordinals) + var i, j - for[.p=[.list]] of .factorial(len .list)-1 { - .i = .n - 1 - .j = .n - while .ordinals[.i] > .ordinals[.i+1] { - .i -= 1 + for[p=[plist]] of factorial(len(plist))-1 { + i = n - 1 + j = n + while ordinals[i] > ordinals[i+1] { + i -= 1 } - while .ordinals[.j] < .ordinals[.i] { - .j -= 1 + while ordinals[j] < ordinals[i] { + j -= 1 } - .ordinals[.i], .ordinals[.j] = .ordinals[.j], .ordinals[.i] - .elements[.i], .elements[.j] = .elements[.j], .elements[.i] + ordinals[i], ordinals[j] = ordinals[j], ordinals[i] + elements[i], elements[j] = elements[j], elements[i] - .i += 1 - for .j = .n; .i < .j ; .i, .j = .i+1, .j-1 { - .ordinals[.i], .ordinals[.j] = .ordinals[.j], .ordinals[.i] - .elements[.i], .elements[.j] = .elements[.j], .elements[.i] + i += 1 + for j = n; i < j ; i, j = i+1, j-1 { + ordinals[i], ordinals[j] = ordinals[j], ordinals[i] + elements[i], elements[j] = elements[j], elements[i] } - .p = more .p, .elements + p = more(p, elements) } } -for .e in .permute([1, 3.14, 7]) { - writeln .e +for e in permute([1, 3.14, 7]) { + writeln e } diff --git a/Task/Permutations/Uiua/permutations.uiua b/Task/Permutations/Uiua/permutations.uiua new file mode 100644 index 0000000000..ec272f75c7 --- /dev/null +++ b/Task/Permutations/Uiua/permutations.uiua @@ -0,0 +1,6 @@ +# Takes strict range 0..=lwb_digits; i--)); do # work backwards # + ((x=base*digits[i] + digit*i)); + ((digits[i]=x%(2*i-1))); + ((digit=x/(2*i-1))) + done; + ((digits[lwb_digits]=digit % base)); ((digit/=base)); +# nines := # + if((digit == nine)); then + ((nines=nines + 1)) + else + if((digit == base)); then + ((out=predigit+1)); + $yield $out; predigit=0; + for((repeats=1; repeats<=nines; repeats++)); do $yield 0; done + else + if((place != 1)); then $yield $predigit; fi; predigit=$digit; + for((repeats=1; repeats<=nines; repeats++)); do $yield $nine; done + fi; + nines=0 + fi + done; + $yield $predigit +}; + +print_digit(){ + echo -n $1 +} +# feynman_point=762; # feynman_point + 4 is a good test case +# the 33rd decimal place is a shorter tricky test case # +target="3.1415926.......................502"; +((test_decimal_places=${#target}-2)); # upb + +# iterate throught the digits as they are being found # +gen_pi_digits $test_decimal_places print_digit +echo # (new_line) diff --git a/Task/Pick-random-element/PascalABC.NET/pick-random-element.pas b/Task/Pick-random-element/PascalABC.NET/pick-random-element.pas new file mode 100644 index 0000000000..479bc07139 --- /dev/null +++ b/Task/Pick-random-element/PascalABC.NET/pick-random-element.pas @@ -0,0 +1,4 @@ +begin + var a := Arr('cat','dog','wolf','zebra'); + a.RandomElement.Print +end. diff --git a/Task/Pick-random-element/Uiua/pick-random-element.uiua b/Task/Pick-random-element/Uiua/pick-random-element.uiua new file mode 100644 index 0000000000..c3955aa455 --- /dev/null +++ b/Task/Pick-random-element/Uiua/pick-random-element.uiua @@ -0,0 +1 @@ +⊡⌊×⚂⧻."abcdefg" diff --git a/Task/Pierpont-primes/EasyLang/pierpont-primes.easy b/Task/Pierpont-primes/EasyLang/pierpont-primes.easy new file mode 100644 index 0000000000..24256ba706 --- /dev/null +++ b/Task/Pierpont-primes/EasyLang/pierpont-primes.easy @@ -0,0 +1,47 @@ +fastfunc isprim num . + if num mod 2 = 0 + if num = 2 + return 1 + . + return 0 + . + i = 3 + while i <= sqrt num + if num mod i = 0 + return 0 + . + i += 2 + . + return 1 +. +fastfunc mod2x3x n . + while n mod 2 = 0 + n /= 2 + . + while n mod 3 = 0 + n /= 3 + . + return n +. +i = 2 +cnt = 1 +write 2 & " " +while cnt < 50 + if mod2x3x i = 1 and isprim (i + 1) = 1 + cnt += 1 + write i + 1 & " " + . + i += 2 +. +print "" +print "" +i = 4 +write 2 & " " +cnt = 1 +while cnt < 50 + if mod2x3x i = 1 and isprim (i - 1) = 1 + cnt += 1 + write i - 1 & " " + . + i += 2 +. diff --git a/Task/Pig-the-dice-game-Player/C/pig-the-dice-game-player.c b/Task/Pig-the-dice-game-Player/C/pig-the-dice-game-player.c new file mode 100644 index 0000000000..ffc61ded62 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/C/pig-the-dice-game-player.c @@ -0,0 +1,179 @@ +#include +#include +#include + + +#define MAX_POINTS 100 +#define PLAYER_COUNT 4 + + +//Possible player moves. +typedef enum { + ROLL, + HOLD +} Moves; + +//To allow the player definition to be used in the function definition. +typedef struct Player Player; + +//This function takes the player's current score, returns 1 if the player rolls and 0 if they hold. +typedef Moves (*DeciderFunction) (Player *player); + +struct Player{ + unsigned int score; + unsigned int roundScore; + DeciderFunction dFunction; +}; + +/* + Auxiliary functions +*/ +static int randrange(int min, int max){ + return (rand() % (max - min + 1)) + min; +} + +//Creates a player with the given decider function. +static Player *create_player(DeciderFunction dFunction) { + Player *player = malloc(sizeof(Player)); + player->score = 0; + player->roundScore = 0; + player->dFunction = dFunction; + + return player; +} + +/* + Player functions +*/ +//Randomly decides whether to hold or roll. +static Moves random_player(Player *player) { + if (player->score + player->roundScore >= MAX_POINTS) + return HOLD; + + int num = randrange(0, 9); + + //We do the second check to make sure the player rolls at least once. + if (num < 5 || player->roundScore == 0) + return ROLL; + return HOLD; +} + +//Always tries to score at least a quarter of the difference between their score and "MAX_POINTS". +static Moves quarter_player(Player *player) { + if (player->score + player->roundScore >= MAX_POINTS) + return HOLD; + + unsigned int target = (MAX_POINTS - player->score) / 4; + + if (player->roundScore < target) + return ROLL; + return HOLD; +} + +//Always tries to score at least fifteen points. +static Moves fifteen_player(Player *player) { + if (player->score + player->roundScore >= MAX_POINTS) + return HOLD; + + if (player->roundScore < 15) + return ROLL; + return HOLD; +} + +//Behaves like the fifteen player, except they get nervous when they are close to wining. +static Moves nervous_player(Player *player) { + if (player->score + player->roundScore >= MAX_POINTS) + return HOLD; + + float scorePercent = (float)(1 / MAX_POINTS) * (float)(player->score + player->roundScore); + + //If the player's score is more than 75% of the total score there is a chance they will hold with less points. + if (scorePercent >= 0.75 && player->roundScore > 6) { + int num = randrange(0, 9); + + if (num < 5) + return ROLL; + return HOLD; + } + + if (player->roundScore < 15) + return ROLL; + return HOLD; +} + +/* + Game functions. +*/ +//Given a player it plays as long as the decider function allows it. +static void play(Player *player) { + while (1) { + if (player->dFunction(player) == ROLL) { + int roll = randrange(1, 6); + + if (roll > 1) { + player->roundScore += roll; + fprintf(stdout, "Player rolls a %d - Round score: %d\n", roll, player->roundScore); + } + else { + //If the player rolls a 1 they loose all their points. + player->score = 0; + player->roundScore = 0; + + fprintf(stdout, "Player rolls a 1, they loose all their points\n"); + + break; + } + } + else { + player->score += player->roundScore; + player->roundScore = 0; + + fprintf(stdout, "Player holds\n"); + + break; + } + } + fprintf(stdout, "Current score: %d\n", player->score); +} + +static void game_controller(Player *players[]) { + int playFlag = 1; + while (playFlag) { + for (int i = 0; i < PLAYER_COUNT; i++) { + fprintf(stdout, "\nPlayer %d turn\n", i + 1); + play(players[i]); + + //Check whether the given player has won, if so end the game and display total scores. + if (players[i]->score >= MAX_POINTS) { + fprintf(stdout, "\n\nPlayer %d has won", i + 1); + + puts("\n\nThe overall scores were:"); + for (int j = 0; j < PLAYER_COUNT; j++) + fprintf(stdout, "Player %d: %d points\n", j + 1, players[j]->score); + puts(""); + + playFlag = 0; + break; + } + } + } +} + + +int main () { + //Seed the random number generator with the current system time. + srand(time(0)); + + Player *players[PLAYER_COUNT]; + players[0] = create_player(random_player); + players[1] = create_player(quarter_player); + players[2] = create_player(fifteen_player); + players[3] = create_player(nervous_player); + + game_controller(players); + + for (int i = 0; i < PLAYER_COUNT; i++) + free(players[i]); + + return 0; +} diff --git a/Task/Pinstripe-Display/EasyLang/pinstripe-display.easy b/Task/Pinstripe-Display/EasyLang/pinstripe-display.easy new file mode 100644 index 0000000000..50ccee3074 --- /dev/null +++ b/Task/Pinstripe-Display/EasyLang/pinstripe-display.easy @@ -0,0 +1,10 @@ +for i = 1 to 4 + col = 000 + y = 100 - i * 25 + for x = 0 step i / 4 to 100 - i / 4 + color col + move x y + rect i / 4 25 + col = 999 - col + . +. diff --git a/Task/Pisano-period/APL/pisano-period.apl b/Task/Pisano-period/APL/pisano-period.apl new file mode 100644 index 0000000000..bd5b7a4cd6 --- /dev/null +++ b/Task/Pisano-period/APL/pisano-period.apl @@ -0,0 +1,17 @@ +pisano_period←{ + prime ← 2∘≤∧0∧.≠1↓⍳∘(⌊*∘0.5)|⊢ + select ← {(⍺⍺¨⍵)/⍵} + factors ← {⍺←2 ⋄ ⍺≥⍵×⍵:⍬ ⋄ 0=⍺|⍵:⍺,⍺∇⍵÷⍺ ⋄ (⍺+1)∇⍵} + + pisanoPeriod ← {⊃⍸1 0⍷(⊢,⍵|(+/¯2∘↑))⍣(⍵×⍵),0 1} + pisanoPrime ← {(pisanoPeriod ⍺)×⍺*⍵-1} + pisano ← {∧/{⍺=0:1 ⋄ ⍺ pisanoPrime ≢⍵}⌸factors ⍵} + + showPisanoPrimes ← {+⎕←⍵'pisanoPrime'⍺'→'(⍵ pisanoPrime ⍺)}¨ + _←2 showPisanoPrimes prime select ⍳15 + ⎕←'' + _←1 showPisanoPrimes prime select ⍳180 + ⎕←'' + ⎕←'pisano ⍵ for integers ''⍵'' from 1 to 180 are:' + ⎕←pisano¨12 15⍴⍳180 +} diff --git a/Task/Pisano-period/Jq/pisano-period.jq b/Task/Pisano-period/Jq/pisano-period.jq new file mode 100644 index 0000000000..a4bf4632de --- /dev/null +++ b/Task/Pisano-period/Jq/pisano-period.jq @@ -0,0 +1,114 @@ +### In case gojq is used: +# Require $n > 0 +def _nwise($n): + def _n: if length <= $n then . else .[:$n] , (.[$n:] | _n) end; + if $n <= 0 then "nwise: argument should be non-negative" else _n end; + +### Generic utilities + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +def lcm($m; $n): + # The helper function takes advantage of jq's tail-recursion optimization + def _lcm: + # state is [m, n, i] + if (.[2] % .[1]) == 0 then .[2] else (.[0:2] + [.[2] + $m]) | _lcm end; + [$m, $n, $m] | _lcm; + +# Preserve integer accuracy as much as the implementation of jq allows +def power($b): . as $in | reduce range(0;$b) as $i (1; . * $in); + +def is_prime: + . as $n + | if ($n < 2) then false + elif ($n % 2 == 0) then $n == 2 + elif ($n % 3 == 0) then $n == 3 + elif ($n % 5 == 0) then $n == 5 + elif ($n % 7 == 0) then $n == 7 + elif ($n % 11 == 0) then $n == 11 + elif ($n % 13 == 0) then $n == 13 + elif ($n % 17 == 0) then $n == 17 + elif ($n % 19 == 0) then $n == 19 + else sqrt as $s + | 23 + | until( . > $s or ($n % . == 0); . + 2) + | . > $s + end; + +# Emit an array of the prime factors of . in order using a wheel with basis [2, 3, 5] +# e.g. 44 | primeFactors => [2,2,11] +def primeFactors: + def out($i): until (.n % $i != 0; .factors += [$i] | .n = ((.n/$i)|floor) ); + if . < 2 then [] + else [4, 2, 4, 2, 4, 6, 2, 6] as $inc + | { n: ., + factors: [] } + | out(2) + | out(3) + | out(5) + | .k = 7 + | .i = 0 + | until(.k * .k > .n; + if .n % .k == 0 + then .factors += [.k] + | .n = ((.n/.k)|floor) + else .k += $inc[.i] + | .i = ((.i + 1) % 8) + end) + | if .n > 1 then .factors += [ .n ] else . end + | .factors + end; + +# Calculate the Pisano period of . from first principles. +def pisanoPeriod: + . as $m + | {p: 0, c: 1} + | first(foreach range(0; $m*$m) as $i (.; + .p as $t + | .p = .c + | .c = ($t + .c) % $m; + select(.p == 0 and .c == 1) | $i + 1 + )) // 1; + +# Calculate the Pisano period of $p^$k where $p is prime and $k is a positive integer. +def pisanoPrime($p; $k): + $p + | if (is_prime|not) or $k == 0 then 0 # no can do + else ( power($k-1) * pisanoPeriod ) + end; + +# Calculate the Pisano period of . using pisanoPrime/2. +def pisano: + . as $m + | (reduce primeFactors[] as $p ({}; .[$p|tostring] += 1) + | to_entries | map([(.key|tonumber), .value]) ) as $primePowers + | (reduce $primePowers[] as [$p, $n] ([]; + . + [ pisanoPrime($p;$n) ] ) ) as $pps + | ($pps|length) as $ppsl + | if $ppsl == 0 then 1 + elif $ppsl == 1 then $pps[0] + else {f: $pps[0], i: 1} + | until(.i >= $ppsl; + .f = lcm(.f; $pps[.i]) + | .i += 1) + | .f + end; + +def examples: + (range( 2; 15) + | pisanoPrime(.; 2) as $pp + | select($pp > 0) + | "pisanoPrime(\(.); 2) = \($pp)" ), + "", + (range( 2; 180) + | pisanoPrime(.; 1) as $pp + | select($pp > 0) + | "pisanoPrime(\(.);1) = \($pp)" ) +; + +examples, +"\npisano(n) for integers 'n' from 1 to 180 are:", +( [range(1; 181) | pisano ] + | _nwise(15) + | map(lpad(3)) + | join(" ")) diff --git a/Task/Pisano-period/SETL/pisano-period.setl b/Task/Pisano-period/SETL/pisano-period.setl new file mode 100644 index 0000000000..7230dab59c --- /dev/null +++ b/Task/Pisano-period/SETL/pisano-period.setl @@ -0,0 +1,79 @@ +program pisano_period; + loop for p in [2..15] | prime p do + print("pisanoPrime(" + lpad(str p,3) + ", 2) = " + + lpad(str pisanoPrime(p,2), 3)); + end loop; + print; + + loop for p in [2..180] | prime p do + print("pisanoPrime(" + lpad(str p,3) + ", 1) = " + + lpad(str pisanoPrime(p,1), 3)); + end loop; + print; + + print("pisano(n) for integers 'n' from 1 to 180 are:"); + loop for n in [1..180] do + nprint(lpad(str pisano n,4)); + if (col +:= 1) mod 15 = 0 then print; end if; + end loop; + + op gcd(a, b); + return {[0, a]}(b) ? (b gcd (a mod b)); + end op; + + op lcm(a, b); + return a div (a gcd b) * b; + end op; + + op factors(n); + d := 2; + f := {}; + loop while d <= n do + loop while n mod d=0 do + f(d) +:= 1; + n div:= d; + end loop; + d +:= 1; + end loop; + return f; + end op; + + op prime(n); + if n<=4 then return n in {2,3}; end if; + if n mod 2=0 then return n=2; end if; + if n mod 3=0 then return n=3; end if; + d := 5; + loop while d*d <= n do + if n mod d=0 then return false; end if; + d +:= 2; + if n mod d=0 then return false; end if; + d +:= 4; + end loop; + return true; + end op; + + op pisanoPeriod(n); + [p, c, i] := [0, 1, 0]; + loop while i < n*n do + [p, c] := [c, (p+c) mod n]; + i +:= 1; + if p=0 and c=1 then return i; end if; + end loop; + return 1; + end op; + + proc pisanoPrime(p, k); + return if not prime p or k=0 + then om + else p**(k-1) * pisanoPeriod p + end; + end proc; + + op pisano(m); + primePowers := factors m; + pps := [pisanoPrime(p, k) : k = primePowers(p)]; + if #pps = 0 then return 1; end if; + if #pps = 1 then return pps(1); end if; + return lcm/pps; + end op; +end program; diff --git a/Task/Plasma-effect/EasyLang/plasma-effect.easy b/Task/Plasma-effect/EasyLang/plasma-effect.easy new file mode 100644 index 0000000000..42060fa850 --- /dev/null +++ b/Task/Plasma-effect/EasyLang/plasma-effect.easy @@ -0,0 +1,20 @@ +# lodev.org/cgtutor/plasma.html (last example) +func dist a b c d . + d1 = a - c ; d2 = b - d + return 15 * sqrt (d1 * d1 + d2 * d2) +. +on animate + for y = 0 step 0.4 to 100 + for x = 0 step 0.4 to 100 + val = sin dist (x + time) y 50 50 + 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 + color3 col col * 2 1 - col + move x y + rect 0.5 0.5 + . + . + time += 1 +. diff --git a/Task/Play-recorded-sounds/Ada/play-recorded-sounds.ada b/Task/Play-recorded-sounds/Ada/play-recorded-sounds.ada new file mode 100644 index 0000000000..8bcfde7d19 --- /dev/null +++ b/Task/Play-recorded-sounds/Ada/play-recorded-sounds.ada @@ -0,0 +1,39 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Sf.Audio.Music; use Sf, Sf.Audio, Sf.Audio.Music; + +procedure Play is + Sound1 : sfMusic_Ptr; + Sound2 : sfMusic_Ptr; +begin + Sound1 := createFromFile ("sound1.ogg"); + Sound2 := createFromFile ("sound2.ogg"); + if Sound1 = null or Sound2 = null then + Put_Line (Standard_Error, "Error: Sound files not found!"); + return; + end if; + + -- Looping for both sounds + setLoop (Sound1, sfTrue); + setLoop (Sound2, sfTrue); + + -- Setting the volume of each sound + setVolume (Sound1, 100.0); + setVolume (Sound2, 75.0); + + Put_Line ("Playing Sound1 individually... "); + play (Sound1); + delay 5.0; + + Put_Line ("Playing Sound1 and Sound2 simultaneously... "); + play (Sound2); + delay 10.0; + + Put_Line ("Stopping Sound1 before the end..."); + stop (Sound1); + + Put_Line ("Playing Sound2 alone for 5 seconds..."); + delay 5.0; + + destroy (Sound1); + destroy (Sound2); +end Play; diff --git a/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy b/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy index 310c247c68..e6f2741331 100644 --- a/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy +++ b/Task/Plot-coordinate-pairs/EasyLang/plot-coordinate-pairs.easy @@ -17,17 +17,17 @@ for i = 1 to n linewidth 0.1 sty = m div 9 for i range0 10 - move 2 4 + i * 10 - text i * sty move 10 5 + i * 10 line 95 5 + i * 10 + move 2 4 + i * 10 + text i * sty . stx = x[n] div 9 for i range0 10 - move i * 9 + 10 1 - text i * stx move i * 9 + 10 5 line i * 9 + 10 97 + move i * 9 + 10 1 + text i * stx . color 900 linewidth 0.5 diff --git a/Task/Pointers-and-references/Ecstasy/pointers-and-references.ecstasy b/Task/Pointers-and-references/Ecstasy/pointers-and-references.ecstasy new file mode 100644 index 0000000000..c3b1d166c3 --- /dev/null +++ b/Task/Pointers-and-references/Ecstasy/pointers-and-references.ecstasy @@ -0,0 +1,18 @@ +module test { + @Inject Console console; + + public class Point(Int x, Int y) { + @Override String toString() = $"({x},{y})"; + } + + void run() { + Point p = new Point(0, 0); + p.x = 7; + p.y = p.x; + console.print($"{p=}"); + + // obtain the reference object itself + Ref r = &p; + console.print($"{r.actualType=}"); + } +} diff --git a/Task/Pointers-and-references/PascalABC.NET/pointers-and-references.pas b/Task/Pointers-and-references/PascalABC.NET/pointers-and-references.pas new file mode 100644 index 0000000000..8c3a415d0e --- /dev/null +++ b/Task/Pointers-and-references/PascalABC.NET/pointers-and-references.pas @@ -0,0 +1,29 @@ +type MyClass = class +public + x: integer := 555; +end; + +begin + var pi: ^integer; + New(pi); + pi^ := 1023; + var pb: ^byte; + //pb := pi; // compiler error + var p: pointer; + p := pi; + pb := p; + Print(pb^); // byte representation of integer + loop 3 do + begin + pb := pointer(integer(pb)+1); // analog of pb++ + Print(pb^); + end; + Println; + var obj := new MyClass; // obj is a reference to object + // All regferences in .NET are under control of garbage collection + Println(obj); + var obj1 := obj; // another reference to the same object + obj1.x := 666; + Println(obj); + obj := nil; // zero reference +end. diff --git a/Task/Poker-hand-analyser/Ada/poker-hand-analyser.ada b/Task/Poker-hand-analyser/Ada/poker-hand-analyser.ada new file mode 100644 index 0000000000..94bdcc4959 --- /dev/null +++ b/Task/Poker-hand-analyser/Ada/poker-hand-analyser.ada @@ -0,0 +1,162 @@ +pragma Ada_2022; +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Containers.Generic_Constrained_Array_Sort; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Poker is + + type Face_T is (two, three, four, five, six, seven, eight, nine, t, j, q, k, a); + for Face_T use (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); + type Suit_T is (C, D, H, S); + type Card_T is record + Face : Face_T; + Suit : Suit_T; + end record; + + subtype Hand_Index is Natural range 1 .. 5; + type Hand_T is array (Hand_Index) of Card_T; + type Test_Hand_Arr is array (Positive range <>) of Hand_T; + type Pip_Counter_T is array (Face_T range Face_T'Range) of Natural; + + Pip_Counts : Pip_Counter_T := [others => 0]; + + Test_Hands : Test_Hand_Arr := [ + 1 => [(two, H), (two, D), (two, C), (k, S), (q, D)], + 2 => [(two, H), (five, H), (seven, D), (eight, C), (nine, S)], + 3 => [(a, H), (two, D), (three, C), (four, C), (five, D)], + 4 => [(two, H), (three, H), (two, D), (three, C), (three, D)], + 5 => [(two, H), (seven, H), (two, D), (three, C), (three, D)], + 6 => [(two, H), (seven, H), (seven, D), (seven, C), (seven, S)], + 7 => [(t, H), (j, H), (q, H), (k, H), (a, H)], + 8 => [(four, H), (four, S), (k, S), (five, D), (t, S)], + 9 => [(q, C), (t, C), (seven, C), (six, C), (q, C)] + ]; + + function "<" (L, R : Card_T) return Boolean is + begin + if L.Face = R.Face then + return L.Suit < R.Suit; + else + return L.Face < R.Face; + end if; + end "<"; + + procedure Sort_Hand is new Ada.Containers.Generic_Constrained_Array_Sort (Hand_Index, Card_T, Hand_T); + + procedure Print_Hand (Hand : Hand_T) is + begin + for Card of Hand loop + if Card.Face < j then + Put (Face_T'Enum_Rep (Card.Face)'Image); + else + Put (" " & To_Lower (Card.Face'Img)); + end if; + Put (To_Lower (Card.Suit'Img)); + end loop; + end Print_Hand; + + function Is_Invalid (Hand : Hand_T) return Boolean is + begin + for Ix in 2 .. 5 loop + if Face_T'Pos (Hand (Ix).Face) = Face_T'Pos (Hand (Ix - 1).Face) and then + Hand (Ix).Suit = Hand (Ix - 1).Suit + then + return True; + end if; + end loop; + return False; + end Is_Invalid; + + function Is_Flush (Hand : Hand_T) return Boolean is + begin + for Ix in 2 .. 5 loop + if Hand (Ix).Suit /= Hand (1).Suit then + return False; + end if; + end loop; + return True; + end Is_Flush; + + function Is_Straight (Hand : Hand_T) return Boolean is + begin + -- special case: Ace low + if Hand (5).Face = a and then Hand (1).Face = two and then Hand (2).Face = three and then Hand (3).Face = four then + return True; + end if; + for Ix in 2 .. 5 loop + if Face_T'Pos (Hand (Ix).Face) /= Face_T'Pos (Hand (Ix - 1).Face) + 1 then + return False; + end if; + end loop; + return True; + end Is_Straight; + + function Of_A_Kind (N : Positive) return Boolean is + begin + for Pip in two .. a loop + if Pip_Counts (Pip) = N then + return True; + end if; + end loop; + return False; + end Of_A_Kind; + + function Count_Pairs return Natural is + Pairs : Natural := 0; + begin + for Pip in two .. a loop + if Pip_Counts (Pip) = 2 then + Pairs := Pairs + 1; + end if; + end loop; + return Pairs; + end Count_Pairs; + + Flush, Straight : Boolean; + +begin + + for Hand of Test_Hands loop + Print_Hand (Hand); + Put (":"); + Set_Col (20); + Sort_Hand (Hand); -- Print_Hand (Hand); + if Is_Invalid (Hand) then + Put ("invalid"); + else + Flush := Is_Flush (Hand); + Straight := Is_Straight (Hand); + if Flush and Straight then + Put ("straight-flush"); + else + for Pip in two .. a loop + Pip_Counts (Pip) := 0; + for Card of Hand loop + if Card.Face = Pip then + Pip_Counts (Pip) := Pip_Counts (Pip) + 1; + end if; + end loop; + end loop; + if Of_A_Kind (4) then + Put ("four-of-a-kind"); + elsif Of_A_Kind (3) and then Of_A_Kind (2) then + Put ("full-house"); + elsif Flush then + Put ("flush"); + elsif Straight then + Put ("straight"); + elsif Of_A_Kind (3) then + Put ("three-of-a-kind"); + else + case Count_Pairs is + when 2 => Put ("two-pairs"); + when 1 => Put ("one-pair"); + when others => Put ("high-card"); + end case; + end if; + end if; + end if; + Put_Line (""); + end loop; + +end Poker; diff --git a/Task/Poker-hand-analyser/Jq/poker-hand-analyser.jq b/Task/Poker-hand-analyser/Jq/poker-hand-analyser.jq new file mode 100644 index 0000000000..f6ad9a73e3 --- /dev/null +++ b/Task/Poker-hand-analyser/Jq/poker-hand-analyser.jq @@ -0,0 +1,65 @@ +# A card is represented by a JSON object: +def Card($face; $suit): {$face, $suit}; + +def FACES: "23456789tjqka"; +def SUITS: "shdc"; + +# Input: an array of Card +def isStraight: + sort_by(.face) + | (.[0].face + 4 == .[4].face) + or (.[4].face == 14 and .[0].face == 2 and .[3].face == 5) ; + +def isFlush: + .[0].suit as $suit + | all(.[]; .suit == $suit); + +# Input: a string such as "2h 2d 2c kc qd" +def analyzeHand: + (FACES | split("")) as $FACES + | (SUITS | split("")) as $SUITS + | ascii_downcase + | split(" ") + | unique + | if length != 5 or + any(length != 2 or + (.[0:1] | IN($FACES[]) | not) or + (.[1: ] | IN($SUITS[]) | not) ) + then "invalid" + else [.[] as $s | Card(($FACES|index($s[0:1])) + 2; $s[1:]) ] + | . as $cards + | group_by(.face) + | if length == 2 + then if any(length == 4) then "four-of-a-kind" + else "full-house" + end + elif length == 3 + then if any(length == 3) then "three-of-a-kind" + else "two-pairs" + end + elif length == 4 + then "one-pair" + else ($cards|[isFlush, isStraight]) as [$flush, $straight] + | if $flush and $straight then "straight-flush" + elif $flush then "flush" + elif $straight then "straight" + else "high-card" + end + end + end ; + +def hands: [ + "2h 2d 2c kc qd", + "2h 5h 7d 8c 9s", + "ah 2d 3c 4c 5d", + "2h 3h 2d 3c 3d", + "2h 7h 2d 3c 3d", + "2h 7h 7d 7c 7s", + "th jh qh kh ah", + "4h 4s ks 5d ts", + "qc tc 7c 6c 4c", + "ah ah 7c 6c 4c" +]; + +hands[] +| "\(.): \(analyzeHand)" diff --git a/Task/Poker-hand-analyser/Liberty-BASIC/poker-hand-analyser.basic b/Task/Poker-hand-analyser/Liberty-BASIC/poker-hand-analyser.basic new file mode 100644 index 0000000000..d0798cdfb2 --- /dev/null +++ b/Task/Poker-hand-analyser/Liberty-BASIC/poker-hand-analyser.basic @@ -0,0 +1,371 @@ +NoMainWin +WindowWidth=900 +WindowHeight=720 +BackgroundColor$ = "191 191 255" ' buttonface default +Global Deck, MaxDecks + +StaticText #1.Debug "", 0, 0, 600, 20 +StaticText #1.StaticText "Ten Decks of Poker Hands", 50, 50, 3000, 40 +Button #1.Deal "Deal", [Start], UL, 700, 180, 80, 40 +Button #1.TenThousand "10,000", [TenThousand], UL, 700, 250, 80, 40 +Button #1.Stats "History", ShowStats, UL, 700, 320, 80, 40 +Button #1.Quit "Quit", Quit, UL, 700, 390, 80, 40 +TextEditor #1.TextEditor 50, 100, 600, 500 + +open "POKER HANDS" for dialog as #1 +#1 "TrapClose Quit" +#1 "Font Ariel 12 Bold" +#1.StaticText "!Font Ariel 16 Bold" +#1.TextEditor "!Font Courier_New 14 Bold" +if not(exists("Poker Hands.txt")) then #1.Stats "!Disable" +MaxDecks=10 +wait + +[TenThousand] +TenThousand = 1 +[Start] +if TenThousand then + MaxDecks=10000 + #1.TextEditor "!Hide" + #1.Deal "!Hide" + #1.TenThousand "!Hide" + #1.Stats "!Hide" + #1.Quit "!Hide" + #1.StaticText "Ten Thousand Decks of Poker Hands" +end if +Deck += 1 +if TenThousand then #1.Debug Str$(Deck) +if Deck>MaxDecks then Deck -= 1: call Quit +#1.TextEditor "!cls" +call ShuffleDeck 0 +'call TestDeck +NextCard=1 +for y=1 to 10 + for x=1 to 5 + y$ = A$(NextCard) + B$(x) = ConvertHiCard$(y$) + NextCard += 1 + next x + sort B$(), 1, 5 + for x=NextCard-5 to NextCard-1 + #1.TextEditor A$(x)+" "; + next x + #1.TextEditor " "; + + Values$="" 'determine high value of hand + for x=1 to 5 + Values$ = Values$ + left$(B$(x),1) + next x + HiValue$ = RealValue$(right$(Values$,1)) + + z=0: Flush=0: Straight=0: Royal=0: FourKind=0 + ThreeKind=0: Pair=0: TwoPair=0: FullHouse=0 + if Flush() then Flush=1 + x = Straight() + if x then Straight=1: if x=9 then Royal=1 + z$ = Kind$() + Value$ = RealValue$(right$(z$,1)) + z=val(left$(z$, len(z$)-1)) + if z=41 then FourKind=1 + if z=32 then FullHouse=1 + if z=31 then ThreeKind=1 + if z=22 then TwoPair=1 + if z=21 then Pair=1 + + select case + case Straight and Royal and Flush: #1.TextEditor "Royal Flush": Stats(1) += 1 + case Straight and Flush: #1.TextEditor "Straight Flush, " + HiValue$ + " high": Stats(2) += 1 + case FourKind: #1.TextEditor "Four of a kind, " + Value$ + "s": Stats(3) += 1 + case FullHouse: #1.TextEditor "Full House, " + Value$ + "s high": Stats(4) += 1 + case Flush: #1.TextEditor "Flush, " + HiValue$ + " high": Stats(5) += 1 + case Straight: #1.TextEditor "Straight, " + HiValue$ + " high": Stats(6) += 1 + case ThreeKind: #1.TextEditor "Three of a kind, " + Value$ + "s": Stats(7) += 1 + case TwoPair: #1.TextEditor "Two Pair, " + Value$ + " high": Stats(8) += 1 + case Pair: #1.TextEditor "Pair " + Value$ + "s": Stats(9) += 1 + case else: #1.TextEditor HiValue$ + " high" + end select +next y +#1.TextEditor "" +#1.TextEditor "Deck #" + str$(Deck) +if TenThousand then goto [Start] else wait + +function RealValue$(Value$) + select case Value$ + case "A": RealValue$="T" + case "B": RealValue$="J" + case "C": RealValue$="Q" + case "D": RealValue$="K" + case "E": RealValue$="A" + case else: RealValue$=Value$ + end select +end function + +sub SaveStats Deck + Stats(0) = 10*Deck + if not(exists("Poker Hands.txt")) then + open "Poker Hands.txt" for output as #2 + for x=0 to 9 + print #2 Stats(x) + next + close #2 + #1.Stats "!Enable" + else + open "Poker Hands.txt" for input as #2 + for x=0 to 9 + input #2 History(x) + next + close #2 + for x=0 to 9 + History(x) += Stats(x) + next + open "Poker Hands.txt" for output as #2 + for x=0 to 9 + print #2 History(x) + next + close #2 + end if +end sub + +sub ShowStats + if exists("Poker Hands.txt") then + open "Poker Hands.txt" for input as #2 + for x=0 to 9 + input #2 History(x) + next + close #2 + #1.TextEditor "!cls" + + for x=1 to 9 + Total += History(x) + next x + Nothing = History(0) - Total + + for x=0 to 9 + #1.TextEditor using("###,### ", History(x)); + select case x + case 0: #1.TextEditor "hands " + case 1: #1.TextEditor "royal flush " + using("##.# %", History(x)/History(0)*100) + case 2: #1.TextEditor "straight flush " + using("##.# %", History(x)/History(0)*100) + case 3: #1.TextEditor "four of a kind " + using("##.# %", History(x)/History(0)*100) + case 4: #1.TextEditor "full house " + using("##.# %", History(x)/History(0)*100) + case 5: #1.TextEditor "flush " + using("##.# %", History(x)/History(0)*100) + case 6: #1.TextEditor "straight " + using("##.# %", History(x)/History(0)*100) + case 7: #1.TextEditor "three of a kind " + using("##.# %", History(x)/History(0)*100) + case 8: #1.TextEditor "two pair " + using("##.# %", History(x)/History(0)*100) + case 9: #1.TextEditor "pair " + using("##.# %", History(x)/History(0)*100) + end select + next + #1.TextEditor using("###,### ", Nothing) + "nothing " + using("###.# %", Nothing/History(0)*100) + end if +end sub + +function Kind$() + for x=1 to 5 + C$(x) = left$(B$(x), 1) + next x + if C$(1) = C$(2) then 'check for Lo4 + Lo2=1 + if C$(2) = C$(3) then + Lo2=0: Lo3=1 + if C$(3) = C$(4) then + Lo3=0: Kind$="41" + left$(C$(4),1): exit function + end if + end if + end if + + if C$(5) = C$(4) then 'check for Hi4 + Hi2=1 + if C$(4) = C$(3) then + Hi2=0: Hi3=1 + if C$(3) = C$(2) then + Hi3=0: Kind$="41" + left$(C$(5),1): exit function + end if + end if + end if + + if Lo3 then 'check for Full House and 3Kind + if C$(4) = C$(5) then + Kind$="32" + left$(C$(3),1): exit function + else + Kind$="31" + left$(C$(3),1): exit function + end if + end if + if Hi3 then + if C$(1) = C$(2) then + Kind$="32" + left$(C$(5),1): exit function + else + Kind$="31" + left$(C$(5),1): exit function + end if + end if + if C$(2) = C$(3) and C$(3) = C$(4) then 'Mid3 + Kind$="31" + left$(C$(4),1): exit function + end if + + if Lo2 and Hi2 then 'check for pairs + Kind$="22" + left$(C$(5),1): exit function + end if + if Lo2 and (C$(3)=C$(4)) then + Kind$="22" + left$(C$(4),1): exit function + end if + if Hi2 and (C$(3)=C$(2)) then + Kind$="22" + left$(C$(5),1): exit function + end if + + if Lo2 then Kind$="21" + left$(C$(2),1) + if Hi2 then Kind$="21" + left$(C$(5),1) + if C$(2)=C$(3) then Kind$="21" + left$(C$(3),1) + if C$(3)=C$(4) then Kind$="21" + left$(C$(4),1) +end function + +function Straight() + Order$="23456789ABCDEF" + for x=1 to 5 + Ranks$ = Ranks$ + left$(B$(x), 1) + next x + x = instr(Order$, Ranks$) + if x then Straight=x +end function + +function Flush() + Flush=1 + for x=1 to 5 + Suits$ = Suits$ + right$(B$(x), 1) + next x + for x=2 to 5 + if mid$(Suits$, x, 1) <> left$(Suits$, 1) then Flush=0: exit function + next x +end function + +sub ShuffleDeck Jokers + Jokers = int(abs(Jokers)): if Jokers>4 then Jokers=4 + Size=52 + Jokers + dim CardDeck$(Size+10,1), A$(Size+10) 'Open new card deck +[Start] + for x=1 to Size + CardDeck$(x,0) = "99" + next x + + for x=1 to Size + 1 y=RandomNumber(1,Size) + if CardDeck$(y,0)="99" then CardDeck$(y,0)=str$(x) else goto 1 + next x + + for x=1 to Size 'Examine shuffled deck + if CardDeck$(x,0)=str$(x) then z = 1: exit for + next x + if z then z=0: goto [Start] + for x=1 to Size 'Save shuffled deck + A$(x) = CardFace$(val(CardDeck$(x,0))) + next x + A$(0) = str$(Size) +end sub + +function CardFace$(n) + select case n + case 1: CardFace$="AD" + case 2: CardFace$="2D" + case 3: CardFace$="3D" + case 4: CardFace$="4D" + case 5: CardFace$="5D" + case 6: CardFace$="6D" + case 7: CardFace$="7D" + case 8: CardFace$="8D" + case 9: CardFace$="9D" + case 10: CardFace$="TD" + case 11: CardFace$="JD" + case 12: CardFace$="QD" + case 13: CardFace$="KD" + case 14: CardFace$="AC" + case 15: CardFace$="2C" + case 16: CardFace$="3C" + case 17: CardFace$="4C" + case 18: CardFace$="5C" + case 19: CardFace$="6C" + case 20: CardFace$="7C" + case 21: CardFace$="8C" + case 22: CardFace$="9C" + case 23: CardFace$="TC" + case 24: CardFace$="JC" + case 25: CardFace$="QC" + case 26: CardFace$="KC" + case 27: CardFace$="AH" + case 28: CardFace$="2H" + case 29: CardFace$="3H" + case 30: CardFace$="4H" + case 31: CardFace$="5H" + case 32: CardFace$="6H" + case 33: CardFace$="7H" + case 34: CardFace$="8H" + case 35: CardFace$="9H" + case 36: CardFace$="TH" + case 37: CardFace$="JH" + case 38: CardFace$="QH" + case 39: CardFace$="KH" + case 40: CardFace$="AS" + case 41: CardFace$="2S" + case 42: CardFace$="3S" + case 43: CardFace$="4S" + case 44: CardFace$="5S" + case 45: CardFace$="6S" + case 46: CardFace$="7S" + case 47: CardFace$="8S" + case 48: CardFace$="9S" + case 49: CardFace$="TS" + case 50: CardFace$="JS" + case 51: CardFace$="QS" + case 52: CardFace$="KS" + case 53: CardFace$="X1" + case 54: CardFace$="X2" + case 55: CardFace$="X3" + case 56: CardFace$="X4" + end select +end function + +function RandomNumber(a, b) + smaller = min(a, b) + range = abs(int(a-b))+1 + if range < 1 then exit function + r = int(rnd()*range) + RandomNumber = r + smaller +end function + +function ConvertHiCard$(Card$) + select case left$(Card$,1) + case "T": left$(Card$,1)="A" + case "J": left$(Card$,1)="B" + case "Q": left$(Card$,1)="C" + case "K": left$(Card$,1)="D" + case "A": left$(Card$,1)="E" + case "X": left$(Card$,1)="F" + end select + ConvertHiCard$ = Card$ +end function + +sub TestDeck + data KD, KC, KS, AH, AS ' full house + data 6D, 6C, 6S, 6H, 8H ' four of a kind (io) + data 2D, 4S, 4C, TH, TD ' two pair + data 4H, 5H, 6H, 7H, 8H ' straight flush + data 9S, QD, QC, QH, 3D ' three of a kind + data 6H, 7D, 8C, 9C, TS ' straight + data TH, AH, AS, AC, AD ' four of a kind (hI) + data 3S, 5S, 7S, 9S, JS ' flush + data AD, KD, QD, JD, TD ' royal flush + data 2C, 2D, 3H, 4S, 5C ' one pair + dim A$(50) + for x=1 to 50 + read A$(x) + next x +end sub + +function exists(FileName$) + files "", FileName$, FileDir$() + FileCount$ = FileDir$(0, 0) + exists = val(FileCount$) +end function + +sub Quit + if Deck = MaxDecks then call SaveStats Deck + close #1 + end +end sub diff --git a/Task/Poker-hand-analyser/XPL0/poker-hand-analyser.xpl0 b/Task/Poker-hand-analyser/XPL0/poker-hand-analyser.xpl0 new file mode 100644 index 0000000000..95ceb38d34 --- /dev/null +++ b/Task/Poker-hand-analyser/XPL0/poker-hand-analyser.xpl0 @@ -0,0 +1,86 @@ +string 0; \Use null-terminated strings (vs MSB terminated) +int Count(1+18); \Counts of ranks and suits in a hand + +proc ShowCat; \Show category of poker hand +int I, J; +[for I:= 1 to 14 do + [if Count(I) = 1 then + [for J:= I+1 to I+4 do \are next 4 cards present? + if Count(J) # 1 then J:= 100; + if J <= 100 then + [Text(0, "straight"); + for J:= 15 to 18 do \scan suits + if Count(J) >= 4 then Text(0, "-flush"); + return; + ]; + ]; + ]; +for I:= 15 to 18 do + if Count(I) = 4 then [Text(0, "flush"); return]; +for I:= 1 to 14 do \scan ranks + if Count(I) = 4 then + [Text(0, "four-of-a-kind"); return]; +for I:= 1 to 14 do + [if Count(I) = 3 then + [for J:= 1 to 14 do + if Count(J) = 2 then + [Text(0, "full-house"); return]; + Text(0, "three-of-a-kind"); return; + ]; + ]; +for I:= 1 to 14 do + [if Count(I) = 2 then + [for J:= 1 to 14 do + if J # I and Count(J) = 2 then + [Text(0, "two-pairs"); return]; + Text(0, "one-pair"); return; + ]; + ]; +Text(0, "high-card"); +]; + +int Hands, H, Card, I, Char, N, Invalid, Valid(4), Suit, Rank; +char Str; +[Hands:= [ + "2h 2d 2c kc qd ", + "2h 5h 7d 8c 9s ", + "ah 2d 3c 4c 5d ", + "2h 3h 2d 3c 3d ", + "2h 7h 2d 3c 3d ", + "2h 7h 7d 7c 7s ", + "10h jh qh kh ah ", + "4h 4s ks 5d 10s ", + "qc 10c 7c 6c qc "]; +for H:= 0 to 9-1 do + [for I:= 0 to 18 do Count(I):= 0; + for I:= 0 to 3 do Valid(I):= 0; + Invalid:= false; + Str:= Hands(H); + Card:= 0; I:= 0; + loop [Char:= Str(I); I:= I+1; + case Char of + ^h: N:= 18; + ^d: N:= 17; + ^c: N:= 16; + ^s: N:= 15; + ^a: N:= 14; + ^k: N:= 13; + ^q: N:= 12; + ^j: N:= 11; + ^1: N:= 10; + ^ : [N:= 0; Card:= Card+1; if Card >= 5 then quit] + other N:= Char-^0; + Count(N):= Count(N)+1; + if N = 14 then Count(1):= Count(1)+1; \two-place ace + if N <= 14 then Rank:= N + else [Suit:= N - 15; + if Valid(Suit) and 1<; + lst.Add(new Base(3)); + lst.Add(new Derived(4,5.5)); + lst.Add(new Base(6)); + lst.Add(new Derived(7,8.8)); + lst.Println; + var lst1 := new List; + foreach var obj in lst do + lst1.Add(obj.Clone); + lst1.Println; +end. diff --git a/Task/Polymorphism/PascalABC.NET/polymorphism.pas b/Task/Polymorphism/PascalABC.NET/polymorphism.pas new file mode 100644 index 0000000000..97d78c8985 --- /dev/null +++ b/Task/Polymorphism/PascalABC.NET/polymorphism.pas @@ -0,0 +1,36 @@ +type + Point = class + public + auto property x: real; + auto property y: real; + constructor (x,y: real); + begin + Self.x := x; Self.y := y; + end; + procedure Print; virtual; + begin + PABCSystem.Print(x,y); + end; + end; + Circle = class(Point) + public + auto property r: real; + constructor (x,y,r: real); + begin + inherited Create(x,y); + Self.r := r; + end; + procedure Print; override; + begin + inherited Print; + PABCSystem.Print(r); + end; + end; + +begin + var p: Point := new Point(3,5); + var c: Circle := new Circle(10,8,4); + p.Print; + Println; + c.Print; +end. diff --git a/Task/Polynomial-regression/Jq/polynomial-regression.jq b/Task/Polynomial-regression/Jq/polynomial-regression.jq new file mode 100644 index 0000000000..7023590262 --- /dev/null +++ b/Task/Polynomial-regression/Jq/polynomial-regression.jq @@ -0,0 +1,47 @@ +def mean: add/length; + +def inner_product($y): + . as $x + | reduce range(0; length) as $i (0; . + ($x[$i] * $y[$i])); + +# $x and $y should be arrays of the same length +# Emit { a, b, c, z} +# Attempt to avoid overflow +def polynomialRegression($x; $y): + ($x | length) as $length + | ($length * $length) as $l2 + | ($x | map(./$length)) as $xs + | ($xs | add) as $xm + | ($y | mean) as $ym + | ($xs | map(. * .) | add * $length) as $x2m + | ($x | map( (./$length) * . * .) | add) as $x3m + | ($xs | map(. * . | (.*.) ) | add * $l2 * $length) as $x4m + | ($xs | inner_product($y)) as $xym + | ($xs | map(. * .) | inner_product($y) * $length) as $x2ym + + | ($x2m - $xm * $xm) as $sxx + | ($xym - $xm * $ym) as $sxy + | ($x3m - $xm * $x2m) as $sxx2 + | ($x4m - $x2m * $x2m) as $sx2x2 + | ($x2ym - $x2m * $ym) as $sx2y + | {z: ([$x,$y] | transpose) } + | .b = ($sxy * $sx2x2 - $sx2y * $sxx2) / ($sxx * $sx2x2 - $sxx2 * $sxx2) + | .c = ($sx2y * $sxx - $sxy * $sxx2) / ($sxx * $sx2x2 - $sxx2 * $sxx2) + | .a = $ym - .b * $xm - .c * $x2m ; + +# Input: {a,b,c,z} +def report: + def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + def abc($x): .a + .b * $x + .c * $x * $x; + def print($p): "\($p[0] | lpad(3)) \($p[1] | lpad(4)) \(abc($p[0]) | lpad(5))"; + + "y = \(.a) + \(.b)x + \(.c)x^2\n", + " Input Approximation", + " x y y\u0302", + print(.z[]) ; + +def x: [range(0;11)]; +def y: [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]; + +polynomialRegression(x; y) +| report diff --git a/Task/Population-count/ABC/population-count.abc b/Task/Population-count/ABC/population-count.abc new file mode 100644 index 0000000000..9143a24f93 --- /dev/null +++ b/Task/Population-count/ABC/population-count.abc @@ -0,0 +1,25 @@ +HOW TO RETURN popcount n: + IF n=0: RETURN 0 + RETURN (n mod 2) + popcount (floor (n/2)) + +HOW TO REPORT evil n: + REPORT (popcount n) mod 2 = 0 + +HOW TO REPORT odious n: + REPORT (popcount n) mod 2 = 1 + +FOR i IN {0..29}: WRITE popcount (3 ** i) +WRITE / + +PUT {} IN evilnums +PUT {} IN odiousnums + +FOR n IN {0..59}: + SELECT: + evil n: INSERT n IN evilnums + odious n: INSERT n IN odiousnums + +FOR i IN {1..30}: WRITE evilnums item i +WRITE / +FOR i IN {1..30}: WRITE odiousnums item i +WRITE / diff --git a/Task/Population-count/Refal/population-count.refal b/Task/Population-count/Refal/population-count.refal new file mode 100644 index 0000000000..a5bbd78cdf --- /dev/null +++ b/Task/Population-count/Refal/population-count.refal @@ -0,0 +1,41 @@ +$ENTRY Go { + = > + > + >; +}; + +Gen { + 0 s.Fil s.Gen (s.State) = ; + s.N s.Fil s.Gen (s.State), + : (s.Next) s.Item, + : { + T = s.Item s.Fil s.Gen (s.Next)>; + F = ; + }; +}; + +Popcount { + 0 = 0; + s.N, : (s.R) s.B = <+ s.B >; +}; + +Pow3 { + s.N = (<* 3 s.N>) ; +}; + +Evil { + s.N, 2>: { + 0 = T; + 1 = F; + }; +}; + +Odious { + s.N, 2>: { + 0 = F; + 1 = T; + }; +}; + +All { s.X = T; } +Iota { s.N = (<+ 1 s.N>) s.N; } diff --git a/Task/Power-set/PascalABC.NET/power-set.pas b/Task/Power-set/PascalABC.NET/power-set.pas new file mode 100644 index 0000000000..bbbb0950b0 --- /dev/null +++ b/Task/Power-set/PascalABC.NET/power-set.pas @@ -0,0 +1,16 @@ +function AllSubSets(a: array of T; i: integer; lst: List): sequence of List; +begin + if i = a.Length then + begin + yield lst; + exit; + end; + lst.Add(a[i]); + yield sequence AllSubSets(a, i + 1, lst); + lst.RemoveAt(lst.Count-1); + yield sequence AllSubSets(a, i + 1, lst); +end; + +begin + AllSubSets(Arr(1..4),0,new List).Print; +end. diff --git a/Task/Price-fraction/Chipmunk-Basic/price-fraction.basic b/Task/Price-fraction/Chipmunk-Basic/price-fraction.basic new file mode 100644 index 0000000000..c528b1fa2f --- /dev/null +++ b/Task/Price-fraction/Chipmunk-Basic/price-fraction.basic @@ -0,0 +1,22 @@ +100 cls +110 data 10,18,26,32,38,44,50,54,58,62,66,70,74,78,82,86,90,94,98,100 +120 data 6,11,16,21,26,31,36,41,46,51,56,61,66,71,76,81,86,91,96 +130 dim od(21) +140 for i = 1 to 20 +150 read olddec +160 od(i) = olddec +170 next i +180 dim nd(20) +190 for j = 1 to 19 +200 read nuedec +210 nd(j) = nuedec +220 next j +230 for i = 1 to 100 +240 for j = 1 to ubound(nd)-1 +250 if i < nd(j) then exit for +260 next j +270 print using "#.##";(i/100);" -> "; +280 print using "#.##";(od(j)/100);chr$(9); +290 if i mod 5 = 0 then print +300 next i +310 end diff --git a/Task/Price-fraction/Langur/price-fraction-1.langur b/Task/Price-fraction/Langur/price-fraction-1.langur new file mode 100644 index 0000000000..d4550892e7 --- /dev/null +++ b/Task/Price-fraction/Langur/price-fraction-1.langur @@ -0,0 +1,33 @@ +val table = [ + {"low": 0.00, "high": 0.06, "use": 0.10}, + {"low": 0.06, "high": 0.11, "use": 0.18}, + {"low": 0.11, "high": 0.16, "use": 0.26}, + {"low": 0.16, "high": 0.21, "use": 0.32}, + {"low": 0.21, "high": 0.26, "use": 0.38}, + {"low": 0.26, "high": 0.31, "use": 0.44}, + {"low": 0.31, "high": 0.36, "use": 0.50}, + {"low": 0.36, "high": 0.41, "use": 0.54}, + {"low": 0.41, "high": 0.46, "use": 0.58}, + {"low": 0.46, "high": 0.51, "use": 0.62}, + {"low": 0.51, "high": 0.56, "use": 0.66}, + {"low": 0.56, "high": 0.61, "use": 0.70}, + {"low": 0.61, "high": 0.66, "use": 0.74}, + {"low": 0.66, "high": 0.71, "use": 0.78}, + {"low": 0.71, "high": 0.76, "use": 0.82}, + {"low": 0.76, "high": 0.81, "use": 0.86}, + {"low": 0.81, "high": 0.86, "use": 0.90}, + {"low": 0.86, "high": 0.91, "use": 0.94}, + {"low": 0.91, "high": 0.96, "use": 0.98}, + {"low": 0.96, "high": 1.00, "use": 1.00}, + ] + +val pricefrac = fn f: { + if f == 1.00: return 1.00 + for h in table { + if f >= h'low and f < h'high: return h'use + } + throw "no match" +} + +writeln pricefrac(0.17) +writeln pricefrac(0.71) diff --git a/Task/Price-fraction/Langur/price-fraction-2.langur b/Task/Price-fraction/Langur/price-fraction-2.langur new file mode 100644 index 0000000000..88ca5bf89e --- /dev/null +++ b/Task/Price-fraction/Langur/price-fraction-2.langur @@ -0,0 +1,35 @@ +val table = [ + # [low, use] + [0.00, 0.10], + [0.06, 0.18], + [0.11, 0.26], + [0.16, 0.32], + [0.21, 0.38], + [0.26, 0.44], + [0.31, 0.50], + [0.36, 0.54], + [0.41, 0.58], + [0.46, 0.62], + [0.51, 0.66], + [0.56, 0.70], + [0.61, 0.74], + [0.66, 0.78], + [0.71, 0.82], + [0.76, 0.86], + [0.81, 0.90], + [0.86, 0.94], + [0.91, 0.98], + [0.96, 1.00], + ] + +val pricefrac = fn f: { + if f >= table[-1][1] and f <= table[-1][2]: return table[-1][2] + + for t of len(table)-1 { + if f >= table[t][1] and f < table[t+1][1]: return table[t][2] + } + throw "no match" +} + +writeln pricefrac(0.17) +writeln pricefrac(0.71) diff --git a/Task/Price-fraction/Langur/price-fraction.langur b/Task/Price-fraction/Langur/price-fraction.langur deleted file mode 100644 index 6c1ee0d357..0000000000 --- a/Task/Price-fraction/Langur/price-fraction.langur +++ /dev/null @@ -1,26 +0,0 @@ -val .pricefrac = fn(.f) switch[and] .f { - case >= 0.00, < 0.06: 0.10 - case >= 0.06, < 0.11: 0.18 - case >= 0.11, < 0.16: 0.26 - case >= 0.16, < 0.21: 0.32 - case >= 0.21, < 0.26: 0.38 - case >= 0.26, < 0.31: 0.44 - case >= 0.31, < 0.36: 0.50 - case >= 0.36, < 0.41: 0.54 - case >= 0.41, < 0.46: 0.58 - case >= 0.46, < 0.51: 0.62 - case >= 0.51, < 0.56: 0.66 - case >= 0.56, < 0.61: 0.70 - case >= 0.61, < 0.66: 0.74 - case >= 0.66, < 0.71: 0.78 - case >= 0.71, < 0.76: 0.82 - case >= 0.76, < 0.81: 0.86 - case >= 0.81, < 0.86: 0.90 - case >= 0.86, < 0.91: 0.94 - case >= 0.91, < 0.96: 0.98 - case >= 0.96, <= 1.00: 1.00 - default: throw "bad data" -} - -writeln .pricefrac(0.17) -writeln .pricefrac(0.71) diff --git a/Task/Price-fraction/QB64/price-fraction.qb64 b/Task/Price-fraction/QB64/price-fraction.qb64 new file mode 100644 index 0000000000..c8ed1f47cc --- /dev/null +++ b/Task/Price-fraction/QB64/price-fraction.qb64 @@ -0,0 +1,19 @@ +Data 10,18,26,32,38,44,50,54,58,62,66,70,74,78,82,86,90,94,98,100 +Data 6,11,16,21,26,31,36,41,46,51,56,61,66,71,76,81,86,91,96 +Dim od(21) +For i = 1 To 20 + Read olddec + od(i) = olddec +Next i +Dim nd(20) +For j = 1 To 19 + Read nuedec + nd(j) = nuedec +Next j +For i = 1 To 100 + For j = 1 To UBound(nd) - 1 + If i < nd(j) Then Exit For + Next j + Print Using "#.## -> #.##"; (i / 100); (od(j) / 100); + If i Mod 5 = 0 Then Print Else Print Chr$(9); +Next i diff --git a/Task/Primality-by-trial-division/GW-BASIC/primality-by-trial-division.basic b/Task/Primality-by-trial-division/GW-BASIC/primality-by-trial-division.basic new file mode 100644 index 0000000000..e0c4cd0c6a --- /dev/null +++ b/Task/Primality-by-trial-division/GW-BASIC/primality-by-trial-division.basic @@ -0,0 +1,11 @@ +100 FOR I = 1 TO 99 +110 IF I < 2 THEN P = 0 : GOTO 180 +120 IF I = 2 THEN P = 1 : GOTO 180 +130 IF I MOD 2 = 0 THEN P = 0 : GOTO 180 +140 P = 1 +150 FOR J = 3 TO SQR(I) STEP 2 +160 IF I MOD J = 0 THEN P = 0 : GOTO 180 +170 NEXT J +180 IF P <> 0 THEN PRINT I; +190 NEXT I +200 END diff --git a/Task/Primality-by-trial-division/Langur/primality-by-trial-division-1.langur b/Task/Primality-by-trial-division/Langur/primality-by-trial-division-1.langur index 8f9728d4a2..747b0d4414 100644 --- a/Task/Primality-by-trial-division/Langur/primality-by-trial-division-1.langur +++ b/Task/Primality-by-trial-division/Langur/primality-by-trial-division-1.langur @@ -1,4 +1,6 @@ -val .isPrime = fn(.i) .i == 2 or .i > 2 and - not any fn(.x) .i div .x, pseries 2 .. .i ^/ 2 +val isPrime = fn(i) { + i == 2 or i > 2 and + not any(fn x:i div x, pseries(2 .. i ^/ 2)) +} -writeln filter .isPrime, series 100 +writeln filter(isPrime, series(100)) diff --git a/Task/Primality-by-trial-division/Langur/primality-by-trial-division-2.langur b/Task/Primality-by-trial-division/Langur/primality-by-trial-division-2.langur index 30818edf41..678610b891 100644 --- a/Task/Primality-by-trial-division/Langur/primality-by-trial-division-2.langur +++ b/Task/Primality-by-trial-division/Langur/primality-by-trial-division-2.langur @@ -1,15 +1,15 @@ -val .isPrime = fn(.i) { - val .n = abs(.i) - if .n <= 2: return .n == 2 +val isPrime = fn(i) { + val n = abs(i) + if n <= 2: return n == 2 - val .chkdiv = fn(.n, .i) { - if .i * .i <= .n { - return .n ndiv .i and self(.n, .i+2) + val chkdiv = fn(n, i) { + if i * i <= n { + return n ndiv i and fn((n, i+2)) } return true } - return .n ndiv 2 and .chkdiv(.n, 3) + return n ndiv 2 and chkdiv(n, 3) } -writeln filter .isPrime, series 100 +writeln filter(isPrime, series(100)) diff --git a/Task/Primality-by-trial-division/PascalABC.NET/primality-by-trial-division.pas b/Task/Primality-by-trial-division/PascalABC.NET/primality-by-trial-division.pas new file mode 100644 index 0000000000..fc3525df36 --- /dev/null +++ b/Task/Primality-by-trial-division/PascalABC.NET/primality-by-trial-division.pas @@ -0,0 +1,18 @@ +function IsPrime(N: integer): boolean; +begin + if N = 1 then + Result := False + else Result := True; + for var i:=2 to N.Sqrt.Round do + if N.Divs(i) then + begin + Result := False; + exit + end; +end; + +begin + for var i:=1 to 1000 do + if IsPrime(i) then + Print(i) +end. diff --git a/Task/Prime-decomposition/PascalABC.NET/prime-decomposition.pas b/Task/Prime-decomposition/PascalABC.NET/prime-decomposition.pas new file mode 100644 index 0000000000..fcc3fbc995 --- /dev/null +++ b/Task/Prime-decomposition/PascalABC.NET/prime-decomposition.pas @@ -0,0 +1,19 @@ +function Factors(N: BigInteger): List; +begin + var lst := new List; + if N = 1 then + lst.Add(N); + var i := 2bi; + while i * i <= N do + begin + while N mod i = 0 do + begin + lst.Add(i); + N := N div i; + end; + i += 1; + end; + if N >= 2 then + lst.Add(N); + Result := lst; +end; diff --git a/Task/Prime-decomposition/REXX/prime-decomposition-1.rexx b/Task/Prime-decomposition/REXX/prime-decomposition-1.rexx index e69de29bb2..dcbc1d8c1d 100644 --- a/Task/Prime-decomposition/REXX/prime-decomposition-1.rexx +++ b/Task/Prime-decomposition/REXX/prime-decomposition-1.rexx @@ -0,0 +1,82 @@ +/*REXX pgm does prime decomposition of a range of positive integers (with a prime count)*/ +Numeric Digits 1000 /*handle thousand digits For the powers*/ +Parse Arg bot top step base add /*get optional arguments from the C.L. */ +If bot='?' Then Do + Say 'rexx pfoo bot top step base add' + Exit + End +If bot=='' Then /* no arguments given */ + Parse Value 1 100 With bot top /* set default range .*/ +If top=='' Then top=bot /* process one number */ +If step=='' Then step=1 /* step=2 to process only odd numbers */ +If add =='' Then add=-1 /* for Mersenne tests */ +tell=top>0 /*If TOP is negative, suppress displays*/ +top=abs(top) +w=length(top) /*get maximum width For aligned display*/ +If base\=='' Then + w=length(base**top) /*will be testing powers of two later? */ +tag.=left('', 7) /*some literals: pad; prime (or not).*/ +tag.0='{unity}' +tag.1='[prime]' +Numeric Digits max(9,w+1) /*maybe increase the digits precision. */ +np=0 /*np: is the number of primes found.*/ +Do n=bot To top by step /*process a single number or a range. */ + ?=n + If base\=='' Then /*should we perform a 'Mersenne' test? */ + ?=base**n+add + pf=factr(?) /* get prime factors */ + f=words(pf) /* number of prime factors */ + If f=1 Then /* If the number is prime */ + np=np+1 /* Then bump prime counter */ + If tell Then + Say right(?,w) right('('f')',9) 'prime factors: ' tag.f pf + End /*n*/ +Say '' +ps='prime' +If f>1 Then ps=ps's' /*setup For proper English in sentence.*/ +Say right(np, w+9+1) ps 'found.' /*display the number of primes found. */ +Exit /*stick a fork in it, we're all done. */ +/*---------------------------------------------------------------------------*/ +factr: Procedure + Parse Arg x 1 d,pl /*set X, D to argument 1, pl to null */ + If x==1 Then Return '' /*handle the special case of X=1. */ + primes=2 3 5 7 + Do While primes>'' /* first check the small primes */ + Parse Var primes prime primes + Do While x//prime==0 + pl=pl prime + x=x%prime + End + End + r=isqrt(x) + Do j=11 by 6 To r /*insure that J isn't divisible by 3. */ + Parse var j '' -1 _ /*obtain the last decimal digit of J. */ + If _\==5 Then Do + Do While x//j==0 + pl=pl j + x=x%j + End /*maybe reduce by J. */ + End + If _ ==3 Then Iterate /*If next Y is divisible by 5? Skip. */ + y=j+2 + Do While x//y==0 + pl=pl y + x=x%y + End /*maybe reduce by y. */ + End /*j*/ + + If x==1 Then Return pl /*Is residual=unity? Then don't append.*/ + Return pl x /*return pl with appended residual.*/ + +isqrt: Procedure + Parse Arg x + x=abs(x) + Parse Value 0 x with lo hi + Do While lo<=hi + t=(lo+hi)%2 + If t**2>x Then + hi=t-1 + Else + lo=t+1 + End + Return t diff --git a/Task/Prime-decomposition/REXX/prime-decomposition-3.rexx b/Task/Prime-decomposition/REXX/prime-decomposition-3.rexx new file mode 100644 index 0000000000..86902ca626 --- /dev/null +++ b/Task/Prime-decomposition/REXX/prime-decomposition-3.rexx @@ -0,0 +1,69 @@ +/*REXX pgm does prime decomposition of a range of positive integers (with a prime count)*/ +call time('r') +Numeric Digits 1000 /*handle thousand digits For the powers*/ +Parse Arg bot top step base add /*get optional arguments from the C.L. */ +If bot='?' Then Do + Say 'rexx pfoo bot top step base add' + Exit + End +If bot=='' Then /* no arguments given */ + Parse Value 1 100 With bot top /* set default range .*/ +If top=='' Then top=bot /* process one number */ +If step=='' Then step=1 /* step=2 to process only odd numbers */ +If add =='' Then add=-1 /* for Mersenne tests */ +tell=top>0 /*If TOP is negative, suppress displays*/ +top=abs(top) +w=length(top) /*get maximum width For aligned display*/ +If base\=='' Then + w=length(base**top) /*will be testing powers of two later? */ +tag.=left('', 7) /*some literals: pad; prime (or not).*/ +tag.0='{unity}' +tag.1='[prime]' +Numeric Digits max(9,w+1) /*maybe increase the digits precision. */ +np=0 /*np: is the number of primes found.*/ +Do n=bot To top by step /*process a single number or a range. */ + ?=n + If base\=='' Then /*should we perform a 'Mersenne' test? */ + ?=base**n+add + pf=factr(?) /* get prime factors */ + f=words(pf) /* number of prime factors */ + If f=1 Then /* If the number is prime */ + np=np+1 /* Then bump prime counter */ + If tell Then + Say right(?,w) right('('f')',9) 'prime factors: ' tag.f pf + End /*n*/ +Say '' +ps='prime' +If f>1 Then ps=ps's' /*setup For proper English in sentence.*/ +Say right(np, w+9+1) ps 'found.' /*display the number of primes found. */ +say format(time('e'),,3) 'seconds' +Exit /*stick a fork in it, we're all done. */ +/*---------------------------------------------------------------------------*/ +Factr: +procedure expose glob. +arg x +primes = '2 3 5 7 11 13 17 19 23'; pl = '' +do n = 1 to words(primes) + prime = word(primes,n) + do while x//prime = 0 + pl = pl prime; x = x%prime + end +end +do j = 29 by 6 while j*j <= x + d = right(j,1) + if d <> 5 then do + do while x//j = 0 + pl = pl j; x = x%j + end + end + if d = 3 then + iterate + y = j+2 + do while x//y = 0 + pl = pl y; x = x%y + end +end +if x = 1 then + return pl +else + return pl x diff --git a/Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/Sidef/prime-numbers-whose-neighboring-pairs-are-tetraprimes.sidef b/Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/Sidef/prime-numbers-whose-neighboring-pairs-are-tetraprimes.sidef new file mode 100644 index 0000000000..bfef71add5 --- /dev/null +++ b/Task/Prime-numbers-whose-neighboring-pairs-are-tetraprimes/Sidef/prime-numbers-whose-neighboring-pairs-are-tetraprimes.sidef @@ -0,0 +1,34 @@ +func display(arr, p, f, g, type, limit, display_primes) { + + var s = arr.map(f).grep{.is_prime} + print "Found #{s.len.commify} primes under #{limit.commify} whose #{type} neighboring pair are tetraprimes" + + if (display_primes) { + say ':' + s.slices(10).each{.map { "%#{limit.len+1}s" % _ }.join.say } + } + + with (p) {|p| + var c = s.count {|a| is_div(g(a), p) || is_div(g(g(a)), p) } + say "\nof which #{c.commify} have a neighboring pair one of whose factors is #{p}.\n" + } + + var D = s.diffs + + func median(a) { + var l = a.len + var j = l>>1 + l.is_even ? ((a[j-1] + a[j]) >> 1) : a[j] + } + + say("Minimum gap between those #{s.len.commify} primes: ", D.min) + say("Median gap between those #{s.len.commify} primes: ", median(D.sort)) + say("Maximum gap between those #{s.len.commify} primes: ", D.max) + say '' +} + +for limit in (1e5, 1e6, 1e7) { + var arr = 4.squarefree_almost_primes(limit).cons(2).grep_2d{|a,b| b-a == 1 } + display(arr, 7, {.last.inc}, {.dec}, "preceding", limit, limit <= 1e5) + display(arr, 7, {.first.dec}, {.inc}, "following", limit, limit <= 1e5) +} diff --git a/Task/Priority-queue/Zig/priority-queue-1.zig b/Task/Priority-queue/Zig/priority-queue-1.zig index de2bc7ba6c..e92ec4a30d 100644 --- a/Task/Priority-queue/Zig/priority-queue-1.zig +++ b/Task/Priority-queue/Zig/priority-queue-1.zig @@ -24,21 +24,20 @@ const Task = struct { /// /// fn(T, T) bool const Comparator = struct { - fn maxCompare(a: Task, b: Task) bool { - return a.priority > b.priority; + fn maxCompare(_: void, a: Task, b: Task) std.math.Order { + return std.math.order(a.priority, b.priority); } - fn minCompare(a: Task, b: Task) bool { - return a.priority < b.priority; + fn minCompare(_: void, a: Task, b: Task) std.math.Order { + return std.math.order(a.priority, b.priority); } }; test "priority queue (max heap)" { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); - var allocator = &arena.allocator; - - var pq = PriorityQueue(Task).init(allocator, Comparator.maxCompare); + const allocator = arena.allocator(); + var pq = PriorityQueue(Task, void, Comparator.maxCompare).init(allocator, {}); defer pq.deinit(); try pq.add(Task.init(3, "Clear drains")); @@ -46,14 +45,14 @@ test "priority queue (max heap)" { try pq.add(Task.init(5, "Make tea")); try pq.add(Task.init(1, "Solve RC tasks")); try pq.add(Task.init(2, "Tax returns")); - testing.expectEqual(pq.count(), 5); + try testing.expectEqual(pq.count(), 5); std.debug.print("\n", .{}); // execute the tasks in decreasing order of priority while (pq.count() != 0) { const task = pq.remove(); - std.debug.print("Executing: {} (priority {})\n", .{ task.name, task.priority }); + std.debug.print("Executing: {s} (priority {d})\n", .{ task.name, task.priority }); } std.debug.print("\n", .{}); } @@ -61,9 +60,8 @@ test "priority queue (max heap)" { test "priority queue (min heap)" { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); - var allocator = &arena.allocator; - - var pq = PriorityQueue(Task).init(allocator, Comparator.minCompare); + const allocator = arena.allocator(); + var pq = PriorityQueue(Task, void, Comparator.minCompare).init(allocator, {}); defer pq.deinit(); try pq.add(Task.init(3, "Clear drains")); @@ -71,14 +69,14 @@ test "priority queue (min heap)" { try pq.add(Task.init(5, "Make tea")); try pq.add(Task.init(1, "Solve RC tasks")); try pq.add(Task.init(2, "Tax returns")); - testing.expectEqual(pq.count(), 5); + try testing.expectEqual(pq.count(), 5); std.debug.print("\n", .{}); // execute the tasks in increasing order of priority while (pq.count() != 0) { const task = pq.remove(); - std.debug.print("Executing: {} (priority {})\n", .{ task.name, task.priority }); + std.debug.print("Executing: {s} (priority {d})\n", .{ task.name, task.priority }); } std.debug.print("\n", .{}); } diff --git a/Task/Problem-of-Apollonius/11l/problem-of-apollonius.11l b/Task/Problem-of-Apollonius/11l/problem-of-apollonius.11l index fdec0e8c50..08843a16fe 100644 --- a/Task/Problem-of-Apollonius/11l/problem-of-apollonius.11l +++ b/Task/Problem-of-Apollonius/11l/problem-of-apollonius.11l @@ -1,11 +1,4 @@ -T Circle - Float x, y, r - - F (x, y, r) - .x = x - .y = y - .r = r - +T Circle((Float x, Float y, Float r)) F String() R ‘Circle(x=#., y=#., r=#.)’.format(.x, .y, .r) diff --git a/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy b/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy index fbde02ed3e..72b2614f28 100644 --- a/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy +++ b/Task/Problem-of-Apollonius/EasyLang/problem-of-apollonius.easy @@ -41,7 +41,7 @@ solve c1[] c2[] c3[] -1 -1 -1 r2[] print r2[] # proc circ x y r . . - linewidth 0.5 + text "" for a = 0 to 360 line x + sin a * r y + cos a * r . diff --git a/Task/Program-name/Ecstasy/program-name.ecstasy b/Task/Program-name/Ecstasy/program-name.ecstasy new file mode 100644 index 0000000000..5934b74a68 --- /dev/null +++ b/Task/Program-name/Ecstasy/program-name.ecstasy @@ -0,0 +1,7 @@ +module WhatIsMyName { + @Inject Console console; + + void run() { + console.print($"program name: {this:module}"); + } +} diff --git a/Task/Program-name/PascalABC.NET/program-name.pas b/Task/Program-name/PascalABC.NET/program-name.pas new file mode 100644 index 0000000000..5e999605d9 --- /dev/null +++ b/Task/Program-name/PascalABC.NET/program-name.pas @@ -0,0 +1,3 @@ +begin + Print(GetEXEFileName); +end. diff --git a/Task/Program-termination/PascalABC.NET/program-termination.pas b/Task/Program-termination/PascalABC.NET/program-termination.pas new file mode 100644 index 0000000000..8b8d6bcdc3 --- /dev/null +++ b/Task/Program-termination/PascalABC.NET/program-termination.pas @@ -0,0 +1,5 @@ +begin + if True then + Halt; + Print(1); +end. diff --git a/Task/Proper-divisors/Chipmunk-Basic/proper-divisors.basic b/Task/Proper-divisors/Chipmunk-Basic/proper-divisors.basic new file mode 100644 index 0000000000..6d789c8e51 --- /dev/null +++ b/Task/Proper-divisors/Chipmunk-Basic/proper-divisors.basic @@ -0,0 +1,35 @@ +100 cls +110 most = 1 +120 maxcount = 0 +130 print "The proper divisors of the following numbers are: ";chr$(10) +140 listproperdivisors(10) +150 for n = 2 to 20000 +160 rem It is extremely slow in this loop +170 count = countproperdivisors(n) +180 if count > maxcount then +190 maxcount = count +200 most = n +210 endif +220 next n +230 print +240 print most;" has the most proper divisors, namely ";maxcount +250 end +260 function countproperdivisors(number) +270 if number < 2 then countproperdivisors = 0 +280 count = 0 +290 for i = 1 to int(number/2) +300 if number mod i = 0 then count = count+1 +310 next i +320 countproperdivisors = count +330 end function +340 sub listproperdivisors(limit) +350 if limit < 1 then exit sub +360 for i = 1 to limit +370 print using "## ->";i; +380 if i = 1 then print " (None)"; +390 for j = 1 to int(i/2) +400 if i mod j = 0 then print " ";j; +410 next j +420 print +430 next i +440 end sub diff --git a/Task/Proper-divisors/EasyLang/proper-divisors.easy b/Task/Proper-divisors/EasyLang/proper-divisors.easy index 3e4ff18fbc..897419fa3e 100644 --- a/Task/Proper-divisors/EasyLang/proper-divisors.easy +++ b/Task/Proper-divisors/EasyLang/proper-divisors.easy @@ -1,7 +1,6 @@ -proc propdivs n . divs[] . - divs[] = [ ] +func[] propdivs n . if n < 2 - return + return [ ] . divs[] &= 1 sqr = sqrt n @@ -13,14 +12,13 @@ proc propdivs n . divs[] . . . . + return divs[] . for i to 10 - propdivs i d[] - write i & ":" - print d[] + print i & ":" & propdivs i . for i to 20000 - propdivs i d[] + d[] = propdivs i if len d[] > max max = len d[] maxi = i diff --git a/Task/Proper-divisors/Gambas/proper-divisors.gambas b/Task/Proper-divisors/Gambas/proper-divisors.gambas new file mode 100644 index 0000000000..7ce4d6643f --- /dev/null +++ b/Task/Proper-divisors/Gambas/proper-divisors.gambas @@ -0,0 +1,47 @@ +Sub ListProperDivisors(limit As Integer) + + If limit < 1 Then Return + For i As Integer = 1 To limit + Print Format$(i, "## ->"); + If i = 1 Then + Print " (None)" + Continue + End If + For j As Integer = 1 To i \ 2 + If i Mod j = 0 Then Print " "; j; + Next + Print + Next + +End Sub + +Function CountProperDivisors(number As Integer) As Integer + + If number < 2 Then Return 0 + Dim count As Integer = 0 + For i As Integer = 1 To number \ 2 + If number Mod i = 0 Then count += 1 + Next + Return count + +End Function + +Public Sub Main() + + Dim n As Integer, count As Integer, most As Integer = 1, maxCount As Integer = 0 + + Print "The proper divisors of the following numbers are: \n" + ListProperDivisors(10) + + For n As Integer = 2 To 20000 + count = CountProperDivisors(n) + If count > maxCount Then + maxCount = count + most = n + End If + Next + + Print + Print most; " has the most proper divisors, namely "; maxCount + +End diff --git a/Task/Proper-divisors/Langur/proper-divisors.langur b/Task/Proper-divisors/Langur/proper-divisors.langur index 18b386c99d..eec521545d 100644 --- a/Task/Proper-divisors/Langur/proper-divisors.langur +++ b/Task/Proper-divisors/Langur/proper-divisors.langur @@ -1,26 +1,26 @@ -val .getproper = fn(.x) for[=[]] .i of .x \ 2 { if .x div .i: _for ~= [.i] } -val .cntproper = fn(.x) for[=0] .i of .x \ 2 { if .x div .i: _for += 1 } +val getproper = fn x: for[=[]] i of x \ 2 { if x div i: _for ~= [i] } +val cntproper = fn x: for[=0] i of x \ 2 { if x div i: _for += 1 } -val .listproper = fn(.x) { - if .x < 1: return null - for[=""] .i of .x { - _for ~= $"\.i:2; -> \.getproper(.i);\n" +val listproper = fn(x) { + if x < 1: return null + for[=""] i of x { + _for ~= "{{i:2}} -> {{getproper(i)}}\n" } } writeln "The proper divisors of the following numbers are :" -writeln .listproper(10) +writeln listproper(10) -var .max = 0 -var .most = [] -for .n in 2 .. 20_000 { - val .cnt = .cntproper(.n) - if .cnt == .max { - .most = more .most, .n - } else if .cnt > .max { - .max, .most = .cnt, [.n] +var mx = 0 +var most = [] +for n in 2 .. 20_000 { + val cnt = cntproper(n) + if cnt == mx { + most = more(most, n) + } else if cnt > mx { + mx, most = cnt, [n] } } -writeln $"The following number(s) <= 20000 have the most proper divisors (\.max;)" -writeln .most +writeln "The following number(s) <= 20000 have the most proper divisors ({{mx}})" +writeln most diff --git a/Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/Jq/pseudo-random-numbers-combined-recursive-generator-mrg32k3a.jq b/Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/Jq/pseudo-random-numbers-combined-recursive-generator-mrg32k3a.jq new file mode 100644 index 0000000000..cd86b572e2 --- /dev/null +++ b/Task/Pseudo-random-numbers-Combined-recursive-generator-MRG32k3a/Jq/pseudo-random-numbers-combined-recursive-generator-mrg32k3a.jq @@ -0,0 +1,15 @@ +include "MRG32k3a" {search: "."}; # see above + +def task1: + foreach range(0; 5) as $i (seed(1234567); nextInt ) | .nextInt; + +def task2($n): + seed(987654321) + | reduce range(0; $n) as $i (.counts = [range(0;5)|0]; + nextFloat + | .counts[ (.nextFloat * 5) | floor ] += 1 ) + | "\nThe counts for \($n) repetitions are:", + (range(0;5) as $i | " \($i) : \(.counts[$i] // 0)"); + +task1, +task2(100000) diff --git a/Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W/pseudo-random-numbers-middle-square-method.alg b/Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W/pseudo-random-numbers-middle-square-method.alg new file mode 100644 index 0000000000..95b5c0d56c --- /dev/null +++ b/Task/Pseudo-random-numbers-Middle-square-method/ALGOL-W/pseudo-random-numbers-middle-square-method.alg @@ -0,0 +1,15 @@ +begin % generate random numbers by the middle-square method % + integer seed; + % returns the next middle-square random number % + integer procedure msRandom ; + begin + real realSeed; + realSeed := seed; + realSeed := ( realSeed * realSeed ) / 1000; + seed := entier( realSeed ) rem 1000000; + seed + end msRandom ; + % test the ms random procedure % + seed := 675248; + for i := 1 until 5 do write( msRandom ) +end. diff --git a/Task/Pseudo-random-numbers-PCG32/FreeBASIC/pseudo-random-numbers-pcg32.basic b/Task/Pseudo-random-numbers-PCG32/FreeBASIC/pseudo-random-numbers-pcg32.basic new file mode 100644 index 0000000000..3e3d26807a --- /dev/null +++ b/Task/Pseudo-random-numbers-PCG32/FreeBASIC/pseudo-random-numbers-pcg32.basic @@ -0,0 +1,49 @@ +#define floor(x) ((x*2.0-0.5) Shr 1) + +Const As Ulongint mask64 = &HFFFFFFFFFFFFFFFF +Const As Ulongint mask32 = &HFFFFFFFF +Const As Ulongint cte = 6364136223846793005 + +Dim Shared As Ulongint state, inc + +Function next_int() As Ulongint + ' return random 32 bit unsigned int + Dim As Ulongint old = state + state = ((old * cte) + inc) And mask64 + Dim As Ulongint xorshifted = (((old Shr 18) Xor old) Shr 27) And mask32 + Dim As Ulongint rot = (old Shr 59) And mask32 + Dim As Ulongint answer = (xorshifted Shr rot) Or (xorshifted Shl ((-rot) And 31)) + answer And= mask32 + Return answer +End Function + +Function next_float() As Double + ' return random float between 0 and 1 + Return next_int() / (2 ^ 32) +End Function + +Sub seed(seed_state As Ulongint, seed_sequence As Ulongint) + state = 0 + inc = ((seed_sequence Shl 1) Or 1) And mask64 + next_int() + state = (state + seed_state) And mask64 + next_int() +End Sub + +Dim As Integer i, hist(4) + +seed(42, 54) +For i = 1 To 5 + Print next_int() +Next i + +Print !"\nThe counts for 100,000 repetitions are:" +seed(987654321, 1) +For i = 1 To 100000 + hist(floor(next_float() * 5)) += 1 +Next i +For i = 0 To 4 + Print Using "hist(#) = #####"; i; hist(i) +Next i + +Sleep diff --git a/Task/Pseudo-random-numbers-PCG32/Jq/pseudo-random-numbers-pcg32.jq b/Task/Pseudo-random-numbers-PCG32/Jq/pseudo-random-numbers-pcg32.jq new file mode 100644 index 0000000000..3273a64d91 --- /dev/null +++ b/Task/Pseudo-random-numbers-PCG32/Jq/pseudo-random-numbers-pcg32.jq @@ -0,0 +1,50 @@ +include "bitwise" {search: "."}; # see above + +def Const: 6364136223846793005; +def Mask64: 18446744073709551615; # i.e. (1 | leftshift(64)) - 1 +def Mask32: 4294967295; # i.e. (1 | leftshift(32)) - 1 + +# An initialization function if you do not wish to use seed/2 +def rcg32: + {state: 9600629759793949339, # 0x853c49e6748fea9b + inc: 15726070495360670683 # 0xda3e39cb94b95bdb + }; + +# Input: {state, inc} +# Output: {state, inc, nextInt} +def nextInt: + .state as $old + | .state = bitwise_and($old * Const + .inc; Mask64) + | bitwise_and(( bitwise_xor($old | rightshift(18); $old) | rightshift(27)); Mask32) as $xorshifted + | bitwise_and($old|rightshift(59) ; Mask32) as $rot + | .nextInt = bitwise_and( + bitwise_or( + $xorshifted | rightshift($rot) ; + $xorshifted | leftshift( bitwise_and( 32 - $rot; 31) )) ; + Mask32) ; + +def nextFloat: + nextInt + | .nextFloat = .nextInt / pow(2;32); + +def seed($seedState; $seedSequence): + {state: 0, + inc: bitwise_and( bitwise_xor($seedSequence|leftshift(1); 1); Mask64) + } + | nextInt + | .state += $seedState + | nextInt; + +def task1($n): + foreach range(0; $n) as $i (seed(42; 54); nextInt) + | .nextInt; + +def task2($n): + reduce range(0; $n) as $i (seed(987654321; 1); + nextFloat + | .counts[((.nextFloat * 5)|floor)] += 1) + | "\nThe counts for \($n) repetitions are:", + (range(0; 5) as $i | "\($i) : \(.counts[$i])") ; + +task1(5), +task2(100000) diff --git a/Task/Pseudo-random-numbers-Splitmix64/FreeBASIC/pseudo-random-numbers-splitmix64.basic b/Task/Pseudo-random-numbers-Splitmix64/FreeBASIC/pseudo-random-numbers-splitmix64.basic new file mode 100644 index 0000000000..186a379f70 --- /dev/null +++ b/Task/Pseudo-random-numbers-Splitmix64/FreeBASIC/pseudo-random-numbers-splitmix64.basic @@ -0,0 +1,44 @@ +#define floor(x) ((x*2.0-0.5) Shr 1) + +Const As Ulongint mask64 = &HFFFFFFFFFFFFFFFF +Const As Ulongint C1 = &H9E3779B97F4A7C15 +Const As Ulongint C2 = &HBF58476D1CE4E5B9 +Const As Ulongint C3 = &H94D049BB133111EB + +Dim Shared As Ulongint state + +Sub seed(num As Ulongint) + state = num And mask64 +End Sub + +Function next_int() As Ulongint + ' return random int between 0 and 2^64 + Dim As Ulongint z = state + state += C1 + z = (z Xor (z Shr 30)) * C2 + z = (z Xor (z Shr 27)) * C3 + Return z Xor (z Shr 31) +End Function + +Function next_float() As Double + ' return random float between 0 and 1 + Return next_int() / (2 ^ 64) +End Function + +Dim As Integer i, hist(4) + +seed(1234567) +For i = 0 To 4 + Print next_int() +Next i + +Print !"\nThe counts for 100,000 repetitions are:" +seed(987654321) +For i = 1 To 100000 + hist(floor(next_float() * 5)) += 1 +Next i +For i = 0 To 4 + Print Using "hist(#) = #####"; i; hist(i) +Next i + +Sleep diff --git a/Task/Pseudo-random-numbers-Splitmix64/Swift/pseudo-random-numbers-splitmix64.swift b/Task/Pseudo-random-numbers-Splitmix64/Swift/pseudo-random-numbers-splitmix64.swift new file mode 100644 index 0000000000..3f208c5ae2 --- /dev/null +++ b/Task/Pseudo-random-numbers-Splitmix64/Swift/pseudo-random-numbers-splitmix64.swift @@ -0,0 +1,34 @@ +struct SplitMix64: RandomNumberGenerator { + var state: UInt64 + init(seed: UInt64) { + state = seed + } + mutating func next() -> UInt64 { + state &+= 0x9e3779b97f4a7c15 + var z = state + z = (z ^ (z >> 30)) &* 0xbf58476d1ce4e5b9 + z = (z ^ (z >> 27)) &* 0x94d049bb133111eb + return z ^ (z >> 31) + } + mutating func nextFloat() -> Float64 { + Float64(next() >> 11) * 0x1.0p-53 + } +} + +do { + var split = SplitMix64(seed: 1234567) + print(split) + for _ in 0..<5 { + print(split.next()) + } + split = .init(seed: 987654321) + print("\n\(split)") + var counts = [0, 0, 0, 0, 0] + for _ in 0..<100_000 { + let i = Int(split.nextFloat() * 5.0) + counts[i] += 1 + } + for (i, count) in zip(0..., counts) { + print("\(i): \(count)") + } +} diff --git a/Task/Pseudo-random-numbers-Xorshift-star/FreeBASIC/pseudo-random-numbers-xorshift-star.basic b/Task/Pseudo-random-numbers-Xorshift-star/FreeBASIC/pseudo-random-numbers-xorshift-star.basic new file mode 100644 index 0000000000..ea4bdfa5bf --- /dev/null +++ b/Task/Pseudo-random-numbers-Xorshift-star/FreeBASIC/pseudo-random-numbers-xorshift-star.basic @@ -0,0 +1,43 @@ +#define floor(x) ((x*2.0-0.5) Shr 1) + +Const As Ulongint mask64 = &HFFFFFFFFFFFFFFFF +Const As Ulongint mask32 = &HFFFFFFFF +Const As Ulongint cte = &H2545F4914F6CDD1D + +Dim Shared As Ulongint state + +Sub seed(num As Ulongint) + state = num And mask64 +End Sub + +Function next_int() As Ulongint + Dim As Ulongint x = state + x = (x Xor (x Shr 12)) And mask64 + x = (x Xor (x Shl 25)) And mask64 + x = (x Xor (x Shr 27)) And mask64 + state = x + Dim As Ulongint answer = (((x * cte) And mask64) Shr 32) And mask32 + Return answer +End Function + +Function next_float() As Double + Return next_int() / (2 ^ 32) +End Function + +Dim As Integer i, hist(4) + +seed(1234567) +For i = 1 To 5 + Print next_int() +Next i + +Print !"\nThe counts for 100,000 repetitions are:" +seed(987654321) +For i = 1 To 100000 + hist(floor(next_float() * 5)) += 1 +Next i +For i = 0 To 4 + Print Using "hist(#) = #####"; i; hist(i) +Next i + +Sleep diff --git a/Task/Pseudo-random-numbers-Xorshift-star/Jq/pseudo-random-numbers-xorshift-star.jq b/Task/Pseudo-random-numbers-Xorshift-star/Jq/pseudo-random-numbers-xorshift-star.jq new file mode 100644 index 0000000000..e25bec7dd0 --- /dev/null +++ b/Task/Pseudo-random-numbers-Xorshift-star/Jq/pseudo-random-numbers-xorshift-star.jq @@ -0,0 +1,38 @@ +include "bitwise" {search: "."}; # see above + +def Const: 2685821657736338717; # i.e. 0x2545F4914F6CDD1D +def Mask64: 18446744073709551615; # i.e. (1 | leftshift(64)) - 1 +def Mask32: 4294967295; # i.e. (1 | leftshift(32)) - 1 + +# Emit a suitable {state} object +def seed($num): + {state: bitwise_and($num; Mask64)}; + +# Input: {state} +# Output: {state, nextInt} +def nextInt: + .state |= bitwise_and(bitwise_xor(.; rightshift(12)); Mask64) + | .state |= bitwise_and(bitwise_xor(.; leftshift( 25)); Mask64) + | .state |= bitwise_and(bitwise_xor(.; rightshift(27)); Mask64) + | .nextInt = bitwise_and( bitwise_and(.state * Const; Mask64) | rightshift(32); Mask32) ; + +# Input: {state} +# Output: {state, nextInt, nextFloat} +def nextFloat: + nextInt + | .nextFloat = (.nextInt / (pow(2;32))); + +def task1: + foreach range(0; 5) as $i (seed(1234567); + nextInt; + .nextInt); + +def task2($max): + reduce range(0; $max) as $i (seed(987654321); + nextFloat + | ((.nextFloat * 5)|floor) as $n + | .counts[$n] += 1) + | "\nThe counts for \($max) repetitions are:", + (range(0; 5) as $i | "\($i) : \(.counts[$i])") ; + +task1, "", task2(100000) diff --git a/Task/Pythagorean-quadruples/EasyLang/pythagorean-quadruples.easy b/Task/Pythagorean-quadruples/EasyLang/pythagorean-quadruples.easy new file mode 100644 index 0000000000..11924ea6f1 --- /dev/null +++ b/Task/Pythagorean-quadruples/EasyLang/pythagorean-quadruples.easy @@ -0,0 +1,28 @@ +n = 2200 +n2 = n * n * 2 +len r[] n +len ab[] n2 +for a = 1 to n + a2 = a * a + for b = a to n + ab[a2 + b * b] = 1 + . +. +s = 3 +for c = 1 to n + s1 = s + s += 2 + s2 = s + for d = c + 1 to n + if ab[s1] = 1 + r[d] = 1 + . + s1 += s2 + s2 += 2 + . +. +for i to n + if r[i] = 0 + write i & " " + . +. diff --git a/Task/Pythagorean-triples/D/pythagorean-triples-1.d b/Task/Pythagorean-triples/D/pythagorean-triples-1.d index 38f73bbc30..3671e42f24 100644 --- a/Task/Pythagorean-triples/D/pythagorean-triples-1.d +++ b/Task/Pythagorean-triples/D/pythagorean-triples-1.d @@ -10,6 +10,6 @@ void main() @safe { .map!(t => tuple(t[0 .. 2].gcd == 1, t[])); auto xs = triples(100); - writeln("Up to 100 there are ", xs.count, " triples, ", - xs.filter!q{ a[0] }.count, " are primitive."); + writefln("\nUp to %d there are %d triples, %d are primitive.", N, xs.count, + xs.filter!q{ a[0] }.count); } diff --git a/Task/Queue-Definition/PascalABC.NET/queue-definition.pas b/Task/Queue-Definition/PascalABC.NET/queue-definition.pas new file mode 100644 index 0000000000..cea9c80af5 --- /dev/null +++ b/Task/Queue-Definition/PascalABC.NET/queue-definition.pas @@ -0,0 +1,39 @@ +type + Node = auto class + data: T; + next: Node; + end; + MyQueue = class + head,tail: Node; + public + procedure Enqueue(x: T); + begin + if tail = nil then + begin + tail := new Node(x,nil); + head := tail; + end + else + begin + tail.next := new Node(x,nil); + tail := tail.next; + end; + end; + function Dequeue(): T; + begin + Result := head.data; + head := head.Next; + if head = nil then + tail := nil; + end; + function IsEmpty: boolean := head = nil; + end; + +begin + var q := new MyQueue; + for var i:=1 to 5 do + q.Enqueue(i); + while not q.IsEmpty do + Print(q.Dequeue); + Print(q.IsEmpty); +end. diff --git a/Task/Queue-Usage/PascalABC.NET/queue-usage.pas b/Task/Queue-Usage/PascalABC.NET/queue-usage.pas new file mode 100644 index 0000000000..47db237571 --- /dev/null +++ b/Task/Queue-Usage/PascalABC.NET/queue-usage.pas @@ -0,0 +1,7 @@ +begin + var q := new Queue; + for var i:=1 to 5 do + q.Enqueue(i); + while q.Count > 0 do + Print(q.Dequeue); +end. diff --git a/Task/Quine/Odin/quine.odin b/Task/Quine/Odin/quine.odin new file mode 100644 index 0000000000..c64cb4fc05 --- /dev/null +++ b/Task/Quine/Odin/quine.odin @@ -0,0 +1,16 @@ +package quine + +import "core:fmt" + +main :: proc() { + q := `package quine + +import "core:fmt" + +main :: proc() {{ + q := %c%s%c + fmt.printf(q, 96, q, 96) +} +` + fmt.printf(q, 96, q, 96) +} diff --git a/Task/Quine/PascalABC.NET/quine.pas b/Task/Quine/PascalABC.NET/quine.pas new file mode 100644 index 0000000000..183c208ff5 --- /dev/null +++ b/Task/Quine/PascalABC.NET/quine.pas @@ -0,0 +1 @@ +## var a:='## var a:='';print(2*a[:12]+2*a[11:])';print(2*a[:12]+2*a[11:]) diff --git a/Task/Quine/Prog8/quine.prog8 b/Task/Quine/Prog8/quine.prog8 new file mode 100644 index 0000000000..e84b6a1c3b --- /dev/null +++ b/Task/Quine/Prog8/quine.prog8 @@ -0,0 +1,9 @@ +%import textio +main { +sub start() { str[] s = [ +"%import textio","main {","sub start() { str[] s = [","]","ubyte i","for i in 0 to 2 { txt.print(s[i]) txt.nl() }","for i in 0 to 8 { txt.chrout(34) txt.print(s[i]) txt.chrout(34) if i<8 txt.chrout(44) }","for i in 3 to 8 { txt.print(s[i]) txt.nl() } }","}"] +ubyte i +for i in 0 to 2 { txt.print(s[i]) txt.nl() } +for i in 0 to 8 { txt.chrout(34) txt.print(s[i]) txt.chrout(34) if i<8 txt.chrout(44) } +for i in 3 to 8 { txt.print(s[i]) txt.nl() } } +} diff --git a/Task/Quine/Uxntal/quine.uxnatl b/Task/Quine/Uxntal/quine.uxnatl new file mode 100644 index 0000000000..ab462458cb --- /dev/null +++ b/Task/Quine/Uxntal/quine.uxnatl @@ -0,0 +1,16 @@ +|100 + ;q DUP2 print quine +BRK + +@quine + LDAk DUP #04 SFT DUP #0a LTH ?{ #27 ADD } #30 ADD #18 DEO + #0f AND DUP #0a LTH ?{ #27 ADD } #30 ADD #18 DEO #2018 DEO + INC2 LDAk ?quine POP2 + #3018 DEO #3018 DEO #0a18 DEO +JMP2r + +@print + LDAk #18 DEO INC2 LDAk ?print POP2 +JMP2r + +@q 7c 31 30 30 0a 09 3b 71 20 44 55 50 32 20 70 72 69 6e 74 20 71 75 69 6e 65 0a 42 52 4b 0a 0a 40 71 75 69 6e 65 0a 09 4c 44 41 6b 20 44 55 50 20 23 30 34 20 53 46 54 20 44 55 50 20 23 30 61 20 4c 54 48 20 3f 7b 20 23 32 37 20 41 44 44 20 7d 20 23 33 30 20 41 44 44 20 23 31 38 20 44 45 4f 0a 09 23 30 66 20 41 4e 44 20 44 55 50 20 23 30 61 20 4c 54 48 20 3f 7b 20 23 32 37 20 41 44 44 20 7d 20 23 33 30 20 41 44 44 20 23 31 38 20 44 45 4f 20 23 32 30 31 38 20 44 45 4f 0a 09 49 4e 43 32 20 4c 44 41 6b 20 3f 71 75 69 6e 65 20 50 4f 50 32 0a 09 23 33 30 31 38 20 44 45 4f 20 23 33 30 31 38 20 44 45 4f 20 23 30 61 31 38 20 44 45 4f 0a 4a 4d 50 32 72 0a 0a 40 70 72 69 6e 74 0a 09 4c 44 41 6b 20 23 31 38 20 44 45 4f 20 49 4e 43 32 20 4c 44 41 6b 20 3f 70 72 69 6e 74 20 50 4f 50 32 0a 4a 4d 50 32 72 0a 0a 40 71 20 00 diff --git a/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-1.pas b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-1.pas new file mode 100644 index 0000000000..84b0e4c1d0 --- /dev/null +++ b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-1.pas @@ -0,0 +1 @@ +var s := 'Hello'; diff --git a/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-2.pas b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-2.pas new file mode 100644 index 0000000000..bd43ef17c8 --- /dev/null +++ b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-2.pas @@ -0,0 +1 @@ +var s := 'd''Artagnan'; // d'Artagnan diff --git a/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-3.pas b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-3.pas new file mode 100644 index 0000000000..1c41e16935 --- /dev/null +++ b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-3.pas @@ -0,0 +1,2 @@ +var (a,b) := (3,5); +var s := $'{a} + {b} = {a + b}'; diff --git a/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-4.pas b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-4.pas new file mode 100644 index 0000000000..3cc41c47bd --- /dev/null +++ b/Task/Quoting-constructs/PascalABC.NET/quoting-constructs-4.pas @@ -0,0 +1,5 @@ +var s := ''' + This is a + multiline + string + '''; diff --git a/Task/RIPEMD-160/Java/ripemd-160-2.java b/Task/RIPEMD-160/Java/ripemd-160-2.java index 5c025e6737..5ffad2ad52 100644 --- a/Task/RIPEMD-160/Java/ripemd-160-2.java +++ b/Task/RIPEMD-160/Java/ripemd-160-2.java @@ -50,7 +50,7 @@ final class RIPEMD160 { } private static byte[] addPadding(String aMessage) { - byte[] bytes = aMessage.getBytes(StandardCharsets.UTF_8); + byte[] bytes = aMessage.getBytes(StandardCharsets.ISO_8859_1); bytes = Arrays.copyOf(bytes, bytes.length + 1); bytes[bytes.length - 1] = (byte) 0x80; diff --git a/Task/RPG-attributes-generator/Uiua/rpg-attributes-generator.uiua b/Task/RPG-attributes-generator/Uiua/rpg-attributes-generator.uiua new file mode 100644 index 0000000000..a7ac39bb69 --- /dev/null +++ b/Task/RPG-attributes-generator/Uiua/rpg-attributes-generator.uiua @@ -0,0 +1,4 @@ +Attr ← (/+↘1⊏⍏.⌈×6∵⋅⚂⊚4) +Attrs ← (∵⋅Attr⊚6) +Valid ← ×⊃(>1/+>14|>75/+) +⍢◌(¬Valid.Attrs) diff --git a/Task/Radical-of-an-integer/PascalABC.NET/radical-of-an-integer.pas b/Task/Radical-of-an-integer/PascalABC.NET/radical-of-an-integer.pas new file mode 100644 index 0000000000..c9dc8df377 --- /dev/null +++ b/Task/Radical-of-an-integer/PascalABC.NET/radical-of-an-integer.pas @@ -0,0 +1,41 @@ +function Factors(N: integer): List; +begin + var lst := new List; + var i := 2; + while i * i <= N do + begin + while N.Divs(i) do + begin + if i not in lst then + lst.Add(i); + N := N div i; + end; + i += 1; + end; + if N >= 2 then + lst.Add(N); + Result := lst; +end; + +function Radical(x: integer) := Factors(x).Product; + +begin + for var i:=1 to 50 do + begin + Write(Radical(i):3); + if i mod 10 = 0 then + Writeln; + end; + Writeln; + + Writeln('Radical(99999) = ',Radical(99999)); + Writeln('Radical(499999) = ',Radical(499999)); + Writeln('Radical(999999) = ',Radical(999999)); + Writeln; + + var a := |0| *8; + for var i:=1 to 1000000 do + a[Factors(i).Count] += 1; + for var i:=0 to 7 do + Writeln($'{i}: {a[i]}'); +end. diff --git a/Task/Radical-of-an-integer/REXX/radical-of-an-integer.rexx b/Task/Radical-of-an-integer/REXX/radical-of-an-integer-1.rexx similarity index 93% rename from Task/Radical-of-an-integer/REXX/radical-of-an-integer.rexx rename to Task/Radical-of-an-integer/REXX/radical-of-an-integer-1.rexx index 446959e900..f1bce2f21a 100644 --- a/Task/Radical-of-an-integer/REXX/radical-of-an-integer.rexx +++ b/Task/Radical-of-an-integer/REXX/radical-of-an-integer-1.rexx @@ -1,4 +1,8 @@ /* REXX */ +parse version version; say version 'Intel i7 5GHz' +say 'Radicals for an integer = product of distinct prime factors' +say 'Version 1: tailor-made procedures' +say call setp Numeric Digits 100 /* 1. Radicals from 1 to 50 */ diff --git a/Task/Radical-of-an-integer/REXX/radical-of-an-integer-2.rexx b/Task/Radical-of-an-integer/REXX/radical-of-an-integer-2.rexx new file mode 100644 index 0000000000..0e51541db3 --- /dev/null +++ b/Task/Radical-of-an-integer/REXX/radical-of-an-integer-2.rexx @@ -0,0 +1,361 @@ +/* REXX */ +arg n +if n = '' then + n = 1000000 +numeric digits 100 +parse version version; say version 'Intel i7 5GHz' +say 'Radicals for an integer = product of distinct prime factors' +say 'Version 2: generic procedures' +say +say 'Radicals for 1..50:' +ol = '' +do i = 1 to 50 + ol = ol||Right(Radical(i),5) + if i//10 = 0 then do + say ol; ol = '' + end +end +say +say 'Radicals for:' +say '99999 =' Radical(99999) +say '499999 =' Radical(499999) +say '999999 =' Radical(999999) +say +s = n/10; r = ISqrt(n); radi. = 0; glob. = '' +say 'Getting distribution list:' +call Time('r') +do i = 1 to n + call Radical(i) + u = glob.ufactor.0 + radi.u = radi.u+1 + if i//s = 0 then + say Right(i,7) Format(Time('e'),,3) 'seconds' +end +say +say 'Distribution for first' n 'radicals over number of factors:' +do i = 0 to 10 + say Right(i,2) Right(radi.i,6) +end +say +say 'Getting primes up to' n':' +call Time('r') +pr = Primes(n) +say 'Took' Format(Time('e'),,3) 'seconds' +say +say 'Getting powers of primes up to' r':' +call Time('r') +pw = 0 +do i = 1 + p1 = glob.prime.i + if p1 > r then + leave + p2 = p1 + do forever + p2 = p2*p1 + if p2 > n then + leave + pw = pw+1 + end +end +say 'Took' Format(Time('e'),,3) 'seconds' +say +say 'Primes' Format(pr,6) +say 'Powers' Format(pw,6) +say ' -----' +say 'Total ' Format(pr+pw,6) +exit + +Radical: +/* Radical function = product of unique prime factors */ +procedure expose glob. +arg x +/* Validity */ +if \ Whole(x) then + return 'X' +if x < 1 then + return 'X' +/* Get unique factors */ +n = Ufactors(x) +/* Calculate product */ +y = 1 +do i = 1 to n + y = y*glob.ufactor.i +end +return y + +Ufactors: +/* Unique factors */ +procedure expose glob. +arg x +/* Validity */ +if \ Datatype(x,'w') then + return 'X' +if x < 1 then + return 'X' +/* Fast values */ +if x = 1 then do + glob.ufactor.0 = 0 + return 0 +end +if x < 4 then do + glob.ufactor.1 = x + glob.ufactor.0 = 1 + return 1 +end +if Prime(x) then do + glob.ufactor.1 = x + glob.ufactor.0 = 1 + return 1 +end +/* Check low factors */ +n = 0; v = 0 +pr = '2 3 5 7 11 13 17 19 23' +do i = 1 to Words(pr) + pn = Word(pr,i) + do while x//pn = 0 + if pn <> v then do + n = n+1; glob.ufactor.n = pn; v = pn + end + x = x%pn + end +end +/* Check higher factors */ +do j = 29 by 6 while j*j <= x + p = Right(j,1) + if p <> 5 then do + do while x//j = 0 + if j <> v then do + n = n+1; glob.ufactor.n = j; v = j + end + x = x%j + end + end + if p = 3 then + iterate + y = j+2 + do while x//y = 0 + if y <> v then do + n = n+1; glob.ufactor.n = y; v = y + end + x = x%y + end +end +/* Last factor */ +if x > 1 then do + if x <> v then do + n = n+1; glob.ufactor.n = x + end +end +glob.ufactor.0 = n +/* Return number of factors */ +return n + +Isqrt: +/* Integer square root Floor(x^(1/2)) function */ +procedure expose glob. +arg x +/* Validity */ +if x < 0 then + return 'X' +/* Fast values */ +if x < 1 then + return 0 +if x < 4 then + return 1 +if x < 9 then + return 2 +/* Uses only integers */ +x = x%1; q = 1 +do until q > x + q = q*4 +end +y = 0 +do while q > 1 + q = q%4; t = x-y-q; y = y%2 + if t >= 0 then do + x = t; y = y+q + end +end +return y + +Powermod: +/* Power modulus x^y mod z function */ +procedure expose glob. +arg x,y,z +/* Validity */ +if \ Whole(x) then + return 'X' +if \ Whole(y) then + return 'X' +if \ Whole(z) then + return 'X' +if x < 0 then + return 'X' +if y < 0 then + return 'X' +if z < 1 then + return 'X' +/* Fast values */ +if z = 1 then + return 0 +/* Binary method */ +numeric digits Max(Length(Format(x,,,0)),Length(Format(y,,,0)),2*Length(Format(z,,,0))) +b = x//z; r = 1 +do while y > 0 + if y//2 then + r = r*x//z + x = x*x//z; y = y%2 +end +return r + +Prime: +/* Is a number prime? function */ +procedure expose glob. +arg x +/* Validity */ +if \ Whole(x) then + return 'X' +if x < 2 then + return 'X' +/* Low primes also used as deterministic witnesses */ +lp = '2 3 5 7 11 13 17 19 23 29 31 37 41' +/* Fast values */ +if x < 42 then do + if Wordpos(x,lp) = 0 then + return 0 + else + return 1 +end +if x//2 = 0 then + return 0 +if x//3 = 0 then + return 0 +if Right(x,1) = 5 then + return 0 +/* Miller-Rabin primality test */ +numeric digits 2*Length(x) +d = x-1; e = d +/* Reduce x-1 by factors of 2 */ +do s = -1 while d//2 = 0 + d = d%2 +end +/* Thresholds deterministic witnesses */ +th = '2047 1373653 25326001 3215031751 2152302898747 3474749660383 341550071728321 0 ', +|| '3825123056546413051 0 0 318665857834031151167461 3317044064679887385961981 ' +w = Words(th) +/* Up to 13 deterministic trials */ +if x < Word(th,w) then do + do k = 1 to w + if x < Word(th,k) then + leave + end +end +/* or 3 probabilistic trials */ +else do + lp = '' + do k = 1 to 3 + r = Rand(2,e)/1; lp = lp||r||' ' + end + k = k-1 +end +/* Algorithm using generated witnesses */ +do k = 1 to k + a = Word(lp,k); y = Powermod(a,d,x) + if y = 1 then + iterate + if y = e then + iterate + do s + y = (y*y)//x + if y = 1 then + return 0 + if y = e then + leave + end + if y <> e then + return 0 +end +return 1 + +Rand: +/* Random number 12 digits precision function */ +procedure expose glob. +arg x,y +/* Validity */ +if x <> '' then do + if \ Whole(x) then + return 'X' + if \ Whole(y) then + return 'X' + if x >= y then + return 'X' +end +/* Fixed precision */ +p = Digits(); numeric digits 30 +/* Get and save first seed from system Date and Time */ +if glob.rand = '' then do + a = Date('s'); b = Time('l') + glob.rand = Substr(b,10,3)||Substr(b,7,2)||Substr(b,4,2)||Substr(b,1,2)||Substr(a,7,2)||Substr(a,5,2)||Substr(a,3,2) +end +/* Calculate next random number method HP calculators */ +glob.rand = Right((glob.rand*2851130928467),15) +/* Uniform deviate [0,1) */ +z = '0.'Left(glob.rand,Length(glob.rand)-3) +numeric digits 12 +if x = '' then + return z/1 +else + return Floor(z*(y+1-x)+x) + +Whole: +/* Is a number integer? function */ +procedure expose glob. +arg x +/* Formula */ +return Datatype(x,'w') + +Primes: +/* Prime numbers */ +procedure expose glob. +arg x +/* Validity */ +if Datatype(x,'w') = 0 then + return 'X' +if x < 1 then + return 'X' +/* Fast values */ +if x = 1 then do + glob.prime.0 = 0 + return 0 +end +if x < 101 then do + p = '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 999' + do n = 1 to Words(p) + w = Word(p,n) + if w > x then do + n = n-1 + leave + end + glob.prime.n = w + end + glob.prime.0 = n + return n +end +/* Wheeled sieve of Eratosthenes */ +z. = 1 +do i = 3 by 2 to x while i*i <= x + if z.i = 1 then do + do j = i*3 by i+i to x + z.j = 0 + end + end +end +/* Save results */ +n = 1; glob.prime.1 = 2 +do i = 3 by 2 to x + if z.i = 1 then do + n = n+1; glob.prime.n = i + end +end +glob.prime.0 = n +return n diff --git a/Task/Ramer-Douglas-Peucker-line-simplification/BASIC256/ramer-douglas-peucker-line-simplification.basic b/Task/Ramer-Douglas-Peucker-line-simplification/BASIC256/ramer-douglas-peucker-line-simplification.basic new file mode 100644 index 0000000000..f12c8cf84f --- /dev/null +++ b/Task/Ramer-Douglas-Peucker-line-simplification/BASIC256/ramer-douglas-peucker-line-simplification.basic @@ -0,0 +1,67 @@ +arraybase 1 +global matriz +dim matriz(10, 3) +matriz[ 1, 1] = 0 : matriz[ 1, 2] = 0 : matriz[ 1, 3] = 0 +matriz[ 2, 1] = 1 : matriz[ 2, 2] = 0.1 : matriz[ 2, 3] = 0 +matriz[ 3, 1] = 2 : matriz[ 3, 2] = -0.1 : matriz[ 3, 3] = 0 +matriz[ 4, 1] = 3 : matriz[ 4, 2] = 5 : matriz[ 4, 3] = 0 +matriz[ 5, 1] = 4 : matriz[ 5, 2] = 6 : matriz[ 5, 3] = 0 +matriz[ 6, 1] = 5 : matriz[ 6, 2] = 7 : matriz[ 6, 3] = 0 +matriz[ 7, 1] = 6 : matriz[ 7, 2] = 8.1 : matriz[ 7, 3] = 0 +matriz[ 8, 1] = 7 : matriz[ 8, 2] = 9 : matriz[ 8, 3] = 0 +matriz[ 9, 1] = 8 : matriz[ 9, 2] = 9 : matriz[ 9, 3] = 0 +matriz[10, 1] = 9 : matriz[10, 2] = 9 : matriz[10, 3] = 0 + +call DRDP(matriz, 1, 10, 1) + +print "Remaining points after simplifying:" +matriz[1, 3] = true +matriz[10, 3] = true +for i = 1 to matriz[?][] + if matriz[i, 3] = true then print "(";matriz[i, 1];", "; matriz[i, 2];") "; +next i +end + +function DistanciaPerpendicular(tabla, i, ini, fin) + dx = tabla[fin, 1] - tabla[ini, 1] + dy = tabla[fin, 2] - tabla[ini, 2] + + #Normalise + mag = (dx^2 + dy^2)^0.5 + if mag > 0 then dx /= mag : dy /= mag + + pvx = tabla[i, 1] - tabla[ini, 1] + pvy = tabla[i, 2] - tabla[ini, 2] + + #Get dot product (project pv onto normalized direction) + pvdot = dx * pvx + dy * pvy + + #Scale line direction vector + dsx = pvdot * dx + dsy = pvdot * dy + + #Subtract this from pv + ax = pvx - dsx + ay = pvy - dsy + return (ax^2 + ay^2)^0.5 +end function + +subroutine DRDP(matriz, ini, fin, epsilon) + dmax = 0 + + # Find the point with the maximum distance + if matriz[?][] < 2 then print "Not enough points to simplify": end + + for i = ini + 1 to fin + d = DistanciaPerpendicular(matriz, i, ini, fin) + if d > dmax then indice = i : dmax = d + next + + # If max distance is greater than epsilon, recursively simplify + if dmax > epsilon then + matriz[indice, 3] = true + # Recursive call + call DRDP(matriz, ini, indice, epsilon) + call DRDP(matriz, indice, fin, epsilon) + end if +end subroutine diff --git a/Task/Ramer-Douglas-Peucker-line-simplification/Jq/ramer-douglas-peucker-line-simplification.jq b/Task/Ramer-Douglas-Peucker-line-simplification/Jq/ramer-douglas-peucker-line-simplification.jq new file mode 100644 index 0000000000..0d819ce0c1 --- /dev/null +++ b/Task/Ramer-Douglas-Peucker-line-simplification/Jq/ramer-douglas-peucker-line-simplification.jq @@ -0,0 +1,29 @@ +def Point($x;$y): {x:$x, y:$y}; # jq and gojq allow: {$x,$y} + +def ppArray: + def pp: "(\(.x), \(.y))"; + "[" + (map(pp) | join(", ")) + "]"; + +def rdp($eps): + . as $l + | {x: 0, + dMax: -1} + | .p1 = $l[0] # first + | .p2 = $l[-1] # last + | (.p2.x - .p1.x) as $x21 + | (.p2.y - .p1.y) as $y21 + | reduce range(1; ($l|length)) as $i (.; + .p = $l[$i] + | ( ($y21*.p.x - $x21*.p.y + .p2.x*.p1.y - .p2.y*.p1.x) | length) as $d # abs ~ length + | if $d > .dMax then .x += 1 | .dMax = $d end ) + | if .dMax > $eps + then ($l[0: 1+.x]|rdp($eps)) + ($l[.x:]|rdp(eps))[1:] + else [$l[0], $l[-1]] + end; + +def points: [ + Point(0; 0), Point(1; 0.1), Point(2; -0.1), Point(3; 5), Point(4; 6), + Point(5; 7), Point(6; 8.1), Point(7; 9), Point(8; 9), Point(9; 9) +]; + +points | rdp(1) | ppArray diff --git a/Task/Ramer-Douglas-Peucker-line-simplification/QBasic/ramer-douglas-peucker-line-simplification.basic b/Task/Ramer-Douglas-Peucker-line-simplification/QBasic/ramer-douglas-peucker-line-simplification.basic new file mode 100644 index 0000000000..eb66842ad5 --- /dev/null +++ b/Task/Ramer-Douglas-Peucker-line-simplification/QBasic/ramer-douglas-peucker-line-simplification.basic @@ -0,0 +1,67 @@ +DECLARE SUB DRDP (ListaDePuntos() AS DOUBLE, ini AS INTEGER, fin AS INTEGER, epsilon AS DOUBLE) +DECLARE FUNCTION DistanciaPerpendicular! (tabla() AS DOUBLE, i AS INTEGER, ini AS INTEGER, fin AS INTEGER) + +CONST True = -1 +DIM matriz(1 TO 10, 1 TO 3) AS DOUBLE +DATA 0,0,1,0.1,2,-0.1,3,5,4,6,5,7,6,8.1,7,9,8,9,9,9 +FOR i = LBOUND(matriz) TO UBOUND(matriz) + READ matriz(i, 1), matriz(i, 2) +NEXT i + +CALL DRDP(matriz(), 1, 10, 1) + +PRINT "Remaining points after simplifying:" +matriz(1, 3) = True: matriz(10, 3) = True +FOR i = LBOUND(matriz) TO UBOUND(matriz) + IF matriz(i, 3) THEN PRINT "("; matriz(i, 1); ", "; matriz(i, 2); ") "; +NEXT i +END + +FUNCTION DistanciaPerpendicular (tabla() AS DOUBLE, i AS INTEGER, ini AS INTEGER, fin AS INTEGER) + DIM dx AS DOUBLE, dy AS DOUBLE, mag AS DOUBLE, pvx AS DOUBLE, pvy AS DOUBLE + DIM pvdot AS DOUBLE, dsx AS DOUBLE, dsy AS DOUBLE, ax AS DOUBLE, ay AS DOUBLE + + dx = tabla(fin, 1) - tabla(ini, 1) + dy = tabla(fin, 2) - tabla(ini, 2) + + 'Normalise + mag = (dx ^ 2 + dy ^ 2) ^ .5 + IF mag > 0 THEN dx = dx / mag: dy = dy / mag + + pvx = tabla(i, 1) - tabla(ini, 1) + pvy = tabla(i, 2) - tabla(ini, 2) + + 'Get dot product (project pv onto normalized direction) + pvdot = dx * pvx + dy * pvy + + 'Scale line direction vector + dsx = pvdot * dx + dsy = pvdot * dy + + 'Subtract this from pv + ax = pvx - dsx + ay = pvy - dsy + + DistanciaPerpendicular = (ax ^ 2 + ay ^ 2) ^ .5 +END FUNCTION + +SUB DRDP (ListaDePuntos() AS DOUBLE, ini AS INTEGER, fin AS INTEGER, epsilon AS DOUBLE) + DIM dmax AS DOUBLE, d AS DOUBLE + DIM indice AS INTEGER, i AS INTEGER + ' Find the point with the maximum distance + + IF UBOUND(ListaDePuntos) < 2 THEN PRINT "Not enough points to simplify": END + + FOR i = ini + 1 TO fin + d = DistanciaPerpendicular(ListaDePuntos(), i, ini, fin) + IF d > dmax THEN indice = i: dmax = d + NEXT + + ' If max distance is greater than epsilon, recursively simplify + IF dmax > epsilon THEN + ListaDePuntos(indice, 3) = True + ' Recursive call + CALL DRDP(ListaDePuntos(), ini, indice, epsilon) + CALL DRDP(ListaDePuntos(), indice, fin, epsilon) + END IF +END SUB diff --git a/Task/Random-numbers/ANSI-BASIC/random-numbers.basic b/Task/Random-numbers/ANSI-BASIC/random-numbers.basic new file mode 100644 index 0000000000..2bb7a7c699 --- /dev/null +++ b/Task/Random-numbers/ANSI-BASIC/random-numbers.basic @@ -0,0 +1,19 @@ +100 REM Random numbers +110 RANDOMIZE +120 DEF RandomNormal = COS(2 * PI * RND) * SQR(-2 * LOG(RND)) +130 DIM R(0 TO 999) +140 LET Sum = 0 +150 FOR I = 0 TO 999 +160 LET R(I) = 1 + RandomNormal / 2 +170 LET Sum = Sum + R(I) +180 NEXT I +190 LET Mean = Sum / 1000 +200 LET Sum = 0 +210 FOR I = 0 TO 999 +220 LET Sum = Sum + (R(I) - Mean) ^ 2 +230 NEXT I +240 LET SD = SQR(Sum / 1000) +250 PRINT "Mean is "; Mean +260 PRINT "Standard Deviation is"; SD +270 PRINT +280 END diff --git a/Task/Random-numbers/QuickBASIC/random-numbers.basic b/Task/Random-numbers/QuickBASIC/random-numbers.basic new file mode 100644 index 0000000000..42387d6e82 --- /dev/null +++ b/Task/Random-numbers/QuickBASIC/random-numbers.basic @@ -0,0 +1,7 @@ +RANDOMIZE TIMER 'seeds random number generator with the system time +pi = 3.141592653589793# +DIM a(1 TO 1000) AS DOUBLE +CLS +FOR i = 1 TO 1000 + a(i) = 1 + SQR(-2 * LOG(RND)) * COS(2 * pi * RND) +NEXT i diff --git a/Task/Random-numbers/Uiua/random-numbers.uiua b/Task/Random-numbers/Uiua/random-numbers.uiua new file mode 100644 index 0000000000..d5343a09dc --- /dev/null +++ b/Task/Random-numbers/Uiua/random-numbers.uiua @@ -0,0 +1,6 @@ +# Generate normal distribution with mean = 1, sd = 0.5 +Gauss ← (×(∿+η××2π⚂) (√ׯ2ₙe⚂)) +[⍥(+1×0.5Gauss)1000] # -> mean = 1, sd = 0.5 +Mean ← ÷⧻⟜/+ +Sd ← √÷⊃(⋅⧻|/+×.-)Mean. +⊸⊃Sd Mean diff --git a/Task/Random-sentence-from-book/Jq/random-sentence-from-book.jq b/Task/Random-sentence-from-book/Jq/random-sentence-from-book.jq new file mode 100644 index 0000000000..1ed3a8cc85 --- /dev/null +++ b/Task/Random-sentence-from-book/Jq/random-sentence-from-book.jq @@ -0,0 +1,107 @@ +include "MRG32k3a" {search: "."}; # see above + +### Generic functions + +def sum(stream): reduce stream as $s (0; . +$s); + +### Random sentences +# puctuation to keep (also keep hyphen and apostrophe but do not count as words) +def ending: ".!?"; +def pausing:" ,:;"; + +# regex for removing puctuation +def removing: "[\"#\\$\\%&\\(\\)\\*\\+/<=>@\\[\\\\]^_`{|}~“”]"; + +# Emit a stream of lines +def text: + foreach inputs as $in (null; + if . then $in + else # skip to start + ($in|index("No one would have believed")) as $ix + | if $ix then $in[$ix:] end + end; + select(.) + | gsub( removing; "" ) # remove extraneous punctuation + | gsub("[\r—]"; " ") # replace \r and EM DASH (unicode 8212) with a space +); + +def pairsAndTriples(stream): + reduce stream as $x ({}; + .pair as $in2 + | .triple as $in3 + | if .pair | length <= 1 then .pair += [$x] end + | if .triple | length <= 2 then .triple += [$x] end + | if .pair | length == 2 + then # .dict2[ .pair | join(" ")] += 1 + .dict[ .pair[0] ][.pair[1]] += 1 + end + | if $in2 | length == 2 + then .pair |= [ last, $x] + end + + | if .triple | length == 3 + then .dict3[.triple[0:2]|join(" ")][ .triple[2]] += 1 + end + | if $in3 | length == 3 + then .triple |= .[1:] + [$x] + end + ) ; + +# split into words +def words: + text + | splits(" +") + | select(length>0) + | (first( foreach (ending, pausing | split("")[]) as $x (.; + if endswith($x) then [.[:-1], .[-1:]] end) + | select(type=="array")) | .[]) + // . +; + +# $randomFloat should be a randomFloat value +# . should be a JSON object with {WORD: count} pairs +def weightedRandomChoice($randomFloat): + to_entries + | . as $entries + | .[0].key as $default + | sum( .[] | .value) as $n + | ($n * $randomFloat | floor) as $r + | first( + { sum: 0 } + | foreach $entries[] as $kv (.; + .key = $kv.key + | .sum += $kv.value ) + | if $r < .sum then .key else empty end) + // $default; + +# build 5 random sentences +def sentences: + pairsAndTriples(words) as $library + | range(1;6) as $u + # First word: + | { prng: (seed((now + $u) % D) | nextFloat)} + | .prng.nextFloat as $nf + | .sentence = ($library.dict["."] | weightedRandomChoice($nf)) + | .lastOne = .sentence + | .lastTwo = ". " + .sentence + | until(.break; + $library.dict3[.lastTwo] as $x + | if $x + then .prng |= nextFloat + | (.prng.nextFloat) as $nf + | ($x | weightedRandomChoice($nf)) as $nextOne + | .sentence += " " + $nextOne + # stop on reaching ending punctuation + | if any(ending|split("")[]; . as $punctuation | $nextOne | index($punctuation)) + then .break = true + else .lastTwo = .lastOne + " " + $nextOne + | .lastOne = $nextOne + end + else debug("unexpected failure") | .break=true + end ) + # tidy up sentence + | .sentence + | reduce (ending + pausing | split("")[]) as $p (.; . |= gsub(" [\($p)]"; "\($p)") ) + | if startswith("“") and (test("”")|not) then .sentence += "”" end ; + +sentences diff --git a/Task/Range-expansion/EasyLang/range-expansion.easy b/Task/Range-expansion/EasyLang/range-expansion.easy new file mode 100644 index 0000000000..c1476c55af --- /dev/null +++ b/Task/Range-expansion/EasyLang/range-expansion.easy @@ -0,0 +1,20 @@ +func[] expand txt$ . + for r$ in strsplit txt$ "," + for i = 2 to len r$ - 1 + if substr r$ i 1 = "-" + a = number substr r$ 1 (i - 1) + b = number substr r$ (i + 1) 999 + break 1 + . + . + if i = len r$ + lst[] &= number r$ + else + for i = a to b + lst[] &= i + . + . + . + return lst[] +. +print expand "-6,-3--1,3-5,7-11,14,15,17-20" diff --git a/Task/Range-extraction/EasyLang/range-extraction.easy b/Task/Range-extraction/EasyLang/range-extraction.easy index 34766517e6..0d3eeb1abe 100644 --- a/Task/Range-extraction/EasyLang/range-extraction.easy +++ b/Task/Range-extraction/EasyLang/range-extraction.easy @@ -1,21 +1,19 @@ -func$ mkrange arr[] . - idx = 1 - idx2 = 1 - while idx <= len arr[] - repeat - idx2 += 1 - until idx2 > len arr[] or arr[idx2] - arr[idx2 - 1] <> 1 +func$ extract l[] . + for i to len l[] + low = l[i] + while i < len l[] and l[i] + 1 = l[i + 1] + i += 1 . - if idx2 - idx > 2 - r$ &= arr[idx] & "-" & arr[idx2 - 1] & "," - idx = idx2 + hi = l[i] + if hi - low >= 2 + r$ &= low & "-" & hi & "," + elif hi - low = 1 + r$ &= low & "," + r$ &= hi & "," else - while idx < idx2 - r$ &= arr[idx] & "," - idx += 1 - . + r$ &= low & "," . . return substr r$ 1 (len r$ - 1) . -print mkrange [ 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 ] +print extract [ 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 ] diff --git a/Task/Rare-numbers/Langur/rare-numbers.langur b/Task/Rare-numbers/Langur/rare-numbers.langur index 7cefd78272..2bec6f3d28 100644 --- a/Task/Rare-numbers/Langur/rare-numbers.langur +++ b/Task/Rare-numbers/Langur/rare-numbers.langur @@ -1,20 +1,29 @@ -val .perfectsquare = fn(.n) (.n ^/ 2) div 1 +val perfectsquare = fn n: (n ^/ 2) div 1 -val .israre = fn(.n) { - val .r = reverse(.n) - if .n == .r: return false - val .sum = .n + .r - val .diff = .n - .r - .diff > 0 and .perfectsquare(.sum) and .perfectsquare(.diff) +val israre = fn(n) { + val r = reverse(n) + if n == r: return false + val sum = n + r + val diff = n - r + diff > 0 and perfectsquare(sum) and perfectsquare(diff) } -val .findfirst = fn(.max) { - for[=[]] .i = 0; len(_for) < .max; .i += 1 { - if .israre(.i) { - _for ~= [.i] +val findfirst = fn(mx) { + for[=[]] i = 0; len(_for) < mx; i += 1 { + if israre(i) { + _for ~= [i] + } + } +} + +val findandprint = impure fn(mx) { + for[cnt=0] i = 0; cnt < mx ; i += 1 { + if israre(i) { + writeln "\n rare ", i, " " + cnt += 1 } } } # if you have the time... -writeln "the first 5 rare numbers: ", .findfirst(5) +writeln "the first 5 rare numbers: ", findfirst(5) diff --git a/Task/Rate-counter/Chipmunk-Basic/rate-counter.basic b/Task/Rate-counter/Chipmunk-Basic/rate-counter.basic new file mode 100644 index 0000000000..9a7e87a49a --- /dev/null +++ b/Task/Rate-counter/Chipmunk-Basic/rate-counter.basic @@ -0,0 +1,17 @@ +100 cls +110 for i = 1 to 3 +120 gosub 170 +130 next i +140 i = 200 +150 gosub 170 +160 end +170 'function timeit +180 iter = 0 +190 starter = timer +200 while true +210 iter = iter+1 +220 if timer >= starter+i then exit while +230 wend +240 print iter;" iteraciones en ";i;" milisegundo"; +250 if i > 1 then print "s" else print "" +260 return diff --git a/Task/Ray-casting-algorithm/11l/ray-casting-algorithm.11l b/Task/Ray-casting-algorithm/11l/ray-casting-algorithm.11l index 9604c7d423..d3bb94d583 100644 --- a/Task/Ray-casting-algorithm/11l/ray-casting-algorithm.11l +++ b/Task/Ray-casting-algorithm/11l/ray-casting-algorithm.11l @@ -1,30 +1,12 @@ -T Pt - Float x, y - - F (x, y) - .x = x - .y = y - +T Pt((Float x, Float y)) F String() R ‘Pt(x=#., y=#.)’.format(.x, .y) -T Edge - Pt a, b - - F (a, b) - .a = a - .b = b - +T Edge((Pt a, Pt b)) F String() R ‘Edge(a=#., b=#.)’.format(.a, .b) -T Poly - String name - [Edge] edges - - F (name, edges) - .name = name - .edges = edges +T Poly = (String name, [Edge] edges) V _eps = 0.00001 V _huge = 1e+100 diff --git a/Task/Read-a-file-character-by-character-UTF8/PascalABC.NET/read-a-file-character-by-character-utf8.pas b/Task/Read-a-file-character-by-character-UTF8/PascalABC.NET/read-a-file-character-by-character-utf8.pas new file mode 100644 index 0000000000..8527400b89 --- /dev/null +++ b/Task/Read-a-file-character-by-character-UTF8/PascalABC.NET/read-a-file-character-by-character-utf8.pas @@ -0,0 +1,6 @@ +begin + var f := OpenRead('a.txt',Encoding.UTF8); + while not f.Eof do + Print(f.ReadChar); + f.Close +end. diff --git a/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c index b966412e9a..b3d9bd3659 100644 --- a/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c +++ b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c @@ -1,29 +1,30 @@ -/* Programa: Número mayor de tres números introducidos (Solución 1) */ - -#include +/* + * Read (and write) the standard input file + * line-by-line. This version is for ASCII + * encoded text files. + */ #include -int main() +/* + * BUFSIZE is a max size of line plus 1. + * + * It would be nice to dynamically allocate bigger buffer for longer lines etc. + * - but this example is as simple as possible. Dynamic buffer allocation from + * the heap may not be a good idea as it seems, because it can cause memory + * segmentation in embeded systems. + */ +#define BUFSIZE 1024 + +int main(void) { - int n1, n2, n3; + static char buffer[BUFSIZE]; - printf( "\n Introduzca el primer n%cmero (entero): ", 163 ); - scanf( "%d", &n1 ); - printf( "\n Introduzca el segundo n%cmero (entero): ", 163 ); - scanf( "%d", &n2 ); - printf( "\n Introduzca el tercer n%cmero (entero): ", 163 ); - scanf( "%d", &n3 ); - - if ( n1 >= n2 && n1 >= n3 ) - printf( "\n %d es el mayor.", n1 ); - else - - if ( n2 > n3 ) - printf( "\n %d es el mayor.", n2 ); - else - printf( "\n %d es el mayor.", n3 ); - - getch(); /* Pausa */ + /* + * Never use gets() instead fgets(), because gets() + * is a really unsafe function. + */ + while (fgets(buffer, BUFSIZE, stdin)) + puts(buffer); return 0; } diff --git a/Task/Read-a-file-line-by-line/PascalABC.NET/read-a-file-line-by-line.pas b/Task/Read-a-file-line-by-line/PascalABC.NET/read-a-file-line-by-line.pas new file mode 100644 index 0000000000..1d927c276d --- /dev/null +++ b/Task/Read-a-file-line-by-line/PascalABC.NET/read-a-file-line-by-line.pas @@ -0,0 +1,6 @@ +begin + var f := OpenRead('_a.pas'); + while not f.Eof do + Println(f.ReadString); + f.Close +end. diff --git a/Task/Read-a-specific-line-from-a-file/PascalABC.NET/read-a-specific-line-from-a-file.pas b/Task/Read-a-specific-line-from-a-file/PascalABC.NET/read-a-specific-line-from-a-file.pas new file mode 100644 index 0000000000..cdd0eb4af5 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/PascalABC.NET/read-a-specific-line-from-a-file.pas @@ -0,0 +1,4 @@ +begin + var linenum := 4; + ReadLines('_a.pas').Skip(linenum-1).First.Print; +end. diff --git a/Task/Read-entire-file/PascalABC.NET/read-entire-file.pas b/Task/Read-entire-file/PascalABC.NET/read-entire-file.pas new file mode 100644 index 0000000000..ac863ce103 --- /dev/null +++ b/Task/Read-entire-file/PascalABC.NET/read-entire-file.pas @@ -0,0 +1,3 @@ +## +var text := ReadAllText('_a.pas',Encoding.UTF8); +Print(text); diff --git a/Task/Real-constants-and-functions/ANSI-BASIC/real-constants-and-functions.basic b/Task/Real-constants-and-functions/ANSI-BASIC/real-constants-and-functions.basic new file mode 100644 index 0000000000..ddc92aa3df --- /dev/null +++ b/Task/Real-constants-and-functions/ANSI-BASIC/real-constants-and-functions.basic @@ -0,0 +1,25 @@ +100 REM Real constants and functions +110 DECLARE EXTERNAL FUNCTION Floor +120 PRINT "e = "; EXP(1) ! e not available +130 PRINT "PI = "; PI +140 LET X = 12.345 +150 LET Y = 1.23 +160 PRINT "sqrt = "; SQR(X), X ^ 0.5 ! square root- NB the unusual name +170 PRINT "ln = "; LOG(X) ! natural logarithm base e +180 PRINT "log2 = "; LOG2(X) ! base 2 logarithm +190 PRINT "log10 = "; LOG10(X) ! base 10 logarithm +200 PRINT "log = "; LOG(X) / LOG(Y) ! arbitrary base logarithm +210 PRINT "exp = "; EXP(X) ! exponential +220 PRINT "abs = "; ABS(-1) ! absolute value +230 PRINT "floor = "; Floor(X) ! floor easily implemented as functions +240 PRINT "ceil = "; CEIL(X) ! ceiling +250 PRINT "power = "; X ^ Y ! power +260 END +270 REM ** +280 EXTERNAL FUNCTION Floor(X) +290 IF X > 0 THEN +300 LET Floor = INT(X) +310 ELSE +320 IF X <> INT(X) THEN LET Floor = INT(X) - 1 ELSE LET Floor = INT(X) +330 END IF +340 END FUNCTION diff --git a/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.basic b/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.basic index f3022653fc..ebfa00b9c3 100644 --- a/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.basic +++ b/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.basic @@ -1,32 +1,31 @@ -print exp( 1) ' e not available -print 4 *atn( 1) ' pi not available +print exp(1) ' e not available +print 4 *atn(1) ' pi not available x =12.345: y =1.23 -print sqr( x), x^0.5 ' square root- NB the unusual name -print log( x) ' natural logarithm base e -print log( x) /2.303 ' base 10 logarithm -print log( x) /log( y) ' arbitrary base logarithm -print exp( x) ' exponential -print abs( x) ' absolute value -print floor( x) ' floor -print ceiling( x) ' ceiling -print x^y ' power - +print sqr(x), x^0.5 ' square root- NB the unusual name +print log(x) ' natural logarithm base e +print log(x) /2.303 ' base 10 logarithm +print log(x) / log(y) ' arbitrary base logarithm +print exp(x) ' exponential +print abs(x) ' absolute value +print floor(x) ' floor +print ceiling(x) ' ceiling +print x^y ' power end -function floor( x) +function floor(x) if x >0 then - floor =int( x) + floor =int(x) else - if x <>int( x) then floor =int( x) -1 else floor =int( x) + if x <>int(x) then floor =int(x) -1 else floor =int(x) end if end function -function ceiling( x) +function ceiling(x) if x <0 then - ceiling =int( x) + ceiling =int(x) else - ceiling =int( x) +1 + ceiling =int(x) +1 end if end function diff --git a/Task/Real-constants-and-functions/PascalABC.NET/real-constants-and-functions.pas b/Task/Real-constants-and-functions/PascalABC.NET/real-constants-and-functions.pas new file mode 100644 index 0000000000..4c4864b10e --- /dev/null +++ b/Task/Real-constants-and-functions/PascalABC.NET/real-constants-and-functions.pas @@ -0,0 +1,13 @@ +## +Println(E); +Println(Pi); +var x := 2.5; +Println(Sqrt(x)); +Println(Ln(x)); // natural logarithm +Println(LogN(10,x)); // logarithm with base +Println(Exp(x)); +Println(Abs(-x)); +Println(Floor(x)); +Println(Ceil(x)); +var y := 4.1; +Println(x ** y); diff --git a/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.basic b/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.basic index 0fa682fa9d..5773a8fa83 100644 --- a/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.basic +++ b/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.basic @@ -1,5 +1,5 @@ print "exp:";chr$(9); EXP(1) -print "PI:";chr$(9); 22/7 +print "PI:";chr$(9); 4 * ATN(1) print "Sqr2:";chr$(9); SQR(2) print "Log2:";chr$(9); LOG(2) : REM Base 10 print "Exp2:";chr$(9); EXP(2) diff --git a/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml b/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml index 73fdedeed4..497596d5b3 100644 --- a/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml +++ b/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml @@ -1,10 +1,11 @@ -Math.e; (* e *) -Math.pi; (* pi *) -Math.sqrt x; (* square root *) -Math.ln x; (* natural logarithm--log base 10 also available (Math.log10) *) -Math.exp x; (* exponential *) -abs x; (* absolute value *) -floor x; (* floor *) -ceil x; (* ceiling *) -Math.pow (x, y); (* power *) -~ x; (* negation *) +Math.e (* e *) +Math.pi (* pi *) +(* Math.tau also available in some implementations *) +Math.sqrt x (* square root *) +Math.ln x (* natural logarithm--log base 10 also available (Math.log10) *) +Math.exp ; (* exponential *) +abs x (* absolute value *) +floor x (* floor *) +ceil x (* ceiling *) +Math.pow (x, y) (* power *) +~x (* negation *) diff --git a/Task/Real-constants-and-functions/XBasic/real-constants-and-functions.basic b/Task/Real-constants-and-functions/XBasic/real-constants-and-functions.basic index 43fe0011ee..877869db73 100644 --- a/Task/Real-constants-and-functions/XBasic/real-constants-and-functions.basic +++ b/Task/Real-constants-and-functions/XBasic/real-constants-and-functions.basic @@ -1,4 +1,4 @@ -PROGRAM "progname" +PROGRAM "realcaf" VERSION "0.0000" IMPORT "xma" @@ -9,15 +9,12 @@ DECLARE FUNCTION Floor (x) FUNCTION Entry () DOUBLE e, pi, x, y - e = EXP(1) PRINT "e = "; e ' e not available pi = 4 * ATAN(1) PRINT "pi = "; pi ' pi not available - x = 12.345 y = 1.23 - PRINT "sqrt = "; SQRT (x) ' square root PRINT "ln = "; LOG (x) ' natural logarithm base e PRINT "log10 = "; LOG10 (x) ' base 10 logarithm diff --git a/Task/Record-sound/00-TASK.txt b/Task/Record-sound/00-TASK.txt index 264fe9687d..64d549b885 100644 --- a/Task/Record-sound/00-TASK.txt +++ b/Task/Record-sound/00-TASK.txt @@ -4,3 +4,4 @@ Record a monophonic 16-bit PCM sound into either memory space, a file or array. The programs in this page might use signed 16-bit or unsigned 16-bit samples, at 8000 Hz, 44100 Hz, or any other sample rate. Therefore, these programs might not record sound in the same format.) + diff --git a/Task/Record-sound/Ada/record-sound.ada b/Task/Record-sound/Ada/record-sound.ada new file mode 100644 index 0000000000..3afa638764 --- /dev/null +++ b/Task/Record-sound/Ada/record-sound.ada @@ -0,0 +1,33 @@ +with Sf.Audio.SoundBufferRecorder; +with Sf.Audio.SoundBuffer; +with Ada.Text_IO; + +procedure Record_Sound is + use Sf, Sf.Audio, Ada.Text_IO; + Sound_Buffer_Recorder : constant sfSoundBufferRecorder_Ptr := SoundBufferRecorder.create; + Sound_Buffer : sfSoundBuffer_Ptr; +begin + + if Sound_Buffer_Recorder = null then + Put_Line (Standard_Error, "Error: sound recorder not available!"); + return; + end if; + + -- By default the recording is in 16-bit mono. Using the + -- setChannelCount method you can change the number of channels + -- used by the audio capture device to record. + if SoundBufferRecorder.start (Sound_Buffer_Recorder, sampleRate => 44_100) /= sfTrue then + Put_Line (Standard_Error, "Error: sound recorder cannot start!"); + return; + end if; + + delay 10.0; + SoundBufferRecorder.stop (Sound_Buffer_Recorder); + + Sound_Buffer := SoundBufferRecorder.getBuffer (Sound_Buffer_Recorder); + if SoundBuffer.saveToFile (Sound_Buffer, filename => "output.ogg") /= sfTrue then + Put_Line (Standard_Error, "Error: recorded sound could not be saved!"); + end if; + + SoundBufferRecorder.destroy (Sound_Buffer_Recorder); +end Record_Sound; diff --git a/Task/Record-sound/FutureBasic/record-sound.basic b/Task/Record-sound/FutureBasic/record-sound.basic new file mode 100644 index 0000000000..c90517e88e --- /dev/null +++ b/Task/Record-sound/FutureBasic/record-sound.basic @@ -0,0 +1,138 @@ +// --------------- +include "NSLog.incl" +include "Tlbx Speech.incl" +include "Tlbx AVFoundation.incl" + +output "RecordToTextDemo" + +#plist CFBundleIdentifier @"com.futurebasic.RecordToTextDemo" +#plist NSSpeechRecognitionUsageDescription @"Enable speech recognition." +#plist NSMicrophoneUsageDescription @"This app requires microphone access." + +#define FILE_URL fn URLByAppendingPathComponent(fn FileManagerURLForApplicationDirectory,@"MyAudioFile.m4a") +#define RECORDER_KEY @"recorder" + + +_window = 1 +begin enum 1 + _recordBtn +end enum + + +void local fn FixViews + dispatchmain + AVAudioRecorderRef recorder = fn AppProperty( RECORDER_KEY ) + if ( recorder ) + button _recordBtn,,, @"Stop Recording",,,, _window + else + button _recordBtn,,, @"Start Recording",,,, _window + end if + dispatchend +end fn + + +void local fn BuildWindow + window _window, @"Record Demo", (0,0,480,270) + button _recordBtn,,, @"Start Recording", (13,13,129,32) +end fn + + +void local fn MyRecognitionTaskHandler( ref as SFSpeechRecognizerRef, result as SFSpeechRecognitionResultRef, err as ErrorRef, userData as ptr ) + SFTranscriptionRef transcription = fn SFSpeechRecognitionResultBestTranscription( result ) + + if ( err ) + NSLog(@"error") + else + if ( fn SFSpeechRecognitionResultIsFinal( result ) ) + NSLog(@"%@",fn SFTranscriptionFormattedString( transcription )) + end if + end if +end fn + + +void local fn MyRequestAuthorization( status as SFSpeechRecognizerAuthorizationStatus, userData as ptr ) + SFSpeechRecognizerRef recognizer + SFSpeechURLRecognitionRequestRef request + + select ( status ) + case SFSpeechRecognizerAuthorizationStatusNotDetermined : NSLog(@"Authorization not determined") + case SFSpeechRecognizerAuthorizationStatusDenied : NSLog(@"Authorization denied") + case SFSpeechRecognizerAuthorizationStatusRestricted : NSLog(@"Authorization restricted") + case SFSpeechRecognizerAuthorizationStatusAuthorized + recognizer = fn SFSpeechRecognizerInit + if ( fn SFSpeechRecognizerIsAvailable( recognizer ) ) + if ( FILE_URL ) + fn SoundPlay( fn SoundWithContentsOfURL( FILE_URL, YES ) ) + request = fn SFSpeechURLRecognitionRequestWithURL( FILE_URL ) + SFSpeechRecognizerSetSupportsOnDeviceRecognition( recognizer, YES ) + fn SFSpeechRecognizerRecognitionTaskWithResultHandler( recognizer, request, @fn MyRecognitionTaskHandler, NULL ) + end if + else + NSLog(@"Speech recognizer not available") + end if + end select +end fn + + +void local fn RecognizeSpeech + SFSpeechRecognizerRequestAuthorization( @fn MyRequestAuthorization, NULL ) +end fn + + +void local fn RecordAudio + CFDictionaryRef settings = @{ + AVFormatIDKey:@(kAudioFormatMPEG4AAC), + AVEncoderAudioQualityKey:@(AVAudioQualityHigh), + AVSampleRateKey:@44100.0, + AVNumberOfChannelsKey:@1, + AVLinearPCMBitDepthKey:@16} + + AVAudioFormatRef format = fn AVAudioFormatWithSettings( settings ) + AVAudioRecorderRef recorder = fn AVAudioRecorderWithFormat( FILE_URL, format, NULL ) + AppSetProperty( RECORDER_KEY, recorder ) + fn FixViews + fn AVAudioRecorderRecord( recorder ) +end fn + + +void local fn MyRequestAccessHandler( granted as BOOL, userData as ptr ) + if ( granted ) then fn RecordAudio +end fn + + +void local fn StartStopRecording + AVAudioRecorderRef recorder = fn AppProperty( RECORDER_KEY ) + AVAuthorizationStatus status + + if ( recorder ) + AVAudioRecorderStop( recorder ) + AppRemoveProperty( RECORDER_KEY ) + fn FixViews + fn RecognizeSpeech + else + status = fn AVCaptureDeviceAuthorizationStatus( AVMediaTypeAudio ) + select ( status ) + case AVAuthorizationStatusDenied : NSLog(@"Denied") + case AVAuthorizationStatusRestricted : NSLog(@"Restricted") + case AVAuthorizationStatusAuthorized : fn RecordAudio + case AVAuthorizationStatusNotDetermined + AVCaptureDeviceRequestAccess( AVMediaTypeAudio, @fn MyRequestAccessHandler, NULL ) + end select + end if +end fn + + +void local fn DoDialog( ev as long, tag as long ) + select ( ev ) + case _btnClick + select ( tag ) + case _recordBtn : fn StartStopRecording + end select + end select +end fn + +fn BuildWindow + +on dialog fn DoDialog + +HandleEvents diff --git a/Task/Reflection-List-methods/Ecstasy/reflection-list-methods.ecstasy b/Task/Reflection-List-methods/Ecstasy/reflection-list-methods.ecstasy new file mode 100644 index 0000000000..1685915756 --- /dev/null +++ b/Task/Reflection-List-methods/Ecstasy/reflection-list-methods.ecstasy @@ -0,0 +1,14 @@ +module test { + void run() { + @Inject Console console; + + String[] names = &this.actualType.multimethods.keys.toArray(); + console.print($"Method/function names on {this}: {names}"); + + Method[] methods = &this.actualType.methods; + console.print($"The methods of {this}: {methods}"); + + Function[] functions = &this.actualType.functions; + console.print($"The functions of {this}: {functions}"); + } +} diff --git a/Task/Reflection-List-methods/PascalABC.NET/reflection-list-methods.pas b/Task/Reflection-List-methods/PascalABC.NET/reflection-list-methods.pas new file mode 100644 index 0000000000..029c568793 --- /dev/null +++ b/Task/Reflection-List-methods/PascalABC.NET/reflection-list-methods.pas @@ -0,0 +1,7 @@ +## +uses System, System.Reflection; + +var flags := BindingFlags.Instance or BindingFlags.Static + or BindingFlags.Public or BindingFlags.DeclaredOnly; + +typeof(integer).GetMethods(flags).PrintLines; diff --git a/Task/Reflection-List-properties/Ecstasy/reflection-list-properties.ecstasy b/Task/Reflection-List-properties/Ecstasy/reflection-list-properties.ecstasy new file mode 100644 index 0000000000..3c79454fd4 --- /dev/null +++ b/Task/Reflection-List-properties/Ecstasy/reflection-list-properties.ecstasy @@ -0,0 +1,7 @@ +module test { + void run() { + @Inject Console console; + Property[] properties = &this.actualType.properties; + console.print($"The properties of {this}: {properties}"); + } +} diff --git a/Task/Reflection-List-properties/PascalABC.NET/reflection-list-properties.pas b/Task/Reflection-List-properties/PascalABC.NET/reflection-list-properties.pas new file mode 100644 index 0000000000..b614140a49 --- /dev/null +++ b/Task/Reflection-List-properties/PascalABC.NET/reflection-list-properties.pas @@ -0,0 +1,19 @@ +uses System, System.Reflection; + +type + MyClass = class + private + auto property NumberPrivate: integer := 666; + public + auto property Number: integer := 3; + end; + +begin + var flags := BindingFlags.Instance or BindingFlags.Static + or BindingFlags.Public or BindingFlags.NonPublic + or BindingFlags.DeclaredOnly; + + var obj := new MyClass; + + typeof(MyClass).GetProperties(flags).Select(p -> (p.Name,p.GetValue(obj))).PrintLines; +end. diff --git a/Task/Regular-expressions/Langur/regular-expressions-2.langur b/Task/Regular-expressions/Langur/regular-expressions-2.langur index 6d9268d481..bd9de4fe0c 100644 --- a/Task/Regular-expressions/Langur/regular-expressions-2.langur +++ b/Task/Regular-expressions/Langur/regular-expressions-2.langur @@ -1 +1 @@ -if val .x, .y = submatch(re/(abc+).+?(def)/, "somestring") { ... } +if x, y = submatch(re/(abc+).+?(def)/, "somestring") { ... } diff --git a/Task/Regular-expressions/PascalABC.NET/regular-expressions.pas b/Task/Regular-expressions/PascalABC.NET/regular-expressions.pas new file mode 100644 index 0000000000..97899d31e8 --- /dev/null +++ b/Task/Regular-expressions/PascalABC.NET/regular-expressions.pas @@ -0,0 +1,10 @@ +begin + // text in tag (lazy quantification) + var s := 'abc def ghi'; + foreach var m in s.Matches('(?<=)(.*?)(?=)') do + Println(m.Value, m.Index); + + // take words in parentheses + s := 'one two three four five'; + Regex.Replace(s,'\w+','<$0>').Println; +end. diff --git a/Task/Remove-duplicate-elements/PascalABC.NET/remove-duplicate-elements.pas b/Task/Remove-duplicate-elements/PascalABC.NET/remove-duplicate-elements.pas new file mode 100644 index 0000000000..2b4aaedfa1 --- /dev/null +++ b/Task/Remove-duplicate-elements/PascalABC.NET/remove-duplicate-elements.pas @@ -0,0 +1,17 @@ +begin + // By algorithm + var nums := Arr(1, 1, 2, 3, 4, 4); + var unique := new List; + foreach var x in nums do + if x not in unique then + unique.Add(x); + unique.Println; + + // By method + var unique2 := nums.Distinct; + unique2.Println; + + // Using hash set + var unique3 := HSet(nums); + unique3.Println; +end. diff --git a/Task/Remove-lines-from-a-file/PascalABC.NET/remove-lines-from-a-file.pas b/Task/Remove-lines-from-a-file/PascalABC.NET/remove-lines-from-a-file.pas new file mode 100644 index 0000000000..debe9b6767 --- /dev/null +++ b/Task/Remove-lines-from-a-file/PascalABC.NET/remove-lines-from-a-file.pas @@ -0,0 +1,9 @@ +procedure RemoveLines(fname: string; start: integer; count: integer := 1); +begin + WriteAllLines(fname, + ReadAllLines(fname).Where((s,ind) -> ind not in start - 1 .. start + count - 2).ToArray) +end; + +begin + RemoveLines('a2.pas',3,2); +end. diff --git a/Task/Rename-a-file/PascalABC.NET/rename-a-file.pas b/Task/Rename-a-file/PascalABC.NET/rename-a-file.pas new file mode 100644 index 0000000000..227ef6594b --- /dev/null +++ b/Task/Rename-a-file/PascalABC.NET/rename-a-file.pas @@ -0,0 +1,9 @@ +uses System.IO; + +begin + &File.Move('input.txt','output.txt'); + &File.Move('\input.txt','\output.txt'); + + Directory.Move('docs','mydocs'); + Directory.Move('\docs','\mydocs'); +end. diff --git a/Task/Repeat-a-string/PascalABC.NET/repeat-a-string.pas b/Task/Repeat-a-string/PascalABC.NET/repeat-a-string.pas new file mode 100644 index 0000000000..21e04fdb9e --- /dev/null +++ b/Task/Repeat-a-string/PascalABC.NET/repeat-a-string.pas @@ -0,0 +1,2 @@ +## +Print('ha' * 5) diff --git a/Task/Repeat/Applesoft-BASIC/repeat.basic b/Task/Repeat/Applesoft-BASIC/repeat.basic new file mode 100644 index 0000000000..865c1b1d9a --- /dev/null +++ b/Task/Repeat/Applesoft-BASIC/repeat.basic @@ -0,0 +1,20 @@ + 100 FOR I = 768 TO 794 + 110 READ B: POKE I,B: NEXT + 120 DATA165,185,72,165,184,72 + 130 DATA165,118,72,165,117,72 + 140 DATA169,176,72,32,123,221 + 150 DATA32,82,231,32,65,217 + 160 DATA76,210,215 + 170 POKE 1014,0: POKE 1015,3 + + 200 LET P = 400:N = 4 + 210 GOSUB 300"REPEAT P N + 220 END + + 300 IF N < = 0 THEN RETURN + 310 LET N = N - 1 + 320 & P + 330 GOTO 300 + + 400 PRINT "EXAMPLE" + 410 RETURN diff --git a/Task/Repeat/Chapel/repeat-1.chapel b/Task/Repeat/Chapel/repeat-1.chapel new file mode 100644 index 0000000000..6ca234b22f --- /dev/null +++ b/Task/Repeat/Chapel/repeat-1.chapel @@ -0,0 +1,13 @@ +config const n = 5; + +proc example() +{ + writeln("example"); +} + +proc repeat(func, n) +{ + for i in 0..#n do func(); +} + +repeat(example, n); diff --git a/Task/Repeat/Chapel/repeat-2.chapel b/Task/Repeat/Chapel/repeat-2.chapel new file mode 100644 index 0000000000..ac4f950092 --- /dev/null +++ b/Task/Repeat/Chapel/repeat-2.chapel @@ -0,0 +1,13 @@ +config const n = 5; + +proc example() +{ + writeln("example"); +} + +proc repeat(func : proc(), n : uint) +{ + for i in 0..#n do func(); +} + +repeat(example, n); diff --git a/Task/Repeat/Chapel/repeat-3.chapel b/Task/Repeat/Chapel/repeat-3.chapel new file mode 100644 index 0000000000..d229a7de7f --- /dev/null +++ b/Task/Repeat/Chapel/repeat-3.chapel @@ -0,0 +1,13 @@ +config const n = 5; + +proc example(x : uint) +{ + writeln("example ", x); +} + +proc repeat(func : proc(x : uint), n : uint) +{ + for i in 0..#n do func(i); +} + +repeat(example, n); diff --git a/Task/Repeat/PascalABC.NET/repeat.pas b/Task/Repeat/PascalABC.NET/repeat.pas new file mode 100644 index 0000000000..28afa11525 --- /dev/null +++ b/Task/Repeat/PascalABC.NET/repeat.pas @@ -0,0 +1,7 @@ +procedure Rep(n: integer; p: procedure) := (p * n); + +procedure p := Print('Hello'); + +begin + Rep(3,p); +end. diff --git a/Task/Repeat/Refal/repeat.refal b/Task/Repeat/Refal/repeat.refal new file mode 100644 index 0000000000..b826dd004c --- /dev/null +++ b/Task/Repeat/Refal/repeat.refal @@ -0,0 +1,12 @@ +$ENTRY Go { + = Eggs And >; +} + +Repeat { + 0 s.F e.X = e.X; + s.N s.F e.X = s.F >; +}; + +Example { + e.X = e.X Spam; +}; diff --git a/Task/Return-multiple-values/PascalABC.NET/return-multiple-values.pas b/Task/Return-multiple-values/PascalABC.NET/return-multiple-values.pas new file mode 100644 index 0000000000..2b6a90767d --- /dev/null +++ b/Task/Return-multiple-values/PascalABC.NET/return-multiple-values.pas @@ -0,0 +1,6 @@ +function AddSub(x,y: real): (real,real) := (x + y, x - y); + +begin + var (a,s) := AddSub(5,3); + Print(a,s); +end. diff --git a/Task/Reverse-a-string/Langur/reverse-a-string.langur b/Task/Reverse-a-string/Langur/reverse-a-string.langur index 43a9ef1478..7758d7657c 100644 --- a/Task/Reverse-a-string/Langur/reverse-a-string.langur +++ b/Task/Reverse-a-string/Langur/reverse-a-string.langur @@ -1 +1 @@ -writeln reverse "don't you know" +writeln reverse("don't you know") diff --git a/Task/Reverse-a-string/PascalABC.NET/reverse-a-string.pas b/Task/Reverse-a-string/PascalABC.NET/reverse-a-string.pas new file mode 100644 index 0000000000..8425b6bdbe --- /dev/null +++ b/Task/Reverse-a-string/PascalABC.NET/reverse-a-string.pas @@ -0,0 +1,3 @@ +## +var s:='asdf';//ReadLnString; +ReverseString(s).Print; 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 new file mode 100644 index 0000000000..d37e9a9155 --- /dev/null +++ b/Task/Reverse-words-in-a-string/PascalABC.NET/reverse-words-in-a-string.pas @@ -0,0 +1,3 @@ +## +var s:='Hey you, Bub!'; +s.ToWords.Reverse.Print; diff --git a/Task/Rhonda-numbers/Python/rhonda-numbers.py b/Task/Rhonda-numbers/Python/rhonda-numbers.py new file mode 100644 index 0000000000..4525bd3730 --- /dev/null +++ b/Task/Rhonda-numbers/Python/rhonda-numbers.py @@ -0,0 +1,47 @@ +# rhonda.py by Xing216 +def prime_factors_sum(n): + i = 2 + factors_sum = 0 + while i * i <= n: + if n % i: + i += 1 + else: + n //= i + factors_sum+=i + if n > 1: + factors_sum+=n + return factors_sum +def digits_product(n: int, base: int): + # translated from the nim solution + i = 1 + while n != 0: + i *= n % base + n //= base + return i +def is_rhonda_num(n:int, base: int): + product = digits_product(n, base) + return product == base * prime_factors_sum(n) +def convert_base(num,b): + numerals="0123456789abcdefghijklmnopqrstuvwxyz" + return ((num == 0) and numerals[0]) or (convert_base(num // b, b).lstrip(numerals[0]) + numerals[num % b]) +def is_prime(n): + if n == 1: + return False + i = 2 + while i*i <= n: + if n % i == 0: + return False + i += 1 + return True +for base in range(4,37): + rhonda_nums = [] + if is_prime(base): + continue + i = 1 + while len(rhonda_nums) < 10: + if is_rhonda_num(i,base) : + rhonda_nums.append(i) + i+=1 + else: + i+=1 + print(f"base {base}: {', '.join([convert_base(n, base) for n in rhonda_nums])}") diff --git a/Task/Rock-paper-scissors/EasyLang/rock-paper-scissors.easy b/Task/Rock-paper-scissors/EasyLang/rock-paper-scissors.easy new file mode 100644 index 0000000000..79c8fd06f4 --- /dev/null +++ b/Task/Rock-paper-scissors/EasyLang/rock-paper-scissors.easy @@ -0,0 +1,24 @@ +tool$[] = [ "rock" "paper" "scissors" ] +repeat + write "choose your weapon: " + h$ = input + c = randint 3 + h$ = substr h$ 1 1 + until h$ = "q" + h = strpos "rps" h$ + if h = 0 + print "that's not a valid choice" + else + print tool$[h] + print "computer: " & tool$[c] + if h = c + print "it's a tie!" + elif (h + 1) mod1 3 = c + print "yay you win!" + else + print "the computer beats you... :(" + . + . + print "" + sleep 1 +. diff --git a/Task/Roman-numerals-Decode/JavaScript/roman-numerals-decode-8.js b/Task/Roman-numerals-Decode/JavaScript/roman-numerals-decode-8.js index a0ea2acf23..fc1d5ff210 100644 --- a/Task/Roman-numerals-Decode/JavaScript/roman-numerals-decode-8.js +++ b/Task/Roman-numerals-Decode/JavaScript/roman-numerals-decode-8.js @@ -1,6 +1,7 @@ (() => { + "use strict"; - // -------------- ROMAN NUMERALS DECODED --------------- + // ------------- ROMAN NUMERALS DECODED -------------- // Folding from right to left, // lower leftward characters are subtracted, @@ -8,49 +9,34 @@ // fromRoman :: String -> Int const fromRoman = s => - foldr(l => ([r, n]) => [ - l, - l >= r ? ( - n + l - ) : n - l - ])([0, 0])( - [...s].map(charVal) + [...s] + .map(glyphValue) + .reduceRight( + ([r, n], l) => [ + l, + l >= r + ? n + l + : n - l + ], + [0, 0] )[1]; - // charVal :: Char -> Maybe Int - const charVal = k => { - const v = { - I: 1, - V: 5, - X: 10, - L: 50, - C: 100, - D: 500, - M: 1000 - } [k]; - return v !== undefined ? v : 0; - }; - // ----------------------- TEST ------------------------ - const main = () => [ - 'MDCLXVI', 'MCMXC', 'MMVIII', 'MMXVI', 'MMXVII' - ] - .map(fromRoman) - .join('\n'); + // glyphValue :: Char -> Maybe Int + const glyphValue = k => ({ + I: 1, + V: 5, + X: 10, + L: 50, + C: 100, + D: 500, + M: 1000 + }) [k] || 0; - - // ----------------- GENERIC FUNCTIONS ----------------- - - // foldr :: (a -> b -> b) -> b -> [a] -> b - const foldr = f => - // Note that that the Haskell signature of foldr - // differs from that of foldl - the positions of - // accumulator and current value are reversed. - a => xs => [...xs].reduceRight( - (a, x) => f(x)(a), - a - ); - - // MAIN --- - return main(); + // ---------------------- TEST ----------------------- + return [ + "MDCLXVI", "MCMXC", "MMVIII", "MMXVI", "MMXVII" + ] + .map(fromRoman) + .join("\n"); })(); diff --git a/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode.pas b/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode.pas new file mode 100644 index 0000000000..d41482fd30 --- /dev/null +++ b/Task/Roman-numerals-Decode/PascalABC.NET/roman-numerals-decode.pas @@ -0,0 +1,39 @@ +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); +begin + var i := 1; + 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; +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); +end. diff --git a/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode-4.js b/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode-4.js index fbd9878304..a7426eb378 100644 --- a/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode-4.js +++ b/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode-4.js @@ -7,9 +7,9 @@ const roman = n => mapAccumL(residue => ([k, v]) => second( - q => 0 < q ? ( - k.repeat(q) - ) : "" + q => 0 < q + ? k.repeat(q) + : "" )(remQuot(residue)(v)) )(n)( zip([ @@ -27,11 +27,31 @@ // main :: IO () const main = () => ( [2016, 1990, 2008, 2000, 2020, 1666].map(roman) - ).join("\n"); + ) + .join("\n"); // ---------------- GENERIC FUNCTIONS ---------------- + // Tuple (,) :: a -> b -> (a, b) + const Tuple = a => + // A pair of values, possibly of + // different types. + b => ({ + type: "Tuple", + "0": a, + "1": b, + length: 2, + *[Symbol.iterator]() { + for (const k in this) { + if (!isNaN(k)) { + yield this[k]; + } + } + } + }); + + // mapAccumL :: (acc -> x -> (acc, y)) -> acc -> // [x] -> (acc, [y]) const mapAccumL = f => @@ -39,14 +59,11 @@ // obtained by a combined map and fold, // with accumulation from left to right. acc => xs => [...xs].reduce( - (a, x) => { - const tpl = f(a[0])(x); - - return [ - tpl[0], - a[1].concat(tpl[1]) - ]; - }, + ([a, bs], x) => second( + v => [...bs, v] + )( + f(a)(x) + ), [acc, []] ); @@ -61,7 +78,11 @@ // A function over a simple value lifted // to a function over a tuple. // f (a, b) -> (a, f(b)) - xy => [xy[0], f(xy[1])]; + xy => Tuple( + xy[0] + )( + f(xy[1]) + ); // zip :: [a] -> [b] -> [(a, b)] diff --git a/Task/Roman-numerals-Encode/PascalABC.NET/roman-numerals-encode.pas b/Task/Roman-numerals-Encode/PascalABC.NET/roman-numerals-encode.pas new file mode 100644 index 0000000000..2c842620d2 --- /dev/null +++ b/Task/Roman-numerals-Encode/PascalABC.NET/roman-numerals-encode.pas @@ -0,0 +1,21 @@ +var anums := |1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1|; +var rnums := 'M CM D CD C XC L XL X IX V IV I'.split; + +function ToRoman(x: integer): string; +begin + Result := ''; + foreach var (a,r) in anums.Zip(rnums) do + begin + var n := x div a; + x := x mod a; + Result += r * n; + end; +end; + +begin + var test := |1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 40, + 50, 60, 69, 70, 80, 90, 99, 100, 200, 300, 400, 500, 600, 666, 700, 800, 900, 1000, + 1009, 1444, 1666, 1945, 1997, 1999, 2000, 2008, 2010, 2011, 2500, 3000, 3999|; + foreach var x in test do + Println($'{x} - {ToRoman(x)}') +end. diff --git a/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada b/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada index 29d0419cb0..94bc29261f 100644 --- a/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada +++ b/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada @@ -27,12 +27,12 @@ procedure Count_Examples is A : Attr; Page : Aws.Response.Data; Uri_Xml : constant String := - "http://rosettacode.org/mw/api.php?action=query&list=categorymembers" + "https://rosettacode.org/w/api.php?action=query&list=categorymembers" & "&format=xml&cmlimit=500&cmtitle=Category:"; begin - Page := Client.Get (Uri_Xml & Category); - if Response.Status_Code (Page) not in Messages.Success then + Page := Client.Get (Uri_Xml & Category, Follow_Redirection => True); + if AWS.Response.Status_Code (Page) not in Messages.Success then raise Client.Connection_Error; end if; declare @@ -65,10 +65,11 @@ procedure Count_Examples is begin Page := Client.Get - ("http://rosettacode.org/mw/index.php?title=" & + ("https://rosettacode.org/w/index.php?title=" & Aws.Url.Encode (Title) & - "&action=raw"); - Response.Message_Body (Page, File); + "&action=raw", + Follow_Redirection => True); + AWS.Response.Message_Body (Page, File); while not End_Of_File (File) loop Resources.Get_Line (File, Buffer, Last); Position := diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada b/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada index 402884b167..2d63221a4c 100644 --- a/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada @@ -1,19 +1,18 @@ -with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; -with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; -with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; +with AWS.Client, AWS.Messages, AWS.Response, AWS.URL; +with DOM.Readers, DOM.Core, DOM.Core.Documents, DOM.Core.Nodes, DOM.Core.Attrs; +with Input_Sources.Strings, Unicode, Unicode.CES.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; -use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; -use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; -use Aws, Ada.Strings.Unbounded, Input_Sources.Strings; +use AWS.Client, AWS.Messages, AWS.Response; +use DOM.Readers, DOM.Core, DOM.Core.Documents, DOM.Core.Nodes, DOM.Core.Attrs; +use AWS, Ada.Strings.Unbounded, Input_Sources.Strings; use Ada.Text_IO, Ada.Command_Line; procedure Not_Coded is - package Members_Vectors is new Ada.Containers.Vectors ( - Index_Type => Positive, - Element_Type => Unbounded_String); + package Members_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, Element_Type => Unbounded_String); use Members_Vectors; All_Tasks, Language_Members : Vector; @@ -24,36 +23,33 @@ procedure Not_Coded is List : Node_List; N : Node; A : Attr; - Page : Aws.Response.Data; + Page : AWS.Response.Data; S : Messages.Status_Code; - -- Query has cmlimit value of 100, so we need 5 calls to - -- retrieve the complete list of Programming_category + -- Query has cmlimit value of 500, so we need 2 calls to + -- retrieve the complete list of Programming_category Uri_Xml : constant String := - "http://rosettacode.org/mw/api.php?action=query&list=categorymembers" - & - "&format=xml&cmlimit=100&cmtitle=Category:"; + "https://rosettacode.org/w/api.php?action=query&list=categorymembers" & + "&format=xml&cmlimit=500&cmtitle=Category:"; Cmcontinue : Unbounded_String := Null_Unbounded_String; begin loop Page := - Aws.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue))); - S := Response.Status_Code (Page); - if S not in Messages.Success then + AWS.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue))); + S := AWS.Response.Status_Code (Page); + if S not in Messages.Success then Put_Line - ("Unable to retrieve data => Status Code :" & - Image (S) & - " Reason :" & - Reason_Phrase (S)); + ("Unable to retrieve data => Status Code :" & Image (S) & + " Reason :" & Reason_Phrase (S)); raise Connection_Error; end if; + declare Xml : constant String := Message_Body (Page); Source : String_Input; begin Open - (Xml'Unrestricted_Access, - Unicode.Ces.Utf8.Utf8_Encoding, + (Xml'Unrestricted_Access, Unicode.CES.Utf8.Utf8_Encoding, Source); Parse (Reader, Source); Close (Source); @@ -64,22 +60,20 @@ procedure Not_Coded is N := Item (List, Index - 1); A := Get_Named_Item (Attributes (N), "title"); Members_Vectors.Append - (Mbr_Vector, - To_Unbounded_String (Value (A))); + (Mbr_Vector, To_Unbounded_String (Value (A))); end loop; Free (List); - List := Get_Elements_By_Tag_Name (Doc, "query-continue"); + List := Get_Elements_By_Tag_Name (Doc, "continue"); if Length (List) = 0 then - -- we are done + -- we are done Free (List); Free (Reader); exit; end if; - N := First_Child (Item (List, 0)); + N := Item (List, 0); A := Get_Named_Item (Attributes (N), "cmcontinue"); Cmcontinue := - To_Unbounded_String - ("&cmcontinue=" & Aws.Url.Encode (Value (A))); + To_Unbounded_String ("&cmcontinue=" & AWS.URL.Encode (Value (A))); Free (List); Free (Reader); end loop; @@ -88,14 +82,14 @@ procedure Not_Coded is procedure Quick_Diff (From : in out Vector; Substract : in Vector) is Beginning, Position : Extended_Index; begin - -- take adavantage that both lists are already sorted + -- take adavantage that both lists are already sorted Beginning := First_Index (From); for I in First_Index (Substract) .. Last_Index (Substract) loop Position := - Find_Index - (Container => From, - Item => Members_Vectors.Element (Substract, I), - Index => Beginning); + Find_Index + (Container => From, + Item => Members_Vectors.Element (Substract, I), + Index => Beginning); if not (Position = No_Index) then Delete (From, Position); Beginning := Position; @@ -108,6 +102,8 @@ begin Put_Line ("Can't process : No language given!"); return; else + Put ("Language given: "); + Put_Line (Argument (1)); Get_Vector (Argument (1), Language_Members); end if; diff --git a/Task/Rosetta-Code-Rank-languages-by-number-of-users/Jq/rosetta-code-rank-languages-by-number-of-users.jq b/Task/Rosetta-Code-Rank-languages-by-number-of-users/Jq/rosetta-code-rank-languages-by-number-of-users.jq new file mode 100644 index 0000000000..2343a99f0b --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-number-of-users/Jq/rosetta-code-rank-languages-by-number-of-users.jq @@ -0,0 +1,14 @@ +def rpad($len): tostring | ($len - length) as $l | . + (" " * $l); + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +def cat: sub("Category:";"") | sub(" User$";""); + +"As of \(now | strftime("%A %B %d, %Y %Z %H:%M") ):", +"\n\("Language" | rpad(30)) Users", +"_" * 36, +([.query.pages[] | {title, n: .categoryinfo.size}] + | sort_by(.n) + | reverse[] + | select(.n>100) + | "\(.title | cat | rpad(30)) \(.n|lpad(5))" ) diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada b/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada index 470a835d1b..5313630359 100644 --- a/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada @@ -1,23 +1,28 @@ +pragma Ada_2022; + with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Ordered_Sets; -with Ada.Strings.Less_Case_Insensitive; +with Ada.Strings.Unbounded.Less_Case_Insensitive; +with Ada.Characters.Handling; use Ada.Characters.Handling; -with AWS.Client; +with AWS.Client; use AWS.Client; +with AWS.Messages; use AWS.Messages; with AWS.Response; -procedure Test is +procedure Rank_Languages_By_Popularity is use Ada.Strings; - function "+" (S : String) return Unbounded_String renames To_Unbounded_String; + function "+" (S : String) return Unbounded_String + renames To_Unbounded_String; type A_Language_Count is record - Count : Integer := 0; + Count : Natural := 0; Language : Unbounded_String; end record; @@ -28,11 +33,12 @@ procedure Test is function "<" (L, R : A_Language_Count) return Boolean is begin - -- Sort by 'Count' and then by Language name + -- Sort by 'Count' and then by Language name return L.Count < R.Count or else (L.Count = R.Count - and then Less_Case_Insensitive (Left => To_String (L.Language), - Right => To_String (R.Language))); + and then Less_Case_Insensitive + (Left => L.Language, + Right => R.Language)); end "<"; package Sets is new Ada.Containers.Ordered_Sets (A_Language_Count); @@ -41,30 +47,140 @@ procedure Test is Counts : Set; procedure Find_Counts (S : String) is - Title_Str : constant String := "title=""Category:"; - End_A_Str : constant String := " ("; - Title_At : constant Natural := Index (S, Title_Str); + function Strip_Character (S : String; C : Character) return String is + S_Copy_Str : String (1 .. S'Length); + S_Copy_Index : Natural := 0; + begin + for I in S'Range loop + if S (I) /= C then + S_Copy_Index := S_Copy_Index + 1; + S_Copy_Str (S_Copy_Index) := S (I); + end if; + end loop; + + return S_Copy_Str (S_Copy_Str'First .. S_Copy_Index); + end Strip_Character; + + function Ignore_Category (L : String) return Boolean is + type Unbounded_String_Array is array (Positive range <>) + of Unbounded_String; + -- This list is quite comprehensive, but not complete + Categories_To_Ignore : Unbounded_String_Array := [ + +"Pages with syntax highlighting errors", + +"Programming", + +"Examples needing attention", + +"Tasks needing attention", + +"Language users", + +"Implementations", + +"Solutions by ", + +"Maintenance/OmitCategoriesCreated", + +"Collection Members", + +"Pages with too many expensive parser function calls", + +"Garbage collection", + +" User", + +"SQL User", + +"Typing", + +"Parameter passing", + +"Execution method", + +"Unimplemented tasks by language", + +"Wolfram Language", + +"/Omit", + +"Wren-", + +"WrenGo", + +"Phix/", + +"PhixClass", + +"Basic language learning", + +"Encyclopedia", + +"RCTemplates", + +"SysUtils", + +"Action! ", + +"Text processing", + +"Image processing", + +"Scala Digital Signal Processing", + +"List processing", + +"Digital signal processing", + +"Processing Python", + +"Classic CS problems and programs", + +"Brainf*** related", + +"Data Structures", + +"Perl modules", + +"Perl/", + +"Perl:LWP", + +"Perl 6 related", + +"Flow control", + +"Excessively difficult task", + +"WikiStubs", + +"Impl needed", + +"Recursion" + ]; + begin + for Category of Categories_To_Ignore loop + declare + Category_At : constant Natural := + Index (+To_Lower (L), + To_Lower (To_String (Category))); + begin + if Category_At /= 0 then + return True; + end if; + end; + end loop; + + return False; + end Ignore_Category; + + Title_Str : constant String := "title=""Category:"; + End_A_Tag_Str : constant String := ""; + Space_Paren_Str : constant String := " ("; + + Title_At : constant Natural := Index (S, Title_Str); begin if Title_At /= 0 then declare - Bracket_At : constant Natural := Index (S (Title_At + Title_Str'Length .. S'Last), ">"); - End_A_At : constant Natural := Index (S (Bracket_At + 1 .. S'Last), End_A_Str); - Space_At : constant Natural := Index (S (End_A_At + End_A_Str'Length .. S'Last), " "); - Count : constant Natural := Natural'Value (S (End_A_At + End_A_Str'Length .. Space_At - 1)); - Language : constant String := S (Title_At + Title_Str'Length .. Bracket_At - 2); + Closing_Bracket_At : constant Natural := + Index (S (Title_At + Title_Str'Length .. S'Last), ">"); + + End_A_Tag_At : constant Natural := + Index (S (Closing_Bracket_At + 1 .. S'Last), End_A_Tag_Str); + + Language : constant String := + S (Closing_Bracket_At + 1 .. End_A_Tag_At - 1); + + Space_Paren_At : constant Natural := + Index (S (End_A_Tag_At + 1 .. S'Last), Space_Paren_Str); + + Space_At : constant Natural := + Index (S (Space_Paren_At + Space_Paren_Str'Length + 1 + .. S'Last), + " "); + + Count : constant Natural := + Natural'Value ( + Strip_Character ( + S (Space_Paren_At + + Space_Paren_Str'Length + .. Space_At - 1), + ',')); begin - if Bracket_At /= 0 and then End_A_At /= 0 and then Space_At /= 0 then + if Closing_Bracket_At /= 0 + and then End_A_Tag_At /= 0 + and then Space_Paren_At /= 0 + and then Space_At /= 0 + then begin - Counts.Insert (New_Item => (Count, +Language)); + if Ignore_Category (Language) = False then + Counts.Insert (New_Item => (Count, +Language)); + end if; exception when Constraint_Error => - Put_Line (Standard_Error, "Warning: repeated language: " & Language); - -- Ignore repeated results. + Put_Line (Standard_Error, "Warning: repeated language: " & + Language); + -- Ignore repeated results. null; end; end if; - -- Recursively parse the string for languages and counts + -- Recursively parse the string for languages and counts Find_Counts (S (Space_At + 1 .. S'Last)); end; end if; @@ -82,8 +198,26 @@ procedure Test is end Display; Http_Source : constant AWS.Response.Data := - AWS.Client.Get ("http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000"); + AWS.Client.Get ("http://rosettacode.org/w/index.php?" & + "title=Special:Categories&limit=5000", + Follow_Redirection => True); + Status : Status_Code; begin + Put_Line ("Getting website data..."); + + Status := AWS.Response.Status_Code (Http_Source); + if Status not in Success then + Put_Line ("Unable to retrieve data => Status Code :" & + Image (Status) & + " Reason :" & Reason_Phrase (Status)); + raise Connection_Error; + end if; + + Put_Line ("Finding categories..."); Find_Counts (AWS.Response.Message_Body (Http_Source)); + + Put_Line ("Displaying categories..."); Counts.Reverse_Iterate (Display'Access); -end Test; + + Put_Line ("Process complete."); +end Rank_Languages_By_Popularity; diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Java/rosetta-code-rank-languages-by-popularity.java b/Task/Rosetta-Code-Rank-languages-by-popularity/Java/rosetta-code-rank-languages-by-popularity.java index c2b11e7ab7..d58f8f244f 100644 --- a/Task/Rosetta-Code-Rank-languages-by-popularity/Java/rosetta-code-rank-languages-by-popularity.java +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Java/rosetta-code-rank-languages-by-popularity.java @@ -1,3 +1,4 @@ +import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.io.*; @@ -45,10 +46,8 @@ public class GetRCLanguages try { - URL url = new URL( path ); + URL url = new URI( path ).toURL(); URLConnection rc = url.openConnection(); - // Rosetta Code objects to the default Java user agant so use a blank one - rc.setRequestProperty( "User-Agent", "" ); BufferedReader bfr = new BufferedReader( new InputStreamReader( rc.getInputStream() ) ); gcmcontinue[0] = ""; @@ -56,27 +55,27 @@ public class GetRCLanguages String line = bfr.readLine(); while( line != null ) { - line = line.trim(); - if ( line.startsWith( "[title]" ) ) + line = line.trim().replaceAll( "[\",]", "" ); + if ( line.startsWith( "title" ) ) { - // have a programming language - should look like "[title] => Category:languageName" - languageName = after( line, ':' ).trim(); + // have a programming language - should look like "title: Category:languageName" + languageName = after( after( line, ':' ), ':' ).trim(); } - else if( line.startsWith( "[pages]" ) ) + else if( line.startsWith( "pages" ) ) { // number of pages the language has (probably) - String pageCount = after( line, '>' ).trim(); - if( pageCount.compareTo( "Array" ) != 0 ) + String pageCount = after( line, ':' ).trim(); + if( pageCount.compareTo( "{" ) != 0 ) { - // haven't got "[pages] => Array" - must be a number of pages + // haven't got "pages: {" - must be a number of pages languageList.add( ( (char) Integer.parseInt( pageCount ) ) + languageName ); languageName = "?"; - } // if [pageCount.compareTo( "Array" ) != 0 + } // if [pageCount.compareTo( "{" ) != 0 } - else if( line.startsWith( "[gcmcontinue]" ) ) + else if( line.startsWith( "gcmcontinue" ) ) { // have an indication of wether there is more data or not - gcmcontinue[0] = after( line, '>' ).trim(); + gcmcontinue[0] = after( line, ':' ).trim().replaceAll( "[|]", "%7C" ); } // if various line starts line = bfr.readLine(); } // while line != null @@ -96,13 +95,13 @@ public class GetRCLanguages gcmcontinue[0] = ""; do { - String path = ( "http://www.rosettacode.org/mw/api.php?action=query" + String path = ( "https://www.rosettacode.org/w/api.php?action=query" + "&generator=categorymembers" + "&gcmtitle=Category:Programming%20Languages" + "&gcmlimit=500" + ( gcmcontinue[0].compareTo( "" ) == 0 ? "" : ( "&gcmcontinue=" + gcmcontinue[0] ) ) + "&prop=categoryinfo" - + "&format=txt" + + "&format=jsonfm" ); parseContent( path, gcmcontinue, languageList ); } diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/PascalABC.NET/rosetta-code-rank-languages-by-popularity.pas b/Task/Rosetta-Code-Rank-languages-by-popularity/PascalABC.NET/rosetta-code-rank-languages-by-popularity.pas new file mode 100644 index 0000000000..883b4194c6 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/PascalABC.NET/rosetta-code-rank-languages-by-popularity.pas @@ -0,0 +1,13 @@ +uses System.Net; + +begin + ServicePointManager.SecurityProtocol := SecurityProtocolType(3072); + var wc := new WebClient; + wc.Encoding := Encoding.UTF8; + var s := wc.DownloadString('https://rosettacode.org/wiki/Special:Categories?limit=5000'); + s.Matches('([^><]+).+\(([\d,]+) member') + .Select(x -> KV(x.Groups[1].Value,x.Groups[2].Value.Replace(',','').ToInteger)) + .Where(x -> not x.Key.StartsWith('Pages')) + .OrderByDescending(pair -> pair.Value).Numerate.Take(10) + .PrintLines(x -> $'Rank: {x[0],3} ({x[1].Value} entries) {x[1].Key}') +end. diff --git a/Task/Rot-13/PascalABC.NET/rot-13.pas b/Task/Rot-13/PascalABC.NET/rot-13.pas new file mode 100644 index 0000000000..5f57c13e01 --- /dev/null +++ b/Task/Rot-13/PascalABC.NET/rot-13.pas @@ -0,0 +1,19 @@ +function Rot13(s: string): string; +begin + var sb := new StringBuilder; + foreach var c in s do + begin + var c1 := c; + if c in 'a'..'z' then + c1 := Chr((c.Code - 'a'.Code + 13) mod 26 + 'a'.Code) + else if c in 'A'..'Z' then + c1 := Chr((c.Code - 'A'.Code + 13) mod 26 + 'A'.Code); + sb.Append(c1) + end; + Result := sb.ToString; +end; + +begin + Println(rot13('foo')); + Println(rot13('sbb')) +end. diff --git a/Task/Run-length-encoding/Uiua/run-length-encoding.uiua b/Task/Run-length-encoding/Uiua/run-length-encoding.uiua new file mode 100644 index 0000000000..d2b538adf4 --- /dev/null +++ b/Task/Run-length-encoding/Uiua/run-length-encoding.uiua @@ -0,0 +1,10 @@ +# Run Length Encoding and Decoding + +"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +Split ← ⇌∧(:⊃(⊂□↙)↘)≡/-◫2⊂¯1⊙⊙{} # Use the indexes to cut the string. +Rle ← setinv( + /◇⊂⊜(□⊂⊃(°⋕⧻|⊢))+1⊛. +| ∧(⊂/⊂↯⋕◇⊃↘↙¯1):Split⊚≥@A. +) + +&p⨬("oops"|"good")≍&p.°Rle&p.⊸Rle&p. diff --git a/Task/Runtime-evaluation-In-an-environment/FreeBASIC/runtime-evaluation-in-an-environment.basic b/Task/Runtime-evaluation-In-an-environment/FreeBASIC/runtime-evaluation-in-an-environment.basic new file mode 100644 index 0000000000..8380944173 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/FreeBASIC/runtime-evaluation-in-an-environment.basic @@ -0,0 +1,10 @@ +#include "solver.bi" + +Dim As String expression = "(x ^ 2 )-7" + +setVar("x",1.2) +Print "one = ";Solver(expression) +setVar("x",3.4) +Print "two = ";Solver(expression) + +Sleep diff --git a/Task/Ruth-Aaron-numbers/EasyLang/ruth-aaron-numbers.easy b/Task/Ruth-Aaron-numbers/EasyLang/ruth-aaron-numbers.easy new file mode 100644 index 0000000000..f77e6f3c62 --- /dev/null +++ b/Task/Ruth-Aaron-numbers/EasyLang/ruth-aaron-numbers.easy @@ -0,0 +1,40 @@ +func divsum n alldiv . + f = 2 + repeat + q = n / f + if n mod f = 0 + if alldiv = 1 + s1 += f + else + if f <> f0 + s1 += f + f0 = f + . + . + n = q + else + f += 1 + . + until f > n + . + return s1 +. +proc ruth_aaron alldiv . . + n = 2 + repeat + s = divsum n alldiv + if s = s0 + write n - 1 & " " + c += 1 + . + s0 = s + n += 1 + until c >= 30 + . +. +print "first 30 ruth-aaron numbers (factors):" +ruth_aaron 1 +print "" +print "" +print "first 30 ruth-aaron numbers (divisors):" +ruth_aaron 0 diff --git a/Task/SEDOLs/Langur/sedols.langur b/Task/SEDOLs/Langur/sedols.langur index ce5b39d4a1..df0c67a995 100644 --- a/Task/SEDOLs/Langur/sedols.langur +++ b/Task/SEDOLs/Langur/sedols.langur @@ -1,26 +1,26 @@ -val .csd = fn(.code) { - switch len(.code) { +val csd = fn(code) { + switch len(code) { case 0: return "nada, zip, zilch" case != 6: return "invalid length" } - if .code -> re/[^B-DF-HJ-NP-TV-Z0-9]/ { + if code -> re/[^B-DF-HJ-NP-TV-Z0-9]/ { return "invalid character(s)" } - val .weight = [1,3,1,7,3,9] + val weight = [1,3,1,7,3,9] - val .nums = s2n .code - val .sum = for[=0] .i of .nums { - _for += .nums[.i] * .weight[.i] + val nums = s2n(code) + val sum = for[=0] i of nums { + _for += nums[i] * weight[i] } - string 9 - (.sum - 1) rem 10 + string 9 - (sum - 1) rem 10 } -val .h = h{ +val h = { # invalid... "": 0, "123": 0, @@ -45,14 +45,14 @@ val .h = h{ "B00030": 0, } -for .input in sort(keys .h) { - val .d = .csd(.input) - if len(.d) > 1 { - writeln .input, ": ", .d +for input in sort(keys(h)) { + val d = csd(input) + if len(d) > 1 { + writeln input, ": ", d } else { - val .expect = string .h[.input] - write .input, .d - writeln if .expect == .d {""} else { - $" (SEDOL test failed; expected check digit \.expect;)"} + val expect = h[input] -> string + write input, d + writeln if expect == d {""} else { + " (SEDOL test failed; expected check digit {{expect}})"} } } diff --git a/Task/SHA-256/Java/sha-256.java b/Task/SHA-256/Java/sha-256.java index 5331ce7af5..40dfd1b2f9 100644 --- a/Task/SHA-256/Java/sha-256.java +++ b/Task/SHA-256/Java/sha-256.java @@ -49,7 +49,7 @@ final class SHA256 { } private static byte[] addPadding(String message) { - byte[] bytes = message.getBytes(StandardCharsets.UTF_8); + byte[] bytes = message.getBytes(StandardCharsets.ISO_8859_1); bytes = Arrays.copyOf(bytes, bytes.length + 1); bytes[bytes.length - 1] = (byte) 0x80; diff --git a/Task/SHA-256/V-(Vlang)/sha-256.v b/Task/SHA-256/V-(Vlang)/sha-256.v index 2182efdc4c..3ac675f005 100644 --- a/Task/SHA-256/V-(Vlang)/sha-256.v +++ b/Task/SHA-256/V-(Vlang)/sha-256.v @@ -1,9 +1,9 @@ import crypto.sha256 fn main() { - println("${sha256.hexhash('Rosetta code')}") + println('${sha256.hexhash('Rosetta code')}') mut h := sha256.new() - h.write('Rosetta code'.bytes()) ? - println('${h.checksum().map(it.hex()).join('')}') + h.write('Rosetta code'.bytes())! + println('${h.sum([]u8{}).hex()}') } diff --git a/Task/Safe-addition/Langur/safe-addition.langur b/Task/Safe-addition/Langur/safe-addition.langur new file mode 100644 index 0000000000..c21dd4d022 --- /dev/null +++ b/Task/Safe-addition/Langur/safe-addition.langur @@ -0,0 +1 @@ +writeln 1.2 + 0.03 diff --git a/Task/Sailors-coconuts-and-a-monkey-problem/EasyLang/sailors-coconuts-and-a-monkey-problem.easy b/Task/Sailors-coconuts-and-a-monkey-problem/EasyLang/sailors-coconuts-and-a-monkey-problem.easy new file mode 100644 index 0000000000..b8f4a4f96f --- /dev/null +++ b/Task/Sailors-coconuts-and-a-monkey-problem/EasyLang/sailors-coconuts-and-a-monkey-problem.easy @@ -0,0 +1,18 @@ +func valid n nuts . + k = n + while k <> 0 + if nuts mod n <> 1 + return 0 + . + k -= 1 + nuts -= 1 + nuts div n + . + return if nuts <> 0 and nuts mod n = 0 +. +for n = 5 to 6 + x = 0 + while valid n x = 0 + x += 1 + . + print n & ": " & x +. diff --git a/Task/Scope-Function-names-and-labels/EasyLang/scope-function-names-and-labels.easy b/Task/Scope-Function-names-and-labels/EasyLang/scope-function-names-and-labels.easy new file mode 100644 index 0000000000..fd8a09f537 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/EasyLang/scope-function-names-and-labels.easy @@ -0,0 +1,13 @@ +# function names are global, the must be +# implemented or declared before usage +# +func foo1 a . + return a + 1 +. +print foo1 2 +# +funcdecl foo2 a . +print foo2 2 +func foo2 a . + return a + 2 +. diff --git a/Task/Scope-Function-names-and-labels/Wren/scope-function-names-and-labels.wren b/Task/Scope-Function-names-and-labels/Wren/scope-function-names-and-labels.wren index 12e8b689b0..e0b97bb5b2 100644 --- a/Task/Scope-Function-names-and-labels/Wren/scope-function-names-and-labels.wren +++ b/Task/Scope-Function-names-and-labels/Wren/scope-function-names-and-labels.wren @@ -1,4 +1,4 @@ -//func.call() /* invalid, can't call func before its declared */ +// func.call() /* invalid, can't call func before its defined */ var func = Fn.new { System.print("func has been called.") } @@ -7,8 +7,17 @@ func.call() // fine //C.init() /* not OK, as C is null at this point */ class C { - static init() { method() } // fine even though 'method' not yet declared + static init() { method() } // fine even though 'method' not yet defined static method() { System.print("method has been called.") } } C.init() // fine + +/* Although this function is recursive, there is no need for a forward + declaration as it is top-level and begins with a capital letter. */ +var Fib = Fn.new { |n| + if (n < 2) return n + return Fib.call(n-1) + Fib.call(n-2) // Fib already visible here +} + +System.print(Fib.call(8)) // fine diff --git a/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-1.pas b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-1.pas new file mode 100644 index 0000000000..3e18ebf09e --- /dev/null +++ b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-1.pas @@ -0,0 +1 @@ +private diff --git a/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-2.pas b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-2.pas new file mode 100644 index 0000000000..418c98625a --- /dev/null +++ b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-2.pas @@ -0,0 +1 @@ +protected diff --git a/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-3.pas b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-3.pas new file mode 100644 index 0000000000..a48cf0de7a --- /dev/null +++ b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-3.pas @@ -0,0 +1 @@ +public diff --git a/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-4.pas b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-4.pas new file mode 100644 index 0000000000..ce83b25d66 --- /dev/null +++ b/Task/Scope-modifiers/PascalABC.NET/scope-modifiers-4.pas @@ -0,0 +1 @@ +internal diff --git a/Task/Search-a-list/Ecstasy/search-a-list.ecstasy b/Task/Search-a-list/Ecstasy/search-a-list.ecstasy new file mode 100644 index 0000000000..3806d41af5 --- /dev/null +++ b/Task/Search-a-list/Ecstasy/search-a-list.ecstasy @@ -0,0 +1,12 @@ +module test { + @Inject Console console; + + void run() { + String[] haystack = ["this", "needle", "is", "a", "test"]; + if (Int pos := haystack.indexOf("needle")) { + console.print($"Found the needle at {pos=}"); + } else { + console.print("No needle in the haystack"); + } + } +} diff --git a/Task/Search-in-paragraphs-text/Perl/search-in-paragraphs-text.pl b/Task/Search-in-paragraphs-text/Perl/search-in-paragraphs-text.pl new file mode 100644 index 0000000000..020884a4a4 --- /dev/null +++ b/Task/Search-in-paragraphs-text/Perl/search-in-paragraphs-text.pl @@ -0,0 +1,15 @@ +use strict; +use warnings; + +local $/ = ""; # Set the input record separator to an empty string to read paragraph mode +local $\ = "\n----------------\n"; # Set the output record separator + +# Open the file Traceback.txt for reading +open my $fh, '<', 'Traceback.txt' or die "Cannot open Traceback.txt: $!"; + +# Read one paragraph at a time +while (<$fh>) { + if (/Traceback \(most recent call last\):/ && /SystemError/) { + print substr($_, index($_, "Traceback (most recent call last):")); + } +} diff --git a/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada/selectively-replace-multiple-instances-of-a-character-within-a-string.ada b/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada/selectively-replace-multiple-instances-of-a-character-within-a-string.ada new file mode 100644 index 0000000000..3e21c4e429 --- /dev/null +++ b/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/Ada/selectively-replace-multiple-instances-of-a-character-within-a-string.ada @@ -0,0 +1,42 @@ +-- Selectively replace multiple instances of a character within a string +-- J. Carter 2024 Jun + +with Ada.Strings.Fixed; +with Ada.Text_IO; + +procedure Selectively_Replace is + procedure Replace + (Letter : in Character; Occurrence : in Positive; Within : in String; By : in Character; Into : in out String) + with Pre => Into'First = Within'First and Into'Last = Within'Last; + -- Finds the index of the Occurrence-th instance of Letter in Within and sets the character in Into at that index to By + -- If there is no such index, has no effect + -- Before the first call to replace, Within should be = Into + + procedure Replace + (Letter : in Character; Occurrence : in Positive; Within : in String; By : in Character; Into : in out String) + is + Start : Natural := 0; + begin -- Replace + Find : for I in 1 .. Occurrence loop + Start := Ada.Strings.Fixed.Index (Within, Letter & "", Start + 1); + + if Start = 0 then -- Within has fewer than Occurrence instances of Letter + return; + end if; + end loop Find; + + Into (Start) := By; + end Replace; + + Source : constant String := "abracadabra"; + + Result : String := Source; +begin -- Selectively_Replace + Replace (Letter => 'a', Occurrence => 1, Within => Source, By => 'A', Into => Result); + Replace (Letter => 'a', Occurrence => 2, Within => Source, By => 'B', Into => Result); + Replace (Letter => 'a', Occurrence => 4, Within => Source, By => 'C', Into => Result); + Replace (Letter => 'a', Occurrence => 5, Within => Source, By => 'D', Into => Result); + Replace (Letter => 'b', Occurrence => 1, Within => Source, By => 'E', Into => Result); + Replace (Letter => 'r', Occurrence => 2, Within => Source, By => 'F', Into => Result); + Ada.Text_IO.Put_Line (Item => Source & " => " & Result); +end Selectively_Replace; diff --git a/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang/selectively-replace-multiple-instances-of-a-character-within-a-string.easy b/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang/selectively-replace-multiple-instances-of-a-character-within-a-string.easy new file mode 100644 index 0000000000..9fcb0ea68b --- /dev/null +++ b/Task/Selectively-replace-multiple-instances-of-a-character-within-a-string/EasyLang/selectively-replace-multiple-instances-of-a-character-within-a-string.easy @@ -0,0 +1,20 @@ +rs$[] = [ "a" "b" "r" ] +rc[][] = [ [ 1 2 4 5 ] [ 1 ] [ 2 ] ] +rd$[][] = [ [ "A" "B" "C" "D" ] [ "E" ] [ "F" ] ] +s$ = "abracadabra" +# +len cnt[] len rs$[] +for c$ in strchars s$ + for i to len rs$[] + if c$ = rs$[i] + cnt[i] += 1 + for j to len rc[i][] + if rc[i][j] = cnt[i] + c$ = rd$[i][j] + . + . + . + . + r$ &= c$ +. +print r$ diff --git a/Task/Self-numbers/EasyLang/self-numbers.easy b/Task/Self-numbers/EasyLang/self-numbers.easy new file mode 100644 index 0000000000..ceb25d963d --- /dev/null +++ b/Task/Self-numbers/EasyLang/self-numbers.easy @@ -0,0 +1,47 @@ +fastfunc digsum h . + while h > 0 + sum += h mod 10 + h = h div 10 + . + return sum +. +fastfunc isself start i . + j = start + sum = digsum start + while j < i + if j + sum = i + return 0 + . + sum += 1 + j += 1 + if j mod 10 = 0 + sum = digsum j + . + . + return 1 +. +proc main . . + i = 1 + po = 10 + digits = 1 + offs = 9 + repeat + start = higher (i - offs) 0 + if isself start i = 1 + cnt += 1 + if cnt <= 50 + write i & " " + . + . + until cnt = 100000000 + i += 1 + if i mod po = 0 + po *= 10 + digits += 1 + offs = digits * 9 + . + . + print "" + print i +. +main diff --git a/Task/Semiprime/REXX/semiprime-4.rexx b/Task/Semiprime/REXX/semiprime-4.rexx new file mode 100644 index 0000000000..9a4cef25e5 --- /dev/null +++ b/Task/Semiprime/REXX/semiprime-4.rexx @@ -0,0 +1,59 @@ +/*REXX program determines if any integer (or a range of integers) is/are semiprime. */ +numeric digits 100 +call time('r') +parse arg bot top . /*obtain optional arguments from the CL*/ +if bot=='' | bot=="," then bot=random() /*None givenqq User wants us to guess.*/ +if top=='' | top=="," then top=bot /*maybe define a range of numbers. */ +tell= (top>0) /*should results be shown to the termqq */ +w=max(length(bot), length(top)) /*obtain the maximum width of numbers. */ +numeric digits max(9, w) /*ensure there're enough decimal digits*/ +hh=0 /*initialize number of semiprimes found*/ + do n=abs(bot) to abs(top) /*show results for a range of numbers. */ + qq=semiPrime(n); hh=hh+qq /*Is N a semiprimeqq; Maybe bump counter*/ +if tell then say right(n,w) right(word("isn't" 'is', qq+1), 6) 'semiprime.' '('format(time('e'),,3) 'seconds)' +call time('r') + end /*n*/ +say +if bot\==top then say 'found ' hh " semiprimes." +say format(time('e'),,3) ' seconds' +exit /*stick a fork in it, we're all done. */ +/*--------------------------------------------------------------------------------------*/ +Semiprime: +-- Is a number semi prime? function +procedure expose glob. +arg x +-- Validity +if \ whole(x) then + return 'X' +if x < 1 then + return 'X' +if x < 4 then + return 0 +-- Low semiprimes +s = '4 6 9 10 14 15 21 22 25 26 33 34 35 38 39 46 49 51 55 57 58 62 65 69 74 77 82 85 86 87 91 93 94 95' +-- Fast values +if x < 101 then do + if wordPos(x,s) = 0 then + return 0 + else + return 1 +end +-- Wheeled scan +do i = 2 for 2 + if x//i = 0 then + if Prime(x%i) then + return 1 + else + return 0 +end +do i = 5 by 6 until i*i > x +-- say 'i' i 'i*i' i*i 'x' x + do j = i by 2 for 2 + if x//j==0 then + if Prime(x%j) then + return 1 + else + return 0 + end +end +return 0 diff --git a/Task/Semordnilap/SuperCollider/semordnilap-1.sc b/Task/Semordnilap/SuperCollider/semordnilap-1.sc deleted file mode 100644 index aa3774f558..0000000000 --- a/Task/Semordnilap/SuperCollider/semordnilap-1.sc +++ /dev/null @@ -1,12 +0,0 @@ -( -var text, words, sdrow, semordnilap, selection; -File.use("unixdict.txt".resolveRelative, "r", { |f| x = text = f.readAllString }); -words = text.split(Char.nl).collect { |each| each.asSymbol }; -sdrow = text.reverse.split(Char.nl).collect { |each| each.asSymbol }; -semordnilap = sect(words, sdrow); // converted to symbols so intersection is possible -semordnilap = semordnilap.collect { |each| each.asString }; -"There are % in unixdict.txt\n".postf(semordnilap.size); -"For example those, with more than 3 characters:".postln; -selection = semordnilap.select { |each| each.size >= 4 }.scramble.keep(4); -selection.do { |each| "% %\n".postf(each, each.reverse); }; -) diff --git a/Task/Semordnilap/SuperCollider/semordnilap-2.sc b/Task/Semordnilap/SuperCollider/semordnilap-2.sc deleted file mode 100644 index c33b0276f6..0000000000 --- a/Task/Semordnilap/SuperCollider/semordnilap-2.sc +++ /dev/null @@ -1,6 +0,0 @@ -There are 405 in unixdict.txt -For example those, with more than 3 characters: -live evil -tram mart -drib bird -eros sore diff --git a/Task/Semordnilap/Uiua/semordnilap.uiua b/Task/Semordnilap/Uiua/semordnilap.uiua index 8c92539883..6905130272 100644 --- a/Task/Semordnilap/Uiua/semordnilap.uiua +++ b/Task/Semordnilap/Uiua/semordnilap.uiua @@ -1 +1,3 @@ -&p &pf "Count: " ⧻.▽≡(×>⇌.⟜∊⇌)⟜¤. ⊜□ ≠@\n. &fras "unixdict.txt" +A ← map:⊚⧻.⊜□≠@\n.&fras"unixdict.txt" +▽:⟜≡(↧⊃(<⇌.|has⇌))⊙◌°map⟜¤A +&p$"Found _ semordnilaps:"⊸⧻ diff --git a/Task/Send-an-unknown-method-call/Ecstasy/send-an-unknown-method-call.ecstasy b/Task/Send-an-unknown-method-call/Ecstasy/send-an-unknown-method-call.ecstasy new file mode 100644 index 0000000000..b6f5ebf098 --- /dev/null +++ b/Task/Send-an-unknown-method-call/Ecstasy/send-an-unknown-method-call.ecstasy @@ -0,0 +1,21 @@ +module test { + @Inject Console console; + + void run(String[] args) { + String name = args.empty ? "foo" : args[0]; + if (val mm := &this.actualType.multimethods.get(name), + val m := mm.methods.any(m -> m.ParamTypes.size == 0)) { + m.invoke(this, Tuple:()); + } else { + console.print($"No such 0-parameter method: {name.quoted()}"); + } + } + + void foo() { + console.print("this is the foo() method"); + } + + void bar() { + console.print("this is the bar() method"); + } +} diff --git a/Task/Send-an-unknown-method-call/PascalABC.NET/send-an-unknown-method-call.pas b/Task/Send-an-unknown-method-call/PascalABC.NET/send-an-unknown-method-call.pas new file mode 100644 index 0000000000..00019bcb23 --- /dev/null +++ b/Task/Send-an-unknown-method-call/PascalABC.NET/send-an-unknown-method-call.pas @@ -0,0 +1,10 @@ +type MyClass = class +public + procedure Hello := Write('Hello'); +end; + +begin + var obj := new MyClass; + var mi := typeof(MyClass).GetMethod('Hello'); + mi.Invoke(obj,new object[0]) +end. diff --git a/Task/Sequence-of-primes-by-trial-division/PascalABC.NET/sequence-of-primes-by-trial-division.pas b/Task/Sequence-of-primes-by-trial-division/PascalABC.NET/sequence-of-primes-by-trial-division.pas new file mode 100644 index 0000000000..eee758aeaa --- /dev/null +++ b/Task/Sequence-of-primes-by-trial-division/PascalABC.NET/sequence-of-primes-by-trial-division.pas @@ -0,0 +1,4 @@ +## +function IsPrime(n: integer) := (2..n.Sqrt.Round).All(i -> n.NotDivs(i)); + +(2..100).Where(IsPrime).Println diff --git a/Task/Set-puzzle/Jq/set-puzzle.jq b/Task/Set-puzzle/Jq/set-puzzle.jq new file mode 100644 index 0000000000..fadc9523e6 --- /dev/null +++ b/Task/Set-puzzle/Jq/set-puzzle.jq @@ -0,0 +1,77 @@ +# Source of entropy +include "MRG32k3a" {search: "."}; # see above + +### General utilities + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +def array_swap($i; $j): + if $i < $j then array_swap($j;$i) + elif $i == $j then . + else .[$i] as $t + | .[:$j] + [$t] + .[$j:$i] + .[$i + 1:] + end ; + +# input: array of length $n +def shuffle: + length as $n + | ($n | prn($n)) as $prn + # First cut the deck + | .[$prn[0]:] + .[:$prn[0]] + | reduce range(0; $n - 1) as $i (.; + array_swap($prn[$i]; $prn[$i+1]) ) ; + + +### The Set Game + +# For the standard Set game: +def attributes: ["Color", "Symbol", "Number", "Shading"]; +def number_of_values: 3; + +# a single card +def toString: + [attributes, .] | transpose + | map(join(": ")|lpad(7)) + | join(" "); + +# Create a deck for which each attribute defined by `attributes` has $j possible values: +def createDeck($j): + (attributes|length) as $k + | [range(0;$j)] + | [combinations($k)]; + +def isSet: + . as $trio + | all( range(0; attributes|length); + . as $i | $trio | map(.[$i]) | unique | length | IN(1,number_of_values)); + +# For the standard Set game +# For "advanced" play, set $advanced == true +def playGame( $advanced ): + (if $advanced then 12 else 9 end) as $nCards + | (($nCards/2)|floor) as $nSets + | {sets: [], deck: createDeck(number_of_values) } + | label $out + | foreach range(0; infinite) as $_ (.; + .deck |= shuffle + | .sets = [] + | foreach range(0; $nCards-2) as $i (.; + foreach range($i+1; $nCards-1) as $j (.; + foreach range($j+1; $nCards) as $k (.; + [.deck[$i], .deck[$j], .deck[$k]] as $trio + | if $trio | isSet + then .sets += [$trio] + | if (.sets|length) >= $nSets + then .emit = true, break $out + end + end ) ) ) ) + | select(.emit) + | (.deck[0:$nCards] | sort) as $hand + | "DEALT \($nCards) CARDS:", + ($hand[]|toString), + "\nCONTAINING \($nSets) SETS:", + (.sets + | sort[] + | ((.[] | toString),"") ), "" ; + +playGame(false, true) diff --git a/Task/Set-right-adjacent-bits/Jq/set-right-adjacent-bits.jq b/Task/Set-right-adjacent-bits/Jq/set-right-adjacent-bits.jq new file mode 100644 index 0000000000..e82b0d59fa --- /dev/null +++ b/Task/Set-right-adjacent-bits/Jq/set-right-adjacent-bits.jq @@ -0,0 +1,27 @@ +# Input should be an array of 0s and 1s +def setRightBits($e; $n): + if $e == 0 or $n <= 0 then . + else . as $bits + | reduce range(0; $e - 1) as $i ({bits2: .}; + $bits[$i] as $c + | if $c == 1 + then .j = $i + 1 + | until (.j > ($i + $n) or .j >= $e; + .bits2[.j] = 1 + | .j += 1 ) + end) + | .bits2 + end; + +def b: + "010000000000100000000010000000010000000100000010000010000100010010"; + +def tests: + [["1000", 2], ["0100", 2], ["0010", 2], ["0000", 2], [b, 0], [b, 1], [b, 2], [b, 3]]; + +tests[] as [$bits, $n] +| ($bits|length) as $e +| "n = \($n); Width e = \($e):", + " Input b: \($bits)", + ( ($bits | [explode[] | . - 48]) as $b + | " Result: \($b | setRightBits($e; $n) | join(""))\n" ) diff --git a/Task/Sexy-primes/BASIC256/sexy-primes.basic b/Task/Sexy-primes/BASIC256/sexy-primes.basic new file mode 100644 index 0000000000..83b424fff2 --- /dev/null +++ b/Task/Sexy-primes/BASIC256/sexy-primes.basic @@ -0,0 +1,70 @@ +include "isprime.kbs" + +maxi = 1000035 +cu = 0 +c2 = 0 +c3 = 0 +c4 = 0 +c5 = 0 +#, n, i, +p = 0 +dim unsexy(10) +dim pairs(5) +dim trips(5) +dim quads(5) +dim quins(5) + +for n = maxi to 2 step -1 + if isPrime(n) then + p += 1 + if not isPrime(n-6) and not isPrime(n+6) then + if cu < 10 then unsexy[cu] = n + cu += 1 + end if + if isPrime(n-6) then + if c2 < 5 then pairs[c2] = n + c2 += 1 + if isPrime(n-12) then + if c3 < 5 then trips[c3] = n + c3 += 1 + if isPrime(n-18) then + if c4 < 5 then quads[c4] = n + c4 += 1 + if isPrime(n-24) then + if c5 < 5 then quins[c5] = n + c5 += 1 + end if + end if + end if + end if + end if +next n + +print p; " primes less than "; maxi + +print chr(10); c2; " pairs ending with:" +for i = 4 to 0 step -1 + print " ["; pairs[i]-6; ", "; pairs[i]; "]" +next i + +print chr(10); c3; " triplets ending with:" +for i = 4 to 0 step -1 + print " ["; trips[i]-12; ", "; trips[i]-6; ", "& trips[i]; "]" +next i + +print chr(10); c4; " quadruplets ending with:" +for i = 4 to 0 step -1 + print " ["; quads[i]-18; ", "; quads[i]-12; ", "; quads[i]-6; ", "; quads[i]; "]" +next i + +print chr(10); c5; " quintuplet(s) ending with:" +if c5 > 5 then i = 5 else i = c5 +for i = i-1 to 0 step -1 + print " ["; quins[i]-24; ", "& quins[i]-18; ", "& quins[i]-12; ", "& quins[i]-6; ", "& quins[i]; "]" +next i + +print chr(10); cu; " unsexy primes ending with:" +for i = 9 to 0 step -1 + print unsexy[i]; ","; +next i +end diff --git a/Task/Sexy-primes/FreeBASIC/sexy-primes.basic b/Task/Sexy-primes/FreeBASIC/sexy-primes.basic index 91dfcd7117..1fc2d9420a 100644 --- a/Task/Sexy-primes/FreeBASIC/sexy-primes.basic +++ b/Task/Sexy-primes/FreeBASIC/sexy-primes.basic @@ -1,14 +1,4 @@ -Function isPrime(Byval ValorEval As Uinteger) As Boolean - If ValorEval < 2 Then Return False - If ValorEval Mod 2 = 0 Then Return ValorEval = 2 - If ValorEval Mod 3 = 0 Then Return ValorEval = 3 - Dim d As Integer = 5 - While d * d <= ValorEval - If ValorEval Mod d = 0 Then Return False Else d += 2 - If ValorEval Mod d = 0 Then Return False Else d += 4 - Wend - Return True -End Function +#include "isprime.bas" #define maxi 1000035 Dim As Integer CU = 0, C2 = 0, C3 = 0, C4 = 0, C5 = 0, N, I, P = 0 diff --git a/Task/Sexy-primes/Yabasic/sexy-primes.basic b/Task/Sexy-primes/Yabasic/sexy-primes.basic new file mode 100644 index 0000000000..5873017f2e --- /dev/null +++ b/Task/Sexy-primes/Yabasic/sexy-primes.basic @@ -0,0 +1,66 @@ +import isprime + +maxi = 1000035 +cu = 0 +c2 = 0 +c3 = 0 +c4 = 0 +c5 = 0 +p = 0 +dim unsexy(10), pairs(5), trips(5), quads(5), quins(5) + +for n = maxi to 2 step -1 + if isPrime(n) then + p = p + 1 + if not isPrime(n - 6) and not isPrime(n + 6) then + if cu < 10 unsexy(cu) = n + cu = cu + 1 + fi + if isPrime(n - 6) then + if c2 < 5 pairs(c2) = n + c2 = c2 + 1 + if isPrime(n - 12) then + if c3 < 5 trips(c3) = n + c3 = c3 + 1 + if isPrime(n - 18) then + if c4 < 5 quads(c4) = n + c4 = c4 + 1 + if isPrime(n - 24) then + if c5 < 5 quins(c5) = n + c5 = c5 + 1 + fi + fi + fi + fi + fi +next n + +print p, " primes less than ", maxi + +print chr$(10), c2, " pairs ending with:" +for i = 4 to 0 step -1 + print " [", pairs(i)-6, ", ", pairs(i), "]" +next i + +print chr$(10), c3, " triplets ending with:" +for i = 4 to 0 step -1 + print " [", trips(i)-12, ", ", trips(i)-6, ", ", trips(i), "]" +next i + +print chr$(10), c4, " quadruplets ending with:" +for i = 4 to 0 step -1 + print " [", quads(i)-18, ", ", quads(i)-12, ", ", quads(i)-6, ", ", quads(i), "]" +next i + +print chr$(10), c5, " quintuplet(s) ending with:" +if c5 > 5 then i = 5 else i = c5 : fi +for i = i-1 to 0 step -1 + print " [", quins(i)-24, ", ", quins(i)-18, ", ", quins(i)-12, ", ", quins(i)-6, ", ", quins(i), "]" +next i + +print chr$(10), cu, " unsexy primes ending with:" +for i = 9 to 0 step -1 + print unsexy(i), ","; +next i +print chr$(8)," " +end diff --git a/Task/Show-ASCII-table/Langur/show-ascii-table.langur b/Task/Show-ASCII-table/Langur/show-ascii-table.langur index 54fbcf7601..3659e774e6 100644 --- a/Task/Show-ASCII-table/Langur/show-ascii-table.langur +++ b/Task/Show-ASCII-table/Langur/show-ascii-table.langur @@ -1,7 +1,7 @@ -for .i of 16 { - for .j = 31 + .i ; .j < 128 ; .j += 16 { - val .L = switch(.j; 32: "spc"; 127: "del"; cp2s .j) - write $"\{.j:3} : \{.L:-4}" +for i of 16 { + for j = 31 + i ; j < 128 ; j += 16 { + val L = switch(j; 32: "spc"; 127: "del"; cp2s(j)) + write "{{j:3}} : {{L:-4}}" } writeln() } diff --git a/Task/Show-ASCII-table/SETL/show-ascii-table.setl b/Task/Show-ASCII-table/SETL/show-ascii-table.setl new file mode 100644 index 0000000000..1e1a366e2b --- /dev/null +++ b/Task/Show-ASCII-table/SETL/show-ascii-table.setl @@ -0,0 +1,9 @@ +program ascii_table; + loop for i in [32..47] do + print(+/[lpad(str j, 3) + ' : ' + rpad(ascii j, 6) : j in [i, i+16..127]]); + end loop; + + op ascii(n); + return {[32, 'Spc'], [127, 'Del']}(n) ? (char n); + end op; +end program; diff --git a/Task/Show-the-epoch/EasyLang/show-the-epoch.easy b/Task/Show-the-epoch/EasyLang/show-the-epoch.easy new file mode 100644 index 0000000000..025029e439 --- /dev/null +++ b/Task/Show-the-epoch/EasyLang/show-the-epoch.easy @@ -0,0 +1,2 @@ +# local time zone +print timestr 0 diff --git a/Task/Sierpinski-pentagon/Jq/sierpinski-pentagon.jq b/Task/Sierpinski-pentagon/Jq/sierpinski-pentagon.jq new file mode 100644 index 0000000000..a832f26b1b --- /dev/null +++ b/Task/Sierpinski-pentagon/Jq/sierpinski-pentagon.jq @@ -0,0 +1,59 @@ +### Generic functions + +def addComplex(stream): reduce stream as [$x,$y] ([0,0]; .[0] += $x | .[1] += $y); + +def lpad($len; $x): tostring | ($len - length) as $l | ($x * $l) + .; + +# Input: an array +def multiply($x): map(. * $x); + +# Round to approx $ndec places +def round($ndec): pow(10;$ndec) as $p | . * $p | round / $p; + +def power($a; $b): reduce range(0;$b) as $i (1; . * $a); + +def tau: 8 * atan2(1; 1); + +def tobase($b): + def digit: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[.:.+1]; + def mod: . % $b; + def div: ((. - mod) / $b); + def digits: recurse( select(. > 0) | div) | mod ; + # For jq it would be wise to protect against `infinite` as input, but using `isinfinite` confuses gojq + select( (tostring|test("^[0-9]+$")) and 2 <= $b and $b <= 36) + | if . == 0 then "0" + else [digits | digit] | reverse[1:] | add + end; + +### Sierpinski Pentagons + +def svgHead($width): + ""; + +def svgEnd: ""; + +# SVG height and width will be 2 * dim +def pentagon($dim): + def sides: 5; + def order: 5; + def scale: (3 - (order | sqrt)) / 2; + + def cis: [cos, sin]; + def orders: + [range(0; order) | ((1 - scale) * $dim) * power(scale ; .) ]; + def vertices: + tau as $tau | [range(0; sides) | ( . * $tau / sides | cis)]; + + svgHead(2*$dim), + (orders as $orders + | vertices as $vertices + | range(1; 1 + power(sides; order)) as $i + | [ ($i|tobase(sides) | lpad(order; "0") | split("")[]) | $vertices[tonumber]] as $varr + | addComplex(range(0; $orders|length) as $i | $varr[$i] | multiply($orders[$i])) as $vector + | ($vertices | map( addComplex($vector, multiply($orders[-1] * (1-scale))))) as $vprod + | ($vprod | map( map(round(3)) | "\(.[0]) \(.[1])") | join(" ")) as $points + | ""), + svgEnd ; + +pentagon(250) diff --git a/Task/Sierpinski-square-curve/Ada/sierpinski-square-curve.ada b/Task/Sierpinski-square-curve/Ada/sierpinski-square-curve.ada new file mode 100644 index 0000000000..518a2e97b0 --- /dev/null +++ b/Task/Sierpinski-square-curve/Ada/sierpinski-square-curve.ada @@ -0,0 +1,49 @@ +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +procedure Sierpinski_Square_Curve is + Axiom : constant String := "F+XF+F+XF"; + Rules : constant String := "XF-F+F-XF+F+XF-F+F-X"; + ORDER : constant Positive := 5; + LENGTH : constant Positive := 4; + X : Integer := (600 - LENGTH) / 2; + Y : Integer := LENGTH; + Angle : Integer := 0; + SVG_File : File_Type; + Production : Unbounded_String := To_Unbounded_String (Axiom); + function Rewrite (Str : String) return Unbounded_String is + Prod : Unbounded_String; + begin + for C of Str loop + if C = 'X' then + Prod := Prod & Rules; + else + Prod := Prod & C; + end if; + end loop; + return Prod; + end Rewrite; +begin + Create (SVG_File, Out_File, "sierpinski.svg"); + Put_Line (SVG_File, ""); + Put_Line (SVG_File, ""); + Put (SVG_File, " + X := X + LENGTH * Integer (Cos (Float (Angle), 360.0)); + Y := Y + LENGTH * Integer (Sin (Float (Angle), 360.0)); + Put (SVG_File, " L" & X'Image & "," & Y'Image); + when '+' => Angle := (Angle + 90) mod 360; + when '-' => Angle := (Angle - 90) mod 360; + when others => null; + end case; + end loop; + Put_Line (SVG_File, "'/>\n"); + Close (SVG_File); +end Sierpinski_Square_Curve; diff --git a/Task/Sierpinski-triangle/EasyLang/sierpinski-triangle.easy b/Task/Sierpinski-triangle/EasyLang/sierpinski-triangle.easy new file mode 100644 index 0000000000..51c9ff37bb --- /dev/null +++ b/Task/Sierpinski-triangle/EasyLang/sierpinski-triangle.easy @@ -0,0 +1,14 @@ +size = bitshift 1 4 - 1 +for y = size downto 0 + for i = 0 to y - 1 + write " " + . + for x = 0 to size - y + if bitand x y <> 0 + write " " + else + write "* " + . + . + write "\n" +. diff --git a/Task/Sieve-of-Eratosthenes/EasyLang/sieve-of-eratosthenes.easy b/Task/Sieve-of-Eratosthenes/EasyLang/sieve-of-eratosthenes.easy index 9ce7a9a5c4..ca63c7c0d5 100644 --- a/Task/Sieve-of-Eratosthenes/EasyLang/sieve-of-eratosthenes.easy +++ b/Task/Sieve-of-Eratosthenes/EasyLang/sieve-of-eratosthenes.easy @@ -1,14 +1,16 @@ -len is_divisible[] 100 -max = sqrt len is_divisible[] -for d = 2 to max - if is_divisible[d] = 0 - for i = d * d step d to len is_divisible[] - is_divisible[i] = 1 +len sieve[] 100 +max = sqrt len sieve[] +for i = 2 to max + if sieve[i] = 0 + j = i * i + while j <= len sieve[] + sieve[j] = 1 + j += i . . . -for i = 2 to len is_divisible[] - if is_divisible[i] = 0 +for i = 2 to len sieve[] + if sieve[i] = 0 print i . . diff --git a/Task/Sieve-of-Eratosthenes/Erlang/sieve-of-eratosthenes-6.erl b/Task/Sieve-of-Eratosthenes/Erlang/sieve-of-eratosthenes-6.erl new file mode 100644 index 0000000000..1c9f4d57a9 --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/Erlang/sieve-of-eratosthenes-6.erl @@ -0,0 +1,20 @@ +-module(primesieve). +-export([primes/1]). + +mult(N, Limit) -> + case Limit > N * N of + true -> lists:seq(N * N, Limit, N); + false -> [] + end. + +primes(Limit) -> + case Limit > 1 of + true -> sieve(Limit, 3, [2] ++ lists:seq(3, Limit, 2), mult(3, Limit)); + false -> [] + end. + +sieve(Limit, D, S, M) -> + case Limit < D * D of + true -> S; + false -> sieve(Limit, D + 2, S -- M, mult(D + 2, Limit)) + end. diff --git a/Task/Sieve-of-Eratosthenes/Langur/sieve-of-eratosthenes.langur b/Task/Sieve-of-Eratosthenes/Langur/sieve-of-eratosthenes.langur index 62cfd57a77..ed2a4bd2b4 100644 --- a/Task/Sieve-of-Eratosthenes/Langur/sieve-of-eratosthenes.langur +++ b/Task/Sieve-of-Eratosthenes/Langur/sieve-of-eratosthenes.langur @@ -1,18 +1,18 @@ -val .sieve = fn(.limit) { - if .limit < 2: return [] +val sieve = fn(limit) { + if limit < 2: return [] - var .composite = .limit * [false] - .composite[1] = true + var composite = limit * [false] + composite[1] = true - for .n in 2 .. trunc(.limit ^/ 2) + 1 { - if not .composite[.n] { - for .k = .n^2 ; .k < .limit ; .k += .n { - .composite[.k] = true + for n in 2 .. trunc(limit ^/ 2) + 1 { + if not composite[n] { + for k = n^2 ; k < limit ; k += n { + composite[k] = true } } } - filter fn(.n) not .composite[.n], series .limit-1 + filter fn n:not composite[n], series(limit-1) } -writeln .sieve(100) +writeln sieve(100) diff --git a/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-7.ocaml b/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-7.ocaml new file mode 100644 index 0000000000..e8250c81ac --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-7.ocaml @@ -0,0 +1,16 @@ +let sieve limit = + let p = Array.make (limit + 1) true in + let rec sieve_outer d = + if d * d > limit then p + else if p.(d) then + let rec sieve_inner m = + if m > limit then sieve_outer (d + 1) + else ((p.(m) <- false); sieve_inner (m + d)) + in sieve_inner (d * d) + else sieve_outer (d + 1) + in sieve_outer 2 + +let primes limit = + let s = (sieve limit) in + List.init (limit - 1) (fun i -> i + 2) + |> List.filter (fun x -> s.(x)) diff --git a/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-8.ocaml b/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-8.ocaml new file mode 100644 index 0000000000..4748dee4bb --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/OCaml/sieve-of-eratosthenes-8.ocaml @@ -0,0 +1,3 @@ +# primes 200;; +- : int list = +[2; 3; 5; 7; 11; 13; 17; 19; 23; 29; 31; 37; 41; 43; 47; 53; 59; 61; 67; 71; 73; 79; 83; 89; 97; 101; 103; 107; 109; 113; 127; 131; 137; 139; 149; 151; 157; 163; 167; 173; 179; 181; 191; 193; 197; 199] diff --git a/Task/Sieve-of-Eratosthenes/PascalABC.NET/sieve-of-eratosthenes.pas b/Task/Sieve-of-Eratosthenes/PascalABC.NET/sieve-of-eratosthenes.pas new file mode 100644 index 0000000000..07aafc9fdb --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/PascalABC.NET/sieve-of-eratosthenes.pas @@ -0,0 +1,17 @@ +function Eratosthenes(N: integer): List; +type primetype = (nonprime,prime); +begin + var sieve := |nonprime|*2 + |prime|*(N-1); + for var i:=2 to N.Sqrt.Round do + if sieve[i] = prime then + for var j := i*i to N step i do + sieve[j] := nonprime; + Result := new List; + for var i:=2 to N do + if sieve[i] = prime then + Result.Add(i); +end; + +begin + Eratosthenes(1000).Println +end. diff --git a/Task/Simple-database/11l/simple-database.11l b/Task/Simple-database/11l/simple-database.11l index a6cda0259c..a0e3d6734a 100644 --- a/Task/Simple-database/11l/simple-database.11l +++ b/Task/Simple-database/11l/simple-database.11l @@ -1,11 +1,4 @@ -T Item - String name, date, category - - F (name, date, category) - .name = name - .date = date - .category = category - +T Item((String name, String date, String category)) F String() R .name‘, ’(.date)‘, ’(.category) diff --git a/Task/Simple-database/C++/simple-database.cpp b/Task/Simple-database/C++/simple-database.cpp new file mode 100644 index 0000000000..cf265ce88b --- /dev/null +++ b/Task/Simple-database/C++/simple-database.cpp @@ -0,0 +1,147 @@ +#include +#include +#include +#include +#include +#include +#include + +const std::string filename = "Contacts.dat"; + +class Contact { +public: + Contact(const std::string& aName, const std::string& aBirth_Date, const std::string& aState, + const std::string& aRelation, const std::string& aEmail) + : name(aName), birth_date(aBirth_Date), state(aState), relation(aRelation), email(aEmail) { } + + std::string get_relation() const { + return relation; + } + + std::string to_string() const { + return name + ", " + birth_date + ", " + state + ", " + relation + ", " + email; + } + + bool operator<(const Contact& other) const { + return birth_date > other.birth_date; + } + +private: + std::string name, birth_date, state, relation, email; +}; + +std::vector contacts = { }; + +Contact parse(std::string entry) { + std::vector parts; + uint64_t position = 0; + while ( ( position = entry.find(", ") ) != std::string::npos ) { + parts.emplace_back(entry.substr(0, position)); + entry.erase(0, position + 2); + } + return Contact(parts[0], parts[1], parts[2], parts[3], entry); +} + +void write_file(const std::string& new_entry) { + std::fstream database(filename, std::ios::out | std::ios::app); + if ( database.is_open() ) { + database << new_entry; + database.close(); + } else { + std::cerr << "Unable to open database '" << filename << "' for writing" << std::endl; + } +} + +// Open the file if it exists, otherwise create a new empty file. +void read_file() { + std::fstream database(filename, std::ios::in | std::ios::app); + if ( database.is_open() ) { + std::string entry; + while ( std::getline(database, entry) ) { + contacts.emplace_back(parse(entry)); + } + database.close(); + } else { + std::cerr << "Unable to open database '" << filename << "' for reading" << std::endl; + } +} + +void add_new_entry() { + std::cout << "Type the new entry, without inverted commas, in the format:" << std::endl; + std::cout << "Name, Birth_Date, State, Relation, Email" << std::endl; + std::string new_entry; + std::cin.ignore(std::numeric_limits::max(), '\n'); // Clear the keyboard buffer + std::getline(std::cin, new_entry); + Contact contact(parse(new_entry)); + contacts.emplace_back(contact); + write_file(new_entry); + std::cout << "The contact \"" << new_entry << "\" has been added to the database" << std::endl; +} + +void show_latest_entry() { + if ( ! contacts.empty() ) { + std::cout << "The latest entry is: " + contacts.back().to_string() << std::endl; + } else { + std::cout << "There are currently no entries in the database" << std::endl; + } +} + +void show_latest_special_entry(const std::string& search) { + int32_t index = contacts.size() - 1; + while ( index >= 0 && contacts[index].get_relation() != search ) { + index--; + } + + if ( index >= 0 ) { + std::cout << "The latest " << search << " entry is " + contacts[index].to_string() << std::endl; + } else { + std::cout << "There are currently no " << search << " entries" << std::endl; + } +} + +void show_latest_friend_entry() { + show_latest_special_entry("Friend"); +} + +void show_latest_family_entry() { + show_latest_special_entry("Family"); +} + +void list_all_entries_by_age() { + if ( ! contacts.empty() ) { + std::vector copy_contacts = contacts; + std::sort(copy_contacts.begin(), copy_contacts.end()); + for ( const Contact& contact : copy_contacts ) { + std::cout << contact.to_string() << std::endl; + } + } else { + std::cout << "There are currently no entries in the database" << std::endl; + } +} + +int main() { + read_file(); + uint32_t choice = 0; + while ( choice != 6 ) { + std::cout << std::endl; + std::cout << " Menu " << std::endl; + std::cout << " 1: Add a new entry" << std::endl; + std::cout << " 2: Show latest entry" << std::endl; + std::cout << " 3: Show latest Friend entry" << std::endl; + std::cout << " 4: Show latest Family entry" << std::endl; + std::cout << " 5: List all entries by age" << std::endl; + std::cout << " 6: Close the program" << std::endl; + std::cout << std::endl; + + std::cin >> choice; + switch ( choice ) { + case 1 : add_new_entry(); break; + case 2 : show_latest_entry(); break; + case 3 : show_latest_friend_entry(); break; + case 4 : show_latest_family_entry(); break; + case 5 : list_all_entries_by_age(); break; + case 6 : std::cout << "Program closed" << std::endl; break; + default : std::cout << "Please enter a number in the range 1..6" << std::endl; break; + } + } +} diff --git a/Task/Simple-windowed-application/PascalABC.NET/simple-windowed-application.pas b/Task/Simple-windowed-application/PascalABC.NET/simple-windowed-application.pas new file mode 100644 index 0000000000..7767cd8186 --- /dev/null +++ b/Task/Simple-windowed-application/PascalABC.NET/simple-windowed-application.pas @@ -0,0 +1,13 @@ +uses WPF; + +begin + var mainpanel := Panels.StackPanel(200).AsMainContent; + var b := CreateButton('Click me!'); + var lb := CreateLabel('0'); + mainpanel.AddElements(b,lb); + var clicks := 0; + b.Click += (o,e) -> begin + clicks += 1; + lb.Content := clicks; + end; +end. diff --git a/Task/Singleton/Ecstasy/singleton.ecstasy b/Task/Singleton/Ecstasy/singleton.ecstasy new file mode 100644 index 0000000000..4ed6c14010 --- /dev/null +++ b/Task/Singleton/Ecstasy/singleton.ecstasy @@ -0,0 +1,15 @@ +module test { + static service Singleton { + private Int counter; + String fooHasBeenCalled() { + return $"{++counter} times"; + } + } + + void run() { + @Inject Console console; + for (Int i : 1..5) { + console.print($"{Singleton.fooHasBeenCalled()=}"); + } + } +} diff --git a/Task/Singly-linked-list-Element-definition/PascalABC.NET/singly-linked-list-element-definition.pas b/Task/Singly-linked-list-Element-definition/PascalABC.NET/singly-linked-list-element-definition.pas new file mode 100644 index 0000000000..050b35e550 --- /dev/null +++ b/Task/Singly-linked-list-Element-definition/PascalABC.NET/singly-linked-list-element-definition.pas @@ -0,0 +1,4 @@ +type Node = auto class + data: T; + next: Node; +end; diff --git a/Task/Singly-linked-list-Element-insertion/PascalABC.NET/singly-linked-list-element-insertion.pas b/Task/Singly-linked-list-Element-insertion/PascalABC.NET/singly-linked-list-element-insertion.pas new file mode 100644 index 0000000000..864ad7ddb1 --- /dev/null +++ b/Task/Singly-linked-list-Element-insertion/PascalABC.NET/singly-linked-list-element-insertion.pas @@ -0,0 +1,33 @@ +type Node = auto class + data: T; + next: Node; +end; + +type + SinglyLinkedList = class + first: Node; + procedure AddFirst(x: T); + begin + first := new Node(x,first); + end; + procedure AddAfter(p: Node; x: T); + begin + p.next := new Node(x,p.next); + end; + procedure PrintList(); + begin + var p := first; + while p<>nil do + begin + Print(p.data); + p := p.next; + end; + end; + end; + +begin + var lst := new SinglyLinkedList; + lst.AddFirst(2); lst.AddFirst(3); + lst.AddAfter(lst.first,555); + lst.PrintList; +end. diff --git a/Task/Sleep/PascalABC.NET/sleep.pas b/Task/Sleep/PascalABC.NET/sleep.pas new file mode 100644 index 0000000000..0fbf64a23c --- /dev/null +++ b/Task/Sleep/PascalABC.NET/sleep.pas @@ -0,0 +1,6 @@ +begin + var ms := ReadInteger; + Print('Sleeping...'); + Sleep(ms); + Print('Awake!'); +end. diff --git a/Task/Sleeping-Beauty-problem/ALGOL-68/sleeping-beauty-problem.alg b/Task/Sleeping-Beauty-problem/ALGOL-68/sleeping-beauty-problem.alg new file mode 100644 index 0000000000..634d6a6fe6 --- /dev/null +++ b/Task/Sleeping-Beauty-problem/ALGOL-68/sleeping-beauty-problem.alg @@ -0,0 +1,19 @@ +BEGIN # sleeping beauty problem - translated from the Wren sample # + PROC sleeping beauty = ( INT reps )REAL: + BEGIN + INT wakings := 0, heads := 0; + FOR i TO reps DO + wakings +:= 1; + IF next random < 0.5 THEN # [0..0.5) = heads, [0.5..1.0) = tails say # + heads +:= 1 + ELSE + wakings +:= 1 + FI + OD; + print( ( "Wakings over ", whole( reps, 0 ), " repetitions = ", whole( wakings, 0 ), newline ) ); + ( heads / wakings ) * 100 + END; # sleeping beauty # + + REAL pc = sleeping beauty( 1 000 000 ); + print( ( "Percentage probability of heads on waking = ", fixed( pc, -10, 6 ), "%", newline ) ) +END diff --git a/Task/Sleeping-Beauty-problem/Fortran/sleeping-beauty-problem.f b/Task/Sleeping-Beauty-problem/Fortran/sleeping-beauty-problem.f new file mode 100644 index 0000000000..f2eccd3d70 --- /dev/null +++ b/Task/Sleeping-Beauty-problem/Fortran/sleeping-beauty-problem.f @@ -0,0 +1,43 @@ +program sleepingbeauty + implicit none + + integer :: total_reps + integer :: result_wakings + real :: result_percent + + total_reps = 1e6 + + call sleepingOp(total_reps, result_wakings, result_percent) + + print *, "wakings over", total_reps, "reps: ", result_wakings + print *, "percentage probability of heads on wake:", result_percent + +contains + +subroutine sleepingOp(reps, wakings, percent) + integer, intent(in) :: reps + integer, intent(out) :: wakings + real, intent(out) :: percent + + integer :: heads + integer :: i + real :: coin + + wakings = 0 + heads = 0 + + do i = 0, reps, 1 + call random_number(coin) + wakings = wakings + 1 + if (coin > 0.5) then + heads = heads + 1 + else + wakings = wakings + 1 + end if + end do + + percent = real(heads) / real(wakings) + +end subroutine sleepingOp + +end program sleepingbeauty diff --git a/Task/Sleeping-Beauty-problem/FutureBasic/sleeping-beauty-problem.basic b/Task/Sleeping-Beauty-problem/FutureBasic/sleeping-beauty-problem.basic index bcffedb249..047d660c75 100644 --- a/Task/Sleeping-Beauty-problem/FutureBasic/sleeping-beauty-problem.basic +++ b/Task/Sleeping-Beauty-problem/FutureBasic/sleeping-beauty-problem.basic @@ -1,17 +1,17 @@ _iterations = 1000000 local fn SleepingBeauty -NSUInteger i -CGFloat heads = 0, sleep = 0 + NSUInteger i + CGFloat heads = 0, sleep = 0 -for i = 1 to _iterations -NSInteger coinToss = int( rnd(2) ) -sleep++ -if coinToss = 1 then heads++ else sleep++ -next + for i = 1 to _iterations + NSInteger coinToss = int( rnd(2) ) + sleep++ + if coinToss = 1 then heads++ else sleep++ + next -printf @"Awakenings over %lld sleep cycles = %.f", _iterations, sleep -printf @"Percent probability of heads on waking = %.4f%%", heads / sleep * 100 + printf @"Awakenings over %lld sleep cycles = %.f", _iterations, sleep + printf @"Percent probability of heads on waking = %.4f%%", heads / sleep * 100 end fn randomize diff --git a/Task/Sleeping-Beauty-problem/Jq/sleeping-beauty-problem.jq b/Task/Sleeping-Beauty-problem/Jq/sleeping-beauty-problem.jq new file mode 100644 index 0000000000..f882b5fe3a --- /dev/null +++ b/Task/Sleeping-Beauty-problem/Jq/sleeping-beauty-problem.jq @@ -0,0 +1,25 @@ +# Output: a PRN in range(0; .) +def prn: + if . == 1 then 0 + else . as $n + | (($n-1)|tostring|length) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +def round($ndec): pow(10;$ndec) as $p | . * $p | round / $p; + +# Output: {n, heads, wakings} +def sleepingBeauty: + { n: ., wakings: 0, heads: 0 } + | reduce range(0; .n) as $i (.; + (2|prn) as $coin # heads = 0, tails = 1 say + | .wakings += 1 + | if $coin == 0 then .heads += 1 + else .wakings += 1 + end ); + +1000000 +| sleepingBeauty +| "Wakings over \(.n) repetitions = \(.wakings).", + "Percentage probability of heads on waking = \(100*.heads/.wakings | round(3))%" diff --git a/Task/Smarandache-Wellin-primes/Sidef/smarandache-wellin-primes.sidef b/Task/Smarandache-Wellin-primes/Sidef/smarandache-wellin-primes.sidef new file mode 100644 index 0000000000..966e01c16a --- /dev/null +++ b/Task/Smarandache-Wellin-primes/Sidef/smarandache-wellin-primes.sidef @@ -0,0 +1,32 @@ +say "Smarandache-Wellen primes:" + +for (var (p=2, i=1, n='', nth=1); nth <= 8; (p.next_prime!, ++i)) { + n += Str(p) + if (Num(n).is_prime){ + var t = n + if (t.len > 50) { + t = (t.first(20) + ' ... ' + t.last(20) + " (#{t.len} digits)") + } + printf("%s: Index:%5d Last prime:%6d S-W: %s\n", nth, i, p, t) + ++nth + } +} + +say "\nSmarandache-Wellen derived primes:" + +func derived(String n) -> String { + var freq = n.chars.freq + 0..9 -> map { freq{_} \\ 0 }.join +} + +for (var (p=2, i=1, nth=1, n=''); nth <= 20; (p.next_prime!, ++i)) { + n += Str(p) + var t = derived(n) + if (Num(t).is_prime){ + if (t.len > 50) { + t = (t.first(20) + ' ... ' + t.last(20) + " (#{t.len} digits)") + } + printf("%2s: Index:%5d %s\n", nth, i, t) + ++nth + } +} diff --git a/Task/Smith-numbers/EasyLang/smith-numbers.easy b/Task/Smith-numbers/EasyLang/smith-numbers.easy index fd160e7f16..b50430147f 100644 --- a/Task/Smith-numbers/EasyLang/smith-numbers.easy +++ b/Task/Smith-numbers/EasyLang/smith-numbers.easy @@ -1,15 +1,15 @@ -proc prim_fact x . pf[] . - pf[] = [ ] +func[] primfact x . p = 2 repeat if x mod p = 0 - pf[] &= p + r[] &= p x = x div p else p += 1 . until x = 1 . + return r[] . func digsum x . while x > 0 @@ -19,7 +19,7 @@ func digsum x . return sum . for i = 2 to 9999 - prim_fact i pf[] + pf[] = primfact i if len pf[] >= 2 sum = 0 for e in pf[] diff --git a/Task/Smith-numbers/Uiua/smith-numbers-1.uiua b/Task/Smith-numbers/Uiua/smith-numbers-1.uiua new file mode 100644 index 0000000000..1dc00589f4 --- /dev/null +++ b/Task/Smith-numbers/Uiua/smith-numbers-1.uiua @@ -0,0 +1,7 @@ +N ← 10000 +Primes ← ⇌◌⍢(⊃(▽≠0◿⊢..|⊂⊢)|>0⧻)⊙[]↘2⇡N +Candidates ← ▽¬∊:Primes.↘2⇡ # Exclude primes +SumD ← /+≡⋕°⋕ +PrimeDivisors ← ◌◌⍢(⟜(÷/×)⟜(⊙⊂:)▽:⟜(=0◿)⊙.|⋅(>1))Primes ⊙[] +Smith ← ▽⊸≡(=⊃(SumD|/+≡SumD PrimeDivisors)) +⟜⧻ Smith Candidates N diff --git a/Task/Smith-numbers/Uiua/smith-numbers-2.uiua b/Task/Smith-numbers/Uiua/smith-numbers-2.uiua new file mode 100644 index 0000000000..21cc459008 --- /dev/null +++ b/Task/Smith-numbers/Uiua/smith-numbers-2.uiua @@ -0,0 +1,3 @@ +IsSmith ← =∩(/+≡⋕)⊃°⋕(/◇⊂°⋕°/×) +▽⊸≡IsSmith▽⊸≡(≠1⧻°/×)+1⇡10000 +&p$"Number under 10000: _\nFirst ten: _\nLast ten: _"⊃(⧻|↙10|↙¯10) diff --git a/Task/Snake/Emacs-Lisp/snake.l b/Task/Snake/Emacs-Lisp/snake.l new file mode 100644 index 0000000000..127dbc0b2c --- /dev/null +++ b/Task/Snake/Emacs-Lisp/snake.l @@ -0,0 +1 @@ +M-x snake diff --git a/Task/Snake/Locomotive-Basic/snake.basic b/Task/Snake/Locomotive-Basic/snake.basic index d27ab9f0f4..0b887d5a71 100644 --- a/Task/Snake/Locomotive-Basic/snake.basic +++ b/Task/Snake/Locomotive-Basic/snake.basic @@ -1,30 +1,31 @@ 10 mode 1:randomize time -20 sx=20:sy=5:dx=1:dy=0:ml=20:dim ox(ml),oy(ml):oi=1:ll=4:skill=6 +15 ink 0,0:ink 1,6:ink 2,18:ink 3,11 +20 sx=20:sy=5:dx=1:dy=0:ml=20:dim ox(ml),oy(ml):oi=1:ll=4:skill=8 30 f$=chr$(228):w$=chr$(127):b$=chr$(231) -40 print string$(40,w$); +40 pen 3:print string$(40,w$); 50 for i=2 to 20:print w$;space$(38);w$;:next 60 print string$(40,w$); -70 locate 10, 12:print string$(20,w$); +70 locate 11, 11:print string$(20,w$); 80 gosub 260 -90 frame -100 if inkey(1)>-1 then dx=1:dy=0 -110 if inkey(8)>-1 then dx=-1:dy=0 -120 if inkey(0)>-1 then dx=0:dy=-1 -130 if inkey(2)>-1 then dx=0:dy=1 -140 locate sx,sy:print chr$(224);:ox(oi)=sx:oy(oi)=sy +140 locate sx,sy:pen 2:print chr$(224);:ox(oi)=sx:oy(oi)=sy 150 oi=oi+1:if oi>ml then oi=1 160 nx=sx+dx:ny=sy+dy 170 locate nx,ny:a$=copychr$(#0) 180 if a$=w$ or a$=b$ then sound 2,62500/20,100:locate 13,6:print "You have died!":end -190 if a$=f$ then sound 2,62500/500,10: sound 1,62500/1000,10: sound 4,62500/2000,10:p=p+100:print " ";:gosub 260:if ll-1 then dx=1:dy=0 +212 if inkey(8)>-1 then dx=-1:dy=0 +213 if inkey(0)>-1 then dx=0:dy=-1 +214 if inkey(2)>-1 then dx=0:dy=1 +215 next +220 locate sx,sy:pen 2:print b$; 230 nn=1+((oi+ml-ll) mod ml) 240 if ox(nn)>0 then locate ox(nn),oy(nn):print " "; -250 sx=nx:sy=ny:goto 90 +250 sx=nx:sy=ny:goto 140 260 fx=rnd*39+1:fy=rnd*19+1 270 locate fx,fy:a$=copychr$(#0) 280 if a$<>" " then 260 -290 print f$; +290 pen 1:print f$; 300 return diff --git a/Task/Solve-a-Hidato-puzzle/00-TASK.txt b/Task/Solve-a-Hidato-puzzle/00-TASK.txt index a23202b09c..6705fafb29 100644 --- a/Task/Solve-a-Hidato-puzzle/00-TASK.txt +++ b/Task/Solve-a-Hidato-puzzle/00-TASK.txt @@ -24,7 +24,7 @@ has the following solution, with path marked on it: * [[A* search algorithm]] * [[N-queens problem]] * [[Solve a Holy Knight's tour]] -* [[Solve a Knight's tour]] +* [[Knight's tour]] * [[Solve a Hopido puzzle]] * [[Solve a Numbrix puzzle]] * [[Solve the no connection puzzle]]; diff --git a/Task/Solve-a-Hidato-puzzle/Jq/solve-a-hidato-puzzle.jq b/Task/Solve-a-Hidato-puzzle/Jq/solve-a-hidato-puzzle.jq new file mode 100644 index 0000000000..7b80214b8d --- /dev/null +++ b/Task/Solve-a-Hidato-puzzle/Jq/solve-a-hidato-puzzle.jq @@ -0,0 +1,74 @@ +### Generic functions + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +### Hidato Puzzle + +# "." ~ -1 (dead cell) +# "_" ~ 0 (to be assigned a number) +def printBoard: + .board[] as $row + | reduce $row[] as $c (""; + if $c == -1 then . + " . " + elif $c > 0 then . + ($c | lpad(3)) + else . + " __" + end); + +# output: { board, given, start} +# "." signifies a dead cell +def setUp($in): + { board:[], given:[], start:[] } + | ($in|length) as $nRows + | [range(0;$nRows) | ($in[.]|split(" "))] as $puzzle + | ($puzzle[0]|length) as $nCols + | .board = [range(0; $nRows+2) | null] + | reduce range(0; .board|length) as $i (. ; .board[$i] = [range(0; $nCols+2) | -1]) + | reduce range(0; $nRows) as $r (.; + $puzzle[$r] as $row + | reduce range(0; $nCols) as $c (.; + $row[$c] as $cell + | if $cell == "_" + then .board[$r + 1][$c + 1] = 0 + elif $cell != "." + then ($cell | tonumber) as $value + | .board[$r + 1][$c + 1] = $value + | .given += [$value] + | if $value == 1 then .start = [$r + 1, $c + 1] end + end )) + | .given |= sort ; + +# Generate all solutions, that is, emit empty on failure. +# $r is a row, $c is a column, $n is the number we're looking for, +# $next is the index in .given of the next given number. +def solve($r; $c; $n; $next): + if $n > .given[-1] then . # all done + else .board[$r][$c] as $back + | if ($back != 0 and $back != $n) then empty + elif $back == 0 and .given[$next] == $n then empty + else + (if $back == $n then (1+$next) else $next end) as $next2 + | if $n != $back then .board[$r][$c] = $n end # avoid unnecessary copying + | ( (-1, 0, 1) as $i + | (-1, 0, 1) as $j + | solve($r + $i; $c + $j; $n + 1; $next2) + ) + end + end; + + +def example: [ + "_ 33 35 _ _ . . .", + "_ _ 24 22 _ . . .", + "_ _ _ 21 _ _ . .", + "_ 26 _ 13 40 11 . .", + "27 _ _ _ 9 _ 1 .", + ". . _ _ 18 _ _ .", + ". . . . _ 7 _ _", + ". . . . . . 5 _" +]; + +setUp(example) +| printBoard, + "\nFound:", + ( first( solve(.start[0]; .start[1]; 1; 0) ) + | printBoard) diff --git a/Task/Solve-a-Hidato-puzzle/Uiua/solve-a-hidato-puzzle.uiua b/Task/Solve-a-Hidato-puzzle/Uiua/solve-a-hidato-puzzle.uiua new file mode 100644 index 0000000000..dd8f3d793a --- /dev/null +++ b/Task/Solve-a-Hidato-puzzle/Uiua/solve-a-hidato-puzzle.uiua @@ -0,0 +1,22 @@ +# Experimental! +G ← [[0 33 35 0 0 ¯1 ¯1 ¯1] + [0 0 24 22 0 ¯1 ¯1 ¯1] + [0 0 0 21 0 0 ¯1 ¯1] + [0 26 0 13 40 11 ¯1 ¯1] + [27 0 0 0 9 0 1 ¯1] + [¯1 ¯1 0 0 18 0 0 ¯1] + [¯1 ¯1 ¯1 ¯1 0 7 0 0] + [¯1 ¯1 ¯1 ¯1 ¯1 ¯1 5 0]] +S ← /×△G # Total size. +N ← /+≠¯1♭G +Width ← ⧻⊢G +Dirs ← [¯.1 ⊓∩(+1)∩(-1),,,,¯.Width] # D8 directions. +DiaD ← /↥⌵-∩(⊟⊃(◿|⌊÷)Width) # Diagonal dist. +Ns ← ▽:⟜≡(=0⊡)⊙¤▽⊸≡(↧⊃(≥0| $cnt then . + else first( + range(0;moves|length) as $i + | ($sx + moves[$i][0]) as $x + | ($sy + moves[$i][1]) as $y + | if $x >= 0 and $x < $sz and $y >= 0 and $y < $sz and .pz[$x][$y] == 0 + then .pz[$x][$y] = $idx + | solve($sz; $x; $y; $idx + 1; $cnt) + else empty + end ) + end; + +def printSolution($sz): + range(0; $sz) as $j + | .emit = "" + | reduce range(0; $sz) as $i (.; + if .pz[$i][$j] != -1 + then .emit += (.pz[$i][$j] | lpad(3)) + else .emit += " --" + end ) + | .emit; + +# $b should be a board of size $sz +def findSolution($b; $sz): + [range(0; $sz) | -1] as $minus + | { pz: [range(0;$sz) | $minus], + x: 0, + y: 0, + idx: 0, + cnt: 0 + } + | reduce range(0; $sz) as $j (.; + reduce range(0; $sz) as $i (.; + if $b[.idx: .idx+1] == "x" + then .pz[$i][$j] = 0 + | .cnt += 1 + elif $b[.idx: .idx+1] == "s" + then + .pz[$i][$j] = 1 + | .cnt += 1 + | .x = $i + | .y = $j + end + | .idx += 1 )) + | (solve($sz; .x; .y; 2; .cnt) | printSolution($sz)) + // "Whoops!" ; + +findSolution(board1; 8), +"", +findSolution(board2; 13) diff --git a/Task/Solve-a-Numbrix-puzzle/Dart/solve-a-numbrix-puzzle.dart b/Task/Solve-a-Numbrix-puzzle/Dart/solve-a-numbrix-puzzle.dart new file mode 100644 index 0000000000..0178290da7 --- /dev/null +++ b/Task/Solve-a-Numbrix-puzzle/Dart/solve-a-numbrix-puzzle.dart @@ -0,0 +1,92 @@ +/// Based on https://rosettacode.org/wiki/Solve_a_Numbrix_puzzle#Kotlin +import 'package:more/more.dart'; +import 'package:sprintf/sprintf.dart'; + +const examples = [ + [ + "00,00,00,00,00,00,00,00,00", + "00,00,46,45,00,55,74,00,00", + "00,38,00,00,43,00,00,78,00", + "00,35,00,00,00,00,00,71,00", + "00,00,33,00,00,00,59,00,00", + "00,17,00,00,00,00,00,67,00", + "00,18,00,00,11,00,00,64,00", + "00,00,24,21,00,01,02,00,00", + "00,00,00,00,00,00,00,00,00" + ], + [ + "00,00,00,00,00,00,00,00,00", + "00,11,12,15,18,21,62,61,00", + "00,06,00,00,00,00,00,60,00", + "00,33,00,00,00,00,00,57,00", + "00,32,00,00,00,00,00,56,00", + "00,37,00,01,00,00,00,73,00", + "00,38,00,00,00,00,00,72,00", + "00,43,44,47,48,51,76,77,00", + "00,00,00,00,00,00,00,00,00" + ] +]; + +const moves = [ + [1, 0], + [0, 1], + [-1, 0], + [0, -1] +]; + +late List board; +late List> grid; +late List clues; +var totalToFill = 0; + +bool solve(int r, int c, int count, int nextClue) { + if (count > totalToFill) return true; + var back = grid[r][c]; + if (back != 0 && back != count) return false; + if (back == 0 && nextClue < clues.length && clues[nextClue] == count) { + return false; + } + + var nextClue2 = nextClue; + if (back == count) nextClue2++; + grid[r][c] = count; + var res = moves.any((m) => solve(r + m[1], c + m[0], count + 1, nextClue2)); + if (!res) grid[r][c] = back; + return res; +} + +void printResult(int n) { + print("Solution for example $n:"); + for (var row in grid) { + print([ + for (var e in row) + if (e != -1) sprintf("%2d ", [e]) + ].join()); + } +} + +main() { + for (var each in examples.indexed()) { + board = each.value; + var nRows = board.length + 2, nCols = board[0].split(",").length + 2; + var startRow = 0, startCol = 0; + grid = List.generate(nRows, (i) => List.filled(nCols, -1)); + totalToFill = (nRows - 2) * (nCols - 2); + var lst = []; + for (var r in 1.to(nRows - 1)) { + var row = board[r - 1].split(","); + for (var c in 1.to(nCols - 1)) { + var value = int.parse(row[c - 1]); + if (value > 0) lst.add(value); + if (value == 1) { + startRow = r; + startCol = c; + } + grid[r][c] = value; + } + } + + clues = (lst..sort()).toList(); + if (solve(startRow, startCol, 1, 0)) printResult(each.index + 1); + } +} diff --git a/Task/Solve-a-Numbrix-puzzle/Jq/solve-a-numbrix-puzzle.jq b/Task/Solve-a-Numbrix-puzzle/Jq/solve-a-numbrix-puzzle.jq new file mode 100644 index 0000000000..122070750a --- /dev/null +++ b/Task/Solve-a-Numbrix-puzzle/Jq/solve-a-numbrix-puzzle.jq @@ -0,0 +1,80 @@ +def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .; + +def moves: [ [1, 0], [0, 1], [-1, 0], [0, -1] ]; + +# "All solutions" +# Can the puzzle be solved by placing the token $count at row $r, column $c? +# Input: { grid, clues, totalToFill } +def solve($r; $c; $count; $nextClue): + if $count > .totalToFill then . + else .grid[$r][$c] as $back + | if ($back != 0 and $back != $count) + or ($back == 0 and $nextClue < (.clues|length) and .clues[$nextClue] == $count) + then empty + else if $back == $count then .nextClue += 1 end + | .grid[$r][$c] = $count + | moves[] as $m + | solve($r + $m[1]; $c + $m[0]; $count + 1; $nextClue) + end + end ; + +def printResult: + .grid[1:-1][] as $row + | reduce range(1; $row|length -1) as $i (""; + . + (if $i != -1 then $row[$i] else "" end | lpad(3)) ); + +def task($board): + { clues: [] } + | (($board|length) + 2) as $nRows + | ($board[0]|split(",")|length + 2) as $nCols + | .startRow = 0 + | .startCol = 0 + | [range(0; $nCols) | -1] as $m1 + | .grid = [range(0; $nRows) | $m1] + | .totalToFill = ($nRows - 2) * ($nCols - 2) + | reduce range(0; $nRows) as $r (.; + if $r >= 1 and $r < $nRows - 1 + then ($board[$r - 1]|split(",")) as $row + | reduce range(1; $nCols - 1) as $c (.; + ($row[$c - 1] | sub("^0";"") | tonumber) as $value + | if $value > 0 then .clues += [$value] end + | if $value == 1 + then .startRow = $r + | .startCol = $c + end + | .grid[$r][$c] = $value ) + end ) + | .clues |= sort + | .startRow as $startRow + | .startCol as $startCol + | first(solve($startRow; $startCol; 1; 0)) + | printResult ; + +### Examples + +def example1: [ + "00,00,00,00,00,00,00,00,00", + "00,00,46,45,00,55,74,00,00", + "00,38,00,00,43,00,00,78,00", + "00,35,00,00,00,00,00,71,00", + "00,00,33,00,00,00,59,00,00", + "00,17,00,00,00,00,00,67,00", + "00,18,00,00,11,00,00,64,00", + "00,00,24,21,00,01,02,00,00", + "00,00,00,00,00,00,00,00,00" +]; + +def example2: [ + "00,00,00,00,00,00,00,00,00", + "00,11,12,15,18,21,62,61,00", + "00,06,00,00,00,00,00,60,00", + "00,33,00,00,00,00,00,57,00", + "00,32,00,00,00,00,00,56,00", + "00,37,00,01,00,00,00,73,00", + "00,38,00,00,00,00,00,72,00", + "00,43,44,47,48,51,76,77,00", + "00,00,00,00,00,00,00,00,00" +]; + + "Example 1", task(example1), +"\nExample 2", task(example2) diff --git a/Task/Solve-a-Numbrix-puzzle/Uiua/solve-a-numbrix-puzzle.uiua b/Task/Solve-a-Numbrix-puzzle/Uiua/solve-a-numbrix-puzzle.uiua new file mode 100644 index 0000000000..d637e85420 --- /dev/null +++ b/Task/Solve-a-Numbrix-puzzle/Uiua/solve-a-numbrix-puzzle.uiua @@ -0,0 +1,22 @@ +# Experimental! +G ← [[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]] +S ← /×△G # Total size. +Width ← ⧻⊢G +Dirs ← [∩(¯.)1Width] # D4 directions. +ManD ← /+⌵-∩(⊟⊃(◿|⌊÷)Width) # Manhattan dist. +Ns ← ▽:⟜≡(=0⊡)⊙¤▽⊸≡(↧⊃(≥0| 0 Then + If Len(s) = 1 Then Return part + Chr(48 + v) + res = solve(Left(s, i - 1) & Mid(s, i + 1), idx + 1, part & Chr(48 + v)) + If Len(res) > 0 Then Return res + End If + Next i + + Return "" +End Function + +Dim As String result = solve("12345678", 1, "") +For i As Integer = 1 To Len(result) + ReplaceString(txt, Chr(64 + i), Mid(result, i, 1)) +Next i +Print txt + +Sleep diff --git a/Task/Solve-the-no-connection-puzzle/Quackery/solve-the-no-connection-puzzle.quackery b/Task/Solve-the-no-connection-puzzle/Quackery/solve-the-no-connection-puzzle.quackery new file mode 100644 index 0000000000..cd0f5ad995 --- /dev/null +++ b/Task/Solve-the-no-connection-puzzle/Quackery/solve-the-no-connection-puzzle.quackery @@ -0,0 +1,24 @@ + [ ' [ [ 0 2 ] [ 0 3 ] [ 0 4 ] + [ 1 3 ] [ 1 4 ] [ 1 5 ] + [ 6 2 ] [ 6 3 ] [ 6 4 ] + [ 7 3 ] [ 7 4 ] [ 7 5 ] + [ 2 3 ] [ 3 4 ] [ 4 5 ] ] ] is connections ( --> [ ) + + [ dip dup do + unrot peek dip peek - abs 1 = ] is invalid ( [ [ --> b ) + + [ true swap + connections witheach + [ dip dup invalid if + [ dip not conclude ] ] + drop ] is allvalid ( [ --> b ) + + say " A B C D E F G H" cr + 8 ! times + [ i^ 8 rank->perm + allvalid if + [ sp + i^ 8 rank->perm + witheach + [ sp 1+ echo ] + cr conclude ] ] diff --git a/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-1.zig b/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-1.zig new file mode 100644 index 0000000000..dec1f5acc4 --- /dev/null +++ b/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-1.zig @@ -0,0 +1,53 @@ +const std = @import("std"); +const print = std.debug.print; + +const PA = 0; +const PB = 1; +const PC = 2; +const PD = 3; +const PE = 4; +const PF = 5; +const PG = 6; +const PH = 7; + +const Pair = struct { u8, u8 }; +const Pairs = [_]Pair{ .{ PA, PC }, .{ PA, PD }, .{ PA, PE }, .{ PB, PD }, .{ PB, PE }, .{ PB, PF }, .{ PC, PG }, .{ PC, PD }, .{ PD, PE }, .{ PD, PG }, .{ PD, PH }, .{ PE, PG }, .{ PE, PH }, .{ PF, PH }, .{ PE, PF } }; +var t: [8]u32 = .{0} ** 8; + +inline fn abs(p: Pair) u32 { + if (t[p.@"0"] < t[p.@"1"]) return t[p.@"1"] - t[p.@"0"]; + return t[p.@"0"] - t[p.@"1"]; +} + +fn check() bool { + var r: bool = true; + for (Pairs) |p| { + r = r and abs(p) > 1; + if (!r) break; + } + + return r; +} + +fn has(a: u32) bool { + for (t) |v| { + if (v == a) return true; + } + return false; +} + +fn solve(lvl: u32) bool { + if (lvl == 8) return check(); + for (1..9) |v| { + if (has(v)) continue; + t[lvl] = v; + if (solve(lvl + 1)) return true; + } + t[lvl] = 0; + return false; +} + +pub fn main() void { + _ = solve(0); + print("{{ A, B, C, D, E, F, G, H }} = {any}", .{t}); +} diff --git a/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-2.zig b/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-2.zig new file mode 100644 index 0000000000..57eea837ff --- /dev/null +++ b/Task/Solve-the-no-connection-puzzle/Zig/solve-the-no-connection-puzzle-2.zig @@ -0,0 +1,54 @@ +const std = @import("std"); +const print = std.debug.print; + +const PA = 0; +const PB = 1; +const PC = 2; +const PD = 3; +const PE = 4; +const PF = 5; +const PG = 6; +const PH = 7; + +const Pair = struct { u8, u8 }; +const Pairs = [_]Pair{ .{ PA, PC }, .{ PA, PD }, .{ PA, PE }, .{ PB, PD }, .{ PB, PE }, .{ PB, PF }, .{ PC, PG }, .{ PC, PD }, .{ PD, PE }, .{ PD, PG }, .{ PD, PH }, .{ PE, PG }, .{ PE, PH }, .{ PF, PH }, .{ PE, PF } }; +var t: [8]u32 = .{0} ** 8; + +inline fn abs(p: Pair) u32 { + if (t[p.@"0"] < t[p.@"1"]) return t[p.@"1"] - t[p.@"0"]; + return t[p.@"0"] - t[p.@"1"]; +} + +fn check() bool { + var r: bool = true; + for (Pairs) |p| { + r = r and abs(p) > 1; + if (!r) break; + } + + return r; +} + +fn has(a: u32) bool { + for (t) |v| { + if (v == a) return true; + } + return false; +} + +fn solve(lvl: u32) bool { + if (lvl == 8) return check(); + for (1..9) |v| { + if (has(v)) continue; + t[lvl] = v; + if (solve(lvl + 1)) { + print("{{ A, B, C, D, E, F, G, H }} = {any}\n", .{t}); + } + } + t[lvl] = 0; + return false; +} + +pub fn main() void { + _ = solve(0); +} diff --git a/Task/Sort-a-list-of-object-identifiers/EasyLang/sort-a-list-of-object-identifiers.easy b/Task/Sort-a-list-of-object-identifiers/EasyLang/sort-a-list-of-object-identifiers.easy new file mode 100644 index 0000000000..73666aae50 --- /dev/null +++ b/Task/Sort-a-list-of-object-identifiers/EasyLang/sort-a-list-of-object-identifiers.easy @@ -0,0 +1,28 @@ +proc sort . d$[] . + for s$ in d$[] + d[][] &= number strsplit s$ "." + . + n = len d[][] + for i = 1 to n - 1 + for j = i + 1 to n + m = lower len d[i][] len d[j][] + for k to m + if d[i][k] <> d[j][k] + break 1 + . + . + if k > m and len d[i][] > len d[j][] or d[i][k] > d[j][k] + swap d[i][] d[j][] + . + . + . + for i to len d[][] + d$[i] = d[i][1] + for j = 2 to len d[i][] + d$[i] &= "." & d[i][j] + . + . +. +oid$[] = [ "1.3.6.1.4.1.11.2.17.19.3.4.0.10" "1.3.6.1.4.1.11.2.17.5.2.0.79" "1.3.6.1.4.1.11.2.17.19.3.4.0.4" "1.3.6.1.4.1.11150.3.4.0.1" "1.3.6.1.4.1.11.2.17.19.3.4.0.1" "1.3.6.1.4.1.11150.3.4.0" ] +sort oid$[] +print oid$[] diff --git a/Task/Sort-an-array-of-composite-structures/PascalABC.NET/sort-an-array-of-composite-structures.pas b/Task/Sort-an-array-of-composite-structures/PascalABC.NET/sort-an-array-of-composite-structures.pas new file mode 100644 index 0000000000..47855620a1 --- /dev/null +++ b/Task/Sort-an-array-of-composite-structures/PascalABC.NET/sort-an-array-of-composite-structures.pas @@ -0,0 +1,10 @@ +type + Pair = auto class + Name,Value: string; + end; + +begin + var a: array of Pair := (new Pair('ZZZ','333'),new Pair('XXX','222'),new Pair('YYY','111')); + a.OrderBy(p -> p.Name).Println; + a.OrderBy(p -> p.Value).Println; +end. diff --git a/Task/Sort-an-integer-array/EasyLang/sort-an-integer-array.easy b/Task/Sort-an-integer-array/EasyLang/sort-an-integer-array.easy new file mode 100644 index 0000000000..5e57891875 --- /dev/null +++ b/Task/Sort-an-integer-array/EasyLang/sort-an-integer-array.easy @@ -0,0 +1,12 @@ +proc sort . d[] . + for i = 1 to len d[] - 1 + for j = i + 1 to len d[] + if d[j] < d[i] + swap d[j] d[i] + . + . + . +. +a[] = [ 2 4 3 1 2 ] +sort a[] +print a[] diff --git a/Task/Sort-an-integer-array/PascalABC.NET/sort-an-integer-array.pas b/Task/Sort-an-integer-array/PascalABC.NET/sort-an-integer-array.pas new file mode 100644 index 0000000000..748474f4dd --- /dev/null +++ b/Task/Sort-an-integer-array/PascalABC.NET/sort-an-integer-array.pas @@ -0,0 +1,4 @@ +## +var a := Arr(5,1,4,2,3); +Sort(a); +Print(a); diff --git a/Task/Sort-an-outline-at-every-level/C++/sort-an-outline-at-every-level.cpp b/Task/Sort-an-outline-at-every-level/C++/sort-an-outline-at-every-level.cpp new file mode 100644 index 0000000000..d58c07152c --- /dev/null +++ b/Task/Sort-an-outline-at-every-level/C++/sort-an-outline-at-every-level.cpp @@ -0,0 +1,258 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +const char DELETE = '\x7f'; + +// Return the number of characters required to print the given string. +uint32_t print_size(const std::string& text) { + uint32_t size = 0; + for ( const char& ch : text ) { + if ( ch == ' ' ) { size += 1; } + if ( ch == '\t' ) { size += 4; } + } + return size; +} + +// Split the given string into a vector of strings separated by the given delimiter. +std::vector split_string(const std::string& text, const char& delimiter) { + std::vector lines; + std::istringstream stream(text); + std::string line; + while ( std::getline(stream, line, delimiter) ) { + lines.emplace_back(line); + } + return lines; +} + +// Return a string consisting of the given string with leading spaces and tabs removed. +std::string trim_left(const std::string& text) { + size_t start = text.find_first_not_of(" \t"); + return ( start == std::string::npos ) ? "" : text.substr(start); +} + +// Return whether the string 'haystack" contains the string 'needle'. +bool contains(const std::string& haystack, const std::string& needle) { + return haystack.find(needle) != std::string::npos; +} + +// Return a string consisting of the given string repeated the given number of times. +std::string repeat(const std::string& text, const uint32_t& multiple) { + std::string result; + result.reserve(multiple * text.size()); + for ( uint32_t i = 0; i < multiple; ++i ) { + result += text; + } + return result; +} + +// Join a vector of strings into a single string separated by the given delimiter. +std::string join(const std::vector& lines, const std::string& delimiter) { + std::stringstream stream; + std::copy(lines.begin(), lines.end(), std::ostream_iterator(stream, delimiter.c_str())); + return stream.str(); +} + +enum Sort { ASCENDING, DESCENDING }; + +// Correct the given outline if necessary and sort it at every level using the given sort. +void sorted_outline(const std::string& outline, const Sort& sort) { + std::vector lines = split_string(outline, '\n'); + // Remove any initial empty lines which typical occur in raw strings. + while ( lines[0].empty() ) { + lines.erase(lines.begin()); + } + + std::string previous_indent = ""; + std::vector messages = {}; + + // Correct formatting errors in each line of the outline. + for ( uint32_t i = 0; i < lines.size(); ++i ) { + std::string line = lines[i]; + if ( line.starts_with(" ") || line.starts_with("\t") ) { + std::string line_trimmed = trim_left(line); + std::string current_indent = line.substr(0, line.size() - line_trimmed.size()); + if ( previous_indent == "" ) { + previous_indent = current_indent; + } else { + bool correction_needed = false; + + if ( ( contains(current_indent, "\t") && ! contains(previous_indent, "\t") ) || + ( ! contains(current_indent, "\t") && contains(previous_indent, "\t") ) ) { + messages.emplace_back("Corrected inconsistent whitespace use at line \"" + line + "\""); + correction_needed = true; + } + + if ( print_size(current_indent) % print_size(previous_indent) != 0 ) { + messages.emplace_back("Corrected inconsistent indent width at line \"" + line + "\""); + correction_needed = true; + } + + if ( correction_needed ) { + const uint32_t multiple = + std::round(static_cast(print_size(current_indent)) / print_size(previous_indent)); + lines[i] = repeat(previous_indent, multiple) + line_trimmed; + } + } + } + } + + // Determine the level of indent for each line of the outline. + std::vector levels(lines.size(), 0); + uint32_t level = 1; + std::string margin = previous_indent; + while ( std::any_of(levels.begin(), levels.end(), [](const uint32_t& i) { return i == 0; }) ) { + for ( uint32_t i = 0; i < lines.size(); ++i ) { + if ( levels[i] == 0 ) { + const std::string line = lines[i]; + if ( line.starts_with(margin) && line[margin.size()] != ' ' && line[margin.size()] != '\t' ) { + levels[i] = level; + } + } + } + margin += previous_indent; + level += 1; + } + + // Prepare the lines of the outline for sorting. + std::vector new_lines(lines.size(), ""); + new_lines[0] = lines[0]; + std::vector nodes = {}; + for ( uint32_t i = 1; i < lines.size(); ++i ) { + if ( levels[i] > levels[i - 1] ) { + nodes.emplace_back(nodes.empty() ? lines[i - 1] : "\n" + lines[i - 1]); + } else if ( levels[i] < levels[i - 1] ) { + for ( uint32_t j = 1; j <= levels[i - 1] - levels[i]; ++j ) { + nodes.pop_back(); + } + } + + if ( ! nodes.empty() ) { + new_lines[i] = join(nodes, "") + "\n" + lines[i]; + } else { + new_lines[i] = lines[i]; + } + } + + // Sort the lines of the outline. + if ( sort == Sort::ASCENDING ) { + std::sort(new_lines.begin(), new_lines.end()); + } else { + // Pad each line of the outline on the right with 'DELETE' characters. + const uint64_t max_size = + std::ranges::max_element(new_lines, std::ranges::less{}, &std::string::size) -> size(); + for ( uint64_t i = 0; i < new_lines.size(); ++i ) { + new_lines[i].insert(new_lines[i].size(), max_size - new_lines[i].size(), DELETE); + } + + std::sort(new_lines.begin(), new_lines.end(), std::greater()); + } + + for ( uint32_t i = 0; i < new_lines.size(); ++i ) { + std::vector sections = split_string(new_lines[i], '\n'); + new_lines[i] = sections.back(); + + if ( sort == Sort::DESCENDING ) { + // Remove the padding of 'DELETE' characters + const int32_t start = new_lines[i].find_first_of(DELETE); + if ( start > 0 ) { + new_lines[i] = new_lines[i].substr(0, start); + } + } + } + + // Display error messages + if ( ! messages.empty() ) { + for ( const std::string& message : messages ) { + std::cout << message << std::endl; + } + } + + // Display corrected and sorted outline + std::cout << join(new_lines, "\n") << std::endl; +} + +int main() { + std::string outline_spaces = R"( + zeta + beta + gamma + lambda + kappa + mu + delta + alpha + theta + iota + epsilon)"; + + std::string outline_tabs = R"( + zeta + beta + gamma + lambda + kappa + mu + delta + alpha + theta + iota + epsilon)"; + + // All spaces except for the line 'kappa' which contains a tab. + std::string outline_faulty_1 = R"( + alpha + epsilon + iota + theta + zeta + beta + delta + gamma + kappa + lambda + mu)"; + + // All spaces with lines 'gamma' and 'kappa' misaligned. + std::string outline_faulty_2 = R"( + zeta + beta + gamma + lambda + kappa + mu + delta + alpha + theta + iota + epsilon)"; + + std::cout << "Four space indented outline, ascending sort:" << std::endl; + sorted_outline(outline_spaces, Sort::ASCENDING); + + std::cout << "Four space indented outline, descending sort:" << std::endl; + sorted_outline(outline_spaces, Sort::DESCENDING); + + std::cout << "Tab indented outline, ascending sort:" << std::endl; + sorted_outline(outline_tabs, Sort::ASCENDING); + + std::cout << "Tab space indented outline, descending sort:" << std::endl; + sorted_outline(outline_tabs, Sort::DESCENDING); + + std::cout << "First faulty outline, ascending sort:" << std::endl; + sorted_outline(outline_faulty_1, Sort::ASCENDING); + + std::cout << "First faulty outline, descending sort:" << std::endl; + sorted_outline(outline_faulty_1, Sort::DESCENDING); + + std::cout << "Second faulty outline, ascending sort:" << std::endl; + sorted_outline(outline_faulty_2, Sort::ASCENDING); + + std::cout << "Second faulty outline, descending sort:" << std::endl; + sorted_outline(outline_faulty_2, Sort::DESCENDING); +} diff --git a/Task/Sort-an-outline-at-every-level/Jq/sort-an-outline-at-every-level.jq b/Task/Sort-an-outline-at-every-level/Jq/sort-an-outline-at-every-level.jq new file mode 100644 index 0000000000..f88bb01876 --- /dev/null +++ b/Task/Sort-an-outline-at-every-level/Jq/sort-an-outline-at-every-level.jq @@ -0,0 +1,169 @@ +# Left justify . +def ljust($width; $pad): + tostring as $s + | ($s|length) as $length + | if $width > $length + then $s + $pad * ($width - $length) + else $s + end; + +def sortedOutline($ascending): + + def del: "\u007f"; + def sep: "\u0000"; + + if .[0] | test("^[ \t]") + then " outline structure is unclear" | error + else + reduce range(1; length) as $i ( + { outline: ., + indent: "", + messages: [] }; + .outline[$i] as $line + | ($line|length) as $lc + | if $line | test("^( | \t|\t)") + then ($line | sub("^[ \t]*";"") | length) as $lc2 + | $line[0:$lc-$lc2] as $currIndent + + | if .indent == "" + then .indent = $currIndent + else .correctionNeeded = false + | if (($currIndent|test("\t")) and (.indent|contains("\t") | not)) or + (($currIndent|test("\t")|not) and (.indent|test("\t"))) + then .messages += [.indent + "corrected inconsistent whitespace use at line '\($line)'"] + | .correctionNeeded = true + elif (($currIndent|length) % (.indent|length)) != 0 + then .messages += [.indent + "corrected inconsistent indent width at line '\($line)'"] + | .correctionNeeded = true + end + | if .correctionNeeded + then ((($currIndent|length) / (.indent|length)) |round) as $mult + | .outline[$i] = (.indent * $mult) + $line[$lc-$lc2:] + end + end + end ) + end + | .levels = [range(0; .outline|length) | 0] + | .levels[0] = 1 + | .level = 1 + | .margin = "" + # while any of the levels is 0 ... + | until( all( .levels[]; . > 0); + (.margin|length) as $mc + | reduce range(1; .outline|length) as $i (.; + if .levels[$i] == 0 + then .outline[$i] as $line + | .margin as $margin + | if ($line|startswith($margin)) and + ($line[$mc:$mc+1] | (. != " ") and (. != "\t")) + then .levels[$i] = .level + end + end ) + | .margin += .indent + | .level += 1 ) + | .lines = [range(0; .outline|length) | ""] + | .lines[0] = .outline[0] + | .nodes = [] + | reduce range(1; .outline|length) as $i (.; + if .levels[$i] > .levels[$i-1] + then .nodes += [ if .nodes|length == 0 then .outline[$i-1] else sep + .outline[$i-1] end] + elif .levels[$i] < .levels[$i-1] + then (.levels[$i-1] - .levels[$i] ) as $j + # remove $j elements from the tail + | .nodes |= .[0: length-$j] + end + | if .nodes|length > 0 + then .lines[$i] = (.nodes|join("")) + sep + .outline[$i] + else .lines[$i] = .outline[$i] + end ) + | if $ascending + then .lines |= sort + else (.lines | map(length) | max) as $maxLen + | reduce range(0; .lines|length) as $i (.; + .lines[$i] |= ljust($maxLen; del) ) + | .lines |= (sort|reverse) + end + | reduce range(0; .lines|length) as $i (.; + (.lines[$i]|split(sep) ) as $s + | .lines[$i] = $s[-1] + | if ($ascending|not) + then .lines[$i] |= sub( del + "+$"; "") + end ) + # First print the messages, and then the lines: + | (select((.messages|length) > 0) + | (.messages | join("\n")) + "\n"), + + (.lines|join("\n")) ; + + +### Examples + +def outline: [ + "zeta", + " beta", + " gamma", + " lambda", + " kappa", + " mu", + " delta", + "alpha", + " theta", + " iota", + " epsilon" +]; + +def outline2: + outline | map(gsub(" "; "\t")); + +def outline3: [ + "alpha", + " epsilon", + " iota", + " theta", + "zeta", + " beta", + " delta", + " gamma", + " \t kappa", # same length but \t instead of space + " lambda", + " mu" +]; + +def outline4: [ + "zeta", + " beta", + " gamma", + " lambda", + " kappa", + " mu", + " delta", + "alpha", + " theta", + " iota", + " epsilon" +]; + + +(outline +| "Four space indented outline, ascending sort:", + sortedOutline(true), + "\nFour space indented outline, descending sort:", + sortedOutline(false)), + +(outline2 +| "\nTab indented outline, ascending sort:", + sortedOutline(true), + "\nTab indented outline, descending sort:", + sortedOutline(false) ), + +(outline3 +| "\nFirst unspecified outline, ascending sort:", + sortedOutline(true), + "\nFirst unspecified outline, descending sort:", + sortedOutline(false) ), + +(outline4 +| "\nSecond unspecified outline, ascending sort:", + sortedOutline(true), + "\nSecond unspecified outline, descending sort:", + sortedOutline(false)) diff --git a/Task/Sort-disjoint-sublist/Uiua/sort-disjoint-sublist.uiua b/Task/Sort-disjoint-sublist/Uiua/sort-disjoint-sublist.uiua new file mode 100644 index 0000000000..b279b2229d --- /dev/null +++ b/Task/Sort-disjoint-sublist/Uiua/sort-disjoint-sublist.uiua @@ -0,0 +1 @@ +⍜▽(⊏⍏.)°⊚ 6_1_7 [7 6 5 4 3 2 1 0] diff --git a/Task/Sort-numbers-lexicographically/EasyLang/sort-numbers-lexicographically.easy b/Task/Sort-numbers-lexicographically/EasyLang/sort-numbers-lexicographically.easy new file mode 100644 index 0000000000..737e91b0eb --- /dev/null +++ b/Task/Sort-numbers-lexicographically/EasyLang/sort-numbers-lexicographically.easy @@ -0,0 +1,14 @@ +func[] numlexsort n . + for i to n + d[] &= i + . + for i = 1 to len d[] - 1 + for j = i + 1 to len d[] + if strcmp d[j] d[i] < 0 + swap d[j] d[i] + . + . + . + return d[] +. +print numlexsort 13 diff --git a/Task/Sort-three-variables/PascalABC.NET/sort-three-variables.pas b/Task/Sort-three-variables/PascalABC.NET/sort-three-variables.pas new file mode 100644 index 0000000000..f8ac9fe119 --- /dev/null +++ b/Task/Sort-three-variables/PascalABC.NET/sort-three-variables.pas @@ -0,0 +1,14 @@ +procedure SortThree(var x,y,z: integer); +begin + if x > y then Swap(x, y); + if x > z then Swap(x, z); + if y > z then Swap(y, z); +end; + +begin + var (x,y,z) := Random3(1,10); + Println(x,y,z); + SortThree(x,y,z); + Assert((x <= y) and (y <= z)); + Println(x,y,z); +end. diff --git a/Task/Sort-using-a-custom-comparator/PascalABC.NET/sort-using-a-custom-comparator.pas b/Task/Sort-using-a-custom-comparator/PascalABC.NET/sort-using-a-custom-comparator.pas new file mode 100644 index 0000000000..9a5a826be7 --- /dev/null +++ b/Task/Sort-using-a-custom-comparator/PascalABC.NET/sort-using-a-custom-comparator.pas @@ -0,0 +1,10 @@ +type + Pair = auto class + Name,Value: string; + end; + +begin + var a: array of Pair := (new Pair('ZZZ','333'),new Pair('XXX','222'),new Pair('YYY','111')); + Sort(a, (p1,p2) -> p1.Name < p2.Name); + Print(a); +end. diff --git a/Task/Sorting-Algorithms-Circle-Sort/ALGOL-68/sorting-algorithms-circle-sort.alg b/Task/Sorting-Algorithms-Circle-Sort/ALGOL-68/sorting-algorithms-circle-sort.alg new file mode 100644 index 0000000000..206cb4b973 --- /dev/null +++ b/Task/Sorting-Algorithms-Circle-Sort/ALGOL-68/sorting-algorithms-circle-sort.alg @@ -0,0 +1,67 @@ +BEGIN # circlesort # + + # swaps a and b # + PRIO =:= = 9; + OP =:= = ( REF INT a, b )VOID: BEGIN INT t = a; a := b; b := t END; + + # sorts data in-place and returns a reference to data # + OP CIRCLESORT = ( REF[]INT data )REF[]INT: + BEGIN + PROC circlesort = ( REF[]INT data, INT low, high, swaps so far )INT: + IF low >= high THEN swaps so far + ELSE + INT swaps := swaps so far; + INT hi := high; + INT lo := low; + INT mid = ( hi - lo ) OVER 2; + WHILE lo < hi DO + IF data[ lo ] > data[ hi ] THEN + data[ lo ] =:= data[ hi ]; + swaps +:= 1 + FI; + lo +:= 1; + hi -:= 1 + OD; + IF lo = hi AND hi < UPB data THEN + IF data[ lo ] > data[ hi + 1 ] THEN + data[ lo ] =:= data[ hi + 1 ]; + swaps +:= 1 + FI + FI; + swaps := circlesort( data, low, low + mid, swaps ); + swaps := circlesort( data, low + mid + 1, high, swaps ) + FI # circlesort # ; + + WHILE circlesort( data, LWB data, UPB data, 0 ) > 0 DO SKIP OD; + data + END # CIRCLESORT # ; + + # prints the elements of an array of integers separated by spaces # + OP SHOW = ( []INT list )VOID: + FOR i FROM LWB list TO UPB list DO + print( ( " ", whole( list[ i ], 0 ) ) ) + OD # SHOW # ; + + # tests the CIRCLESORT operator # + PROC test circle sort = ( []INT unsorted )VOID: + BEGIN + [ LWB unsorted : UPB unsorted ]INT data := unsorted; + print( ( "[" ) ); + SHOW unsorted; + print( ( " ]", newline, " -> [" ) ); + SHOW CIRCLESORT data; + print( ( " ]", newline ) ) + END # test circle sort # ; + + # task test case # + test circle sort( ( 6, 7, 8, 9, 2, 5, 3, 4, 1 ) ); + # test cases from the Action! sample # + test circle sort( ( 1, 4, -1, 0, 3, 7, 4, 8, 20, -6 ) ); + test circle sort( ( 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 ) ); + test circle sort( ( 101, 102, 103, 104, 105, 106, 107, 108 ) ); + test circle sort( ( 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1 ) ); + # additional tests # + test circle sort( ( ) ); + test circle sort( ( 1 ) ) + +END diff --git a/Task/Sorting-Algorithms-Circle-Sort/EasyLang/sorting-algorithms-circle-sort.easy b/Task/Sorting-Algorithms-Circle-Sort/EasyLang/sorting-algorithms-circle-sort.easy new file mode 100644 index 0000000000..1bfad31157 --- /dev/null +++ b/Task/Sorting-Algorithms-Circle-Sort/EasyLang/sorting-algorithms-circle-sort.easy @@ -0,0 +1,31 @@ +global d[] . +func circsort lo hi swaps . + if lo = hi + return swaps + . + high = hi + low = lo + mid = (hi - lo) div 2 + while lo < hi + if d[lo] > d[hi] + swap d[lo] d[hi] + swaps += 1 + . + lo += 1 + hi -= 1 + . + if lo = hi + if d[lo] > d[hi + 1] + swap d[lo] d[hi + 1] + swaps += 1 + . + . + swaps = circsort low (low + mid) swaps + swaps = circsort (low + mid + 1) high swaps + return swaps +. +d[] = [ -4 -1 1 0 5 -7 -2 4 -6 -3 2 6 3 7 -5 ] +while circsort 1 len d[] 0 > 0 + # +. +print d[] diff --git a/Task/Sorting-algorithms-Bogosort/EMal/sorting-algorithms-bogosort.emal b/Task/Sorting-algorithms-Bogosort/EMal/sorting-algorithms-bogosort.emal new file mode 100644 index 0000000000..3966eca2e0 --- /dev/null +++ b/Task/Sorting-algorithms-Bogosort/EMal/sorting-algorithms-bogosort.emal @@ -0,0 +1,19 @@ +type BogoSorter +fun inOrder ← logic by List list + if list.length ≤ 1 do return true end + for int i ← 1; i < list.length; ++i + if list[i] < list[i - 1] do return false end + end + return true +end +fun shuffle ← d[i + 1] + swap d[i] d[i + 1] + h = i + . + . + b = h - 1 + h = b + for i = b downto a + if d[i] > d[i + 1] + swap d[i] d[i + 1] + h = i + . + . + a = h + 1 + . +. +l[] = [ 5 6 1 2 9 14 2 15 6 7 8 97 ] +sort l[] +print l[] diff --git a/Task/Sorting-algorithms-Comb-sort/EasyLang/sorting-algorithms-comb-sort.easy b/Task/Sorting-algorithms-Comb-sort/EasyLang/sorting-algorithms-comb-sort.easy new file mode 100644 index 0000000000..78061a2157 --- /dev/null +++ b/Task/Sorting-algorithms-Comb-sort/EasyLang/sorting-algorithms-comb-sort.easy @@ -0,0 +1,17 @@ +proc combsort . d[] . + gap = len d[] + while gap > 1 or swaps = 1 + gap = higher 1 (gap div 1.25) + swaps = 0 + for i = 1 to len d[] - gap + j = i + gap + if d[i] > d[j] + swap d[i] d[j] + swaps = 1 + . + . + . +. +d[] = [ 88 18 31 44 4 0 8 81 14 78 20 76 84 33 73 75 82 5 62 70 ] +combsort d[] +print d[] diff --git a/Task/Sorting-algorithms-Counting-sort/Langur/sorting-algorithms-counting-sort.langur b/Task/Sorting-algorithms-Counting-sort/Langur/sorting-algorithms-counting-sort.langur index f70238e95f..cc333bc3fa 100644 --- a/Task/Sorting-algorithms-Counting-sort/Langur/sorting-algorithms-counting-sort.langur +++ b/Task/Sorting-algorithms-Counting-sort/Langur/sorting-algorithms-counting-sort.langur @@ -1,11 +1,11 @@ -val .countingSort = fn(.list) { - val .min, .max = minmax(.list) - var .count = [0] * (.max-.min+1) - for .i in .list { .count[.i-.min+1] += 1 } - for .i of .count { _for ~= .count[.i] * [.i+.min-1] } +val countingSort = fn(zlist) { + val mi, ma = minmax(zlist) + var cnt = [0] * (ma-mi+1) + for i in zlist { cnt[i-mi+1] += 1 } + for i of cnt { _for ~= cnt[i] * [i+mi-1] } } -val .data = [7, 234, -234, 9, 43, 123, 14] +val data = [7, 234, -234, 9, 43, 123, 14] -writeln "Original: ", .data -writeln "Sorted : ", .countingSort(.data) +writeln "Original: ", data +writeln "Sorted : ", countingSort(data) diff --git a/Task/Sorting-algorithms-Counting-sort/Yabasic/sorting-algorithms-counting-sort.basic b/Task/Sorting-algorithms-Counting-sort/Yabasic/sorting-algorithms-counting-sort.basic new file mode 100644 index 0000000000..927f87dc47 --- /dev/null +++ b/Task/Sorting-algorithms-Counting-sort/Yabasic/sorting-algorithms-counting-sort.basic @@ -0,0 +1,72 @@ +dim array(15) +a = 0 +b = arraysize(array(),1) + +for i = a to b + array(i) = ran(1000) +next i + +print "unsort "; +printArray(array()) +mx = findMax(array()) +mn = findMin(array()) + +countingSort(array(), mn, mx) // ordenar el array + +print " sort "; +printArray(array()) +end + +sub findMax(array()) + local length, i + + length = arraysize(array(),1) - 1 + if length = 0 return 0 + if length = 1 return array(0) + mx = 0 + for i = 1 to arraysize(array(),1) + if array(i) > mx mx = array(i) + next i + return mx +end sub + +sub findMin(array()) + local length, i + + length = arraysize(array(),1) - 1 + if length = 0 return 0 + if length = 1 return array(0) + mn = 0 + for i = 1 to arraysize(array(),1) + if array(i) < mn mn = array(i) + next i + return mn +end sub + +sub countingSort(array(), mn, mx) + local number, z, i, ub + + dim count(mx - mn) + ub = arraysize(array(),1) + + for i = 0 to ub + number = array(i) + count(number - mn) = count(number - mn) + 1 + next + z = 0 + for i = mn to mx + while count(i - mn) > 0 + array(z) = i + z = z + 1 + count(i - mn) = count(i - mn) - 1 + wend + next i +end sub + +sub printArray(array()) + for i = 0 to arraysize(array(),1) + print array(i) using("####"); + if i = b then print ""; else print ", "; : fi + next i + print +end sub diff --git a/Task/Sorting-algorithms-Insertion-sort/Common-Lisp/sorting-algorithms-insertion-sort-3.lisp b/Task/Sorting-algorithms-Insertion-sort/Common-Lisp/sorting-algorithms-insertion-sort-3.lisp new file mode 100644 index 0000000000..fe968b834d --- /dev/null +++ b/Task/Sorting-algorithms-Insertion-sort/Common-Lisp/sorting-algorithms-insertion-sort-3.lisp @@ -0,0 +1,24 @@ +(defgeneric nsrt (sequence predicate)) + +(defmethod nsrt ((sequence sequence) predicate) + (loop :for i :from 1 :below (length sequence) + :do (loop :for j :from i :downto 1 + :do (let ((current (elt sequence j)) + (previous (elt sequence (1- j)))) + (when (funcall predicate current previous) + (rotatef (elt sequence j) + (elt sequence (1- j)))))) + :finally (return sequence))) + +;; (nsrt "adfcghjiklmnoprbtuvqewysxz" #'char<) +;; => "abcdefghijklmnopqrstuvwxyz" +;; +;; (nsrt '(who the hecc do you think i am?) +;; (lambda (x y) +;; (string< (nsrt (format nil "~a" x) #'char<) +;; (nsrt (format nil "~a" y) #'char<)))) +;; => (AM? HECC DO THE THINK WHO I YOU) +;; +;; (nsrt (loop :for i :from 1 :to 1000 :collect (random i)) +;; #'<) +;; => [not printed but works, try it!] diff --git a/Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort.kotlin b/Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-1.kotlin similarity index 100% rename from Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort.kotlin rename to Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-1.kotlin diff --git a/Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-2.kotlin b/Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-2.kotlin new file mode 100644 index 0000000000..a829e8dcc8 --- /dev/null +++ b/Task/Sorting-algorithms-Insertion-sort/Kotlin/sorting-algorithms-insertion-sort-2.kotlin @@ -0,0 +1,16 @@ +fun > Array.insertionSort() { + for (i in 1..lastIndex) { + val currentElement = this[i] + var low = 0 + var high = i - 1 + while (low <= high) { + val mid = low + (high - low) / 2 + if (this[mid] <= currentElement) + low = mid + 1 + else + high = mid - 1 + } + copyInto(this, low + 1, low, i) + this[low] = currentElement + } +} diff --git a/Task/Sorting-algorithms-Merge-sort/Standard-ML/sorting-algorithms-merge-sort.ml b/Task/Sorting-algorithms-Merge-sort/Standard-ML/sorting-algorithms-merge-sort.ml index f854d7afd7..2b1e424219 100644 --- a/Task/Sorting-algorithms-Merge-sort/Standard-ML/sorting-algorithms-merge-sort.ml +++ b/Task/Sorting-algorithms-Merge-sort/Standard-ML/sorting-algorithms-merge-sort.ml @@ -1,9 +1,10 @@ fun merge cmp ([], ys) = ys | merge cmp (xs, []) = xs | merge cmp (xs as x::xs', ys as y::ys') = - case cmp (x, y) of GREATER => y :: merge cmp (xs, ys') - | _ => x :: merge cmp (xs', ys) -; + case cmp (x, y) of + GREATER => y :: merge cmp (xs, ys') + | _ => x :: merge cmp (xs', ys) + fun merge_sort cmp [] = [] | merge_sort cmp [x] = [x] | merge_sort cmp xs = let @@ -12,5 +13,3 @@ fun merge_sort cmp [] = [] in merge cmp (merge_sort cmp ys, merge_sort cmp zs) end -; -merge_sort Int.compare [8,6,4,2,1,3,5,7,9] diff --git a/Task/Sorting-algorithms-Pancake-sort/EasyLang/sorting-algorithms-pancake-sort.easy b/Task/Sorting-algorithms-Pancake-sort/EasyLang/sorting-algorithms-pancake-sort.easy new file mode 100644 index 0000000000..24657b1535 --- /dev/null +++ b/Task/Sorting-algorithms-Pancake-sort/EasyLang/sorting-algorithms-pancake-sort.easy @@ -0,0 +1,48 @@ +global a[] . +proc flip n . . + for i = 1 to n div 2 + swap a[i] a[n - i + 1] + . + # print "flip (1 .. " & n & ") : " & a[] +. +func[] minmax n . + pmin = 1 + pmax = 1 + for i = 2 to n + if a[i] > a[pmax] + pmax = i + elif a[i] < a[pmin] + pmin = i + . + . + return [ pmin pmax ] +. +proc pcsort n dir . . + if n = 1 + return + . + r[] = minmax n + bestx = r[dir] + altx = r[3 - dir] + flipped = 0 + if bestx = n + n -= 1 + elif bestx = 1 + flip n + n -= 1 + elif altx = n + dir = 3 - dir + n -= 1 + flipped = 1 + else + flip bestx + . + pcsort n dir + if flipped = 1 + flip n + 1 + . +. +a[] = [ 6 7 2 1 8 9 5 3 4 ] +print a[] +pcsort len a[] 2 +print a[] diff --git a/Task/Sorting-algorithms-Permutation-sort/Ada/sorting-algorithms-permutation-sort.ada b/Task/Sorting-algorithms-Permutation-sort/Ada/sorting-algorithms-permutation-sort.ada new file mode 100644 index 0000000000..bb2a8889c7 --- /dev/null +++ b/Task/Sorting-algorithms-Permutation-sort/Ada/sorting-algorithms-permutation-sort.ada @@ -0,0 +1,39 @@ +-- Permutation sort +-- J. Carter 2024 Jun +-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC) + +with Ada.Text_IO; +with PragmARC.Permutations; + +procedure Slow_Sort is + package Char_Perms is new PragmARC.Permutations (Element => Character); + + procedure Put (Item : in Char_Perms.Sequence); + -- Outputs all the Characters in Item to standard output, followed by a line terminator + + procedure Process (Seq : in Char_Perms.Sequence; Stop : in out Boolean); + -- If Seq is sorted, outputs it and sets Stop to True + + procedure Put (Item : in Char_Perms.Sequence) is + -- Empty + begin -- Put + All_Chars : for C of Item loop + Ada.Text_IO.Put (Item => C); + end loop All_Chars; + + Ada.Text_IO.New_Line; + end Put; + + procedure Process (Seq : in Char_Perms.Sequence; Stop : in out Boolean) is + -- Empty + begin -- Process + if (for all J in 1 .. Seq'Last - 1 => Seq (J) <= Seq (J + 1) ) then -- Sorted + Put (Item => Seq); + Stop := True; + end if; + end Process; + + Test : constant Char_Perms.Sequence := "kjihgfedcba"; +begin -- Slow_Sort + Char_Perms.Generate (Initial => Test, Process => Process'Access); +end Slow_Sort; diff --git a/Task/Sorting-algorithms-Permutation-sort/EasyLang/sorting-algorithms-permutation-sort.easy b/Task/Sorting-algorithms-Permutation-sort/EasyLang/sorting-algorithms-permutation-sort.easy new file mode 100644 index 0000000000..fa9ff44ab4 --- /dev/null +++ b/Task/Sorting-algorithms-Permutation-sort/EasyLang/sorting-algorithms-permutation-sort.easy @@ -0,0 +1,49 @@ +global perm[] . +proc nextperm . a[] . + n = len perm[] + k = n - 1 + while k >= 1 and perm[k + 1] <= perm[k] + k -= 1 + . + if k = 0 + a[] = [ ] + return + . + l = n + while perm[l] <= perm[k] + l -= 1 + . + swap perm[l] perm[k] + swap a[l] a[k] + k += 1 + while k < n + swap perm[k] perm[n] + swap a[k] a[n] + k += 1 + n -= 1 + . +. +proc perminit . a[] . + for i to len a[] + perm[] &= i + . +. +proc permsort . a[] . + perminit a[] + repeat + for i = 2 to len a[] + if a[i - 1] > a[i] + break 1 + . + . + until i > len a[] + nextperm a[] + if len a[] = 0 + print "error" + break 1 + . + . +. +arr[] = [ 7 6 5 9 8 4 3 1 2 0 ] +permsort arr[] +print arr[] diff --git a/Task/Sorting-algorithms-Quicksort/11l/sorting-algorithms-quicksort.11l b/Task/Sorting-algorithms-Quicksort/11l/sorting-algorithms-quicksort.11l index d7b0f8efb8..708c053f94 100644 --- a/Task/Sorting-algorithms-Quicksort/11l/sorting-algorithms-quicksort.11l +++ b/Task/Sorting-algorithms-Quicksort/11l/sorting-algorithms-quicksort.11l @@ -1,4 +1,4 @@ -F _quicksort(&array, start, stop) -> N +F _quicksort(&array, start, stop) -> Void I stop - start > 0 V pivot = array[start] V left = start diff --git a/Task/Sorting-algorithms-Quicksort/ANSI-BASIC/sorting-algorithms-quicksort.basic b/Task/Sorting-algorithms-Quicksort/ANSI-BASIC/sorting-algorithms-quicksort.basic new file mode 100644 index 0000000000..3280568cbf --- /dev/null +++ b/Task/Sorting-algorithms-Quicksort/ANSI-BASIC/sorting-algorithms-quicksort.basic @@ -0,0 +1,51 @@ +100 REM Sorting algorithms/Quicksort +110 DECLARE EXTERNAL SUB QuickSort +120 DIM Arr(0 TO 19) +130 LET A = LBOUND(Arr) +140 LET B = UBOUND(Arr) +150 RANDOMIZE +160 FOR I = A TO B +170 LET Arr(I) = ROUND(INT(RND * 99)) +180 NEXT I +190 PRINT "Unsorted:" +200 FOR I = A TO B +210 PRINT USING "## ": Arr(I); +220 NEXT I +230 PRINT +240 PRINT "Sorted:" +250 CALL QuickSort(Arr, A, B) +260 FOR I = A TO B +270 PRINT USING "## ": Arr(I); +280 NEXT I +290 PRINT +300 END +310 REM ** +320 EXTERNAL SUB QuickSort (Arr(), L, R) +330 LET LIndex = L +340 LET RIndex = R +350 IF R > L THEN +360 LET Pivot = INT((L + R) / 2) +370 DO WHILE (LIndex <= Pivot) AND (RIndex >= Pivot) +380 DO WHILE (Arr(LIndex) < Arr(Pivot)) AND (LIndex <= Pivot) +390 LET LIndex = LIndex + 1 +400 LOOP +410 DO WHILE (Arr(RIndex) > Arr(Pivot)) AND (RIndex >= Pivot) +420 LET RIndex = RIndex - 1 +430 LOOP +440 LET Temp = Arr(LIndex) +450 LET Arr(LIndex) = Arr(RIndex) +460 LET Arr(RIndex) = Temp +470 LET LIndex = LIndex + 1 +480 LET RIndex = RIndex - 1 +490 IF (LIndex - 1) = Pivot THEN +500 LET RIndex = RIndex + 1 +510 LET Pivot = RIndex +520 ELSEIF (RIndex + 1) = Pivot THEN +530 LET LIndex = LIndex - 1 +540 LET Pivot = LIndex +550 END IF +560 LOOP +570 CALL QuickSort (Arr, L, Pivot - 1) +580 CALL QuickSort (Arr, Pivot + 1, R) +590 END IF +600 END SUB diff --git a/Task/Sorting-algorithms-Quicksort/EasyLang/sorting-algorithms-quicksort.easy b/Task/Sorting-algorithms-Quicksort/EasyLang/sorting-algorithms-quicksort.easy index 4838d2105f..7ddf5cf8ad 100644 --- a/Task/Sorting-algorithms-Quicksort/EasyLang/sorting-algorithms-quicksort.easy +++ b/Task/Sorting-algorithms-Quicksort/EasyLang/sorting-algorithms-quicksort.easy @@ -1,24 +1,17 @@ proc qsort left right . d[] . - while left < right - # partition - piv = d[left] - mid = left - for i = left + 1 to right - if d[i] < piv - mid += 1 - swap d[i] d[mid] - . - . - swap d[left] d[mid] - # - if mid < (right + left) / 2 - qsort left mid - 1 d[] - left = mid + 1 - else - qsort mid + 1 right d[] - right = mid - 1 + if left >= right + return + . + mid = left + for i = left + 1 to right + if d[i] < d[left] + mid += 1 + swap d[i] d[mid] . . + swap d[left] d[mid] + qsort left mid - 1 d[] + qsort mid + 1 right d[] . proc sort . d[] . qsort 1 len d[] d[] diff --git a/Task/Sorting-algorithms-Quicksort/PascalABC.NET/sorting-algorithms-quicksort.pas b/Task/Sorting-algorithms-Quicksort/PascalABC.NET/sorting-algorithms-quicksort.pas new file mode 100644 index 0000000000..3ca9ce5b4e --- /dev/null +++ b/Task/Sorting-algorithms-Quicksort/PascalABC.NET/sorting-algorithms-quicksort.pas @@ -0,0 +1,41 @@ +function Partition(a: array of integer; l,r: integer): integer; +begin + var i := l - 1; + var j := r + 1; + var x := a[l]; + while True do + begin + repeat + i += 1; + until a[i]>=x; + repeat + j -= 1; + until a[j]<=x; + if i=r then exit; + var j := Partition(a,l,r); + QuickSort(a,l,j); + QuickSort(a,j+1,r); +end; + +const n = 20; + +begin + var a := ArrRandom(n); + Println('Before: '); + Println(a); + QuickSort(a,0,a.Length-1); + Println('After sorting: '); + Println(a); +end. diff --git a/Task/Sorting-algorithms-Quicksort/Python/sorting-algorithms-quicksort-8.py b/Task/Sorting-algorithms-Quicksort/Python/sorting-algorithms-quicksort-8.py new file mode 100644 index 0000000000..9511b0bdb8 --- /dev/null +++ b/Task/Sorting-algorithms-Quicksort/Python/sorting-algorithms-quicksort-8.py @@ -0,0 +1,9 @@ +def quicksort(unsorted_list): + if len(unsorted_list) == 0: + return [] + pivot = unsorted_list[0] + less = list(filter(lambda x: x < pivot, unsorted_list)) + same = list(filter(lambda x: x == pivot, unsorted_list)) + more = list(filter(lambda x: x > pivot, unsorted_list)) + + return quicksort(less) + same + quicksort(more) diff --git a/Task/Sorting-algorithms-Quicksort/BASIC/sorting-algorithms-quicksort.basic b/Task/Sorting-algorithms-Quicksort/QuickBASIC/sorting-algorithms-quicksort.basic similarity index 100% rename from Task/Sorting-algorithms-Quicksort/BASIC/sorting-algorithms-quicksort.basic rename to Task/Sorting-algorithms-Quicksort/QuickBASIC/sorting-algorithms-quicksort.basic diff --git a/Task/Sorting-algorithms-Quicksort/XBasic/sorting-algorithms-quicksort.basic b/Task/Sorting-algorithms-Quicksort/XBasic/sorting-algorithms-quicksort.basic new file mode 100644 index 0000000000..b50bd9c3c1 --- /dev/null +++ b/Task/Sorting-algorithms-Quicksort/XBasic/sorting-algorithms-quicksort.basic @@ -0,0 +1,75 @@ +' Sorting algorithms/Quicksort +PROGRAM "quicksort" +VERSION "1.0" + +IMPORT "xst" + +DECLARE FUNCTION Entry () +DECLARE FUNCTION QuickSort (@arr%[], l%%, r%%) +' Pseudo-random number generator +' Based on the rand, srand functions from Kernighan & Ritchie's book +' 'The C Programming Language' +DECLARE FUNCTION Rand() +DECLARE FUNCTION SRand(seed%%) + +FUNCTION Entry () + DIM arr%[19] + a%% = 0 + b%% = UBOUND(arr%[]) + XstGetSystemTime (@msec) + SRand(INT(msec) MOD 32768) + FOR i%% = a%% TO b%% + arr%[i%%] = INT(Rand() / 32768.0 * 99.0) + NEXT i%% + PRINT "Unsorted:" + FOR i%% = a%% TO b%% + PRINT FORMAT$("## ", arr%[i%%]); + NEXT i%% + PRINT + PRINT "Sorted:" + QuickSort(@arr%[], a%%, b%%) + FOR i%% = a%% TO b%% + PRINT FORMAT$("## ", arr%[i%%]); + NEXT i%% + PRINT +END FUNCTION + +FUNCTION QuickSort (@arr%[], l%%, r%%) + leftIndex%% = l%% + rightIndex%% = r%% + IF r%% > l%% THEN + pivot%% = (l%% + r%%) \ 2 + DO WHILE (leftIndex%% <= pivot%%) AND (rightIndex%% >= pivot%%) + DO WHILE (arr%[leftIndex%%] < arr%[pivot%%]) AND (leftIndex%% <= pivot%%) + INC leftIndex%% + LOOP + DO WHILE (arr%[rightIndex%%] > arr%[pivot%%]) AND (rightIndex%% >= pivot%%) + DEC rightIndex%% + LOOP + SWAP arr%[leftIndex%%], arr%[rightIndex%%] + INC leftIndex%% + DEC rightIndex%% + SELECT CASE TRUE + CASE leftIndex%% - 1 = pivot%%: + INC rightIndex%% + pivot%% = rightIndex%% + CASE rightIndex%% + 1 = pivot%%: + DEC leftIndex%% + pivot%% = leftIndex%% + END SELECT + LOOP + QuickSort (@arr%[], l%%, pivot%% - 1) + QuickSort (@arr%[], pivot%% + 1, r%%) + END IF +END FUNCTION + +' Return pseudo-random integer on 0..32767 +FUNCTION Rand() + #next&& = #next&& * 1103515245 + 12345 +END FUNCTION USHORT(#next&& / 65536) MOD 32768 + +' Set seed for Rand() +FUNCTION SRand(seed%%) + #next&& = seed%% +END FUNCTION +END PROGRAM diff --git a/Task/Sorting-algorithms-Shell-sort/EasyLang/sorting-algorithms-shell-sort.easy b/Task/Sorting-algorithms-Shell-sort/EasyLang/sorting-algorithms-shell-sort.easy new file mode 100644 index 0000000000..81c18775a5 --- /dev/null +++ b/Task/Sorting-algorithms-Shell-sort/EasyLang/sorting-algorithms-shell-sort.easy @@ -0,0 +1,18 @@ +proc shellsort . a[] . + inc = len a[] div 2 + while inc > 0 + for i = inc to len a[] + tmp = a[i] + j = i + while j > inc and a[j - inc] > tmp + a[j] = a[j - inc] + j = j - inc + . + a[j] = tmp + . + inc = floor (0.5 + inc / 2.2) + . +. +a[] = [ -12 3 0 4 7 4 8 -5 9 ] +shellsort a[] +print a[] diff --git a/Task/Sorting-algorithms-Stooge-sort/11l/sorting-algorithms-stooge-sort.11l b/Task/Sorting-algorithms-Stooge-sort/11l/sorting-algorithms-stooge-sort.11l index 73342017c6..a6ee8c8ca9 100644 --- a/Task/Sorting-algorithms-Stooge-sort/11l/sorting-algorithms-stooge-sort.11l +++ b/Task/Sorting-algorithms-Stooge-sort/11l/sorting-algorithms-stooge-sort.11l @@ -1,4 +1,4 @@ -F stoogesort(&l, i, j) -> N +F stoogesort(&l, i, j) -> Void I l[j] < l[i] swap(&l[i], &l[j]) I j - i > 1 diff --git a/Task/Sorting-algorithms-Stooge-sort/EasyLang/sorting-algorithms-stooge-sort.easy b/Task/Sorting-algorithms-Stooge-sort/EasyLang/sorting-algorithms-stooge-sort.easy index 9e4fcc91e1..90b23cbadc 100644 --- a/Task/Sorting-algorithms-Stooge-sort/EasyLang/sorting-algorithms-stooge-sort.easy +++ b/Task/Sorting-algorithms-Stooge-sort/EasyLang/sorting-algorithms-stooge-sort.easy @@ -9,8 +9,6 @@ proc stsort left right . d[] . stsort left right - t d[] . . -for i = 1 to 100 - d[] &= randint 1000 -. +d[] = [ 1 4 5 3 -6 3 7 10 -2 -5 ] stsort 1 len d[] d[] print d[] diff --git a/Task/Sorting-algorithms-Stooge-sort/Yabasic/sorting-algorithms-stooge-sort.basic b/Task/Sorting-algorithms-Stooge-sort/Yabasic/sorting-algorithms-stooge-sort.basic new file mode 100644 index 0000000000..fb592eb1bf --- /dev/null +++ b/Task/Sorting-algorithms-Stooge-sort/Yabasic/sorting-algorithms-stooge-sort.basic @@ -0,0 +1,38 @@ +dim array(15) +a = 0 +b = arraysize(array(),1) + +for i = a to b + array(i) = ran(1000) +next i + +print "unsort "; +for i = a to b + print array(i) using("####"); + if i = b then print ""; else print ", "; : fi +next i + +stoogeSort(array(), a, b) // ordenar el array + +print "\n sort "; +for i = a to b + print array(i) using("####"); + if i = b then print ""; else print ", "; : fi +next i +print +end + +sub stoogeSort(array(), l, r) + if array(r) < array(l) then + temp = array(r) + array(r) = array(l) + array(l) = temp + fi + + if r - l > 1 then + t = int((r - l +1) / 3) + stoogeSort(array(), l , r - t) + stoogeSort(array(), l + t, r ) + stoogeSort(array(), l , r - t) + fi +end sub diff --git a/Task/Sorting-algorithms-Strand-sort/EasyLang/sorting-algorithms-strand-sort.easy b/Task/Sorting-algorithms-Strand-sort/EasyLang/sorting-algorithms-strand-sort.easy new file mode 100644 index 0000000000..484f6e4117 --- /dev/null +++ b/Task/Sorting-algorithms-Strand-sort/EasyLang/sorting-algorithms-strand-sort.easy @@ -0,0 +1,43 @@ +proc merge . a[] b[] . + a = 1 ; b = 1 + while a <= len a[] and b <= len b[] + if a[a] < b[b] + r[] &= a[a] + a += 1 + else + r[] &= b[b] + b += 1 + . + . + while a <= len a[] + r[] &= a[a] + a += 1 + . + while b <= len b[] + r[] &= b[b] + b += 1 + . + swap a[] r[] +. +proc strand . a[] s[] . + s[] = [ a[1] ] + for i = 2 to len a[] + if a[i] > s[$] + s[] &= a[i] + else + an[] &= a[i] + . + . + swap a[] an[] +. +proc strandsort . a[] . + strand a[] out[] + while len a[] > 0 + strand a[] b[] + merge out[] b[] + . + swap a[] out[] +. +a[] = [ 1 6 3 2 1 7 5 3 ] +strandsort a[] +print a[] diff --git a/Task/Special-variables/PascalABC.NET/special-variables-1.pas b/Task/Special-variables/PascalABC.NET/special-variables-1.pas new file mode 100644 index 0000000000..1fcb3cc601 --- /dev/null +++ b/Task/Special-variables/PascalABC.NET/special-variables-1.pas @@ -0,0 +1,4 @@ +function Add(a,b: integer): integer; +begin + Result := a + b +end; diff --git a/Task/Special-variables/PascalABC.NET/special-variables-2.pas b/Task/Special-variables/PascalABC.NET/special-variables-2.pas new file mode 100644 index 0000000000..e0b87b6a18 --- /dev/null +++ b/Task/Special-variables/PascalABC.NET/special-variables-2.pas @@ -0,0 +1,7 @@ +type A = class + n: integer; + constructor (n: integer); + begin + Self.n := n + end; +end; diff --git a/Task/Special-variables/PascalABC.NET/special-variables-3.pas b/Task/Special-variables/PascalABC.NET/special-variables-3.pas new file mode 100644 index 0000000000..8d09583abe --- /dev/null +++ b/Task/Special-variables/PascalABC.NET/special-variables-3.pas @@ -0,0 +1,4 @@ +type A = class + n: integer; + property pn: integer write n := value; +end; diff --git a/Task/Split-a-character-string-based-on-change-of-character/Refal/split-a-character-string-based-on-change-of-character.refal b/Task/Split-a-character-string-based-on-change-of-character/Refal/split-a-character-string-based-on-change-of-character.refal new file mode 100644 index 0000000000..356936cfb5 --- /dev/null +++ b/Task/Split-a-character-string-based-on-change-of-character/Refal/split-a-character-string-based-on-change-of-character.refal @@ -0,0 +1,16 @@ +$ENTRY Go { + = >>; +}; + +Split { + (e.Cur) = (e.Cur); + (e.Cur s.1) s.1 e.X = ; + (e.Cur) s.1 e.X = (e.Cur) ; + s.1 e.X = ; +}; + +Join { + (e.Joiner) = ; + (e.Joiner) (e.Str) = e.Str; + (e.Joiner) (e.Str) e.Strs = e.Str e.Joiner ; +}; diff --git a/Task/Split-a-character-string-based-on-change-of-character/SETL/split-a-character-string-based-on-change-of-character.setl b/Task/Split-a-character-string-based-on-change-of-character/SETL/split-a-character-string-based-on-change-of-character.setl new file mode 100644 index 0000000000..7c186a705a --- /dev/null +++ b/Task/Split-a-character-string-based-on-change-of-character/SETL/split-a-character-string-based-on-change-of-character.setl @@ -0,0 +1,17 @@ +program split_a_character_string_based_on_change_of_character; + s := "gHHH5YY++///\\"; + print(join_strings(", ", split_on_change(s))); + + proc split_on_change(s); + parts := []; + loop while s /= "" do + parts with:= span(s, s(1)); + end loop; + return parts; + end proc; + + proc join_strings(s, parts); + if parts=[] then return ""; end if; + return parts(1) +/ [s + part : part in parts(2..)]; + end proc; +end program; diff --git a/Task/Split-a-character-string-based-on-change-of-character/Uiua/split-a-character-string-based-on-change-of-character.uiua b/Task/Split-a-character-string-based-on-change-of-character/Uiua/split-a-character-string-based-on-change-of-character.uiua new file mode 100644 index 0000000000..2fb89a9b6a --- /dev/null +++ b/Task/Split-a-character-string-based-on-change-of-character/Uiua/split-a-character-string-based-on-change-of-character.uiua @@ -0,0 +1 @@ +&p/$"_, _"⊜□+1⊸⊛ "gHHH5YY++///\\" diff --git a/Task/Square-but-not-cube/8080-Assembly/square-but-not-cube.8080 b/Task/Square-but-not-cube/8080-Assembly/square-but-not-cube.8080 new file mode 100644 index 0000000000..15af8e54b8 --- /dev/null +++ b/Task/Square-but-not-cube/8080-Assembly/square-but-not-cube.8080 @@ -0,0 +1,91 @@ + org 100h + mvi b,30 ; Counter + push b +loop: lhld curcub ; DE = current cube + xchg + lhld cursqr ; HL = current square + call cdehl + jc advcub ; DE < HL, next cube + jz advsqr ; DE = HL, both square and cube + call prhl ; HL = square but not cube, print it + pop b ; Get counter + dcr b ; Decrease counter + rz ; Stop when zero reached + push b ; Push counter back +advsqr: call nexsqr ; Next square + jmp loop +advcub: call nexcub ; Next cube + jmp loop + + ; compare DE to HL +cdehl: mov a,d + cmp h + rnz + mov a,e + cmp l + ret + + ; Get next square (starting with 1) +nexsqr: lhld sqdiff ; DE = current difference + xchg + lhld cursqr ; HL = current square + dad d ; Add difference to square + inx d ; Increment difference twice + inx d + shld cursqr ; Update current square + xchg + shld sqdiff ; Update current difference + ret +cursqr: dw 0 ; Current square +sqdiff: dw 1 ; Difference to next squre + + ; Get next cube (starting with 1) +nexcub: lhld csumst ; DE = start of current sum + xchg + lxi h,0 ; HL = current cube + lda csumn ; A = amount of numbers to sum +csumlp: dad d ; Add to current cube + inx d ; Next odd number + inx d + dcr a ; Until done summing + jnz csumlp + shld curcub ; Store next sum + xchg + shld csumst ; Store start of next sum + lxi h,csumn ; Increment sum counter + inr m + ret +curcub: dw 0 ; Current cube +csumst: dw 1 ; Start of current sum +csumn: db 1 ; Amount of numbers to sum + + ; Print HL as a decimal value +prhl: push h ; Store registers + push d + push b + lxi b,pnum ; Store pointer to buffer on stack + push b + lxi b,-10 ; Divide by 10 using trial subtraction +prdgt: lxi d,-1 ; D = +prdgtl: inx d + dad b + jc prdgtl + mvi a,'0'+10 ; ASCII digit + 10 + add l ; L = remainder - 10 + pop h ; Get pointer to buffer + dcx h ; Go back one digit + mov m,a ; Store digit + push h ; Store pointer to buffer + xchg ; HL = n/10 + mov a,h ; Zero? + ora l + jnz prdgt ; If not, get more digits + mvi c,9 ; 9 = CP/M print string + pop d ; DE = buffer + call 5 + pop b ; Restore registers + pop d + pop h + ret + db '*****' ; Number placeholder +pnum: db 13,10,'$' diff --git a/Task/Square-but-not-cube/ABC/square-but-not-cube.abc b/Task/Square-but-not-cube/ABC/square-but-not-cube.abc new file mode 100644 index 0000000000..e3035390d2 --- /dev/null +++ b/Task/Square-but-not-cube/ABC/square-but-not-cube.abc @@ -0,0 +1,11 @@ +PUT 1 IN square.root +PUT 1 IN cube.root +PUT 30 IN amount + +WHILE amount > 0: + WHILE square.root ** 2 > cube.root ** 3: + PUT cube.root + 1 IN cube.root + IF square.root ** 2 <> cube.root ** 3: + WRITE square.root ** 2/ + PUT amount - 1 IN amount + PUT square.root + 1 IN square.root diff --git a/Task/Square-but-not-cube/MACRO-11/square-but-not-cube.macro11 b/Task/Square-but-not-cube/MACRO-11/square-but-not-cube.macro11 new file mode 100644 index 0000000000..2211e1072c --- /dev/null +++ b/Task/Square-but-not-cube/MACRO-11/square-but-not-cube.macro11 @@ -0,0 +1,53 @@ + .TITLE SQRCUB + .MCALL .TTYOUT,.EXIT + +SQRCUB::MOV #^D30,R5 + JSR PC,NEXCUB +1$: JSR PC,NEXSQR +2$: CMP R4,R3 + BLT 3$ + BEQ 1$ + MOV R3,R0 + JSR PC,PR0 + SOB R5,1$ + .EXIT +3$: JSR PC,NEXCUB + BR 2$ + + ; PUT SUCCESSIVE SQUARES IN R3 +NEXSQR: MOV 1$,R3 + ADD 2$,R3 + MOV R3,1$ + ADD #2,2$ + RTS PC +1$: .WORD 0 +2$: .WORD 1 + + ; PUT SUCCESSIVE CUBES IN R4 +NEXCUB: CLR R4 + MOV 3$,R1 +1$: ADD 2$,R4 + ADD #2,2$ + SOB R1,1$ + INC 3$ + RTS PC +2$: .WORD 1 +3$: .WORD 1 + + ; PRINT R0 AS DECIMAL WITH NEWLINE +PR0: MOV #4$,R2 +1$: MOV #-1,R1 +2$: INC R1 + SUB #12,R0 + BCC 2$ + ADD #72,R0 + MOVB R0,-(R2) + MOV R1,R0 + BNE 1$ +3$: MOVB (R2)+,R0 + .TTYOUT + BNE 3$ + RTS PC + .BLKB 5 +4$: .BYTE 15,12,0 + .END SQRCUB diff --git a/Task/Square-but-not-cube/Refal/square-but-not-cube.refal b/Task/Square-but-not-cube/Refal/square-but-not-cube.refal new file mode 100644 index 0000000000..0579e28990 --- /dev/null +++ b/Task/Square-but-not-cube/Refal/square-but-not-cube.refal @@ -0,0 +1,21 @@ +$ENTRY Go { + = >; +}; + +SquareCube { + s.Max = ; + 0 s.Sqrt s.Cbrt = ; + + s.Max s.Sqrt s.Cbrt, + : s.Square, + : s.Cube, + : { + '-' = s.Square + <+ 1 s.Sqrt> s.Cbrt>; + '0' = s.Cbrt>; + '+' = >; + }; +}; + +Square { s.N = <* s.N s.N>; }; +Cube { s.N = <* s.N <* s.N s.N>>; }; diff --git a/Task/Square-free-integers/Uiua/square-free-integers.uiua b/Task/Square-free-integers/Uiua/square-free-integers.uiua new file mode 100644 index 0000000000..fdf5d9ec43 --- /dev/null +++ b/Task/Square-free-integers/Uiua/square-free-integers.uiua @@ -0,0 +1,6 @@ +Sqf ← ≠0/↧◿⊸(×.↘2⇡+1⌊√) +⟜⧻▽⊸≡Sqf +1⇡145 +⟜⧻▽⊸≡Sqf +1e12+1⇡145 +# Find all squares and their multiples, and mask them out. +▽:⇡⟜(¬±°⊚/◇⊂≡(□×⇡+1)⌊÷:⟜(.×.↘2⇡√.))1000000 +⊙◌≡(/+<)⇌[⍥(×10.)4 100]¤ diff --git a/Task/Stack-traces/PascalABC.NET/stack-traces.pas b/Task/Stack-traces/PascalABC.NET/stack-traces.pas new file mode 100644 index 0000000000..e43d36da47 --- /dev/null +++ b/Task/Stack-traces/PascalABC.NET/stack-traces.pas @@ -0,0 +1,14 @@ +procedure qqq; +begin + var st := new System.Diagnostics.StackTrace(); + Print(st); +end; + +procedure ppp; +begin + qqq; +end; + +begin + ppp +end. diff --git a/Task/Stack/PascalABC.NET/stack.pas b/Task/Stack/PascalABC.NET/stack.pas new file mode 100644 index 0000000000..d006c63f48 --- /dev/null +++ b/Task/Stack/PascalABC.NET/stack.pas @@ -0,0 +1,11 @@ +begin + var st := new Stack; + var st1 := new Stack; + st.Push(1); + st.Push(2); + st.Push(3); + Println(st1,st); + while st.Count <> 0 do + st1.Push(st.Pop); + Println(st1,st); +end. diff --git a/Task/Stair-climbing-puzzle/EasyLang/stair-climbing-puzzle.easy b/Task/Stair-climbing-puzzle/EasyLang/stair-climbing-puzzle.easy new file mode 100644 index 0000000000..7f6a07a051 --- /dev/null +++ b/Task/Stair-climbing-puzzle/EasyLang/stair-climbing-puzzle.easy @@ -0,0 +1,15 @@ +func step . + if randint 2 = 2 + print "climbed up" + return 1 + else + print "fell down" + return 0 + . +. +proc step_up . . + while step = 0 + step_up + . +. +step_up diff --git a/Task/Steffensens-method/Phix/steffensens-method.phix b/Task/Steffensens-method/Phix/steffensens-method.phix index f551ce91ba..e328994710 100644 --- a/Task/Steffensens-method/Phix/steffensens-method.phix +++ b/Task/Steffensens-method/Phix/steffensens-method.phix @@ -1,62 +1,60 @@ -(phixonline)--> - with javascript_semantics - function aitken(integer f, atom p0) - atom p1 = f(p0), - p2 = f(p1), - p1m0 = p1 - p0 - return p0 - (p1m0 * p1m0) / (p2 - (2 * p1) + p0) - end function +with javascript_semantics +function aitken(integer f, atom p0) + atom p1 = f(p0), + p2 = f(p1), + p1m0 = p1 - p0 + return p0 - (p1m0 * p1m0) / (p2 - (2 * p1) + p0) +end function - function steffensenAitken(integer f, maxiter, atom pinit, tol) - atom p0 = pinit, p = aitken(f, p0) - integer iter = 1 - while abs(p-p0)>tol and iter<maxiter do - p0 = p - p = aitken(f, p0) - iter += 1 - end while - return iff(abs(p-p0)>tol?"none":p) - end function +function steffensenAitken(integer f, maxiter, atom pinit, tol) + atom p0 = pinit, p = aitken(f, p0) + integer iter = 1 + while abs(p-p0)>tol and itertol?"none":p) +end function - function deCasteljau(atom c0, c1, c2, t) - atom s = 1 - t, - c01 = (s * c0) + (t * c1), - c12 = (s * c1) + (t * c2), - c012 = (s * c01) + (t * c12) - return c012 - end function +function deCasteljau(atom c0, c1, c2, t) + atom s = 1 - t, + c01 = (s * c0) + (t * c1), + c12 = (s * c1) + (t * c2), + c012 = (s * c01) + (t * c12) + return c012 +end function - function xConvexLeftParabola(atom t) - return deCasteljau(2, -8, 2, t) - end function +function xConvexLeftParabola(atom t) + return deCasteljau(2, -8, 2, t) +end function - function yConvexLeftParabola(atom t) - return deCasteljau(1, 2, 3, t) - end function +function yConvexLeftParabola(atom t) + return deCasteljau(1, 2, 3, t) +end function - function implicitEquation(atom x, y) - return (5 * x * x) + y - 5 - end function +function implicitEquation(atom x, y) + return (5 * x * x) + y - 5 +end function - function f(atom t) - atom x = xConvexLeftParabola(t), - y = yConvexLeftParabola(t) - return implicitEquation(x, y) + t - end function +function f(atom t) + atom x = xConvexLeftParabola(t), + y = yConvexLeftParabola(t) + return implicitEquation(x, y) + t +end function - for i=0 to 10 do - printf(1,"t0 = %.1f : ",i/10) - object t = steffensenAitken(f, 1000, i/10, 0.00000001) - if string(t) then - printf(1,"no answer\n") - else - atom x = xConvexLeftParabola(t), - y = yConvexLeftParabola(t) - if abs(implicitEquation(x, y)) <= 0.000001 then - printf(1,"intersection at (%.6f, %.6f)\n",{x,y}) - else - printf(1,"spurious solution\n") - end if - end if - end for - - string size = "little" - string s = sprintf("Mary had a %s lamb.",{size}) - ?s -cell for -? -->cell for -? -->cell for -? - x w s -) - -while=: conjunction def 'u ^: v ^:_' NB. j assumes while is a verb and needs to know while is a conjunction. - -ttt=: outcome@:((display@:move) while undecided)@:display@:prepare - -blindfolded_variant=: outcome@:display@:(move while undecided)@:display@:prepare - -outcome=: {&(>;:'kitty VICTORY')@:won NB. (outcome does not pass along the state) -move=: post locate -undecided=: won nor full -prepare=: , board@:] NB. form the state vector - -Note 'locate' - is a monadic verb. y is the state vector. - returns the character of the chosen cell. - Generally: - locate=: second_strategy`first_strategy@.(first = mark) - Simplified: - locate=: human_locate NB. human versus human -) -locate=: human_locate`computer_locate@.(first = mark) - -display=: show [: (1 1,:5 5)&(];.0)@:": [: <"0 fold - -computer_locate=: [: show@{. board -. marks NB. strategy: first available -computer_locate=: [: show@({~ ?@:#) board -. marks NB. strategy: random - -human_locate=: monad define - state=. y - m=. mark state - b=. board state - cells=. b -. marks state - show '-->cell for ' , m , '?' - whilst. cell -.@:e. cells do. cell =. {. (1!:1]1) , m end. -) - -post=: 2&A.@:(3&{.)@:[ prepare mark@:[`((i.~ board)~)`(board@:[)} - -mark=: {. NB. mark of the current player from state -marks=: 2&{. NB. extract both markers from state -board=: _9&{. NB. extract board from state -first=: 2&{ NB. extract first player from state - -show=: [ smoutput - -full=: 2 = #@:~. -won=: test@:fold -fold=: 3 3 $ board -test=: [: any [: all [: infix_pairs_agree |:@:lines - -lines=: , diagonal , diagonal@:|. , |: -diagonal=: (<0 1)&|: -all=: *./ -any=: +./ -nor=: 8 b. -infix_pairs_agree=: 2&(=/\) + '`turn board open full'=: {.`}.`(0=[{board@])`(0-.@e.board) + '`cpu_move position'=: (?@#{])@([:I.0=board)`(cpu_move`you_move@.(_1 1 i.turn)) + you_move=: $:@echo@'invalid'^:(-.@e.i.@9)@:<:@".@{.@;:@(1!:1@1) + move=: position (][echo@'already taken!')`(-@turn@] , turn@]`[`(board@])})@.open ] + show=: [ [: echo@''@echo (,' '&,)/"1@({&'.XO')@(3 3$board) [ echo@'' + won=: [: +./ (3=[:|+/)"1@(], |:, (<@i.@#|:]),: <@i.@#|:|.)@(3 3$board) + prompt=: echo@:>:@i.@3 3@echo@'enter a move (1–9) each turn; you''re X''s' + outcome=: (echo@'tie')`(' wins'echo@,~{&'.XO'@-@turn)@.won + ttt=: outcome@([F.(show@move[_2:Z:won+.full))@(10{._1)@prompt diff --git a/Task/Tic-tac-toe/Jq/tic-tac-toe.jq b/Task/Tic-tac-toe/Jq/tic-tac-toe.jq new file mode 100644 index 0000000000..b6c396dc78 --- /dev/null +++ b/Task/Tic-tac-toe/Jq/tic-tac-toe.jq @@ -0,0 +1,151 @@ +include "MRG32k3a" {search: "."}; # see comment above + +### Generic functions + +def inform(msg): + . as $in + | msg + "\n" | stderr + | $in; + +def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .; + +# Create an m x n matrix with initial values specified by . +def matrix($m; $n): + if $m == 0 then [] + else . as $init + | if $m == 1 then [range(0;$n) | $init] + elif $m > 0 then + matrix(1; $n) as $row + | [range(0; $m) | $row ] + else error("matrix\($m);\($n)) invalid") + end + end; + + +### Tic-Tac-Toe + +# The board is represented by a matrix in which: +# 0 : blank; -1: computer; 1: user +def init: + {b: (0 | matrix(3;3)), + bestI: 0, + bestJ: 0, + prng: seed(now | tostring | sub("^.*[.]";"") | tonumber)}; + +# Output: 0 if undecided, null if game over, otherwise the player id +def checkWinner: + first(range(0; 3) as $i + | if .b[$i][0] != 0 and .b[$i][1] == .b[$i][0] and .b[$i][2] == .b[$i][0] then .b[$i][0] + elif .b[0][$i] != 0 and .b[1][$i] == .b[0][$i] and .b[2][$i] == .b[0][$i] then .b[0][$i] + else empty + end) + // if (.b[1][1] == 0) then 0 + elif (.b[1][1] == .b[0][0] and .b[2][2] == .b[0][0]) then .b[0][0] + elif (.b[1][1] == .b[2][0] and .b[0][2] == .b[1][1]) then .b[1][1] + elif all(.b[][]; . != 0) then null + else 0 + end ; + +def showBoard: + ["X", " ", "O"] as $t + | .b as $b + | range(0;3) as $i + | reduce range(0;3) as $j (""; + . + "\($t[$b[$i][$j] + 1]) " ), # b == -1 => "X"; b == 1 => "O" + "-----"; + +# Examine possible moves of the player identified by $value, avoiding embarrassment +# Set .result, .bestI, .bestJ, etc +def testMove($value; $depth): + checkWinner as $score + | if $score == null then .result = 0 + elif $score != 0 + then .result = (if $score == $value then 1 else -1 end) + else .best = -1 + | .changed = 0 + | reduce range(0;3) as $i (.; + reduce range(0;3) as $j (.; + if .b[$i][$j] == 0 + then .b[$i][$j] = $value + | .changed = $value + | testMove(-$value; $depth + 1) as $test + | (-$test.result) as $score + | .b[$i][$j] = 0 + | if $score > .best + then if $depth == 0 + then .bestI = $i + | .bestJ = $j + end + | .best = $score + end + end ) ) + | .result = if .changed != 0 then .best else 0 end + end; + +# Issue prompts on stderr; +# always allow q for quit +def read($prompt; $regex): + def r: + ($prompt | stderr | empty), + (try ((input + | if . == "q" then halt + else select(test($regex)) + end) // r) + catch if . == "break" then halt else r end ); + r; + +# Input: irrelevant +# $user should be boolean; specify `true` if the user plays first +def game($user): + "Board positions are numbered so:\n1 2 3\n4 5 6\n7 8 9", + "You have O, I have X.\n", + (init + {$user} + | label $out + | foreach range(0;9) as $k (.; + if .user + then .move = null + | until(.move; + (read("Your move: "; "^ *[1-9]") | tonumber - 1) as $move + | ($move/3|floor) as $i + | ($move % 3) as $j + | if .b[$i][$j] == 0 + then .b[$i][$j] = 1 + | .move = $move + end ) + end + | if (.user|not) + then # in the interests of entertainment, randomize if computer opens + if $k == 0 + then .prng |= nextFloat + | .bestI = (.prng.nextFloat * 100 | trunc) % 3 + | .prng |= nextFloat + | .bestJ = (.prng.nextFloat * 100 | trunc) % 3 + else testMove(-1; 0) + end + | .b[.bestI][.bestJ] = -1 + | inform("My move: \(.bestI * 3 + .bestJ + 1)") + end + | .user |= not + ; + # Output: + showBoard, + (checkWinner + | if . == 0 then empty + else (if . == 1 then "You win" + elif . == -1 then "I win" + else "A draw.\n\n" + end), + break $out + end ) )) ; + +# Alternate players +def controller: + def c($user): + game($user), + (read("Play again? [yn]: "; "^[yYnN]") as $in + | if $in|.[0:1]|ascii_downcase == "n" then halt + else c($user|not) + end); + c(true); + +controller diff --git a/Task/Time-a-function/PascalABC.NET/time-a-function.pas b/Task/Time-a-function/PascalABC.NET/time-a-function.pas new file mode 100644 index 0000000000..ebbe256cad --- /dev/null +++ b/Task/Time-a-function/PascalABC.NET/time-a-function.pas @@ -0,0 +1,14 @@ +function LongTimeCalc(n: integer): real; +begin + var sum := 0.0; + for var i:=1 to n do + for var j := 1 to n do + sum += 1/i/j; + Result := sum; +end; + +begin + MillisecondsDelta; + LongTimeCalc(10000).Println; + MillisecondsDelta.Println; +end. diff --git a/Task/Tokenize-a-string-with-escaping/EasyLang/tokenize-a-string-with-escaping.easy b/Task/Tokenize-a-string-with-escaping/EasyLang/tokenize-a-string-with-escaping.easy new file mode 100644 index 0000000000..99f46e1de6 --- /dev/null +++ b/Task/Tokenize-a-string-with-escaping/EasyLang/tokenize-a-string-with-escaping.easy @@ -0,0 +1,20 @@ +func$[] tokenize src$ sep$ esc$ . + r$[] = [ "" ] + for i = 1 to len src$ + c$ = substr src$ i 1 + if esc = 1 + r$[$] &= c$ + esc = 0 + else + if c$ = sep$ + r$[] &= "" + elif c$ = esc$ + esc = 1 + else + r$[$] &= c$ + . + . + . + return r$[] +. +print tokenize "one^|uno||three^^^^|four^^^|^cuatro|" "|" "^" diff --git a/Task/Tokenize-a-string/PascalABC.NET/tokenize-a-string.pas b/Task/Tokenize-a-string/PascalABC.NET/tokenize-a-string.pas new file mode 100644 index 0000000000..2f40bf497d --- /dev/null +++ b/Task/Tokenize-a-string/PascalABC.NET/tokenize-a-string.pas @@ -0,0 +1,5 @@ +begin + var s := 'Hello,How,Are,You,Today'; + var strings := s.Split(','); + Print(strings.JoinToString('.')); +end. diff --git a/Task/Top-rank-per-group/EasyLang/top-rank-per-group.easy b/Task/Top-rank-per-group/EasyLang/top-rank-per-group.easy new file mode 100644 index 0000000000..9a39f89571 --- /dev/null +++ b/Task/Top-rank-per-group/EasyLang/top-rank-per-group.easy @@ -0,0 +1,58 @@ +global na$[] id$[] sal[] dep$[] n . +# +proc read . . + s$ = input + repeat + s$ = input + until s$ = "" + a$[] = strsplit s$ "," + na$[] &= a$[1] + id$[] &= a$[2] + sal[] &= number a$[3] + dep$[] &= a$[4] + . + n = len na$[] +. +read +# +proc sort . . + for i = 1 to n - 1 + for j = i + 1 to n + h = strcmp dep$[i] dep$[j] + if h > 0 or h = 0 and sal[i] < sal[j] + swap na$[i] na$[j] + swap id$[i] id$[j] + swap sal[i] sal[j] + swap dep$[i] dep$[j] + . + . + . +. +sort +# +for i to n + if i > 1 and dep$[i] <> dep$[i - 1] + cnt = 0 + print "" + . + if cnt < 2 + print dep$[i] & " " & sal[i] & " " & na$[i] + cnt += 1 + . +. +# +input_data +Employee Name,Employee ID,Salary,Department +Tyler Bennett,E10297,32000,D101 +John Rappl,E21437,47000,D050 +George Woltman,E00127,53500,D101 +Adam Smith,E63535,18000,D202 +Claire Buckman,E39876,27800,D202 +David McClellan,E04242,41500,D101 +Rich Holcomb,E01234,49500,D202 +Nathan Adams,E41298,21900,D050 +Richard Potter,E43128,15900,D101 +David Motsinger,E27002,19250,D202 +Tim Sampair,E03033,27000,D101 +Kim Arlich,E10001,57000,D190 +Timothy Grove,E16398,29900,D190 diff --git a/Task/Top-rank-per-group/PascalABC.NET/top-rank-per-group.pas b/Task/Top-rank-per-group/PascalABC.NET/top-rank-per-group.pas new file mode 100644 index 0000000000..e717892e08 --- /dev/null +++ b/Task/Top-rank-per-group/PascalABC.NET/top-rank-per-group.pas @@ -0,0 +1,25 @@ +begin + var data := |('Tyler Bennett', 'E10297', 32000, 'D101'), + ('John Rappl', 'E21437', 47000, 'D050'), + ('George Woltman', 'E00127', 53500, 'D101'), + ('Adam Smith', 'E63535', 18000, 'D202'), + ('Claire Buckman', 'E39876', 27800, 'D202'), + ('David McClellan', 'E04242', 41500, 'D101'), + ('Rich Holcomb', 'E01234', 49500, 'D202'), + ('Nathan Adams', 'E41298', 21900, 'D050'), + ('Richard Potter', 'E43128', 15900, 'D101'), + ('David Motsinger', 'E27002', 19250, 'D202'), + ('Tim Sampair', 'E03033', 27000, 'D101'), + ('Kim Arlich', 'E10001', 57000, 'D190'), + ('Timothy Grove', 'E16398', 29900, 'D190')|; + + var N := 3; + foreach var group in data.GroupBy(rec -> rec[3]).OrderBy(gr -> gr.Key) do + begin + Println('Department',group.Key); + Println($' Employee Name Employee ID Salary'); + foreach var rec in group.OrderByDescending(x -> x[2]).Take(3) do + Println($' {rec[0],-18} {rec[1],-14} {rec[2]}'); + Println; + end; +end. diff --git a/Task/Topic-variable/Java/topic-variable.java b/Task/Topic-variable/Java/topic-variable.java new file mode 100644 index 0000000000..ddd2465093 --- /dev/null +++ b/Task/Topic-variable/Java/topic-variable.java @@ -0,0 +1,42 @@ +import java.awt.Point; +import java.util.ArrayDeque; +import java.util.List; +import java.util.Queue; + +public final class TopicVariable { + + public static void main(String[] args) { + List numbers = List.of( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); + // Example 1: + // We only want to count the number of elements in a list, + // so a topic variable can be used for the identify of each element of the list. + // An artificial example since we could just use 'total = numbers.size()'. + int total = 0; + for ( Integer _ : numbers ) { // Topic variable + total += 1; + } + System.out.println("The list contains " + total + " numbers"); + + // Example 2: + // A topic variable is suitable for the unused identifier of the NumberFormatException. + String text = "123456:@~"; + int i = 0; + try { + i = Integer.parseInt(text); + } catch(NumberFormatException _) { // Topic variable + System.out.println("Variable i is incorrectly defined with value: " + i); + } + + // Example 3: + // We only require the first two out of every three items in a queue. + // A topic variable can be used for the third unused item. + Queue queue = new ArrayDeque(numbers); + while ( queue.size() >= 3 ) { + int x = queue.poll(); + int y = queue.poll(); + int _ = queue.poll(); // Topic variable + System.out.println( new Point(x, y) ); + } + } + +} diff --git a/Task/Towers-of-Hanoi/11l/towers-of-hanoi.11l b/Task/Towers-of-Hanoi/11l/towers-of-hanoi.11l index b49ca4c909..39a07d4627 100644 --- a/Task/Towers-of-Hanoi/11l/towers-of-hanoi.11l +++ b/Task/Towers-of-Hanoi/11l/towers-of-hanoi.11l @@ -1,4 +1,4 @@ -F hanoi(ndisks, startPeg = 1, endPeg = 3) -> N +F hanoi(ndisks, startPeg = 1, endPeg = 3) -> Void I ndisks hanoi(ndisks - 1, startPeg, 6 - startPeg - endPeg) print(‘Move disk #. from peg #. to peg #.’.format(ndisks, startPeg, endPeg)) diff --git a/Task/Towers-of-Hanoi/Asymptote/towers-of-hanoi.asymptote b/Task/Towers-of-Hanoi/Asymptote/towers-of-hanoi.asymptote new file mode 100644 index 0000000000..b08a7c6dbb --- /dev/null +++ b/Task/Towers-of-Hanoi/Asymptote/towers-of-hanoi.asymptote @@ -0,0 +1,12 @@ +void hanoi(int n, string origen, string auxiliar, string destino) { + if (n == 1) { + write("Move disk 1 from " + origen + " to " + destino); + } else { + hanoi(n - 1, origen, destino, auxiliar); + write("Move disk " + string(n) + " from " + origen + " to " + destino); + hanoi(n - 1, auxiliar, origen, destino); + } +} + +hanoi(3, "pole 1", "pole 2", "pole 3"); +write("Towers of Hanoi puzzle completed!"); diff --git a/Task/Towers-of-Hanoi/Bruijn/towers-of-hanoi.bruijn b/Task/Towers-of-Hanoi/Bruijn/towers-of-hanoi.bruijn new file mode 100644 index 0000000000..afebb12485 --- /dev/null +++ b/Task/Towers-of-Hanoi/Bruijn/towers-of-hanoi.bruijn @@ -0,0 +1,10 @@ +:import std/Combinator . +:import std/Number . +:import std/String . + +hanoi y [[[[=?2 empty go]]]] + go [(4 --3 2 0) ++ str ++ (4 --3 0 1)] ((+6) - 1 - 0) + str "Move " ++ disk ++ " from " ++ source ++ " to " ++ destination ++ "\n" + disk number→string 3 + source number→string 2 + destination number→string 1 diff --git a/Task/Towers-of-Hanoi/JavaScript/towers-of-hanoi-4.js b/Task/Towers-of-Hanoi/JavaScript/towers-of-hanoi-4.js index 49e482c77c..6ac3a344ab 100644 --- a/Task/Towers-of-Hanoi/JavaScript/towers-of-hanoi-4.js +++ b/Task/Towers-of-Hanoi/JavaScript/towers-of-hanoi-4.js @@ -9,18 +9,18 @@ (a, b, c) => { const go = hanoi(n - 1); - return Boolean(n) ? [ - ...go(a, c, b), - ...[ - [a, b] - ], - ...go(c, b, a) - ] : []; + return n + ? [ + ...go(a, c, b), + [a, b], + ...go(c, b, a) + ] + : []; }; // ---------------------- TEST ----------------------- return hanoi(3)("left", "right", "mid") - .map(d => `${d[0]} -> ${d[1]}`) - .join("\n"); + .map(d => `${d[0]} -> ${d[1]}`) + .join("\n"); })(); diff --git a/Task/Towers-of-Hanoi/PascalABC.NET/towers-of-hanoi.pas b/Task/Towers-of-Hanoi/PascalABC.NET/towers-of-hanoi.pas new file mode 100644 index 0000000000..b1b19ee5d4 --- /dev/null +++ b/Task/Towers-of-Hanoi/PascalABC.NET/towers-of-hanoi.pas @@ -0,0 +1,9 @@ +## procedure Hanoi(n,rfrom,rto,rwork: integer); +begin + if n = 0 then + exit; + Hanoi(n-1,rfrom,rwork,rto); + Print($'{rfrom}→{rto} '); + Hanoi(n-1,rwork,rto,rfrom); +end; +Hanoi(5,1,3,2); diff --git a/Task/Trabb-Pardo-Knuth-algorithm/PascalABC.NET/trabb-pardo-knuth-algorithm.pas b/Task/Trabb-Pardo-Knuth-algorithm/PascalABC.NET/trabb-pardo-knuth-algorithm.pas new file mode 100644 index 0000000000..de14726133 --- /dev/null +++ b/Task/Trabb-Pardo-Knuth-algorithm/PascalABC.NET/trabb-pardo-knuth-algorithm.pas @@ -0,0 +1,10 @@ +function f(x:real) := Sqrt(x) + 5 *x ** 3; + +begin + var seq := ReadArrInteger(11).Reverse; + foreach var x in seq do + begin + var fx := f(x); + Println($'f({x}): {fx > 400 ? ''overflow'' : fx.ToString}'); + end; +end. diff --git a/Task/Trabb-Pardo-Knuth-algorithm/UNIX-Shell/trabb-pardo-knuth-algorithm.sh b/Task/Trabb-Pardo-Knuth-algorithm/UNIX-Shell/trabb-pardo-knuth-algorithm.sh new file mode 100644 index 0000000000..2edba48216 --- /dev/null +++ b/Task/Trabb-Pardo-Knuth-algorithm/UNIX-Shell/trabb-pardo-knuth-algorithm.sh @@ -0,0 +1,18 @@ +fn f { + printf 'scale=3; sqrt(sqrt(%s^2)) + 5.0 * %s ^ 3 \n' $1 $1 | bc +} + +count = 11 +list = () +for (idx in `{seq $count}) { + num = `{read} # get value from stdin + list = ($num $list) # add to list in reverse +} +for (idx in `{seq $count}) { + x = $list($idx) + printf 'f(%s) = ' $x + y = `{f $x} + if (~ `{printf '%s > 400 \n' $y | bc} 1) + echo TOO LARGE! + if not echo $y +} diff --git a/Task/Transliterate-English-text-using-the-Greek-alphabet/PascalABC.NET/transliterate-english-text-using-the-greek-alphabet.pas b/Task/Transliterate-English-text-using-the-Greek-alphabet/PascalABC.NET/transliterate-english-text-using-the-greek-alphabet.pas new file mode 100644 index 0000000000..b2e05df688 --- /dev/null +++ b/Task/Transliterate-English-text-using-the-Greek-alphabet/PascalABC.NET/transliterate-english-text-using-the-greek-alphabet.pas @@ -0,0 +1,37 @@ +var repl := Dict( + ('ch', 'χ'), ('th', 'θ'), ('ps', 'ψ'), ('ph', 'f'), ('Ch', 'Χ'), + ('Th', 'Θ'), ('Ps', 'Ψ'), ('Ph', 'F'), ('ee', 'h'), ('ck', 'κ'), ('rh', 'r'), ('kh', 'χ'), + ('Kh', 'Χ'), ('oo', 'w'), + ($'a', 'α'), ($'b', 'β'), ($'c', 'κ'), ($'d', 'δ'), ($'e', 'ε'), + ($'f', 'φ'), ($'g', 'γ'), ($'h', 'η'), ($'i', 'ι'), ($'j', 'ι'), ($'k', 'κ'), ($'l', 'λ'), + ($'m', 'μ'), ($'n', 'ν'), ($'o', 'ο'), ($'p', 'π'), ($'q', 'κ'), ($'r', 'ρ'), ($'s', 'σ'), + ($'t', 'τ'), ($'u', 'υ'), ($'v', 'β'), ($'w', 'ω'), ($'x', 'ξ'), ($'y', 'υ'), ($'z', 'ζ'), + ($'D', 'Δ'), ($'F', 'Φ'), ($'G', 'Γ'), ($'J', 'I'), ($'L', 'Λ'), ($'P', 'Π'), ($'Q', 'Κ'), + ($'R', 'Ρ'), ($'S', 'Σ'), ($'Y', 'U'), ($'W', 'Ω'), ($'X', 'Ξ') +); + +var texts := Arr( + 'The quick brown fox jumped over the lazy dog.', + + ''' + I was looking at some rhododendrons in my back garden, + dressed in my khaki shorts, when the telephone rang. + + As I answered it, I cheerfully glimpsed that the July sun + caused a fragment of black pine wax to ooze on the velvet quilt + laying in my patio. + ''', + + 'sphinx of black quartz, judge my vow.' +); + +begin + foreach var txt in texts do + begin + Println(txt); Println('=>'); + var txt1 := txt; + foreach var pair in repl do + txt1 := txt1.Replace(pair.Key,pair.Value); + Println(txt1 + NewLine); + end; +end. diff --git a/Task/Tree-datastructures/11l/tree-datastructures.11l b/Task/Tree-datastructures/11l/tree-datastructures.11l index 7c2c8d2cff..ef681a86d3 100644 --- a/Task/Tree-datastructures/11l/tree-datastructures.11l +++ b/Task/Tree-datastructures/11l/tree-datastructures.11l @@ -17,16 +17,11 @@ T NNode F String() R .to_str(0) -T INode - String value - Int level - F (value, level) - .value = value - .level = level +T INode = (String value, Int level) F to_indented(node) [INode] result - F add_node(NNode node, Int level) -> N + F add_node(NNode node, Int level) -> Void @result.append(INode(node.value, level)) L(child) node.children @add_node(child, level + 1) diff --git a/Task/Tree-datastructures/PascalABC.NET/tree-datastructures.pas b/Task/Tree-datastructures/PascalABC.NET/tree-datastructures.pas new file mode 100644 index 0000000000..66b73fe890 --- /dev/null +++ b/Task/Tree-datastructures/PascalABC.NET/tree-datastructures.pas @@ -0,0 +1,41 @@ +{$zerobasedstrings} +function NestedToIndented(nested: string): string; +begin + var lst := new List; + foreach var line in Regex.Split(nested,NewLine) do + begin + var ind := Regex.Match(line,'[^\.]').Index; + lst.Add($'{ind div 4} {line[ind:]}'); + end; + Result := lst.JoinToString(NewLine); +end; + +function IndentedToNested(indented: string): string; +begin + var lst := new List; + foreach var line in Regex.Split(indented,NewLine) do + begin + var ind := line.IndexOf(' '); + var level := line[:ind].ToInteger; + lst.Add((level*4) * '.' + line[ind+1:]); + end; + Result := lst.JoinToString(NewLine); +end; + +begin + var initialNested := ''' + Rosetta Code + ....rocks + ........code + ........comparison + ........wiki + ....mocks + ........trolling + '''; + Writeln(initialNested,NewLine); + var indented := NestedToIndented(initialNested); + Writeln(indented,NewLine); + var nested := IndentedToNested(indented); + Writeln(nested,NewLine); + Writeln($'Initial = Restored: {initialNested = nested}'); +end. diff --git a/Task/Tree-from-nesting-levels/C-sharp/tree-from-nesting-levels.cs b/Task/Tree-from-nesting-levels/C-sharp/tree-from-nesting-levels.cs new file mode 100644 index 0000000000..c6e586132d --- /dev/null +++ b/Task/Tree-from-nesting-levels/C-sharp/tree-from-nesting-levels.cs @@ -0,0 +1,70 @@ +public static class TreeFromNestingLevels +{ + public static void Main() + { + List tests = [[], [1,2,4], [3,1,3,1], [1,2,3,1], [3,2,1,3], [3,3,3,1,1,3,3,3]]; + Console.WriteLine($"{"Input",24} -> {"Nested",-32} -> Round-trip"); + foreach (var test in tests) { + var tree = BuildTree(test); + string input = $"[{string.Join(", ", test)}]"; + string roundTrip = $"[{string.Join(", ", tree.ToList())}]"; + Console.WriteLine($"{input,24} -> {tree,-32} -> {roundTrip}"); + } + } + + private static Tree BuildTree(int[] levels) + { + Tree root = new(0); + Tree current = root; + foreach (int level in levels) { + while (current.Level > level) current = current.Parent; + current = current.Parent.Add(level); + } + return root; + } + + private class Tree + { + public int Level { get; } + public Tree Parent { get; } + private readonly List children = []; + + public Tree(int level, Tree? parent = null) + { + Level = level; + Parent = parent ?? this; + } + + public Tree Add(int level) + { + if (Level == level) return this; + Tree tree = new(Level + 1, this); + children.Add(tree); + return tree.Add(level); + } + + public override string ToString() => children.Count == 0 + ? (Level == 0 ? "[]" : $"{Level}") + : $"[{string.Join(", ", children.Select(c => c.ToString()))}]"; + + public List ToList() + { + List list = []; + ToList(this, list); + return list; + } + + private static void ToList(Tree tree, List list) + { + if (tree.children.Count == 0) { + if (tree.Level > 0) list.Add(tree.Level); + } else { + foreach (Tree child in tree.children) { + ToList(child, list); + } + } + } + + } + +} diff --git a/Task/Tree-traversal/11l/tree-traversal.11l b/Task/Tree-traversal/11l/tree-traversal.11l index 2a278b81b8..d4cb66b021 100644 --- a/Task/Tree-traversal/11l/tree-traversal.11l +++ b/Task/Tree-traversal/11l/tree-traversal.11l @@ -8,28 +8,28 @@ T Node .left = left .right = right - F preorder(visitor) -> N + F preorder(visitor) -> Void visitor(.data) I .left != N .left.preorder(visitor) I .right != N .right.preorder(visitor) - F inorder(visitor) -> N + F inorder(visitor) -> Void I .left != N .left.inorder(visitor) visitor(.data) I .right != N .right.inorder(visitor) - F postorder(visitor) -> N + F postorder(visitor) -> Void I .left != N .left.postorder(visitor) I .right != N .right.postorder(visitor) visitor(.data) - F preorder2(&d, level = 0) -> N + F preorder2(&d, level = 0) -> Void d[level].append(.data) I .left != N .left.preorder2(d, level + 1) diff --git a/Task/Tree-traversal/EMal/tree-traversal.emal b/Task/Tree-traversal/EMal/tree-traversal.emal new file mode 100644 index 0000000000..b9445a4632 --- /dev/null +++ b/Task/Tree-traversal/EMal/tree-traversal.emal @@ -0,0 +1,63 @@ +type Node +model + :T value + Node left + Node right + new by generic T, :T ←value do end + fun visit ← <|write(me.value + " ") +end +type Order +enum + int PREORDER, INORDER, POSTORDER, LEVELORDER +end +type Main +fun traverse ← void by Node node, Order order + if node æ null do return end + if order æ Order.PREORDER + node.visit() + traverse(node.left, order) + traverse(node.right, order) + else if order æ Order.INORDER + traverse(node.left, order) + node.visit() + traverse(node.right, order) + else if order æ Order.POSTORDER + traverse(node.left, order) + traverse(node.right, order) + node.visit() + else if order æ Order.LEVELORDER + List queue ← Node[] + queue.insertFirst(node) + while not queue.isEmpty() + Node next ← queue.deleteLast() + next.visit() + if next.left ≠ null do queue.insertFirst(next.left) end + if next.right ≠ null do queue.insertFirst(next.right) end + end + end +end +Node one ← Node(int, 1) +Node two ← Node(int, 2) +Node three ← Node(int, 3) +Node four ← Node(int, 4) +Node five ← Node(int, 5) +Node six ← Node(int, 6) +Node seven ← Node(int, 7) +Node eight ← Node(int, 8) +Node nine ← Node(int, 9) +one.left ← two +one.right ← three +two.left ← four +two.right ← five +three.left ← six +four.left ← seven +six.left ← eight +six.right ← nine +traverse(one, Order.PREORDER) +writeLine() +traverse(one, Order.INORDER) +writeLine() +traverse(one, Order.POSTORDER) +writeLine() +traverse(one, Order.LEVELORDER) +writeLine() diff --git a/Task/Tree-traversal/PascalABC.NET/tree-traversal.pas b/Task/Tree-traversal/PascalABC.NET/tree-traversal.pas new file mode 100644 index 0000000000..caf40fdf02 --- /dev/null +++ b/Task/Tree-traversal/PascalABC.NET/tree-traversal.pas @@ -0,0 +1,61 @@ +type + Node = auto class + data: T; + left,right: Node; + end; + +function ND(data: T; left: Node := nil; right: Node := nil) + := new Node(data,left,right); + +procedure Prefix(r: Node); +begin + if r = nil then + exit; + Print(r.data); + Prefix(r.left); + Prefix(r.right); +end; + +procedure Infix(r: Node); +begin + if r = nil then + exit; + Infix(r.left); + Print(r.data); + Infix(r.right); +end; + +procedure Postfix(r: Node); +begin + if r = nil then + exit; + Postfix(r.left); + Postfix(r.right); + Print(r.data); +end; + +procedure LevelOrder(r: Node); +begin + if r = nil then + exit; + var q := new Queue>; + q.Enqueue(r); + while q.Count > 0 do + begin + var x := q.Dequeue; + Print(x.data); + if x.left <> nil then + q.Enqueue(x.Left); + if x.Right <> nil then + q.Enqueue(x.Right); + end; +end; + +begin + var root := ND(1,ND(2,ND(4,ND(7)),ND(5)),ND(3,ND(6,ND(8),ND(9)))); + Println(root); + Prefix(root); Println; + Infix(root); Println; + Postfix(root); Println; + LevelOrder(root); Println; +end. diff --git a/Task/Tree-traversal/Rust/tree-traversal.rust b/Task/Tree-traversal/Rust/tree-traversal.rust index 3fece25e48..1d40a9504c 100644 --- a/Task/Tree-traversal/Rust/tree-traversal.rust +++ b/Task/Tree-traversal/Rust/tree-traversal.rust @@ -64,38 +64,23 @@ impl TreeNode { res } - // Leftmost to rightmost + // From left to right fn iterative_inorder(&self) -> Vec<&TreeNode> { let mut stack: Vec<&TreeNode> = Vec::new(); let mut res: Vec<&TreeNode> = Vec::new(); - let mut p = self; + let mut opt = Some(self); - loop { - // Stack parents and right children while left-descending - loop { - match p.right { - None => {} - Some(box ref n) => stack.push(n), - } - stack.push(p); - match p.left { - None => break, - Some(box ref n) => p = n, - } - } - // Visit the nodes with no right child - p = stack.pop().unwrap(); - while !stack.is_empty() && p.right.is_none() { - res.push(p); - p = stack.pop().unwrap(); - } - // First node that can potentially have a right child: - res.push(p); - if stack.is_empty() { - break; - } else { - p = stack.pop().unwrap(); + while { + // Descend leftwards + while let Some(tree) = opt { + stack.push(tree); + opt = tree.left.as_deref(); } + !stack.is_empty() + } { + let tree = stack.pop().unwrap(); + res.push(tree); + opt = tree.right.as_deref(); } res } diff --git a/Task/Trigonometric-functions/PascalABC.NET/trigonometric-functions.pas b/Task/Trigonometric-functions/PascalABC.NET/trigonometric-functions.pas new file mode 100644 index 0000000000..83f732fc74 --- /dev/null +++ b/Task/Trigonometric-functions/PascalABC.NET/trigonometric-functions.pas @@ -0,0 +1,20 @@ +begin + var rad := Pi/3; + var deg := RadToDeg(rad); + Println('=== Radians ==='); + var (Si,Co,Ta) := (Sin(rad),Cos(rad),Tan(rad)); + Println($'Sin({rad}) = {Si}'); + Println($'Cos({rad}) = {Co}'); + Println($'Tan({rad}) = {Ta}'); + Println($'ArcSin({Si}) = {ArcSin(Si)}'); + Println($'ArcCos({Co}) = {ArcCos(Co)}'); + Println($'ArcTan({Ta}) = {ArcTan(Ta)}'); + Println('=== Degrees ==='); + var (SiD,CoD,TaD) := (Sin(DegToRad(deg)),Cos(DegToRad(deg)),Tan(DegToRad(deg))); + Println($'Sin({deg}) = {SiD}'); + Println($'Cos({deg}) = {CoD}'); + Println($'Tan({deg}) = {TaD}'); + Println($'ArcSin({SiD}) = {RadToDeg(ArcSin(SiD))}'); + Println($'ArcCos({CoD}) = {RadToDeg(ArcCos(CoD))}'); + Println($'ArcTan({TaD}) = {RadToDeg(ArcTan(TaD))}'); +end. diff --git a/Task/Trigonometric-functions/Phix/trigonometric-functions.phix b/Task/Trigonometric-functions/Phix/trigonometric-functions.phix index 2b71f21c5b..c6b4fb5c91 100644 --- a/Task/Trigonometric-functions/Phix/trigonometric-functions.phix +++ b/Task/Trigonometric-functions/Phix/trigonometric-functions.phix @@ -1,15 +1,13 @@ -(phixonline)--> - with javascript_semantics - ?sin(PI/2) - ?sin(90*PI/180) - ?cos(0) - ?cos(0*PI/180) - ?tan(PI/4) - ?tan(45*PI/180) - ?arcsin(1)*2 - ?arcsin(1)*180/PI - ?arccos(0)*2 - ?arccos(0)*180/PI - ?arctan(1)*4 - ?arctan(1)*180/PI -9 A-->Z */ +Do n=1 To words(z) /* [?] process all specified ISINs.*/ + x=word(z,n) /*obtain an ISIN from the Z list. */ + p=verify(x,valid,'N') + If p>0 Then msg='invalid character in position' p':' substr(x,p,1) + Else Do + dd='' /* [?] construct list of ISIN digits. */ + Do k=1 To length(x) + _=substr(x,k,1) /*the ISIN may contain alphabetic chars*/ + p=pos(_,valid) /*X contains 0-->9 A-->Z */ + dd=dd||p-1 /*convert X string (base 36 --? dec).*/ + End + msg='' + Select + When length(x)\==12 Then msg='not exactly 12 chars' + When \datatype( left(x,2),'U') Then msg='not starting with 2 capital chars' + When \datatype(right(x,1),'W') Then msg='last character is not a digit' + Otherwise + If \luhn(dd) Then msg='does not pass the Luhn test' + End + End + If msg='' Then + Say right(x,15) ' valid' /* display the positive message. */ + Else + Say right(x,15) 'not valid:' msg /* display the problem */ + End /*n*/ +Exit /*stick a fork in it, we're all done */ +/*-----------------------------------------------------------------------------------*/ +luhn: Procedure + Parse Arg x /* get credit card number; */ + dsum=0 /* zero digit sum. */ + y=reverse(left(0,length(x)//2)x) /* add leading zero If needed & reverse */ + Do j=1 To length(y)-1 By 2 + _=2*substr(y,j+1,1) + dsum=dsum+substr(y,j,1)+left(_,1)+substr(_,2,1,0) + End + Return right(dsum,1)==0 /* Return 1 if number passed Luhn test */ diff --git a/Task/Validate-International-Securities-Identification-Number/Uiua/validate-international-securities-identification-number.uiua b/Task/Validate-International-Securities-Identification-Number/Uiua/validate-international-securities-identification-number.uiua new file mode 100644 index 0000000000..50c0fb243e --- /dev/null +++ b/Task/Validate-International-Securities-Identification-Number/Uiua/validate-international-securities-identification-number.uiua @@ -0,0 +1,19 @@ +Base ← "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +Luhn ← =0◿10+⊃(/+⊢|/+∵(⍥(-9)>9.×2)⊡1)⍉⬚0↯∞_2⇌ +Checksum ← Luhn≡⋕/◇⊂≡(□°⋕⊗)⊙(¤Base) +Format ← ××⊃(/×≡(≥@A)↙2|=12⧻|/↧∊:Base) +Valid ← ×⊃(Format|Checksum) + +Tests ← { + "AU0000XVGZA3" + "US0378331005" + "US0373831005" # twiddled + "U50378331005" # 5 rather than S + "US03378331005" # Extra char + "AU0000XVGZA3" + "AU0000VXGZA3" + "FR0000988040" + "F00Ö00988040" # Illegal char +} + +≡◇Valid Tests diff --git a/Task/Van-Eck-sequence/REXX/van-eck-sequence-1.rexx b/Task/Van-Eck-sequence/REXX/van-eck-sequence-1.rexx index edf190ada6..3faa5e1190 100644 --- a/Task/Van-Eck-sequence/REXX/van-eck-sequence-1.rexx +++ b/Task/Van-Eck-sequence/REXX/van-eck-sequence-1.rexx @@ -1,10 +1,24 @@ -/*REXX pgm generates/displays the 'start ──► end' elements of the Van Eck sequence.*/ -parse arg LO HI $ . /*obtain optional arguments from the CL*/ -if LO=='' | LO=="," then LO= 1 /*Not specified? Then use the default.*/ -if HI=='' | HI=="," then HI= 10 /* " " " " " " */ -if $=='' | $=="," then $= 0 /* " " " " " " */ -$$=; z= $ /*$$: old seq: $: initial value of seq*/ - do HI-1; z= wordpos( reverse(z), reverse($$) ); $$= $; $= $ z - end /*HI-1*/ /*REVERSE allows backwards search in $.*/ - /*stick a fork in it, we're all done. */ -say 'terms ' LO " through " HI ' of the Van Eck sequence are: ' subword($,LO,HI-LO+1) +/*REXX pgm generates/displays the 'start --> end' elements of the Van Eck sequence.*/ +Parse Arg lo hi d . /*obtain optional arguments from the CL*/ +If lo=='' | lo==',' Then lo= 1 /*Not specified? Then use the default.*/ +If hi=='' | hi==',' Then hi= 10 /* " " " " " " */ +If d=='' | d==',' Then d= 0 /* " " " " " " */ +dd='' +z=d /*dd: old seq: d: initial value of seq*/ +Do i=1 To hi-1 + za=wordpos(reverse(z),reverse(dd)) + zb=0 + wdd=words(dd) + Do zz=wdd To 1 By -1 + If z=word(dd,zz) Then Do + zb=wdd-zz+1 + Leave + End + End + z=za + dd=d + d=d z + End /*HI-1*/ /*REVERSE allows backwards search in d.*/ +Say 'terms ' lo ' through ' hi ' of the Van Eck sequence are: ' subword(d,lo,hi-lo+1) +Exit + /*stick a fork in it, we're all done. */ diff --git a/Task/Van-Eck-sequence/REXX/van-eck-sequence-2.rexx b/Task/Van-Eck-sequence/REXX/van-eck-sequence-2.rexx index e8cb15b233..533d8971e8 100644 --- a/Task/Van-Eck-sequence/REXX/van-eck-sequence-2.rexx +++ b/Task/Van-Eck-sequence/REXX/van-eck-sequence-2.rexx @@ -1,14 +1,30 @@ -/*REXX pgm generates/displays the 'start ──► end' elements of the Van Eck sequence.*/ -parse arg LO HI sta . /*obtain optional arguments from the CL*/ -if LO=='' | LO=="," then LO= 1 /*Not specified? Then use the default.*/ -if HI=='' | HI=="," then HI= 10 /* " " " " " " */ -if sta=='' | sta=="," then sta= 0 /* " " " " " " */ -$.0= sta; x= sta; @.=. /*$.: the Van Eck sequence as a list.*/ - do #=1 for HI-1 /*X: is the last term being examined. */ - if @.x==. then do; @.x= #; $.#= 0; x= 0; end /*new term.*/ - else do; z= # - @.x; $.#= z; @.x= #; x= z; end /*old term.*/ - end /*#*/ /*Z: the new term being added to list.*/ - LOw= LO - 1; out= $.LOw /*initialize the output value. */ - do j=LO to HI-1; out= out $.j /*build a list for the output display. */ - end /*j*/ /*stick a fork in it, we're all done. */ -say 'terms ' LO " through " HI ' of the Van Eck sequence are: ' out +/*REXX pgm generates/displays the 'start --? end' elements of the Van Eck sequence.*/ +Parse Arg lo hi sta . /*obtain optional arguments from the CL*/ +If lo=='' | lo==',' Then lo= 1 /*Not specified? Then use the default.*/ +If hi=='' | hi==',' Then hi= 10 /* " " " " " " */ +If sta=='' | sta==',' Then sta= 0 /* " " " " " " */ +d.0=sta /*d.: the Van Eck sequence as a list.*/ +x=sta +a.=. +out='0' +Do n=1 For hi-1 /*X: is the last term being examined. */ + If a.x==. Then Do /* new term. */ + a.x=n + d.n=0 + x=0 + End + Else Do /* old term. */ + z=n-a.x + d.n=z + a.x=n + x=z + End + out=out d.n + End /*n*/ /*Z: the new term being added To list.*/ +low=lo-1 +out=d.low /* initialize the output list */ +Do j=lo To hi-1 + out=out d.j /*build a list For the output display. */ + End /*j*/ +Say 'terms ' lo ' through ' hi ' of the Van Eck sequence are: ' out + /*stick a fork in it, we're all done. */ diff --git a/Task/Variable-declaration-reset/C-sharp/variable-declaration-reset.cs b/Task/Variable-declaration-reset/C-sharp/variable-declaration-reset.cs new file mode 100644 index 0000000000..8c41a8eebb --- /dev/null +++ b/Task/Variable-declaration-reset/C-sharp/variable-declaration-reset.cs @@ -0,0 +1,37 @@ +internal class Program +{ + private static void Main(string[] args) + { + int[] s = { 1, 2, 2, 3, 4, 4, 5 }; + + // There is no output as 'prev' is created anew each time + // around the loop and set to zero. + for (int i = 0; i < s.Length; ++i) + { + int curr = s[i]; + int prev = 0; + // int prev; // triggers "error: variable prev might not have been initialized" + if (i > 0 && curr == prev) + { + Console.WriteLine(i); + } + + prev = curr; + } + + int gprev = 0; + + // Now 'gprev' is used and reassigned + // each time around the loop producing the desired output. + for (int i = 0; i < s.Length; ++i) + { + int curr = s[i]; + if (i > 0 && curr == gprev) + { + Console.WriteLine(i); + } + + gprev = curr; + } + } +} diff --git a/Task/Variables/PascalABC.NET/variables-1.pas b/Task/Variables/PascalABC.NET/variables-1.pas new file mode 100644 index 0000000000..201530a172 --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-1.pas @@ -0,0 +1 @@ +var i,j: integer; diff --git a/Task/Variables/PascalABC.NET/variables-2.pas b/Task/Variables/PascalABC.NET/variables-2.pas new file mode 100644 index 0000000000..7ce986bc9e --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-2.pas @@ -0,0 +1 @@ +var n: integer := 5; diff --git a/Task/Variables/PascalABC.NET/variables-3.pas b/Task/Variables/PascalABC.NET/variables-3.pas new file mode 100644 index 0000000000..6760f159bf --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-3.pas @@ -0,0 +1 @@ +var n := 5; diff --git a/Task/Variables/PascalABC.NET/variables-4.pas b/Task/Variables/PascalABC.NET/variables-4.pas new file mode 100644 index 0000000000..6ae29d48a4 --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-4.pas @@ -0,0 +1 @@ +var (m,x) := (5,4.3); diff --git a/Task/Variables/PascalABC.NET/variables-5.pas b/Task/Variables/PascalABC.NET/variables-5.pas new file mode 100644 index 0000000000..9ae9ea9563 --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-5.pas @@ -0,0 +1,6 @@ +var i: integer; + +procedure p; +begin + var i: integer; +end; diff --git a/Task/Variables/PascalABC.NET/variables-6.pas b/Task/Variables/PascalABC.NET/variables-6.pas new file mode 100644 index 0000000000..c9d7f126b3 --- /dev/null +++ b/Task/Variables/PascalABC.NET/variables-6.pas @@ -0,0 +1,5 @@ +var i: integer; +begin + for var i:=1 to 10 do // Error! + Print(i) +end; diff --git a/Task/Variadic-function/PascalABC.NET/variadic-function.pas b/Task/Variadic-function/PascalABC.NET/variadic-function.pas new file mode 100644 index 0000000000..8edacaec86 --- /dev/null +++ b/Task/Variadic-function/PascalABC.NET/variadic-function.pas @@ -0,0 +1,11 @@ +procedure Output(params arr: array of object); +begin + foreach var obj in arr do + Println(obj); +end; + +begin + Output(1,2.5,'z','PascalABC.NET'); + var a: array of object := (1,2.5,'z','PascalABC.NET'); + Output(a); +end. diff --git a/Task/Vector-products/PascalABC.NET/vector-products.pas b/Task/Vector-products/PascalABC.NET/vector-products.pas new file mode 100644 index 0000000000..8bd220f682 --- /dev/null +++ b/Task/Vector-products/PascalABC.NET/vector-products.pas @@ -0,0 +1,26 @@ +uses System.Numerics; + +function DotProduct(v1,v2: Vector3): real + := v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; + +function CrossProduct(v1,v2: Vector3): Vector3 + := new Vector3(v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x); + +function ScalarTripleProduct(a,b,c: Vector3): real + := DotProduct(a, CrossProduct(b, c)); + +function VectorTripleProduct(a,b,c: Vector3): Vector3 + := CrossProduct(a, CrossProduct(b, c)); + + +begin + var a := new Vector3(3,4,5); + var b := new Vector3(4,3,5); + var c := new Vector3(-5,-12,-13); + Writeln(DotProduct(a, b)); + Writeln(CrossProduct(a, b)); + Writeln(ScalarTripleProduct(a, b, c)); + Writeln(VectorTripleProduct(a, b, c)); +end. diff --git a/Task/Vector-products/REXX/vector-products.rexx b/Task/Vector-products/REXX/vector-products.rexx index 4f409c7129..facf79ebfb 100644 --- a/Task/Vector-products/REXX/vector-products.rexx +++ b/Task/Vector-products/REXX/vector-products.rexx @@ -1,19 +1,26 @@ -/*REXX program computes the products: dot, cross, scalar triple, and vector triple.*/ - a= 3 4 5 - b= 4 3 5 /*(positive numbers don't need quotes.)*/ - c= "-5 -12 -13" -call tellV 'vector A =', a /*show the A vector, aligned numbers.*/ -call tellV 'vector B =', b /* " " B " " " */ -call tellV 'vector C =', c /* " " C " " " */ - say -call tellV ' dot product [A∙B] =', dot(a, b) -call tellV 'cross product [AxB] =', cross(a, b) -call tellV 'scalar triple product [A∙(BxC)] =', dot(a, cross(b, c) ) -call tellV 'vector triple product [Ax(BxC)] =', cross(a, cross(b, c) ) -exit 0 /*stick a fork in it, we're all done. */ -/*──────────────────────────────────────────────────────────────────────────────────────*/ -cross: procedure; arg $1 $2 $3,@1 @2 @3; return $2*@3 -$3*@2 $3*@1 -$1*@3 $1*@2 -$2*@1 -dot: procedure; arg $1 $2 $3,@1 @2 @3; return $1*@1 + $2*@2 + $3*@3 -/*──────────────────────────────────────────────────────────────────────────────────────*/ -tellV: procedure; parse arg name,x y z; w=max(4,length(x),length(y),length(z)) /*max W*/ - say right(name,40) right(x,w) right(y,w) right(z,w); /*show vector.*/ return +/*REXX program computes the products: dot, cross, scalar triple, and vector triple.*/ +a= 3 4 5 +b= 4 3 5 /*(positive numbers don't need quotes.)*/ +c= '-5 -12 -13' +Call tellV 'vector A =', a /*show the A vector, aligned numbers.*/ +Call tellV "vector B =", b /* " " B " " " */ +Call tellV "vector C =", c /* " " C " " " */ +Say '' +Call tellV ' dot product [A·B] =', dot(a,b) +Call tellV 'cross product [AxB] =', cross(a,b) +Call tellV 'scalar triple product [A·(BxC)] =', dot(a,cross(b,c)) +Call tellV 'vector triple product [Ax(BxC)] =', cross(a,cross(b,c)) +Exit /*stick a fork in it, we're all done. */ +/*---------------------------------------------------------------------------*/ +cross: Procedure + Arg a b c, u v w + Return b*w-c*v c*u-a*w a*v-b*u +dot: Procedure + Arg a b c, u v w + Return a*u + b*v + c*w +/*---------------------------------------------------------------------------*/ +tellV: Procedure + Parse Arg name,x y z + w=max(4,length(x),length(y),length(z)) /*max width */ + Say right(name,33) right(x,w) right(y,w) right(z,w) /*show vector. */ + Return diff --git a/Task/Vector/Chipmunk-Basic/vector.basic b/Task/Vector/Chipmunk-Basic/vector.basic new file mode 100644 index 0000000000..bd147fff68 --- /dev/null +++ b/Task/Vector/Chipmunk-Basic/vector.basic @@ -0,0 +1,37 @@ +100 cls +110 dim vect1(2) +120 vect1(1) = 5 : vect1(2) = 7 +130 dim vect2(2) +140 vect2(1) = 2 : vect2(2) = 3 +150 dim vect3(ubound(vect1)) +160 for n = 1 to ubound(vect1) +170 vect3(n) = vect1(n)+vect2(n) +180 next n +190 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] + ["+str$(vect2(1))+", "+str$(vect2(2))+"] = "; +200 showarray(vect3) +210 for n = 1 to ubound(vect1) +220 vect3(n) = vect1(n)-vect2(n) +230 next n +240 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] - ["+str$(vect2(1))+", "+str$(vect2(2))+"] = "; +250 showarray(vect3) +260 for n = 1 to ubound(vect1) +270 vect3(n) = vect1(n)*11 +280 next n +290 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] * 11 = "; +300 showarray(vect3) +310 for n = 1 to ubound(vect1) +320 vect3(n) = vect1(n)/2 +330 next n +340 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] / 2 = "; +350 showarray(vect3) +360 end +370 sub showarray(vect3) +380 print "["; +390 svect$ = "" +400 for n = 1 to ubound(vect3) +410 svect$ = svect$+str$(vect3(n))+", " +420 next n +430 svect$ = left$(svect$,len(svect$)-2) +440 print svect$; +450 print "]" +460 end sub diff --git a/Task/Vector/GW-BASIC/vector.basic b/Task/Vector/GW-BASIC/vector.basic new file mode 100644 index 0000000000..01719a40df --- /dev/null +++ b/Task/Vector/GW-BASIC/vector.basic @@ -0,0 +1,37 @@ +100 CLS : rem 100 HOME for Applesoft BASIC +110 DIM v1(2) +120 v1(1) = 5 : v1(2) = 7 +130 DIM v2(2) +140 v2(1) = 2 : v2(2) = 3 +150 DIM v3(2) +160 FOR n = 1 TO 2 +170 v3(n) = v1(n)+v2(n) +180 NEXT n +190 PRINT "[";v1(1);", ";v1(2);"] + [";v2(1);", ";v2(2);"] = "; +200 GOSUB 370 : rem showarray(vect3) +210 FOR n = 1 TO 2 +220 v3(n) = v1(n)-v2(n) +230 NEXT n +240 PRINT "[";v1(1);", ";v1(2);"] - [";v2(1);", ";v2(2);"] = "; +250 GOSUB 370 : rem showarray(vect3) +260 FOR n = 1 TO 2 +270 v3(n) = v1(n)*11 +280 NEXT n +290 PRINT "[";v1(1);", ";v1(2);"] * ";11;" = "; +300 GOSUB 370 : rem showarray(vect3) +310 FOR n = 1 TO 2 +320 v3(n) = v1(n)/2 +330 NEXT n +340 PRINT "[";v1(1);", ";v1(2);"] / ";2;" = "; +350 GOSUB 370 : rem showarray(vect3) +360 END +370 rem SUB showarray(vect3) +380 PRINT "["; +390 svt$ = "" +400 FOR n = 1 TO 2 +410 svt$ = svt$+STR$(v3(n))+", " +420 NEXT n +430 svt$ = LEFT$(svt$,LEN(svt$)-2) +440 PRINT svt$; +450 PRINT "]" +460 RETURN diff --git a/Task/Vector/PascalABC.NET/vector.pas b/Task/Vector/PascalABC.NET/vector.pas new file mode 100644 index 0000000000..7eac61123f --- /dev/null +++ b/Task/Vector/PascalABC.NET/vector.pas @@ -0,0 +1,31 @@ +type + Vector = class + x,y: real; + public + constructor (xx,yy: real) := (x,y) := (xx,yy); + function ToString: string; override := $'({x},{y})'; + end; + +function operator+(v1,v2: Vector): Vector; extensionmethod + := new Vector(v1.x + v2.x, v1.y + v2.y); + +function operator-(v1,v2: Vector): Vector; extensionmethod + := new Vector(v1.x - v2.x, v1.y - v2.y); + +function operator*(v: Vector; n: real): Vector; extensionmethod + := new Vector(v.x * n, v.y * n); + +function operator*(n: real; v: Vector): Vector; extensionmethod + := v * n; + +function operator/(v: Vector; n: real): Vector; extensionmethod + := new Vector(v.x / n, v.y / n); + +begin + var v1 := new Vector(1,2); + var v2 := new Vector(3,4); + Println(v1 + v2); + Println(v1 - v2); + Println(v1 * 2.5, 2.5 * v1); + Println(v1 / 2); +end. diff --git a/Task/Vector/QBasic/vector.basic b/Task/Vector/QBasic/vector.basic new file mode 100644 index 0000000000..e74c698251 --- /dev/null +++ b/Task/Vector/QBasic/vector.basic @@ -0,0 +1,39 @@ +DECLARE SUB showarray (vect3!()) +CLS +DIM vect1(2) +vect1(1) = 5: vect1(2) = 7 +DIM vect2(2) +vect2(1) = 2: vect2(2) = 3 +DIM vect3(UBOUND(vect1)) +FOR n = 1 TO UBOUND(vect1) + vect3(n) = vect1(n) + vect2(n) +NEXT n +PRINT "["; STR$(vect1(1)); ","; STR$(vect1(2)); " ] + ["; STR$(vect2(1)) + ","; STR$(vect2(2)); " ] = "; +CALL showarray(vect3()) +FOR n = 1 TO UBOUND(vect1) + vect3(n) = vect1(n) - vect2(n) +NEXT n +PRINT "["; STR$(vect1(1)); ","; STR$(vect1(2)); " ] - ["; STR$(vect2(1)) + ","; STR$(vect2(2)); " ] = "; +CALL showarray(vect3()) +FOR n = 1 TO UBOUND(vect1) + vect3(n) = vect1(n) * 11 +NEXT n +PRINT "["; STR$(vect1(1)); ","; STR$(vect1(2)); " ] * 11 = "; +CALL showarray(vect3()) +FOR n = 1 TO UBOUND(vect1) + vect3(n) = vect1(n) / 2 +NEXT n +PRINT "["; STR$(vect1(1)); ","; STR$(vect1(2)); " ] / 2 = "; +CALL showarray(vect3()) +END + +SUB showarray (vect3()) + PRINT "["; + svect$ = "" + FOR n = 1 TO UBOUND(vect3) + svect$ = svect$ + STR$(vect3(n)) + "," + NEXT n + svect$ = LEFT$(svect$, LEN(svect$) - 1) + PRINT svect$; + PRINT " ]" +END SUB diff --git a/Task/Vector/True-BASIC/vector.basic b/Task/Vector/True-BASIC/vector.basic new file mode 100644 index 0000000000..826ab3e64a --- /dev/null +++ b/Task/Vector/True-BASIC/vector.basic @@ -0,0 +1,40 @@ +SUB showarray (vect3()) + PRINT "["; + LET svect$ = "" + FOR n = 1 TO UBOUND(vect3) + LET svect$ = svect$ & STR$(vect3(n)) & ", " + NEXT n + LET svect$ = (svect$)[1:LEN(svect$)-2] + PRINT svect$; + PRINT "]" +END SUB + +DIM vect1(2) +LET vect1(1) = 5 +LET vect1(2) = 7 +DIM vect2(2) +LET vect2(1) = 2 +LET vect2(2) = 3 +DIM vect3(0) +MAT REDIM vect3(UBOUND(vect1)) +FOR n = 1 TO UBOUND(vect1) + LET vect3(n) = vect1(n)+vect2(n) +NEXT n +PRINT "["; STR$(vect1(1)); ", "; STR$(vect1(2)); "] + ["; STR$(vect2(1)) & ", "; STR$(vect2(2)); "] = "; +CALL showarray (vect3()) +FOR n = 1 TO UBOUND(vect1) + LET vect3(n) = vect1(n)-vect2(n) +NEXT n +PRINT "["; STR$(vect1(1)); ", "; STR$(vect1(2)); "] - ["; STR$(vect2(1)) & ", "; STR$(vect2(2)); "] = "; +CALL showarray (vect3()) +FOR n = 1 TO UBOUND(vect1) + LET vect3(n) = vect1(n)*11 +NEXT n +PRINT "["; STR$(vect1(1)); ", "; STR$(vect1(2)); "] * 11 = "; +CALL showarray (vect3()) +FOR n = 1 TO UBOUND(vect1) + LET vect3(n) = vect1(n)/2 +NEXT n +PRINT "["; STR$(vect1(1)); ", "; STR$(vect1(2)); "] / 2 = "; +CALL showarray (vect3()) +END diff --git a/Task/Verify-distribution-uniformity-Naive/EasyLang/verify-distribution-uniformity-naive.easy b/Task/Verify-distribution-uniformity-Naive/EasyLang/verify-distribution-uniformity-naive.easy new file mode 100644 index 0000000000..e3fa0a53fb --- /dev/null +++ b/Task/Verify-distribution-uniformity-Naive/EasyLang/verify-distribution-uniformity-naive.easy @@ -0,0 +1,47 @@ +func dice5 . + return randint 5 +. +func dice25 . + return (dice5 - 1) * 5 + dice5 +. +func dice7a . + return dice25 mod1 7 +. +func dice7b . + repeat + h = dice25 + until h <= 21 + . + return h mod1 7 +. +numfmt 3 0 +# +proc checkdist dicefunc n delta . . + len dist[] 7 + for i to n + # no function pointers + if dicefunc = 1 + h = dice7a + else + h = dice7b + . + dist[h] += 1 + . + for i to len dist[] + h = dist[i] / n * 7 + if abs (h - 1) > delta + bad = 1 + . + dist[i] = 0 + print h + . + if bad = 1 + print "-> not uniform" + else + print "-> uniform" + . + print "" +. +# +checkdist 1 1000000 0.01 +checkdist 2 1000000 0.01 diff --git a/Task/Wagstaff-primes/Sidef/wagstaff-primes.sidef b/Task/Wagstaff-primes/Sidef/wagstaff-primes.sidef new file mode 100644 index 0000000000..a9d7e1b63a --- /dev/null +++ b/Task/Wagstaff-primes/Sidef/wagstaff-primes.sidef @@ -0,0 +1,20 @@ +var iter = Enumerator({|callback| + var p = 2 + loop { + var t = ((2**p + 1)/3) + callback([p, t]) if t.is_prime + p.next_prime! + } +}) + +var n = 1 +say "Index Exponent Prime" +say "-"*31 + +iter.each {|k| + var (e, p) = k... + p = "(#{p.len} digits)" if (n > 10) + say "#{'%5s'%n} #{'%8s'%e} #{'%16s'%p}" + break if (n == 24) + ++n +} diff --git a/Task/Walk-a-directory-Non-recursively/PascalABC.NET/walk-a-directory-non-recursively.pas b/Task/Walk-a-directory-Non-recursively/PascalABC.NET/walk-a-directory-non-recursively.pas new file mode 100644 index 0000000000..84e2e8c6f4 --- /dev/null +++ b/Task/Walk-a-directory-Non-recursively/PascalABC.NET/walk-a-directory-non-recursively.pas @@ -0,0 +1,4 @@ +begin + var path := 'C:\PABCWork.NET'; + EnumerateFiles(path,'*.pas').PrintLines; +end. diff --git a/Task/Walk-a-directory-Recursively/PascalABC.NET/walk-a-directory-recursively.pas b/Task/Walk-a-directory-Recursively/PascalABC.NET/walk-a-directory-recursively.pas new file mode 100644 index 0000000000..5f9a45edfc --- /dev/null +++ b/Task/Walk-a-directory-Recursively/PascalABC.NET/walk-a-directory-recursively.pas @@ -0,0 +1,4 @@ +begin + var path := 'C:\PABCWork.NET'; + EnumerateAllFiles(path,'*.pas').PrintLines; +end. diff --git a/Task/War-card-game/00-TASK.txt b/Task/War-card-game/00-TASK.txt index b4b80f82e7..a9541f8693 100644 --- a/Task/War-card-game/00-TASK.txt +++ b/Task/War-card-game/00-TASK.txt @@ -15,4 +15,3 @@ Related tasks: * [[Poker hand_analyser]] * [[Go Fish]] - diff --git a/Task/War-card-game/Ada/war-card-game.ada b/Task/War-card-game/Ada/war-card-game.ada new file mode 100644 index 0000000000..ad8c89f727 --- /dev/null +++ b/Task/War-card-game/Ada/war-card-game.ada @@ -0,0 +1,146 @@ +-- Play the card game War +-- J. Carter 2024 Jul +-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC) + +with Ada.Text_IO; +with PragmARC.Ansi_Tty_Control; +with PragmARC.Cards.Decks.US; +with PragmARC.Cards.US; + +procedure War is + package Ansi renames PragmARC.Ansi_Tty_Control; + package Cards renames PragmARC.Cards.US; + package Decks renames PragmARC.Cards.Decks.US; + + use type Cards.Rank_Id; + + procedure Display (Hand1 : in Decks.Deck_52; Hand2 : in Decks.Deck_52); + -- Display the state of the game represented by the 2 hands + + function ">" (Left : in Cards.Card_Info; Right : in Cards.Card_Info) return Boolean is + (if Left.Rank = Cards.Ace then + Right.Rank /= Cards.Ace + elsif Right.Rank = Cards.Ace then + False + else + Left.Rank > Right.Rank); + + procedure Display (Hand1 : in Decks.Deck_52; Hand2 : in Decks.Deck_52) is + function Image (Card : in Cards.Card_Info) return Character is + (Cards.Image (Card) (1) ); + + procedure Display (Hand : in Decks.Deck_52); + -- Puts the ranks of the cards in Hand in a row + + procedure Display (Hand : in Decks.Deck_52) is + -- Empty + begin -- Display + All_Cards : for I in 1 .. Hand.Size loop + Ada.Text_IO.Put (Item => Image (Hand.Value (I) ) ); + end loop All_Cards; + end Display; + begin -- Display + Ada.Text_IO.Put (Item => Ansi.Clear_Screen); + Display (Hand => Hand1); + Ada.Text_IO.Put (Item => Ansi.Position (2, 1) ); + Display (Hand => Hand2); + Ada.Text_IO.Put (Item => Ansi.Position (3, 1) ); + end Display; + + Hand1 : Decks.Deck_52; -- Player 1 + Hand2 : Decks.Deck_52; -- Player 2 + Card1 : Cards.Card_Info; -- Player 1 + Card2 : Cards.Card_Info; -- Player 2 + War1 : Decks.Deck_52; -- Player 1 + War2 : Decks.Deck_52; -- Player 2 +begin -- War + Decks.Standard_Deck (Item => Hand1); + Hand1.Shuffle; + + Deal : for I in 1 .. Hand1.Size / 2 loop -- Each player gets half the deck + Hand1.Deal (To => Card1); + Hand2.Add (Item => Card1); + end loop Deal; + + Play : loop + Display (Hand1 => Hand1, Hand2 => Hand2); + + exit Play when Hand1.Size = 0 or Hand2.Size = 0; + + delay 0.5; + + Hand1.Deal (To => Card1); + Hand2.Deal (To => Card2); + + if Card1.Rank /= Card2.Rank then + if Card1 > Card2 then + Hand1.Add (Item => Card1); + Hand1.Add (Item => Card2); + else + Hand2.Add (Item => Card2); + Hand2.Add (Item => Card1); + end if; + else -- War! + War1.Add (Item => Card1); + War2.Add (Item => Card2); + + All_Tries : loop + Ada.Text_IO.Put (Item => "W^^"); + + delay 0.5; + + Deal1 : for I in 1 .. 2 loop + exit Deal1 when Hand1.Is_Empty; + + Hand1.Deal (To => Card1); + War1.Add (Item => Card1); + end loop Deal1; + + Deal2 : for I in 1 .. 2 loop + exit Deal2 when Hand2.Is_Empty; + + Hand2.Deal (To => Card2); + War2.Add (Item => Card2); + end loop Deal2; + + if War1.Value (War1.Size) > War2.Value (War2.Size) then -- 1 wins + Deal11 : loop + exit Deal11 when War1.Is_Empty; + + War1.Deal (To => Card1); + Hand1.Add (Item => Card1); + end loop Deal11; + + Deal12 : loop + exit Deal12 when War2.Is_Empty; + + War2.Deal (To => Card1); + Hand1.Add (Item => Card1); + end loop Deal12; + + exit All_Tries; + elsif War2.Value (War2.Size) > War1.Value (War1.Size) then -- 2 Wins + Deal22 : loop + exit Deal22 when War2.Is_Empty; + + War2.Deal (To => Card2); + Hand2.Add (Item => Card2); + end loop Deal22; + + Deal21 : loop + exit Deal21 when War1.Is_Empty; + + War1.Deal (To => Card2); + Hand2.Add (Item => Card2); + end loop Deal21; + + exit All_Tries; + else + null; -- The war continues + end if; + end loop All_Tries; + end if; + end loop Play; + + Ada.Text_IO.Put (Item => "Player " & (if Hand1.Size = 0 then '2' else '1') & " wins"); +end War; diff --git a/Task/War-card-game/Jq/war-card-game.jq b/Task/War-card-game/Jq/war-card-game.jq new file mode 100644 index 0000000000..f07aeea78e --- /dev/null +++ b/Task/War-card-game/Jq/war-card-game.jq @@ -0,0 +1,113 @@ +### Generic functions + +# Set .popped to the first item of the specified array, and remove it therefrom +@ Usage example: {a:[1,2]} | pop(.a; .x) +def pop(array; popped): + popped = array[0] + | array |= .[1:]; + +# like while/2 but emit the final term rather than the first one +def whilst(cond; update): + def _whilst: + if cond then update | (., _whilst) else empty end; + _whilst; + +# Output: a prn in range(0;.) +def prn: + if . == 1 then 0 + else . as $n + | (($n-1)|tostring|length) as $w + | [limit($w; inputs)] | join("") | tonumber + | if . < $n then . else ($n | prn) end + end; + +def knuthShuffle: + length as $n + | if $n <= 1 then . + else {i: $n, a: .} + | until(.i == 0; + .i += -1 + | (.i + 1 | prn) as $j + | .a[.i] as $t + | .a[.i] = .a[$j] + | .a[$j] = $t) + | .a + end; + + +### War Card Game +def suits: ["♣", "♦", "♥", "♠"]; +def faces: ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A" ]; + +def cards: [range( 0; 52) | "\(faces[.%13])\(suits[(./13)|floor])"]; +def ranks: [range( 0; 52) | . % 13]; + +def war: + cards as $cards + | ranks as $ranks + | ([range(0; 52)] | knuthShuffle) as $deck + | reduce range(0; 26) as $i ({}; + .hand1 |= [$deck[2*$i]] + . + | .hand2 |= [$deck[2*$i+1]] + .) + | .numPlayed=0 + | whilst( .numPlayed == 0 and + (.hand1|length) > 0 and (.hand2|length) > 0; + + pop(.hand1; .card1) + | pop(.hand2; .card2) + | .played1 = [.card1] + | .played2 = [.card2] + | .numPlayed = 2 + | whilst(.numPlayed > 0 ; + .emit = "\($cards[.card1])\t\($cards[.card2])\t" + | if $ranks[.card1] > $ranks[.card2] + then .hand1 += .played1 + .played2 + | .emit += "Player 1 takes the \(.numPlayed) cards. Now has \(.hand1|length)." + | .numPlayed = 0 + + elif $ranks[.card1] < $ranks[.card2] + then .hand2 += .played2 + .played1 + | .emit += "Player 2 takes the \(.numPlayed) cards. Now has \(.hand2|length)." + | .numPlayed = 0 + + else .emit += "War!\n" + | if (.hand1|length) < 2 + then .emit += "Player 1 has insufficient cards left." + | .hand2 = .hand2 + .played2 + .played1 + .hand1 + | .hand1 = [] + | .numPlayed = 0 + + elif .hand2|length < 2 + then .emit += "Player 2 has insufficient cards left." + | .hand1 = .hand1 + .played1 + .played2 + .hand2 + | .hand2 = [] + | .numPlayed = 0 + + else + pop(.hand1; .card1) # face down card + | .played1 += [.card1] + + | pop(.hand1; .card1) # face up card + | .played1 += [.card1] + + | pop( .hand2; .card2) # face down card 2 + | .played2 += [.card2] + + | pop(.hand2; .card2) # face up card 2 + | .played2 += [.card2] + + | .numPlayed += 4 + | .emit += "? \t?\tFace down cards." + end + end + ) + ) + | .emit, + (if .hand1|length == 52 + then "Player 1 wins the game!" + elif .hand2|length == 52 + then "Player 2 wins the game!" + else empty + end) ; + +war diff --git a/Task/Water-collected-between-towers/PHP/water-collected-between-towers.php b/Task/Water-collected-between-towers/PHP/water-collected-between-towers.php new file mode 100644 index 0000000000..5e62a76be4 --- /dev/null +++ b/Task/Water-collected-between-towers/PHP/water-collected-between-towers.php @@ -0,0 +1,60 @@ + $build[$i][$j]) { + $l = max($l, $build[$i][$k]); + } + } + for ($k = $j + 1; $k < count($build[$i]); $k++) { + if ($build[$i][$k] > $build[$i][$j]) { + $r = max($r, $build[$i][$k]); + } + } + if ($l > 0 && $r > 0) { + $w = min($l, $r) - $build[$i][$j]; + $level[$j] = $w; + } + } + +// Report + echo '
';
+	$max = max($build[$i]);
+	$u = 0;
+	for ($j = $max; $j > 0; $j--) {
+		for ($k = 0; $k < count($build[$i]); $k++) {
+			if ($j - 1 < $build[$i][$k]) {
+				echo $tower;
+			}
+			elseif (!empty($level[$k]) && $level[$k] + $build[$i][$k] >= $j) {
+				echo $water;
+				$u++;
+			}
+			elseif ($build[$i][$k] < $j) {
+				echo $empty;
+			}
+		}
+		echo '
'; + } + echo '
Block ' . $i + 1 . ' will collect ' . $u . ' units of water
'; + echo '
'; +} +?> diff --git a/Task/Water-collected-between-towers/Uiua/water-collected-between-towers.uiua b/Task/Water-collected-between-towers/Uiua/water-collected-between-towers.uiua new file mode 100644 index 0000000000..ecaabaff75 --- /dev/null +++ b/Task/Water-collected-between-towers/Uiua/water-collected-between-towers.uiua @@ -0,0 +1,10 @@ +Area ← /+-:↧⍜⇌\↥⟜\↥. + +{[1 5 3 7 2] + [5 3 7 2 6 4 5 9 1 2] + [2 6 3 5 2 8 1 4 2 2 5 3 5 7 4 1] + [5 5 5 5] + [5 6 7 8] + [8 7 7 6] + [6 7 10 7 6]} +∵◇Area diff --git a/Task/Weird-numbers/Ada/weird-numbers-1.ada b/Task/Weird-numbers/Ada/weird-numbers-1.ada new file mode 100644 index 0000000000..906371dcc6 --- /dev/null +++ b/Task/Weird-numbers/Ada/weird-numbers-1.ada @@ -0,0 +1,109 @@ +pragma Ada_2022; + +with Ada.Text_IO; +with Ada.Containers.Vectors; +with Ada.Containers.Ordered_Sets; + +procedure Weird_Numbers is + package IO renames Ada.Text_IO; + -- allows us to type "IO.Put_Line" instead of "Ada.Text_IO.Put_Line" + + package IntVecs is new Ada.Containers.Vectors + (Index_Type => Positive, Element_Type => Natural); + subtype IntVec is IntVecs.Vector; +-- use all type IntVec; + + Factor_Cache : IntVec; + -- used to keep track of the factors on each iteration + + package Intsets is new Ada.Containers.Ordered_Sets + (Element_Type => Positive); + subtype Intset is Intsets.Set; + Semiperfect_Cache : Intset; + Not_Abundant_Cache : Intset; + + function Proper_Divisors (Value : Positive) return IntVec is + Cofactors : IntVec; + begin + Factor_Cache.Clear; + begin + Factor_Cache.Append (1); + for Factor in 2 .. Value / 2 loop + if Value rem Factor = 0 then + Factor_Cache.Append (Factor); + end if; + end loop; + return Factor_Cache; + end; + end Proper_Divisors; + + function Is_Abundant (Value : Positive) return Boolean is + begin + if Not_Abundant_Cache.Contains (Value) + or else Semiperfect_Cache.Contains (Value) + then + return False; + end if; + if Proper_Divisors (Value)'Reduce ("+", 0) > Value then + return True; + end if; + Not_Abundant_Cache.Insert (Value); + return False; + end Is_Abundant; + + function Subset_Of (Factors : IntVec; Ith : Positive) return IntVec is + -- returns the Ith subset of Factors + -- if Factors has N elements, then there are 2**N possibilities + -- this maps Ith to one of these possibilities using its binary representation + Result : IntVec; + Index : Natural := 1; + Ith_Remainder : Natural := Ith; + begin + while Ith_Remainder /= 0 loop + if Ith_Remainder rem 2 = 1 then + Result.Append (Factors (Index)); + Ith_Remainder := @ - 1; + end if; + Ith_Remainder := @ / 2; + Index := @ + 1; + end loop; + return Result; + end Subset_Of; + + function Is_Semiperfect (Value : Positive) return Boolean is + Factors : constant IntVec := Factor_Cache; + Subset : IntVec; + Sum : Natural; + begin + if (for some Previous of Semiperfect_Cache => Value rem Previous = 0) + then + return True; + end if; + for Ith in reverse 1 .. (2**Positive (Factors.Length) - 1) loop + Subset := Subset_Of (Factors, Positive (Ith)); + Sum := Subset'Reduce ("+", 0); + if Sum = Value then + Semiperfect_Cache.Insert (Value); + return True; + end if; + end loop; + return False; + end Is_Semiperfect; + + function Is_Weird (Value : Positive) return Boolean is + (Is_Abundant (Value) and then not Is_Semiperfect (Value)); + + Current : Positive := 2; + Number_Found : Natural := 0; + +begin + IO.Put ("The first 25 weird numbers are"); + while Number_Found < 25 loop + if Is_Weird (Current * 2) then + IO.Put (Integer'Image (Current * 2)); + Number_Found := @ + 1; + end if; + Current := @ + 1; + end loop; + IO.New_Line; +end Weird_Numbers; diff --git a/Task/Weird-numbers/Ada/weird-numbers-2.ada b/Task/Weird-numbers/Ada/weird-numbers-2.ada new file mode 100644 index 0000000000..f1a649cfab --- /dev/null +++ b/Task/Weird-numbers/Ada/weird-numbers-2.ada @@ -0,0 +1,105 @@ +pragma Ada_2022; + +with Ada.Text_IO; +with Ada.Containers.Vectors; +with Ada.Containers.Ordered_Sets; + +procedure Weird_Numbers is + package IO renames Ada.Text_IO; + + package IntVecs is new Ada.Containers.Vectors + (Index_Type => Positive, Element_Type => Positive); + subtype IntVec is IntVecs.Vector; + use all type IntVec; + + Factor_Cache : IntVec; + + package Intsets is new Ada.Containers.Ordered_Sets + (Element_Type => Positive); + subtype Intset is Intsets.Set; + Semiperfect_Cache : Intset; + Not_Abundant_Cache : Intset; + + function Proper_Divisors (Value : Positive) return IntVec is + Cofactors : IntVec; + begin + Factor_Cache.Clear; + begin + Factor_Cache.Append (1); + for Factor in 2 .. Value / 2 loop + if Factor * Factor > Value then + exit; + end if; + if Value rem Factor = 0 then + Factor_Cache.Append (Factor); + if Factor * Factor /= Value then + Cofactors.Append (Value / Factor); + end if; + end if; + end loop; + Factor_Cache.Prepend_Vector (Cofactors); + -- this ordering is REALLY curious + -- for instance, the factors of 12 are ordered as 6, 4, 1, 2, 3 + -- AND THIS MATTERS + -- both strictly ascending and strictly descending orders are much slower + return Factor_Cache; + end; + end Proper_Divisors; + + function Is_Abundant (Value : Positive) return Boolean is + begin + if Not_Abundant_Cache.Contains (Value) + or else Semiperfect_Cache.Contains (Value) + then + return False; + end if; + if Proper_Divisors (Value)'Reduce ("+", 0) > Value then + return True; + end if; + Not_Abundant_Cache.Insert (Value); + return False; + end Is_Abundant; + + function Alternate_Semiperfect (Value : Positive) return Boolean is + function Reroute + (Value : Positive; First : Positive) return Boolean + is + Head : Positive; + begin + if Factor_Cache.Last_Index >= First then + Head := Factor_Cache (First); + if Value < Head then + return Reroute (Value, First + 1); + else + return + Value = Head + or else Reroute (Value - Head, First + 1) + or else Reroute (Value, First + 1); + end if; + else + return False; + end if; + end Reroute; + begin + return + Reroute + (Value, Factor_Cache.First_Index); + end Alternate_Semiperfect; + + function Is_Weird (Value : Positive) return Boolean is + (Is_Abundant (Value) and then not Alternate_Semiperfect (Value)); + + Current : Positive := 2; + Number_Found : Natural := 0; + +begin + IO.Put ("The first 25 weird numbers are"); + while Number_Found < 25 loop + if Is_Weird (Current * 2) then + IO.Put (Integer'Image (Current * 2)); + Number_Found := @ + 1; + end if; + Current := @ + 1; + end loop; + IO.New_Line; +end Weird_Numbers; diff --git a/Task/Weird-numbers/Python/weird-numbers.py b/Task/Weird-numbers/Python/weird-numbers-1.py similarity index 100% rename from Task/Weird-numbers/Python/weird-numbers.py rename to Task/Weird-numbers/Python/weird-numbers-1.py diff --git a/Task/Weird-numbers/Python/weird-numbers-2.py b/Task/Weird-numbers/Python/weird-numbers-2.py new file mode 100644 index 0000000000..8457ac3814 --- /dev/null +++ b/Task/Weird-numbers/Python/weird-numbers-2.py @@ -0,0 +1,51 @@ +# anySum :: Int -> [Int] -> [Int] + +from time import time +start = time() + +primitivesp_nos = set(); primes = [] + +def main(): + x = 2; weird_nos = [] + n = 50 + while n > 0: + if isweird(x) == 1: weird_nos.append(x); n = n - 1 + x = x + 1 + print("First", len(weird_nos), "weird nos:\n", weird_nos) + +def isweird(n): + global primes; global primitivesp_nos; pr_fctrs = []; a = n + for i in primes: + while a % i == 0: pr_fctrs.append(i); a = a//i + if i * i > a: break + if a > 1: pr_fctrs.append(a) + if a == n: primes.append(n); return 0 + sum_fctrs = 1; divisors = set(pr_fctrs) + for i in divisors: sum_fctrs = sum_fctrs*(i**(pr_fctrs.count(i)+1)-1)//(i-1) + difference = sum_fctrs - 2 * n + if difference <= 0: + if difference == 0: primitivesp_nos.add(n) + return 0 + # Next 10 lines from Jerome Richard: stackoverflow.com/questions/6800193 + divisors = [1]; last_prime = 0; fctr = 0; slice_len = 0 + for prime in pr_fctrs: + if last_prime != prime: slice_len = len(divisors); fctr = prime + else: fctr *= prime + for i in range(slice_len): + d = divisors[i] * fctr + if d not in primitivesp_nos: divisors.append(d) + else: return 0 + last_prime = prime + x = 1; divisors = set(i for i in divisors if i <= difference) + ns = n - (difference + n - sum(divisors)) + if ns < 0: return 1 + for d in divisors: x |= x << d + if x >> ns & 1: primitivesp_nos.add(n); return 0 + else: return 1 + +main() + +end = time() +print("Execution time: ", round(end - start, 2), "s") + +-- -> [100,96] diff --git a/Task/Weird-numbers/Uxntal/weird-numbers.uxnatl b/Task/Weird-numbers/Uxntal/weird-numbers.uxnatl new file mode 100644 index 0000000000..9b1ed1016a --- /dev/null +++ b/Task/Weird-numbers/Uxntal/weird-numbers.uxnatl @@ -0,0 +1,85 @@ +( uxncli weird.rom ) + +|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1 +%MOD2 { DIV2k MUL2 SUB2 } +|0000 +@c $2 +@n $2 +@i $1 + +|0100 +( init ) +;str ptext #0a .Console/write DEO + +( main ) +#000c +&sieve + #0000 .c STZ2 + DUP2 DUP2 .n STZ2 divisors + abundance ?{ semiperfection } + clear + INC2 .i LDZ #19 LTH ?&sieve + POP2 +BRK + +@pdec ( short* -- ) + #2710 [ LIT2r 00fb ] + &while ( -- ) + DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{ + DUP [ LIT "0 ] ADD #19 DEO + INCr } + POP2 #000a DIV2 SWPr INCr STHkr ?&while + POP2r POP2 POP2 JMP2r + +@ptext ( str* -- ) + &while + LDAk .Console/write DEO + INC2 LDAk ?&while + POP2 + JMP2r + +@divisors ( short* -- ) + #0000 + &loop + OVR2 OVR2 MOD2 #0000 GTH2 ?{ DUP2 ;divs .c LDZ2 STH2k ADD2 STA2 STH2r INC2 INC2 .c STZ2 } + INC2 GTH2k ?&loop POP2 POP2 + JMP2r + +@abundance ( -- flag ) + #0000 STH2 + ;divs + &while + LDA2k STH2 ADD2r + #0002 ADD2 + LDA2k NIP ?&while + POP2 + STH2r .n LDZ2 GTH2 ?{ #01 JMP2r } #00 ( returns 1 when not abundant to skip semiperfection check in main ) + JMP2r + +@semiperfection ( -- ) + #0001 ;divs .c LDZ2 ADD2 STA2 + #0000 + &for + .n LDZ2 + &loop + OVR2 OVR2 SWP2 #0002 MUL2 ;divs ADD2 LDA2 SUB2 #0002 MUL2 + ;divs .c LDZ2 ADD2 ADD2 LDA2 + #0000 EQU2 ?{ #0001 OVR2 #0002 MUL2 ;divs .c LDZ2 ADD2 ADD2 STA2 } + #0001 SUB2 + OVR2 #0002 MUL2 ;divs ADD2 LDA2 GTH2k STH EQU2k STHr ORA NIP NIP ?&loop POP2 + + INC2 DUP2 .c LDZ2 #0002 DIV2 LTH2 ?&for POP2 + ;divs .c LDZ2 ADD2 .n LDZ2 #0002 MUL2 ADD2 LDA2 NIP ?{ .n LDZ2 pdec #20 #18 DEO .i LDZk INC SWP STZ JMP2r } + JMP2r + +@clear ( -- ) + ;divs + .n LDZ2 .c LDZ2 ADD2 + &while + SWP2 #0000 SWP2 STA2k NIP2 + INC2 INC2 + SWP2 #0001 SUB2 #0000 GTH2k NIP NIP ?&while POP2 POP2 + JMP2r + +@str "The 20 "first 20 "25 20 "weird 20 "numbers: 00 +@divs diff --git a/Task/Window-creation/PascalABC.NET/window-creation.pas b/Task/Window-creation/PascalABC.NET/window-creation.pas new file mode 100644 index 0000000000..6209d1e8d1 --- /dev/null +++ b/Task/Window-creation/PascalABC.NET/window-creation.pas @@ -0,0 +1,5 @@ +uses GraphWPF; + +begin + +end. diff --git a/Task/Wireworld/11l/wireworld.11l b/Task/Wireworld/11l/wireworld.11l index 6ea83c817c..b6191e28d2 100644 --- a/Task/Wireworld/11l/wireworld.11l +++ b/Task/Wireworld/11l/wireworld.11l @@ -11,14 +11,7 @@ V w = . . Ht.. ......’ -T WW - [[Char]] world - Int w - Int h - F (world, w, h) - .world = world - .w = w - .h = h +T WW = ([[Char]] world, Int w, Int h) F readfile(f) V world = f.map(row -> row.rtrim(Array[Char]("\r\n"))) diff --git a/Task/Word-frequency/PascalABC.NET/word-frequency.pas b/Task/Word-frequency/PascalABC.NET/word-frequency.pas new file mode 100644 index 0000000000..759f414c6a --- /dev/null +++ b/Task/Word-frequency/PascalABC.NET/word-frequency.pas @@ -0,0 +1,3 @@ +## +ReadAllText('135-0.txt').ToLower.MatchValues('\w+').EachCount + .OrderByDescending(w -> w.Value).Take(10).PrintLines diff --git a/Task/Word-ladder/APL/word-ladder.apl b/Task/Word-ladder/APL/word-ladder.apl new file mode 100644 index 0000000000..8138277c6e --- /dev/null +++ b/Task/Word-ladder/APL/word-ladder.apl @@ -0,0 +1,23 @@ +wordladder←{ + from to←⍵ + dict←((≢¨⍺)=≢to)/⍺ + + dict{ + match←(⊂to)≡¨⊃∘⌽¨⍵ + ∨/match:⊃match/⍵ + 0∊≢¨⍺⍵:⍬ + word←⊃⌽ladder←⊃⍵ + next←(1=⍺+.≠¨⊂word)/⍺ + (⍺~next)∇(1↓⍵),(⊂ladder),¨⊂¨next + }⊂⊂from +} +task←{ + dict←(~dict∊⎕TC)⊆dict←⊃⎕NGET'unixdict.txt' + pairs←('boy' 'man')('girl' 'lady')('john' 'jane')('child' 'adult') + ⎕←↑↑{ + hdr←⍺,' → ',⍵,': ' + ladder←dict wordladder ⍺ ⍵ + 0=≢ladder:hdr,'impossible' + hdr,1↓∊'→',¨ladder + }/¨pairs +} diff --git a/Task/Word-ladder/Ada/word-ladder.ada b/Task/Word-ladder/Ada/word-ladder.ada new file mode 100644 index 0000000000..1baca530f6 --- /dev/null +++ b/Task/Word-ladder/Ada/word-ladder.ada @@ -0,0 +1,146 @@ +pragma Ada_2022; +with Ada.Containers.Multiway_Trees; +with Ada.Containers.Vectors; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; +procedure Word_Ladder is + + DICT_FILENAME : constant String := "unixdict.txt"; + MAX_DEPTH : constant Positive := 50; + + subtype LC_Chars is Character range 'a' .. 'z'; + + type Word_Node_T is record + Level : Positive; + Word : Unbounded_String; + end record; + + package Word_Vectors is new Ada.Containers.Vectors (Positive, Unbounded_String); + package Dict_Vectors is new Ada.Containers.Vectors (Positive, Unbounded_String); + + package Word_Trees is new Ada.Containers.Multiway_Trees (Word_Node_T); + use Word_Trees; + Word_Tree : Tree; + Solved : Boolean; + Solution : Cursor; + + function Load_Candidate_Words (Dict_Filename : String; Word_Len : Positive) + return Dict_Vectors.Vector is + Dict_File : File_Type; + Read_Word : Unbounded_String; + Cands : Dict_Vectors.Vector; + Valid : Boolean; + C : Character; + begin + Open (File => Dict_File, Mode => In_File, Name => Dict_Filename); + while not End_Of_File (Dict_File) loop + Read_Word := Get_Line (Dict_File); + if Length (Read_Word) = Word_Len then + Valid := True; + for Ix in 1 .. Word_Len loop + C := Element (Read_Word, Ix); + Valid := C in LC_Chars; + exit when not Valid; + end loop; + if Valid then Cands.Append (Read_Word); end if; + end if; + end loop; + Close (Dict_File); + return Cands; + end Load_Candidate_Words; + + function Mutate (Word : Unbounded_String; Dict : in out Dict_Vectors.Vector) + return Word_Vectors.Vector is + Mutations : Word_Vectors.Vector; + Poss_Word : Unbounded_String; + begin + for Ix in 1 .. Length (Word) loop + for Letter in LC_Chars loop + if Letter /= Element (Word, Ix) then + Poss_Word := Word; + Replace_Element (Poss_Word, Ix, Letter); + if Dict.Contains (Poss_Word) then + Mutations.Append (Poss_Word); + Dict.Delete (Dict.Find_Index (Poss_Word)); + end if; + end if; + end loop; + end loop; + return Mutations; + end Mutate; + + procedure Recurse_Tree (Start_Pos : Cursor; + Level : Positive; + Target : Unbounded_String; + Dict : in out Dict_Vectors.Vector) is + Pos : Cursor := Start_Pos; + Mutations : Word_Vectors.Vector; + New_Node : Word_Node_T; + begin + while not Solved and then Pos /= No_Element loop + if Element (Pos).Level = Level then + Mutations := Mutate (Element (Pos).Word, Dict); + if not Word_Vectors.Is_Empty (Mutations) then + for Word of Mutations loop + New_Node.Level := Level + 1; + New_Node.Word := Word; + Append_Child (Word_Tree, Pos, New_Node); + if Word = Target then + Solved := True; + Solution := Pos; + end if; + end loop; + end if; + end if; + if not Solved then + Recurse_Tree (First_Child (Pos), Level, Target, Dict); + end if; + Pos := Next_Sibling (Pos); + end loop; + end Recurse_Tree; + + procedure Ladder (Start_S, Target_S : String) is + Dictionary : Dict_Vectors.Vector; + Level : Positive := 1; + Word_Node : Word_Node_T; + Start, Target : Unbounded_String; + Start_Pos : Cursor; + Output : Unbounded_String; + begin + if Start_S'Length /= Target_S'Length then + Put_Line ("ERROR: Start and Target words must be same length."); + return; + end if; + Dictionary := Load_Candidate_Words (DICT_FILENAME, Start_S'Length); + Start := To_Unbounded_String (Start_S); + Target := To_Unbounded_String (Target_S); + Solved := False; + Word_Node.Level := 1; + Word_Node.Word := Start; + Word_Tree := Empty_Tree; + Word_Tree.Insert_Child (Word_Tree.Root, No_Element, Word_Node); + Start_Pos := Find (Word_Tree, Word_Node); + while Level <= MAX_DEPTH and then not Solved loop + Recurse_Tree (Start_Pos, Level, Target, Dictionary); + Level := @ + 1; + end loop; + if not Solved then + Put_Line (Start & " -> " & Target & " - No solution found at depth" & MAX_DEPTH'Image); + else + while not Is_Root (Solution) loop + Word_Node := Element (Solution); + Output := Word_Node.Word & " -> " & Output; + Solution := Parent (Solution); + end loop; + Put_Line (Output & Target); + end if; + end Ladder; +begin + Ladder ("boy", "man"); + Ladder ("girl", "lady"); + Ladder ("jane", "john"); + Ladder ("child", "adult"); + Ladder ("ada", "god"); + Ladder ("rust", "hell"); +end Word_Ladder; diff --git a/Task/Word-ladder/Refal/word-ladder.refal b/Task/Word-ladder/Refal/word-ladder.refal new file mode 100644 index 0000000000..4da2fac7e6 --- /dev/null +++ b/Task/Word-ladder/Refal/word-ladder.refal @@ -0,0 +1,95 @@ +$ENTRY Go { + , : e.Dict + = + + + ; +}; + +DisplayLadder { + (e.Dict) (e.From) (e.To), + e.From ' -> ' e.To ': ': e.Header, + : { + Impossible = ; + Result e.Words = ') e.Words>>; + }; +}; + +Join { + (e.Join) = ; + (e.Join) (e.Word) = e.Word; + (e.Join) (e.Word) e.Words = e.Word e.Join ; +}; + +ReadFile { + s.Chan e.File = + + ; + (s.Chan), : { + 0 = ; + e.Line = (e.Line) ; + }; +}; + +Filter { + (e.Fn) = ; + (e.Fn) t.Item e.Items, : { + True = t.Item ; + False = ; + }; +}; + +SameLen { + (e.Word1) (e.Word2), + : s.Len e.Word1, + : s.Len e.Word2 = True; + (e.Word1) (e.Word2) = False; +}; + +Diffs { + () () = 0; + (s.X e.Word1) (s.X e.Word2) = ; + (s.X e.Word1) (s.Y e.Word2) = <+ 1 >; +}; + +OneDiff { + t.Word1 t.Word2, : { + 1 = True; + s.Diffs = False; + }; +}; + +Ladder { + (e.Dict) t.From t.To, + : e.Dict2 = + ; +}; + +Ladder2 { + (e.Ladders) (e.Dict) t.To, + e.Ladders: e.X (e.Words t.To) e.Y = Result e.Words t.To; + + (e.Ladders) () t.To = Impossible; + () (e.Dict) t.To = Impossible; + + ((e.Ladder) e.Ladders) (e.Dict) t.To, + e.Ladder: e.1 t.Last, + : e.NextWords, + : e.NextDict, + : e.NextLadders + = ; +}; + +RemoveAll { + (e.Remove) = ; + (e.Remove) t.Word e.Words, e.Remove: { + e.X t.Word e.Y = ; + e.Remove = t.Word ; + }; +}; + +AddAll { + (e.Ladder) = ; + (e.Ladder) t.Word e.Words = + (e.Ladder t.Word) ; +}; diff --git a/Task/Word-ladder/SETL/word-ladder.setl b/Task/Word-ladder/SETL/word-ladder.setl new file mode 100644 index 0000000000..200d0c2766 --- /dev/null +++ b/Task/Word-ladder/SETL/word-ladder.setl @@ -0,0 +1,45 @@ +program word_ladder; + dict := read_dictionary("unixdict.txt"); + testpairs := [['boy', 'man'], ['girl', 'lady'], ['john', 'jane'], ['child', 'adult']]; + + loop for [fromWord, toWord] in testpairs do + l := ladder(dict, fromWord, toWord); + if l = om then + print(fromWord, '->', toWord, 'impossible'); + else + print(fromWord, '->', toWord, l); + end if; + end loop; + + proc ladder(dict, fromWord, toWord); + dict := {word : word in dict | #word = #fromWord}; + ladders := [[fromWord]]; + dict less:= fromWord; + loop while ladders /= [] do + l fromb ladders; + next := {word : word in onediff(dict, l(#l))}; + dict -:= next; + nextls := [l + [word] : word in next]; + if exists l in nextls | l(#l) = toWord then + return l; + end if; + ladders +:= nextls; + end loop; + return om; + end proc; + + proc onediff(rw dict, word); + return {other : other in dict | #other = #word and diffs(word, other) = 1}; + end proc; + + proc diffs(word1, word2); + return +/[if word1(i) = word2(i) then 0 else 1 end : i in [1..#word1]]; + end proc; + + proc read_dictionary(file); + dictfile := open(file, 'r'); + dict := {getline(dictfile) : until eof(dictfile)}; + close(dictfile); + return dict; + end proc; +end program; diff --git a/Task/Word-search/Ada/word-search.ada b/Task/Word-search/Ada/word-search.ada new file mode 100644 index 0000000000..712854b9c1 --- /dev/null +++ b/Task/Word-search/Ada/word-search.ada @@ -0,0 +1,259 @@ +pragma Ada_2022; +with Ada.Containers; use Ada.Containers; +with Ada.Containers.Vectors; +with Ada.Numerics.Discrete_Random; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; + +procedure Word_Search is + + MIN_WORDS : constant Positive := 25; + MIN_WORD_LEN : constant Positive := 3; + MAX_WORD_LEN : constant Positive := 9; + SIDE_LEN : constant Positive := 10; + MESSAGE : constant String := "ROSETTACODE"; + DICT_FILENAME : constant String := "unixdict.txt"; + + type Directions is (N, NE, E, SE, S, SW, W, NW); + type Move is record + DX, DY : Integer; + end record; + type Moves_Arr is array (Directions) of Move; + Moves : constant Moves_Arr := [ + N => (0, -1), NE => (1, -1), E => (1, 0), SE => (1, 1), + S => (0, 1), SW => (-1, 1), W => (-1, 0), NW => (-1, -1) + ]; + subtype Grid_Dimension is Positive range 1 .. SIDE_LEN; + type Matrix is array (Grid_Dimension, Grid_Dimension) of Character; + subtype LC_Chars is Character range 'a' .. 'z'; + subtype Valid_Lengths is Positive range MIN_WORD_LEN .. MAX_WORD_LEN; + + package Word_Vectors is new Ada.Containers.Vectors (Positive, Unbounded_String); + type Dictionary is array (Valid_Lengths) of Word_Vectors.Vector; + Dict : Dictionary; + + type Placement is record + Word : Unbounded_String; + Start : Unbounded_String; + end record; + package Placement_Vectors is new Ada.Containers.Vectors (Positive, Placement); + Placings : Placement_Vectors.Vector; + + subtype Ten_K is Positive range 1 .. 10000; + package Rand_Dimension is new Ada.Numerics.Discrete_Random (Grid_Dimension); + package Rand_Dir is new Ada.Numerics.Discrete_Random (Directions); + package Rand_Len is new Ada.Numerics.Discrete_Random (Valid_Lengths); + package Rand_10k is new Ada.Numerics.Discrete_Random (Ten_K); + Dimension_Gen : Rand_Dimension.Generator; + Dir_Gen : Rand_Dir.Generator; + Len_Gen : Rand_Len.Generator; + Ten_K_Gen : Rand_10k.Generator; + + procedure Load_Dictionary (Filename : String) is + Dict_File : File_Type; + Dict_Word : Unbounded_String; + Dict_Word_Len : Positive; + Word_OK : Boolean; + begin + Open (File => Dict_File, Mode => In_File, Name => Filename); + while not End_Of_File (Dict_File) loop + Dict_Word := Get_Line (Dict_File); + Dict_Word_Len := Length (Dict_Word); + if Dict_Word_Len >= MIN_WORD_LEN and then + Dict_Word_Len <= MAX_WORD_LEN + then + Word_OK := True; + for C of To_String (Dict_Word) loop + if C not in LC_Chars then + Word_OK := False; + exit; + end if; + end loop; + if Word_OK then + Dict (Dict_Word_Len).Append (Dict_Word); + end if; + end if; + end loop; + end Load_Dictionary; + + function Pick_Random_Word return Unbounded_String is + Word_Length : Positive := Rand_Len.Random (Len_Gen); + Rand : constant Natural := Rand_10k.Random (Ten_K_Gen); + Word_Ix : Positive; + begin + Word_Length := Rand_Len.Random (Len_Gen); + if Word_Length > 4 then -- Reduce number of words > 4 chars + Word_Length := Rand_Len.Random (Len_Gen); + end if; + Word_Ix := Positive (Rand) mod (Positive (Dict (Word_Length).Length) - 1) + 1; + return Dict (Word_Length) (Word_Ix); + end Pick_Random_Word; + + function Not_Too_Long (X, Y : Grid_Dimension; Len : Positive; Dir : Directions) return Boolean is + begin + case Dir is + when N => return Y - Len > 0; + when S => return Y + Len <= SIDE_LEN; + when E => return X + Len <= SIDE_LEN; + when W => return X - Len > 0; + when NE => return X + Len <= SIDE_LEN and then Y - Len > 0; + when SW => return Y + Len <= SIDE_LEN and then X - Len > 0; + when SE => return Y + Len <= SIDE_LEN and then X + Len <= SIDE_LEN; + when NW => return Y - Len > 0 and then X - Len > 0; + end case; + end Not_Too_Long; + + function Is_Empty (G : Matrix; Row, Col : Positive) return Boolean is + (G (Row, Col) = ' '); + + function Count_Empties (G : Matrix) return Natural is + Count : Natural := 0; + begin + for Row in Grid_Dimension loop + for Col in Grid_Dimension loop + Count := Count + (if Is_Empty (G, Row, Col) then 1 else 0); + end loop; + end loop; + return Count; + end Count_Empties; + + function Can_Place (G : Matrix; X, Y : Grid_Dimension; Word : Unbounded_String; Dir : Directions) + return Boolean is + GX : Grid_Dimension := X; + GY : Grid_Dimension := Y; + Len : constant Positive := Length (Word); + begin + for C in 1 .. Len loop + if not Is_Empty (G, GX, GY) and then + G (GX, GY) /= Element (Word, C) + then + return False; + else + GX := GX + Moves (Dir).DX; + GY := GY + Moves (Dir).DY; + end if; + end loop; + return True; + end Can_Place; + + procedure Insert_Word (G : in out Matrix; + X, Y : Grid_Dimension; + Dir : Directions; + Word : Unbounded_String) is + -- We assume it fits. You've checked first haven't you! + GX : Grid_Dimension := X; + GY : Grid_Dimension := Y; + begin + for C in 1 .. Length (Word) loop + G (GX, GY) := Element (Word, C); + GX := GX + Moves (Dir).DX; + GY := GY + Moves (Dir).DY; + end loop; + end Insert_Word; + + function Try_To_Place_Word (G : in out Matrix; Word : Unbounded_String; Max_Tries : Positive) + return Boolean is + -- Attempt to place the given word in the grid, return success or failure. + X1, Y1 : Grid_Dimension; + Dir : Directions; + Try : Positive := 1; + Place : Placement; + begin + while Try <= Max_Tries loop + X1 := Rand_Dimension.Random (Dimension_Gen); + Y1 := Rand_Dimension.Random (Dimension_Gen); + Dir := Rand_Dir.Random (Dir_Gen); + if Not_Too_Long (X1, Y1, Length (Word), Dir) and then + Can_Place (G, X1, Y1, Word, Dir) + then + Insert_Word (G, X1, Y1, Dir, Word); + Place.Word := Word; + Place.Start := To_Unbounded_String (X1'Image & LC_Chars'Val (Integer (Y1) + 64)); + Placings.Append (Place); + return True; + end if; + Try := Try + 1; + end loop; + return False; + end Try_To_Place_Word; + + procedure Print_Matrix (M : Matrix) is + begin + Put_Line (" A B C D E F G H I J"); New_Line; + for Row in Grid_Dimension loop + Put (Row'Image); + Set_Col (6); + for Col in Grid_Dimension loop + Put (M (Row, Col) & " "); + end loop; + New_Line; + end loop; + New_Line; + end Print_Matrix; + + function Place_Message (G : in out Matrix; Msg : String) return Boolean is + -- Attempt to put message in grid, return False if unable. + Msg_Posn : Positive := 1; + begin + for Row in Grid_Dimension loop + for Col in Grid_Dimension loop + if Is_Empty (G, Row, Col) then + G (Row, Col) := Msg (Msg_Posn); + if Msg_Posn = Msg'Length then + return True; + else + Msg_Posn := Msg_Posn + 1; + end if; + end if; + end loop; + end loop; + return False; + end Place_Message; + + Grid : Matrix; + Words_Placed : Natural; + Message_Placed : Boolean; + A_Word : Unbounded_String; + Attempt : Positive; + Col : Positive_Count := 1; +begin + Load_Dictionary (DICT_FILENAME); + Rand_Dimension.Reset (Dimension_Gen); + Rand_Dir.Reset (Dir_Gen); + Rand_Len.Reset (Len_Gen); + Rand_10k.Reset (Ten_K_Gen); + loop + Grid := [others => [others => ' ']]; + Words_Placed := 0; Message_Placed := False; Placings.Clear; + Attempt := 1; + Builder : + loop + A_Word := Pick_Random_Word; + if Try_To_Place_Word (Grid, A_Word, 50) then + Words_Placed := @ + 1; + end if; + if Count_Empties (Grid) = MESSAGE'Length then + if Place_Message (Grid, MESSAGE) then + Message_Placed := True; + exit Builder; + end if; + elsif Count_Empties (Grid) < MESSAGE'Length then + -- Put_Line ("No room for message, giving up."); + exit Builder; + elsif Attempt > 1000 then + Put_Line ("Giving up after 1000 tries."); + exit Builder; + end if; + Attempt := Attempt + 1; + end loop Builder; + exit when Words_Placed >= MIN_WORDS and then Message_Placed; + end loop; + Print_Matrix (Grid); + Put_Line ("Words placed:" & Words_Placed'Image); + for P of Placings loop + Set_Col (Col); Put (P.Word); + Set_Col (Col + 9); Put (P.Start); + Col := (if Col < 61 then Col + 20 else 1); + end loop; +end Word_Search; diff --git a/Task/Word-wheel/Ada/word-wheel.ada b/Task/Word-wheel/Ada/word-wheel.ada new file mode 100644 index 0000000000..73db7574e6 --- /dev/null +++ b/Task/Word-wheel/Ada/word-wheel.ada @@ -0,0 +1,56 @@ +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; +procedure Wordwheel is + Compulsory_Ix : constant Positive := 5; + Min_Length : constant Positive := 3; + + function Char_Posn (Str : Unbounded_String; C : Character) return Natural is + begin + for Ix in 1 .. Length (Str) loop + if Element (Str, Ix) = C then + return Ix; + end if; + end loop; + return 0; + end Char_Posn; + + procedure Search (Dict_Filename : String; Wheel : String) is + Dict_File : File_Type; + Allowed : constant String := To_Lower (Wheel); + Required_Char : constant String (1 .. 1) := "" & Allowed (Compulsory_Ix); + Available, Dict_Word : Unbounded_String; + Dict_Word_Len : Positive; + Matched : Boolean; + Posn : Natural; + begin + Open (File => Dict_File, Mode => In_File, Name => Dict_Filename); + while not End_Of_File (Dict_File) loop + Dict_Word := Get_Line (Dict_File); + Dict_Word_Len := Length (Dict_Word); + if Dict_Word_Len >= Min_Length and then + Dict_Word_Len <= Wheel'Length and then + Ada.Strings.Unbounded.Count (Dict_Word, Required_Char) > 0 + then + Available := To_Unbounded_String (Allowed); + Matched := True; + for i in 1 .. Dict_Word_Len loop + Posn := Char_Posn (Available, Element (Dict_Word, i)); + if Posn > 0 then + Delete (Source => Available, From => Posn, Through => Posn); + else + Matched := False; + exit; + end if; + end loop; + if Matched then + Put_Line (Dict_Word); + end if; + end if; + end loop; + Close (Dict_File); + end Search; +begin + Search ("unixdict.txt", "ndeokgelw"); +end Wordwheel; diff --git a/Task/Word-wheel/Lua/word-wheel.lua b/Task/Word-wheel/Lua/word-wheel-1.lua similarity index 100% rename from Task/Word-wheel/Lua/word-wheel.lua rename to Task/Word-wheel/Lua/word-wheel-1.lua diff --git a/Task/Word-wheel/Lua/word-wheel-2.lua b/Task/Word-wheel/Lua/word-wheel-2.lua new file mode 100644 index 0000000000..15ec4ccda0 --- /dev/null +++ b/Task/Word-wheel/Lua/word-wheel-2.lua @@ -0,0 +1,15 @@ +-- Algorithm is from Ruby implementation. +local wheel = arg[1] or 'ndeoKgelw' -- wheel is 1st argument +wheel = wheel:lower() +local middle = wheel:sub(5, 5) +assert(#middle == 1) +for line in io.lines() do -- get dictionary from standard input + local word = line:lower() + if word:find(middle) and #word >= 3 then + for wheel_char in wheel:gmatch('.') do + word = word:gsub(wheel_char, '', 1) + end -- for + if #word == 0 then io.write(line:lower() .. ' ') end + end -- if +end -- for +print '' diff --git a/Task/Word-wrap/PascalABC.NET/word-wrap.pas b/Task/Word-wrap/PascalABC.NET/word-wrap.pas new file mode 100644 index 0000000000..08a58e9720 --- /dev/null +++ b/Task/Word-wrap/PascalABC.NET/word-wrap.pas @@ -0,0 +1,40 @@ +function Wrap(words: sequence of string; lineWidth: integer): sequence of string; +begin + var currentWidth := 0; + foreach var word in words do + begin + if currentWidth <> 0 then + if currentWidth + word.Length < lineWidth then + begin + currentWidth += 1; + yield ' '; + end + else + begin + currentWidth := 0; + yield NewLine; + end; + currentWidth += word.Length; + yield word; + end; +end; + +function Wrap(text: string; lineWidth: integer): string + := Wrap(text.ToWords(' '#13#10),lineWidth).JoinToString(''); + +begin + var text := ''' +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius sapien +vel purus hendrerit vehicula. Integer hendrerit viverra turpis, ac sagittis arcu +pharetra id. Sed dapibus enim non dui posuere sit amet rhoncus tellus +consectetur. Proin blandit lacus vitae nibh tincidunt cursus. Cum sociis natoque +penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam tincidunt +purus at tortor tincidunt et aliquam dui gravida. Nulla consectetur sem vel +felis vulputate et imperdiet orci pharetra. Nam vel tortor nisi. Sed eget porta +tortor. Aliquam suscipit lacus vel odio faucibus tempor. Sed ipsum est, +condimentum eget eleifend ac, ultricies non dui. Integer tempus, nunc sed +venenatis feugiat, augue orci pellentesque risus, nec pretium lacus enim eu +nibh. +'''; + Wrap(text,50).Println; +end. diff --git a/Task/Wordiff/Jq/wordiff.jq b/Task/Wordiff/Jq/wordiff.jq new file mode 100644 index 0000000000..c0cec7cb3b --- /dev/null +++ b/Task/Wordiff/Jq/wordiff.jq @@ -0,0 +1,108 @@ +include "MRG32k3a" {search: "."}; # see comment above + +### Generic functions + +# Determine if stream is non-decreasing +def is_sorted(stream): + first(foreach stream as $s ( null; + if . == null or $s >= .[0] then [$s] + else 0 + end; + select(. == 0) ) ) + // 1 + | . == 1; + +# Write to stderr +def inform(msg): + . as $in + | ("\(msg)\n" | stderr) + | $in; + +# q means quit +def read($prompt; $regex): + def r: + ($prompt | stderr | empty), + (try ((input + | if . == "q" then halt + else select(test($regex)) + end) // r) + catch if . == "break" then halt else r end ); + r; + +# Returns levenshteinDistance(s1; $s2) <= $max +# A recursive algorithm is good enough if $max is small +def levenshteinDistance($s1; $s2; $max): + def lev: + . as [$s1, $s2, $max] + | if ($s1|length) == 0 then ($s2|length) <= $max + elif ($s2|length) == 0 then ($s1|length) <= $max + elif $s1[:1] == $s2[:1] + then [$s1[1:], $s2[1:], $max] | lev + else ($s1|length) <= $max + or ($s2|length) <= $max + or ([$s1[1:], $s2, $max-1] | lev) + or ([$s1, $s2[1:], $max-1] | lev) + or ([$s1[1:], $s2[1:], $max-1] | lev) + end ; + [$s1, $s2, $max] | lev; + +##### The Wordiff Game + +# Output: the sorted list of words +# The sort is skipped if we can readily determine the list is already sorted +def words: + [$dict | splits(" *\n *")] + | if is_sorted(.[]) then . + else sort + end; + +def player1: read("Player 1, please enter your name : "; "."); +def player2: read("Player 2, please enter your name : "; "."); + +def round: + .words as $words + | read("\(.player), enter your word: "; ".") as $word + | ($word|length) as $len + | .ok = false + | if $len < 3 + then inform("Words must be at least three letters long.") + elif $word == .prevWord + then inform("You must change the previous word.") + elif .used[$word] + then inform("The word \"\($word)\" has been used before.") + elif # not in dictionary + # if $words is not sorted: ($word | IN($words[]) | not) + # binary search: + ($words | bsearch($word) < 0) + then inform("Not in dictionary.") + + elif levenshteinDistance($word; .prevWord; 1) + #### Good to go + then .ok = true + | .prevLen = ($word|length) + | .prevWord = $word + | .used[$word] = true + | .player = (if .player == .player1 then .player2 else .player1 end) + else inform("Sorry. Only one addition, deletion or alteration is allowed.") + end + | if (.ok|not) then inform("Please retry. The current word is: \(.prevWord)") end + | round ; + +def play: + player1 as $player1 + | { player1: $player1, + player2: ( player2 | if . == $player1 then . + "2" else . end) + } + | inform("Reading and perhaps sorting the list of words takes a few seconds... ") + | inform("Meanwhile note that you can quit by entering q at a prompt.") + | .words = words + # Avoid storing the subset of words needed to make a random selection: + | (.words | map(select(length | IN(3,4))) | .[length | prn(1)[]]) as $firstWord + | .prevLen = ($firstWord|length) + | .prevWord = $firstWord + | .used = {($firstWord): true} # a JSON object for efficiency + | .player = .player1 + | "\nThe first word is: \($firstWord)", + round; + +play diff --git a/Task/Write-entire-file/PascalABC.NET/write-entire-file.pas b/Task/Write-entire-file/PascalABC.NET/write-entire-file.pas new file mode 100644 index 0000000000..7039e6432a --- /dev/null +++ b/Task/Write-entire-file/PascalABC.NET/write-entire-file.pas @@ -0,0 +1,2 @@ +## +WriteAllText('a.txt','string'); diff --git a/Task/Write-to-Windows-event-log/FreeBASIC/write-to-windows-event-log.basic b/Task/Write-to-Windows-event-log/FreeBASIC/write-to-windows-event-log.basic new file mode 100644 index 0000000000..249367b5b2 --- /dev/null +++ b/Task/Write-to-Windows-event-log/FreeBASIC/write-to-windows-event-log.basic @@ -0,0 +1,36 @@ +Dim As String argV(1 To 5) +Dim Shared As String t() + +Sub Split (cadena As String, t() As String, sep As String = " ") + Dim As Integer i, j = 0 + Dim As String word = "" + For i = 1 To Len(cadena) + If Mid(cadena, i, 1) <> sep Then + word &= Mid(cadena, i, 1) + Else + Redim Preserve t(j) + t(j) = word + word = "" + j += 1 + End If + Next i + If word <> "" Then + Redim Preserve t(j) + t(j) = word + End If +End Sub + +Split(Command, t()) + +#ifdef __FB_WIN32__ + If Ubound(t) <> 3 Then + Print "Usage: "; Command(0); " " + Else + For i As Integer = 1 To 4 + argV(i) = t(i-1) + Next i + Shell "EventCreate /t " & argV(1) & " /id " & argV(2) & " /l APPLICATION /so " & argV(3) & " /d """ & argV(4) & """" + End If +#else + Print "Not implemented for *nix, only Windows." +#endif diff --git a/Task/Write-to-Windows-event-log/PascalABC.NET/write-to-windows-event-log.pas b/Task/Write-to-Windows-event-log/PascalABC.NET/write-to-windows-event-log.pas new file mode 100644 index 0000000000..ea94fb0698 --- /dev/null +++ b/Task/Write-to-Windows-event-log/PascalABC.NET/write-to-windows-event-log.pas @@ -0,0 +1,7 @@ +uses System.Diagnostics; + +begin + if not EventLog.SourceExists('MyApp') then + EventLog.CreateEventSource('MyApp', 'Application'); + EventLog.WriteEntry('MyApp', 'Hello from PABC!'); +end. diff --git a/Task/XML-DOM-serialization/PascalABC.NET/xml-dom-serialization.pas b/Task/XML-DOM-serialization/PascalABC.NET/xml-dom-serialization.pas new file mode 100644 index 0000000000..5e75bd8059 --- /dev/null +++ b/Task/XML-DOM-serialization/PascalABC.NET/xml-dom-serialization.pas @@ -0,0 +1,19 @@ +{$reference System.Xml.Serialization.dll} +{$reference System.Xml.dll} +uses System.Xml; +uses System.Xml.Serialization; + +type + [XmlRoot('root')] + ExampleXML = class + public + [XmlElementAttribute('element')] + element := 'My text'; + end; + +begin + var xmlnamespace := new XmlSerializerNamespaces(); + xmlnamespace.Add('', ''); + var writer := XmlWriter.Create('output.xml'); + (new XmlSerializer(typeof(ExampleXML))).Serialize(writer, new ExampleXML(), xmlnamespace); +end. diff --git a/Task/XML-Input/PascalABC.NET/xml-input.pas b/Task/XML-Input/PascalABC.NET/xml-input.pas new file mode 100644 index 0000000000..d1feafbcee --- /dev/null +++ b/Task/XML-Input/PascalABC.NET/xml-input.pas @@ -0,0 +1,20 @@ +{$reference System.Xml.Linq.dll} +{$reference System.Xml.XDocument.dll} +uses System.Xml.Linq; + +begin + var XMLText := ''' + + + + + + + + + + '''; + var xmlDoc := XDocument.Parse(XMLText); + var q := xmlDoc.Descendants('Student').Select(p -> p.Attribute('Name')); + q.PrintLines(item -> item.Value); +end. diff --git a/Task/XML-Input/Vim-Script/xml-input.vim b/Task/XML-Input/Vim-Script/xml-input.vim new file mode 100644 index 0000000000..fff3a4844a --- /dev/null +++ b/Task/XML-Input/Vim-Script/xml-input.vim @@ -0,0 +1,9 @@ +let students_xml = readfile('XML-Input.xml') +call filter(students_xml, 'v:val =~ " substitute(val, s:s_pat, s:s_sub, 'g')}) +let s:s_pat = '\c\v\�*([a-f][[:xdigit:]]|[[:xdigit:]]{3,7});' +let s:s_sub = '\=nr2char(str2nr(submatch(1), 16), 1)' +call map(students_xml, {_, val -> substitute(val, s:s_pat, s:s_sub, 'g')}) +echo students_xml->writefile('XML-input.out.txt') diff --git a/Task/XML-Output/PascalABC.NET/xml-output.pas b/Task/XML-Output/PascalABC.NET/xml-output.pas new file mode 100644 index 0000000000..fb0e205c2e --- /dev/null +++ b/Task/XML-Output/PascalABC.NET/xml-output.pas @@ -0,0 +1,20 @@ +{$reference System.Xml.Linq.dll} +{$reference System.Xml.XDocument.dll} +uses System.Xml.Linq; + +function CreateXML(characterRemarks: Dictionary ): string; +begin + var remarks := characterRemarks.Select(r -> new XElement('Character', r.Value, new XAttribute('Name', r.Key))); + var xml := new XElement('CharacterRemarks', remarks); + Result := xml.ToString; +end; + +begin + var characterRemarks := Dict( + ('April', 'Bubbly: I''m > Tam and <= Emily' ), + ( 'Tam O''Shanter', 'Burns: "When chapman billies leave the street ..."' ), + ( 'Emily', 'Short & shrift' ) + ); + var xml := CreateXML(characterRemarks); + Writeln(xml); +end. diff --git a/Task/Yellowstone-sequence/C-sharp/yellowstone-sequence.cs b/Task/Yellowstone-sequence/C-sharp/yellowstone-sequence.cs new file mode 100644 index 0000000000..c5c8c580aa --- /dev/null +++ b/Task/Yellowstone-sequence/C-sharp/yellowstone-sequence.cs @@ -0,0 +1,73 @@ +internal class Program +{ + private static void Main(string[] args) + { + List yellowStoneList = YellowstoneSequence(30); + + Console.WriteLine("Yellowstone 30"); + + foreach (int i in yellowStoneList) + { + Console.Write(i + " "); + } + } + + private static List YellowstoneSequence(int sequenceCount) + { + List yellowstoneList = [1, 2, 3]; + int num = 4; + List notYellowstoneList = new(); + int yellowSize = 3; + + while (yellowSize < sequenceCount) + { + int found = -1; + + for (int index = 0; index < notYellowstoneList.Count; index++) + { + int test = notYellowstoneList[index]; + + if (GCD(yellowstoneList[yellowSize - 2], test) > 1 && GCD(yellowstoneList[yellowSize - 1], test) == 1) + { + found = index; + break; + } + } + + if (found >= 0) + { + yellowstoneList.Add(notYellowstoneList[found]); + notYellowstoneList.RemoveAt(found); + yellowSize++; + } + else + { + while (true) + { + if (GCD(yellowstoneList[yellowSize - 2], num) > 1 && GCD(yellowstoneList[yellowSize - 1], num) == 1) + { + yellowstoneList.Add(num); + yellowSize++; + num++; + break; + } + + notYellowstoneList.Add(num); + num++; + } + } + } + + return yellowstoneList; + } + + private static int GCD(int a, int b) + { + if (b == 0) + { + return a; + } + + return GCD(b, a % b); + } +} diff --git a/Task/Yellowstone-sequence/Uiua/yellowstone-sequence.uiua b/Task/Yellowstone-sequence/Uiua/yellowstone-sequence.uiua new file mode 100644 index 0000000000..05925645dc --- /dev/null +++ b/Task/Yellowstone-sequence/Uiua/yellowstone-sequence.uiua @@ -0,0 +1,6 @@ +Gcd ← ⊙◌⍢(⟜◿:|±,) +NextY ← ⍢(+1|⟨¬≍0_1≡(=1Gcd)⊙(↙¯2)|1⟩∊,,)1 # [a0 a1...an] -> an+1 +N ← 200 +⍢(⊂:NextY| - enum Colour, Nationality, Drink, Smoke, Pet - constant Colours = {"red","white","green","yellow","blue"}, - Nationalities = {"English","Swede","Dane","Norwegian","German"}, - Drinks = {"tea","coffee","milk","beer","water"}, - Smokes = {"Pall Mall","Dunhill","Blend","Blue Master","Prince"}, - Pets = {"dog","birds","cats","horse","zebra"}, - Sets = {Colours,Nationalities,Drinks,Smokes,Pets} +--enum colour, nationality, drink, smoke, pet -- (now implicit) +enum red,white,green,yellow,blue +enum English,Swede,Dane,Norwegian,German +enum tea,coffee,milk,beer,water +enum PallMall,Dunhill,Blend,BlueMaster,Prince +enum dog,birds,cats,horse,zebra - constant tagset5 = tagset(5) -- {1,2,3,4,5}, oft-permuted - sequence perm = repeat(tagset5,5) -- perm[1] is Colour of each house, etc +constant colours = {"red","white","green","yellow","blue"}, + nationalities = {"English","Swede","Dane","Norwegian","German"}, + drinks = {"tea","coffee","milk","beer","water"}, + smokes = {"Pall Mall","Dunhill","Blend","Blue Master","Prince"}, + pets = {"dog","birds","cats","horse","zebra"}, + sets = {colours,nationalities,drinks,smokes,pets} - function house(integer i, string name) - return find(find(name,Sets[i]),perm[i]) - end function +constant p5 = permutes(tagset(5)), -- all permutes of {1,2,3,4,5}, + lp = length(p5) -- (== factorial(5), ie 120) - function left_of(integer h1, integer h2) - return (h1-h2)==1 - end function +// In the following, c1,c2 are indexes to p5, for colour..pet, +// and v1,v2 are from their corresponding enums, so eg p5[c1] +// might be {1,4,3,2,5} for the colours of 1..5 and finding +// v1 in that gives us a house number. Checking the specified +// condition, eg [h] == green && [h+1] == white is then easy. - function next_to(integer h1, integer h2) - return abs(h1-h2)==1 - end function +function left_of(integer c1, v1, c2, v2) + integer h = find(v1,p5[c1]) + return h<=4 and p5[c2][h+1]=v2 +end function - procedure print_house(integer i) - printf(1,"%d:%s,%s,%s,%s,%s\n",{i, - Colours[perm[Colour][i]], - Nationalities[perm[Nationality][i]], - Drinks[perm[Drink][i]], - Smokes[perm[Smoke][i]], - Pets[perm[Pet][i]]}) - end procedure +function same_house(integer c1, v1, c2, v2) + integer h = find(v1,p5[c1]) + return p5[c2][h]=v2 +end function - integer solutions = 0 - sequence solperms = {} - atom t0 = time() - constant factorial5 = factorial(5) - for C=1 to factorial5 do - perm[Colour] = permute(C,tagset5) - if left_of(house(Colour,"green"),house(Colour,"white")) then - for N=1 to factorial5 do - perm[Nationality] = permute(N,tagset5) - if house(Nationality,"Norwegian")==1 - and house(Nationality,"English")==house(Colour,"red") - and next_to(house(Nationality,"Norwegian"),house(Colour,"blue")) then - for D=1 to factorial5 do - perm[Drink] = permute(D,tagset5) - if house(Nationality,"Dane")==house(Drink,"tea") - and house(Drink,"coffee")==house(Colour,"green") - and house(Drink,"milk")==3 then - for S=1 to factorial5 do - perm[Smoke] = permute(S,tagset5) - if house(Colour,"yellow")==house(Smoke,"Dunhill") - and house(Nationality,"German")==house(Smoke,"Prince") - and house(Smoke,"Blue Master")==house(Drink,"beer") - and next_to(house(Drink,"water"),house(Smoke,"Blend")) then - for P=1 to factorial5 do - perm[Pet] = permute(P,tagset5) - if house(Nationality,"Swede")==house(Pet,"dog") - and house(Smoke,"Pall Mall")==house(Pet,"birds") - and next_to(house(Smoke,"Blend"),house(Pet,"cats")) - and next_to(house(Pet,"horse"),house(Smoke,"Dunhill")) then - for i=1 to 5 do - print_house(i) - end for - solutions += 1 - solperms = append(solperms,perm) - end if - end for - end if - end for - end if - end for - end if - end for - end if - end for - printf(1,"%d solution%s found (%3.3fs).\n",{solutions,iff(solutions>1,"s",""),time()-t0}) - for i=1 to length(solperms) do - perm = solperms[i] - printf(1,"The %s owns the Zebra\n",{Nationalities[house(Pet,"zebra")]}) - end for -